summaryrefslogtreecommitdiff
path: root/sw/source/ui
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2021-03-22 13:34:37 +0100
committerLászló Németh <nemeth@numbertext.org>2021-03-31 12:24:22 +0200
commitec44f87d5b99a3299322d0b79abc4c6808877865 (patch)
tree684cd7e5306595fe406988c33874aaca569adc2c /sw/source/ui
parent3db477fd0e6cfc4ff77b3c911ca4ab14fd980932 (diff)
tdf#117212 sw mailmerge: merge only the selected range
All records were merged before saving or printing the record range selected in “From 'X' To 'Y' of the “Save Merged Documents” or “Print Merged Documents” dialog windows (opened via the Mail merge toolbar). This was a waste of time in the case of selecting only a few records. Change-Id: I52c47d3c5707b09ed7f9b05a1a0f4d20a5595b8d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112922 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/ui')
-rw-r--r--sw/source/ui/dbui/mmresultdialogs.cxx67
1 files changed, 30 insertions, 37 deletions
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx
index ef10e4f321a9..2c9d89039dff 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -551,6 +551,15 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void)
SwView* pView = ::GetActiveView();
std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem();
assert(xConfigItem);
+
+ sal_uInt32 nBegin = static_cast<sal_Int32>(m_xFromNF->get_value() - 1);
+ sal_uInt32 nEnd = static_cast<sal_Int32>(m_xToNF->get_value());
+ sal_uInt32 nMax = static_cast<sal_Int32>(m_xToNF->get_max());
+ if (nEnd > nMax)
+ nEnd = nMax;
+
+ xConfigItem->SetBeginEnd(nBegin, nEnd);
+
if (!xConfigItem->GetTargetView())
SwDBManager::PerformMailMerge(pView);
@@ -594,18 +603,6 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void)
}
else
{
- const sal_uInt32 nDocumentCount = xConfigItem->GetMergedDocumentCount();
- sal_uInt32 nBegin = 0;
- sal_uInt32 nEnd = nDocumentCount;
-
- if (!m_xSaveIndividualRB->get_active())
- {
- nBegin = static_cast< sal_Int32 >(m_xFromNF->get_value() - 1);
- nEnd = static_cast< sal_Int32 >(m_xToNF->get_value());
- if(nEnd > nDocumentCount)
- nEnd = nDocumentCount;
- }
-
OUString sTargetTempURL = URIHelper::SmartRel2Abs(
INetURLObject(), utl::TempFile::CreateTempName(),
URIHelper::GetMaybeFileHdl());
@@ -649,7 +646,7 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void)
xSaveMonitor.reset();
});
- for(sal_uInt32 nDoc = nBegin; nDoc < nEnd && !m_bCancelSaving; ++nDoc)
+ for(sal_uInt32 nDoc = 0; nDoc < nEnd - nBegin && !m_bCancelSaving; ++nDoc)
{
INetURLObject aURL(sPath);
OUString sExtension = aURL.getExtension();
@@ -658,7 +655,7 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void)
sExtension = pSfxFlt->GetWildcard().getGlob().getToken(1, '.');
sPath += "." + sExtension;
}
- OUString sStat = SwResId(STR_STATSTR_LETTER) + " " + OUString::number( nDoc );
+ OUString sStat = SwResId(STR_STATSTR_LETTER) + " " + OUString::number(nBegin + nDoc);
xSaveMonitor->m_xPrintInfo->set_label(sStat);
//now extract a document from the target document
@@ -686,7 +683,7 @@ IMPL_LINK_NOARG(SwMMResultSaveDialog, SaveOutputHdl_Impl, weld::Button&, void)
pTargetView->GetWrtShell().EndAction();
//then save it
OUString sOutPath = aURL.GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
- OUString sCounter = "_" + OUString::number(nDoc + 1);
+ OUString sCounter = "_" + OUString::number(nBegin + nDoc + 1);
sOutPath = sOutPath.replaceAt( sOutPath.getLength() - sExtension.getLength() - 1, 0, sCounter);
while(true)
@@ -775,24 +772,21 @@ IMPL_LINK_NOARG(SwMMResultPrintDialog, PrintHdl_Impl, weld::Button&, void)
SwView* pView = ::GetActiveView();
std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem();
assert(xConfigItem);
+
+ sal_uInt32 nBegin = static_cast<sal_Int32>(m_xFromNF->get_value() - 1);
+ sal_uInt32 nEnd = static_cast<sal_Int32>(m_xToNF->get_value());
+ sal_uInt32 nMax = static_cast<sal_Int32>(m_xToNF->get_max());
+ if (nEnd > nMax)
+ nEnd = nMax;
+
+ xConfigItem->SetBeginEnd(nBegin, nEnd);
+
if(!xConfigItem->GetTargetView())
SwDBManager::PerformMailMerge(pView);
SwView* pTargetView = xConfigItem->GetTargetView();
assert(pTargetView);
- const sal_uInt32 nDocumentCount = xConfigItem->GetMergedDocumentCount();
- sal_uInt32 nBegin = 0;
- sal_uInt32 nEnd = nDocumentCount;
-
- if (!m_xPrintAllRB->get_active())
- {
- nBegin = m_xFromNF->get_value() - 1;
- nEnd = m_xToNF->get_value();
- if(nEnd > nDocumentCount)
- nEnd = nDocumentCount;
- }
-
// If we skip autoinserted blanks, then the page numbers used in the print range string
// refer to the non-blank pages as they appear in the document (see tdf#89708).
const bool bIgnoreEmptyPages =
@@ -889,6 +883,15 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi
SwView* pView = ::GetActiveView();
std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem();
assert(xConfigItem);
+
+ sal_uInt32 nBegin = static_cast<sal_Int32>(m_xFromNF->get_value() - 1);
+ sal_uInt32 nEnd = static_cast<sal_Int32>(m_xToNF->get_value());
+ sal_uInt32 nMax = static_cast<sal_Int32>(m_xToNF->get_max());
+ if (nEnd > nMax)
+ nEnd = nMax;
+
+ xConfigItem->SetBeginEnd(nBegin, nEnd);
+
if (!xConfigItem->GetTargetView())
SwDBManager::PerformMailMerge(pView);
@@ -920,16 +923,6 @@ IMPL_LINK_NOARG(SwMMResultEmailDialog, SendDocumentsHdl_Impl, weld::Button&, voi
lcl_UpdateEmailSettingsFromGlobalConfig(*xConfigItem);
}
//add the documents
- const sal_uInt32 nDocumentCount = xConfigItem->GetMergedDocumentCount();
- sal_uInt32 nBegin = 0;
- sal_uInt32 nEnd = nDocumentCount;
- if (!m_xSendAllRB->get_active())
- {
- nBegin = static_cast< sal_Int32 >(m_xFromNF->get_value() - 1);
- nEnd = static_cast< sal_Int32 >(m_xToNF->get_value());
- if(nEnd > nDocumentCount)
- nEnd = nDocumentCount;
- }
bool bAsBody = false;
rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding();
SfxFilterContainer* pFilterContainer = SwDocShell::Factory().GetFilterContainer();