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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Sat Jul 4 15:18:38 PDT 2015


 sw/source/ui/dbui/mailmergewizard.cxx    |    1 
 sw/source/ui/dbui/mmpreparemergepage.cxx |   31 +--
 sw/source/uibase/dbui/mmconfigitem.cxx   |   70 ++------
 sw/source/uibase/inc/mmconfigitem.hxx    |  266 +++++++++++++++----------------
 4 files changed, 172 insertions(+), 196 deletions(-)

New commits:
commit 67afab2a7cd5596d321bb85e6e2624df19c2296b
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Jul 4 23:49:00 2015 +0200

    this file has significant (amounts) of whitespace ...
    
    ... lets reduce it to somewhat bearable levels.
    
    Change-Id: I2d17b313dfd151b3572ea1250613b73ebc20dbcf

diff --git a/sw/source/uibase/inc/mmconfigitem.hxx b/sw/source/uibase/inc/mmconfigitem.hxx
index 07f216c..682aff5 100644
--- a/sw/source/uibase/inc/mmconfigitem.hxx
+++ b/sw/source/uibase/inc/mmconfigitem.hxx
@@ -50,22 +50,22 @@ struct SwDocMergeInfo
 class SW_DLLPUBLIC SwMailMergeConfigItem
 {
 //    com::sun::star::uno::Sequence< OUString>     m_aSavedDocuments;
-    SwMailMergeConfigItem_Impl*                                 m_pImpl;
+    SwMailMergeConfigItem_Impl* m_pImpl;
     //session information - not stored in configuration
-    bool                                                        m_bAddressInserted;
-    bool                                                        m_bMergeDone;
-    bool                                                        m_bGreetingInserted;
-    sal_Int32                                                   m_nGreetingMoves;
-    OUString                                             m_rAddressBlockFrame;
+    bool m_bAddressInserted;
+    bool m_bMergeDone;
+    bool m_bGreetingInserted;
+    sal_Int32 m_nGreetingMoves;
+    OUString m_rAddressBlockFrame;
     std::set<sal_Int32> m_aExcludedRecords;
 
-    sal_uInt16                                                      m_nStartPrint;
-    sal_uInt16                                                      m_nEndPrint;
+    sal_uInt16 m_nStartPrint;
+    sal_uInt16 m_nEndPrint;
 
-    OUString                                             m_sSelectedPrinter;
+    OUString m_sSelectedPrinter;
 
-    SwView*                                                     m_pSourceView;
-    SwView*                                                     m_pTargetView;
+    SwView* m_pSourceView;
+    SwView* m_pTargetView;
 public:
     SwMailMergeConfigItem();
     ~SwMailMergeConfigItem();
@@ -77,192 +77,192 @@ public:
         NEUTRAL
     };
 
-    void                Commit();
+    void Commit();
 
-    const ResStringArray&   GetDefaultAddressHeaders() const;
+    const ResStringArray& GetDefaultAddressHeaders() const;
 
-    void                SetCurrentConnection(
-                            ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>          xSource,
-                            const SharedConnection&                                                         rConnection,
-                            ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>    xColumnsSupplier,
-                            const SwDBData& rDBData);
+    void SetCurrentConnection(
+        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> xSource,
+        const SharedConnection& rConnection,
+        ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xColumnsSupplier,
+        const SwDBData& rDBData);
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>
-                        GetSource();
+    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> GetSource();
 
-    SharedConnection    GetConnection();
+    SharedConnection GetConnection();
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier>
-                        GetColumnsSupplier();
+    ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> GetColumnsSupplier();
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>
-                        GetResultSet() const;
+    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> GetResultSet() const;
 
-    void                DisposeResultSet();
+    void DisposeResultSet();
 
-    OUString&    GetFilter() const;
-    void                SetFilter(OUString&);
+    OUString& GetFilter() const;
+    void SetFilter(OUString&);
 
-    void                SetSelection(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rSelection);
+    void SetSelection(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rSelection);
 
-    void                SetCurrentDBData( const SwDBData& rDBData);
-    const SwDBData&     GetCurrentDBData() const;
+    void SetCurrentDBData( const SwDBData& rDBData);
+    const SwDBData& GetCurrentDBData() const;
 
     // move absolute, nTarget == -1 -> goto last record
