diff options
Diffstat (limited to 'sdext/source/minimizer/impoptimizer.cxx')
-rw-r--r-- | sdext/source/minimizer/impoptimizer.cxx | 116 |
1 files changed, 67 insertions, 49 deletions
diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx index 2ee2b89ce9b2..2c1f826140bc 100644 --- a/sdext/source/minimizer/impoptimizer.cxx +++ b/sdext/source/minimizer/impoptimizer.cxx @@ -406,66 +406,84 @@ void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XComponentCont rOptimizer.SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( nProgress ) ) ); rOptimizer.DispatchStatus(); - GraphicSettings aGraphicSettings( rGraphicSettings ); - aGraphicSettings.mbRemoveCropArea = aGraphicIter->mbRemoveCropArea; - - Reference< XPropertySet > xNewGraphicPropertySet( aGraphicIter->mxGraphic, UNO_QUERY_THROW ); - awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, aGraphicIter->mxGraphic ) ); - Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxMSF, aGraphicIter->mxGraphic, aGraphicIter->maLogicalSize, aGraphicIter->maGraphicCropLogic, aGraphicSettings ) ); - if ( xNewGraphic.is() ) + if ( aGraphicIter->maUser.size() ) { - // applying graphic to each user - std::vector< GraphicCollector::GraphicUser >::iterator aGraphicUserIter( aGraphicIter->maUser.begin() ); - while( aGraphicUserIter != aGraphicIter->maUser.end() ) + GraphicSettings aGraphicSettings( rGraphicSettings ); + aGraphicSettings.mbRemoveCropArea = aGraphicIter->mbRemoveCropArea; + + Reference< XGraphic > xGraphic; + if ( aGraphicIter->maUser[ 0 ].mbFillBitmap && aGraphicIter->maUser[ 0 ].mxPropertySet.is() ) + { + Reference< XBitmap > xFillBitmap; + if ( aGraphicIter->maUser[ 0 ].mxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap ) + xGraphic = Reference< XGraphic >( xFillBitmap, UNO_QUERY_THROW ); + } + else if ( aGraphicIter->maUser[ 0 ].mxShape.is() ) + { + Reference< XPropertySet > xShapePropertySet( aGraphicIter->maUser[ 0 ].mxShape, UNO_QUERY_THROW ); + xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic; + } + if ( xGraphic.is() ) { - if ( aGraphicUserIter->mxShape.is() ) + Reference< XPropertySet > xNewGraphicPropertySet( xGraphic, UNO_QUERY_THROW ); + awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); + Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxMSF, xGraphic, aGraphicIter->maLogicalSize, aGraphicIter->maGraphicCropLogic, aGraphicSettings ) ); + if ( xNewGraphic.is() ) { - rtl::OUString sEmptyGraphicURL; - Reference< XPropertySet > xShapePropertySet( aGraphicUserIter->mxShape, UNO_QUERY_THROW ); - xShapePropertySet->setPropertyValue( TKGet( TK_GraphicURL ), Any( sEmptyGraphicURL ) ); - xShapePropertySet->setPropertyValue( TKGet( TK_Graphic ), Any( xNewGraphic ) ); - - if ( aGraphicUserIter->maGraphicCropLogic.Left || aGraphicUserIter->maGraphicCropLogic.Top - || aGraphicUserIter->maGraphicCropLogic.Right || aGraphicUserIter->maGraphicCropLogic.Bottom ) - { // removing crop area was not possible or should't been applied - text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 ); - if ( !aGraphicSettings.mbRemoveCropArea ) + // applying graphic to each user + std::vector< GraphicCollector::GraphicUser >::iterator aGraphicUserIter( aGraphicIter->maUser.begin() ); + while( aGraphicUserIter != aGraphicIter->maUser.end() ) + { + if ( aGraphicUserIter->mxShape.is() ) { - awt::Size aNewSize( GraphicCollector::GetOriginalSize( rxMSF, xNewGraphic ) ); - aGraphicCropLogic.Left = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Left * ((double)aNewSize.Width / (double)aSize100thMM.Width)); - aGraphicCropLogic.Top = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Top * ((double)aNewSize.Height / (double)aSize100thMM.Height)); - aGraphicCropLogic.Right = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Right * ((double)aNewSize.Width / (double)aSize100thMM.Width)); - aGraphicCropLogic.Bottom = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Bottom * ((double)aNewSize.Height / (double)aSize100thMM.Height)); + rtl::OUString sEmptyGraphicURL; + Reference< XPropertySet > xShapePropertySet( aGraphicUserIter->mxShape, UNO_QUERY_THROW ); + xShapePropertySet->setPropertyValue( TKGet( TK_GraphicURL ), Any( sEmptyGraphicURL ) ); + xShapePropertySet->setPropertyValue( TKGet( TK_Graphic ), Any( xNewGraphic ) ); + + if ( aGraphicUserIter->maGraphicCropLogic.Left || aGraphicUserIter->maGraphicCropLogic.Top + || aGraphicUserIter->maGraphicCropLogic.Right || aGraphicUserIter->maGraphicCropLogic.Bottom ) + { // removing crop area was not possible or should't been applied + text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 ); + if ( !aGraphicSettings.mbRemoveCropArea ) + { + awt::Size aNewSize( GraphicCollector::GetOriginalSize( rxMSF, xNewGraphic ) ); + aGraphicCropLogic.Left = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Left * ((double)aNewSize.Width / (double)aSize100thMM.Width)); + aGraphicCropLogic.Top = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Top * ((double)aNewSize.Height / (double)aSize100thMM.Height)); + aGraphicCropLogic.Right = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Right * ((double)aNewSize.Width / (double)aSize100thMM.Width)); + aGraphicCropLogic.Bottom = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Bottom * ((double)aNewSize.Height / (double)aSize100thMM.Height)); + } + xShapePropertySet->setPropertyValue( TKGet( TK_GraphicCrop ), Any( aGraphicCropLogic ) ); + } } - xShapePropertySet->setPropertyValue( TKGet( TK_GraphicCrop ), Any( aGraphicCropLogic ) ); - } - } - else if ( aGraphicUserIter->mxPropertySet.is() ) - { - Reference< XBitmap > xFillBitmap( xNewGraphic, UNO_QUERY ); - if ( xFillBitmap.is() ) - { - awt::Size aSize; - sal_Bool bLogicalSize; - - Reference< XPropertySet >& rxPropertySet( aGraphicUserIter->mxPropertySet ); - rxPropertySet->setPropertyValue( TKGet( TK_FillBitmap ), Any( xFillBitmap ) ); - if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize ) - && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width ) - && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) ) + else if ( aGraphicUserIter->mxPropertySet.is() ) { - if ( !aSize.Width || !aSize.Height ) + Reference< XBitmap > xFillBitmap( xNewGraphic, UNO_QUERY ); + if ( xFillBitmap.is() ) { - rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapLogicalSize ), Any( sal_True ) ); - rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeX ), Any( aGraphicUserIter->maLogicalSize.Width ) ); - rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeY ), Any( aGraphicUserIter->maLogicalSize.Height ) ); + awt::Size aSize; + sal_Bool bLogicalSize; + + Reference< XPropertySet >& rxPropertySet( aGraphicUserIter->mxPropertySet ); + rxPropertySet->setPropertyValue( TKGet( TK_FillBitmap ), Any( xFillBitmap ) ); + if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize ) + && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width ) + && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) ) + { + if ( !aSize.Width || !aSize.Height ) + { + rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapLogicalSize ), Any( sal_True ) ); + rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeX ), Any( aGraphicUserIter->maLogicalSize.Width ) ); + rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeY ), Any( aGraphicUserIter->maLogicalSize.Height ) ); + } + } + if ( aGraphicUserIter->mxPagePropertySet.is() ) + aGraphicUserIter->mxPagePropertySet->setPropertyValue( TKGet( TK_Background ), Any( rxPropertySet ) ); } } - if ( aGraphicUserIter->mxPagePropertySet.is() ) - aGraphicUserIter->mxPagePropertySet->setPropertyValue( TKGet( TK_Background ), Any( rxPropertySet ) ); + ++aGraphicUserIter; } } - ++aGraphicUserIter; } } ++aGraphicIter; |