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
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sdext.hxx"
26 
27 #include "graphiccollector.hxx"
28 #include <com/sun/star/awt/XDevice.hpp>
29 #include <com/sun/star/frame/XFramesSupplier.hpp>
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 
38 using namespace ::rtl;
39 using namespace ::com::sun::star;
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::awt;
42 using namespace ::com::sun::star::drawing;
43 using namespace ::com::sun::star::graphic;
44 using namespace ::com::sun::star::frame;
45 using namespace ::com::sun::star::beans;
46 using namespace ::com::sun::star::presentation;
47 
48 const 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(
56 					OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), rxFact ), UNO_QUERY_THROW );
57 			Reference< XFrame > xFrame( xDesktop->getActiveFrame() );
58 			Reference< XWindow > xWindow( xFrame->getContainerWindow() );
59 			Reference< XDevice > xDevice( xWindow, UNO_QUERY_THROW );
60 			aDeviceInfo = xDevice->getInfo();
61 		}
62 		catch( Exception& )
63 		{
64 		}
65 	}
66 	return aDeviceInfo;
67 }
68 
69 void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser )
70 {
71 	const rtl::OUString aGraphicURL( rUser.maGraphicURL );
72 	const rtl::OUString sPackageURL( OUString::createFromAscii( "vnd.sun.star.GraphicObject:" ) );
73 
74 	if ( rGraphicSettings.mbEmbedLinkedGraphics || ( !aGraphicURL.getLength() || aGraphicURL.match( sPackageURL, 0 ) ) )
75 	{
76 		std::vector< GraphicCollector::GraphicEntity >::iterator aIter( rGraphicEntities.begin() );
77 		while( aIter != rGraphicEntities.end() )
78 		{
79 			if ( aIter->maUser[ 0 ].maGraphicURL == aGraphicURL )
80 			{
81 				if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width )
82 					aIter->maLogicalSize.Width = rUser.maLogicalSize.Width;
83 				if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height )
84 					aIter->maLogicalSize.Height = rUser.maLogicalSize.Height;
85 				aIter->maUser.push_back( rUser );
86 				break;
87 			}
88 			aIter++;
89 		}
90 		if ( aIter == rGraphicEntities.end() )
91 		{
92 			GraphicCollector::GraphicEntity aEntity( rUser );
93 			rGraphicEntities.push_back( aEntity );
94 		}
95 	}
96 }
97 
98 void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, 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 		{
117 			awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, 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 
136 void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, 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 )
145 			{
146 				rtl::OUString aFillBitmapURL;
147 				Reference< XBitmap > xFillBitmap;
148 				if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap )
149 				{
150 					Reference< XGraphic > xGraphic( xFillBitmap, UNO_QUERY_THROW );
151 					if ( xGraphic.is() )
152 					{
153 						awt::Size aLogicalSize( rLogicalSize );
154 						Reference< XPropertySetInfo > axPropSetInfo( rxPropertySet->getPropertySetInfo() );
155 						if ( axPropSetInfo.is() )
156 						{
157 							if ( axPropSetInfo->hasPropertyByName( TKGet( TK_FillBitmapMode ) ) )
158 							{
159 								BitmapMode eBitmapMode;
160 								if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapMode ) ) >>= eBitmapMode )
161 								{
162 									if ( ( eBitmapMode == BitmapMode_REPEAT ) || ( eBitmapMode == BitmapMode_NO_REPEAT ) )
163 									{
164 										sal_Bool bLogicalSize = sal_False;
165 										awt::Size aSize( 0, 0 );
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 												{
174 													awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
175 													if ( aSize100thMM.Width && aSize100thMM.Height )
176 														aLogicalSize = aSize100thMM;
177 												}
178 												else
179 													aLogicalSize = aSize;
180 											}
181 											else
182 											{
183 												aLogicalSize.Width = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Width ) * aSize.Width ) / -100.0 );
184 												aLogicalSize.Height = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Height ) * aSize.Height ) / -100.0 );
185 											}
186 										}
187 									}
188 								}
189 							}
190 						}
191 						GraphicCollector::GraphicUser aUser;
192 						aUser.mxPropertySet = rxPropertySet;
193 						rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapURL ) ) >>= aUser.maGraphicURL;
194 						aUser.mbFillBitmap = sal_True;
195 						aUser.maLogicalSize = aLogicalSize;
196 						aUser.mxPagePropertySet = rxPagePropertySet;
197 						ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
198 					}
199 				}
200 			}
201 		}
202 	}
203 	catch( Exception& )
204 	{
205 	}
206 }
207 
208 void ImpCollectBackgroundGraphic( const Reference< XComponentContext >& rxMSF, 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 )
219 			ImpAddFillBitmapEntity( rxMSF, xBackgroundPropSet, aLogicalSize, rGraphicEntities, rGraphicSettings, xPropertySet );
220 	}
221 	catch( Exception& )
222 	{
223 	}
224 }
225 
226 void ImpCollectGraphicObjects( const Reference< XComponentContext >& rxMSF, 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 );
239 				ImpCollectGraphicObjects( rxMSF, xShapes, rGraphicSettings, rGraphicEntities );
240 				continue;
241 			}
242 
243 			if ( sShapeType == sGraphicObjectShape )
244 				ImpAddGraphicEntity( rxMSF, 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() );
250 			ImpAddFillBitmapEntity( rxMSF, xShapePropertySet, aLogicalSize, rGraphicEntities, rGraphicSettings, xEmptyPagePropSet );
251 		}
252 		catch( Exception& )
253 		{
254 		}
255 	}
256 }
257 
258 awt::Size GraphicCollector::GetOriginalSize( const Reference< XComponentContext >& rxMSF, 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 			{
269 				const DeviceInfo& rDeviceInfo( GraphicCollector::GetDeviceInfo( rxMSF ) );
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 
281 void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rxMSF, 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 );
292 			ImpCollectBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rGraphicList );
293 			Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
294 			ImpCollectGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rGraphicList );
295 
296 			Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
297 			Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
298 			ImpCollectBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rGraphicList );
299 			Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
300 			ImpCollectGraphicObjects( rxMSF, 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 );
307 			ImpCollectBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rGraphicList );
308 			Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
309 			ImpCollectGraphicObjects( rxMSF, 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;
318 			if ( aGraphicIter->mbRemoveCropArea )
319 			{
320 				std::vector< GraphicCollector::GraphicUser >::iterator aGUIter( aGraphicIter->maUser.begin() );
321 				while( aGraphicIter->mbRemoveCropArea && ( aGUIter != aGraphicIter->maUser.end() ) )
322 				{
323 					if ( aGUIter->maGraphicCropLogic.Left || aGUIter->maGraphicCropLogic.Top
324 						|| aGUIter->maGraphicCropLogic.Right || aGUIter->maGraphicCropLogic.Bottom )
325 					{
326 						if ( aGUIter == aGraphicIter->maUser.begin() )
327 							aGraphicIter->maGraphicCropLogic = aGUIter->maGraphicCropLogic;
328 						else if ( ( aGraphicIter->maGraphicCropLogic.Left != aGUIter->maGraphicCropLogic.Left )
329 							|| ( aGraphicIter->maGraphicCropLogic.Top != aGUIter->maGraphicCropLogic.Top )
330 							|| ( aGraphicIter->maGraphicCropLogic.Right != aGUIter->maGraphicCropLogic.Right )
331 							|| ( aGraphicIter->maGraphicCropLogic.Bottom != aGUIter->maGraphicCropLogic.Bottom ) )
332 						{
333 							aGraphicIter->mbRemoveCropArea = sal_False;
334 						}
335 					}
336 					else
337 						aGraphicIter->mbRemoveCropArea = sal_False;
338 					aGUIter++;
339 				}
340 			}
341 			if ( !aGraphicIter->mbRemoveCropArea )
342 				aGraphicIter->maGraphicCropLogic = text::GraphicCrop( 0, 0, 0, 0 );
343 			aGraphicIter++;
344 		}
345 	}
346 	catch ( Exception& )
347 	{
348 	}
349 }
350 
351 void ImpCountGraphicObjects( const Reference< XComponentContext >& rxMSF, 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 );
364 				ImpCountGraphicObjects( rxMSF, xShapes, rGraphicSettings, rnGraphics );
365 				continue;
366 			}
367 
368 			if ( sShapeType == sGraphicObjectShape )
369 			{
370 				rnGraphics++;
371 			}
372 
373 			// now check for a fillstyle
374 			Reference< XPropertySet > xEmptyPagePropSet;
375 			Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW );
376 			awt::Size aLogicalSize( xShape->getSize() );
377 
378 			FillStyle eFillStyle;
379 			if ( xShapePropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
380 			{
381 				if ( eFillStyle == FillStyle_BITMAP )
382 				{
383 					rnGraphics++;
384 				}
385 			}
386 		}
387 		catch( Exception& )
388 		{
389 		}
390 	}
391 }
392 
393 void ImpCountBackgroundGraphic( const Reference< XComponentContext >& /* rxMSF */, 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;
402 
403 		Reference< XPropertySet > xBackgroundPropSet;
404 		if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet )
405 		{
406 			FillStyle eFillStyle;
407 			if ( xBackgroundPropSet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
408 			{
409 				if ( eFillStyle == FillStyle_BITMAP )
410 				{
411 					rnGraphics++;
412 				}
413 			}
414 		}
415 	}
416 	catch( Exception& )
417 	{
418 	}
419 }
420 
421 void GraphicCollector::CountGraphics( const Reference< XComponentContext >& rxMSF, 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 );
432 			ImpCountBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rnGraphics );
433 			Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
434 			ImpCountGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rnGraphics );
435 
436 			Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
437 			Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
438 			ImpCountBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rnGraphics );
439 			Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
440 			ImpCountGraphicObjects( rxMSF, 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 );
447 			ImpCountBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rnGraphics );
448 			Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
449 			ImpCountGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rnGraphics );
450 		}
451 	}
452 	catch ( Exception& )
453 	{
454 	}
455 }
456 
457