tdf#109390 Warn about empty New Document only on Apply, not OK

Creating new document type hyperlink shows a warning about empty
file name only when pressing Apply, and closes silently on OK

Change-Id: I00e7b20a12df8e35e154e3cf532067cbad72c614
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127010
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx
index e695ea3..3eef90c 100644
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ b/cui/source/dialogs/cuihyperdlg.cxx
@@ -182,14 +182,16 @@ void SvxHpLinkDlg::Close()
        pViewFrame->ToggleChildWindow(SID_HYPERLINK_DIALOG);
}

void SvxHpLinkDlg::Apply()
void SvxHpLinkDlg::Apply( bool bWarn )
{
    SfxItemSetFixed<SID_HYPERLINK_GETLINK, SID_HYPERLINK_SETLINK> aItemSet( SfxGetpApp()->GetPool() );

    SvxHyperlinkTabPageBase* pCurrentPage = static_cast<SvxHyperlinkTabPageBase*>(
                                                GetTabPage( GetCurPageId() ) );

    if ( pCurrentPage->AskApply() )
    // tdf#109390: only show warning that the dialog was not filled properly
    // if the user pressed Apply
    if ( pCurrentPage->AskApply( bWarn ) )
    {
        pCurrentPage->FillItemSet( &aItemSet );

@@ -205,7 +207,7 @@ void SvxHpLinkDlg::Apply()
/// Click on OK button
IMPL_LINK_NOARG(SvxHpLinkDlg, ClickOkHdl_Impl, weld::Button&, void)
{
    Apply();
    Apply( false );
    m_xDialog->response(RET_OK);
}

@@ -216,7 +218,7 @@ IMPL_LINK_NOARG(SvxHpLinkDlg, ClickOkHdl_Impl, weld::Button&, void)
|************************************************************************/
IMPL_LINK_NOARG(SvxHpLinkDlg, ClickApplyHdl_Impl, weld::Button&, void)
{
    Apply();
    Apply( true );
}

/*************************************************************************
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index 8cf2258..980a10d 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -241,11 +241,11 @@ void SvxHyperlinkNewDocTp::SetInitFocus()
|* Ask page whether an insert is possible
|*
\************************************************************************/
bool SvxHyperlinkNewDocTp::AskApply()
bool SvxHyperlinkNewDocTp::AskApply( bool bShowWarning )
{
    INetURLObject aINetURLObject;
    bool bRet = ImplGetURLObject(m_xCbbPath->get_active_text(), m_xCbbPath->GetBaseURL(), aINetURLObject);
    if ( !bRet )
    if ( !bRet && bShowWarning )
    {
        std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpDialog->getDialog(),
                                                   VclMessageType::Warning, VclButtonsType::Ok,
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index 820d34a..abd7074 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -293,7 +293,7 @@ void SvxHyperlinkTabPageBase::DoApply ()
}

// Ask page whether an insert is possible
bool SvxHyperlinkTabPageBase::AskApply ()
bool SvxHyperlinkTabPageBase::AskApply ( bool /* bShowWarning */ )
{
    // default-implementation
    return true;
diff --git a/cui/source/inc/cuihyperdlg.hxx b/cui/source/inc/cuihyperdlg.hxx
index b43361e..fc94a2c 100644
--- a/cui/source/inc/cuihyperdlg.hxx
+++ b/cui/source/inc/cuihyperdlg.hxx
@@ -106,7 +106,8 @@ private:

    void Activate() override;
    virtual void Close() override;
    void Apply();
    void Apply( bool bWarn );
    bool AskApply (bool bShowWarning);

public:
    SvxHpLinkDlg(SfxBindings* pBindings, SfxChildWindow* pChild, weld::Window* pParent);
diff --git a/cui/source/inc/hldocntp.hxx b/cui/source/inc/hldocntp.hxx
index 95a11dd..7e153d6 100644
--- a/cui/source/inc/hldocntp.hxx
+++ b/cui/source/inc/hldocntp.hxx
@@ -52,7 +52,7 @@ public:

    static std::unique_ptr<IconChoicePage> Create(weld::Container* pWindow, SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet);

    virtual bool        AskApply () override;
    virtual bool        AskApply ( bool bShowWarning ) override;
    virtual void        DoApply () override;

    virtual void        SetInitFocus() override;
diff --git a/cui/source/inc/hltpbase.hxx b/cui/source/inc/hltpbase.hxx
index 2ad0007..0bfb7df 100644
--- a/cui/source/inc/hltpbase.hxx
+++ b/cui/source/inc/hltpbase.hxx
@@ -105,7 +105,7 @@ public:
        mxDocumentFrame = rxDocumentFrame;
    }

    virtual bool AskApply ();
    virtual bool AskApply ( bool bShowWarning );
    virtual void DoApply ();
    virtual void SetInitFocus();
    virtual void SetMarkStr ( const OUString& aStrMark );