[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Thu Jul 21 14:27:41 UTC 2016
sw/source/uibase/app/apphdl.cxx | 66 +++++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 27 deletions(-)
New commits:
commit 56bba2d5e2de7693db3a523e951dc1852c870758
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 21 09:52:11 2016 +0200
tdf#98798: MM Wizard should not leave MM toolbar visible when canceled
This remembers now the state of the MM toolbar before the MM wizard was
started and reset the visiblity of the toolbar to that state when
canceled.
Change-Id: I390feae3287c10d3d0c93dbfa64037229c5327e2
Reviewed-on: https://gerrit.libreoffice.org/27359
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
(cherry picked from commit 20245ba9755e1c0199359c3462eff974f33c1bec)
Reviewed-on: https://gerrit.libreoffice.org/27370
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index 3090ceb..ecfeb18 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -317,6 +317,7 @@ class SwMailMergeWizardExecutor : public salhelper::SimpleReferenceObject
SwView* m_pView; // never owner
SwView* m_pView2Close; // never owner
AbstractMailMergeWizard* m_pWizard; // always owner
+ bool m_bDestroyMMToolbarOnCancel;
DECL_LINK_TYPED( EndDialogHdl, Dialog&, void );
DECL_LINK_TYPED( DestroyDialogHdl, void*, void );
@@ -337,7 +338,8 @@ public:
SwMailMergeWizardExecutor::SwMailMergeWizardExecutor()
: m_pView( nullptr ),
m_pView2Close( nullptr ),
- m_pWizard( nullptr )
+ m_pWizard( nullptr ),
+ m_bDestroyMMToolbarOnCancel( false )
{
}
@@ -443,6 +445,25 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *pMMConfig);
+ uno::Reference<beans::XPropertySet> xPropSet(m_pView->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY);
+ if (!xPropSet.is())
+ return;
+
+ uno::Reference<frame::XLayoutManager> xLayoutManager;
+ uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ if (!xLayoutManager.is())
+ return;
+
+ const OUString sResourceURL( "private:resource/toolbar/mailmerge" );
+ uno::Reference<ui::XUIElement> xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (!xUIElement.is())
+ {
+ // ensure the mail-merge toolbar is displayed and remember if it was before
+ m_bDestroyMMToolbarOnCancel = true;
+ xLayoutManager->createElement(sResourceURL);
+ xLayoutManager->showElement(sResourceURL);
+ }
ExecuteWizard();
}
@@ -600,8 +621,23 @@ IMPL_LINK_NOARG_TYPED(SwMailMergeWizardExecutor, CancelHdl, void*, void)
pMMConfig->SetTargetView(nullptr);
}
if (pMMConfig->GetSourceView())
- pMMConfig->GetSourceView()->GetViewFrame()->GetFrame().AppearWithUpdate();
-
+ {
+ auto pViewFrame(pMMConfig->GetSourceView()->GetViewFrame());
+ pViewFrame->GetFrame().AppearWithUpdate();
+ uno::Reference<beans::XPropertySet> xPropSet(pViewFrame->GetFrame().GetFrameInterface(), uno::UNO_QUERY);
+ if (xPropSet.is() && m_bDestroyMMToolbarOnCancel)
+ {
+ // hide mailmerge toolbar if it hasnt been there before
+ uno::Reference<frame::XLayoutManager> xLayoutManager;
+ uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
+ aValue >>= xLayoutManager;
+ if (xLayoutManager.is())
+ {
+ const OUString sResourceURL( "private:resource/toolbar/mailmerge" );
+ xLayoutManager->destroyElement( sResourceURL );
+ }
+ }
+ }
pMMConfig->Commit();
}
@@ -685,30 +721,6 @@ void SwModule::ExecOther(SfxRequest& rReq)
// show the mailmerge wizard
rtl::Reference< SwMailMergeWizardExecutor > xEx( new SwMailMergeWizardExecutor );
xEx->ExecuteMailMergeWizard( pArgs );
-
- // show the mailmerge toolbar
- SwView* pView = ::GetActiveView();
- if (!pView)
- return;
-
- uno::Reference<beans::XPropertySet> xPropSet(pView->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY);
- if (!xPropSet.is())
- return;
-
- uno::Reference<frame::XLayoutManager> xLayoutManager;
- uno::Any aValue = xPropSet->getPropertyValue("LayoutManager");
- aValue >>= xLayoutManager;
- if (!xLayoutManager.is())
- return;
-
- const OUString sResourceURL( "private:resource/toolbar/mailmerge" );
- uno::Reference<ui::XUIElement> xUIElement = xLayoutManager->getElement(sResourceURL);
- if (!xUIElement.is())
- {
- // do the work, finally
- xLayoutManager->createElement(sResourceURL);
- xLayoutManager->showElement(sResourceURL);
- }
}
break;
case FN_MAILMERGE_FIRST_ENTRY:
More information about the Libreoffice-commits
mailing list