[Libreoffice-commits] core.git: cui/source dbaccess/source extensions/source include/svx sc/source svx/source sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 24 06:55:43 UTC 2018


 cui/source/tabpages/numfmt.cxx                       |    8 --
 dbaccess/source/ui/misc/UITools.cxx                  |    8 --
 extensions/source/propctrlr/formcomponenthandler.cxx |    8 --
 include/svx/numfmtsh.hxx                             |    3 
 include/svx/numinf.hxx                               |   10 ---
 sc/source/ui/view/tabvwsh5.cxx                       |   11 ---
 svx/source/items/numfmtsh.cxx                        |   16 ----
 svx/source/items/numinf.cxx                          |   62 ++-----------------
 sw/source/uibase/shells/tabsh.cxx                    |   19 ++---
 sw/source/uibase/utlui/numfmtlb.cxx                  |    8 --
 10 files changed, 37 insertions(+), 116 deletions(-)

New commits:
commit e8e558488217b8d2c381191389f2a785aaa5ca27
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Aug 23 15:43:40 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 24 08:55:14 2018 +0200

    pass DelFormats around using std::vector
    
    instead of an array and a separate count
    
    Change-Id: Ia12a549da7e35092da2db35f8b2b9fc6a9e9c2be
    Reviewed-on: https://gerrit.libreoffice.org/59506
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index 9e518219d7d5..304bfbe6187f 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -757,14 +757,12 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
 
         // List of changed user defined formats:
 
-        const size_t nDelCount = pNumFmtShell->GetUpdateDataCount();
+        std::vector<sal_uInt32> const & aDelFormats = pNumFmtShell->GetUpdateData();
 
-        if ( nDelCount > 0 )
+        if ( !aDelFormats.empty() )
         {
-            std::unique_ptr<sal_uInt32[]> pDelArr(new sal_uInt32[nDelCount]);
 
-            pNumFmtShell->GetUpdateData( pDelArr.get(), nDelCount );
-            pNumItem->SetDelFormatArray( pDelArr.get(), nDelCount );
+            pNumItem->SetDelFormats( aDelFormats );
 
             if(bNumItemFlag)
             {
diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx
index 24210c560bda..6643ca7a3dea 100644
--- a/dbaccess/source/ui/misc/UITools.cxx
+++ b/dbaccess/source/ui/misc/UITools.cxx
@@ -873,12 +873,10 @@ bool callColumnFormatDialog(vcl::Window* _pParent,
         {
             const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
             const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem);
-            if (pInfoItem && pInfoItem->GetDelCount())
+            if (pInfoItem)
             {
-                const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
-
-                for (sal_uInt32 i=0; i< pInfoItem->GetDelCount(); ++i)
-                    _pFormatter->DeleteEntry(pDeletedKeys[i]);
+                for (sal_uInt32 key : pInfoItem->GetDelFormats())
+                    _pFormatter->DeleteEntry(key);
             }
         }
     }
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index 1abe2f2c8237..803bc84abb49 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2658,12 +2658,10 @@ namespace pcr
 
                 const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
                 const SvxNumberInfoItem* pInfoItem = dynamic_cast< const SvxNumberInfoItem* >( pItem );
-                if (pInfoItem && pInfoItem->GetDelCount())
+                if (pInfoItem)
                 {
-                    const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
-
-                    for (sal_uInt32 i=0; i< pInfoItem->GetDelCount(); ++i)
-                        pFormatter->DeleteEntry(pDeletedKeys[i]);
+                    for (sal_uInt32 key : pInfoItem->GetDelFormats())
+                        pFormatter->DeleteEntry(key);
                 }
 
                 pItem = nullptr;
diff --git a/include/svx/numfmtsh.hxx b/include/svx/numfmtsh.hxx
index 8c1731cb1f73..3cecade46e68 100644
--- a/include/svx/numfmtsh.hxx
+++ b/include/svx/numfmtsh.hxx
@@ -144,8 +144,7 @@ public:
     bool                FindEntry( const OUString& rFmtString, sal_uInt32* pAt = nullptr );
 
     void                ValidateNewEntries() { bUndoAddList = false; }
-    size_t              GetUpdateDataCount() const;
-    void                GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize );
+    std::vector<sal_uInt32> const & GetUpdateData() const;
 
     void                SetCurNumFmtKey( sal_uInt32 nNew )  { nCurFormatKey = nNew; }
     sal_uInt32          GetCurNumFmtKey() const             { return nCurFormatKey; }
diff --git a/include/svx/numinf.hxx b/include/svx/numinf.hxx
index 5b87881cbce5..f49e48b2310d 100644
--- a/include/svx/numinf.hxx
+++ b/include/svx/numinf.hxx
@@ -56,12 +56,10 @@ public:
     const OUString&         GetValueString() const { return aStringVal; }
     double                  GetValueDouble() const  { return nDoubleVal; }
 