-    sal_Int32           MoveResultSet(sal_Int32 nTarget);
-    sal_Int32           GetResultSetPosition()const;
-    bool                IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast);
+    sal_Int32 MoveResultSet(sal_Int32 nTarget);
+    sal_Int32 GetResultSetPosition()const;
+    bool IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast);
 
-    bool                IsRecordExcluded(sal_Int32 nRecord) const;
-    void                ExcludeRecord(sal_Int32 nRecord, bool bExclude);
+    bool IsRecordExcluded(sal_Int32 nRecord) const;
+    void ExcludeRecord(sal_Int32 nRecord, bool bExclude);
     css::uno::Sequence< css::uno::Any> GetSelection() const;
 
-    const com::sun::star::uno::Sequence< OUString>&
-                        GetSavedDocuments() const;
-    void                AddSavedDocument(const OUString& rName);
+    const com::sun::star::uno::Sequence<OUString>& GetSavedDocuments() const;
+    void AddSavedDocument(const OUString& rName);
 
-    bool            IsOutputToLetter()const;
-    void                SetOutputToLetter(bool bSet);
+    bool IsOutputToLetter()const;
+    void SetOutputToLetter(bool bSet);
 
-    bool                IsAddressBlock()const;
-    void                SetAddressBlock(bool bSet);
+    bool IsAddressBlock()const;
+    void SetAddressBlock(bool bSet);
 
-    bool            IsHideEmptyParagraphs() const;
-    void                SetHideEmptyParagraphs(bool bSet);
+    bool IsHideEmptyParagraphs() const;
+    void SetHideEmptyParagraphs(bool bSet);
 
-    const com::sun::star::uno::Sequence< OUString>
-                        GetAddressBlocks() const;
-    void                SetAddressBlocks(const com::sun::star::uno::Sequence< OUString>& rBlocks);
+    const com::sun::star::uno::Sequence<OUString> GetAddressBlocks() const;
+    void SetAddressBlocks(const com::sun::star::uno::Sequence< OUString>& rBlocks);
 
-    void                SetCurrentAddressBlockIndex( sal_Int32 nSet );
-    sal_Int32           GetCurrentAddressBlockIndex() const;
+    void SetCurrentAddressBlockIndex( sal_Int32 nSet );
+    sal_Int32 GetCurrentAddressBlockIndex() const;
 
-    bool            IsIncludeCountry() const;
-    OUString&      GetExcludeCountry() const;
-    void                SetCountrySettings(bool bSet, const OUString& sCountry);
+    bool IsIncludeCountry() const;
+    OUString& GetExcludeCountry() const;
+    void SetCountrySettings(bool bSet, const OUString& sCountry);
 
-    bool            IsIndividualGreeting(bool bInEMail) const;
-    void                SetIndividualGreeting(bool bSet, bool bInEMail);
+    bool IsIndividualGreeting(bool bInEMail) const;
+    void SetIndividualGreeting(bool bSet, bool bInEMail);
 
-    bool            IsGreetingLine(bool bInEMail) const;
-    void                SetGreetingLine(bool bSet, bool bInEMail);
+    bool IsGreetingLine(bool bInEMail) const;
+    void SetGreetingLine(bool bSet, bool bInEMail);
 
-    const com::sun::star::uno::Sequence< OUString>
-                        GetGreetings(Gender eType) const;
-    void                SetGreetings(Gender eType, const com::sun::star::uno::Sequence< OUString>& rBlocks);
+    const com::sun::star::uno::Sequence<OUString> GetGreetings(Gender eType) const;
+    void SetGreetings(Gender eType, const com::sun::star::uno::Sequence< OUString>& rBlocks);
 
-    sal_Int32           GetCurrentGreeting(Gender eType) const;
-    void                SetCurrentGreeting(Gender eType, sal_Int32 nIndex);
+    sal_Int32 GetCurrentGreeting(Gender eType) const;
+    void SetCurrentGreeting(Gender eType, sal_Int32 nIndex);
 
     //the content of the gender column that marks it as female
     const OUString& GetFemaleGenderValue() const;
-    void                   SetFemaleGenderValue(const OUString& rValue);
+    void SetFemaleGenderValue(const OUString& rValue);
 
     //returns the assignment in the order of the default headers (GetDefaultAddressHeaders())
