summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-05-26 19:55:49 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-05-29 08:04:20 +0200
commitd7c2667089535d25b8f0ad4f58810ee54552156b (patch)
tree7634cc41a8c4a7c55669e923543f620b94d96d16 /sw
parent255bfc283c531512c93401bb4a23cb617137b864 (diff)
Only show Mail Merge toolbar after wizard finished
The toolbar is not needed while wizard works (since it's modal). This simplifies the logic a little. Also this allows to show the toolbar in the actual document used for mailmerge (e.g., when a new or existing document is used, nit the current one); previously, the toolbar appeared in the document active at the moment of wizard launch remained in that document, and actual document went without the toolbar. Change-Id: I44c45c41f1a3e06cd0fb1930092727b9e08caf74 Reviewed-on: https://gerrit.libreoffice.org/54864 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/app/apphdl.cxx70
1 files changed, 18 insertions, 52 deletions
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index 05efb9d821e4..ac5a40287a4d 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -59,9 +59,7 @@
#include <uinums.hxx>
#include <dbconfig.hxx>
#include <mmconfigitem.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XChild.hpp>
-#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdb/TextConnectionSettings.hpp>
#include <com/sun/star/sdbc/XDataSource.hpp>
@@ -331,8 +329,6 @@ class SwMailMergeWizardExecutor : public salhelper::SimpleReferenceObject
VclPtr<AbstractMailMergeWizard> m_pWizard; // always owner
VclPtr<AbstractMailMergeWizard> m_pWizardToDestroyInCallback;
- bool m_bDestroyMMToolbarOnCancel;
-
DECL_LINK( EndDialogHdl, Dialog&, void );
DECL_LINK( DestroyDialogHdl, void*, void );
DECL_LINK( DestroyWizardHdl, void*, void );
@@ -352,8 +348,7 @@ public:
SwMailMergeWizardExecutor::SwMailMergeWizardExecutor()
: m_pView( nullptr ),
m_pView2Close( nullptr ),
- m_pWizard( nullptr ),
- m_bDestroyMMToolbarOnCancel( false )
+ m_pWizard( nullptr )
{
}
@@ -418,25 +413,6 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
m_pWizard = pFact->CreateMailMergeWizard(*m_pView, xMMConfig);
- 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();
}
@@ -452,21 +428,24 @@ void SwMailMergeWizardExecutor::ExecutionFinished()
SwDBManager* pDbManager = pDoc->GetDBManager();
if (pDbManager)
pDbManager->CommitLastRegistrations();
- }
- // Update Mail Merge controls
- const sal_uInt16 slotIds[] = { FN_MAILMERGE_FIRST_ENTRY,
- FN_MAILMERGE_PREV_ENTRY,
- FN_MAILMERGE_NEXT_ENTRY,
- FN_MAILMERGE_LAST_ENTRY,
- FN_MAILMERGE_CURRENT_ENTRY,
- FN_MAILMERGE_EXCLUDE_ENTRY,
- FN_MAILMERGE_CREATE_DOCUMENTS,
- FN_MAILMERGE_SAVE_DOCUMENTS,
- FN_MAILMERGE_PRINT_DOCUMENTS,
- FN_MAILMERGE_EMAIL_DOCUMENTS,
- 0 };
- m_pView->GetViewFrame()->GetBindings().Invalidate(slotIds);
+ // Show the toolbar
+ m_pView->ShowUIElement("private:resource/toolbar/mailmerge");
+
+ // Update Mail Merge controls
+ const sal_uInt16 slotIds[] = { FN_MAILMERGE_FIRST_ENTRY,
+ FN_MAILMERGE_PREV_ENTRY,
+ FN_MAILMERGE_NEXT_ENTRY,
+ FN_MAILMERGE_LAST_ENTRY,
+ FN_MAILMERGE_CURRENT_ENTRY,
+ FN_MAILMERGE_EXCLUDE_ENTRY,
+ FN_MAILMERGE_CREATE_DOCUMENTS,
+ FN_MAILMERGE_SAVE_DOCUMENTS,
+ FN_MAILMERGE_PRINT_DOCUMENTS,
+ FN_MAILMERGE_EMAIL_DOCUMENTS,
+ 0 };
+ m_pView->GetViewFrame()->GetBindings().Invalidate(slotIds);
+ }
// release/destroy asynchronously
Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) );
@@ -623,19 +602,6 @@ IMPL_LINK_NOARG(SwMailMergeWizardExecutor, CancelHdl, void*, void)
{
auto pViewFrame(xMMConfig->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 hasn't 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 );
- }
- }
}
xMMConfig->Commit();
}