diff options
27 files changed, 283 insertions, 324 deletions
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 7f4ff6bd0f0c..9390cabd04de 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -515,14 +515,15 @@ OUString lclAddRelation( const Reference< XRelationshipAccess >& rRelations, sal OUString sId = "rId" + OUString::number( nId ); Sequence< StringPair > aEntry( bExternal ? 3 : 2 ); - aEntry[0].First = "Type"; - aEntry[0].Second = rType; - aEntry[1].First = "Target"; - aEntry[1].Second = INetURLObject::decode(rTarget, INetURLObject::DecodeMechanism::ToIUri, RTL_TEXTENCODING_UTF8); + auto pEntry = aEntry.getArray(); + pEntry[0].First = "Type"; + pEntry[0].Second = rType; + pEntry[1].First = "Target"; + pEntry[1].Second = INetURLObject::decode(rTarget, INetURLObject::DecodeMechanism::ToIUri, RTL_TEXTENCODING_UTF8); if( bExternal ) { - aEntry[2].First = "TargetMode"; - aEntry[2].Second = "External"; + pEntry[2].First = "TargetMode"; + pEntry[2].Second = "External"; } rRelations->insertRelationshipByID( sId, aEntry, true ); diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index ebcb87c3cdde..95043e497aea 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -256,11 +256,7 @@ void OOXMLDocPropHandler::UpdateDocStatistic( const OUString& aChars ) if (nInd == aSet.getLength()) aSet.realloc( nInd + 1 ); - beans::NamedValue aProp; - aProp.Name = aName; - aProp.Value <<= aChars.toInt32(); - - aSet[nInd] = aProp; + aSet.getArray()[nInd] = { aName, uno::Any(aChars.toInt32()) }; m_xDocProp->setDocumentStatistics( aSet ); } diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 4620f5b5a15c..a8ccc6cdf164 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -315,7 +315,7 @@ void AxisConverter::convertFromModel(const Reference<XCoordinateSystem>& rxCoord // minor increment Sequence< SubIncrement >& rSubIncrementSeq = rIncrementData.SubIncrements; rSubIncrementSeq.realloc( 1 ); - Any& rIntervalCount = rSubIncrementSeq[ 0 ].IntervalCount; + Any& rIntervalCount = rSubIncrementSeq.getArray()[ 0 ].IntervalCount; rIntervalCount.clear(); if( bLogScale ) { diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 324f3817d6f1..d4fa267da536 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -309,7 +309,6 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat if( bCustomLabelField ) { css::uno::Reference< XComponentContext > xContext = getComponentContext(); - uno::Sequence< css::uno::Reference< XDataPointCustomLabelField > > aSequence; auto& rParagraphs = mrModel.mxText->mxTextBody->getParagraphs(); @@ -336,7 +335,8 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat } } - aSequence.realloc( nSequenceSize ); + uno::Sequence< css::uno::Reference< XDataPointCustomLabelField > > aSequence( nSequenceSize ); + auto aSequenceRange = asNonConstRange(aSequence); int nPos = 0; @@ -373,7 +373,7 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat xCustomLabel->setString( pRun->getText() ); xCustomLabel->setFieldType( DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_TEXT ); } - aSequence[ nPos++ ] = xCustomLabel; + aSequenceRange[ nPos++ ] = xCustomLabel; } if( nParagraphs > 1 && nPos < nSequenceSize ) @@ -381,7 +381,7 @@ void DataLabelConverter::convertFromModel( const Reference< XDataSeries >& rxDat css::uno::Reference< XDataPointCustomLabelField > xCustomLabel = DataPointCustomLabelField::create( xContext ); xCustomLabel->setFieldType( DataPointCustomLabelFieldType::DataPointCustomLabelFieldType_NEWLINE ); xCustomLabel->setString("\n"); - aSequence[ nPos++ ] = xCustomLabel; + aSequenceRange[ nPos++ ] = xCustomLabel; } } diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx index 9a0b9342ac56..36c035efcc60 100644 --- a/oox/source/drawingml/chart/typegroupconverter.cxx +++ b/oox/source/drawingml/chart/typegroupconverter.cxx @@ -328,10 +328,9 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra { case TYPECATEGORY_BAR: { - Sequence< sal_Int32 > aInt32Seq( 2 ); - aInt32Seq[ 0 ] = aInt32Seq[ 1 ] = mrModel.mnOverlap; + Sequence< sal_Int32 > aInt32Seq{ mrModel.mnOverlap, mrModel.mnOverlap }; aTypeProp.setProperty( PROP_OverlapSequence, aInt32Seq ); - aInt32Seq[ 0 ] = aInt32Seq[ 1 ] = mrModel.mnGapWidth; + aInt32Seq = { mrModel.mnGapWidth, mrModel.mnGapWidth }; aTypeProp.setProperty( PROP_GapwidthSequence, aInt32Seq ); } break; diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index 1cd5d2ebaed7..3c9ac2f6ac44 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -339,8 +339,9 @@ void Color::addTransformation( sal_Int32 nElement, sal_Int32 nValue ) } sal_Int32 nSize = maInteropTransformations.getLength(); maInteropTransformations.realloc(nSize + 1); - maInteropTransformations[nSize].Name = getColorTransformationName( nToken ); - maInteropTransformations[nSize].Value <<= nValue; + auto pInteropTransformations = maInteropTransformations.getArray(); + pInteropTransformations[nSize].Name = getColorTransformationName( nToken ); + pInteropTransformations[nSize].Value <<= nValue; } void Color::addChartTintTransformation( double fTint ) diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 62bc860ee7b2..37c42b5119dc 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -33,6 +33,8 @@ #include <comphelper/sequence.hxx> #include <sal/log.hxx> +#include <algorithm> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -187,6 +189,7 @@ void CustomShapeProperties::pushToPropSet( uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq; if ( rGeoProp.Value >>= aAdjustmentSeq ) { + auto aAdjustmentSeqRange = asNonConstRange(aAdjustmentSeq); int nIndex=0; for (auto const& adjustmentGuide : maAdjustmentGuideList) { @@ -199,7 +202,7 @@ void CustomShapeProperties::pushToPropSet( aAdjustmentVal.Value <<= adjustmentGuide.maFormula.toInt32(); aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentVal.Name = adjustmentGuide.maName; - aAdjustmentSeq[ nAdjustmentIndex ] = aAdjustmentVal; + aAdjustmentSeqRange[ nAdjustmentIndex ] = aAdjustmentVal; } } else if ( aAdjustmentSeq.hasElements() ) { EnhancedCustomShapeAdjustmentValue aAdjustmentVal; @@ -208,7 +211,7 @@ void CustomShapeProperties::pushToPropSet( aAdjustmentVal.Name = adjustmentGuide.maName; if (nIndex < aAdjustmentSeq.getLength()) { - aAdjustmentSeq[nIndex] = aAdjustmentVal; + aAdjustmentSeqRange[nIndex] = aAdjustmentVal; ++nIndex; } } @@ -246,13 +249,14 @@ void CustomShapeProperties::pushToPropSet( aPropertyMap.setProperty( PROP_ViewBox, aViewBox); Sequence< EnhancedCustomShapeAdjustmentValue > aAdjustmentValues( maAdjustmentGuideList.size() ); + auto aAdjustmentValuesRange = asNonConstRange(aAdjustmentValues); for ( std::vector<CustomShapeGuide>::size_type i = 0; i < maAdjustmentGuideList.size(); i++ ) { EnhancedCustomShapeAdjustmentValue aAdjustmentVal; aAdjustmentVal.Value <<= maAdjustmentGuideList[ i ].maFormula.toInt32(); aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentVal.Name = maAdjustmentGuideList[ i ].maName; - aAdjustmentValues[ i ] = aAdjustmentVal; + aAdjustmentValuesRange[ i ] = aAdjustmentVal; } aPropertyMap.setProperty( PROP_AdjustmentValues, aAdjustmentValues); @@ -261,11 +265,10 @@ void CustomShapeProperties::pushToPropSet( aPath.setProperty( PROP_Segments, comphelper::containerToSequence(maSegments) ); if ( maTextRect.has() ) { - Sequence< EnhancedCustomShapeTextFrame > aTextFrames(1); - aTextFrames[0].TopLeft.First = maTextRect.get().l; - aTextFrames[0].TopLeft.Second = maTextRect.get().t; - aTextFrames[0].BottomRight.First = maTextRect.get().r; - aTextFrames[0].BottomRight.Second = maTextRect.get().b; + Sequence< EnhancedCustomShapeTextFrame > aTextFrames{ + { /* tl */ { maTextRect.get().l, maTextRect.get().t }, + /* br */ { maTextRect.get().r, maTextRect.get().b } } + }; aPath.setProperty( PROP_TextFrames, aTextFrames); } @@ -274,10 +277,11 @@ void CustomShapeProperties::pushToPropSet( nParameterPairs += i.parameter.size(); Sequence< EnhancedCustomShapeParameterPair > aParameterPairs( nParameterPairs ); + auto aParameterPairsRange = asNonConstRange(aParameterPairs); sal_uInt32 k = 0; for ( auto const & i: maPath2DList ) for ( auto const & j: i.parameter ) - aParameterPairs[ k++ ] = j; + aParameterPairsRange[ k++ ] = j; aPath.setProperty( PROP_Coordinates, aParameterPairs); if ( !maPath2DList.empty() ) @@ -293,15 +297,13 @@ void CustomShapeProperties::pushToPropSet( if ( !bAllZero ) { Sequence< awt::Size > aSubViewSize( maPath2DList.size() ); - for ( std::vector<Path2D>::size_type i=0; i < maPath2DList.size(); i++ ) - { - aSubViewSize[i].Width = static_cast< sal_Int32 >( maPath2DList[i].w ); - aSubViewSize[i].Height = static_cast< sal_Int32 >( maPath2DList[i].h ); - SAL_INFO( - "oox.cscode", - "set subpath " << i << " size: " << maPath2DList[i].w - << " x " << maPath2DList[i].h); - } + std::transform(maPath2DList.begin(), maPath2DList.end(), aSubViewSize.getArray(), + [](const auto& p2d) + { + SAL_INFO("oox.cscode", + "set subpath; size: " << p2d.w << " x " << p2d.h); + return awt::Size(p2d.w, p2d.h); + }); aPath.setProperty( PROP_SubViewSize, aSubViewSize); } } @@ -310,11 +312,12 @@ void CustomShapeProperties::pushToPropSet( aPropertyMap.setProperty( PROP_Path, aPathSequence); Sequence< OUString > aEquations( maGuideList.size() ); - for ( std::vector<CustomShapeGuide>::size_type i = 0; i < maGuideList.size(); i++ ) - aEquations[ i ] = maGuideList[ i ].maFormula; + std::transform(maGuideList.begin(), maGuideList.end(), aEquations.getArray(), + [](const auto& g) { return g.maFormula; }); aPropertyMap.setProperty( PROP_Equations, aEquations); Sequence< PropertyValues > aHandles( maAdjustHandleList.size() ); + auto aHandlesRange = asNonConstRange(aHandles); for ( std::vector<AdjustHandle>::size_type i = 0; i < maAdjustHandleList.size(); i++ ) { PropertyMap aHandle; @@ -383,7 +386,7 @@ void CustomShapeProperties::pushToPropSet( if ( maAdjustHandleList[ i ].max2.has() ) aHandle.setProperty( PROP_RangeYMaximum, maAdjustHandleList[ i ].max2.get()); } - aHandles[ i ] = aHandle.makePropertyValueSequence(); + aHandlesRange[ i ] = aHandle.makePropertyValueSequence(); } aPropertyMap.setProperty( PROP_Handles, aHandles); diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx index b97f6b37ff1f..88d69a16d177 100644 --- a/oox/source/drawingml/effectproperties.cxx +++ b/oox/source/drawingml/effectproperties.cxx @@ -13,6 +13,9 @@ #include <oox/token/properties.hxx> #include <basegfx/numeric/ftools.hxx> +#include <comphelper/propertyvalue.hxx> + +#include <algorithm> namespace oox::drawingml { @@ -114,13 +117,9 @@ css::beans::PropertyValue Effect::getEffect() return aRet; css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() ); - sal_uInt32 i = 0; - for (auto const& attrib : maAttribs) - { - aSeq[i].Name = attrib.first; - aSeq[i].Value = attrib.second; - i++; - } + std::transform(maAttribs.begin(), maAttribs.end(), aSeq.getArray(), + [](const auto& attrib) + { return comphelper::makePropertyValue(attrib.first, attrib.second); }); aRet.Name = msName; aRet.Value <<= aSeq; diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 3aa54ef36ea2..12d2cd9ad2fd 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -21,6 +21,7 @@ #include <iterator> +#include <comphelper/propertyvalue.hxx> #include <drawingml/graphicproperties.hxx> #include <vcl/graph.hxx> @@ -970,24 +971,24 @@ css::beans::PropertyValue ArtisticEffectProperties::getEffect() return aRet; css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() + 1 ); + auto pSeq = aSeq.getArray(); sal_uInt32 i = 0; for (auto const& attrib : maAttribs) { - aSeq[i].Name = attrib.first; - aSeq[i].Value = attrib.second; + pSeq[i].Name = attrib.first; + pSeq[i].Value = attrib.second; i++; } if( mrOleObjectInfo.maEmbeddedData.hasElements() ) { - css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq( 2 ); - aGraphicSeq[0].Name = "Id"; - aGraphicSeq[0].Value <<= mrOleObjectInfo.maProgId; - aGraphicSeq[1].Name = "Data"; - aGraphicSeq[1].Value <<= mrOleObjectInfo.maEmbeddedData; - - aSeq[i].Name = "OriginalGraphic"; - aSeq[i].Value <<= aGraphicSeq; + css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq{ + comphelper::makePropertyValue("Id", mrOleObjectInfo.maProgId), + comphelper::makePropertyValue("Data", mrOleObjectInfo.maEmbeddedData) + }; + + pSeq[i].Name = "OriginalGraphic"; + pSeq[i].Value <<= aGraphicSeq; } aRet.Name = msName; diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 63e768a08c3f..dedde505e61a 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -371,12 +371,10 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap, if( !aPoints.empty() ) { PolyPolygonBezierCoords aMarkerCoords; - aMarkerCoords.Coordinates.realloc( 1 ); - aMarkerCoords.Coordinates[ 0 ] = comphelper::containerToSequence( aPoints ); + aMarkerCoords.Coordinates = { comphelper::containerToSequence( aPoints ) }; ::std::vector< PolygonFlags > aFlags( aPoints.size(), PolygonFlags_NORMAL ); - aMarkerCoords.Flags.realloc( 1 ); - aMarkerCoords.Flags[ 0 ] = comphelper::containerToSequence( aFlags ); + aMarkerCoords.Flags = { comphelper::containerToSequence( aFlags ) }; aNamedMarker.Name = aMarkerName; aNamedMarker.Value <<= aMarkerCoords; diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 6622001b2b0d..bc72e01dead6 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -457,7 +457,7 @@ static void lcl_createPresetShape(const uno::Reference<drawing::XShape>& xShape, auto aAdjGdList = pCustomShapePropertiesPtr->getAdjustmentGuideList(); Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustment( !aAdjGdList.empty() ? aAdjGdList.size() : 1 ); - + auto pAdjustment = aAdjustment.getArray(); int nIndex = 0; for (const auto& aEntry : aAdjGdList) { @@ -505,8 +505,8 @@ static void lcl_createPresetShape(const uno::Reference<drawing::XShape>& xShape, } } - aAdjustment[nIndex].Value <<= fValue; - aAdjustment[nIndex++].State = css::beans::PropertyState_DIRECT_VALUE; + pAdjustment[nIndex].Value <<= fValue; + pAdjustment[nIndex++].State = css::beans::PropertyState_DIRECT_VALUE; } // Set properties @@ -1171,12 +1171,13 @@ Reference< XShape > const & Shape::createAndInsert( propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag; sal_Int32 length = aGrabBag.getLength(); aGrabBag.realloc( length+1); - aGrabBag[length].Name = "mso-orig-shape-type"; + auto pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "mso-orig-shape-type"; uno::Sequence< sal_Int8 > const & aNameSeq = mpCustomShapePropertiesPtr->getShapePresetTypeName(); OUString sShapePresetTypeName(reinterpret_cast< const char* >( aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8); - aGrabBag[length].Value <<= sShapePresetTypeName; + pGrabBag[length].Value <<= sShapePresetTypeName; propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag)); } //If the text box has links then save the link information so that @@ -1188,12 +1189,13 @@ Reference< XShape > const & Shape::createAndInsert( propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag; sal_Int32 length = aGrabBag.getLength(); aGrabBag.realloc( length + 3 ); - aGrabBag[length].Name = "TxbxHasLink"; - aGrabBag[length].Value <<= isLinkedTxbx(); - aGrabBag[length + 1 ].Name = "Txbx-Id"; - aGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id; - aGrabBag[length + 2 ].Name = "Txbx-Seq"; - aGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq; + auto pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "TxbxHasLink"; + pGrabBag[length].Value <<= isLinkedTxbx(); + pGrabBag[length + 1 ].Name = "Txbx-Id"; + pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id; + pGrabBag[length + 2 ].Name = "Txbx-Seq"; + pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq; propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag)); } @@ -1248,19 +1250,17 @@ Reference< XShape > const & Shape::createAndInsert( static const OUStringLiteral aGrabBagPropName = u"FrameInteropGrabBag"; uno::Sequence<beans::PropertyValue> aGrabBag; xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag; - beans::PropertyValue aPair; - aPair.Name = "mso-rotation-angle"; - aPair.Value <<= mnRotation; + beans::PropertyValue aPair(comphelper::makePropertyValue("mso-rotation-angle", + mnRotation)); if (aGrabBag.hasElements()) { sal_Int32 nLength = aGrabBag.getLength(); aGrabBag.realloc(nLength + 1); - aGrabBag[nLength] = aPair; + aGrabBag.getArray()[nLength] = aPair; } else { - aGrabBag.realloc(1); - aGrabBag[0] = aPair; + aGrabBag = { aPair }; } xPropertySet->setPropertyValue(aGrabBagPropName, uno::makeAny(aGrabBag)); } @@ -1327,12 +1327,13 @@ Reference< XShape > const & Shape::createAndInsert( propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; sal_Int32 length = aGrabBag.getLength(); aGrabBag.realloc( length + 3 ); - aGrabBag[length].Name = "TxbxHasLink"; - aGrabBag[length].Value <<= isLinkedTxbx(); - aGrabBag[length + 1 ].Name = "Txbx-Id"; - aGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id; - aGrabBag[length + 2 ].Name = "Txbx-Seq"; - aGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq; + auto pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "TxbxHasLink"; + pGrabBag[length].Value <<= isLinkedTxbx(); + pGrabBag[length + 1 ].Name = "Txbx-Id"; + pGrabBag[length + 1 ].Value <<= getLinkedTxbxAttributes().id; + pGrabBag[length + 2 ].Name = "Txbx-Seq"; + pGrabBag[length + 2 ].Value <<= getLinkedTxbxAttributes().seq; propertySet->setPropertyValue("InteropGrabBag",uno::makeAny(aGrabBag)); } @@ -1662,14 +1663,15 @@ Reference< XShape > const & Shape::createAndInsert( void Shape::keepDiagramDrawing(XmlFilterBase& rFilterBase, const OUString& rFragmentPath) { - uno::Sequence<uno::Any> diagramDrawing(2); - // drawingValue[0] => dom, drawingValue[1] => Sequence of associated relationships sal_Int32 length = maDiagramDoms.getLength(); maDiagramDoms.realloc(length + 1); - diagramDrawing[0] <<= rFilterBase.importFragment(rFragmentPath); - diagramDrawing[1] <<= resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, rFragmentPath, u"image"); + // drawingValue[0] => dom, drawingValue[1] => Sequence of associated relationships + uno::Sequence<uno::Any> diagramDrawing{ + uno::Any(rFilterBase.importFragment(rFragmentPath)), + uno::Any(resolveRelationshipsOfTypeFromOfficeDoc(rFilterBase, rFragmentPath, u"image")) + }; beans::PropertyValue* pValue = maDiagramDoms.getArray(); pValue[length].Name = "OOXDrawing"; @@ -1795,23 +1797,18 @@ Reference < XShape > Shape::renderDiagramToGraphic( XmlFilterBase const & rFilte awt::Size aSize( static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Width ) + 0.5 ), static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Height ) + 0.5 ) ); - Sequence< PropertyValue > aFilterData( 4 ); - aFilterData[ 0 ].Name = "PixelWidth"; - aFilterData[ 0 ].Value <<= aSize.Width; - aFilterData[ 1 ].Name = "PixelHeight"; - aFilterData[ 1 ].Value <<= aSize.Height; - aFilterData[ 2 ].Name = "LogicalWidth"; - aFilterData[ 2 ].Value <<= aActualSize.Width; - aFilterData[ 3 ].Name = "LogicalHeight"; - aFilterData[ 3 ].Value <<= aActualSize.Height; - - Sequence < PropertyValue > aDescriptor( 3 ); - aDescriptor[ 0 ].Name = "OutputStream"; - aDescriptor[ 0 ].Value <<= xOutputStream; - aDescriptor[ 1 ].Name = "FilterName"; - aDescriptor[ 1 ].Value <<= OUString("SVM"); // Rendering format - aDescriptor[ 2 ].Name = "FilterData"; - aDescriptor[ 2 ].Value <<= aFilterData; + Sequence< PropertyValue > aFilterData{ + comphelper::makePropertyValue("PixelWidth", aSize.Width), + comphelper::makePropertyValue("PixelHeight", aSize.Height), + comphelper::makePropertyValue("LogicalWidth", aActualSize.Width), + comphelper::makePropertyValue("LogicalHeight", aActualSize.Height) + }; + + Sequence < PropertyValue > aDescriptor{ + comphelper::makePropertyValue("OutputStream", xOutputStream), + comphelper::makePropertyValue("FilterName", OUString("SVM")), // Rendering format + comphelper::makePropertyValue("FilterData", aFilterData) + }; Reference < lang::XComponent > xSourceDoc( mxShape, UNO_QUERY_THROW ); Reference < XGraphicExportFilter > xGraphicExporter = GraphicExportFilter::create( rFilterBase.getComponentContext() ); @@ -1986,7 +1983,7 @@ void Shape::putPropertyToGrabBag( const PropertyValue& pProperty ) sal_Int32 length = aGrabBag.getLength(); aGrabBag.realloc( length + 1 ); - aGrabBag[length] = pProperty; + aGrabBag.getArray()[length] = pProperty; xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) ); } @@ -2108,25 +2105,27 @@ uno::Sequence< uno::Sequence< uno::Any > > Shape::resolveRelationshipsOfTypeFro if ( xImageRels ) { xRelListTemp.realloc( xImageRels->size() ); + auto pxRelListTemp = xRelListTemp.getArray(); for (auto const& imageRel : *xImageRels) { uno::Sequence< uno::Any > diagramRelTuple (3); + auto pdiagramRelTuple = diagramRelTuple.getArray(); // [0] => RID, [1] => InputStream [2] => extension OUString sRelId = imageRel.second.maId; - diagramRelTuple[0] <<= sRelId; + pdiagramRelTuple[0] <<= sRelId; OUString sTarget = xImageRels->getFragmentPathFromRelId( sRelId ); uno::Reference< io::XInputStream > xImageInputStrm( rFilter.openInputStream( sTarget ), uno::UNO_SET_THROW ); StreamDataSequence dataSeq; if ( rFilter.importBinaryData( dataSeq, sTarget ) ) { - diagramRelTuple[1] <<= dataSeq; + pdiagramRelTuple[1] <<= dataSeq; } - diagramRelTuple[2] <<= sTarget.copy( sTarget.lastIndexOf(".") ); + pdiagramRelTuple[2] <<= sTarget.copy( sTarget.lastIndexOf(".") ); - xRelListTemp[counter] = diagramRelTuple; + pxRelListTemp[counter] = diagramRelTuple; ++counter; } xRelListTemp.realloc(counter); diff --git a/oox/source/drawingml/shape3dproperties.cxx b/oox/source/drawingml/shape3dproperties.cxx index 18f53a7e309f..4cb127022c1d 100644 --- a/oox/source/drawingml/shape3dproperties.cxx +++ b/oox/source/drawingml/shape3dproperties.cxx @@ -20,6 +20,8 @@ #include <drawingml/shape3dproperties.hxx> #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/graphic/XGraphicTransformer.hpp> + +#include <comphelper/propertyvalue.hxx> #include <oox/token/tokens.hxx> #include <sal/log.hxx> @@ -203,41 +205,42 @@ OUString Generic3DProperties::getPresetMaterialTypeString( sal_Int32 nType ) css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getCameraAttributes() { css::uno::Sequence<css::beans::PropertyValue> aSeq(6); + auto pSeq = aSeq.getArray(); sal_Int32 nSize = 0; if( mfFieldOfVision.has() ) { - aSeq[nSize].Name = "fov"; - aSeq[nSize].Value <<= mfFieldOfVision.use(); + pSeq[nSize].Name = "fov"; + pSeq[nSize].Value <<= mfFieldOfVision.use(); nSize++; } if( mfZoom.has() ) { - aSeq[nSize].Name = "zoom"; - aSeq[nSize].Value <<= mfZoom.use(); + pSeq[nSize].Name = "zoom"; + pSeq[nSize].Value <<= mfZoom.use(); nSize++; } if( mnPreset.has() ) { - aSeq[nSize].Name = "prst"; - aSeq[nSize].Value <<= getCameraPrstName( mnPreset.use() ); + pSeq[nSize].Name = "prst"; + pSeq[nSize].Value <<= getCameraPrstName( mnPreset.use() ); nSize++; } if( maCameraRotation.mnLatitude.has() ) { - aSeq[nSize].Name = "rotLat"; - aSeq[nSize].Value <<= maCameraRotation.mnLatitude.use(); + pSeq[nSize].Name = "rotLat"; + pSeq[nSize].Value <<= maCameraRotation.mnLatitude.use(); nSize++; } if( maCameraRotation.mnLongitude.has() ) { - aSeq[nSize].Name = "rotLon"; - aSeq[nSize].Value <<= maCameraRotation.mnLongitude.use(); + pSeq[nSize].Name = "rotLon"; + pSeq[nSize].Value <<= maCameraRotation.mnLongitude.use(); nSize++; } if( maCameraRotation.mnRevolution.has() ) { - aSeq[nSize].Name = "rotRev"; - aSeq[nSize].Value <<= maCameraRotation.mnRevolution.use(); + pSeq[nSize].Name = "rotRev"; + pSeq[nSize].Value <<= maCameraRotation.mnRevolution.use(); nSize++; } aSeq.realloc( nSize ); @@ -247,35 +250,36 @@ css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getCameraAt css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getLightRigAttributes() { css::uno::Sequence<css::beans::PropertyValue> aSeq(5); + auto pSeq = aSeq.getArray(); sal_Int32 nSize = 0; if( mnLightRigDirection.has() ) { - aSeq[nSize].Name = "dir"; - aSeq[nSize].Value <<= getLightRigDirName( mnLightRigDirection.use() ); + pSeq[nSize].Name = "dir"; + pSeq[nSize].Value <<= getLightRigDirName( mnLightRigDirection.use() ); nSize++; } if( mnLightRigType.has() ) { - aSeq[nSize].Name = "rig"; - aSeq[nSize].Value <<= getLightRigName( mnLightRigType.use() ); + pSeq[nSize].Name = "rig"; + pSeq[nSize].Value <<= getLightRigName( mnLightRigType.use() ); nSize++; } if( maLightRigRotation.mnLatitude.has() ) { - aSeq[nSize].Name = "rotLat"; - aSeq[nSize].Value <<= maLightRigRotation.mnLatitude.use(); + pSeq[nSize].Name = "rotLat"; + pSeq[nSize].Value <<= maLightRigRotation.mnLatitude.use(); nSize++; } if( maLightRigRotation.mnLongitude.has() ) { - aSeq[nSize].Name = "rotLon"; - aSeq[nSize].Value <<= maLightRigRotation.mnLongitude.use(); + pSeq[nSize].Name = "rotLon"; + pSeq[nSize].Value <<= maLightRigRotation.mnLongitude.use(); nSize++; } if( maLightRigRotation.mnRevolution.has() ) { - aSeq[nSize].Name = "rotRev"; - aSeq[nSize].Value <<= maLightRigRotation.mnRevolution.use(); + pSeq[nSize].Name = "rotRev"; + pSeq[nSize].Value <<= maLightRigRotation.mnRevolution.use(); nSize++; } aSeq.realloc( nSize ); @@ -285,23 +289,24 @@ css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getLightRig css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getBevelAttributes( BevelProperties rProps ) { css::uno::Sequence<css::beans::PropertyValue> aSeq(3); + auto pSeq = aSeq.getArray(); sal_Int32 nSize = 0; if( rProps.mnPreset.has() ) { - aSeq[nSize].Name = "prst"; - aSeq[nSize].Value <<= getBevelPresetTypeString( rProps.mnPreset.use() ); + pSeq[nSize].Name = "prst"; + pSeq[nSize].Value <<= getBevelPresetTypeString( rProps.mnPreset.use() ); nSize++; } if( rProps.mnWidth.has() ) { - aSeq[nSize].Name = "w"; - aSeq[nSize].Value <<= rProps.mnWidth.use(); + pSeq[nSize].Name = "w"; + pSeq[nSize].Value <<= rProps.mnWidth.use(); nSize++; } if( rProps.mnHeight.has() ) { - aSeq[nSize].Name = "h"; - aSeq[nSize].Value <<= rProps.mnHeight.use(); + pSeq[nSize].Name = "h"; + pSeq[nSize].Value <<= rProps.mnHeight.use(); nSize++; } aSeq.realloc( nSize ); @@ -311,78 +316,71 @@ css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getBevelAtt css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getColorAttributes( const Color& rColor, const GraphicHelper& rGraphicHelper, ::Color rPhClr ) { - css::uno::Sequence<css::beans::PropertyValue> aSeq(2); const OUString& sColorScheme = rColor.getSchemeName(); if( sColorScheme.isEmpty() ) { // RGB color and transparency value - aSeq[0].Name = "rgbClr"; - aSeq[0].Value <<= rColor.getColor( rGraphicHelper, rPhClr ); - aSeq[1].Name = "rgbClrTransparency"; - aSeq[1].Value <<= rColor.getTransparency(); - } - else - { - // scheme color with name and transformations - aSeq[0].Name = "schemeClr"; - aSeq[0].Value <<= sColorScheme; - aSeq[1].Name = "schemeClrTransformations"; - aSeq[1].Value <<= rColor.getTransformations(); + return { comphelper::makePropertyValue("rgbClr", rColor.getColor( rGraphicHelper, rPhClr )), + comphelper::makePropertyValue("rgbClrTransparency", rColor.getTransparency()) }; } - return aSeq; + // scheme color with name and transformations + return { comphelper::makePropertyValue("schemeClr", sColorScheme), + comphelper::makePropertyValue("schemeClrTransformations", + rColor.getTransformations()) }; } css::uno::Sequence< css::beans::PropertyValue > Generic3DProperties::getShape3DAttributes( const GraphicHelper& rGraphicHelper, ::Color rPhClr ) { css::uno::Sequence<css::beans::PropertyValue> aSeq(8); + auto pSeq = aSeq.getArray(); sal_Int32 nSize = 0; if( mnExtrusionH.has() ) { - aSeq[nSize].Name = "extrusionH"; - aSeq[nSize].Value <<= mnExtrusionH.use(); + pSeq[nSize].Name = "extrusionH"; + pSeq[nSize].Value <<= mnExtrusionH.use(); nSize++; } if( mnContourW.has() ) { - aSeq[nSize].Name = "contourW"; - aSeq[nSize].Value <<= mnContourW.use(); + pSeq[nSize].Name = "contourW"; + pSeq[nSize].Value <<= mnContourW.use(); nSize++; } if( mnShapeZ.has() ) { - aSeq[nSize].Name = "z"; - aSeq[nSize].Value <<= mnShapeZ.use(); + pSeq[nSize].Name = "z"; + pSeq[nSize].Value <<= mnShapeZ.use(); nSize++; } if( mnMaterial.has() ) { - aSeq[nSize].Name = "prstMaterial"; - aSeq[nSize].Value <<= getPresetMaterialTypeString( mnMaterial.use() ); + pSeq[nSize].Name = "prstMaterial"; + pSeq[nSize].Value <<= getPresetMaterialTypeString( mnMaterial.use() ); nSize++; } if( maTopBevelProperties.has() ) { - aSeq[nSize].Name = "bevelT"; - aSeq[nSize].Value <<= getBevelAttributes( maTopBevelProperties.use() ); + pSeq[nSize].Name = "bevelT"; + pSeq[nSize].Value <<= getBevelAttributes( maTopBevelProperties.use() ); nSize++; } if( maBottomBevelProperties.has() ) { - aSeq[nSize].Name = "bevelB"; - aSeq[nSize].Value <<= getBevelAttributes( maBottomBevelProperties.use() ); + pSeq[nSize].Name = "bevelB"; + pSeq[nSize].Value <<= getBevelAttributes( maBottomBevelProperties.use() ); nSize++; } if( maExtrusionColor.isUsed() ) { - aSeq[nSize].Name = "extrusionClr"; - aSeq[nSize].Value <<= getColorAttributes( maExtrusionColor, rGraphicHelper, rPhClr ); + pSeq[nSize].Name = "extrusionClr"; + pSeq[nSize].Value <<= getColorAttributes( maExtrusionColor, rGraphicHelper, rPhClr ); nSize++; } if( maContourColor.isUsed() ) { - aSeq[nSize].Name = "contourClr"; - aSeq[nSize].Value <<= getColorAttributes( maContourColor, rGraphicHelper, rPhClr ); + pSeq[nSize].Name = "contourClr"; + pSeq[nSize].Value <<= getColorAttributes( maContourColor, rGraphicHelper, rPhClr ); nSize++; } aSeq.realloc( nSize ); diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index e78ca42af24f..4b88f6959460 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -388,8 +388,9 @@ static Sequence< OUString > lcl_getLabelSequence( const Reference< chart2::data: { const Sequence< uno::Any > aAnies( xLabelSeq->getData()); aLabels.realloc( aAnies.getLength()); + auto pLabels = aLabels.getArray(); for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) - aAnies[i] >>= aLabels[i]; + aAnies[i] >>= pLabels[i]; } return aLabels; @@ -563,19 +564,13 @@ uno::Sequence< beans::PropertyValue > createArguments( if (bUseColumns) eRowSource = css::chart::ChartDataRowSource_COLUMNS; - uno::Sequence< beans::PropertyValue > aArguments(4); - aArguments[0] = beans::PropertyValue("DataRowSource" - , -1, uno::Any(eRowSource) - , beans::PropertyState_DIRECT_VALUE); - aArguments[1] = beans::PropertyValue("FirstCellAsLabel" - , -1, uno::Any(false) - , beans::PropertyState_DIRECT_VALUE); - aArguments[2] = beans::PropertyValue("HasCategories" - , -1, uno::Any(false) - , beans::PropertyState_DIRECT_VALUE); - aArguments[3] = beans::PropertyValue("CellRangeRepresentation" - , -1, uno::Any(rRangeRepresentation) - , beans::PropertyState_DIRECT_VALUE); + uno::Sequence<beans::PropertyValue> aArguments{ + { "DataRowSource", -1, uno::Any(eRowSource), beans::PropertyState_DIRECT_VALUE }, + { "FirstCellAsLabel", -1, uno::Any(false), beans::PropertyState_DIRECT_VALUE }, + { "HasCategories", -1, uno::Any(false), beans::PropertyState_DIRECT_VALUE }, + { "CellRangeRepresentation", -1, uno::Any(rRangeRepresentation), + beans::PropertyState_DIRECT_VALUE } + }; return aArguments; } @@ -664,16 +659,18 @@ Sequence< Sequence< OUString > > ChartExport::getSplitCategoriesList( const OUSt //we have complex categories //sort the categories name Sequence<Sequence<OUString>>aFinalSplitSource(nLevelCount); + auto pFinalSplitSource = aFinalSplitSource.getArray(); for (sal_Int32 i = 0; i < nLevelCount; i++) { sal_Int32 nElemLabel = 0; - aFinalSplitSource[nLevelCount - i - 1].realloc(aAnyCategories.getLength()); + pFinalSplitSource[nLevelCount - i - 1].realloc(aAnyCategories.getLength()); + auto pSeq = pFinalSplitSource[nLevelCount - i - 1].getArray(); for (auto const& elemLabel : aAnyCategories) { // make sure elemLabel[i] exists! if (elemLabel.getLength() > i) { - aFinalSplitSource[nLevelCount - i - 1][nElemLabel] = elemLabel[i].get<OUString>(); + pSeq[nElemLabel] = elemLabel[i].get<OUString>(); nElemLabel++; } } @@ -1599,7 +1596,7 @@ namespace { uno::Sequence<Reference<chart2::XDataSeries> >& rAxisSeriesSeq = aSplitSeries[nVectorPos]; sal_Int32 nLength = rAxisSeriesSeq.getLength(); rAxisSeriesSeq.realloc(nLength + 1); - rAxisSeriesSeq[nLength] = xSeries; + rAxisSeriesSeq.getArray()[nLength] = xSeries; } // if the first series attached to secondary axis, then export those series first, which are attached to primary axis // also the MS Office export every time in this order diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index d9dd073fbaf7..6c2011ac9eef 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -100,6 +100,7 @@ #include <com/sun/star/drawing/XDrawPages.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <comphelper/propertyvalue.hxx> #include <comphelper/random.hxx> #include <comphelper/seqstream.hxx> #include <comphelper/storagehelper.hxx> @@ -4438,30 +4439,24 @@ void DrawingML::WriteShapeEffects( const Reference< XPropertySet >& rXPropSet ) WriteGlowEffect(rXPropSet); if( bHasShadow ) { - Sequence< PropertyValue > aShadowGrabBag( 3 ); - Sequence< PropertyValue > aShadowAttribsGrabBag( 4 ); - double dX = +0.0, dY = +0.0; sal_Int32 nBlur =0; rXPropSet->getPropertyValue( "ShadowXDistance" ) >>= dX; rXPropSet->getPropertyValue( "ShadowYDistance" ) >>= dY; rXPropSet->getPropertyValue( "ShadowBlur" ) >>= nBlur; - aShadowAttribsGrabBag[0].Name = "dist"; - aShadowAttribsGrabBag[0].Value <<= lcl_CalculateDist(dX, dY); - aShadowAttribsGrabBag[1].Name = "dir"; - aShadowAttribsGrabBag[1].Value <<= lcl_CalculateDir(dX, dY); - aShadowAttribsGrabBag[2].Name = "blurRad"; - aShadowAttribsGrabBag[2].Value <<= oox::drawingml::convertHmmToEmu(nBlur); - aShadowAttribsGrabBag[3].Name = "rotWithShape"; - aShadowAttribsGrabBag[3].Value <<= false; //ooxml default is 'true', so must write it - - aShadowGrabBag[0].Name = "Attribs"; - aShadowGrabBag[0].Value <<= aShadowAttribsGrabBag; - aShadowGrabBag[1].Name = "RgbClr"; - aShadowGrabBag[1].Value = rXPropSet->getPropertyValue( "ShadowColor" ); - aShadowGrabBag[2].Name = "RgbClrTransparency"; - aShadowGrabBag[2].Value = rXPropSet->getPropertyValue( "ShadowTransparence" ); + Sequence< PropertyValue > aShadowAttribsGrabBag{ + comphelper::makePropertyValue("dist", lcl_CalculateDist(dX, dY)), + comphelper::makePropertyValue("dir", lcl_CalculateDir(dX, dY)), + comphelper::makePropertyValue("blurRad", oox::drawingml::convertHmmToEmu(nBlur)), + comphelper::makePropertyValue("rotWithShape", false) //ooxml default is 'true', so must write it + }; + + Sequence< PropertyValue > aShadowGrabBag{ + comphelper::makePropertyValue("Attribs", aShadowAttribsGrabBag), + comphelper::makePropertyValue("RgbClr", rXPropSet->getPropertyValue( "ShadowColor" )), + comphelper::makePropertyValue("RgbClrTransparency", rXPropSet->getPropertyValue( "ShadowTransparence" )) + }; WriteShapeEffect( u"outerShdw", aShadowGrabBag ); } @@ -4557,16 +4552,13 @@ void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet) if (!nRad) return; - Sequence< PropertyValue > aGlowAttribs(1); - aGlowAttribs[0].Name = "rad"; - aGlowAttribs[0].Value <<= oox::drawingml::convertHmmToEmu(nRad); - Sequence< PropertyValue > aGlowProps(3); - aGlowProps[0].Name = "Attribs"; - aGlowProps[0].Value <<= aGlowAttribs; - aGlowProps[1].Name = "RgbClr"; - aGlowProps[1].Value = rXPropSet->getPropertyValue("GlowEffectColor"); - aGlowProps[2].Name = "RgbClrTransparency"; - aGlowProps[2].Value = rXPropSet->getPropertyValue("GlowEffectTransparency"); + Sequence< PropertyValue > aGlowAttribs{ comphelper::makePropertyValue( + "rad", oox::drawingml::convertHmmToEmu(nRad)) }; + Sequence< PropertyValue > aGlowProps{ + comphelper::makePropertyValue("Attribs", aGlowAttribs), + comphelper::makePropertyValue("RgbClr", rXPropSet->getPropertyValue("GlowEffectColor")), + comphelper::makePropertyValue("RgbClrTransparency", rXPropSet->getPropertyValue("GlowEffectTransparency")) + }; // TODO other stuff like saturation or luminance WriteShapeEffect(u"glow", aGlowProps); @@ -4584,12 +4576,10 @@ void DrawingML::WriteSoftEdgeEffect(const css::uno::Reference<css::beans::XPrope if (!nRad) return; - css::uno::Sequence<css::beans::PropertyValue> aAttribs(1); - aAttribs[0].Name = "rad"; - aAttribs[0].Value <<= oox::drawingml::convertHmmToEmu(nRad); - css::uno::Sequence<css::beans::PropertyValue> aProps(1); - aProps[0].Name = "Attribs"; - aProps[0].Value <<= aAttribs; + css::uno::Sequence<css::beans::PropertyValue> aAttribs{ comphelper::makePropertyValue( + "rad", oox::drawingml::convertHmmToEmu(nRad)) }; + css::uno::Sequence<css::beans::PropertyValue> aProps{ comphelper::makePropertyValue("Attribs", + aAttribs) }; WriteShapeEffect(u"softEdge", aProps); } diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 7bc3178173e3..8ff8c7939f4f 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/graphic/GraphicMapper.hpp> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/seqstream.hxx> #include <vcl/wmfexternal.hxx> #include <vcl/svapp.hxx> @@ -237,24 +238,20 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea Reference< XGraphic > xGraphic; if( rxInStrm.is() && mxGraphicProvider.is() ) try { - Sequence< PropertyValue > aArgs( 2 ); - aArgs[ 0 ].Name = "InputStream"; - aArgs[ 0 ].Value <<= rxInStrm; - aArgs[ 1 ].Name = "LazyRead"; - aArgs[ 1 ].Value <<= true; + Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("InputStream", rxInStrm), + comphelper::makePropertyValue("LazyRead", true) }; if ( pExtHeader && pExtHeader->mapMode > 0 ) { aArgs.realloc( aArgs.getLength() + 1 ); - Sequence< PropertyValue > aFilterData( 3 ); - aFilterData[ 0 ].Name = "ExternalWidth"; - aFilterData[ 0 ].Value <<= pExtHeader->xExt; - aFilterData[ 1 ].Name = "ExternalHeight"; - aFilterData[ 1 ].Value <<= pExtHeader->yExt; - aFilterData[ 2 ].Name = "ExternalMapMode"; - aFilterData[ 2 ].Value <<= pExtHeader->mapMode; - aArgs[ 2 ].Name = "FilterData"; - aArgs[ 2 ].Value <<= aFilterData; + auto pArgs = aArgs.getArray(); + Sequence< PropertyValue > aFilterData{ + comphelper::makePropertyValue("ExternalWidth", pExtHeader->xExt), + comphelper::makePropertyValue("ExternalHeight", pExtHeader->yExt), + comphelper::makePropertyValue("ExternalMapMode", pExtHeader->mapMode) + }; + pArgs[ 2 ].Name = "FilterData"; + pArgs[ 2 ].Value <<= aFilterData; } xGraphic = mxGraphicProvider->queryGraphic( aArgs ); diff --git a/oox/source/helper/textinputstream.cxx b/oox/source/helper/textinputstream.cxx index 923f49396059..a48860c35481 100644 --- a/oox/source/helper/textinputstream.cxx +++ b/oox/source/helper/textinputstream.cxx @@ -144,8 +144,7 @@ OUString TextInputStream::readToChar( sal_Unicode cChar, bool bIncludeChar ) { if( mxTextStrm.is() ) try { - Sequence< sal_Unicode > aDelimiters( 1 ); - aDelimiters[ 0 ] = cChar; + Sequence< sal_Unicode > aDelimiters{ cChar }; /* Always get the delimiter character from the UNO text input stream. In difference to this implementation, it will not return it in the next call but silently skip it. If caller specifies to exclude the diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 59f9d62fefc1..7442e54ea675 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -343,11 +343,7 @@ void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlMo } // create argument sequence - NamedValue aValue; - aValue.Name = "BoundCell"; - aValue.Value <<= aAddress; - Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= aValue; + Sequence< Any > aArgs{ Any(NamedValue("BoundCell", Any(aAddress))) }; // create the CellValueBinding instance and set at the control model Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW ); @@ -378,11 +374,7 @@ void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlMo } // create argument sequence - NamedValue aValue; - aValue.Name = "CellRange"; - aValue.Value <<= aRangeAddr; - Sequence< Any > aArgs( 1 ); - aArgs[ 0 ] <<= aValue; + Sequence< Any > aArgs{ Any(NamedValue("CellRange", Any(aRangeAddr))) }; // create the EntrySource instance and set at the control model Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW ); @@ -2618,16 +2610,18 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) if ( !listValues.empty() ) { msListData.realloc( listValues.size() ); + auto psListData = msListData.getArray(); sal_Int32 index = 0; for (auto const& listValue : listValues) - msListData[ index++ ] = listValue; + psListData[ index++ ] = listValue; } if ( !selectedIndices.empty() ) { msIndices.realloc( selectedIndices.size() ); + auto psIndices = msIndices.getArray(); sal_Int32 index = 0; for (auto const& selectedIndice : selectedIndices) - msIndices[ index++ ] = selectedIndice; + psIndices[ index++ ] = selectedIndice; } return true; } diff --git a/oox/source/ole/oleobjecthelper.cxx b/oox/source/ole/oleobjecthelper.cxx index 9cecf3d0b705..9282e2944a20 100644 --- a/oox/source/ole/oleobjecthelper.cxx +++ b/oox/source/ole/oleobjecthelper.cxx @@ -31,6 +31,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <osl/diagnose.h> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <oox/helper/propertymap.hxx> #include <oox/token/properties.hxx> @@ -101,9 +102,8 @@ void SaveInteropProperties(uno::Reference<frame::XModel> const& xModel, if (aGrabBag.find(sEmbeddingsPropName) != aGrabBag.end()) objectsList << aGrabBag[sEmbeddingsPropName]; - uno::Sequence< beans::PropertyValue > aGrabBagAttribute(1); - aGrabBagAttribute[0].Name = "ProgID"; - aGrabBagAttribute[0].Value <<= rProgId; + uno::Sequence< beans::PropertyValue > aGrabBagAttribute{ comphelper::makePropertyValue("ProgID", + rProgId) }; // If we got an "old name", erase that first. if (pOldObjectName) diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx index 32673fa699af..4b20e20f842a 100644 --- a/oox/source/ole/olestorage.cxx +++ b/oox/source/ole/olestorage.cxx @@ -227,9 +227,8 @@ void OleStorage::initStorage( const Reference< XInputStream >& rxInStream ) if( xInStrm.is() ) try { Reference< XMultiServiceFactory > xFactory( mxContext->getServiceManager(), UNO_QUERY_THROW ); - Sequence< Any > aArgs( 2 ); - aArgs[ 0 ] <<= xInStrm; - aArgs[ 1 ] <<= true; // true = do not create a copy of the input stream + Sequence< Any > aArgs{ Any(xInStrm), + Any(true) };// true = do not create a copy of the input stream mxStorage.set( xFactory->createInstanceWithArguments("com.sun.star.embed.OLESimpleStorage", aArgs ), UNO_QUERY_THROW ); } catch(const Exception& ) @@ -243,9 +242,8 @@ void OleStorage::initStorage( const Reference< XStream >& rxOutStream ) if( rxOutStream.is() ) try { Reference< XMultiServiceFactory > xFactory( mxContext->getServiceManager(), UNO_QUERY_THROW ); - Sequence< Any > aArgs( 2 ); - aArgs[ 0 ] <<= rxOutStream; - aArgs[ 1 ] <<= true; // true = do not create a copy of the stream + Sequence< Any > aArgs{ Any(rxOutStream), + Any(true) }; // true = do not create a copy of the stream mxStorage.set( xFactory->createInstanceWithArguments("com.sun.star.embed.OLESimpleStorage", aArgs ), UNO_QUERY_THROW ); } catch(const Exception& ) diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index c3f587513be5..82b02d152dc2 100644 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -523,9 +523,7 @@ void VbaProject::attachMacros() comphelper::DocumentInfo::notifyMacroEventRead(mxDocModel); Reference< XMultiComponentFactory > xFactory( mxContext->getServiceManager(), UNO_SET_THROW ); - Sequence< Any > aArgs( 2 ); - aArgs[ 0 ] <<= mxDocModel; - aArgs[ 1 ] <<= maPrjName; + Sequence< Any > aArgs{ Any(mxDocModel), Any(maPrjName) }; Reference< XVBAMacroResolver > xResolver( xFactory->createInstanceWithArgumentsAndContext( "com.sun.star.script.vba.VBAMacroResolver", aArgs, mxContext ), UNO_QUERY_THROW ); maMacroAttachers.forEachMem( &VbaMacroAttacherBase::resolveAndAttachMacro, ::std::cref( xResolver ) ); diff --git a/oox/source/ppt/animationspersist.cxx b/oox/source/ppt/animationspersist.cxx index 544b5e4626aa..40655e6863c6 100644 --- a/oox/source/ppt/animationspersist.cxx +++ b/oox/source/ppt/animationspersist.cxx @@ -60,13 +60,11 @@ Any addToSequence( const Any& rOldValue, const Any& rNewValue ) { sal_Int32 nSize = aNewSeq.getLength(); aNewSeq.realloc(nSize+1); - aNewSeq[nSize] = rNewValue; + aNewSeq.getArray()[nSize] = rNewValue; } else { - aNewSeq.realloc(2); - aNewSeq[0] = rOldValue; - aNewSeq[1] = rNewValue; + aNewSeq = { rOldValue, rNewValue }; } return makeAny( aNewSeq ); } diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 95eb5fdb53c0..5d5c3a594009 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -18,6 +18,7 @@ */ #include <comphelper/anytostring.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <sal/log.hxx> #include <tools/multisel.hxx> @@ -225,11 +226,11 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::Theme // get existing grab bag comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue(aGrabBagPropName)); - uno::Sequence<beans::PropertyValue> aTheme(2); comphelper::SequenceAsHashMap aThemesHashMap; // create current theme uno::Sequence<beans::PropertyValue> aCurrentTheme(PredefinedClrSchemeId::Count); + auto pCurrentTheme = aCurrentTheme.getArray(); ClrScheme rClrScheme = pThemePtr->getClrScheme(); for (int nId = PredefinedClrSchemeId::dk2; nId != PredefinedClrSchemeId::Count; nId++) @@ -241,22 +242,20 @@ void PresentationFragmentHandler::saveThemeToGrabBag(const oox::drawingml::Theme rClrScheme.getColor(nToken, nColor); const uno::Any& rColor = uno::makeAny(nColor); - aCurrentTheme[nId].Name = sName; - aCurrentTheme[nId].Value = rColor; + pCurrentTheme[nId].Name = sName; + pCurrentTheme[nId].Value = rColor; } - // add new theme to the sequence - // Export code uses the master slide's index to find the right theme - // so use the same index in the grabbag. - aTheme[0].Name = "ppt/theme/theme" + OUString::number(nThemeIdx) + ".xml"; - const uno::Any& rCurrentTheme = makeAny(aCurrentTheme); - aTheme[0].Value = rCurrentTheme; - - // store DOM fragment for SmartArt re-generation - aTheme[1].Name = "OOXTheme"; - const uno::Any& rOOXTheme = makeAny(pThemePtr->getFragment()); - aTheme[1].Value = rOOXTheme; + uno::Sequence<beans::PropertyValue> aTheme{ + // add new theme to the sequence + // Export code uses the master slide's index to find the right theme + // so use the same index in the grabbag. + comphelper::makePropertyValue( + "ppt/theme/theme" + OUString::number(nThemeIdx) + ".xml", aCurrentTheme), + // store DOM fragment for SmartArt re-generation + comphelper::makePropertyValue("OOXTheme", pThemePtr->getFragment()) + }; aThemesHashMap << aTheme; @@ -650,16 +649,12 @@ void PresentationFragmentHandler::finalizeImport() if (!sAlgorithmName.isEmpty()) { - uno::Sequence<beans::PropertyValue> aResult; - aResult.realloc(4); - aResult[0].Name = "algorithm-name"; - aResult[0].Value <<= sAlgorithmName; - aResult[1].Name = "salt"; - aResult[1].Value <<= sSalt; - aResult[2].Name = "iteration-count"; - aResult[2].Value <<= nSpinCount; - aResult[3].Name = "hash"; - aResult[3].Value <<= sHash; + uno::Sequence<beans::PropertyValue> aResult{ + comphelper::makePropertyValue("algorithm-name", sAlgorithmName), + comphelper::makePropertyValue("salt", sSalt), + comphelper::makePropertyValue("iteration-count", nSpinCount), + comphelper::makePropertyValue("hash", sHash) + }; try { uno::Reference<beans::XPropertySet> xDocSettings( diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx index 13d9a1d090b9..5a6535e314c5 100644 --- a/oox/source/ppt/timenodelistcontext.cxx +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -109,16 +109,12 @@ namespace oox::ppt { Any get() const { sal_Int32 nColor; - Sequence< double > aHSL( 3 ); Any aColor; switch( colorSpace ) { case AnimationColorSpace::HSL: - aHSL[ 0 ] = double(one) / 100000; - aHSL[ 1 ] = double(two) / 100000; - aHSL[ 2 ] = double(three) / 100000; - aColor <<= aHSL; + aColor <<= Sequence< double >{ one / 100000.0, two / 100000.0, three / 100000.0 }; break; case AnimationColorSpace::RGB: nColor = ( ( ( one * 128 ) / 1000 ) & 0xff ) << 16 @@ -597,16 +593,18 @@ namespace oox::ppt { int i=0; Sequence< double > aKeyTimes( nKeyTimes ); + auto pKeyTimes = aKeyTimes.getArray(); Sequence< Any > aValues( nKeyTimes ); + auto pValues = aValues.getArray(); NodePropertyMap & aProps( mpNode->getNodeProperties() ); for (auto const& tav : maTavList) { // TODO what to do if it is Timing_INFINITE ? Any aTime = GetTimeAnimateValueTime( tav.msTime ); - aTime >>= aKeyTimes[i]; - aValues[i] = tav.maValue; - convertAnimationValueWithTimeNode(mpNode, aValues[i]); + aTime >>= pKeyTimes[i]; + pValues[i] = tav.maValue; + convertAnimationValueWithTimeNode(mpNode, pValues[i]); // Examine pptx documents and find that only the first tav // has the formula set. The formula can be used for the whole. diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index 77e744d31fc9..5eaff0abe6e0 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -103,8 +103,9 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; sal_Int32 length = aGrabBag.getLength(); aGrabBag.realloc(length + 1); - aGrabBag[length].Name = "Upright"; - aGrabBag[length].Value <<= bUpright; + auto pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "Upright"; + pGrabBag[length].Value <<= bUpright; xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag)); } diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 72c967d103c4..c7ff6796db21 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -939,7 +939,7 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen { sal_Int32 nSize = aGeomPropSeq.getLength(); aGeomPropSeq.realloc(nSize+1); - aGeomPropSeq[nSize] = lcl_createTextpathProps(); + aGeomPropSeq.getArray()[nSize] = lcl_createTextpathProps(); } rPropMap.setAnyProperty(PROP_CustomShapeGeometry, uno::makeAny(aGeomPropSeq)); } diff --git a/oox/source/vml/vmlinputstream.cxx b/oox/source/vml/vmlinputstream.cxx index cdb8b9724ec6..93204ac50710 100644 --- a/oox/source/vml/vmlinputstream.cxx +++ b/oox/source/vml/vmlinputstream.cxx @@ -269,14 +269,12 @@ constexpr OStringLiteral gaClosingCData( "]]>" ); InputStream::InputStream( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm ) : // use single-byte ISO-8859-1 encoding which maps all byte characters to the first 256 Unicode characters mxTextStrm( TextInputStream::createXTextInputStream( rxContext, rxInStrm, RTL_TEXTENCODING_ISO_8859_1 ) ), - maOpeningBracket( 1 ), - maClosingBracket( 1 ), + maOpeningBracket{ '<' }, + maClosingBracket{ '>' }, mnBufferPos( 0 ) { if (!mxTextStrm.is()) throw IOException(); - maOpeningBracket[ 0 ] = '<'; - maClosingBracket[ 0 ] = '>'; } InputStream::~InputStream() diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index f197bd009af6..81abe64e5322 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -432,29 +432,32 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS length = aGrabBag.getLength(); aGrabBag.realloc( length+1 ); - aGrabBag[length].Name = "VML-Z-ORDER"; - aGrabBag[length].Value <<= maTypeModel.maZIndex.toInt32(); + auto pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "VML-Z-ORDER"; + pGrabBag[length].Value <<= maTypeModel.maZIndex.toInt32(); if( !s_mso_next_textbox.isEmpty() ) { length = aGrabBag.getLength(); aGrabBag.realloc( length+1 ); - aGrabBag[length].Name = "mso-next-textbox"; - aGrabBag[length].Value <<= s_mso_next_textbox; + pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "mso-next-textbox"; + pGrabBag[length].Value <<= s_mso_next_textbox; } if( !sLinkChainName.isEmpty() ) { length = aGrabBag.getLength(); aGrabBag.realloc( length+4 ); - aGrabBag[length].Name = "TxbxHasLink"; - aGrabBag[length].Value <<= true; - aGrabBag[length+1].Name = "Txbx-Id"; - aGrabBag[length+1].Value <<= id; - aGrabBag[length+2].Name = "Txbx-Seq"; - aGrabBag[length+2].Value <<= seq; - aGrabBag[length+3].Name = "LinkChainName"; - aGrabBag[length+3].Value <<= sLinkChainName; + pGrabBag = aGrabBag.getArray(); + pGrabBag[length].Name = "TxbxHasLink"; + pGrabBag[length].Value <<= true; + pGrabBag[length+1].Name = "Txbx-Id"; + pGrabBag[length+1].Value <<= id; + pGrabBag[length+2].Name = "Txbx-Seq"; + pGrabBag[length+2].Value <<= seq; + pGrabBag[length+3].Name = "LinkChainName"; + pGrabBag[length+3].Value <<= sLinkChainName; } propertySet->setPropertyValue( "InteropGrabBag", uno::makeAny(aGrabBag) ); } @@ -1057,8 +1060,7 @@ Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShape if (!aAbsPoints.empty()) { - PointSequenceSequence aPointSeq( 1 ); - aPointSeq[ 0 ] = comphelper::containerToSequence( aAbsPoints ); + PointSequenceSequence aPointSeq{ comphelper::containerToSequence( aAbsPoints ) }; PropertySet aPropSet( xShape ); aPropSet.setProperty( PROP_PolyPolygon, aPointSeq ); } @@ -1225,12 +1227,14 @@ Reference< XShape > BezierShape::implConvertAndInsert( const Reference< XShapes } aBezierCoords.Coordinates.realloc( aCoordLists.size() ); + auto pCoordinates = aBezierCoords.Coordinates.getArray(); for ( size_t i = 0; i < aCoordLists.size(); i++ ) - aBezierCoords.Coordinates[i] = comphelper::containerToSequence( aCoordLists[i] ); + pCoordinates[i] = comphelper::containerToSequence( aCoordLists[i] ); aBezierCoords.Flags.realloc( aFlagLists.size() ); + auto pFlags = aBezierCoords.Flags.getArray(); for ( size_t i = 0; i < aFlagLists.size(); i++ ) - aBezierCoords.Flags[i] = comphelper::containerToSequence( aFlagLists[i] ); + pFlags[i] = comphelper::containerToSequence( aFlagLists[i] ); if( !aCoordLists.front().empty() && !aCoordLists.back().empty() && aCoordLists.front().front().X == aCoordLists.back().back().X @@ -1545,12 +1549,9 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes > { uno::Sequence<beans::PropertyValue> aGrabBag; xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; - beans::PropertyValue aPair; - aPair.Name = "mso-edit-as"; - aPair.Value <<= maTypeModel.maEditAs; sal_Int32 nLength = aGrabBag.getLength(); aGrabBag.realloc(nLength + 1); - aGrabBag[nLength] = aPair; + aGrabBag.getArray()[nLength] = comphelper::makePropertyValue("mso-edit-as", maTypeModel.maEditAs); xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag)); } // Make sure group shapes are inline as well, unless there is an explicit different style. |