diff options
-rw-r--r-- | sdext/source/minimizer/graphiccollector.cxx | 8 | ||||
-rw-r--r-- | sdext/source/minimizer/graphiccollector.hxx | 5 | ||||
-rw-r--r-- | sdext/source/minimizer/impoptimizer.cxx | 118 |
3 files changed, 74 insertions, 57 deletions
diff --git a/sdext/source/minimizer/graphiccollector.cxx b/sdext/source/minimizer/graphiccollector.cxx index 8eba9c3..78dc037 100644 --- a/sdext/source/minimizer/graphiccollector.cxx +++ b/sdext/source/minimizer/graphiccollector.cxx @@ -70,7 +70,7 @@ const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentCo return aDeviceInfo; } -void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, Reference< XGraphic >& rxGraphic, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser ) +void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser ) { const rtl::OUString aGraphicURL( rUser.maGraphicURL ); const rtl::OUString sPackageURL( OUString::createFromAscii( "vnd.sun.star.GraphicObject:" ) ); @@ -93,7 +93,7 @@ void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntit } if ( aIter == rGraphicEntities.end() ) { - GraphicCollector::GraphicEntity aEntity( rxGraphic, rUser ); + GraphicCollector::GraphicEntity aEntity( rUser ); rGraphicEntities.push_back( aEntity ); } } @@ -133,7 +133,7 @@ void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Reference } aUser.maGraphicCropLogic = aGraphicCropLogic; aUser.maLogicalSize = aLogicalSize; - ImpAddEntity( rGraphicEntities, xGraphic, rGraphicSettings, aUser ); + ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); } } @@ -198,7 +198,7 @@ void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const aUser.mbFillBitmap = sal_True; aUser.maLogicalSize = aLogicalSize; aUser.mxPagePropertySet = rxPagePropertySet; - ImpAddEntity( rGraphicEntities, xGraphic, rGraphicSettings, aUser ); + ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); } } } diff --git a/sdext/source/minimizer/graphiccollector.hxx b/sdext/source/minimizer/graphiccollector.hxx index 0f63c33..3688939 100644 --- a/sdext/source/minimizer/graphiccollector.hxx +++ b/sdext/source/minimizer/graphiccollector.hxx @@ -76,14 +76,13 @@ class GraphicCollector struct GraphicEntity { - com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > mxGraphic; // the corresponding XGraphic of the Shape com::sun::star::awt::Size maLogicalSize; // the biggest logical size the graphic will be displayed sal_Bool mbRemoveCropArea; // com::sun::star::text::GraphicCrop maGraphicCropLogic; std::vector< GraphicUser > maUser; - GraphicEntity( const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic >& xGraphic, const GraphicUser& rUser ) - : mxGraphic( xGraphic ), maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); }; + GraphicEntity( const GraphicUser& rUser ) + : maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); }; }; static const com::sun::star::awt::DeviceInfo& GetDeviceInfo( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxFact ); diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx index 5161955..8a3e600 100644 --- a/sdext/source/minimizer/impoptimizer.cxx +++ b/sdext/source/minimizer/impoptimizer.cxx @@ -409,68 +409,86 @@ 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() ) { - if ( aGraphicUserIter->mxShape.is() ) + Reference< XPropertySet > xShapePropertySet( aGraphicIter->maUser[ 0 ].mxShape, UNO_QUERY_THROW ); + xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic; + } + if ( xGraphic.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++; } } |