-    com::sun::star::uno::Sequence< OUString >
-                        GetColumnAssignment( const SwDBData& rDBData ) const;
-    void                SetColumnAssignment(
-                            const SwDBData& rDBData,
-                            const com::sun::star::uno::Sequence< OUString>& );
+    com::sun::star::uno::Sequence<OUString> GetColumnAssignment( const SwDBData& rDBData ) const;
+    void SetColumnAssignment(
+        const SwDBData& rDBData,
+        const com::sun::star::uno::Sequence< OUString>& );
 
-    bool                IsAddressFieldsAssigned() const;
-    bool                IsGreetingFieldsAssigned() const;
+    bool IsAddressFieldsAssigned() const;
+    bool IsGreetingFieldsAssigned() const;
 
     //e-Mail settings:
-    OUString     GetMailDisplayName() const;
-    void                SetMailDisplayName(const OUString& rName);
+    OUString GetMailDisplayName() const;
+    void SetMailDisplayName(const OUString& rName);
 
-    OUString     GetMailAddress() const;
-    void                SetMailAddress(const OUString& rAddress);
+    OUString GetMailAddress() const;
+    void SetMailAddress(const OUString& rAddress);
 
-    bool            IsMailReplyTo() const;
-    void                SetMailReplyTo(bool bSet);
+    bool IsMailReplyTo() const;
+    void SetMailReplyTo(bool bSet);
 
-    OUString     GetMailReplyTo() const;
-    void                SetMailReplyTo(const OUString& rReplyTo);
+    OUString GetMailReplyTo() const;
+    void SetMailReplyTo(const OUString& rReplyTo);
 
-    OUString     GetMailServer() const;
-    void                SetMailServer(const OUString& rAddress);
+    OUString GetMailServer() const;
+    void SetMailServer(const OUString& rAddress);
 
-    sal_Int16           GetMailPort() const;
-    void                SetMailPort(sal_Int16 nSet);
+    sal_Int16 GetMailPort() const;
+    void SetMailPort(sal_Int16 nSet);
 
-    bool            IsSecureConnection() const;
-    void                SetSecureConnection(bool bSet);
+    bool IsSecureConnection() const;
+    void SetSecureConnection(bool bSet);
 
-    bool            IsAuthentication() const;
-    void                SetAuthentication(bool bSet);
+    bool IsAuthentication() const;
+    void SetAuthentication(bool bSet);
 
-    OUString     GetMailUserName() const;
-    void                SetMailUserName(const OUString& rName);
+    OUString GetMailUserName() const;
+    void SetMailUserName(const OUString& rName);
 
-    OUString     GetMailPassword() const;
-    void                SetMailPassword(const OUString& rPassword);
+    OUString GetMailPassword() const;
+    void SetMailPassword(const OUString& rPassword);
 
-    bool            IsSMTPAfterPOP() const;
-    void                SetSMTPAfterPOP(bool bSet);
+    bool IsSMTPAfterPOP() const;
+    void SetSMTPAfterPOP(bool bSet);
 
-    OUString     GetInServerName() const;
-    void                SetInServerName(const OUString& rServer);
+    OUString GetInServerName() const;
+    void SetInServerName(const OUString& rServer);
 
-    sal_Int16           GetInServerPort() const;
-    void                SetInServerPort(sal_Int16 nSet);
+    sal_Int16 GetInServerPort() const;
+    void SetInServerPort(sal_Int16 nSet);
 
-    bool            IsInServerPOP() const;
-    void                SetInServerPOP(bool bSet);
+    bool IsInServerPOP() const;
+    void SetInServerPOP(bool bSet);
 
-    OUString     GetInServerUserName() const;
-    void                SetInServerUserName(const OUString& rName);
+    OUString GetInServerUserName() const;
+    void SetInServerUserName(const OUString& rName);
 
-    OUString     GetInServerPassword() const;
-    void                SetInServerPassword(const OUString& rPassword);
+    OUString GetInServerPassword() const;
+    void SetInServerPassword(const OUString& rPassword);
 
     //session information
-    bool                IsAddressInserted() const { return m_bAddressInserted; }
-    void                SetAddressInserted(const OUString& rFrameName)
-                            { m_bAddressInserted = true;
-                              m_rAddressBlockFrame = rFrameName;
-                            }
+    bool IsAddressInserted() const { return m_bAddressInserted; }
+    void SetAddressInserted(const OUString& rFrameName)
+    {
+        m_bAddressInserted = true;
+        m_rAddressBlockFrame = rFrameName;
+    }
 
