[Libreoffice-commits] core.git: Branch 'feature/mailmerge-toolbar' - sw/source
Jan Holesovsky
kendy at collabora.com
Fri Feb 19 20:39:54 UTC 2016
sw/source/uibase/app/apphdl.cxx | 64 +++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 33 deletions(-)
New commits:
commit 04d239711187667032398e622857f06c5eeaa332
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Feb 19 21:37:21 2016 +0100
mailmerge: Create the documents for printing.
Now the printing from the toolbar works.
Change-Id: Id52deb78f0fcce96afc7727c63e6020f1743a430
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index ca57274..fe61bcc 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -619,6 +619,33 @@ IMPL_LINK_NOARG_TYPED(SwMailMergeWizardExecutor, CloseFrameHdl, void*, void)
}
}
+SwMailMergeConfigItem* PerformMailMerge(SwView* pView)
+{
+ SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+ if (!pConfigItem)
+ return nullptr;
+
+ svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(pConfigItem->GetCurrentDBData().sDataSource);
+ aDescriptor[ svx::daConnection ] <<= pConfigItem->GetConnection().getTyped();
+ aDescriptor[ svx::daCursor ] <<= pConfigItem->GetResultSet();
+ aDescriptor[ svx::daCommand ] <<= pConfigItem->GetCurrentDBData().sCommand;
+ aDescriptor[ svx::daCommandType ] <<= pConfigItem->GetCurrentDBData().nCommandType;
+ aDescriptor[ svx::daSelection ] <<= pConfigItem->GetSelection();
+
+ SwWrtShell& rSh = pView->GetWrtShell();
+ pConfigItem->SetTargetView(nullptr);
+
+ SwMergeDescriptor aMergeDesc(DBMGR_MERGE_SHELL, rSh, aDescriptor);
+ aMergeDesc.pMailMergeConfigItem = pConfigItem;
+ aMergeDesc.bCreateSingleFile = true;
+ rSh.GetDBManager()->MergeNew(aMergeDesc);
+
+ pConfigItem->SetMergeDone();
+
+ return pConfigItem;
+}
+
} // namespace
#endif // HAVE_FEATURE_DBCONNECTIVITY
@@ -735,6 +762,7 @@ void SwModule::ExecOther(SfxRequest& rReq)
}
// now the record has to be merged into the source document
+ // TODO can we re-use PerformMailMerge() here somehow?
const SwDBData& rDBData = pConfigItem->GetCurrentDBData();
uno::Sequence<uno::Any> vSelection({ uno::makeAny(pConfigItem->GetResultSetPosition()) });
svx::ODataAccessDescriptor aDescriptor(::comphelper::InitPropertySequence({
@@ -764,49 +792,19 @@ void SwModule::ExecOther(SfxRequest& rReq)
break;
case FN_MAILMERGE_CREATE_DOCUMENTS:
{
- SwView* pView = ::GetActiveView();
- SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
- if (!pConfigItem)
- return;
-
- // TODO share this code somehow with the above FN_MAILMERGE_*_ENTRY
- // TODO kill SwMailMergeWizard::CreateTargetDocument()
- svx::ODataAccessDescriptor aDescriptor;
- aDescriptor.setDataSource(pConfigItem->GetCurrentDBData().sDataSource);
- aDescriptor[ svx::daConnection ] <<= pConfigItem->GetConnection().getTyped();
- aDescriptor[ svx::daCursor ] <<= pConfigItem->GetResultSet();
- aDescriptor[ svx::daCommand ] <<= pConfigItem->GetCurrentDBData().sCommand;
- aDescriptor[ svx::daCommandType ] <<= pConfigItem->GetCurrentDBData().nCommandType;
- aDescriptor[ svx::daSelection ] <<= pConfigItem->GetSelection();
-
- SwWrtShell& rSh = pView->GetWrtShell();
- pConfigItem->SetTargetView(nullptr);
-
- SwMergeDescriptor aMergeDesc(DBMGR_MERGE_SHELL, rSh, aDescriptor);
- aMergeDesc.pMailMergeConfigItem = pConfigItem;
- aMergeDesc.bCreateSingleFile = true;
- rSh.GetDBManager()->MergeNew(aMergeDesc);
+ SwMailMergeConfigItem* pConfigItem = PerformMailMerge(GetActiveView());
- pConfigItem->SetMergeDone();
- if (pConfigItem->GetTargetView())
+ if (pConfigItem && pConfigItem->GetTargetView())
pConfigItem->GetTargetView()->GetViewFrame()->GetFrame().Appear();
}
case FN_MAILMERGE_SAVE_DOCUMENTS:
case FN_MAILMERGE_PRINT_DOCUMENTS:
case FN_MAILMERGE_EMAIL_DOCUMENTS:
{
- SwView* pView = ::GetActiveView();
- SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+ SwMailMergeConfigItem* pConfigItem = PerformMailMerge(GetActiveView());
if (!pConfigItem)
return;
- if (!pConfigItem->GetTargetView())
- {
- SwView* pSourceView = pConfigItem->GetSourceView();
- assert(pSourceView);
- pConfigItem->SetTargetView(SwDBManager::CreateTargetDocShell(true, &pSourceView->GetEditWin(), pSourceView->GetWrtShellPtr(), pSourceView->GetDocShell()));
- }
-
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
switch (nWhich)
{
More information about the Libreoffice-commits
mailing list