-    const sal_uInt32*       GetDelArray() const { return pDelFormatArr.get(); }
-    void                    SetDelFormatArray( const sal_uInt32* pData,
-                                               const sal_uInt32  nCount );
+    const std::vector<sal_uInt32> & GetDelFormats() const { return mvDelFormats; }
+    void                    SetDelFormats( std::vector<sal_uInt32> const & );
 
     SvxNumberValueType      GetValueType() const { return eValueType; }
-    sal_uInt32              GetDelCount() const  { return nDelCount; }
 
 private:
     SvNumberFormatter*  pFormatter;
@@ -69,9 +67,7 @@ private:
     OUString            aStringVal;
     double              nDoubleVal;
 
-    std::unique_ptr<sal_uInt32[]>
-                        pDelFormatArr;
-    sal_uInt32          nDelCount;
+    std::vector<sal_uInt32> mvDelFormats;
 };
 
 #endif
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 5215deb2c74f..54aa18c4516f 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -386,15 +386,8 @@ SvxNumberInfoItem* ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, const S
 void ScTabViewShell::UpdateNumberFormatter(
                         const SvxNumberInfoItem& rInfoItem )
 {
-    const sal_uInt32 nDelCount = rInfoItem.GetDelCount();
-
-    if ( nDelCount > 0 )
-    {
-        const sal_uInt32* pDelArr = rInfoItem.GetDelArray();
-
-        for ( sal_uInt32 i=0; i<nDelCount; i++ )
-            rInfoItem.GetNumberFormatter()->DeleteEntry( pDelArr[i] );
-    }
+    for ( sal_uInt32 key : rInfoItem.GetDelFormats() )
+        rInfoItem.GetNumberFormatter()->DeleteEntry( key );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
index e2b7faf2ece7..673ed349e4a3 100644
--- a/svx/source/items/numfmtsh.cxx
+++ b/svx/source/items/numfmtsh.cxx
@@ -177,21 +177,9 @@ SvxNumberFormatShell::~SvxNumberFormatShell()
 }
 
 
-size_t SvxNumberFormatShell::GetUpdateDataCount() const
+std::vector<sal_uInt32> const & SvxNumberFormatShell::GetUpdateData() const
 {
-    return aDelList.size();
-}
-
-
-void SvxNumberFormatShell::GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize )
-{
-    const size_t nListSize = aDelList.size();
-
-    DBG_ASSERT( pDelArray && ( nSize == nListSize ), "Array not initialised!" );
-
-    if ( pDelArray && ( nSize == nListSize ) )
-        for (std::vector<sal_uInt32>::const_iterator it(aDelList.begin()); it != aDelList.end(); ++it )
-            *pDelArray++ = *it;
+    return aDelList;
 }
 
 
diff --git a/svx/source/items/numinf.cxx b/svx/source/items/numinf.cxx
index 0dcf67964b1b..f47706ad5936 100644
--- a/svx/source/items/numinf.cxx
+++ b/svx/source/items/numinf.cxx
@@ -26,9 +26,7 @@
     pFormatter      ( pNum ),           \
     eValueType      ( eVal ),           \
     aStringVal      ( rStr ),           \
-    nDoubleVal      ( nDouble ),        \
-    pDelFormatArr   ( nullptr ),           \
-    nDelCount       ( 0 )
+    nDoubleVal      ( nDouble )        \
 
 SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
 
@@ -83,17 +81,8 @@ SvxNumberInfoItem::SvxNumberInfoItem( const SvxNumberInfoItem& rItem ) :
     eValueType   ( rItem.eValueType ),
     aStringVal   ( rItem.aStringVal ),
     nDoubleVal   ( rItem.nDoubleVal ),
-    pDelFormatArr( nullptr ),
-    nDelCount    ( rItem.nDelCount )
-
+    mvDelFormats( rItem.mvDelFormats )
 {
-    if ( rItem.nDelCount > 0 )
-    {
-        pDelFormatArr.reset( new sal_uInt32[ rItem.nDelCount ] );
-
-        for ( sal_uInt32 i = 0; i < rItem.nDelCount; ++i )
-            pDelFormatArr[i] = rItem.pDelFormatArr[i];
-    }
 }
 
 
@@ -121,30 +110,11 @@ bool SvxNumberInfoItem::operator==( const SfxPoolItem& rItem ) const
 
     const SvxNumberInfoItem& rOther = static_cast<const SvxNumberInfoItem&>(rItem);
 
