summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-05-21 09:35:01 +0300
committerAndras Timar <andras.timar@collabora.com>2018-05-23 13:45:36 +0200
commitdcb523dbf09096e7f8f99455292f98139636db3a (patch)
tree289b797a673733d1b0da39b01ac20cd996e76717
parent3790b16318f687b11a1a6453e96e86a48b0e2eb1 (diff)
tdf#115386: Show Mail Merge toolbar for documents with MM fields
Change-Id: I357a30d72c5ac4af8c64b82b4cc61c3bd606940a Reviewed-on: https://gerrit.libreoffice.org/54612 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/54698 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sw/inc/view.hxx1
-rw-r--r--sw/source/uibase/uiview/view.cxx39
2 files changed, 40 insertions, 0 deletions
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index a2321ce13531..a54c6d8e7935 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -250,6 +250,7 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
m_bIsPreviewDoubleClick : 1, // #i114045#
m_bMakeSelectionVisible : 1, // transport the bookmark selection
m_bAnnotationMode; ///< The real cursor position is inside an annotation.
+ bool m_bInitOnceCompleted = false;
/// LibreOfficeKit has to force the page size for PgUp/PgDown
/// functionality based on the user's view, instead of using the m_aVisArea.
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index ea211cf616f5..2e241fc01555 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -221,6 +221,28 @@ IMPL_LINK_NOARG(SwView, FormControlActivated, LinkParamNone*, void)
}
}
+namespace
+{
+uno::Reference<frame::XLayoutManager> getLayoutManager(const SfxViewFrame& rViewFrame)
+{
+ uno::Reference<frame::XLayoutManager> xLayoutManager;
+ uno::Reference<beans::XPropertySet> xPropSet(rViewFrame.GetFrame().GetFrameInterface(),
+ uno::UNO_QUERY);
+ if (xPropSet.is())
+ {
+ try
+ {
+ xLayoutManager.set(xPropSet->getPropertyValue("LayoutManager"), uno::UNO_QUERY);
+ }
+ catch (const Exception& e)
+ {
+ SAL_WARN("sw.ui", "Failure getting layout manager: " + e.Message);
+ }
+ }
+ return xLayoutManager;
+}
+}
+
void SwView::SelectShell()
{
// Attention: Maintain the SelectShell for the WebView additionally
@@ -426,6 +448,21 @@ void SwView::SelectShell()
GetEditWin().SetInputContext( aCntxt );
}
+ // Show Mail Merge toolbar initially for documents with Database fields
+ if (!m_bInitOnceCompleted && GetWrtShell().IsAnyDatabaseFieldInDoc())
+ {
+ auto xLayoutManager = getLayoutManager(*GetViewFrame());
+ if (xLayoutManager.is())
+ {
+ const OUString sResourceURL("private:resource/toolbar/mailmerge");
+ if (!xLayoutManager->getElement(sResourceURL).is())
+ {
+ xLayoutManager->createElement(sResourceURL);
+ xLayoutManager->showElement(sResourceURL);
+ }
+ }
+ }
+
// Activate the toolbar to the new selection which also was active last time.
// Before a flush () must be, but does not affect the UI according to MBA and
// is not a performance problem.
@@ -450,6 +487,8 @@ void SwView::SelectShell()
m_pWrtShell->UpdateTable();
GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
+
+ m_bInitOnceCompleted = true;
}
// Interaction: AttrChangedNotify() and TimeoutHdl.