LCOV - code coverage report
Current view: top level - libreoffice/sdext/source/minimizer - graphiccollector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 233 0.0 %
Date: 2012-12-27 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "graphiccollector.hxx"
      22             : #include <com/sun/star/awt/XDevice.hpp>
      23             : #include <com/sun/star/frame/Desktop.hpp>
      24             : #include <com/sun/star/frame/XFramesSupplier.hpp>
      25             : #include <com/sun/star/drawing/FillStyle.hpp>
      26             : #include <com/sun/star/drawing/BitmapMode.hpp>
      27             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      28             : #include <com/sun/star/presentation/XPresentationPage.hpp>
      29             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      30             : 
      31             : #include "impoptimizer.hxx"
      32             : 
      33             : using namespace ::rtl;
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::awt;
      37             : using namespace ::com::sun::star::drawing;
      38             : using namespace ::com::sun::star::graphic;
      39             : using namespace ::com::sun::star::frame;
      40             : using namespace ::com::sun::star::beans;
      41             : using namespace ::com::sun::star::presentation;
      42             : 
      43           0 : const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentContext >& rxFact )
      44             : {
      45           0 :     static DeviceInfo aDeviceInfo;
      46           0 :     if( !aDeviceInfo.Width )
      47             :     {
      48             :         try
      49             :         {
      50           0 :             Reference< XDesktop2 > xDesktop = Desktop::create( rxFact );
      51           0 :             Reference< XFrame > xFrame( xDesktop->getActiveFrame() );
      52           0 :             Reference< XWindow > xWindow( xFrame->getContainerWindow() );
      53           0 :             Reference< XDevice > xDevice( xWindow, UNO_QUERY_THROW );
      54           0 :             aDeviceInfo = xDevice->getInfo();
      55             :         }
      56           0 :         catch( Exception& )
      57             :         {
      58             :         }
      59             :     }
      60           0 :     return aDeviceInfo;
      61             : }
      62             : 
      63           0 : void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser )
      64             : {
      65           0 :     const rtl::OUString aGraphicURL( rUser.maGraphicURL );
      66           0 :     const rtl::OUString sPackageURL( "vnd.sun.star.GraphicObject:" );
      67             : 
      68           0 :     if ( rGraphicSettings.mbEmbedLinkedGraphics || (aGraphicURL.isEmpty() || aGraphicURL.match( sPackageURL, 0 ) ) )
      69             :     {
      70           0 :         std::vector< GraphicCollector::GraphicEntity >::iterator aIter( rGraphicEntities.begin() );
      71           0 :         while( aIter != rGraphicEntities.end() )
      72             :         {
      73           0 :             if ( aIter->maUser[ 0 ].maGraphicURL == aGraphicURL )
      74             :             {
      75           0 :                 if ( rUser.maLogicalSize.Width > aIter->maLogicalSize.Width )
      76           0 :                     aIter->maLogicalSize.Width = rUser.maLogicalSize.Width;
      77           0 :                 if ( rUser.maLogicalSize.Height > aIter->maLogicalSize.Height )
      78           0 :                     aIter->maLogicalSize.Height = rUser.maLogicalSize.Height;
      79           0 :                 aIter->maUser.push_back( rUser );
      80           0 :                 break;
      81             :             }
      82           0 :             ++aIter;
      83             :         }
      84           0 :         if ( aIter == rGraphicEntities.end() )
      85             :         {
      86           0 :             GraphicCollector::GraphicEntity aEntity( rUser );
      87           0 :             rGraphicEntities.push_back( aEntity );
      88             :         }
      89           0 :     }
      90           0 : }
      91             : 
      92           0 : void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Reference< XShape >& rxShape, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
      93             : {
      94           0 :     Reference< XGraphic > xGraphic;
      95           0 :     Reference< XPropertySet > xShapePropertySet( rxShape, UNO_QUERY_THROW );
      96           0 :     if ( xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic )
      97             :     {
      98           0 :         text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 );
      99             : 
     100           0 :         GraphicCollector::GraphicUser aUser;
     101           0 :         aUser.mxShape = rxShape;
     102           0 :         aUser.mbFillBitmap = sal_False;
     103           0 :         xShapePropertySet->getPropertyValue( TKGet( TK_GraphicURL ) ) >>= aUser.maGraphicURL;
     104           0 :         xShapePropertySet->getPropertyValue( TKGet( TK_GraphicStreamURL ) ) >>= aUser.maGraphicStreamURL;
     105           0 :         xShapePropertySet->getPropertyValue( TKGet( TK_GraphicCrop ) ) >>= aGraphicCropLogic;
     106           0 :         awt::Size aLogicalSize( rxShape->getSize() );
     107             : 
     108             :         // calculating the logical size, as if there were no cropping
     109           0 :         if ( aGraphicCropLogic.Left || aGraphicCropLogic.Right || aGraphicCropLogic.Top || aGraphicCropLogic.Bottom )
     110             :         {
     111           0 :             awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
     112           0 :             if ( aSize100thMM.Width && aSize100thMM.Height )
     113             :             {
     114             :                 awt::Size aCropSize( aSize100thMM.Width - ( aGraphicCropLogic.Left + aGraphicCropLogic.Right ),
     115           0 :                                      aSize100thMM.Height - ( aGraphicCropLogic.Top + aGraphicCropLogic.Bottom ));
     116           0 :                 if ( aCropSize.Width && aCropSize.Height )
     117             :                 {
     118             :                     awt::Size aNewLogSize( static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Width * aLogicalSize.Width ) / aCropSize.Width ),
     119           0 :                         static_cast< sal_Int32 >( static_cast< double >( aSize100thMM.Height * aLogicalSize.Height ) / aCropSize.Height ) );
     120           0 :                     aLogicalSize = aNewLogSize;
     121             :                 }
     122             :             }
     123             :         }
     124           0 :         aUser.maGraphicCropLogic = aGraphicCropLogic;
     125           0 :         aUser.maLogicalSize = aLogicalSize;
     126           0 :         ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
     127           0 :     }
     128           0 : }
     129             : 
     130           0 : void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const Reference< XPropertySet >& rxPropertySet, const awt::Size& rLogicalSize,
     131             :     std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const Reference< XPropertySet >& rxPagePropertySet )
     132             : {
     133             :     try
     134             :     {
     135             :         FillStyle eFillStyle;
     136           0 :         if ( rxPropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
     137             :         {
     138           0 :             if ( eFillStyle == FillStyle_BITMAP )
     139             :             {
     140           0 :                 Reference< XBitmap > xFillBitmap;
     141           0 :                 if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap )
     142             :                 {
     143           0 :                     Reference< XGraphic > xGraphic( xFillBitmap, UNO_QUERY_THROW );
     144           0 :                     if ( xGraphic.is() )
     145             :                     {
     146           0 :                         awt::Size aLogicalSize( rLogicalSize );
     147           0 :                         Reference< XPropertySetInfo > axPropSetInfo( rxPropertySet->getPropertySetInfo() );
     148           0 :                         if ( axPropSetInfo.is() )
     149             :                         {
     150           0 :                             if ( axPropSetInfo->hasPropertyByName( TKGet( TK_FillBitmapMode ) ) )
     151             :                             {
     152             :                                 BitmapMode eBitmapMode;
     153           0 :                                 if ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapMode ) ) >>= eBitmapMode )
     154             :                                 {
     155           0 :                                     if ( ( eBitmapMode == BitmapMode_REPEAT ) || ( eBitmapMode == BitmapMode_NO_REPEAT ) )
     156             :                                     {
     157           0 :                                         sal_Bool bLogicalSize = sal_False;
     158           0 :                                         awt::Size aSize( 0, 0 );
     159           0 :                                         if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize )
     160           0 :                                           && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width )
     161           0 :                                           && ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) )
     162             :                                         {
     163           0 :                                             if ( bLogicalSize )
     164             :                                             {
     165           0 :                                                 if ( !aSize.Width || !aSize.Height )
     166             :                                                 {
     167           0 :                                                     awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
     168           0 :                                                     if ( aSize100thMM.Width && aSize100thMM.Height )
     169           0 :                                                         aLogicalSize = aSize100thMM;
     170             :                                                 }
     171             :                                                 else
     172           0 :                                                     aLogicalSize = aSize;
     173             :                                             }
     174             :                                             else
     175             :                                             {
     176           0 :                                                 aLogicalSize.Width = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Width ) * aSize.Width ) / -100.0 );
     177           0 :                                                 aLogicalSize.Height = sal::static_int_cast< sal_Int32 >( ( static_cast< double >( aLogicalSize.Height ) * aSize.Height ) / -100.0 );
     178             :                                             }
     179             :                                         }
     180             :                                     }
     181             :                                 }
     182             :                             }
     183             :                         }
     184           0 :                         GraphicCollector::GraphicUser aUser;
     185           0 :                         aUser.mxPropertySet = rxPropertySet;
     186           0 :                         rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapURL ) ) >>= aUser.maGraphicURL;
     187           0 :                         aUser.mbFillBitmap = sal_True;
     188           0 :                         aUser.maLogicalSize = aLogicalSize;
     189           0 :                         aUser.mxPagePropertySet = rxPagePropertySet;
     190           0 :                         ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
     191           0 :                     }
     192           0 :                 }
     193             :             }
     194             :         }
     195             :     }
     196           0 :     catch( Exception& )
     197             :     {
     198             :     }
     199           0 : }
     200             : 
     201           0 : void ImpCollectBackgroundGraphic( const Reference< XComponentContext >& rxMSF, const Reference< XDrawPage >& rxDrawPage, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
     202             : {
     203             :     try
     204             :     {
     205           0 :         awt::Size aLogicalSize( 28000, 21000 );
     206           0 :         Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW );
     207           0 :         xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width;
     208           0 :         xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height;
     209             : 
     210           0 :         Reference< XPropertySet > xBackgroundPropSet;
     211           0 :         if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet )
     212           0 :             ImpAddFillBitmapEntity( rxMSF, xBackgroundPropSet, aLogicalSize, rGraphicEntities, rGraphicSettings, xPropertySet );
     213             :     }
     214           0 :     catch( Exception& )
     215             :     {
     216             :     }
     217           0 : }
     218             : 
     219           0 : void ImpCollectGraphicObjects( const Reference< XComponentContext >& rxMSF, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities )
     220             : {
     221           0 :     for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ )
     222             :     {
     223             :         try
     224             :         {
     225           0 :             const OUString sGraphicObjectShape( "com.sun.star.drawing.GraphicObjectShape"  );
     226           0 :             const OUString sGroupShape( "com.sun.star.drawing.GroupShape"  );
     227           0 :             Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW );
     228           0 :             const OUString sShapeType( xShape->getShapeType() );
     229           0 :             if ( sShapeType == sGroupShape )
     230             :             {
     231           0 :                 Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW );
     232           0 :                 ImpCollectGraphicObjects( rxMSF, xShapes, rGraphicSettings, rGraphicEntities );
     233           0 :                 continue;
     234             :             }
     235             : 
     236           0 :             if ( sShapeType == sGraphicObjectShape )
     237           0 :                 ImpAddGraphicEntity( rxMSF, xShape, rGraphicSettings, rGraphicEntities );
     238             : 
     239             :             // now check for a fillstyle
     240           0 :             Reference< XPropertySet > xEmptyPagePropSet;
     241           0 :             Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW );
     242           0 :             awt::Size aLogicalSize( xShape->getSize() );
     243           0 :             ImpAddFillBitmapEntity( rxMSF, xShapePropertySet, aLogicalSize, rGraphicEntities, rGraphicSettings, xEmptyPagePropSet );
     244             :         }
     245           0 :         catch( Exception& )
     246             :         {
     247             :         }
     248             :     }
     249           0 : }
     250             : 
     251           0 : awt::Size GraphicCollector::GetOriginalSize( const Reference< XComponentContext >& rxMSF, const Reference< XGraphic >& rxGraphic )
     252             : {
     253           0 :     awt::Size aSize100thMM( 0, 0 );
     254           0 :     Reference< XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
     255           0 :     if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_Size100thMM ) ) >>= aSize100thMM )
     256             :     {
     257           0 :         if ( !aSize100thMM.Width && !aSize100thMM.Height )
     258             :         {   // MAPMODE_PIXEL USED :-(
     259           0 :             awt::Size aSourceSizePixel( 0, 0 );
     260           0 :             if ( xGraphicPropertySet->getPropertyValue( TKGet( TK_SizePixel ) ) >>= aSourceSizePixel )
     261             :             {
     262           0 :                 const DeviceInfo& rDeviceInfo( GraphicCollector::GetDeviceInfo( rxMSF ) );
     263           0 :                 if ( rDeviceInfo.PixelPerMeterX && rDeviceInfo.PixelPerMeterY )
     264             :                 {
     265           0 :                     aSize100thMM.Width = static_cast< sal_Int32 >( ( aSourceSizePixel.Width * 100000.0 ) / rDeviceInfo.PixelPerMeterX );
     266           0 :                     aSize100thMM.Height = static_cast< sal_Int32 >( ( aSourceSizePixel.Height * 100000.0 ) / rDeviceInfo.PixelPerMeterY );
     267             :                 }
     268             :             }
     269             :         }
     270             :     }
     271           0 :     return aSize100thMM;
     272             : }
     273             : 
     274           0 : void GraphicCollector::CollectGraphics( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel,
     275             :         const GraphicSettings& rGraphicSettings, std::vector< GraphicCollector::GraphicEntity >& rGraphicList )
     276             : {
     277             :     try
     278             :     {
     279             :         sal_Int32 i;
     280           0 :         Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
     281           0 :         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     282           0 :         for ( i = 0; i < xDrawPages->getCount(); i++ )
     283             :         {
     284           0 :             Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
     285           0 :             ImpCollectBackgroundGraphic( rxMSF, xDrawPage, rGraphicSettings, rGraphicList );
     286           0 :             Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
     287           0 :             ImpCollectGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rGraphicList );
     288             : 
     289           0 :             Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
     290           0 :             Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
     291           0 :             ImpCollectBackgroundGraphic( rxMSF, xNotesPage, rGraphicSettings, rGraphicList );
     292           0 :             Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
     293           0 :             ImpCollectGraphicObjects( rxMSF, xNotesShapes, rGraphicSettings, rGraphicList );
     294           0 :         }
     295           0 :         Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
     296           0 :         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
     297           0 :         for ( i = 0; i < xMasterPages->getCount(); i++ )
     298             :         {
     299           0 :             Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
     300           0 :             ImpCollectBackgroundGraphic( rxMSF, xMasterPage, rGraphicSettings, rGraphicList );
     301           0 :             Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
     302           0 :             ImpCollectGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rGraphicList );
     303           0 :         }
     304             : 
     305           0 :         std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIter( rGraphicList.begin() );
     306           0 :         std::vector< GraphicCollector::GraphicEntity >::iterator aGraphicIEnd( rGraphicList.end() );
     307           0 :         while( aGraphicIter != aGraphicIEnd )
     308             :         {
     309             :             // check if it is possible to remove the crop area
     310           0 :             aGraphicIter->mbRemoveCropArea = rGraphicSettings.mbRemoveCropArea;
     311           0 :             if ( aGraphicIter->mbRemoveCropArea )
     312             :             {
     313           0 :                 std::vector< GraphicCollector::GraphicUser >::iterator aGUIter( aGraphicIter->maUser.begin() );
     314           0 :                 while( aGraphicIter->mbRemoveCropArea && ( aGUIter != aGraphicIter->maUser.end() ) )
     315             :                 {
     316           0 :                     if ( aGUIter->maGraphicCropLogic.Left || aGUIter->maGraphicCropLogic.Top
     317           0 :                         || aGUIter->maGraphicCropLogic.Right || aGUIter->maGraphicCropLogic.Bottom )
     318             :                     {
     319           0 :                         if ( aGUIter == aGraphicIter->maUser.begin() )
     320           0 :                             aGraphicIter->maGraphicCropLogic = aGUIter->maGraphicCropLogic;
     321           0 :                         else if ( ( aGraphicIter->maGraphicCropLogic.Left != aGUIter->maGraphicCropLogic.Left )
     322           0 :                             || ( aGraphicIter->maGraphicCropLogic.Top != aGUIter->maGraphicCropLogic.Top )
     323           0 :                             || ( aGraphicIter->maGraphicCropLogic.Right != aGUIter->maGraphicCropLogic.Right )
     324           0 :                             || ( aGraphicIter->maGraphicCropLogic.Bottom != aGUIter->maGraphicCropLogic.Bottom ) )
     325             :                         {
     326           0 :                             aGraphicIter->mbRemoveCropArea = sal_False;
     327             :                         }
     328             :                     }
     329             :                     else
     330           0 :                         aGraphicIter->mbRemoveCropArea = sal_False;
     331           0 :                     ++aGUIter;
     332             :                 }
     333             :             }
     334           0 :             if ( !aGraphicIter->mbRemoveCropArea )
     335           0 :                 aGraphicIter->maGraphicCropLogic = text::GraphicCrop( 0, 0, 0, 0 );
     336           0 :             ++aGraphicIter;
     337           0 :         }
     338             :     }
     339           0 :     catch ( Exception& )
     340             :     {
     341             :     }
     342           0 : }
     343             : 
     344           0 : void ImpCountGraphicObjects( const Reference< XComponentContext >& rxMSF, const Reference< XShapes >& rxShapes, const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics )
     345             : {
     346           0 :     for ( sal_Int32 i = 0; i < rxShapes->getCount(); i++ )
     347             :     {
     348             :         try
     349             :         {
     350           0 :             const OUString sGraphicObjectShape( "com.sun.star.drawing.GraphicObjectShape"  );
     351           0 :             const OUString sGroupShape( "com.sun.star.drawing.GroupShape"  );
     352           0 :             Reference< XShape > xShape( rxShapes->getByIndex( i ), UNO_QUERY_THROW );
     353           0 :             const OUString sShapeType( xShape->getShapeType() );
     354           0 :             if ( sShapeType == sGroupShape )
     355             :             {
     356           0 :                 Reference< XShapes > xShapes( xShape, UNO_QUERY_THROW );
     357           0 :                 ImpCountGraphicObjects( rxMSF, xShapes, rGraphicSettings, rnGraphics );
     358           0 :                 continue;
     359             :             }
     360             : 
     361           0 :             if ( sShapeType == sGraphicObjectShape )
     362             :             {
     363           0 :                 rnGraphics++;
     364             :             }
     365             : 
     366             :             // now check for a fillstyle
     367           0 :             Reference< XPropertySet > xEmptyPagePropSet;
     368           0 :             Reference< XPropertySet > xShapePropertySet( xShape, UNO_QUERY_THROW );
     369             :             FillStyle eFillStyle;
     370           0 :             if ( xShapePropertySet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
     371             :             {
     372           0 :                 if ( eFillStyle == FillStyle_BITMAP )
     373             :                 {
     374           0 :                     rnGraphics++;
     375             :                 }
     376           0 :             }
     377             :         }
     378           0 :         catch( Exception& )
     379             :         {
     380             :         }
     381             :     }
     382           0 : }
     383             : 
     384           0 : void ImpCountBackgroundGraphic(
     385             :     const Reference< XDrawPage >& rxDrawPage, sal_Int32& rnGraphics )
     386             : {
     387             :     try
     388             :     {
     389           0 :         awt::Size aLogicalSize( 28000, 21000 );
     390           0 :         Reference< XPropertySet > xPropertySet( rxDrawPage, UNO_QUERY_THROW );
     391           0 :         xPropertySet->getPropertyValue( TKGet( TK_Width ) ) >>= aLogicalSize.Width;
     392           0 :         xPropertySet->getPropertyValue( TKGet( TK_Height ) ) >>= aLogicalSize.Height;
     393             : 
     394           0 :         Reference< XPropertySet > xBackgroundPropSet;
     395           0 :         if ( xPropertySet->getPropertyValue( TKGet( TK_Background ) ) >>= xBackgroundPropSet )
     396             :         {
     397             :             FillStyle eFillStyle;
     398           0 :             if ( xBackgroundPropSet->getPropertyValue( TKGet( TK_FillStyle ) ) >>= eFillStyle )
     399             :             {
     400           0 :                 if ( eFillStyle == FillStyle_BITMAP )
     401             :                 {
     402           0 :                     rnGraphics++;
     403             :                 }
     404             :             }
     405           0 :         }
     406             :     }
     407           0 :     catch( Exception& )
     408             :     {
     409             :     }
     410           0 : }
     411             : 
     412           0 : void GraphicCollector::CountGraphics( const Reference< XComponentContext >& rxMSF, const Reference< XModel >& rxModel,
     413             :         const GraphicSettings& rGraphicSettings, sal_Int32& rnGraphics )
     414             : {
     415             :     try
     416             :     {
     417             :         sal_Int32 i;
     418           0 :         Reference< XDrawPagesSupplier > xDrawPagesSupplier( rxModel, UNO_QUERY_THROW );
     419           0 :         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     420           0 :         for ( i = 0; i < xDrawPages->getCount(); i++ )
     421             :         {
     422           0 :             Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
     423           0 :             ImpCountBackgroundGraphic( xDrawPage, rnGraphics );
     424           0 :             Reference< XShapes > xDrawShapes( xDrawPage, UNO_QUERY_THROW );
     425           0 :             ImpCountGraphicObjects( rxMSF, xDrawShapes, rGraphicSettings, rnGraphics );
     426             : 
     427           0 :             Reference< XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
     428           0 :             Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() );
     429           0 :             ImpCountBackgroundGraphic( xNotesPage, rnGraphics );
     430           0 :             Reference< XShapes > xNotesShapes( xNotesPage, UNO_QUERY_THROW );
     431           0 :             ImpCountGraphicObjects( rxMSF, xNotesShapes, rGraphicSettings, rnGraphics );
     432           0 :         }
     433           0 :         Reference< XMasterPagesSupplier > xMasterPagesSupplier( rxModel, UNO_QUERY_THROW );
     434           0 :         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
     435           0 :         for ( i = 0; i < xMasterPages->getCount(); i++ )
     436             :         {
     437           0 :             Reference< XDrawPage > xMasterPage( xMasterPages->getByIndex( i ), UNO_QUERY_THROW );
     438           0 :             ImpCountBackgroundGraphic( xMasterPage, rnGraphics );
     439           0 :             Reference< XShapes > xMasterPageShapes( xMasterPage, UNO_QUERY_THROW );
     440           0 :             ImpCountGraphicObjects( rxMSF, xMasterPageShapes, rGraphicSettings, rnGraphics );
     441           0 :         }
     442             :     }
     443           0 :     catch ( Exception& )
     444             :     {
     445             :     }
     446           0 : }
     447             : 
     448             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10