-    bool bEqual = false;
-
-    if ( nDelCount == rOther.nDelCount )
-    {
-        if ( nDelCount > 0 )
-        {
-            if ( pDelFormatArr != nullptr && rOther.pDelFormatArr != nullptr )
-            {
-                bEqual = true;
-
-                for ( sal_uInt32 i = 0; i < nDelCount && bEqual; ++i )
-                    bEqual = ( pDelFormatArr[i] == rOther.pDelFormatArr[i] );
-            }
-        }
-        else if ( nDelCount == 0 )
-            bEqual = ( pDelFormatArr == nullptr && rOther.pDelFormatArr == nullptr );
-
-        bEqual = bEqual &&
-                 pFormatter == rOther.pFormatter &&
-                 eValueType == rOther.eValueType &&
-                 nDoubleVal == rOther.nDoubleVal &&
-                 aStringVal == rOther.aStringVal;
-    }
-    return bEqual;
+    return mvDelFormats == rOther.mvDelFormats &&
+           pFormatter == rOther.pFormatter &&
+           eValueType == rOther.eValueType &&
+           nDoubleVal == rOther.nDoubleVal &&
+           aStringVal == rOther.aStringVal;
 }
 
 
@@ -154,23 +124,9 @@ SfxPoolItem* SvxNumberInfoItem::Clone( SfxItemPool * ) const
 }
 
 
-void SvxNumberInfoItem::SetDelFormatArray( const sal_uInt32* pData,
-                                           const sal_uInt32 nCount )
+void SvxNumberInfoItem::SetDelFormats( std::vector<sal_uInt32> const & aData )
 {
-    pDelFormatArr.reset();
-
-    nDelCount = nCount;
-
-    if ( nCount > 0 )
-    {
-        pDelFormatArr.reset( new sal_uInt32[ nCount ] );
-
-        if ( pData != nullptr )
-        {
-            for ( sal_uInt32 i = 0; i < nCount; ++i )
-                pDelFormatArr[i] = pData[i];
-        }
-    }
+    mvDelFormats = aData;
 }
 
 
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index c319c895483c..fecda67dd7cf 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -681,26 +681,23 @@ void SwTableShell::Execute(SfxRequest &rReq)
 
                 if (RET_OK == pDlg->Execute())
                 {
-                    const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()->
-                                    GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+                    const SvxNumberInfoItem* pNumberFormatItem
+                        = GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
 
-                    if( pNumberFormatItem && 0 != static_cast<const SvxNumberInfoItem*>(pNumberFormatItem)->GetDelCount() )
+                    if( pNumberFormatItem )
                     {
-                        const sal_uInt32* pDelArr = static_cast<const SvxNumberInfoItem*>(
-                                                        pNumberFormatItem)->GetDelArray();
-
-                        for ( sal_uInt32 i = 0; i < static_cast<const SvxNumberInfoItem*>(pNumberFormatItem)->GetDelCount(); i++ )
-                            static_cast<const SvxNumberInfoItem*>(pNumberFormatItem)->
-                            GetNumberFormatter()->DeleteEntry( pDelArr[i] );
+                        for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
+                            pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
                     }
 
+                    const SfxPoolItem* pNumberFormatValueItem = nullptr;
                     if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(
-                        SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatItem ))
+                        SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatValueItem ))
                     {
                         SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
                                     svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT>{} );
                         aBoxFormatSet.Put( SwTableBoxNumFormat(
-                                static_cast<const SfxUInt32Item*>(pNumberFormatItem)->GetValue() ));
+                                static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() ));
                         rSh.SetTableBoxFormulaAttrs( aBoxFormatSet );
 
                     }
diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx
index 089e0e9f7445..fef26cf61c3b 100644
--- a/sw/source/uibase/utlui/numfmtlb.cxx
+++ b/sw/source/uibase/utlui/numfmtlb.cxx
@@ -378,12 +378,10 @@ IMPL_LINK( NumFormatListBox, SelectHdl, ListBox&, rBox, void )
         const SfxPoolItem* pItem = pView->GetDocShell()->
                         GetItem( SID_ATTR_NUMBERFORMAT_INFO );
 
-        if( pItem && 0 != static_cast<const SvxNumberInfoItem*>(pItem)->GetDelCount() )
+        if( pItem )
         {
-            const sal_uInt32* pDelArr = static_cast<const SvxNumberInfoItem*>(pItem)->GetDelArray();
-
-            for ( sal_uInt32 i = 0; i < static_cast<const SvxNumberInfoItem*>(pItem)->GetDelCount(); i++ )
-                pFormatter->DeleteEntry( pDelArr[i] );
+            for ( sal_uInt32 key : static_cast<const SvxNumberInfoItem*>(pItem)->GetDelFormats() )
+                pFormatter->DeleteEntry( key );
         }
 
         const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();


More information about the Libreoffice-commits mailing list