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 ::com::sun::star;
39 using namespace ::com::sun::star::uno;
40 using namespace ::com::sun::star::awt;
41 using namespace ::com::sun::star::drawing;
42 using namespace ::com::sun::star::graphic;
43 using namespace ::com::sun::star::frame;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::presentation;
46 
47 using ::rtl::OUString;
48 
49 const 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(
57 					OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), rxFact ), UNO_QUERY_THROW );
58 			Reference< XFrame > xFrame( xDesktop->getActiveFrame() );
59 			Reference< XWindow > xWindow( xFrame->getContainerWindow() );
60 			Reference< XDevice > xDevice( xWindow, UNO_QUERY_THROW );
61 			aDeviceInfo = xDevice->getInfo();
62 		}
63 		catch( Exception& )
64 		{
65 		}
66 	}
67 	return aDeviceInfo;
68 }
69 
70 void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser )
71 {
72 	const rtl::OUString aGraphicURL( rUser.maGraphicURL );
73 	const rtl::OUString sPackageURL( OUString::createFromAscii( "vnd.sun.star.GraphicObject:" ) );
74 
75 	if ( rGraphicSettings.mbEmbedLinkedGraphics || ( !aGraphicURL.getLength() || aGraphicURL.match( sPackageURL, 0 ) ) )
76 	{
77 		std::vector< GraphicCollector::GraphicEntity >::iterator aIter( rGraphicEntities.begin() );
78 		while( aIter != rGraphicEntities.end() )
79 		{
80 			if ( aIter->maUser[ 0 ].maGraphicURL == aGraphicURL )
81 			{
82 				if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width )
83 					aIter->maLogicalSize.Width = rUser.maLogicalSize.Width;
84 				if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height )
85 					aIter->maLogicalSize.Height = rUser.maLogicalSize.Height;
86 				aIter->maUser.push_back( rUser );
87 				break;
88 			}
89 			aIter++;
90 		}
91 		if ( aIter == rGraphicEntities.end() )
92 		{
93 			GraphicCollector::GraphicEntity aEntity( rUser );
94 			rGraphicEntities.push_back( aEntity );
95 		}
96 	}
97 }
98 
99 void ImpAddGraphicEntity( const Reference< XComponentContext >& rxContext, Reference< XShape >& rxShape, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
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 		{
118 			awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxContext, xGraphic ) );
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 
137 void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxContext, const Reference< XPropertySet >& rxPropertySet, const awt::Size& rLogicalSize,
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 )
146 			{
147 				rtl::OUString aFillBitmapURL;
148 				Reference< XBitmap > xFillBitmap;
149 				if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap )
150 				{
151 					Reference< XGraphic > xGraphic( xFillBitmap, UNO_QUERY_THROW );
152 					if ( xGraphic.is() )
153 					{
154 						awt::Size aLogicalSize( rLogicalSize );
155 						Reference< XPropertySetInfo > axPropSetInfo( rxPropertySet->getPropertySetInfo() );
156 						if ( axPropSetInfo.is() )
157 						{
158 							if ( axPropSetInfo->hasPropertyByName( TKGet( TK_FillBitmapMode ) ) )
159 							{
160 								BitmapMode eBitmapMode;
161 								if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapMode ) ) >>= eBitmapMode )
162 								{
163 									if ( ( eBitmapMode == BitmapMode_REPEAT ) || ( eBitmapMode == BitmapMode_NO_REPEAT ) )
164 									{
165 										sal_Bool bLogicalSize = sal_False;
166 										awt::Size aSize( 0, 0 );
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 												{
175 													awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxContext, xGraphic ) );
176 													if ( aSize100thMM.Width && aSize100thMM.Height )
177 														aLogicalSize = aSize100thMM;
178 												}
179 												else
180 													aLogicalSize = aSize;
181 											}
182 											else
183 											{
184 												aLogicalSize.Width = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Width ) * aSize.Width ) / -100.0 );
185 												aLogicalSize.Height = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Height ) * aSize.Height ) / -100.0 );
186 											}
187 										}
188 									}
189 								}
190 							}
191 						}
192 						GraphicCollector::GraphicUser aUser;
193 						aUser.mxPropertySet = rxPropertySet;
194 						rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapURL ) ) >>= aUser.maGraphicURL;
195 						aUser.mbFillBitmap = sal_True;
196 						aUser.maLogicalSize = aLogicalSize;
197 						aUser.mxPagePropertySet = rxPagePropertySet;
198 						ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
199 					}
200 				}
201 			}
202 		}
203 	}
204 	catch( Exception& )
205 	{
206 	}
207 }
208 
209 void ImpCollectBackgroundGraphic( const Reference< XComponentContext >& rxContext, const Reference< XDrawPage >& rxDrawPage, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
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 )
220 			ImpAddFillBitmapEntity( rxContext, xBackgroundPropSet, aLogicalSize, rGraphicEntities, rGraphicSettings, xPropertySet );
221 	}
222 	catch( Exception& )
223 	{
224 	}
225 }
226 
227 void ImpCollectGraphicObjects( const Reference< XComponentContext >& rxContext, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
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 );
240 				ImpCollectGraphicObjects( rxContext, xShapes, rGraphicSettings, rGraphicEntities );
241 				continue;
242 			}
243 
244 			if ( sShapeType == sGraphicObjectShape )
245 				ImpAddGraphicEntity( rxContext, xShape, rGraphicSettings, rGraphicEntities );
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() );
251 			ImpAddFillBitmapEntity( rxContext, xShapePropertySet, aLogicalSize, rGraphicEntities, rGraphicSettings, xEmptyPagePropSet );
252 		}
253 		catch( Exception& )
254 		{
255 		}
256 	}
257 }
258 
259 awt::Size GraphicCollector::GetOriginalSize( const Reference< XComponentContext >& rxContext, const Reference< XGraphic >& rxGraphic )
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 			{
270 				const DeviceInfo& rDeviceInfo( GraphicCollector::GetDeviceInfo( rxContext ) );
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 
282 void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rxContext, const Reference< XModel >& rxModel,
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 );
293 			ImpCollectBackgroundGraphic( rxContext, xDrawPage, rGraphicSettings, rGraphicList );
294 			Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
295 			ImpCollectGraphicObjects( rxContext, xDrawShapes, rGraphicSettings, rGraphicList );
296 
297 			Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
298 			Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
299 			ImpCollectBackgroundGraphic( rxContext, xNotesPage, rGraphicSettings, rGraphicList );
300 			Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
301 			ImpCollectGraphicObjects( rxContext, xNotesShapes, rGraphicSettings, rGraphicList );
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 );
308 			ImpCollectBackgroundGraphic( rxContext, xMasterPage, rGraphicSettings, rGraphicList );
309 			Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
310 			ImpCollectGraphicObjects( rxContext, xMasterPageShapes, rGraphicSettings, rGraphicList );
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;
319 			if ( aGraphicIter->mbRemoveCropArea )
320 			{
321 				std::vector< GraphicCollector::GraphicUser >::iterator aGUIter( aGraphicIter->maUser.begin() );
322 				while( aGraphicIter->mbRemoveCropArea && ( aGUIter != aGraphicIter->maUser.end() ) )
323 				{
324 					if ( aGUIter->maGraphicCropLogic.Left || aGUIter->maGraphicCropLogic.Top
325 						|| aGUIter->maGraphicCropLogic.Right || aGUIter->maGraphicCropLogic.Bottom )
326 					{
327 						if ( aGUIter == aGraphicIter->maUser.begin() )
328 							aGraphicIter->maGraphicCropLogic = aGUIter->maGraphicCropLogic;
329 						else if ( ( aGraphicIter->maGraphicCropLogic.Left != aGUIter->maGraphicCropLogic.Left )
330 							|| ( aGraphicIter->maGraphicCropLogic.Top != aGUIter->maGraphicCropLogic.Top )
331 							|| ( aGraphicIter->maGraphicCropLogic.Right != aGUIter->maGraphicCropLogic.Right )
332 							|| ( aGraphicIter->maGraphicCropLogic.Bottom != aGUIter->maGraphicCropLogic.Bottom ) )
333 						{
334 							aGraphicIter->mbRemoveCropArea = sal_False;
335 						}
336 					}
337 					else
338 						aGraphicIter->mbRemoveCropArea = sal_False;
339 					aGUIter++;
340 				}
341 			}
342 			if ( !aGraphicIter->mbRemoveCropArea )
343 				aGraphicIter->maGraphicCropLogic = text::GraphicCrop( 0, 0, 0, 0 );
344 			aGraphicIter++;
345 		}
346 	}
347 	catch ( Exception& )
348 	{
349 	}
350 }
351 
352 void ImpCountGraphicObjects( const Reference< XComponentContext >& rxContext, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics )
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 );
365 				ImpCountGraphicObjects( rxContext, xShapes, rGraphicSettings, rnGraphics );
366 				continue;
367 			}
368 
369 			if ( sShapeType == sGraphicObjectShape )
370 			{
371 				rnGraphics++;
372 			}
373 
374 			// now check for a fillstyle
375 			Reference< XPropertySet > xEmptyPagePropSet;
376 			Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW );
377 			awt::Size aLogicalSize( xShape->getSize() );
378 
379 			FillStyle eFillStyle;
380 			if ( xShapePropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
381 			{
382 				if ( eFillStyle == FillStyle_BITMAP )
383 				{
384 					rnGraphics++;
385 				}
386 			}
387 		}
388 		catch( Exception& )
389 		{
390 		}
391 	}
392 }
393 
394 void ImpCountBackgroundGraphic( const Reference< XComponentContext >& /* rxContext */, const Reference< XDrawPage >& rxDrawPage,
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;
403 
404 		Reference< XPropertySet > xBackgroundPropSet;
405 		if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet )
406 		{
407 			FillStyle eFillStyle;
408 			if ( xBackgroundPropSet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
409 			{
410 				if ( eFillStyle == FillStyle_BITMAP )
411 				{
412 					rnGraphics++;
413 				}
414 			}
415 		}
416 	}
417 	catch( Exception& )
418 	{
419 	}
420 }
421 
422 void GraphicCollector::CountGraphics( const Reference< XComponentContext >& rxContext, const Reference< XModel >& rxModel,
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 );
433 			ImpCountBackgroundGraphic( rxContext, xDrawPage, rGraphicSettings, rnGraphics );
434 			Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
435 			ImpCountGraphicObjects( rxContext, xDrawShapes, rGraphicSettings, rnGraphics );
436 
437 			Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
438 			Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
439 			ImpCountBackgroundGraphic( rxContext, xNotesPage, rGraphicSettings, rnGraphics );
440 			Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
441 			ImpCountGraphicObjects( rxContext, xNotesShapes, rGraphicSettings, rnGraphics );
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 );
448 			ImpCountBackgroundGraphic( rxContext, xMasterPage, rGraphicSettings, rnGraphics );
449 			Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
450 			ImpCountGraphicObjects( rxContext, xMasterPageShapes, rGraphicSettings, rnGraphics );
451 		}
452 	}
453 	catch ( Exception& )
454 	{
455 	}
456 }
457 
458