summaryrefslogtreecommitdiff
path: root/sdext/source/minimizer
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-10-29 10:02:46 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-10-31 06:56:57 +0100
commit8b9e502480812f61a1c8d37c465aaf93763fe156 (patch)
treec74b7baf71fe1ffd88a9819bb53b33fb75668392 /sdext/source/minimizer
parentce22935a8586eda71fd29d4ff969d9cd7a2ec15b (diff)
Prepare for removal of non-const operator[] from Sequence in sdext
Change-Id: I1992d1ffbbc80efe9749ebd254971a0a92a10019 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124386 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sdext/source/minimizer')
-rw-r--r--sdext/source/minimizer/configurationaccess.cxx49
-rw-r--r--sdext/source/minimizer/impoptimizer.cxx62
-rw-r--r--sdext/source/minimizer/optimizationstats.cxx13
-rw-r--r--sdext/source/minimizer/optimizerdialog.cxx15
-rw-r--r--sdext/source/minimizer/optimizerdialogcontrols.cxx20
5 files changed, 69 insertions, 90 deletions
diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx
index 0ed089e341a2..3479918c2dc9 100644
--- a/sdext/source/minimizer/configurationaccess.cxx
+++ b/sdext/source/minimizer/configurationaccess.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <sal/macros.h>
#include <sal/log.hxx>
#include <tools/diagnose_ex.h>
@@ -427,38 +428,24 @@ sal_Int32 ConfigurationAccess::GetConfigProperty( const PPPOptimizerTokenEnum eP
Sequence< PropertyValue > ConfigurationAccess::GetConfigurationSequence()
{
- Sequence< PropertyValue > aRet( 15 );
OptimizerSettings& rSettings( maSettings.front() );
- aRet[ 0 ].Name = "JPEGCompression";
- aRet[ 0 ].Value <<= rSettings.mbJPEGCompression;
- aRet[ 1 ].Name = "JPEGQuality";
- aRet[ 1 ].Value <<= rSettings.mnJPEGQuality;
- aRet[ 2 ].Name = "RemoveCropArea";
- aRet[ 2 ].Value <<= rSettings.mbRemoveCropArea;
- aRet[ 3 ].Name = "ImageResolution";
- aRet[ 3 ].Value <<= rSettings.mnImageResolution;
- aRet[ 4 ].Name = "EmbedLinkedGraphics";
- aRet[ 4 ].Value <<= rSettings.mbEmbedLinkedGraphics;
- aRet[ 5 ].Name = "OLEOptimization";
- aRet[ 5 ].Value <<= rSettings.mbOLEOptimization;
- aRet[ 6 ].Name = "OLEOptimizationType";
- aRet[ 6 ].Value <<= rSettings.mnOLEOptimizationType;
- aRet[ 7 ].Name = "DeleteUnusedMasterPages";
- aRet[ 7 ].Value <<= rSettings.mbDeleteUnusedMasterPages;
- aRet[ 8 ].Name = "DeleteHiddenSlides";
- aRet[ 8 ].Value <<= rSettings.mbDeleteHiddenSlides;
- aRet[ 9 ].Name = "DeleteNotesPages";
- aRet[ 9 ].Value <<= rSettings.mbDeleteNotesPages;
- aRet[ 10].Name = "CustomShowName";
- aRet[ 10].Value <<= rSettings.maCustomShowName;
- aRet[ 11].Name = "SaveAsURL";
- aRet[ 11].Value <<= rSettings.maSaveAsURL;
- aRet[ 12].Name = "FilterName";
- aRet[ 12].Value <<= rSettings.maFilterName;
- aRet[ 13].Name = "OpenNewDocument";
- aRet[ 13].Value <<= rSettings.mbOpenNewDocument;
- aRet[ 14].Name = "EstimatedFileSize";
- aRet[ 14].Value <<= rSettings.mnEstimatedFileSize;
+ Sequence< PropertyValue > aRet{
+ comphelper::makePropertyValue("JPEGCompression", rSettings.mbJPEGCompression),
+ comphelper::makePropertyValue("JPEGQuality", rSettings.mnJPEGQuality),
+ comphelper::makePropertyValue("RemoveCropArea", rSettings.mbRemoveCropArea),
+ comphelper::makePropertyValue("ImageResolution", rSettings.mnImageResolution),
+ comphelper::makePropertyValue("EmbedLinkedGraphics", rSettings.mbEmbedLinkedGraphics),
+ comphelper::makePropertyValue("OLEOptimization", rSettings.mbOLEOptimization),
+ comphelper::makePropertyValue("OLEOptimizationType", rSettings.mnOLEOptimizationType),
+ comphelper::makePropertyValue("DeleteUnusedMasterPages", rSettings.mbDeleteUnusedMasterPages),
+ comphelper::makePropertyValue("DeleteHiddenSlides", rSettings.mbDeleteHiddenSlides),
+ comphelper::makePropertyValue("DeleteNotesPages", rSettings.mbDeleteNotesPages),
+ comphelper::makePropertyValue("CustomShowName", rSettings.maCustomShowName),
+ comphelper::makePropertyValue("SaveAsURL", rSettings.maSaveAsURL),
+ comphelper::makePropertyValue("FilterName", rSettings.maFilterName),
+ comphelper::makePropertyValue("OpenNewDocument", rSettings.mbOpenNewDocument),
+ comphelper::makePropertyValue("EstimatedFileSize", rSettings.mnEstimatedFileSize)
+ };
return aRet;
}
diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx
index 6f9e2416ac94..cf8b875ebe21 100644
--- a/sdext/source/minimizer/impoptimizer.cxx
+++ b/sdext/source/minimizer/impoptimizer.cxx
@@ -50,6 +50,8 @@
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
+#include <comphelper/propertyvalue.hxx>
+
using namespace ::std;
using namespace ::com::sun::star;
using namespace ::com::sun::star::io;
@@ -202,31 +204,22 @@ static void ImpCompressGraphic( Reference< XGraphicProvider > const & rxGraphicP
{
if ( rxGraphicProvider.is() && rxOutputStream.is() )
{
- Sequence< PropertyValue > aFilterData( 8 );
- aFilterData[ 0 ].Name = "ImageResolution";
- aFilterData[ 0 ].Value <<= nImageResolution;
- aFilterData[ 1 ].Name = "ColorMode"; // todo: jpeg color mode (0->true color, 1->greyscale)
- aFilterData[ 1 ].Value <<= sal_Int32(0);
- aFilterData[ 2 ].Name = "Quality"; // quality that is used if we export to jpeg
- aFilterData[ 2 ].Value <<= nJPEGQuality;
- aFilterData[ 3 ].Name = "Compression"; // compression that is used if we export to png
- aFilterData[ 3 ].Value <<= sal_Int32(6);
- aFilterData[ 4 ].Name = "Interlaced"; // interlaced is turned off if we export to png
- aFilterData[ 4 ].Value <<= sal_Int32(0);
- aFilterData[ 5 ].Name = "LogicalSize";
- aFilterData[ 5 ].Value <<= rLogicalSize;
- aFilterData[ 6 ].Name = "RemoveCropArea";
- aFilterData[ 6 ].Value <<= bRemoveCropping;
- aFilterData[ 7 ].Name = "GraphicCropLogic";
- aFilterData[ 7 ].Value <<= rGraphicCropLogic;
-
- Sequence< PropertyValue > aArgs( 3 );
- aArgs[ 0 ].Name = "MimeType"; // the GraphicProvider is using "MimeType", the GraphicExporter "MediaType"...
- aArgs[ 0 ].Value <<= rDestMimeType;
- aArgs[ 1 ].Name = "OutputStream";
- aArgs[ 1 ].Value <<= rxOutputStream;
- aArgs[ 2 ].Name = "FilterData";
- aArgs[ 2 ].Value <<= aFilterData;
+ Sequence< PropertyValue > aFilterData{
+ comphelper::makePropertyValue("ImageResolution", nImageResolution),
+ comphelper::makePropertyValue("ColorMode", sal_Int32(0)), // todo: jpeg color mode (0->true color, 1->greyscale)
+ comphelper::makePropertyValue("Quality", nJPEGQuality), // quality that is used if we export to jpeg
+ comphelper::makePropertyValue("Compression", sal_Int32(6)), // compression that is used if we export to png
+ comphelper::makePropertyValue("Interlaced", sal_Int32(0)), // interlaced is turned off if we export to png
+ comphelper::makePropertyValue("LogicalSize", rLogicalSize),
+ comphelper::makePropertyValue("RemoveCropArea", bRemoveCropping),
+ comphelper::makePropertyValue("GraphicCropLogic", rGraphicCropLogic)
+ };
+
+ Sequence< PropertyValue > aArgs{
+ comphelper::makePropertyValue("MimeType", rDestMimeType), // the GraphicProvider is using "MimeType", the GraphicExporter "MediaType"...
+ comphelper::makePropertyValue("OutputStream", rxOutputStream),
+ comphelper::makePropertyValue("FilterData", aFilterData)
+ };
rxGraphicProvider->storeGraphic( rxGraphic, aArgs );
}
@@ -328,9 +321,8 @@ static Reference< XGraphic > ImpCompressGraphic( const Reference< XComponentCont
Reference< XInputStream > xInputStream( xTempFile->getInputStream() );
Reference< XSeekable > xSeekable( xInputStream, UNO_QUERY_THROW );
xSeekable->seek( 0 );
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[ 0 ].Name = "InputStream";
- aArgs[ 0 ].Value <<= xInputStream;
+ Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
+ "InputStream", xInputStream) };
xNewGraphic = xGraphicProvider->queryGraphic( aArgs );
}
}
@@ -347,9 +339,8 @@ static Reference< XGraphic > ImpCompressGraphic( const Reference< XComponentCont
Reference< XInputStream > xInputStream( xTempFile->getInputStream() );
Reference< XSeekable > xSeekable( xInputStream, UNO_QUERY_THROW );
xSeekable->seek( 0 );
- Sequence< PropertyValue > aArgs( 1 );
- aArgs[ 0 ].Name = "InputStream";
- aArgs[ 0 ].Value <<= xInputStream;
+ Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue("InputStream",
+ xInputStream) };
xNewGraphic = xGraphicProvider->queryGraphic( aArgs );
}
}
@@ -633,8 +624,9 @@ void ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments )
{
int nLength = aArguments.getLength();
aArguments.realloc( nLength + 1 );
- aArguments[ nLength ].Name = "FilterName";
- aArguments[ nLength ].Value <<= maFilterName;
+ auto pArguments = aArguments.getArray();
+ pArguments[ nLength ].Name = "FilterName";
+ pArguments[ nLength ].Value <<= maFilterName;
}
xStorable->storeToURL( maSaveAsURL, aArguments );
if ( !nSourceSize )
@@ -648,9 +640,7 @@ void ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments )
xSelf = xDesktop->findFrame( "_blank", FrameSearchFlag::CREATE );
Reference< XComponentLoader > xComponentLoader( xSelf, UNO_QUERY );
- Sequence< PropertyValue > aLoadProps( 1 );
- aLoadProps[ 0 ].Name = "Hidden";
- aLoadProps[ 0 ].Value <<= true;
+ Sequence< PropertyValue > aLoadProps{ comphelper::makePropertyValue("Hidden", true) };
mxModel.set( xComponentLoader->loadComponentFromURL(
maSaveAsURL, "_self", 0, aLoadProps ), UNO_QUERY );
}
diff --git a/sdext/source/minimizer/optimizationstats.cxx b/sdext/source/minimizer/optimizationstats.cxx
index deed337c712a..1deef26ac059 100644
--- a/sdext/source/minimizer/optimizationstats.cxx
+++ b/sdext/source/minimizer/optimizationstats.cxx
@@ -23,6 +23,10 @@
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <comphelper/propertyvalue.hxx>
+
+#include <algorithm>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -51,13 +55,10 @@ const uno::Any* OptimizationStats::GetStatusValue( const PPPOptimizerTokenEnum e
css::beans::PropertyValues OptimizationStats::GetStatusSequence()
{
- int i = 0;
uno::Sequence< PropertyValue > aStatsSequence( maStats.size() );
- for( const auto& rEntry : maStats )
- {
- aStatsSequence[ i ].Name = TKGet( rEntry.first );
- aStatsSequence[ i++ ].Value = rEntry.second;
- }
+ std::transform(maStats.begin(), maStats.end(), aStatsSequence.getArray(),
+ [](const auto& rEntry)
+ { return comphelper::makePropertyValue(TKGet( rEntry.first ), rEntry.second); });
return aStatsSequence;
}
diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx
index ab392266e56d..bdfca5f326cd 100644
--- a/sdext/source/minimizer/optimizerdialog.cxx
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -31,6 +31,8 @@
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/util/XModifiable.hpp>
+
+#include <comphelper/propertyvalue.hxx>
#include <sal/macros.h>
#include <osl/time.h>
#include <vcl/errinf.hxx>
@@ -595,14 +597,11 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
aURL.Path = "optimize";
- Sequence< PropertyValue > lArguments( 3 );
- lArguments[ 0 ].Name = "Settings";
- lArguments[ 0 ].Value <<= mrOptimizerDialog.GetConfigurationSequence();
- lArguments[ 1 ].Name = "StatusDispatcher";
- lArguments[ 1 ].Value <<= mrOptimizerDialog.GetStatusDispatcher();
- lArguments[ 2 ].Name = "InformationDialog";
- lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
-
+ Sequence< PropertyValue > lArguments{
+ comphelper::makePropertyValue("Settings", mrOptimizerDialog.GetConfigurationSequence()),
+ comphelper::makePropertyValue("StatusDispatcher", mrOptimizerDialog.GetStatusDispatcher()),
+ comphelper::makePropertyValue("InformationDialog", mrOptimizerDialog.GetFrame())
+ };
ErrCode errorCode;
try
diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx
index 23011e50716b..8b98f2a5faaf 100644
--- a/sdext/source/minimizer/optimizerdialogcontrols.cxx
+++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx
@@ -393,9 +393,10 @@ void OptimizerDialog::UpdateControlStatesPage0()
if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
{
aItemList.realloc( rList.size() - 1 );
+ auto pItemList = aItemList.getArray();
for ( std::vector<OptimizerSettings>::size_type i = 1; i < rList.size(); i++ )
{
- aItemList[ i - 1 ] = rList[ i ].maName;
+ pItemList[ i - 1 ] = rList[ i ].maName;
if ( nSelectedItem < 0 )
{
if ( rList[ i ] == rList[ 0 ] )
@@ -407,8 +408,7 @@ void OptimizerDialog::UpdateControlStatesPage0()
Sequence< short > aSelectedItems;
if ( nSelectedItem >= 0 )
{
- aSelectedItems.realloc( 1 );
- aSelectedItems[ 0 ] = nSelectedItem;
+ aSelectedItems = { nSelectedItem };
if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted
bRemoveButtonEnabled = true;
}
@@ -517,11 +517,12 @@ void OptimizerDialog::UpdateControlStatesPage2()
}
void OptimizerDialog::InitPage2()
{
- Sequence< OUString > aResolutionItemList( 4 );
- aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';' );
- aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';' );
- aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';' );
- aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';' );
+ Sequence< OUString > aResolutionItemList{
+ getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';' ),
+ getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';' ),
+ getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';' ),
+ getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';' )
+ };
std::vector< OUString > aControlList
{
@@ -619,8 +620,9 @@ void OptimizerDialog::UpdateControlStatesPage4()
if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
{
aItemList.realloc( rList.size() - 1 );
+ auto pItemList = aItemList.getArray();
for ( std::vector<OptimizerSettings>::size_type w = 1; w < rList.size(); w++ )
- aItemList[ w - 1 ] = rList[ w ].maName;
+ pItemList[ w - 1 ] = rList[ w ].maName;
}
setControlProperty( "ComboBox0Pg4", "StringItemList", Any( aItemList ) );