Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi Kohei,
Thanks for review!

First, for your svl patch:

1) in SfxIntegerListItem::GetList(), you do

+        rList.insert( aIt, m_aList[n] );

but you can simply call push_back here to append new data to the end of
the vector.  Also, let's use pre-increment on iterators in the "for"
loop there i.e. instead of doing aIt++, do ++aIt.  Post-increment on
iterators is generally more expensive than pre-increment, so it's best
to stick with pre-increments.

Done, and with push_back we don't need iterator.

2) Your new constructors take arrays of different integer type; one
takes std::vector<sal_uLong> while the other takes
uno::Sequence<sal_Int32>.  Let's just stick with one type and use
sal_Int32 in both cases since that's the integer type that this class
uses internally.

Done and checked in other places to use right type.

And for your sc patch:

3) In ScTabViewShell::Execute() you do

-            SvULongs aIndexList( 4, 4 );
+            ::std::vector < sal_uLong > aIndexList( 4, 4 );

but this actually changes the behavior of the code.  The arguments to
SvULong's constructor controls how the internal array is laid out during
initialization but it doesn't populate the container with data.
Vector's ctor arguments OTOH populate the container with data.  So, your
new code initializes aIndexList with 4 elements of value 4, which is not
what the code intends to do.  You can simply do without passing any
arguments to aIndexList there.

Done, Now I understand the SvULong's constructor. Also changed type to
sal_uInt32.

4) Last but not least, please state that you are submitting your patches
under LGPLv3+/MPL 1.1.

Of course and future also.

Best Regards,
        Maciej

From a4f2da5241afdd8062f9611ca1f580df1c2ffe54 Mon Sep 17 00:00:00 2001
From: Maciej Rumianowski <maciej.rumianowski@gmail.com>
Date: Tue, 19 Jul 2011 10:50:54 +0200
Subject: [PATCH] Get rid of SvULongs in calc

Instead of SvULongs use ::std::vector < sal_Int32 >
---
 .../itemsetwrapper/DataPointItemConverter.cxx      |    7 +------
 .../itemsetwrapper/SeriesOptionsItemConverter.cxx  |    7 +------
 chart2/source/view/main/ChartItemPool.cxx          |    8 +++-----
 sc/source/ui/docshell/impex.cxx                    |   11 +++++------
 sc/source/ui/view/tabvwsh3.cxx                     |   11 +++++------
 5 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 3802ffc..76e7db0 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -54,8 +54,6 @@
 #include <editeng/brshitem.hxx>
 //SfxIntegerListItem
 #include <svl/ilstitem.hxx>
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
 #include <vcl/graph.hxx>
 #include <com/sun/star/graphic/XGraphic.hpp>
 
@@ -641,10 +639,7 @@ void DataPointItemConverter::FillSpecialItem(
 
         case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS:
         {
-            SvULongs aList;
-            for ( sal_Int32 nN=0; nN<m_aAvailableLabelPlacements.getLength(); nN++ )
-                aList.Insert( m_aAvailableLabelPlacements[nN], sal::static_int_cast< sal_uInt16 
(nN) );
-            rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) );
+            rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aAvailableLabelPlacements ) );
         }
         break;
 
diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
index a199b66..7df2d61 100644
--- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx
@@ -51,8 +51,6 @@
 
 //SfxIntegerListItem
 #include <svl/ilstitem.hxx>
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
 
 #include <rtl/math.hxx>
 #include <functional>
@@ -433,10 +431,7 @@ void SeriesOptionsItemConverter::FillSpecialItem(
         }
         case SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS:
         {
-            SvULongs aList;
-            for ( sal_Int32 nN=0; nN<m_aSupportedMissingValueTreatments.getLength(); nN++ )
-                aList.Insert( m_aSupportedMissingValueTreatments[nN], sal::static_int_cast< 
sal_uInt16 >(nN) );
-            rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) );
+            rOutItemSet.Put( SfxIntegerListItem( nWhichId, m_aSupportedMissingValueTreatments ) );
             break;
         }
         case SCHATTR_INCLUDE_HIDDEN_CELLS:
diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx
index 2cdac8f..aa81e06 100644
--- a/chart2/source/view/main/ChartItemPool.cxx
+++ b/chart2/source/view/main/ChartItemPool.cxx
@@ -39,10 +39,9 @@
 #include <svl/stritem.hxx>
 #include <svl/rectitem.hxx>
 #include <svl/ilstitem.hxx>
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
 #include <editeng/editids.hrc>
 #include <svx/svxids.hrc>
+#include <vector>
 
 #include <com/sun/star/chart2/LegendPosition.hpp>
 
@@ -63,8 +62,7 @@ ChartItemPool::ChartItemPool():
     ppPoolDefaults[SCHATTR_DATADESCR_SHOW_SYMBOL    - SCHATTR_START] = new 
SfxBoolItem(SCHATTR_DATADESCR_SHOW_SYMBOL);
     ppPoolDefaults[SCHATTR_DATADESCR_SEPARATOR      - SCHATTR_START] = new 
