diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-12 12:31:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-12 13:01:50 +0100 |
commit | 58e31745600757f3d95085e67aa6bf13d7b9878b (patch) | |
tree | e165629c049dccdc3c991d40e07de0401b6f9b0f /sdext/source/minimizer | |
parent | a8f21e120b1073d7019d41e85cc9a15104ed5c93 (diff) |
loplugin:flatten in sdext
Change-Id: I5a7c2d38ef2e4af54316becd807bffab83d402d0
Reviewed-on: https://gerrit.libreoffice.org/67715
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext/source/minimizer')
-rw-r--r-- | sdext/source/minimizer/configurationaccess.cxx | 130 | ||||
-rw-r--r-- | sdext/source/minimizer/graphiccollector.cxx | 84 | ||||
-rw-r--r-- | sdext/source/minimizer/impoptimizer.cxx | 228 | ||||
-rw-r--r-- | sdext/source/minimizer/optimizerdialog.cxx | 136 | ||||
-rw-r--r-- | sdext/source/minimizer/pppoptimizerdialog.cxx | 68 |
5 files changed, 323 insertions, 323 deletions
diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx index f7978379761b..f0e16bd12461 100644 --- a/sdext/source/minimizer/configurationaccess.cxx +++ b/sdext/source/minimizer/configurationaccess.cxx @@ -41,89 +41,89 @@ static OUString GetPathToConfigurationRoot() void OptimizerSettings::LoadSettingsFromConfiguration( const Reference< XNameAccess >& rSettings ) { - if ( rSettings.is() ) + if ( !rSettings.is() ) + return; + + const Sequence< OUString > aElements( rSettings->getElementNames() ); + for ( int i = 0; i < aElements.getLength(); i++ ) { - const Sequence< OUString > aElements( rSettings->getElementNames() ); - for ( int i = 0; i < aElements.getLength(); i++ ) + try { - try + const OUString aPropertyName( aElements[ i ] ); + Any aValue( rSettings->getByName( aPropertyName ) ); + switch( TKGet( aPropertyName ) ) { - const OUString aPropertyName( aElements[ i ] ); - Any aValue( rSettings->getByName( aPropertyName ) ); - switch( TKGet( aPropertyName ) ) - { - case TK_Name : aValue >>= maName; break; - case TK_JPEGCompression : aValue >>= mbJPEGCompression; break; - case TK_JPEGQuality : aValue >>= mnJPEGQuality; break; - case TK_RemoveCropArea : aValue >>= mbRemoveCropArea; break; - case TK_ImageResolution : aValue >>= mnImageResolution; break; - case TK_EmbedLinkedGraphics : aValue >>= mbEmbedLinkedGraphics; break; - case TK_OLEOptimization : aValue >>= mbOLEOptimization; break; - case TK_OLEOptimizationType : aValue >>= mnOLEOptimizationType; break; - case TK_DeleteUnusedMasterPages : aValue >>= mbDeleteUnusedMasterPages; break; - case TK_DeleteHiddenSlides : aValue >>= mbDeleteHiddenSlides; break; - case TK_DeleteNotesPages : aValue >>= mbDeleteNotesPages ;break; - case TK_SaveAs : aValue >>= mbSaveAs; break; + case TK_Name : aValue >>= maName; break; + case TK_JPEGCompression : aValue >>= mbJPEGCompression; break; + case TK_JPEGQuality : aValue >>= mnJPEGQuality; break; + case TK_RemoveCropArea : aValue >>= mbRemoveCropArea; break; + case TK_ImageResolution : aValue >>= mnImageResolution; break; + case TK_EmbedLinkedGraphics : aValue >>= mbEmbedLinkedGraphics; break; + case TK_OLEOptimization : aValue >>= mbOLEOptimization; break; + case TK_OLEOptimizationType : aValue >>= mnOLEOptimizationType; break; + case TK_DeleteUnusedMasterPages : aValue >>= mbDeleteUnusedMasterPages; break; + case TK_DeleteHiddenSlides : aValue >>= mbDeleteHiddenSlides; break; + case TK_DeleteNotesPages : aValue >>= mbDeleteNotesPages ;break; + case TK_SaveAs : aValue >>= mbSaveAs; break; // case TK_SaveAsURL : aValue >>= maSaveAsURL; break; // URL is not saved to configuration // case TK_FilterName : aValue >>= maFilterName; break; // URL is not saved to configuration - case TK_OpenNewDocument : aValue >>= mbOpenNewDocument; break; - default: break; - } - } - catch (const Exception&) - { + case TK_OpenNewDocument : aValue >>= mbOpenNewDocument; break; + default: break; } } + catch (const Exception&) + { + } } } void OptimizerSettings::SaveSettingsToConfiguration( const Reference< XNameReplace >& rSettings ) { - if ( rSettings.is() ) - { - OUString pNames[] = { - OUString("Name"), - OUString("JPEGCompression"), - OUString("JPEGQuality"), - OUString("RemoveCropArea"), - OUString("ImageResolution"), - OUString("EmbedLinkedGraphics"), - OUString("OLEOptimization"), - OUString("OLEOptimizationType"), - OUString("DeleteUnusedMasterPages"), - OUString("DeleteHiddenSlides"), - OUString("DeleteNotesPages"), - OUString("SaveAs"), + if ( !rSettings.is() ) + return; + + OUString pNames[] = { + OUString("Name"), + OUString("JPEGCompression"), + OUString("JPEGQuality"), + OUString("RemoveCropArea"), + OUString("ImageResolution"), + OUString("EmbedLinkedGraphics"), + OUString("OLEOptimization"), + OUString("OLEOptimizationType"), + OUString("DeleteUnusedMasterPages"), + OUString("DeleteHiddenSlides"), + OUString("DeleteNotesPages"), + OUString("SaveAs"), // OUString("SaveAsURL"), // OUString("FilterName"), - OUString("OpenNewDocument") }; - - Any pValues[] = { - Any( maName ), - Any( mbJPEGCompression ), - Any( mnJPEGQuality ), - Any( mbRemoveCropArea ), - Any( mnImageResolution ), - Any( mbEmbedLinkedGraphics ), - Any( mbOLEOptimization ), - Any( mnOLEOptimizationType ), - Any( mbDeleteUnusedMasterPages ), - Any( mbDeleteHiddenSlides ), - Any( mbDeleteNotesPages ), - Any( mbSaveAs ), + OUString("OpenNewDocument") }; + + Any pValues[] = { + Any( maName ), + Any( mbJPEGCompression ), + Any( mnJPEGQuality ), + Any( mbRemoveCropArea ), + Any( mnImageResolution ), + Any( mbEmbedLinkedGraphics ), + Any( mbOLEOptimization ), + Any( mnOLEOptimizationType ), + Any( mbDeleteUnusedMasterPages ), + Any( mbDeleteHiddenSlides ), + Any( mbDeleteNotesPages ), + Any( mbSaveAs ), // Any( maSaveAsURL ), // Any( maFilterName ), - Any( mbOpenNewDocument ) }; + Any( mbOpenNewDocument ) }; - for ( int i = 0; i < int(SAL_N_ELEMENTS( pNames )); i++ ) + for ( int i = 0; i < int(SAL_N_ELEMENTS( pNames )); i++ ) + { + try + { + rSettings->replaceByName( pNames[ i ], pValues[ i ] ); + } + catch (const Exception&) { - try - { - rSettings->replaceByName( pNames[ i ], pValues[ i ] ); - } - catch (const Exception&) - { - } } } } diff --git a/sdext/source/minimizer/graphiccollector.cxx b/sdext/source/minimizer/graphiccollector.cxx index c0ca3d57f4a0..73cd5195e51e 100644 --- a/sdext/source/minimizer/graphiccollector.cxx +++ b/sdext/source/minimizer/graphiccollector.cxx @@ -60,25 +60,25 @@ const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentCo static void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser ) { - if ( rGraphicSettings.mbEmbedLinkedGraphics ) + if ( !rGraphicSettings.mbEmbedLinkedGraphics ) + return; + + auto aIter = std::find_if(rGraphicEntities.begin(), rGraphicEntities.end(), + [&rUser](const GraphicCollector::GraphicEntity& rGraphicEntity) { + return rGraphicEntity.maUser[ 0 ].mxGraphic == rUser.mxGraphic; + }); + if ( aIter == rGraphicEntities.end() ) { - auto aIter = std::find_if(rGraphicEntities.begin(), rGraphicEntities.end(), - [&rUser](const GraphicCollector::GraphicEntity& rGraphicEntity) { - return rGraphicEntity.maUser[ 0 ].mxGraphic == rUser.mxGraphic; - }); - if ( aIter == rGraphicEntities.end() ) - { - GraphicCollector::GraphicEntity aEntity( rUser ); - rGraphicEntities.push_back( aEntity ); - } - else - { - if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width ) - aIter->maLogicalSize.Width = rUser.maLogicalSize.Width; - if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height ) - aIter->maLogicalSize.Height = rUser.maLogicalSize.Height; - aIter->maUser.push_back( rUser ); - } + GraphicCollector::GraphicEntity aEntity( rUser ); + rGraphicEntities.push_back( aEntity ); + } + else + { + if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width ) + aIter->maLogicalSize.Width = rUser.maLogicalSize.Width; + if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height ) + aIter->maLogicalSize.Height = rUser.maLogicalSize.Height; + aIter->maUser.push_back( rUser ); } } @@ -86,37 +86,37 @@ static void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Re { Reference< XGraphic > xGraphic; Reference< XPropertySet > xShapePropertySet( rxShape, UNO_QUERY_THROW ); - if ( xShapePropertySet->getPropertyValue( "Graphic" ) >>= xGraphic ) - { - text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 ); + if ( !(xShapePropertySet->getPropertyValue( "Graphic" ) >>= xGraphic) ) + return; + + text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 ); - GraphicCollector::GraphicUser aUser; - aUser.mxShape = rxShape; - aUser.mbFillBitmap = false; - aUser.mxGraphic = xGraphic; - xShapePropertySet->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropLogic; - awt::Size aLogicalSize( rxShape->getSize() ); + GraphicCollector::GraphicUser aUser; + aUser.mxShape = rxShape; + aUser.mbFillBitmap = false; + aUser.mxGraphic = xGraphic; + xShapePropertySet->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropLogic; + awt::Size aLogicalSize( rxShape->getSize() ); - // calculating the logical size, as if there were no cropping - if ( aGraphicCropLogic.Left || aGraphicCropLogic.Right || aGraphicCropLogic.Top || aGraphicCropLogic.Bottom ) + // calculating the logical size, as if there were no cropping + if ( aGraphicCropLogic.Left || aGraphicCropLogic.Right || aGraphicCropLogic.Top || aGraphicCropLogic.Bottom ) + { + awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); + if ( aSize100thMM.Width && aSize100thMM.Height ) { - awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); - if ( aSize100thMM.Width && aSize100thMM.Height ) + awt::Size aCropSize( aSize100thMM.Width - ( aGraphicCropLogic.Left + aGraphicCropLogic.Right ), + aSize100thMM.Height - ( aGraphicCropLogic.Top + aGraphicCropLogic.Bottom )); + if ( aCropSize.Width && aCropSize.Height ) { - awt::Size aCropSize( aSize100thMM.Width - ( aGraphicCropLogic.Left + aGraphicCropLogic.Right ), - aSize100thMM.Height - ( aGraphicCropLogic.Top + aGraphicCropLogic.Bottom )); - if ( aCropSize.Width && aCropSize.Height ) - { - awt::Size aNewLogSize( static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Width * aLogicalSize.Width ) / aCropSize.Width ), - static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Height * aLogicalSize.Height ) / aCropSize.Height ) ); - aLogicalSize = aNewLogSize; - } + awt::Size aNewLogSize( static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Width * aLogicalSize.Width ) / aCropSize.Width ), + static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Height * aLogicalSize.Height ) / aCropSize.Height ) ); + aLogicalSize = aNewLogSize; } } - aUser.maGraphicCropLogic = aGraphicCropLogic; - aUser.maLogicalSize = aLogicalSize; - ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); } + aUser.maGraphicCropLogic = aGraphicCropLogic; + aUser.maLogicalSize = aLogicalSize; + ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); } static void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const Reference< XPropertySet >& rxPropertySet, const awt::Size& rLogicalSize, diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx index 520001fedabd..b8d8d5c3a33e 100644 --- a/sdext/source/minimizer/impoptimizer.cxx +++ b/sdext/source/minimizer/impoptimizer.cxx @@ -574,151 +574,151 @@ static void DispatchURL( const Reference< XComponentContext >& xContext, const O void ImpOptimizer::Optimize( const Sequence< PropertyValue >& rArguments ) { - if ( mxModel.is() ) - { - sal_Int64 nEstimatedFileSize = 0; - SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 0 ) ) ); - DispatchStatus(); + if ( !mxModel.is() ) + return; + + sal_Int64 nEstimatedFileSize = 0; + SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 0 ) ) ); + DispatchStatus(); - int i, nICount; - for ( i = 0, nICount = rArguments.getLength(); i < nICount; i++ ) + int i, nICount; + for ( i = 0, nICount = rArguments.getLength(); i < nICount; i++ ) + { + switch( TKGet( rArguments[ i ].Name ) ) { - switch( TKGet( rArguments[ i ].Name ) ) + case TK_StatusDispatcher : rArguments[ i ].Value >>= mxStatusDispatcher; break; + case TK_InformationDialog: rArguments[ i ].Value >>= mxInformationDialog; break; + case TK_Settings : { - case TK_StatusDispatcher : rArguments[ i ].Value >>= mxStatusDispatcher; break; - case TK_InformationDialog: rArguments[ i ].Value >>= mxInformationDialog; break; - case TK_Settings : + css::uno::Sequence< css::beans::PropertyValue > aSettings; + int j, nJCount; + rArguments[ i ].Value >>= aSettings; + for ( j = 0, nJCount = aSettings.getLength(); j < nJCount; j++ ) { - css::uno::Sequence< css::beans::PropertyValue > aSettings; - int j, nJCount; - rArguments[ i ].Value >>= aSettings; - for ( j = 0, nJCount = aSettings.getLength(); j < nJCount; j++ ) + switch( TKGet( aSettings[ j ].Name ) ) { - switch( TKGet( aSettings[ j ].Name ) ) - { - case TK_JPEGCompression : aSettings[ j ].Value >>= mbJPEGCompression; break; - case TK_JPEGQuality : aSettings[ j ].Value >>= mnJPEGQuality; break; - case TK_RemoveCropArea : aSettings[ j ].Value >>= mbRemoveCropArea; break; - case TK_ImageResolution : aSettings[ j ].Value >>= mnImageResolution; break; - case TK_EmbedLinkedGraphics : aSettings[ j ].Value >>= mbEmbedLinkedGraphics; break; - case TK_OLEOptimization : aSettings[ j ].Value >>= mbOLEOptimization; break; - case TK_OLEOptimizationType : aSettings[ j ].Value >>= mnOLEOptimizationType; break; - case TK_CustomShowName : aSettings[ j ].Value >>= maCustomShowName; break; - case TK_DeleteUnusedMasterPages : aSettings[ j ].Value >>= mbDeleteUnusedMasterPages; break; - case TK_DeleteHiddenSlides : aSettings[ j ].Value >>= mbDeleteHiddenSlides; break; - case TK_DeleteNotesPages : aSettings[ j ].Value >>= mbDeleteNotesPages; break; - case TK_SaveAsURL : aSettings[ j ].Value >>= maSaveAsURL; break; - case TK_FilterName : aSettings[ j ].Value >>= maFilterName; break; - case TK_OpenNewDocument : aSettings[ j ].Value >>= mbOpenNewDocument; break; - case TK_EstimatedFileSize : aSettings[ j ].Value >>= nEstimatedFileSize; break; - default: break; - } + case TK_JPEGCompression : aSettings[ j ].Value >>= mbJPEGCompression; break; + case TK_JPEGQuality : aSettings[ j ].Value >>= mnJPEGQuality; break; + case TK_RemoveCropArea : aSettings[ j ].Value >>= mbRemoveCropArea; break; + case TK_ImageResolution : aSettings[ j ].Value >>= mnImageResolution; break; + case TK_EmbedLinkedGraphics : aSettings[ j ].Value >>= mbEmbedLinkedGraphics; break; + case TK_OLEOptimization : aSettings[ j ].Value >>= mbOLEOptimization; break; + case TK_OLEOptimizationType : aSettings[ j ].Value >>= mnOLEOptimizationType; break; + case TK_CustomShowName : aSettings[ j ].Value >>= maCustomShowName; break; + case TK_DeleteUnusedMasterPages : aSettings[ j ].Value >>= mbDeleteUnusedMasterPages; break; + case TK_DeleteHiddenSlides : aSettings[ j ].Value >>= mbDeleteHiddenSlides; break; + case TK_DeleteNotesPages : aSettings[ j ].Value >>= mbDeleteNotesPages; break; + case TK_SaveAsURL : aSettings[ j ].Value >>= maSaveAsURL; break; + case TK_FilterName : aSettings[ j ].Value >>= maFilterName; break; + case TK_OpenNewDocument : aSettings[ j ].Value >>= mbOpenNewDocument; break; + case TK_EstimatedFileSize : aSettings[ j ].Value >>= nEstimatedFileSize; break; + default: break; } } - break; - default: break; } + break; + default: break; } + } + + sal_Int64 nSourceSize = 0; + sal_Int64 nDestSize = 0; - sal_Int64 nSourceSize = 0; - sal_Int64 nDestSize = 0; + Reference< XFrame > xSelf; + if ( !maSaveAsURL.isEmpty() ) + { + + SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 10 ) ) ); + SetStatusValue( TK_Status, Any( OUString("STR_DUPLICATING_PRESENTATION") ) ); + DispatchStatus(); - Reference< XFrame > xSelf; - if ( !maSaveAsURL.isEmpty() ) + Reference< XStorable >xStorable( mxModel, UNO_QUERY ); + if ( xStorable.is() ) { + if ( xStorable->hasLocation() ) + nSourceSize = PPPOptimizer::GetFileSize( xStorable->getLocation() ); - SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 10 ) ) ); + Sequence< PropertyValue > aArguments; + if ( !maFilterName.isEmpty() ) + { + int nLength = aArguments.getLength(); + aArguments.realloc( nLength + 1 ); + aArguments[ nLength ].Name = "FilterName"; + aArguments[ nLength ].Value <<= maFilterName; + } + xStorable->storeToURL( maSaveAsURL, aArguments ); + if ( !nSourceSize ) + nSourceSize = PPPOptimizer::GetFileSize( maSaveAsURL ); + + SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 30 ) ) ); SetStatusValue( TK_Status, Any( OUString("STR_DUPLICATING_PRESENTATION") ) ); DispatchStatus(); - Reference< XStorable >xStorable( mxModel, UNO_QUERY ); - if ( xStorable.is() ) - { - if ( xStorable->hasLocation() ) - nSourceSize = PPPOptimizer::GetFileSize( xStorable->getLocation() ); + Reference< XDesktop2 > xDesktop = Desktop::create( mxContext ); + xSelf = xDesktop->findFrame( "_blank", FrameSearchFlag::CREATE ); + Reference< XComponentLoader > xComponentLoader( xSelf, UNO_QUERY ); - Sequence< PropertyValue > aArguments; - if ( !maFilterName.isEmpty() ) - { - int nLength = aArguments.getLength(); - aArguments.realloc( nLength + 1 ); - aArguments[ nLength ].Name = "FilterName"; - aArguments[ nLength ].Value <<= maFilterName; - } - xStorable->storeToURL( maSaveAsURL, aArguments ); - if ( !nSourceSize ) - nSourceSize = PPPOptimizer::GetFileSize( maSaveAsURL ); - - SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( 30 ) ) ); - SetStatusValue( TK_Status, Any( OUString("STR_DUPLICATING_PRESENTATION") ) ); - DispatchStatus(); - - Reference< XDesktop2 > xDesktop = Desktop::create( mxContext ); - xSelf = xDesktop->findFrame( "_blank", FrameSearchFlag::CREATE ); - Reference< XComponentLoader > xComponentLoader( xSelf, UNO_QUERY ); - - Sequence< PropertyValue > aLoadProps( 1 ); - aLoadProps[ 0 ].Name = "Hidden"; - aLoadProps[ 0 ].Value <<= true; - mxModel.set( xComponentLoader->loadComponentFromURL( - maSaveAsURL, "_self", 0, aLoadProps ), UNO_QUERY ); - } + Sequence< PropertyValue > aLoadProps( 1 ); + aLoadProps[ 0 ].Name = "Hidden"; + aLoadProps[ 0 ].Value <<= true; + mxModel.set( xComponentLoader->loadComponentFromURL( + maSaveAsURL, "_self", 0, aLoadProps ), UNO_QUERY ); } + } - // check if the document is ReadOnly -> error - Reference< XStorable > xStorable( mxModel, UNO_QUERY ); - if ( xStorable.is() && !xStorable->isReadonly() ) - { - mxModel->lockControllers(); - Optimize(); - mxModel->unlockControllers(); - - // clearing undo stack: - Reference< XFrame > xFrame( xSelf.is() ? xSelf : mxInformationDialog ); - if ( xFrame.is() ) - { - const OUString sSlot( "slot:27115" ); - DispatchURL( mxContext, sSlot, xFrame ); - } - } + // check if the document is ReadOnly -> error + Reference< XStorable > xStorable( mxModel, UNO_QUERY ); + if ( xStorable.is() && !xStorable->isReadonly() ) + { + mxModel->lockControllers(); + Optimize(); + mxModel->unlockControllers(); - if ( !maSaveAsURL.isEmpty() ) + // clearing undo stack: + Reference< XFrame > xFrame( xSelf.is() ? xSelf : mxInformationDialog ); + if ( xFrame.is() ) { - if ( xStorable.is() ) - { - xStorable->store(); - nDestSize = PPPOptimizer::GetFileSize( maSaveAsURL ); - } + const OUString sSlot( "slot:27115" ); + DispatchURL( mxContext, sSlot, xFrame ); } + } - if ( mxInformationDialog.is() ) + if ( !maSaveAsURL.isEmpty() ) + { + if ( xStorable.is() ) { - InformationDialog aInformationDialog( mxContext, mxInformationDialog, maSaveAsURL, mbOpenNewDocument, nSourceSize, nDestSize, nEstimatedFileSize ); - aInformationDialog.execute(); - SetStatusValue( TK_OpenNewDocument, Any( mbOpenNewDocument ) ); - DispatchStatus(); + xStorable->store(); + nDestSize = PPPOptimizer::GetFileSize( maSaveAsURL ); } + } + + if ( mxInformationDialog.is() ) + { + InformationDialog aInformationDialog( mxContext, mxInformationDialog, maSaveAsURL, mbOpenNewDocument, nSourceSize, nDestSize, nEstimatedFileSize ); + aInformationDialog.execute(); + SetStatusValue( TK_OpenNewDocument, Any( mbOpenNewDocument ) ); + DispatchStatus(); + } - if ( !maSaveAsURL.isEmpty() ) + if ( !maSaveAsURL.isEmpty() ) + { + if ( mbOpenNewDocument && xSelf.is() ) { - if ( mbOpenNewDocument && xSelf.is() ) - { - Reference< awt::XWindow > xContainerWindow( xSelf->getContainerWindow() ); - xContainerWindow->setVisible( true ); - } - else - { - Reference< XComponent > xComponent( mxModel, UNO_QUERY ); - xComponent->dispose(); - } + Reference< awt::XWindow > xContainerWindow( xSelf->getContainerWindow() ); + xContainerWindow->setVisible( true ); } - if ( nSourceSize && nDestSize ) + else { - SetStatusValue( TK_FileSizeSource, Any( nSourceSize ) ); - SetStatusValue( TK_FileSizeDestination, Any( nDestSize ) ); - DispatchStatus(); + Reference< XComponent > xComponent( mxModel, UNO_QUERY ); + xComponent->dispose(); } } + if ( nSourceSize && nDestSize ) + { + SetStatusValue( TK_FileSizeSource, Any( nSourceSize ) ); + SetStatusValue( TK_FileSizeDestination, Any( nDestSize ) ); + DispatchStatus(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index a1056b3a2542..3da7dc6c2d93 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -177,21 +177,21 @@ void OptimizerDialog::UpdateConfiguration() } aAny = getControlProperty( "CheckBox3Pg3", "State" ); - if ( (aAny >>= nInt16) && nInt16 ) + if ( !((aAny >>= nInt16) && nInt16) ) + return; + + aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" ); + if ( !(aAny >>= aSelectedItems) ) + return; + + if ( aSelectedItems.getLength() ) { - aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" ); - if ( aAny >>= aSelectedItems ) + sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; + aAny = getControlProperty( "ListBox0Pg3", "StringItemList" ); + if ( aAny >>= aStringItemList ) { - if ( aSelectedItems.getLength() ) - { - sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; - aAny = getControlProperty( "ListBox0Pg3", "StringItemList" ); - if ( aAny >>= aStringItemList ) - { - if ( aStringItemList.getLength() > nSelectedItem ) - SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); - } - } + if ( aStringItemList.getLength() > nSelectedItem ) + SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); } } } @@ -251,27 +251,27 @@ void OptimizerDialog::execute() void OptimizerDialog::SwitchPage( sal_Int16 nNewStep ) { - if ( ( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 ) ) - { - sal_Int16 nOldStep = mnCurrentStep; - if ( nNewStep == 0 ) - disableControl( "btnNavBack" ); - else if ( nOldStep == 0 ) - enableControl( "btnNavBack" ); + if ( !(( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 )) ) + return; - if ( nNewStep == MAX_STEP ) - disableControl( "btnNavNext" ); - else if ( nOldStep == MAX_STEP ) - enableControl( "btnNavNext" ); + sal_Int16 nOldStep = mnCurrentStep; + if ( nNewStep == 0 ) + disableControl( "btnNavBack" ); + else if ( nOldStep == 0 ) + enableControl( "btnNavBack" ); - setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) ); + if ( nNewStep == MAX_STEP ) + disableControl( "btnNavNext" ); + else if ( nOldStep == MAX_STEP ) + enableControl( "btnNavNext" ); - DeactivatePage( nOldStep ); - UpdateControlStates( nNewStep ); + setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) ); - ActivatePage( nNewStep ); - mnCurrentStep = nNewStep; - } + DeactivatePage( nOldStep ); + UpdateControlStates( nNewStep ); + + ActivatePage( nNewStep ); + mnCurrentStep = nNewStep; } void OptimizerDialog::UpdateControlStates( sal_Int16 nPage ) @@ -317,32 +317,32 @@ OUString OptimizerDialog::GetSelectedString( OUString const & token ) void OptimizerDialog::UpdateStatus( const css::uno::Sequence< css::beans::PropertyValue >& rStatus ) { - if ( mxReschedule.is() ) + if ( !mxReschedule.is() ) + return; + + maStats.InitializeStatusValues( rStatus ); + const Any* pVal( maStats.GetStatusValue( TK_Status ) ); + if ( pVal ) { - maStats.InitializeStatusValues( rStatus ); - const Any* pVal( maStats.GetStatusValue( TK_Status ) ); - if ( pVal ) + OUString sStatus; + if ( *pVal >>= sStatus ) { - OUString sStatus; - if ( *pVal >>= sStatus ) - { - setControlProperty( "FixedText1Pg4", "Enabled", Any( true ) ); - setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) ); - } + setControlProperty( "FixedText1Pg4", "Enabled", Any( true ) ); + setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) ); } - pVal = maStats.GetStatusValue( TK_Progress ); - if ( pVal ) - { - sal_Int32 nProgress = 0; - if ( *pVal >>= nProgress ) - setControlProperty( "Progress", "ProgressValue", Any( nProgress ) ); - } - pVal = maStats.GetStatusValue( TK_OpenNewDocument ); - if ( pVal ) - SetConfigProperty( TK_OpenNewDocument, *pVal ); - - mxReschedule->reschedule(); } + pVal = maStats.GetStatusValue( TK_Progress ); + if ( pVal ) + { + sal_Int32 nProgress = 0; + if ( *pVal >>= nProgress ) + setControlProperty( "Progress", "ProgressValue", Any( nProgress ) ); + } + pVal = maStats.GetStatusValue( TK_OpenNewDocument ); + if ( pVal ) + SetConfigProperty( TK_OpenNewDocument, *pVal ); + + mxReschedule->reschedule(); } @@ -716,22 +716,22 @@ void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ ) { OUString aString; Any aAny = mrOptimizerDialog.getControlProperty( "ComboBox0Pg1", "Text" ); - if ( aAny >>= aString ) - { - sal_Int32 nI0, nI1, nI2, nI3, nI4; - nI0 = nI1 = nI2 = nI3 = nI4 = 0; - - if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString ) - aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 ); - else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString ) - aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 ); - else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString ) - aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 ); - else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString ) - aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 ); - - mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) ); - } + if ( !(aAny >>= aString) ) + return; + + sal_Int32 nI0, nI1, nI2, nI3, nI4; + nI0 = nI1 = nI2 = nI3 = nI4 = 0; + + if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 ); + else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 ); + else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 ); + else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString ) + aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 ); + + mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) ); } void TextListenerComboBox0Pg1::disposing( const css::lang::EventObject& /* Source */ ) { diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx index f575e88a5f60..90baad21091b 100644 --- a/sdext/source/minimizer/pppoptimizerdialog.cxx +++ b/sdext/source/minimizer/pppoptimizerdialog.cxx @@ -94,48 +94,48 @@ void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL, const Sequence< PropertyValue >& rArguments ) { - if ( mxController.is() && rURL.Protocol.equalsIgnoreAsciiCase( "vnd.com.sun.star.comp.PresentationMinimizer:" ) ) + if ( !(mxController.is() && rURL.Protocol.equalsIgnoreAsciiCase( "vnd.com.sun.star.comp.PresentationMinimizer:" )) ) + return; + + if ( rURL.Path == "execute" ) { - if ( rURL.Path == "execute" ) + try { - try - { - sal_Int64 nFileSizeSource = 0; - sal_Int64 nFileSizeDest = 0; - mpOptimizerDialog = new OptimizerDialog( mxContext, mxFrame, this ); - mpOptimizerDialog->execute(); - - const Any* pVal( mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeSource ) ); - if ( pVal ) - *pVal >>= nFileSizeSource; - pVal = mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeDestination ); - if ( pVal ) - *pVal >>= nFileSizeDest; - - if ( nFileSizeSource && nFileSizeDest ) - { - OUStringBuffer sBuf( "Your Presentation has been minimized from:" ); - sBuf.append( OUString::number( nFileSizeSource >> 10 ) ); - sBuf.append( "KB to " ); - sBuf.append( OUString::number( nFileSizeDest >> 10 ) ); - sBuf.append( "KB." ); - OUString sResult( sBuf.makeStringAndClear() ); - SAL_INFO("sdext.minimizer", sResult ); - } - delete mpOptimizerDialog; - mpOptimizerDialog = nullptr; - } - catch( ... ) + sal_Int64 nFileSizeSource = 0; + sal_Int64 nFileSizeDest = 0; + mpOptimizerDialog = new OptimizerDialog( mxContext, mxFrame, this ); + mpOptimizerDialog->execute(); + + const Any* pVal( mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeSource ) ); + if ( pVal ) + *pVal >>= nFileSizeSource; + pVal = mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeDestination ); + if ( pVal ) + *pVal >>= nFileSizeDest; + + if ( nFileSizeSource && nFileSizeDest ) { - + OUStringBuffer sBuf( "Your Presentation has been minimized from:" ); + sBuf.append( OUString::number( nFileSizeSource >> 10 ) ); + sBuf.append( "KB to " ); + sBuf.append( OUString::number( nFileSizeDest >> 10 ) ); + sBuf.append( "KB." ); + OUString sResult( sBuf.makeStringAndClear() ); + SAL_INFO("sdext.minimizer", sResult ); } + delete mpOptimizerDialog; + mpOptimizerDialog = nullptr; } - else if ( rURL.Path == "statusupdate" ) + catch( ... ) { - if ( mpOptimizerDialog ) - mpOptimizerDialog->UpdateStatus( rArguments ); + } } + else if ( rURL.Path == "statusupdate" ) + { + if ( mpOptimizerDialog ) + mpOptimizerDialog->UpdateStatus( rArguments ); + } } void SAL_CALL PPPOptimizerDialog::addStatusListener( const Reference< XStatusListener >&, const URL& ) |