[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-1' - sw/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 29 11:29:03 UTC 2021
sw/source/ui/dbui/mmresultdialogs.cxx | 67 ++++++++++++++-------------------
sw/source/uibase/dbui/mmconfigitem.cxx | 16 ++++---
sw/source/uibase/inc/mmconfigitem.hxx | 8 +++
3 files changed, 47 insertions(+), 44 deletions(-)
New commits:
commit 71dfa96ecd27d49480ebb0a5eaddf1eaf3f2e02f
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Mon Mar 22 13:34:37 2021 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Tue Jun 29 13:28:30 2021 +0200
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 at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit ec44f87d5b99a3299322d0b79abc4c6808877865)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118094
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
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();
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index cdcb729c10a1..23068396fb9c 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -688,6 +688,8 @@ SwMailMergeConfigItem::SwMailMergeConfigItem() :
m_bAddressInserted(false),
m_bGreetingInserted(false),
m_nGreetingMoves(0),
+ m_nBegin(0),
+ m_nEnd(0),
m_pSourceView(nullptr),
m_pTargetView(nullptr)
{
@@ -982,7 +984,10 @@ sal_Int32 SwMailMergeConfigItem::GetResultSetPosition() const
return m_pImpl->m_nResultSetCursorPos;
}
-bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord) const
+bool SwMailMergeConfigItem::IsRecordIncluded(sal_uInt32 nRecord) const
+ { return nRecord > m_nBegin && nRecord <= m_nEnd; }
+
+bool SwMailMergeConfigItem::IsRecordExcluded(sal_uInt32 nRecord) const
{ return m_aExcludedRecords.find(nRecord) != m_aExcludedRecords.end(); }
void SwMailMergeConfigItem::ExcludeRecord(sal_Int32 nRecord, bool bExclude)
@@ -1000,12 +1005,11 @@ uno::Sequence<uno::Any> SwMailMergeConfigItem::GetSelection() const
if(!m_pImpl->m_xResultSet.is())
return {};
m_pImpl->m_xResultSet->last();
- sal_Int32 nResultSetSize = m_pImpl->m_xResultSet->getRow()+1;
+ sal_uInt32 nResultSetSize = m_pImpl->m_xResultSet->getRow()+1;
std::vector<uno::Any> vResult;
- vResult.reserve(nResultSetSize);
- for(sal_Int32 nIdx=1; nIdx<nResultSetSize;++nIdx)
- if(!IsRecordExcluded(nIdx))
- vResult.push_back(uno::makeAny<sal_Int32>(nIdx));
+ for(sal_uInt32 nIdx=1; nIdx<nResultSetSize;++nIdx)
+ if( !IsRecordExcluded(nIdx) && IsRecordIncluded(nIdx) )
+ vResult.push_back(uno::makeAny<sal_uInt32>(nIdx));
return comphelper::containerToSequence(vResult);
}
diff --git a/sw/source/uibase/inc/mmconfigitem.hxx b/sw/source/uibase/inc/mmconfigitem.hxx
index b058d65d3e43..b32a76d50e7a 100644
--- a/sw/source/uibase/inc/mmconfigitem.hxx
+++ b/sw/source/uibase/inc/mmconfigitem.hxx
@@ -57,6 +57,8 @@ class SW_DLLPUBLIC SwMailMergeConfigItem
bool m_bAddressInserted;
bool m_bGreetingInserted;
sal_Int32 m_nGreetingMoves;
+ sal_uInt32 m_nBegin;
+ sal_uInt32 m_nEnd;
std::set<sal_Int32> m_aExcludedRecords;
css::uno::Reference<css::view::XSelectionChangeListener> m_xDBChangedListener;
@@ -106,7 +108,8 @@ public:
sal_Int32 GetResultSetPosition()const;
bool IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast);
- bool IsRecordExcluded(sal_Int32 nRecord) const;
+ bool IsRecordIncluded(sal_uInt32 nRecord) const;
+ bool IsRecordExcluded(sal_uInt32 nRecord) const;
void ExcludeRecord(sal_Int32 nRecord, bool bExclude);
css::uno::Sequence< css::uno::Any> GetSelection() const;
@@ -217,6 +220,9 @@ public:
void SetGreetingInserted()
{ m_bGreetingInserted = true; }
+ void SetBeginEnd(sal_uInt32 nBegin, sal_uInt32 nEnd)
+ { m_nBegin = nBegin; m_nEnd = nEnd; }
+
// counts the moves in the layout page
void MoveGreeting( sal_Int32 nMove) { m_nGreetingMoves += nMove;}
sal_Int32 GetGreetingMoves() const { return m_nGreetingMoves;}
More information about the Libreoffice-commits
mailing list