-    bool                IsGreetingInserted() const { return m_bGreetingInserted; }
-    void                SetGreetingInserted()
-                            { m_bGreetingInserted = true; }
+    bool IsGreetingInserted() const
+        { return m_bGreetingInserted; }
+    void SetGreetingInserted()
+        { m_bGreetingInserted = true; }
 
     // counts the moves in the layout page
-    void                MoveGreeting( sal_Int32 nMove) { m_nGreetingMoves += nMove;}
-    sal_Int32           GetGreetingMoves() const { return m_nGreetingMoves;}
+    void MoveGreeting( sal_Int32 nMove) { m_nGreetingMoves += nMove;}
+    sal_Int32 GetGreetingMoves() const { return m_nGreetingMoves;}
 
-    bool                IsMergeDone() const { return m_bMergeDone;}
-    void                SetMergeDone(  ) { m_bMergeDone = true; }
+    bool IsMergeDone() const
+        { return m_bMergeDone; }
+    void SetMergeDone(  )
+        { m_bMergeDone = true; }
 
     // new source document - reset some flags
-    void                DocumentReloaded();
+    void DocumentReloaded();
 
-    bool                IsMailAvailable() const;
+    bool IsMailAvailable() const;
 
     // notify a completed merge, provid the appropriate e-Mail address if available
-    void                AddMergedDocument(SwDocMergeInfo& rInfo);
+    void AddMergedDocument(SwDocMergeInfo& rInfo);
     //returns the page and database cursor information of each merged document
-    SwDocMergeInfo&     GetDocumentMergeInfo(sal_uInt32 nDocument);
-    sal_uInt32          GetMergedDocumentCount() const;
+    SwDocMergeInfo& GetDocumentMergeInfo(sal_uInt32 nDocument);
+    sal_uInt32 GetMergedDocumentCount() const;
 
-    void                SetPrintRange( sal_uInt16 nStartDocument, sal_uInt16 nEndDocument)
-                            {m_nStartPrint = nStartDocument; m_nEndPrint = nEndDocument;}
-    sal_uInt16              GetPrintRangeStart() const  {return m_nStartPrint;}
-    sal_uInt16              GetPrintRangeEnd() const {return m_nEndPrint;}
+    void SetPrintRange( sal_uInt16 nStartDocument, sal_uInt16 nEndDocument)
+        { m_nStartPrint = nStartDocument; m_nEndPrint = nEndDocument; }
+    sal_uInt16 GetPrintRangeStart() const
+        { return m_nStartPrint; }
+    sal_uInt16 GetPrintRangeEnd() const
+        { return m_nEndPrint; }
 
-    const OUString&  GetSelectedPrinter() const {return m_sSelectedPrinter;}
-    void                    SetSelectedPrinter(const OUString& rSet )
-                                    {m_sSelectedPrinter = rSet;}
+    const OUString&  GetSelectedPrinter() const
+        { return m_sSelectedPrinter; }
+    void SetSelectedPrinter(const OUString& rSet)
+        { m_sSelectedPrinter = rSet; }
 
-    SwView*             GetTargetView();
-    void                SetTargetView(SwView* pView);
+    SwView* GetTargetView();
+    void SetTargetView(SwView* pView);
 
-    SwView*             GetSourceView();
-    void                SetSourceView(SwView* pView);
+    SwView* GetSourceView();
+    void SetSourceView(SwView* pView);
 
     //helper methods
-    OUString     GetAssignedColumn(sal_uInt32 nColumn)const;
+    OUString GetAssignedColumn(sal_uInt32 nColumn)const;
 };
 
 #endif
commit 6942e18899756cb49bc17f531c156bf3e6abce03
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Jul 4 23:32:52 2015 +0200

    tdf#89592: use initializer list
    
    Change-Id: If3ca55d4dc42975785a4978e473ddf78e7713912

diff --git a/sw/source/ui/dbui/mmpreparemergepage.cxx b/sw/source/ui/dbui/mmpreparemergepage.cxx
index 644ffab..52d6af5 100644
--- a/sw/source/ui/dbui/mmpreparemergepage.cxx
+++ b/sw/source/ui/dbui/mmpreparemergepage.cxx
@@ -18,6 +18,8 @@
  */
 
 #include <mmpreparemergepage.hxx>
+
+#include <comphelper/propertysequence.hxx>
 #include <mailmergewizard.hxx>
 #include <mmconfigitem.hxx>
 #include <dbui.hrc>
