summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-07-21 09:52:11 +0200
committerBjörn Michaelsen <bjoern.michaelsen@canonical.com>2016-07-21 09:37:05 +0000
commit20245ba9755e1c0199359c3462eff974f33c1bec (patch)
tree1888857673f9ecd42ca1be1796673212d150140a
parent79fdf19e94cec72b49ec3845ba45a6dd40eead5c (diff)
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@collabora.com> Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r--sw/source/uibase/app/apphdl.cxx66
1 files changed, 39 insertions, 27 deletions
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index 3090ceb85268..ecfeb18c312f 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: