filter/qa/cppunit/xslt-test.cxx | 43 ++++----- filter/source/config/cache/filtercache.cxx | 2 filter/source/graphic/GraphicExportFilter.cxx | 2 filter/source/msfilter/escherex.cxx | 6 - filter/source/msfilter/msdffimp.cxx | 84 ++++++++++--------- filter/source/msfilter/msoleexp.cxx | 19 ++-- filter/source/msfilter/mstoolbar.cxx | 24 ++--- filter/source/msfilter/msvbahelper.cxx | 3 filter/source/pdf/pdfdialog.cxx | 5 - filter/source/pdf/pdfexport.cxx | 40 +++------ filter/source/pdf/pdffilter.cxx | 5 - filter/source/svg/svgexport.cxx | 13 +- filter/source/svg/svgfilter.cxx | 2 filter/source/t602/t602filter.cxx | 3 filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx | 8 - filter/source/xmlfilterdetect/filterdetect.cxx | 4 filter/source/xsltdialog/xmlfilterjar.cxx | 20 +--- filter/source/xsltdialog/xmlfiltersettingsdialog.cxx | 72 ++++++---------- filter/source/xsltdialog/xmlfiltertestdialog.cxx | 49 ++++------- filter/source/xsltfilter/OleHandler.cxx | 24 ++--- filter/source/xsltfilter/XSLTFilter.cxx | 51 ++--------- formula/source/ui/dlg/formula.cxx | 2 22 files changed, 206 insertions(+), 275 deletions(-)
New commits: commit 8565e4ef18e96b9a68a4b75d551a80ce52128bd5 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Oct 29 09:41:26 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Oct 30 08:02:43 2021 +0200 Prepare for removal of non-const operator[] from Sequence in formula Change-Id: I9baa0ac24865d54503c21545109163bde11eac47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124367 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx index 36b59d5eb0ec..d5510e92346d 100644 --- a/formula/source/ui/dlg/formula.cxx +++ b/formula/source/ui/dlg/formula.cxx @@ -419,7 +419,7 @@ sal_Int32 FormulaDlg_Impl::GetFunctionPos(sal_Int32 nPos) } if ( pNextToken != pEnd ) { - aArgs[0] = *pNextToken; + aArgs.getArray()[0] = *pNextToken; const OUString a2String = xParser->printFormula( aArgs, aRefPos); const sal_Int32 n3 = nXXX < 0 ? -1 : aFormString.indexOf( a2String, nXXX); if (n3 < nTokPos && n3 != -1) commit 7233e65db1a78f4764a05d4eb53c1df9e9bc9da6 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Fri Oct 29 09:37:53 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Oct 30 08:02:32 2021 +0200 Prepare for removal of non-const operator[] from Sequence in filter Change-Id: I3296bf6dbacfc47a7e51afe88082c4801ea28ea8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124365 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/filter/qa/cppunit/xslt-test.cxx b/filter/qa/cppunit/xslt-test.cxx index c3b27b2dbc24..de0e9e71f07a 100644 --- a/filter/qa/cppunit/xslt-test.cxx +++ b/filter/qa/cppunit/xslt-test.cxx @@ -96,16 +96,17 @@ void XsltFilterTest::testXsltCopyNew() OUString source( m_directories.getURLFromSrc(u"/filter/source/xsltfilter/xsltfilter.component")); - uno::Sequence<uno::Any> args(7); - args[0] <<= beans::NamedValue("StylesheetURL", - uno::makeAny(m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/xslt/copy.xslt"))); - args[1] <<= beans::NamedValue("SourceURL", uno::makeAny(source)); - args[2] <<= beans::NamedValue("TargetURL", uno::makeAny(tempURL)); - args[3] <<= beans::NamedValue("SourceBaseURL", - uno::makeAny(m_directories.getURLFromSrc(u"/filter/source/xsltfilter/"))); - args[4] <<= beans::NamedValue("TargetBaseURL", uno::makeAny(tempDirURL)); - args[5] <<= beans::NamedValue("SystemType", uno::makeAny(OUString())); - args[6] <<= beans::NamedValue("PublicType", uno::makeAny(OUString())); + uno::Sequence<uno::Any> args{ + uno::Any(beans::NamedValue("StylesheetURL", + uno::makeAny(m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/xslt/copy.xslt")))), + uno::Any(beans::NamedValue("SourceURL", uno::makeAny(source))), + uno::Any(beans::NamedValue("TargetURL", uno::makeAny(tempURL))), + uno::Any(beans::NamedValue("SourceBaseURL", + uno::makeAny(m_directories.getURLFromSrc(u"/filter/source/xsltfilter/")))), + uno::Any(beans::NamedValue("TargetBaseURL", uno::makeAny(tempDirURL))), + uno::Any(beans::NamedValue("SystemType", uno::makeAny(OUString()))), + uno::Any(beans::NamedValue("PublicType", uno::makeAny(OUString()))) + }; uno::Reference<ucb::XSimpleFileAccess3> xSFA = ucb::SimpleFileAccess::create(getComponentContext()); @@ -150,17 +151,17 @@ void XsltFilterTest::testXsltCopyOld() OUString source( m_directories.getURLFromSrc(u"/filter/source/xsltfilter/xsltfilter.component")); - uno::Sequence<uno::Any> args(7); - args[0] <<= beans::NamedValue("StylesheetURL", - uno::makeAny(m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/xslt/copy.xslt"))); - args[1] <<= beans::NamedValue("SourceURL", uno::makeAny(source)); - args[2] <<= beans::NamedValue("TargetURL", uno::makeAny(tempURL)); - args[3] <<= beans::NamedValue("SourceBaseURL", - uno::makeAny(m_directories.getURLFromSrc(u"/filter/source/xsltfilter/"))); - args[4] <<= beans::NamedValue("TargetBaseURL", uno::makeAny(tempDirURL)); - args[5] <<= beans::NamedValue("SystemType", uno::makeAny(OUString())); - args[6] <<= beans::NamedValue("PublicType", uno::makeAny(OUString())); - + uno::Sequence<uno::Any> args{ + uno::Any(beans::NamedValue("StylesheetURL", + uno::makeAny(m_directories.getURLFromSrc(u"/filter/qa/cppunit/data/xslt/copy.xslt")))), + uno::Any(beans::NamedValue("SourceURL", uno::makeAny(source))), + uno::Any(beans::NamedValue("TargetURL", uno::makeAny(tempURL))), + uno::Any(beans::NamedValue("SourceBaseURL", + uno::makeAny(m_directories.getURLFromSrc(u"/filter/source/xsltfilter/")))), + uno::Any(beans::NamedValue("TargetBaseURL", uno::makeAny(tempDirURL))), + uno::Any(beans::NamedValue("SystemType", uno::makeAny(OUString()))), + uno::Any(beans::NamedValue("PublicType", uno::makeAny(OUString()))) + }; uno::Reference<ucb::XSimpleFileAccess3> xSFA = ucb::SimpleFileAccess::create(getComponentContext()); diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index ca698f378b59..0167bddd4f6f 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -1609,7 +1609,7 @@ CacheItem FilterCache::impl_loadItem(const css::uno::Reference< css::container:: for (sal_Int32 i = 0; i < rNames.getLength(); i++) { - OUString &rPropName = rNames[i]; + const OUString &rPropName = rNames[i]; if (i != rNames.getLength() - 1 || rPropName != PROPNAME_FLAGS) aItem[rPropName] = aValues[i]; else diff --git a/filter/source/graphic/GraphicExportFilter.cxx b/filter/source/graphic/GraphicExportFilter.cxx index b498e71dd4e3..e20c56ddf232 100644 --- a/filter/source/graphic/GraphicExportFilter.cxx +++ b/filter/source/graphic/GraphicExportFilter.cxx @@ -203,7 +203,7 @@ bool GraphicExportFilter::filterExportShape( { if (aDescriptor[i].Name == "FilterName") { - aDescriptor[i].Value <<= maFilterExtension; + aDescriptor.getArray()[i].Value <<= maFilterExtension; break; } } diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index bd25e5248c79..bfdbdd72853a 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -4203,8 +4203,6 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, GraphicObjec "ExportGraphic to GIF failed with " << nErrCode); if (nErrCode == ERRCODE_NONE) { - uno::Sequence<beans::PropertyValue> aFilterData( 1 ); - uno::Sequence<beans::PropertyValue> aAdditionalChunkSequence( 1 ); sal_uInt32 nGIFSreamLen = aGIFStream.Tell(); uno::Sequence<sal_Int8> aGIFSeq( nGIFSreamLen ); sal_Int8* pSeq = aGIFSeq.getArray(); @@ -4213,10 +4211,10 @@ sal_uInt32 EscherGraphicProvider::GetBlibID( SvStream& rPicOutStrm, GraphicObjec beans::PropertyValue aChunkProp, aFilterProp; aChunkProp.Name = "msOG"; aChunkProp.Value <<= aGIFSeq; - aAdditionalChunkSequence[ 0 ] = aChunkProp; + uno::Sequence<beans::PropertyValue> aAdditionalChunkSequence{ aChunkProp }; aFilterProp.Name = "AdditionalChunks"; aFilterProp.Value <<= aAdditionalChunkSequence; - aFilterData[ 0 ] = aFilterProp; + uno::Sequence<beans::PropertyValue> aFilterData{ aFilterProp }; nErrCode = rFilter.ExportGraphic( aGraphic, OUString(), aStream, rFilter.GetExportFormatNumberForShortName( u"PNG" ), &aFilterData ); } diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index c86e56fca8d4..743f4f7cdbe7 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -719,7 +719,7 @@ void SvxMSDffManager::SolveSolver( const SvxMSDffSolverContainer& rSolver ) if ( nPt < o3tl::make_unsigned(aCoordinates.getLength()) ) { nId = 4; - css::drawing::EnhancedCustomShapeParameterPair& rPara = aCoordinates[ nPt ]; + css::drawing::EnhancedCustomShapeParameterPair& rPara = aCoordinates.getArray()[ nPt ]; sal_Int32 nX = 0, nY = 0; if ( ( rPara.First.Value >>= nX ) && ( rPara.Second.Value >>= nY ) ) { @@ -730,8 +730,9 @@ void SvxMSDffManager::SolveSolver( const SvxMSDffSolverContainer& rSolver ) *pAny >>= aGluePoints; sal_Int32 nGluePoints = aGluePoints.getLength(); aGluePoints.realloc( nGluePoints + 1 ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ nGluePoints ].First, nX ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ nGluePoints ].Second, nY ); + auto pGluePoints = aGluePoints.getArray(); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( pGluePoints[ nGluePoints ].First, nX ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( pGluePoints[ nGluePoints ].Second, nY ); PropertyValue aProp; aProp.Name = sGluePoints; aProp.Value <<= aGluePoints; @@ -1913,12 +1914,12 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if ( nNumElem <= 128 ) { uno::Sequence< OUString > aEquations( nNumElem ); - for ( sal_uInt16 i = 0; i < nNumElem; i++ ) + for ( auto& rEquation : asNonConstRange(aEquations) ) { sal_Int16 nP1(0), nP2(0), nP3(0); sal_uInt16 nFlags(0); rIn.ReadUInt16( nFlags ).ReadInt16( nP1 ).ReadInt16( nP2 ).ReadInt16( nP3 ); - aEquations[ i ] = EnhancedCustomShape2d::GetEquation( nFlags, nP1, nP2, nP3 ); + rEquation = EnhancedCustomShape2d::GetEquation( nFlags, nP1, nP2, nP3 ); } // pushing the whole Equations element aProp.Name = "Equations"; @@ -1949,6 +1950,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if (bImport) { uno::Sequence< beans::PropertyValues > aHandles( nNumElem ); + auto aHandlesRange = asNonConstRange(aHandles); for (sal_uInt32 i = 0; i < nNumElem; ++i) { PropVec aHandlePropVec; @@ -2095,7 +2097,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt } if ( !aHandlePropVec.empty() ) { - aHandles[ i ] = comphelper::containerToSequence(aHandlePropVec); + aHandlesRange[ i ] = comphelper::containerToSequence(aHandlePropVec); } } // pushing the whole Handles element @@ -2172,7 +2174,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if (bImport) { aCoordinates.realloc( nNumElemVert ); - for (sal_uInt16 i = 0; i < nNumElemVert; ++i) + for (auto& rCoordinate : asNonConstRange(aCoordinates)) { sal_Int32 nX(0), nY(0); @@ -2203,8 +2205,8 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt nY = nTmpB; } } - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aCoordinates[ i ].First, nX ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aCoordinates[ i ].Second, nY ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rCoordinate.First, nX ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rCoordinate.Second, nY ); } } aProp.Name = "Coordinates"; @@ -2233,7 +2235,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if ( nNumElemSeg ) { aSegments.realloc( nNumElemSeg ); - for (sal_uInt16 i = 0; i < nNumElemSeg; ++i) + for (auto& rSegment : asNonConstRange(aSegments)) { sal_uInt16 nTmp(0); rIn.ReadUInt16( nTmp ); @@ -2333,8 +2335,8 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt // if the command is unknown, we will store all the data in nCnt, so it will be possible to export without loss if ( nCommand == EnhancedCustomShapeSegmentCommand::UNKNOWN ) nCnt = static_cast<sal_Int16>(nTmp); - aSegments[ i ].Command = nCommand; - aSegments[ i ].Count = nCnt; + rSegment.Command = nCommand; + rSegment.Count = nCnt; } } aProp.Name = "Segments"; @@ -2377,7 +2379,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if (bImport) { css::uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > aTextFrames( nNumElem ); - for (sal_uInt16 i = 0; i < nNumElem; ++i) + for (auto& rTextFrame : asNonConstRange(aTextFrames)) { sal_Int32 nLeft(0), nTop(0), nRight(0), nBottom(0); @@ -2386,10 +2388,10 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt .ReadInt32( nRight ) .ReadInt32( nBottom ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].TopLeft.First, nLeft ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].TopLeft.Second, nTop ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].BottomRight.First, nRight ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrames[ i ].BottomRight.Second, nBottom); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rTextFrame.TopLeft.First, nLeft ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rTextFrame.TopLeft.Second, nTop ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rTextFrame.BottomRight.First, nRight ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rTextFrame.BottomRight.Second, nBottom); } aProp.Name = "TextFrames"; aProp.Value <<= aTextFrames; @@ -2418,7 +2420,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if (bImport) { aGluePoints.realloc( nNumElemVert ); - for (sal_uInt16 i = 0; i < nNumElemVert; ++i) + for (auto& rGluePoint : asNonConstRange(aGluePoints)) { sal_Int32 nX(0), nY(0); if ( nElemSizeVert == 8 ) @@ -2436,8 +2438,8 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt nX = nTmpA; nY = nTmpB; } - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ i ].First, nX ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aGluePoints[ i ].Second, nY ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rGluePoint.First, nX ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( rGluePoint.Second, nY ); } } aProp.Name = "GluePoints"; @@ -2529,6 +2531,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt if ( nAdjustmentValues ) { uno::Sequence< css::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq( nAdjustmentValues ); + auto pAdjustmentSeq = aAdjustmentSeq.getArray(); while( --nAdjustmentValues >= 0 ) { sal_Int32 nValue = 0; @@ -2542,11 +2545,11 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt { double fValue = nValue; fValue /= 65536; - aAdjustmentSeq[ nAdjustmentValues ].Value <<= fValue; + pAdjustmentSeq[ nAdjustmentValues ].Value <<= fValue; } else - aAdjustmentSeq[ nAdjustmentValues ].Value <<= nValue; - aAdjustmentSeq[ nAdjustmentValues ].State = ePropertyState; + pAdjustmentSeq[ nAdjustmentValues ].Value <<= nValue; + pAdjustmentSeq[ nAdjustmentValues ].State = ePropertyState; i--; } aProp.Name = "AdjustmentValues"; @@ -4523,15 +4526,16 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r const uno::Any* pAny = aGeometryItem.GetPropertyValueByName(sAdjustmentValues); if (pAny && (*pAny >>= seqAdjustmentValues) && seqAdjustmentValues.getLength() > 1) { + auto pseqAdjustmentValues = seqAdjustmentValues.getArray(); if (seqAdjustmentValues[0].State == css::beans::PropertyState_DEFAULT_VALUE) { - seqAdjustmentValues[0].Value <<= -90.0; - seqAdjustmentValues[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; + pseqAdjustmentValues[0].Value <<= -90.0; + pseqAdjustmentValues[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; } if (seqAdjustmentValues[1].State == css::beans::PropertyState_DEFAULT_VALUE) { - seqAdjustmentValues[1].Value <<= 0.0; - seqAdjustmentValues[1].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; + pseqAdjustmentValues[1].Value <<= 0.0; + pseqAdjustmentValues[1].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; } seqAdjustmentValues[0].Value >>= fStartAngle; seqAdjustmentValues[1].Value >>= fEndAngle; @@ -4667,10 +4671,11 @@ SdrObject* SvxMSDffManager::ImportShape( const DffRecordHeader& rHd, SvStream& r sal_Int32 nRight = static_cast<sal_Int32>((aPieRect_MS.getMaxX() - aEllipseRect_MS.getMinX()) * fTextFrameScaleX ); sal_Int32 nBottom= static_cast<sal_Int32>((aPieRect_MS.getMaxY() - aEllipseRect_MS.getMinY()) * fTextFrameScaleY ); css::uno::Sequence< css::drawing::EnhancedCustomShapeTextFrame > aTextFrame( 1 ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].TopLeft.First, nLeft ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].TopLeft.Second, nTop ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].BottomRight.First, nRight ); - EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( aTextFrame[ 0 ].BottomRight.Second,nBottom ); + auto pTextFrame = aTextFrame.getArray(); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( pTextFrame[ 0 ].TopLeft.First, nLeft ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( pTextFrame[ 0 ].TopLeft.Second, nTop ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( pTextFrame[ 0 ].BottomRight.First, nRight ); + EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( pTextFrame[ 0 ].BottomRight.Second,nBottom ); PropertyValue aProp; aProp.Name = "TextFrames"; aProp.Value <<= aTextFrame; @@ -7107,18 +7112,19 @@ css::uno::Reference < css::embed::XEmbeddedObject > SvxMSDffManager::CheckForCo aFilterName = SvxMSDffManager::GetFilterNameFromClassID( aStgNm ); uno::Sequence<beans::PropertyValue> aMedium(aFilterName.isEmpty() ? 3 : 4); - aMedium[0].Name = "InputStream"; + auto pMedium = aMedium.getArray(); + pMedium[0].Name = "InputStream"; uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( aMemStream ); - aMedium[0].Value <<= xStream; - aMedium[1].Name = "URL"; - aMedium[1].Value <<= OUString( "private:stream" ); - aMedium[2].Name = "DocumentBaseURL"; - aMedium[2].Value <<= rBaseURL; + pMedium[0].Value <<= xStream; + pMedium[1].Name = "URL"; + pMedium[1].Value <<= OUString( "private:stream" ); + pMedium[2].Name = "DocumentBaseURL"; + pMedium[2].Value <<= rBaseURL; if ( !aFilterName.isEmpty() ) { - aMedium[3].Name = "FilterName"; - aMedium[3].Value <<= aFilterName; + pMedium[3].Name = "FilterName"; + pMedium[3].Value <<= aFilterName; } OUString aName( aDstStgName ); diff --git a/filter/source/msfilter/msoleexp.cxx b/filter/source/msfilter/msoleexp.cxx index da109342b6c9..9e68e5cb0ab7 100644 --- a/filter/source/msfilter/msoleexp.cxx +++ b/filter/source/msfilter/msoleexp.cxx @@ -38,6 +38,7 @@ #include <tools/diagnose_ex.h> #include <comphelper/fileformat.h> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <unotools/streamwrap.hxx> #include <comphelper/storagehelper.hxx> #include <svtools/embedhlp.hxx> @@ -88,8 +89,8 @@ static bool UseOldMSExport() configuration::theDefaultProvider::get( comphelper::getProcessComponentContext())); try { - uno::Sequence< uno::Any > aArg( 1 ); - aArg[0] <<= OUString( "/org.openoffice.Office.Common/InternalMSExport" ); + uno::Sequence< uno::Any > aArg{ uno::Any( + OUString( "/org.openoffice.Office.Common/InternalMSExport" )) }; uno::Reference< container::XNameAccess > xNameAccess( xProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationUpdateAccess", @@ -189,13 +190,12 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj rObj->changeState( embed::EmbedStates::RUNNING ); //TODO/LATER: is stream instead of outputstream a better choice?! //TODO/LATER: a "StoreTo" method at embedded object would be nice - uno::Sequence < beans::PropertyValue > aSeq(2); SvStream* pStream = new SvMemoryStream; - aSeq[0].Name = "OutputStream"; ::uno::Reference < io::XOutputStream > xOut = new ::utl::OOutputStreamWrapper( *pStream ); - aSeq[0].Value <<= xOut; - aSeq[1].Name = "FilterName"; - aSeq[1].Value <<= pExpFilter->GetName(); + uno::Sequence < beans::PropertyValue > aSeq{ + comphelper::makePropertyValue("OutputStream", xOut), + comphelper::makePropertyValue("FilterName", pExpFilter->GetName()) + }; uno::Reference < frame::XStorable > xStor( rObj->getComponent(), uno::UNO_QUERY ); try { @@ -289,10 +289,9 @@ void SvxMSExportOLEObjects::ExportOLEObject( svt::EmbeddedObjectRef const & rObj rObj->changeState( embed::EmbedStates::RUNNING ); //TODO/LATER: is stream instead of outputstream a better choice?! //TODO/LATER: a "StoreTo" method at embedded object would be nice - uno::Sequence < beans::PropertyValue > aSeq(1); - aSeq[0].Name = "OutputStream"; ::uno::Reference < io::XOutputStream > xOut = new ::utl::OOutputStreamWrapper( *xEmbStm ); - aSeq[0].Value <<= xOut; + uno::Sequence < beans::PropertyValue > aSeq{ comphelper::makePropertyValue( + "OutputStream", xOut) }; uno::Reference < frame::XStorable > xStor( rObj->getComponent(), uno::UNO_QUERY ); xStor->storeToURL( "private:stream", aSeq ); } diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx index d857c611719d..339b54766101 100644 --- a/filter/source/msfilter/mstoolbar.cxx +++ b/filter/source/msfilter/mstoolbar.cxx @@ -6,6 +6,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <sal/config.h> + +#include <comphelper/propertyvalue.hxx> #include <filter/msfilter/mstoolbar.hxx> #include <o3tl/safeint.hxx> #include <sal/log.hxx> @@ -54,6 +58,7 @@ void CustomToolBarImportHelper::applyIcons() { uno::Sequence<OUString> commands { concommand.sCommand }; uno::Sequence< uno::Reference< graphic::XGraphic > > images { concommand.image }; + auto pimages = images.getArray(); uno::Reference< ui::XImageManager > xImageManager( getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW ); sal_uInt16 nColor = ui::ImageType::COLOR_NORMAL; @@ -62,9 +67,9 @@ void CustomToolBarImportHelper::applyIcons() if ( topwin != nullptr && topwin->GetBackgroundColor().IsDark() ) nColor = css::ui::ImageType::COLOR_HIGHCONTRAST; - ScaleImage( images[ 0 ], 16 ); + ScaleImage( pimages[ 0 ], 16 ); xImageManager->replaceImages( ui::ImageType::SIZE_DEFAULT | nColor, commands, images ); - ScaleImage( images[ 0 ], 26 ); + ScaleImage( pimages[ 0 ], 26 ); xImageManager->replaceImages( ui::ImageType::SIZE_LARGE | nColor, commands, images ); } } @@ -130,15 +135,12 @@ CustomToolBarImportHelper::createMenu( const OUString& rName, const uno::Referen xProps->setPropertyValue("UIName", uno::makeAny( rName ) ); if ( xPopup.is() ) { - uno::Sequence< beans::PropertyValue > aPopupMenu( 4 ); - aPopupMenu[0].Name = "CommandURL"; - aPopupMenu[0].Value <<= "vnd.openoffice.org:" + rName; - aPopupMenu[1].Name = "Label"; - aPopupMenu[1].Value <<= rName; - aPopupMenu[2].Name = "ItemDescriptorContainer"; - aPopupMenu[2].Value <<= xMenuDesc; - aPopupMenu[3].Name = "Type"; - aPopupMenu[3].Value <<= sal_Int32( 0 ); + uno::Sequence< beans::PropertyValue > aPopupMenu{ + comphelper::makePropertyValue("CommandURL", "vnd.openoffice.org:" + rName), + comphelper::makePropertyValue("Label", rName), + comphelper::makePropertyValue("ItemDescriptorContainer", xMenuDesc), + comphelper::makePropertyValue("Type", sal_Int32( 0 )) + }; xPopup->insertByIndex( xPopup->getCount(), uno::makeAny( aPopupMenu ) ); xCfgManager->insertSettings( sMenuBar, xPopup ); diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 4eec9e4e696e..f413af1db651 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -485,10 +485,11 @@ bool executeMacro( SfxObjectShell* pShell, const OUString& sMacroName, uno::Sequ // convert any out params to seem like they were inputs if (nLen) { + auto pArgs = aArgs.getArray(); for (sal_Int32 index = 0; index < nLen; ++index) { sal_Int32 nOutIndex = aOutArgsIndex[index]; - aArgs[nOutIndex] = aOutArgs[index]; + pArgs[nOutIndex] = aOutArgs[index]; } } bRes = ( nErr == ERRCODE_NONE ); diff --git a/filter/source/pdf/pdfdialog.cxx b/filter/source/pdf/pdfdialog.cxx index 44953c242fb3..7c3e5dda1956 100644 --- a/filter/source/pdf/pdfdialog.cxx +++ b/filter/source/pdf/pdfdialog.cxx @@ -100,9 +100,10 @@ Sequence< PropertyValue > SAL_CALL PDFDialog::getPropertyValues() if( i == nCount ) maMediaDescriptor.realloc( ++nCount ); + auto pMediaDescriptor = maMediaDescriptor.getArray(); - maMediaDescriptor[ i ].Name = "FilterData"; - maMediaDescriptor[ i ].Value <<= maFilterData; + pMediaDescriptor[ i ].Name = "FilterData"; + pMediaDescriptor[ i ].Value <<= maFilterData; return maMediaDescriptor; } diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 2932d2e52ac9..43d2b97167fd 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -27,6 +27,7 @@ #include <vcl/canvastools.hxx> #include <vcl/mapmod.hxx> #include <vcl/gdimtf.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <comphelper/string.hxx> #include <comphelper/storagehelper.hxx> @@ -156,14 +157,15 @@ bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, bool bExportNotesPages = false; + auto rRenderOptionsRange = asNonConstRange(rRenderOptions); for( sal_Int32 nData = 0, nDataCount = rRenderOptions.getLength(); nData < nDataCount; ++nData ) { if ( rRenderOptions[ nData ].Name == "IsFirstPage" ) - pFirstPage = &rRenderOptions[ nData ].Value; + pFirstPage = &rRenderOptionsRange[ nData ].Value; else if ( rRenderOptions[ nData ].Name == "IsLastPage" ) - pLastPage = &rRenderOptions[ nData ].Value; + pLastPage = &rRenderOptionsRange[ nData ].Value; else if ( rRenderOptions[ nData ].Name == "ExportNotesPages" ) - rRenderOptions[ nData ].Value >>= bExportNotesPages; + rRenderOptionsRange[ nData ].Value >>= bExportNotesPages; } OutputDevice* pOut = rPDFWriter.GetReferenceDevice(); @@ -332,11 +334,10 @@ static OUString getMimetypeForDocument( const Reference< XComponentContext >& xC // get the actual filter name Reference< lang::XMultiServiceFactory > xConfigProvider = configuration::theDefaultProvider::get( xContext ); - uno::Sequence< uno::Any > aArgs( 1 ); beans::NamedValue aPathProp; aPathProp.Name = "nodepath"; aPathProp.Value <<= OUString( "/org.openoffice.Setup/Office/Factories/" ); - aArgs[0] <<= aPathProp; + uno::Sequence< uno::Any > aArgs{ uno::Any(aPathProp) }; Reference< container::XNameAccess > xSOFConfig( xConfigProvider->createInstanceWithArguments( @@ -867,24 +868,17 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& aPDFExtOutDevData.SetIsReduceImageResolution( mbReduceImageResolution ); aPDFExtOutDevData.SetIsExportNamedDestinations( mbExportBmkToDest ); - Sequence< PropertyValue > aRenderOptions( 8 ); - aRenderOptions[ 0 ].Name = "RenderDevice"; - aRenderOptions[ 0 ].Value <<= uno::Reference<awt::XDevice>(xDevice); - aRenderOptions[ 1 ].Name = "ExportNotesPages"; - aRenderOptions[ 1 ].Value <<= false; - Any& rExportNotesValue = aRenderOptions[ 1 ].Value; - aRenderOptions[ 2 ].Name = "IsFirstPage"; - aRenderOptions[ 2 ].Value <<= true; - aRenderOptions[ 3 ].Name = "IsLastPage"; - aRenderOptions[ 3 ].Value <<= false; - aRenderOptions[ 4 ].Name = "IsSkipEmptyPages"; - aRenderOptions[ 4 ].Value <<= mbSkipEmptyPages; - aRenderOptions[ 5 ].Name = "PageRange"; - aRenderOptions[ 5 ].Value <<= aPageRange; - aRenderOptions[ 6 ].Name = "ExportPlaceholders"; - aRenderOptions[ 6 ].Value <<= mbExportPlaceholders; - aRenderOptions[ 7 ].Name = "SinglePageSheets"; - aRenderOptions[ 7 ].Value <<= mbSinglePageSheets; + Sequence< PropertyValue > aRenderOptions{ + comphelper::makePropertyValue("RenderDevice", uno::Reference<awt::XDevice>(xDevice)), + comphelper::makePropertyValue("ExportNotesPages", false), + comphelper::makePropertyValue("IsFirstPage", true), + comphelper::makePropertyValue("IsLastPage", false), + comphelper::makePropertyValue("IsSkipEmptyPages", mbSkipEmptyPages), + comphelper::makePropertyValue("PageRange", aPageRange), + comphelper::makePropertyValue("ExportPlaceholders", mbExportPlaceholders), + comphelper::makePropertyValue("SinglePageSheets", mbSinglePageSheets) + }; + Any& rExportNotesValue = aRenderOptions.getArray()[ 1 ].Value; if( !aPageRange.isEmpty() || !aSelection.hasValue() ) { diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx index 8c115b1018b5..6d1a793a7158 100644 --- a/filter/source/pdf/pdffilter.cxx +++ b/filter/source/pdf/pdffilter.cxx @@ -146,8 +146,9 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) { sal_Int32 nNewSize = aFilterData.getLength() + 1; aFilterData.realloc( nNewSize ); - aFilterData[nNewSize - 1].Name = "IsRedactMode"; - aFilterData[nNewSize - 1].Value <<= bIsRedactMode; + auto pFilterData = aFilterData.getArray(); + pFilterData[nNewSize - 1].Name = "IsRedactMode"; + pFilterData[nNewSize - 1].Value <<= bIsRedactMode; } } diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 19e810f26956..bda6aa46cc8c 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -45,6 +45,7 @@ #include <editeng/outliner.hxx> #include <editeng/flditem.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertyvalue.hxx> #include <comphelper/sequenceashashmap.hxx> #include <i18nlangtag/lang.h> #include <svl/numformat.hxx> @@ -2459,13 +2460,11 @@ void SVGFilter::implCreateObjectsFromBackground( const Reference< css::drawing:: utl::TempFile aFile; aFile.EnableKillingFile(); - Sequence< PropertyValue > aDescriptor( 3 ); - aDescriptor[0].Name = "FilterName"; - aDescriptor[0].Value <<= OUString( "SVM" ); - aDescriptor[1].Name = "URL"; - aDescriptor[1].Value <<= aFile.GetURL(); - aDescriptor[2].Name = "ExportOnlyBackground"; - aDescriptor[2].Value <<= true; + Sequence< PropertyValue > aDescriptor{ + comphelper::makePropertyValue("FilterName", OUString( "SVM" )), + comphelper::makePropertyValue("URL", aFile.GetURL()), + comphelper::makePropertyValue("ExportOnlyBackground", true) + }; xExporter->setSourceDocument( Reference< XComponent >( rxDrawPage, UNO_QUERY ) ); xExporter->filter( aDescriptor ); diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index e2a3279f86c1..bf7389176097 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -668,7 +668,7 @@ private: } mnFirstRead = aStream->ReadBytes( - &mnFirstBytes[0], + &mnFirstBytes.getArray()[0], std::min(nStreamLen, static_cast<sal_uInt64>(mnFirstBytesSize))); if(aStream->GetError()) diff --git a/filter/source/t602/t602filter.cxx b/filter/source/t602/t602filter.cxx index a8df18768b3a..d2f44023b590 100644 --- a/filter/source/t602/t602filter.cxx +++ b/filter/source/t602/t602filter.cxx @@ -960,8 +960,7 @@ bool T602ImportFilterDialog::OptionsDlg() any <<= ous; xPSetCodeLB->setPropertyValue("StringItemList", any); - Sequence < sal_Int16 > shr(1); - shr[0] = ini.forcecode ? static_cast<sal_Int16>(ini.xcode) + 1 : 0; + Sequence < sal_Int16 > shr{ static_cast<sal_Int16>(ini.forcecode ? ini.xcode + 1 : 0) }; any <<= shr; xPSetCodeLB->setPropertyValue("SelectedItems", any); diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index 27c483d98f71..4bce69876d3c 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -70,7 +70,6 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& xStatusIndicator->start( "Loading :", 4); } - Sequence< Any > aAnys(1); OUString aBaseURI; if (aMediaMap.find(OUString( "URL" ))->second >>= aBaseURI) { @@ -104,7 +103,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& Sequence<PropertyValue> aSettings{ EmptyDbFieldHidesPara }; xInfoSet->setPropertyValue("DefaultDocumentSettings", makeAny(aSettings)); } - aAnys[0] <<= xInfoSet; + Sequence< Any > aAnys{ Any(xInfoSet) }; // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler @@ -259,9 +258,6 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >& try{ // create the xml exporter service and supply the converter component // which implements the document handler - Sequence < Any > aAnys (2); - aAnys[0] <<= xConverter; - // pretty printing is confusing for some filters so it is disabled by default bool bPrettyPrint = @@ -299,7 +295,7 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >& "ExportTextNumberElement", makeAny( bExportTextNumberElementForListItems )); xInfoSet->setPropertyValue("BaseURI", makeAny( aBaseURI )); - aAnys[1] <<= xInfoSet; + Sequence < Any > aAnys{ Any(xConverter), Any(xInfoSet) }; Reference< XExporter > xExporter( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( udExport, aAnys, mxContext ), UNO_QUERY_THROW ); diff --git a/filter/source/xmlfilterdetect/filterdetect.cxx b/filter/source/xmlfilterdetect/filterdetect.cxx index fd179a0e7898..1a3f80cb589a 100644 --- a/filter/source/xmlfilterdetect/filterdetect.cxx +++ b/filter/source/xmlfilterdetect/filterdetect.cxx @@ -205,9 +205,9 @@ OUString SAL_CALL FilterDetect::detect( css::uno::Sequence< css::beans::Property if (location == aArguments.getLength()) { aArguments.realloc(nLength+1); - aArguments[location].Name = "TypeName"; + aArguments.getArray()[location].Name = "TypeName"; } - aArguments[location].Value <<=sTypeName; + aArguments.getArray()[location].Value <<=sTypeName; } return sTypeName; diff --git a/filter/source/xsltdialog/xmlfilterjar.cxx b/filter/source/xsltdialog/xmlfilterjar.cxx index 3ddaed0df05c..e3c8d6239a83 100644 --- a/filter/source/xsltdialog/xmlfilterjar.cxx +++ b/filter/source/xsltdialog/xmlfilterjar.cxx @@ -85,8 +85,7 @@ static Reference< XInterface > addFolder( Reference< XInterface > const & xRootF if ( rName == ".." || rName == "." ) throw lang::IllegalArgumentException(); - Sequence< Any > aArgs(1); - aArgs[0] <<= true; + Sequence< Any > aArgs{ Any(true) }; Reference< XInterface > xFolder( xFactory->createInstanceWithArguments(aArgs) ); Reference< XNamed > xNamed( xFolder, UNO_QUERY ); @@ -147,14 +146,10 @@ bool XMLFilterJarHelper::savePackage( const OUString& rPackageURL, const std::ve // create the package jar file - Sequence< Any > aArguments( 2 ); - aArguments[ 0 ] <<= rPackageURL; - - // let ZipPackage be used ( no manifest.xml is required ) - beans::NamedValue aArg; - aArg.Name = "StorageFormat"; - aArg.Value <<= OUString(ZIP_STORAGE_FORMAT_STRING); - aArguments[ 1 ] <<= aArg; + Sequence< Any > aArguments{ Any(rPackageURL), + // let ZipPackage be used ( no manifest.xml is required ) + Any(beans::NamedValue( + "StorageFormat", Any(OUString(ZIP_STORAGE_FORMAT_STRING)))) }; Reference< XHierarchicalNameAccess > xIfc( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( @@ -237,14 +232,11 @@ void XMLFilterJarHelper::openPackage( const OUString& rPackageURL, { // create the package jar file - Sequence< Any > aArguments( 2 ); - aArguments[ 0 ] <<= rPackageURL; - // let ZipPackage be used ( no manifest.xml is required ) beans::NamedValue aArg; aArg.Name = "StorageFormat"; aArg.Value <<= OUString(ZIP_STORAGE_FORMAT_STRING); - aArguments[ 1 ] <<= aArg; + Sequence< Any > aArguments{ Any(rPackageURL), Any(aArg) }; Reference< XHierarchicalNameAccess > xIfc( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx index 66e35f186c5d..8a0d901cb6e6 100644 --- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx @@ -24,6 +24,8 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> + +#include <comphelper/propertyvalue.hxx> #include <tools/diagnose_ex.h> #include <tools/urlobj.hxx> #include <unotools/pathoptions.hxx> @@ -272,6 +274,7 @@ static Sequence< OUString > createExtensionsSequence( const OUString& rExtension } Sequence< OUString > aExtensions( nExtensions ); + auto aExtensionsRange = asNonConstRange(aExtensions); // extract the extensions from the source string and fill the sequence @@ -285,12 +288,12 @@ static Sequence< OUString > createExtensionsSequence( const OUString& rExtension if( nLastIndex == -1 ) { - aExtensions[i] = rExtensions.copy( nCurrentIndex ); + aExtensionsRange[i] = rExtensions.copy( nCurrentIndex ); break; } else { - aExtensions[i] = rExtensions.copy( nCurrentIndex, nLastIndex - nCurrentIndex ); + aExtensionsRange[i] = rExtensions.copy( nCurrentIndex, nLastIndex - nCurrentIndex ); nCurrentIndex = nLastIndex + 1; nLastIndex = nCurrentIndex; } @@ -496,31 +499,16 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi Sequence< OUString > aUserData( pFilterEntry->getFilterUserData()); // 3. create property values for filter entry - Sequence< PropertyValue > aFilterData( 8 ); - - aFilterData[0].Name = "Type"; - aFilterData[0].Value <<= pFilterEntry->maType; - - aFilterData[1].Name = "UIName"; - aFilterData[1].Value <<= pFilterEntry->maInterfaceName; - - aFilterData[2].Name = "DocumentService"; - aFilterData[2].Value <<= pFilterEntry->maDocumentService; - - aFilterData[3].Name = "FilterService"; - aFilterData[3].Value <<= OUString( "com.sun.star.comp.Writer.XmlFilterAdaptor" ); - - aFilterData[4].Name = "Flags"; - aFilterData[4].Value <<= pFilterEntry->maFlags; - - aFilterData[5].Name = "UserData"; - aFilterData[5].Value <<= aUserData; - - aFilterData[6].Name = "FileFormatVersion"; - aFilterData[6].Value <<= pFilterEntry->maFileFormatVersion; - - aFilterData[7].Name = "TemplateName"; - aFilterData[7].Value <<= pFilterEntry->maImportTemplate; + Sequence< PropertyValue > aFilterData{ + comphelper::makePropertyValue("Type", pFilterEntry->maType), + comphelper::makePropertyValue("UIName", pFilterEntry->maInterfaceName), + comphelper::makePropertyValue("DocumentService", pFilterEntry->maDocumentService), + comphelper::makePropertyValue("FilterService", OUString( "com.sun.star.comp.Writer.XmlFilterAdaptor" )), + comphelper::makePropertyValue("Flags", pFilterEntry->maFlags), + comphelper::makePropertyValue("UserData", aUserData), + comphelper::makePropertyValue("FileFormatVersion", pFilterEntry->maFileFormatVersion), + comphelper::makePropertyValue("TemplateName", pFilterEntry->maImportTemplate) + }; // 4. insert new or replace existing filter try @@ -545,11 +533,6 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi // 5. prepare type information if( bOk ) { - Sequence< PropertyValue > aValues(4); - - aValues[0].Name = "UIName"; - aValues[0].Value <<= pFilterEntry->maInterfaceName; - aValues[1].Name = "ClipboardFormat"; OUString aDocType; if( !pFilterEntry->maDocType.match( m_sDocTypePrefix ) ) { @@ -560,22 +543,22 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi aDocType = pFilterEntry->maDocType; } if (aDocType == m_sDocTypePrefix) - aValues[1].Value <<= OUString(); - else - aValues[1].Value <<= aDocType; - - aValues[2].Name = "DocumentIconID"; - aValues[2].Value <<= pFilterEntry->mnDocumentIconID; + aDocType.clear(); - aValues[3].Name = "Extensions"; - aValues[3].Value <<= createExtensionsSequence( pFilterEntry->maExtension ); + Sequence< PropertyValue > aValues{ + comphelper::makePropertyValue("UIName", pFilterEntry->maInterfaceName), + comphelper::makePropertyValue("ClipboardFormat", aDocType), + comphelper::makePropertyValue("DocumentIconID", pFilterEntry->mnDocumentIconID), + comphelper::makePropertyValue("Extensions", createExtensionsSequence( pFilterEntry->maExtension )) + }; // the detect service will only be registered, if a doctype/search token was specified if (aDocType.getLength() > m_sDocTypePrefix.getLength()) { aValues.realloc(5); - aValues[4].Name = "DetectService"; - aValues[4].Value <<= OUString( "com.sun.star.comp.filters.XMLFilterDetect" ); + auto pValues = aValues.getArray(); + pValues[4].Name = "DetectService"; + pValues[4].Value <<= OUString( "com.sun.star.comp.filters.XMLFilterDetect" ); } // 6. insert new or replace existing type information @@ -668,6 +651,7 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi Sequence< PropertyValue > aSequence; if( mxExtendedTypeDetection->getByName( sFilterDetectService ) >>= aSequence ) { + auto aSequenceRange = asNonConstRange(aSequence); sal_Int32 nCount = aSequence.getLength(); sal_Int32 nIndex; for( nIndex = 0; nIndex < nCount; nIndex++ ) @@ -688,9 +672,9 @@ bool XMLFilterSettingsDialog::insertOrEdit( filter_info_impl* pNewInfo, const fi if( nStr == nStrCount ) { aTypes.realloc( nStrCount + 1 ); - aTypes[nStrCount] = pFilterEntry->maType; + aTypes.getArray()[nStrCount] = pFilterEntry->maType; - aSequence[nIndex].Value <<= aTypes; + aSequenceRange[nIndex].Value <<= aTypes; mxExtendedTypeDetection->replaceByName( sFilterDetectService, makeAny( aSequence ) ); diff --git a/filter/source/xsltdialog/xmlfiltertestdialog.cxx b/filter/source/xsltdialog/xmlfiltertestdialog.cxx index 032e00782a7b..6cbea30926fb 100644 --- a/filter/source/xsltdialog/xmlfiltertestdialog.cxx +++ b/filter/source/xsltdialog/xmlfiltertestdialog.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/xml/sax/Writer.hpp> #include <comphelper/oslfile2streamwrap.hxx> +#include <comphelper/propertyvalue.hxx> #include <vcl/svapp.hxx> #include <sfx2/filedlghelper.hxx> #include <osl/file.hxx> @@ -388,9 +389,8 @@ void XMLFilterTestDialog::onExportBrowse() Reference< XDesktop2 > xLoader = Desktop::create( mxContext ); Reference< XInteractionHandler2 > xInter = InteractionHandler::createWithParent(mxContext, nullptr); - Sequence< PropertyValue > aArguments(1); - aArguments[0].Name = "InteractionHandler"; - aArguments[0].Value <<= xInter; + Sequence< PropertyValue > aArguments{ comphelper::makePropertyValue("InteractionHandler", + xInter) }; Reference< XComponent > xComp( xLoader->loadComponentFromURL( m_sExportRecentFile, "_default", 0, aArguments ) ); if( xComp.is() ) { @@ -432,19 +432,20 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp ) Reference< XOutputStream > xIS( new comphelper::OSLOutputStreamWrapper( aOutputFile ) ); int bUseDocType = m_xFilterInfo->maDocType.isEmpty() ? 0 : 1; Sequence< PropertyValue > aSourceData( 2 + bUseDocType ); + auto pSourceData = aSourceData.getArray(); int i = 0; - aSourceData[i ].Name = "OutputStream"; - aSourceData[i++].Value <<= xIS; + pSourceData[i ].Name = "OutputStream"; + pSourceData[i++].Value <<= xIS; - aSourceData[i].Name = "Indent"; - aSourceData[i++].Value <<= true; + pSourceData[i].Name = "Indent"; + pSourceData[i++].Value <<= true; if( bUseDocType ) { - aSourceData[i ].Name = "DocType_Public"; - aSourceData[i++].Value <<= m_xFilterInfo->maDocType; + pSourceData[i ].Name = "DocType_Public"; + pSourceData[i++].Value <<= m_xFilterInfo->maDocType; } Reference< XExportFilter > xExporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY ); @@ -490,9 +491,8 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp ) { xExporter2->setSourceDocument( xComp ); - Sequence< PropertyValue > aDescriptor( 1 ); - aDescriptor[0].Name = "FileName"; - aDescriptor[0].Value <<= aTempFileURL; + Sequence< PropertyValue > aDescriptor{comphelper::makePropertyValue( + "FileName", aTempFileURL) }; if( xFilter->filter( aDescriptor ) ) displayXMLFile( aTempFileURL ); @@ -569,11 +569,10 @@ void XMLFilterTestDialog::import( const OUString& rURL ) Reference< XDesktop2 > xLoader = Desktop::create( mxContext ); Reference< XInteractionHandler2 > xInter = InteractionHandler::createWithParent(mxContext, nullptr); - Sequence< PropertyValue > aArguments(2); - aArguments[0].Name = "FilterName"; - aArguments[0].Value <<= m_xFilterInfo->maFilterName; - aArguments[1].Name = "InteractionHandler"; - aArguments[1].Value <<= xInter; + Sequence< PropertyValue > aArguments{ + comphelper::makePropertyValue("FilterName", m_xFilterInfo->maFilterName), + comphelper::makePropertyValue("InteractionHandler", xInter) + }; xLoader->loadComponentFromURL( rURL, "_default", 0, aArguments ); @@ -591,17 +590,11 @@ void XMLFilterTestDialog::import( const OUString& rURL ) Reference< XInputStream > xIS( new comphelper::OSLInputStreamWrapper( aInputFile ) ); - Sequence< PropertyValue > aSourceData( 3 ); - int i = 0; - - aSourceData[i ].Name = "InputStream"; - aSourceData[i++].Value <<= xIS; - - aSourceData[i ].Name = "FileName"; - aSourceData[i++].Value <<= rURL; - - aSourceData[i ].Name = "Indent"; - aSourceData[i++].Value <<= true; + Sequence< PropertyValue > aSourceData{ + comphelper::makePropertyValue("InputStream", xIS), + comphelper::makePropertyValue("FileName", rURL), + comphelper::makePropertyValue("Indent", true) + }; Reference< XWriter > xWriter = Writer::create( mxContext ); diff --git a/filter/source/xsltfilter/OleHandler.cxx b/filter/source/xsltfilter/OleHandler.cxx index 44b698aaa5a1..12aff3bcc7c2 100644 --- a/filter/source/xsltfilter/OleHandler.cxx +++ b/filter/source/xsltfilter/OleHandler.cxx @@ -48,8 +48,7 @@ namespace XSLT if (m_storage == nullptr || m_rootStream == nullptr) { m_rootStream = createTempFile(); - Sequence<Any> args(1); - args[0] <<= m_rootStream->getInputStream(); + Sequence<Any> args{ Any(m_rootStream->getInputStream()) }; Reference<XNameContainer> cont( Reference<XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW) @@ -72,8 +71,7 @@ namespace XSLT xSeek->seek(0); //create a com.sun.star.embed.OLESimpleStorage from the temp stream - Sequence<Any> args(1); - args[0] <<= xSeek; + Sequence<Any> args{ Any(xSeek) }; Reference<XNameContainer> cont( Reference<XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW) ->createInstanceWithArguments("com.sun.star.embed.OLESimpleStorage", args), UNO_QUERY); @@ -179,11 +177,12 @@ namespace XSLT Reference<XInputStream> xInput = subStream->getInputStream(); Reference<XOutputStream> xOutput = subStream->getOutputStream(); //write the length to the temp stream - Sequence<sal_Int8> header(4); - header[0] = static_cast<sal_Int8>(oledata.getLength() >> 0) & 0xFF; - header[1] = static_cast<sal_Int8>(oledata.getLength() >> 8) & 0xFF; - header[2] = static_cast<sal_Int8>(oledata.getLength() >> 16) & 0xFF; - header[3] = static_cast<sal_Int8>(oledata.getLength() >> 24) & 0xFF; + Sequence<sal_Int8> header{ + static_cast<sal_Int8>((oledata.getLength() >> 0) & 0xFF), + static_cast<sal_Int8>((oledata.getLength() >> 8) & 0xFF), + static_cast<sal_Int8>((oledata.getLength() >> 16) & 0xFF), + static_cast<sal_Int8>((oledata.getLength() >> 24) & 0xFF) + }; xOutput->writeBytes(header); // Compress the bytes @@ -194,13 +193,10 @@ namespace XSLT int compressedDataLength = compresser->doDeflateSegment(output, oledata.getLength()); compresser.reset(); //realloc the data length - Sequence<sal_Int8> compressed(compressedDataLength); - for (int i = 0; i < compressedDataLength; i++) { - compressed[i] = output[i]; - } + output.realloc(compressedDataLength); //write the compressed data to the temp stream - xOutput->writeBytes(compressed); + xOutput->writeBytes(output); //seek to 0 Reference<XSeekable> xSeek(xInput, UNO_QUERY); xSeek->seek(0); diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx index f7dcab9e5cdd..4a8cd64b4fe6 100644 --- a/filter/source/xsltfilter/XSLTFilter.cxx +++ b/filter/source/xsltfilter/XSLTFilter.cxx @@ -331,19 +331,9 @@ namespace XSLT return false; // create transformer - Sequence<Any> args(3); - NamedValue nv; - - nv.Name = "StylesheetURL"; - nv.Value <<= expandUrl(udStyleSheet); - args[0] <<= nv; - nv.Name = "SourceURL"; - nv.Value <<= aURL; - args[1] <<= nv; - nv.Name = "SourceBaseURL"; - nv.Value <<= INetURLObject(aURL).getBase(); - args[2] <<= nv; - + Sequence<Any> args{ Any(NamedValue("StylesheetURL", Any(expandUrl(udStyleSheet)))), + Any(NamedValue("SourceURL", Any(aURL))), + Any(NamedValue("SourceBaseURL", Any(INetURLObject(aURL).getBase()))) }; m_tcontrol = impl_createTransformer(msUserData[1], args); OSL_ASSERT(xHandler.is()); @@ -471,19 +461,9 @@ namespace XSLT return false; // create transformer - Sequence<Any> args(3); - NamedValue nv; - - nv.Name = "StylesheetURL"; - nv.Value <<= expandUrl(udStyleSheet); - args[0] <<= nv; - nv.Name = "SourceURL"; - nv.Value <<= aURL; - args[1] <<= nv; - nv.Name = "SourceBaseURL"; - nv.Value <<= INetURLObject(aURL).getBase(); - args[2] <<= nv; - + Sequence<Any> args{ Any(NamedValue("StylesheetURL", Any(expandUrl(udStyleSheet)))), + Any(NamedValue("SourceURL", Any(aURL))), + Any(NamedValue("SourceBaseURL", Any(INetURLObject(aURL).getBase()))) }; m_tcontrol = impl_createTransformer(msUserData[1], args); assert(xFastParser.is()); @@ -601,24 +581,13 @@ namespace XSLT } // create transformer - Sequence<Any> args(4); - NamedValue nv; - nv.Name = "StylesheetURL"; - nv.Value <<= expandUrl(udStyleSheet); - args[0] <<= nv; - nv.Name = "TargetURL"; - nv.Value <<= sURL; - args[1] <<= nv; - nv.Name = "DoctypePublic"; - nv.Value <<= aDoctypePublic; - args[2] <<= nv; - nv.Name = "TargetBaseURL"; INetURLObject ineturl(sURL); ineturl.removeSegment(); m_aExportBaseUrl = ineturl.GetMainURL(INetURLObject::DecodeMechanism::NONE); - nv.Value <<= m_aExportBaseUrl; - args[3] <<= nv; - + Sequence<Any> args{ Any(NamedValue("StylesheetURL", Any(expandUrl(udStyleSheet)))), + Any(NamedValue("TargetURL", Any(sURL))), + Any(NamedValue("DoctypePublic", Any(aDoctypePublic))), + Any(NamedValue("TargetBaseURL", Any(m_aExportBaseUrl))) }; m_tcontrol = impl_createTransformer(msUserData[1], args); OSL_ASSERT(m_rOutputStream.is());