SfxStringItem(SCHATTR_DATADESCR_SEPARATOR,C2U(" "));
     ppPoolDefaults[SCHATTR_DATADESCR_PLACEMENT      - SCHATTR_START] = new 
SfxInt32Item(SCHATTR_DATADESCR_PLACEMENT,0);
-    SvULongs aTmp;
-    ppPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new 
SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS,aTmp);
+    ppPoolDefaults[SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS - SCHATTR_START] = new 
SfxIntegerListItem(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, ::std::vector < sal_Int32 >() );
     ppPoolDefaults[SCHATTR_DATADESCR_NO_PERCENTVALUE    - SCHATTR_START] = new 
SfxBoolItem(SCHATTR_DATADESCR_NO_PERCENTVALUE);
     ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_VALUE  - SCHATTR_START] = new 
SfxUInt32Item(SCHATTR_PERCENT_NUMBERFORMAT_VALUE, 0);
     ppPoolDefaults[SCHATTR_PERCENT_NUMBERFORMAT_SOURCE - SCHATTR_START] = new 
SfxBoolItem(SCHATTR_PERCENT_NUMBERFORMAT_SOURCE);
@@ -157,7 +155,7 @@ ChartItemPool::ChartItemPool():
     ppPoolDefaults[SCHATTR_CLOCKWISE            - SCHATTR_START] = new SfxBoolItem( 
SCHATTR_CLOCKWISE, sal_False );
 
     ppPoolDefaults[SCHATTR_MISSING_VALUE_TREATMENT    - SCHATTR_START] = new 
SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT, 0);
-    ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new 
SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,aTmp);
+    ppPoolDefaults[SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS - SCHATTR_START] = new 
SfxIntegerListItem(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, ::std::vector < sal_Int32 >() );
     ppPoolDefaults[SCHATTR_INCLUDE_HIDDEN_CELLS - SCHATTR_START] = new 
SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, sal_True);
 
     ppPoolDefaults[SCHATTR_AXIS_FOR_ALL_SERIES  - SCHATTR_START] = new 
SfxInt32Item(SCHATTR_AXIS_FOR_ALL_SERIES, 0);
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 7b0e30d..d13f3e2 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -49,8 +49,6 @@ class StarBASIC;
 #include <rtl/math.hxx>
 #include <svtools/htmlout.hxx>
 #include <svl/zforlist.hxx>
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
 #include <sot/formats.hxx>
 #include <sfx2/mieclip.hxx>
 #include <unotools/charclass.hxx>
@@ -58,6 +56,7 @@ class StarBASIC;
 #include <unotools/calendarwrapper.hxx>
 #include <com/sun/star/i18n/CalendarFieldIndex.hpp>
 #include <unotools/transliterationwrapper.hxx>
+#include <vector>
 
 #include "global.hxx"
 #include "scerrors.hxx"
@@ -1544,7 +1543,7 @@ sal_Bool ScImportExport::Sylk2Doc( SvStream& rStrm )
     SCROW nEndRow = aRange.aEnd.Row();
     sal_uLong nOldPos = rStrm.Tell();
     sal_Bool bData = sal_Bool( !bSingle );
-    SvULongs aFormats;
+    ::std::vector< sal_uInt32 > aFormats;
 
     if( !bSingle)
         bOk = StartPaste();
@@ -1730,9 +1729,9 @@ sal_Bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                     if( nCol > nEndCol )
                         nEndCol = nCol;
                 }
-                if ( 0 <= nFormat && nFormat < aFormats.Count() )
+                if ( 0 <= nFormat && nFormat < (sal_Int32)aFormats.size() )
                 {
-                    sal_uLong nKey = aFormats[(sal_uInt16)nFormat];
+                    sal_uInt32 nKey = aFormats[nFormat];
                     pDoc->ApplyAttr( nCol, nRow, aRange.aStart.Tab(),
                             SfxUInt32Item( ATTR_VALUE_FORMAT, nKey ) );
                 }
@@ -1759,7 +1758,7 @@ sal_Bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                         ScGlobal::eLnge );
                     if ( nCheckPos )
                         nKey = 0;
-                    aFormats.Insert( nKey, aFormats.Count() );
+                    aFormats.push_back( nKey );
                 }
             }
             else if( cTag == 'I' && *p == 'D' )
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 270542c..b8b1069 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -73,8 +73,7 @@
 #include "protectiondlg.hxx"
 
 #include <svl/ilstitem.hxx>
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
+#include <vector>
 
 #include <svx/zoomslideritem.hxx>
 #include <svx/svxdlg.hxx>
@@ -810,7 +809,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
             SCTAB nTabCount = rDoc.GetTableCount();
             SCTAB nTab;
 
-            SvULongs aIndexList( 4, 4 );
+            ::std::vector < sal_Int32 > aIndexList;
             SFX_REQUEST_ARG( rReq, pItem, SfxIntegerListItem, SID_SELECT_TABLES, false );
             if ( pItem )
                 pItem->GetList( aIndexList );
