graphiccollector.cxx (880c69c6) | graphiccollector.cxx (597a4c59) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 21 unchanged lines hidden (view full) --- 30#include <com/sun/star/drawing/FillStyle.hpp> 31#include <com/sun/star/drawing/BitmapMode.hpp> 32#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 33#include <com/sun/star/presentation/XPresentationPage.hpp> 34#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 35 36#include "impoptimizer.hxx" 37 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 21 unchanged lines hidden (view full) --- 30#include <com/sun/star/drawing/FillStyle.hpp> 31#include <com/sun/star/drawing/BitmapMode.hpp> 32#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> 33#include <com/sun/star/presentation/XPresentationPage.hpp> 34#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> 35 36#include "impoptimizer.hxx" 37 |
38using namespace ::rtl; | |
39using namespace ::com::sun::star; 40using namespace ::com::sun::star::uno; 41using namespace ::com::sun::star::awt; 42using namespace ::com::sun::star::drawing; 43using namespace ::com::sun::star::graphic; 44using namespace ::com::sun::star::frame; 45using namespace ::com::sun::star::beans; 46using namespace ::com::sun::star::presentation; 47 | 38using namespace ::com::sun::star; 39using namespace ::com::sun::star::uno; 40using namespace ::com::sun::star::awt; 41using namespace ::com::sun::star::drawing; 42using namespace ::com::sun::star::graphic; 43using namespace ::com::sun::star::frame; 44using namespace ::com::sun::star::beans; 45using namespace ::com::sun::star::presentation; 46 |
47using ::rtl::OUString; 48 |
|
48const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentContext >& rxFact ) 49{ 50 static DeviceInfo aDeviceInfo; 51 if( !aDeviceInfo.Width ) 52 { 53 try 54 { 55 Reference< XFramesSupplier > xDesktop( rxFact->getServiceManager()->createInstanceWithContext( --- 34 unchanged lines hidden (view full) --- 90 if ( aIter == rGraphicEntities.end() ) 91 { 92 GraphicCollector::GraphicEntity aEntity( rUser ); 93 rGraphicEntities.push_back( aEntity ); 94 } 95 } 96} 97 | 49const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentContext >& rxFact ) 50{ 51 static DeviceInfo aDeviceInfo; 52 if( !aDeviceInfo.Width ) 53 { 54 try 55 { 56 Reference< XFramesSupplier > xDesktop( rxFact->getServiceManager()->createInstanceWithContext( --- 34 unchanged lines hidden (view full) --- 91 if ( aIter == rGraphicEntities.end() ) 92 { 93 GraphicCollector::GraphicEntity aEntity( rUser ); 94 rGraphicEntities.push_back( aEntity ); 95 } 96 } 97} 98 |
98void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Reference< XShape >& rxShape, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities ) | 99void ImpAddGraphicEntity( const Reference< XComponentContext >& rxContext, Reference< XShape >& rxShape, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities ) |
99{ 100 Reference< XGraphic > xGraphic; 101 Reference< XPropertySet > xShapePropertySet( rxShape, UNO_QUERY_THROW ); 102 if ( xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic ) 103 { 104 text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 ); 105 106 GraphicCollector::GraphicUser aUser; 107 aUser.mxShape = rxShape; 108 aUser.mbFillBitmap = sal_False; 109 xShapePropertySet->getPropertyValue( TKGet( TK_GraphicURL ) ) >>= aUser.maGraphicURL; 110 xShapePropertySet->getPropertyValue( TKGet( TK_GraphicStreamURL ) ) >>= aUser.maGraphicStreamURL; 111 xShapePropertySet->getPropertyValue( TKGet( TK_GraphicCrop ) ) >>= aGraphicCropLogic; 112 awt::Size aLogicalSize( rxShape->getSize() ); 113 114 // calculating the logical size, as if there were no cropping 115 if ( aGraphicCropLogic.Left || aGraphicCropLogic.Right || aGraphicCropLogic.Top || aGraphicCropLogic.Bottom ) 116 { | 100{ 101 Reference< XGraphic > xGraphic; 102 Reference< XPropertySet > xShapePropertySet( rxShape, UNO_QUERY_THROW ); 103 if ( xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic ) 104 { 105 text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 ); 106 107 GraphicCollector::GraphicUser aUser; 108 aUser.mxShape = rxShape; 109 aUser.mbFillBitmap = sal_False; 110 xShapePropertySet->getPropertyValue( TKGet( TK_GraphicURL ) ) >>= aUser.maGraphicURL; 111 xShapePropertySet->getPropertyValue( TKGet( TK_GraphicStreamURL ) ) >>= aUser.maGraphicStreamURL; 112 xShapePropertySet->getPropertyValue( TKGet( TK_GraphicCrop ) ) >>= aGraphicCropLogic; 113 awt::Size aLogicalSize( rxShape->getSize() ); 114 115 // calculating the logical size, as if there were no cropping 116 if ( aGraphicCropLogic.Left || aGraphicCropLogic.Right || aGraphicCropLogic.Top || aGraphicCropLogic.Bottom ) 117 { |
117 awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); | 118 awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxContext, xGraphic ) ); |
118 if ( aSize100thMM.Width && aSize100thMM.Height ) 119 { 120 awt::Size aCropSize( aSize100thMM.Width - ( aGraphicCropLogic.Left + aGraphicCropLogic.Right ), 121 aSize100thMM.Height - ( aGraphicCropLogic.Top + aGraphicCropLogic.Bottom )); 122 if ( aCropSize.Width && aCropSize.Height ) 123 { 124 awt::Size aNewLogSize( static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Width * aLogicalSize.Width ) / aCropSize.Width ), 125 static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Height * aLogicalSize.Height ) / aCropSize.Height ) ); 126 aLogicalSize = aNewLogSize; 127 } 128 } 129 } 130 aUser.maGraphicCropLogic = aGraphicCropLogic; 131 aUser.maLogicalSize = aLogicalSize; 132 ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); 133 } 134} 135 | 119 if ( aSize100thMM.Width && aSize100thMM.Height ) 120 { 121 awt::Size aCropSize( aSize100thMM.Width - ( aGraphicCropLogic.Left + aGraphicCropLogic.Right ), 122 aSize100thMM.Height - ( aGraphicCropLogic.Top + aGraphicCropLogic.Bottom )); 123 if ( aCropSize.Width && aCropSize.Height ) 124 { 125 awt::Size aNewLogSize( static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Width * aLogicalSize.Width ) / aCropSize.Width ), 126 static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Height * aLogicalSize.Height ) / aCropSize.Height ) ); 127 aLogicalSize = aNewLogSize; 128 } 129 } 130 } 131 aUser.maGraphicCropLogic = aGraphicCropLogic; 132 aUser.maLogicalSize = aLogicalSize; 133 ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser ); 134 } 135} 136 |
136void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const Reference< XPropertySet >& rxPropertySet, const awt::Size& rLogicalSize, | 137void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxContext, const Reference< XPropertySet >& rxPropertySet, const awt::Size& rLogicalSize, |
137 std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const Reference< XPropertySet >& rxPagePropertySet ) 138{ 139 try 140 { 141 FillStyle eFillStyle; 142 if ( rxPropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle ) 143 { 144 if ( eFillStyle == FillStyle_BITMAP ) --- 21 unchanged lines hidden (view full) --- 166 if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize ) 167 && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width ) 168 && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) ) 169 { 170 if ( bLogicalSize ) 171 { 172 if ( !aSize.Width || !aSize.Height ) 173 { | 138 std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const Reference< XPropertySet >& rxPagePropertySet ) 139{ 140 try 141 { 142 FillStyle eFillStyle; 143 if ( rxPropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle ) 144 { 145 if ( eFillStyle == FillStyle_BITMAP ) --- 21 unchanged lines hidden (view full) --- 167 if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize ) 168 && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width ) 169 && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) ) 170 { 171 if ( bLogicalSize ) 172 { 173 if ( !aSize.Width || !aSize.Height ) 174 { |
174 awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) ); | 175 awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxContext, xGraphic ) ); |
175 if ( aSize100thMM.Width && aSize100thMM.Height ) 176 aLogicalSize = aSize100thMM; 177 } 178 else 179 aLogicalSize = aSize; 180 } 181 else 182 { --- 17 unchanged lines hidden (view full) --- 200 } 201 } 202 } 203 catch( Exception& ) 204 { 205 } 206} 207 | 176 if ( aSize100thMM.Width && aSize100thMM.Height ) 177 aLogicalSize = aSize100thMM; 178 } 179 else 180 aLogicalSize = aSize; 181 } 182 else 183 { --- 17 unchanged lines hidden (view full) --- 201 } 202 } 203 } 204 catch( Exception& ) 205 { 206 } 207} 208 |
208void ImpCollectBackgroundGraphic( const Reference< XComponentContext >& rxMSF, const Reference< XDrawPage >& rxDrawPage, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities ) | 209void ImpCollectBackgroundGraphic( const Reference< XComponentContext >& rxContext, const Reference< XDrawPage >& rxDrawPage, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities ) |
209{ 210 try 211 { 212 awt::Size aLogicalSize( 28000, 21000 ); 213 Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW ); 214 xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width; 215 xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height; 216 217 Reference< XPropertySet > xBackgroundPropSet; 218 if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet ) | 210{ 211 try 212 { 213 awt::Size aLogicalSize( 28000, 21000 ); 214 Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW ); 215 xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width; 216 xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height; 217 218 Reference< XPropertySet > xBackgroundPropSet; 219 if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet ) |
219 ImpAddFillBitmapEntity( rxMSF, xBackgroundPropSet, aLogicalSize, rGraphicEntities, rGraphicSettings, xPropertySet ); | 220 ImpAddFillBitmapEntity( rxContext, xBackgroundPropSet, aLogicalSize, rGraphicEntities, rGraphicSettings, xPropertySet ); |
220 } 221 catch( Exception& ) 222 { 223 } 224} 225 | 221 } 222 catch( Exception& ) 223 { 224 } 225} 226 |
226void ImpCollectGraphicObjects( const Reference< XComponentContext >& rxMSF, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities ) | 227void ImpCollectGraphicObjects( const Reference< XComponentContext >& rxContext, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities ) |
227{ 228 for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ ) 229 { 230 try 231 { 232 const OUString sGraphicObjectShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ); 233 const OUString sGroupShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) ); 234 Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW ); 235 const OUString sShapeType( xShape->getShapeType() ); 236 if ( sShapeType == sGroupShape ) 237 { 238 Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW ); | 228{ 229 for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ ) 230 { 231 try 232 { 233 const OUString sGraphicObjectShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ); 234 const OUString sGroupShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) ); 235 Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW ); 236 const OUString sShapeType( xShape->getShapeType() ); 237 if ( sShapeType == sGroupShape ) 238 { 239 Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW ); |
239 ImpCollectGraphicObjects( rxMSF, xShapes, rGraphicSettings, rGraphicEntities ); | 240 ImpCollectGraphicObjects( rxContext, xShapes, rGraphicSettings, rGraphicEntities ); |
240 continue; 241 } 242 243 if ( sShapeType == sGraphicObjectShape ) | 241 continue; 242 } 243 244 if ( sShapeType == sGraphicObjectShape ) |
244 ImpAddGraphicEntity( rxMSF, xShape, rGraphicSettings, rGraphicEntities ); | 245 ImpAddGraphicEntity( rxContext, xShape, rGraphicSettings, rGraphicEntities ); |
245 246 // now check for a fillstyle 247 Reference< XPropertySet > xEmptyPagePropSet; 248 Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW ); 249 awt::Size aLogicalSize( xShape->getSize() ); | 246 247 // now check for a fillstyle 248 Reference< XPropertySet > xEmptyPagePropSet; 249 Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW ); 250 awt::Size aLogicalSize( xShape->getSize() ); |
250 ImpAddFillBitmapEntity( rxMSF, xShapePropertySet, aLogicalSize, rGraphicEntities, rGraphicSettings, xEmptyPagePropSet ); | 251 ImpAddFillBitmapEntity( rxContext, xShapePropertySet, aLogicalSize, rGraphicEntities, rGraphicSettings, xEmptyPagePropSet ); |
251 } 252 catch( Exception& ) 253 { 254 } 255 } 256} 257 | 252 } 253 catch( Exception& ) 254 { 255 } 256 } 257} 258 |
258awt::Size GraphicCollector::GetOriginalSize( const Reference< XComponentContext >& rxMSF, const Reference< XGraphic >& rxGraphic ) | 259awt::Size GraphicCollector::GetOriginalSize( const Reference< XComponentContext >& rxContext, const Reference< XGraphic >& rxGraphic ) |
259{ 260 awt::Size aSize100thMM( 0, 0 ); 261 Reference< XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW ); 262 if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Size100thMM ) ) >>= aSize100thMM ) 263 { 264 if ( !aSize100thMM.Width && !aSize100thMM.Height ) 265 { // MAPMODE_PIXEL USED :-( 266 awt::Size aSourceSizePixel( 0, 0 ); 267 if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_SizePixel ) ) >>= aSourceSizePixel ) 268 { | 260{ 261 awt::Size aSize100thMM( 0, 0 ); 262 Reference< XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW ); 263 if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Size100thMM ) ) >>= aSize100thMM ) 264 { 265 if ( !aSize100thMM.Width && !aSize100thMM.Height ) 266 { // MAPMODE_PIXEL USED :-( 267 awt::Size aSourceSizePixel( 0, 0 ); 268 if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_SizePixel ) ) >>= aSourceSizePixel ) 269 { |
269 const DeviceInfo& rDeviceInfo( GraphicCollector::GetDeviceInfo( rxMSF ) ); | 270 const DeviceInfo& rDeviceInfo( GraphicCollector::GetDeviceInfo( rxContext ) ); |
270 if ( rDeviceInfo.PixelPerMeterX && rDeviceInfo.PixelPerMeterY ) 271 { 272 aSize100thMM.Width = static_cast< sal_Int32 >( ( aSourceSizePixel.Width * 100000.0 ) / rDeviceInfo.PixelPerMeterX ); 273 aSize100thMM.Height = static_cast< sal_Int32 >( ( aSourceSizePixel.Height * 100000.0 ) / rDeviceInfo.PixelPerMeterY ); 274 } 275 } 276 } 277 } 278 return aSize100thMM; 279} 280 | 271 if ( rDeviceInfo.PixelPerMeterX && rDeviceInfo.PixelPerMeterY ) 272 { 273 aSize100thMM.Width = static_cast< sal_Int32 >( ( aSourceSizePixel.Width * 100000.0 ) / rDeviceInfo.PixelPerMeterX ); 274 aSize100thMM.Height = static_cast< sal_Int32 >( ( aSourceSizePixel.Height * 100000.0 ) / rDeviceInfo.PixelPerMeterY ); 275 } 276 } 277 } 278 } 279 return aSize100thMM; 280} 281 |
281void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel, | 282void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rxContext, const Reference< XModel >& rxModel, |
282 const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicList ) 283{ 284 try 285 { 286 sal_Int32 i; 287 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); 288 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 289 for ( i = 0; i < xDrawPages->getCount(); i++ ) 290 { 291 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); | 283 const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicList ) 284{ 285 try 286 { 287 sal_Int32 i; 288 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); 289 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 290 for ( i = 0; i < xDrawPages->getCount(); i++ ) 291 { 292 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); |
292 ImpCollectBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rGraphicList ); | 293 ImpCollectBackgroundGraphic( rxContext, xDrawPage, rGraphicSettings, rGraphicList ); |
293 Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW ); | 294 Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW ); |
294 ImpCollectGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rGraphicList ); | 295 ImpCollectGraphicObjects( rxContext, xDrawShapes, rGraphicSettings, rGraphicList ); |
295 296 Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW ); 297 Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() ); | 296 297 Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW ); 298 Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() ); |
298 ImpCollectBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rGraphicList ); | 299 ImpCollectBackgroundGraphic( rxContext, xNotesPage, rGraphicSettings, rGraphicList ); |
299 Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW ); | 300 Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW ); |
300 ImpCollectGraphicObjects( rxMSF, xNotesShapes, rGraphicSettings, rGraphicList ); | 301 ImpCollectGraphicObjects( rxContext, xNotesShapes, rGraphicSettings, rGraphicList ); |
301 } 302 Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW ); 303 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); 304 for ( i = 0; i < xMasterPages->getCount(); i++ ) 305 { 306 Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW ); | 302 } 303 Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW ); 304 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); 305 for ( i = 0; i < xMasterPages->getCount(); i++ ) 306 { 307 Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW ); |
307 ImpCollectBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rGraphicList ); | 308 ImpCollectBackgroundGraphic( rxContext, xMasterPage, rGraphicSettings, rGraphicList ); |
308 Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW ); | 309 Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW ); |
309 ImpCollectGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rGraphicList ); | 310 ImpCollectGraphicObjects( rxContext, xMasterPageShapes, rGraphicSettings, rGraphicList ); |
310 } 311 312 std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() ); 313 std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() ); 314 while( aGraphicIter != aGraphicIEnd ) 315 { 316 // check if it is possible to remove the crop area 317 aGraphicIter->mbRemoveCropArea = rGraphicSettings.mbRemoveCropArea; --- 25 unchanged lines hidden (view full) --- 343 aGraphicIter++; 344 } 345 } 346 catch ( Exception& ) 347 { 348 } 349} 350 | 311 } 312 313 std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() ); 314 std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() ); 315 while( aGraphicIter != aGraphicIEnd ) 316 { 317 // check if it is possible to remove the crop area 318 aGraphicIter->mbRemoveCropArea = rGraphicSettings.mbRemoveCropArea; --- 25 unchanged lines hidden (view full) --- 344 aGraphicIter++; 345 } 346 } 347 catch ( Exception& ) 348 { 349 } 350} 351 |
351void ImpCountGraphicObjects( const Reference< XComponentContext >& rxMSF, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics ) | 352void ImpCountGraphicObjects( const Reference< XComponentContext >& rxContext, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics ) |
352{ 353 for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ ) 354 { 355 try 356 { 357 const OUString sGraphicObjectShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ); 358 const OUString sGroupShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) ); 359 Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW ); 360 const OUString sShapeType( xShape->getShapeType() ); 361 if ( sShapeType == sGroupShape ) 362 { 363 Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW ); | 353{ 354 for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ ) 355 { 356 try 357 { 358 const OUString sGraphicObjectShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ); 359 const OUString sGroupShape( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GroupShape" ) ); 360 Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW ); 361 const OUString sShapeType( xShape->getShapeType() ); 362 if ( sShapeType == sGroupShape ) 363 { 364 Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW ); |
364 ImpCountGraphicObjects( rxMSF, xShapes, rGraphicSettings, rnGraphics ); | 365 ImpCountGraphicObjects( rxContext, xShapes, rGraphicSettings, rnGraphics ); |
365 continue; 366 } 367 368 if ( sShapeType == sGraphicObjectShape ) 369 { 370 rnGraphics++; 371 } 372 --- 12 unchanged lines hidden (view full) --- 385 } 386 } 387 catch( Exception& ) 388 { 389 } 390 } 391} 392 | 366 continue; 367 } 368 369 if ( sShapeType == sGraphicObjectShape ) 370 { 371 rnGraphics++; 372 } 373 --- 12 unchanged lines hidden (view full) --- 386 } 387 } 388 catch( Exception& ) 389 { 390 } 391 } 392} 393 |
393void ImpCountBackgroundGraphic( const Reference< XComponentContext >& /* rxMSF */, const Reference< XDrawPage >& rxDrawPage, | 394void ImpCountBackgroundGraphic( const Reference< XComponentContext >& /* rxContext */, const Reference< XDrawPage >& rxDrawPage, |
394 const GraphicSettings& /* rGraphicSettings */, sal_Int32& rnGraphics ) 395{ 396 try 397 { 398 awt::Size aLogicalSize( 28000, 21000 ); 399 Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW ); 400 xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width; 401 xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height; --- 11 unchanged lines hidden (view full) --- 413 } 414 } 415 } 416 catch( Exception& ) 417 { 418 } 419} 420 | 395 const GraphicSettings& /* rGraphicSettings */, sal_Int32& rnGraphics ) 396{ 397 try 398 { 399 awt::Size aLogicalSize( 28000, 21000 ); 400 Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW ); 401 xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width; 402 xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height; --- 11 unchanged lines hidden (view full) --- 414 } 415 } 416 } 417 catch( Exception& ) 418 { 419 } 420} 421 |
421void GraphicCollector::CountGraphics( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel, | 422void GraphicCollector::CountGraphics( const Reference< XComponentContext >& rxContext, const Reference< XModel >& rxModel, |
422 const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics ) 423{ 424 try 425 { 426 sal_Int32 i; 427 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); 428 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 429 for ( i = 0; i < xDrawPages->getCount(); i++ ) 430 { 431 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); | 423 const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics ) 424{ 425 try 426 { 427 sal_Int32 i; 428 Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW ); 429 Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW ); 430 for ( i = 0; i < xDrawPages->getCount(); i++ ) 431 { 432 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW ); |
432 ImpCountBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rnGraphics ); | 433 ImpCountBackgroundGraphic( rxContext, xDrawPage, rGraphicSettings, rnGraphics ); |
433 Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW ); | 434 Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW ); |
434 ImpCountGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rnGraphics ); | 435 ImpCountGraphicObjects( rxContext, xDrawShapes, rGraphicSettings, rnGraphics ); |
435 436 Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW ); 437 Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() ); | 436 437 Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW ); 438 Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() ); |
438 ImpCountBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rnGraphics ); | 439 ImpCountBackgroundGraphic( rxContext, xNotesPage, rGraphicSettings, rnGraphics ); |
439 Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW ); | 440 Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW ); |
440 ImpCountGraphicObjects( rxMSF, xNotesShapes, rGraphicSettings, rnGraphics ); | 441 ImpCountGraphicObjects( rxContext, xNotesShapes, rGraphicSettings, rnGraphics ); |
441 } 442 Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW ); 443 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); 444 for ( i = 0; i < xMasterPages->getCount(); i++ ) 445 { 446 Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW ); | 442 } 443 Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW ); 444 Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW ); 445 for ( i = 0; i < xMasterPages->getCount(); i++ ) 446 { 447 Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW ); |
447 ImpCountBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rnGraphics ); | 448 ImpCountBackgroundGraphic( rxContext, xMasterPage, rGraphicSettings, rnGraphics ); |
448 Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW ); | 449 Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW ); |
449 ImpCountGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rnGraphics ); | 450 ImpCountGraphicObjects( rxContext, xMasterPageShapes, rGraphicSettings, rnGraphics ); |
450 } 451 } 452 catch ( Exception& ) 453 { 454 } 455} 456 | 451 } 452 } 453 catch ( Exception& ) 454 { 455 } 456} 457 |