[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 30 09:54:24 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 c4fe9369eeadf6b76156e697229a8af3b080acec
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: Fri Apr 30 11:53:52 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/+/114913
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 2702afde2b17..92a41b6333dc 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -528,6 +528,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);
@@ -571,18 +580,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());
@@ -626,7 +623,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();
@@ -635,7 +632,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
@@ -663,7 +660,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)
@@ -752,24 +749,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 =
@@ -851,6 +845,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);
@@ -882,16 +885,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 84cb6774253e..243f53572a4e 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 bae35cfdcb14..2405c48304c6 100644
--- a/sw/source/uibase/inc/mmconfigitem.hxx
+++ b/sw/source/uibase/inc/mmconfigitem.hxx
@@ -56,6 +56,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;
@@ -105,7 +107,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;
@@ -216,6 +219,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