LCOV - code coverage report
Current view: top level - sdext/source/minimizer - graphiccollector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 234 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10