[Libreoffice-commits] core.git: sw/inc sw/source

Caolán McNamara caolanm at redhat.com
Thu Jul 28 15:43:51 UTC 2016


 sw/inc/view.hxx                 |    3 
 sw/source/uibase/app/apphdl.cxx |  121 +++++++++++++++++++++-------------------
 2 files changed, 66 insertions(+), 58 deletions(-)

New commits:
commit 53423cb1f177369f72938ad45aa8a24568104e8e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 28 16:23:53 2016 +0100

    Resolves: tdf#98793 create a MailMergeConfigItem if toolbar is active...
    
    and one hasn't been set yet via the mail merge wizard. This
    should have the same effect as launching mail merge and cancelling
    it, which is given as the workaround
    
    Change-Id: I9deb8173d2e18ccde705a923a74ef8a1175e9393

diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 66ce27e..c9cccd0 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -614,7 +614,8 @@ public:
     // store MailMerge data while "Back to Mail Merge Wizard" FloatingWindow is active
     // or to support printing
     void   SetMailMergeConfigItem(SwMailMergeConfigItem*  pConfigItem, sal_uInt16 nRestart, bool bIsSource);
-    SwMailMergeConfigItem*  GetMailMergeConfigItem();
+    SwMailMergeConfigItem* GetMailMergeConfigItem();
+    SwMailMergeConfigItem* EnsureMailMergeConfigItem(const SfxItemSet* pArgs = nullptr, sal_uInt16 nWizardRestartPage = 0);
 
     void ExecFormatPaintbrush(SfxRequest &);
     void StateFormatPaintbrush(SfxItemSet &);
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index ecfeb18..20a7948 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -239,7 +239,7 @@ void SwModule::StateOther(SfxItemSet &rSet)
             case FN_MAILMERGE_EMAIL_DOCUMENTS:
             {
                 SwView* pView = ::GetActiveView();
-                SwMailMergeConfigItem* pConfigItem = pView ? pView->GetMailMergeConfigItem() : nullptr;
+                SwMailMergeConfigItem* pConfigItem = pView ? pView->EnsureMailMergeConfigItem() : nullptr;
 
                 // #i51949# hide e-Mail option if e-Mail is not supported
                 // #i63267# printing might be disabled
@@ -263,6 +263,68 @@ void NewXForms( SfxRequest& rReq ); // implementation: below
 
 #if HAVE_FEATURE_DBCONNECTIVITY
 
+SwMailMergeConfigItem* SwView::EnsureMailMergeConfigItem(const SfxItemSet* pArgs, sal_uInt16 nWizardRestartPage)
+{
+    // create if it does not exist yet
+    SwMailMergeConfigItem* pMMConfig = GetMailMergeConfigItem();
+    if (!pMMConfig)
+    {
+        pMMConfig = new SwMailMergeConfigItem;
+        pMMConfig->SetSourceView(this);
+
+        //set the first used database as default source on the config item
+        const SfxPoolItem* pItem = nullptr;
+        if (pArgs && SfxItemState::SET == pArgs->GetItemState(
+               FN_PARAM_DATABASE_PROPERTIES, false, &pItem))
+        {
+            //mailmerge has been called from the database beamer
+            uno::Sequence< beans::PropertyValue> aDBValues;
+            if (static_cast<const SfxUsrAnyItem*>(pItem)->GetValue() >>= aDBValues)
+            {
+                SwDBData aDBData;
+                svx::ODataAccessDescriptor aDescriptor(aDBValues);
+                aDescriptor[svx::daDataSource]   >>= aDBData.sDataSource;
+                aDescriptor[svx::daCommand]      >>= aDBData.sCommand;
+                aDescriptor[svx::daCommandType]  >>= aDBData.nCommandType;
+
+                uno::Sequence< uno::Any >                   aSelection;
+                uno::Reference< sdbc::XConnection>          xConnection;
+                uno::Reference< sdbc::XDataSource>          xSource;
+                uno::Reference< sdbcx::XColumnsSupplier>    xColumnsSupplier;
+                if (aDescriptor.has(svx::daSelection))
+                    aDescriptor[svx::daSelection] >>= aSelection;
+                if (aDescriptor.has(svx::daConnection))
+                    aDescriptor[svx::daConnection] >>= xConnection;
+                uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY);
+                if (xChild.is())
+                    xSource.set(xChild->getParent(), uno::UNO_QUERY);
+                pMMConfig->SetCurrentConnection(
+                    xSource, SharedConnection(xConnection, SharedConnection::NoTakeOwnership),
+                    xColumnsSupplier, aDBData);
+            }
+        }
+        else
+        {
+            std::vector<OUString> aDBNameList;
+            std::vector<OUString> aAllDBNames;
+            GetWrtShell().GetAllUsedDB(aDBNameList, &aAllDBNames);
+            if (!aDBNameList.empty())
+            {
+                OUString sDBName(aDBNameList[0]);
+                SwDBData aDBData;
+                aDBData.sDataSource = sDBName.getToken(0, DB_DELIM);
+                aDBData.sCommand = sDBName.getToken(1, DB_DELIM);
+                aDBData.nCommandType = sDBName.getToken(2, DB_DELIM).toInt32();
+                //set the currently used database for the wizard
+                pMMConfig->SetCurrentDBData(aDBData);
+            }
+        }
+
+        SetMailMergeConfigItem(pMMConfig, nWizardRestartPage, true);
+    }
+    return pMMConfig;
+}
+
 namespace
 {
 
@@ -385,62 +447,7 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs
     acquire();
 
     // create if it does not exist yet
-    SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem();
-    if (!pMMConfig)
-    {
-        pMMConfig = new SwMailMergeConfigItem;
-        pMMConfig->SetSourceView(m_pView);
-
-        //set the first used database as default source on the config item
-        const SfxPoolItem* pItem = nullptr;
-        if (pArgs && SfxItemState::SET == pArgs->GetItemState(
-               FN_PARAM_DATABASE_PROPERTIES, false, &pItem))
-        {
-            //mailmerge has been called from the database beamer
-            uno::Sequence< beans::PropertyValue> aDBValues;
-            if (static_cast<const SfxUsrAnyItem*>(pItem)->GetValue() >>= aDBValues)
-            {
-                SwDBData aDBData;
-                svx::ODataAccessDescriptor aDescriptor(aDBValues);
-                aDescriptor[svx::daDataSource]   >>= aDBData.sDataSource;
-                aDescriptor[svx::daCommand]      >>= aDBData.sCommand;
-                aDescriptor[svx::daCommandType]  >>= aDBData.nCommandType;
-
-                uno::Sequence< uno::Any >                   aSelection;
-                uno::Reference< sdbc::XConnection>          xConnection;
-                uno::Reference< sdbc::XDataSource>          xSource;
-                uno::Reference< sdbcx::XColumnsSupplier>    xColumnsSupplier;
-                if (aDescriptor.has(svx::daSelection))
-                    aDescriptor[svx::daSelection] >>= aSelection;
-                if (aDescriptor.has(svx::daConnection))
-                    aDescriptor[svx::daConnection] >>= xConnection;
-                uno::Reference<container::XChild> xChild(xConnection, uno::UNO_QUERY);
-                if (xChild.is())
-                    xSource.set(xChild->getParent(), uno::UNO_QUERY);
-                pMMConfig->SetCurrentConnection(
-                    xSource, SharedConnection(xConnection, SharedConnection::NoTakeOwnership),
-                    xColumnsSupplier, aDBData);
-            }
-        }
-        else
-        {
-            std::vector<OUString> aDBNameList;
-            std::vector<OUString> aAllDBNames;
-            m_pView->GetWrtShell().GetAllUsedDB(aDBNameList, &aAllDBNames);
-            if (!aDBNameList.empty())
-            {
-                OUString sDBName(aDBNameList[0]);
-                SwDBData aDBData;
-                aDBData.sDataSource = sDBName.getToken(0, DB_DELIM);
-                aDBData.sCommand = sDBName.getToken(1, DB_DELIM);
-                aDBData.nCommandType = sDBName.getToken(2, DB_DELIM).toInt32();
-                //set the currently used database for the wizard
-                pMMConfig->SetCurrentDBData(aDBData);
-            }
-        }
-
-        m_pView->SetMailMergeConfigItem(pMMConfig, m_pWizard? m_pWizard->GetRestartPage(): 0, true);
-    }
+    SwMailMergeConfigItem* pMMConfig = m_pView->EnsureMailMergeConfigItem(pArgs, m_pWizard ? m_pWizard->GetRestartPage() : 0);
 
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *pMMConfig);


More information about the Libreoffice-commits mailing list