tdf#146612 Drop confirmation question when applying new doc hyperlink
To be consistent with other tabs of the dialog where Apply does
not show a similar question
Change-Id: Id3bced8ec861b7166974da5ad223513dbfec25c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128424
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index e2c56b8..eb7d701 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -76,7 +76,6 @@
#define RID_CUISTR_HYPDLG_MACROACT1 NC_("RID_SVXSTR_HYPDLG_MACROACT1", "Mouse over object")
#define RID_CUISTR_HYPDLG_MACROACT2 NC_("RID_SVXSTR_HYPDLG_MACROACT2", "Trigger hyperlink")
#define RID_CUISTR_HYPDLG_MACROACT3 NC_("RID_SVXSTR_HYPDLG_MACROACT3", "Mouse leaves object")
#define RID_CUISTR_HYPDLG_NOVALIDFILENAME NC_("RID_SVXSTR_HYPDLG_NOVALIDFILENAME", "Please type in a valid file name.")
#define RID_CUISTR_HYPERDLG_FORM_BUTTON NC_("RID_SVXSTR_HYPERDLG_FORM_BUTTON", "Button")
#define RID_CUISTR_HYPERDLG_FROM_TEXT NC_("RID_SVXSTR_HYPERDLG_FROM_TEXT", "Text")
#define RID_CUISTR_HYPERDLG_QUERYOVERWRITE NC_("RID_SVXSTR_HYPERDLG_QUERYOVERWRITE", "The file already exists. Overwrite?")
diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx
index 3eef90c..20c1b1e 100644
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ b/cui/source/dialogs/cuihyperdlg.cxx
@@ -182,32 +182,27 @@ void SvxHpLinkDlg::Close()
pViewFrame->ToggleChildWindow(SID_HYPERLINK_DIALOG);
}
void SvxHpLinkDlg::Apply( bool bWarn )
void SvxHpLinkDlg::Apply()
{
SfxItemSetFixed<SID_HYPERLINK_GETLINK, SID_HYPERLINK_SETLINK> aItemSet( SfxGetpApp()->GetPool() );
SvxHyperlinkTabPageBase* pCurrentPage = static_cast<SvxHyperlinkTabPageBase*>(
GetTabPage( GetCurPageId() ) );
// tdf#109390: only show warning that the dialog was not filled properly
// if the user pressed Apply
if ( pCurrentPage->AskApply( bWarn ) )
{
pCurrentPage->FillItemSet( &aItemSet );
pCurrentPage->FillItemSet( &aItemSet );
const SvxHyperlinkItem *aItem = aItemSet.GetItem(SID_HYPERLINK_SETLINK);
if ( !aItem->GetURL().isEmpty() )
GetDispatcher()->ExecuteList(SID_HYPERLINK_SETLINK,
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { aItem });
const SvxHyperlinkItem *aItem = aItemSet.GetItem(SID_HYPERLINK_SETLINK);
if ( !aItem->GetURL().isEmpty() )
GetDispatcher()->ExecuteList(SID_HYPERLINK_SETLINK,
SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { aItem });
static_cast<SvxHyperlinkTabPageBase*>( GetTabPage( GetCurPageId() ) )->DoApply();
}
static_cast<SvxHyperlinkTabPageBase*>( GetTabPage( GetCurPageId() ) )->DoApply();
}
/// Click on OK button
IMPL_LINK_NOARG(SvxHpLinkDlg, ClickOkHdl_Impl, weld::Button&, void)
{
Apply( false );
Apply();
m_xDialog->response(RET_OK);
}
@@ -218,7 +213,7 @@ IMPL_LINK_NOARG(SvxHpLinkDlg, ClickOkHdl_Impl, weld::Button&, void)
|************************************************************************/
IMPL_LINK_NOARG(SvxHpLinkDlg, ClickApplyHdl_Impl, weld::Button&, void)
{
Apply( true );
Apply();
}
/*************************************************************************
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index 93921c0..c823336 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -234,25 +234,6 @@ void SvxHyperlinkNewDocTp::SetInitFocus()
m_xCbbPath->grab_focus();
}
/*************************************************************************
|*
|* Ask page whether an insert is possible
|*
\************************************************************************/
bool SvxHyperlinkNewDocTp::AskApply( bool bShowWarning )
{
INetURLObject aINetURLObject;
bool bRet = ImplGetURLObject(m_xCbbPath->get_active_text(), m_xCbbPath->GetBaseURL(), aINetURLObject);
if ( !bRet && bShowWarning )
{
std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(mpDialog->getDialog(),
VclMessageType::Warning, VclButtonsType::Ok,
CuiResId(RID_CUISTR_HYPDLG_NOVALIDFILENAME)));
xWarn->run();
}
return bRet;
}
namespace
{
struct ExecuteInfo
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index abd7074..fb64eec 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -292,13 +292,6 @@ void SvxHyperlinkTabPageBase::DoApply ()
// default-implementation : do nothing
}
// Ask page whether an insert is possible
bool SvxHyperlinkTabPageBase::AskApply ( bool /* bShowWarning */ )
{
// default-implementation
return true;
}
// This method would be called from bookmark-window to set new mark-string
void SvxHyperlinkTabPageBase::SetMarkStr ( const OUString& /*aStrMark*/ )
{
diff --git a/cui/source/inc/cuihyperdlg.hxx b/cui/source/inc/cuihyperdlg.hxx
index 2e2b180..b43361e 100644
--- a/cui/source/inc/cuihyperdlg.hxx
+++ b/cui/source/inc/cuihyperdlg.hxx
@@ -106,7 +106,7 @@ private:
void Activate() override;
virtual void Close() override;
void Apply( bool bWarn );
void Apply();
public:
SvxHpLinkDlg(SfxBindings* pBindings, SfxChildWindow* pChild, weld::Window* pParent);
diff --git a/cui/source/inc/hldocntp.hxx b/cui/source/inc/hldocntp.hxx
index 7e153d6..227840f6 100644
--- a/cui/source/inc/hldocntp.hxx
+++ b/cui/source/inc/hldocntp.hxx
@@ -52,7 +52,6 @@ public:
static std::unique_ptr<IconChoicePage> Create(weld::Container* pWindow, SvxHpLinkDlg* pDlg, const SfxItemSet* pItemSet);
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 0bfb7df..e3c399b 100644
--- a/cui/source/inc/hltpbase.hxx
+++ b/cui/source/inc/hltpbase.hxx
@@ -105,7 +105,6 @@ public:
mxDocumentFrame = rxDocumentFrame;
}
virtual bool AskApply ( bool bShowWarning );
virtual void DoApply ();
virtual void SetInitFocus();
virtual void SetMarkStr ( const OUString& aStrMark );