[Libreoffice-commits] core.git: filter/source xmloff/source

Noel Grandin noel at peralex.com
Thu Nov 19 01:06:09 PST 2015


 filter/source/msfilter/msdffimp.cxx    |   54 +++--------------
 xmloff/source/draw/ximpcustomshape.cxx |  103 +++------------------------------
 xmloff/source/draw/ximpshap.cxx        |    8 --
 xmloff/source/style/prstylei.cxx       |   13 +---
 4 files changed, 28 insertions(+), 150 deletions(-)

New commits:
commit 49c5b9a98c45cd082e7fa6b6e399c39cd664ed66
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Nov 19 10:37:10 2015 +0200

    use comphelper::containerToSequence
    
    Change-Id: I223ff4af01ab2da92da0c26d32457204a5008c4a

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index f637f66..41c1e5a 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -34,6 +34,7 @@
 #include <comphelper/string.hxx>
 #include <comphelper/seqstream.hxx>
 #include <comphelper/storagehelper.hxx>
+#include <comphelper/sequence.hxx>
 #include <sot/exchange.hxx>
 #include <sot/storinfo.hxx>
 #include <vcl/cvtgrf.hxx>
@@ -1532,7 +1533,6 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt
 
     // creating SdrCustomShapeGeometryItem
 
-    typedef uno::Sequence< beans::PropertyValue > PropSeq;
     typedef std::vector< beans::PropertyValue > PropVec;
     typedef PropVec::iterator PropVecIter;
     PropVecIter aIter;
@@ -1861,15 +1861,8 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt
             rSet.Put( XSecondaryFillColorItem( OUString(), rManager.MSO_CLR_ToColor(
                 GetPropertyValue( DFF_Prop_c3DExtrusionColor, 0 ), DFF_Prop_c3DExtrusionColor ) ) );
         // pushing the whole Extrusion element
-        const OUString sExtrusion( "Extrusion" );
-        PropSeq aExtrusionPropSeq( aExtrusionPropVec.size() );
-        aIter = aExtrusionPropVec.begin();
-        aEnd = aExtrusionPropVec.end();
-        beans::PropertyValue* pExtrusionValues = aExtrusionPropSeq.getArray();
-        while ( aIter != aEnd )
-            *pExtrusionValues++ = *aIter++;
-        aProp.Name = sExtrusion;
-        aProp.Value <<= aExtrusionPropSeq;
+        aProp.Name = "Extrusion";
+        aProp.Value <<= comphelper::containerToSequence(aExtrusionPropVec);
         aPropVec.push_back( aProp );
     }
 
@@ -2088,18 +2081,11 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt
                 }
                 if ( !aHandlePropVec.empty() )
                 {
-                    PropSeq aHandlePropSeq( aHandlePropVec.size() );
-                    aIter = aHandlePropVec.begin();
-                    aEnd = aHandlePropVec.end();
-                    beans::PropertyValue* pHandleValues = aHandlePropSeq.getArray();
-                    while ( aIter != aEnd )
-                        *pHandleValues++ = *aIter++;
-                    aHandles[ i ] = aHandlePropSeq;
+                    aHandles[ i ] = comphelper::containerToSequence(aHandlePropVec);
                 }
             }
             // pushing the whole Handles element
-            const OUString sHandles( "Handles" );
-            aProp.Name = sHandles;
+            aProp.Name = "Handles";
             aProp.Value <<= aHandles;
             aPropVec.push_back( aProp );
         }
@@ -2435,15 +2421,8 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt
         // pushing the whole Path element
         if ( !aPathPropVec.empty() )
         {
-            const OUString sPath( "Path" );
-            PropSeq aPathPropSeq( aPathPropVec.size() );
-            aIter = aPathPropVec.begin();
-            aEnd = aPathPropVec.end();
-            beans::PropertyValue* pPathValues = aPathPropSeq.getArray();
-            while ( aIter != aEnd )
-                *pPathValues++ = *aIter++;
-            aProp.Name = sPath;
-            aProp.Value <<= aPathPropSeq;
+            aProp.Name = "Path";
+            aProp.Value <<= comphelper::containerToSequence(aPathPropVec);
             aPropVec.push_back( aProp );
         }
     }
@@ -2504,15 +2483,8 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt
         aTextPathPropVec.push_back( aProp );
 
         // pushing the whole TextPath element
-        const OUString sTextPath( "TextPath" );
-        PropSeq aTextPathPropSeq( aTextPathPropVec.size() );
-        aIter = aTextPathPropVec.begin();
-        aEnd = aTextPathPropVec.end();
-        beans::PropertyValue* pTextPathValues = aTextPathPropSeq.getArray();
-        while ( aIter != aEnd )
-            *pTextPathValues++ = *aIter++;
-        aProp.Name = sTextPath;
-        aProp.Value <<= aTextPathPropSeq;
+        aProp.Name = "TextPath";
+        aProp.Value <<= comphelper::containerToSequence(aTextPathPropVec);
         aPropVec.push_back( aProp );
     }
 
@@ -2554,13 +2526,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt
     }
 
     // creating the whole property set
-    PropSeq aSeq( aPropVec.size() );
-    beans::PropertyValue* pValues = aSeq.getArray();
-    aIter = aPropVec.begin();
-    aEnd = aPropVec.end();
-    while ( aIter != aEnd )
-        *pValues++ = *aIter++;
-    rSet.Put( SdrCustomShapeGeometryItem( aSeq ) );
+    rSet.Put( SdrCustomShapeGeometryItem( comphelper::containerToSequence(aPropVec) ) );
 }
 
 void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet ) const
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index 51aaca6..21f0029 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -45,6 +45,7 @@
 #include <com/sun/star/drawing/EnhancedCustomShapeTextPathMode.hpp>
 #include <com/sun/star/drawing/ProjectionMode.hpp>
 #include <sax/tools/converter.hxx>
+#include <comphelper/sequence.hxx>
 #include <unordered_map>
 
 using namespace ::com::sun::star;
@@ -455,17 +456,9 @@ void GetDoubleSequence( std::vector< com::sun::star::beans::PropertyValue >& rDe
 
     if ( !vDirection.empty() )
     {
-        uno::Sequence< double > aDirectionsSeq( vDirection.size() );
-        std::vector< double >::const_iterator aIter = vDirection.begin();
-        std::vector< double >::const_iterator aEnd = vDirection.end();
-        double* pValues = aDirectionsSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = EASGet( eDestProp );
-        aProp.Value <<= aDirectionsSeq;
+        aProp.Value <<= comphelper::containerToSequence(vDirection);
         rDest.push_back( aProp );
     }
 }
@@ -550,17 +543,9 @@ sal_Int32 GetEnhancedParameterPairSequence( std::vector< com::sun::star::beans::
     }
     if ( !vParameter.empty() )
     {
-        uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > aParameterSeq( vParameter.size() );
-        std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aIter = vParameter.begin();
-        std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aEnd = vParameter.end();
-        com::sun::star::drawing::EnhancedCustomShapeParameterPair* pValues = aParameterSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = EASGet( eDestProp );
-        aProp.Value <<= aParameterSeq;
+        aProp.Value <<= comphelper::containerToSequence(vParameter);
         rDest.push_back( aProp );
     }
     return vParameter.size();
@@ -583,17 +568,9 @@ void GetEnhancedRectangleSequence( std::vector< com::sun::star::beans::PropertyV
     }
     if ( !vTextFrame.empty() )
     {
-        uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > aTextFrameSeq( vTextFrame.size() );
-        std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame >::const_iterator aIter = vTextFrame.begin();
-        std::vector< com::sun::star::drawing::EnhancedCustomShapeTextFrame >::const_iterator aEnd = vTextFrame.end();
-        com::sun::star::drawing::EnhancedCustomShapeTextFrame* pValues = aTextFrameSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = EASGet( eDestProp );
-        aProp.Value <<= aTextFrameSeq;
+        aProp.Value <<= comphelper::containerToSequence(vTextFrame);
         rDest.push_back( aProp );
     }
 }
@@ -823,32 +800,16 @@ void GetEnhancedPath( std::vector< com::sun::star::beans::PropertyValue >& rDest
             nParameterCount = 0;
         }
     }
-    // adding the Coordinates property
-    uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair > seqCoordinates( vCoordinates.size() );
-    std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aCoordinatesIter = vCoordinates.begin();
-    std::vector< com::sun::star::drawing::EnhancedCustomShapeParameterPair >::const_iterator aCoordinatesEnd = vCoordinates.end();
-    com::sun::star::drawing::EnhancedCustomShapeParameterPair* pCoordinateValues = seqCoordinates.getArray();
-
-    while ( aCoordinatesIter != aCoordinatesEnd )
-        *pCoordinateValues++ = *aCoordinatesIter++;
 
+    // adding the Coordinates property
     beans::PropertyValue aProp;
     aProp.Name = EASGet( EAS_Coordinates );
-    aProp.Value <<= seqCoordinates;
+    aProp.Value <<= comphelper::containerToSequence(vCoordinates);
     rDest.push_back( aProp );
 
-
     // adding the Segments property
-    uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments( vSegments.size() );
-    std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >::const_iterator aSegmentsIter = vSegments.begin();
-    std::vector< com::sun::star::drawing::EnhancedCustomShapeSegment >::const_iterator aSegmentsEnd = vSegments.end();
-    com::sun::star::drawing::EnhancedCustomShapeSegment* pSegmentValues = seqSegments.getArray();
-
-    while ( aSegmentsIter != aSegmentsEnd )
-        *pSegmentValues++ = *aSegmentsIter++;
-
     aProp.Name = EASGet( EAS_Segments );
-    aProp.Value <<= seqSegments;
+    aProp.Value <<= comphelper::containerToSequence(vSegments);
     rDest.push_back( aProp );
 }
 
@@ -875,17 +836,9 @@ void GetAdjustmentValues( std::vector< com::sun::star::beans::PropertyValue >& r
     sal_Int32 nAdjustmentValues = vAdjustmentValue.size();
     if ( nAdjustmentValues )
     {
-        uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentValues( nAdjustmentValues );
-        std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >::const_iterator aIter = vAdjustmentValue.begin();
-        std::vector< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue >::const_iterator aEnd = vAdjustmentValue.end();
-        com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue* pValues = aAdjustmentValues.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = EASGet( EAS_AdjustmentValues );
-        aProp.Value <<= aAdjustmentValues;
+        aProp.Value <<= comphelper::containerToSequence(vAdjustmentValue);
         rDest.push_back( aProp );
     }
 }
@@ -1155,17 +1108,9 @@ void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::Property
 {
     if ( !rElement.empty() )
     {
-        uno::Sequence< beans::PropertyValues > aPropSeq( rElement.size() );
-        std::vector< beans::PropertyValues >::const_iterator aIter = rElement.begin();
-        std::vector< beans::PropertyValues >::const_iterator aEnd = rElement.end();
-        beans::PropertyValues* pValues = aPropSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = rElementName;
-        aProp.Value <<= aPropSeq;
+        aProp.Value <<= comphelper::containerToSequence(rElement);
         rPropVec.push_back( aProp );
     }
 }
@@ -1176,17 +1121,9 @@ void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::Property
 {
     if ( !rElement.empty() )
     {
-        uno::Sequence< OUString > aPropSeq( rElement.size() );
-        std::vector< OUString >::const_iterator aIter = rElement.begin();
-        std::vector< OUString >::const_iterator aEnd = rElement.end();
-        OUString* pValues = aPropSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = rElementName;
-        aProp.Value <<= aPropSeq;
+        aProp.Value <<= comphelper::containerToSequence(rElement);
         rPropVec.push_back( aProp );
     }
 }
@@ -1197,17 +1134,9 @@ void SdXMLCustomShapePropertyMerge( std::vector< com::sun::star::beans::Property
 {
     if ( !rElement.empty() )
     {
-        uno::Sequence< beans::PropertyValue > aPropSeq( rElement.size() );
-        std::vector< beans::PropertyValue >::const_iterator aIter = rElement.begin();
-        std::vector< beans::PropertyValue >::const_iterator aEnd = rElement.end();
-        beans::PropertyValue* pValues = aPropSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
         beans::PropertyValue aProp;
         aProp.Name = rElementName;
-        aProp.Value <<= aPropSeq;
+        aProp.Value <<= comphelper::containerToSequence(rElement);
         rPropVec.push_back( aProp );
     }
 }
@@ -1450,15 +1379,7 @@ SvXMLImportContext* XMLEnhancedCustomShapeContext::CreateChildContext( sal_uInt1
                     break;
             }
         }
-        beans::PropertyValues aPropSeq( aHandle.size() );
-        std::vector< beans::PropertyValue >::const_iterator aIter = aHandle.begin();
-        std::vector< beans::PropertyValue >::const_iterator aEnd = aHandle.end();
-        beans::PropertyValue* pValues = aPropSeq.getArray();
-
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
-
-        maHandles.push_back( aPropSeq );
+        maHandles.push_back( comphelper::containerToSequence(aHandle) );
     }
     return SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
 }
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index bad7295..41704fa 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -58,6 +58,7 @@
 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
 
 #include <sax/tools/converter.hxx>
+#include <comphelper/sequence.hxx>
 
 #include "PropertySetMerger.hxx"
 #include <xmloff/families.hxx>
@@ -3864,12 +3865,7 @@ void SdXMLCustomShapeContext::EndElement()
         const OUString sCustomShapeGeometry    (  "CustomShapeGeometry"  );
 
         // converting the vector to a sequence
-        uno::Sequence< beans::PropertyValue > aSeq( maCustomShapeGeometry.size() );
-        beans::PropertyValue* pValues = aSeq.getArray();
-        std::vector< beans::PropertyValue >::const_iterator aIter( maCustomShapeGeometry.begin() );
-        std::vector< beans::PropertyValue >::const_iterator aEnd( maCustomShapeGeometry.end() );
-        while ( aIter != aEnd )
-            *pValues++ = *aIter++;
+        uno::Sequence< beans::PropertyValue > aSeq( comphelper::containerToSequence(maCustomShapeGeometry) );
 
         try
         {
diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx
index b939c8f..2fe2953 100644
--- a/xmloff/source/style/prstylei.cxx
+++ b/xmloff/source/style/prstylei.cxx
@@ -36,6 +36,7 @@
 #include <xmloff/xmlerror.hxx>
 #include <xmloff/xmltypes.hxx>
 #include <xmloff/maptype.hxx>
+#include <comphelper/sequence.hxx>
 
 //UUUU
 #include <com/sun/star/drawing/FillStyle.hpp>
@@ -401,16 +402,10 @@ void XMLPropStyleContext::CreateAndInsert( bool bOverwrite )
                     }
 
                     nCount = aNameSet.size();
-                    Sequence < OUString > aNames( nCount );
-                    OUString *pNames = aNames.getArray();
-                    PropertyNameSet::iterator aIter = aNameSet.begin();
-                    while( aIter != aNameSet.end() )
-                        *pNames++ = *aIter++;
-
-                    Sequence < PropertyState > aStates(
-                        xPropState->getPropertyStates( aNames ) );
+                    Sequence<OUString> aNames( comphelper::containerToSequence<OUString>(aNameSet) );
+                    Sequence < PropertyState > aStates( xPropState->getPropertyStates(aNames) );
                     const PropertyState *pStates = aStates.getConstArray();
-                    pNames = aNames.getArray();
+                    OUString* pNames = aNames.getArray();
 
                     for( i = 0; i < nCount; i++ )
                     {


More information about the Libreoffice-commits mailing list