@@ -116,25 +118,16 @@ IMPL_LINK( SwMailMergePrepareMergePage, MoveHdl_Impl, void*, pCtrl)
     m_pExcludeCB->Check(rConfigItem.IsRecordExcluded( rConfigItem.GetResultSetPosition() ));
     //now the record has to be merged into the source document
     const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
-
-    Sequence< PropertyValue > aArgs(7);
-    Sequence<Any> aSelection(1);
-    aSelection[0] <<= rConfigItem.GetResultSetPosition();
-    aArgs[0].Name = "Selection";
-    aArgs[0].Value <<= aSelection;
-    aArgs[1].Name = "DataSourceName";
-    aArgs[1].Value <<= rDBData.sDataSource;
-    aArgs[2].Name = "Command";
-    aArgs[2].Value <<= rDBData.sCommand;
-    aArgs[3].Name = "CommandType";
-    aArgs[3].Value <<= rDBData.nCommandType;
-    aArgs[4].Name = "ActiveConnection";
-    aArgs[4].Value <<=  rConfigItem.GetConnection().getTyped();
-    aArgs[5].Name = "Filter";
-    aArgs[5].Value <<= rConfigItem.GetFilter();
-    aArgs[6].Name = "Cursor";
-    aArgs[6].Value <<= rConfigItem.GetResultSet();
-
+    Sequence<Any> vSelection = { makeAny(rConfigItem.GetResultSetPosition()) };
+    auto aArgs(::comphelper::InitPropertySequence({
+        {"Selection",        makeAny(vSelection)},
+        {"DataSourceNamea",  makeAny(rDBData.sDataSource)},
+        {"Command",          makeAny(rDBData.sCommand)},
+        {"CommandType",      makeAny(rDBData.nCommandType)},
+        {"ActiveConnection", makeAny(rConfigItem.GetConnection().getTyped())},
+        {"Filter",           makeAny(rConfigItem.GetFilter())},
+        {"Cursor",           makeAny(rConfigItem.GetResultSet())}
+    }));
     svx::ODataAccessDescriptor aDescriptor(aArgs);
     SwWrtShell& rSh = m_pWizard->GetSwView()->GetWrtShell();
     SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
commit 88298839b51ef511161cddd5b20f001462384eea
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Sat Jul 4 23:22:53 2015 +0200

    tdf#90377: fix exclude recipient in mail merge
    
    - first, actually use the selection in MergeNew()
    - secoond, bring back GetSelection() for that
    - third, throw away lots of the old (dead) code that mostly just
      stumbled over itself
      - e.g. ExcludeRecord() wouldnt work on the last element due to a
        off-by-one error
    
    Change-Id: I07d07e086b748b393f2ada7cb22fdb2ce285ad65

diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
index 341bede..04bd7f8 100644
--- a/sw/source/ui/dbui/mailmergewizard.cxx
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -276,6 +276,7 @@ void SwMailMergeWizard::CreateTargetDocument()
     aDescriptor[ svx::daCursor ]      <<= m_rConfigItem.GetResultSet();
     aDescriptor[ svx::daCommand ]     <<= m_rConfigItem.GetCurrentDBData().sCommand;
     aDescriptor[ svx::daCommandType ] <<= m_rConfigItem.GetCurrentDBData().nCommandType;
+    aDescriptor[ svx::daSelection ]   <<= m_rConfigItem.GetSelection();
 
     SwMergeDescriptor aMergeDesc( DBMGR_MERGE_SHELL, GetSwView()->GetWrtShell(),
         aDescriptor);
diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx
index d765dc0f..879870b 100644
--- a/sw/source/uibase/dbui/mmconfigitem.cxx
+++ b/sw/source/uibase/dbui/mmconfigitem.cxx
@@ -17,7 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+
 #include <mmconfigitem.hxx>
+#include <vector>
 #include <swtypes.hxx>
 #include <osl/diagnose.h>
 #include <com/sun/star/uno/Any.hxx>
@@ -34,6 +36,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/types.hxx>
 #include <com/sun/star/sdb/CommandType.hpp>
+#include <comphelper/sequence.hxx>
 #include <rtl/instance.hxx>
 #include <unotools/configitem.hxx>
 #include <mailmergehelper.hxx>