@@ -839,7 +838,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                     sal_uInt16 nSelCount = pDlg->GetSelectEntryCount();
                     sal_uInt16 nSelIx;
                     for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
-                        aIndexList.Insert( pDlg->GetSelectEntryPos( nSelIx ), nSelIx );
+                        aIndexList.insert( aIndexList.begin()+nSelIx, pDlg->GetSelectEntryPos( 
nSelIx ) );
                     delete pDlg;
                     rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, aIndexList ) );
                 }
@@ -847,9 +846,9 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
                     rReq.Ignore();
             }
 
-            if ( aIndexList.Count() )
+            if ( aIndexList.size() )
             {
-                sal_uInt16 nSelCount = aIndexList.Count();
+                sal_uInt16 nSelCount = aIndexList.size();
                 sal_uInt16 nSelIx;
                 SCTAB nFirstVisTab = 0;
 
-- 
1.7.4.1

From a61e25e775bff90c83e9ef97bb7396334ef41926 Mon Sep 17 00:00:00 2001
From: Maciej Rumianowski <maciej.rumianowski@gmail.com>
Date: Tue, 19 Jul 2011 10:19:45 +0200
Subject: [PATCH] Port SfxIntegerListItem to ::std::vector

For calc to be free of SvULongs SfxIntegerListItem has to use SvULongs.
Additionaly a constructor with Sequence used in calc.
---
 svl/inc/svl/ilstitem.hxx      |    8 ++++----
 svl/source/items/ilstitem.cxx |   24 +++++++++++++++---------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/svl/inc/svl/ilstitem.hxx b/svl/inc/svl/ilstitem.hxx
index 286edf2..cd77741 100644
--- a/svl/inc/svl/ilstitem.hxx
+++ b/svl/inc/svl/ilstitem.hxx
@@ -32,8 +32,7 @@
 #include "svl/svldllapi.h"
 #include <svl/poolitem.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
-
-class SvULongs;
+#include <vector>
 
 class SVL_DLLPUBLIC SfxIntegerListItem : public SfxPoolItem
 {
@@ -43,7 +42,8 @@ public:
     TYPEINFO();
 
     SfxIntegerListItem();
-    SfxIntegerListItem( sal_uInt16 nWhich, const SvULongs& rList );
+    SfxIntegerListItem( sal_uInt16 nWhich, const ::std::vector < sal_Int32 >& rList );
+    SfxIntegerListItem( sal_uInt16 nWhich, const ::com::sun::star::uno::Sequence < sal_Int32 >& 
rList );
     SfxIntegerListItem( const SfxIntegerListItem& rItem );
     ~SfxIntegerListItem();
 
@@ -52,7 +52,7 @@ public:
     ::com::sun::star::uno::Sequence < sal_Int32 > GetConstSequence() const
     { return SAL_CONST_CAST(SfxIntegerListItem *, this)->GetSequence(); }
 
-    void                    GetList( SvULongs& rList ) const;
+    void                    GetList( ::std::vector < sal_Int32 >& rList ) const;
 
     virtual int                        operator==( const SfxPoolItem& ) const;
     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
diff --git a/svl/source/items/ilstitem.cxx b/svl/source/items/ilstitem.cxx
index 1a897a8..a699f6c 100644
--- a/svl/source/items/ilstitem.cxx
+++ b/svl/source/items/ilstitem.cxx
@@ -35,20 +35,25 @@
 
 #include <svl/ilstitem.hxx>
 
-#define _SVSTDARR_ULONGS
-#include <svl/svstdarr.hxx>
-
 TYPEINIT1_AUTOFACTORY(SfxIntegerListItem, SfxPoolItem);
 
 SfxIntegerListItem::SfxIntegerListItem()
 {
 }
 
-SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const SvULongs& rList )
+SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const ::std::vector < sal_Int32 >& rList 
)
+    : SfxPoolItem( which )
+{
+    m_aList.realloc( rList.size() );
+    for ( sal_uInt16 n=0; n<rList.size(); ++n )
+        m_aList[n] = rList[n];
+}
+
+SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const ::com::sun::star::uno::Sequence < 
sal_Int32 >& rList )
     : SfxPoolItem( which )
 {
-    m_aList.realloc( rList.Count() );
-    for ( sal_uInt16 n=0; n<rList.Count(); n++ )
+    m_aList.realloc( rList.getLength() );
+    for ( sal_Int32 n=0; n<rList.getLength(); ++n )
         m_aList[n] = rList[n];
 }
 
@@ -97,10 +102,11 @@ bool SfxIntegerListItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 
)
     return true;
 }
 
-void SfxIntegerListItem::GetList( SvULongs& rList ) const
+void SfxIntegerListItem::GetList( ::std::vector< sal_Int32 >& rList ) const
 {
-    for ( sal_Int32 n=0; n<m_aList.getLength(); n++ )
-        rList.Insert( m_aList[n], sal::static_int_cast< sal_uInt16 >(n) );
+    rList.reserve( m_aList.getLength() );
+    for ( sal_Int32 n=0; n<m_aList.getLength(); ++n )
+        rList.push_back( m_aList[n] );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.