@@ -1021,57 +1024,34 @@ sal_Int32 SwMailMergeConfigItem::GetResultSetPosition() const
     return m_pImpl->nResultSetCursorPos;
 }
 
-bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord)
-{
-    bool bRet = false;
-    if(nRecord > 0 && nRecord < m_aSelection.getLength())
-    {
-        sal_Int32 nTemp = 0;
-        m_aSelection[nRecord - 1] >>= nTemp;
-        bRet = nTemp < 1;
-    }
-    return bRet;
-}
+bool SwMailMergeConfigItem::IsRecordExcluded(sal_Int32 nRecord) const
+    { return m_aExcludedRecords.find(nRecord) != m_aExcludedRecords.end(); }
 
 void SwMailMergeConfigItem::ExcludeRecord(sal_Int32 nRecord, bool bExclude)
 {
-    //nRecord is based on 1
-    //the selection array contains Anys for all records
-    //excluded records  contain a '-1'
-    if(!m_aSelection.getLength() || nRecord > m_aSelection.getLength())
-    {
-        if(bExclude)
-        {
-            //if no selection array is available we need to create one containing the
-            //entries for all available records
-            if(!m_pImpl->xResultSet.is())
-                GetResultSet();
-            if(m_pImpl->xResultSet.is())
-            {
-                m_pImpl->xResultSet->last();
-                sal_Int32 nEnd = m_pImpl->xResultSet->getRow();
-                sal_Int32 nStart = m_aSelection.getLength();
-                m_aSelection.realloc(nEnd);
-                Any* pSelection = m_aSelection.getArray();
-                for(sal_Int32 nIndex = nStart; nIndex < nEnd; ++nIndex)
-                {
-                    if((nRecord - 1) != nIndex)
-                        pSelection[nIndex] <<= nIndex + 1;
-                    else
-                        pSelection[nIndex] <<= (sal_Int32) -1;
-                }
-            }
-        }
-    }
+    if(bExclude)
+        m_aExcludedRecords.insert(nRecord);
     else
-    {
-        if(nRecord > 0 && m_aSelection.getLength() > nRecord)
-        {
-            m_aSelection[nRecord - 1] <<= bExclude ? -1 : nRecord;
-        }
-    }
+        m_aExcludedRecords.erase(nRecord);
 }
 
+uno::Sequence<uno::Any> SwMailMergeConfigItem::GetSelection() const
+{
+    if(!m_pImpl->xResultSet.is())
+        GetResultSet();
+    if(!m_pImpl->xResultSet.is())
+        return {};
+    m_pImpl->xResultSet->last();
+    sal_Int32 nResultSetSize = m_pImpl->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));
+    return comphelper::containerToSequence(vResult);
+}
+
+
 const uno::Sequence< OUString>&
                     SwMailMergeConfigItem::GetSavedDocuments() const
 {
diff --git a/sw/source/uibase/inc/mmconfigitem.hxx b/sw/source/uibase/inc/mmconfigitem.hxx
index 7b4115e..07f216c 100644
--- a/sw/source/uibase/inc/mmconfigitem.hxx
+++ b/sw/source/uibase/inc/mmconfigitem.hxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/uno/Sequence.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include <tools/resary.hxx>
+#include <set>
 #include <swdbdata.hxx>
 #include "swdllapi.h"
 #include "sharedconnection.hxx"
@@ -56,7 +57,7 @@ class SW_DLLPUBLIC SwMailMergeConfigItem
     bool                                                        m_bGreetingInserted;
     sal_Int32                                                   m_nGreetingMoves;
     OUString                                             m_rAddressBlockFrame;
-    ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> m_aSelection;
+    std::set<sal_Int32> m_aExcludedRecords;
 
     sal_uInt16                                                      m_nStartPrint;
     sal_uInt16                                                      m_nEndPrint;
@@ -112,8 +113,9 @@ public:
     sal_Int32           GetResultSetPosition()const;
     bool                IsResultSetFirstLast(bool& bIsFirst, bool& bIsLast);
 
-    bool                IsRecordExcluded(sal_Int32 nRecord);
+    bool                IsRecordExcluded(sal_Int32 nRecord) const;
     void                ExcludeRecord(sal_Int32 nRecord, bool bExclude);
+    css::uno::Sequence< css::uno::Any> GetSelection() const;
 
     const com::sun::star::uno::Sequence< OUString>&
                         GetSavedDocuments() const;


More information about the Libreoffice-commits mailing list