LCOV - code coverage report
Current view: top level - svtools/source/graphic - grfmgr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 259 596 43.5 %
Date: 2012-08-25 Functions: 34 60 56.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 212 1084 19.6 %

           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                 :            : #include "sal/config.h"
      30                 :            : 
      31                 :            : #include <algorithm>
      32                 :            : 
      33                 :            : #include <officecfg/Office/Common.hxx>
      34                 :            : #include <tools/vcompat.hxx>
      35                 :            : #include <tools/helpers.hxx>
      36                 :            : #include <unotools/ucbstreamhelper.hxx>
      37                 :            : #include <unotools/localfilehelper.hxx>
      38                 :            : #include <unotools/tempfile.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : #include <vcl/cvtgrf.hxx>
      41                 :            : #include <vcl/metaact.hxx>
      42                 :            : #include <vcl/virdev.hxx>
      43                 :            : #include <svtools/grfmgr.hxx>
      44                 :            : 
      45                 :            : #include <vcl/pdfextoutdevdata.hxx>
      46                 :            : 
      47                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      48                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      49                 :            : 
      50                 :            : using com::sun::star::uno::Reference;
      51                 :            : using com::sun::star::uno::XInterface;
      52                 :            : using com::sun::star::uno::UNO_QUERY;
      53                 :            : using com::sun::star::uno::Sequence;
      54                 :            : using com::sun::star::container::XNameContainer;
      55                 :            : using com::sun::star::beans::XPropertySet;
      56                 :            : 
      57                 :            : GraphicManager* GraphicObject::mpGlobalMgr = NULL;
      58                 :            : 
      59         [ #  # ]:          0 : struct GrfSimpleCacheObj
      60                 :            : {
      61                 :            :     Graphic     maGraphic;
      62                 :            :     GraphicAttr maAttr;
      63                 :            : 
      64                 :          0 :                 GrfSimpleCacheObj( const Graphic& rGraphic, const GraphicAttr& rAttr ) :
      65                 :          0 :                     maGraphic( rGraphic ), maAttr( rAttr ) {}
      66                 :            : };
      67                 :            : 
      68 [ #  # ][ #  # ]:          0 : TYPEINIT1_AUTOFACTORY( GraphicObject, SvDataCopyStream );
                 [ #  # ]
      69                 :            : 
      70                 :       5657 : GraphicObject::GraphicObject( const GraphicManager* pMgr ) :
      71                 :            :     mpLink      ( NULL ),
      72 [ +  - ][ +  - ]:       5657 :     mpUserData  ( NULL )
                 [ +  - ]
      73                 :            : {
      74                 :       5657 :     ImplConstruct();
      75         [ +  - ]:       5657 :     ImplAssignGraphicData();
      76         [ +  - ]:       5657 :     ImplSetGraphicManager( pMgr );
      77                 :       5657 : }
      78                 :            : 
      79                 :      21815 : GraphicObject::GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr ) :
      80                 :            :     maGraphic   ( rGraphic ),
      81                 :            :     mpLink      ( NULL ),
      82 [ +  - ][ +  - ]:      21815 :     mpUserData  ( NULL )
                 [ +  - ]
      83                 :            : {
      84                 :      21815 :     ImplConstruct();
      85         [ +  - ]:      21815 :     ImplAssignGraphicData();
      86         [ +  - ]:      21815 :     ImplSetGraphicManager( pMgr );
      87                 :      21815 : }
      88                 :            : 
      89                 :       1080 : GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicManager* pMgr ) :
      90                 :            :     SvDataCopyStream(),
      91         [ +  - ]:       1080 :     maGraphic   ( rGraphicObj.GetGraphic() ),
      92                 :            :     maAttr      ( rGraphicObj.maAttr ),
      93         [ #  # ]:          0 :     mpLink      ( rGraphicObj.mpLink ? ( new String( *rGraphicObj.mpLink ) ) : NULL ),
      94 [ +  - ][ +  - ]:       2160 :     mpUserData  ( rGraphicObj.mpUserData ? ( new String( *rGraphicObj.mpUserData ) ) : NULL )
         [ -  + ][ #  # ]
         [ -  + ][ #  # ]
                 [ #  # ]
      95                 :            : {
      96                 :       1080 :     ImplConstruct();
      97         [ +  - ]:       1080 :     ImplAssignGraphicData();
      98         [ +  - ]:       1080 :     ImplSetGraphicManager( pMgr, NULL, &rGraphicObj );
      99                 :       1080 : }
     100                 :            : 
     101                 :        423 : GraphicObject::GraphicObject( const rtl::OString& rUniqueID, const GraphicManager* pMgr ) :
     102                 :            :     mpLink      ( NULL ),
     103 [ +  - ][ +  - ]:        423 :     mpUserData  ( NULL )
                 [ +  - ]
     104                 :            : {
     105                 :        423 :     ImplConstruct();
     106                 :            : 
     107                 :            :     // assign default properties
     108         [ +  - ]:        423 :     ImplAssignGraphicData();
     109                 :            : 
     110         [ +  - ]:        423 :     ImplSetGraphicManager( pMgr, &rUniqueID );
     111                 :            : 
     112                 :            :     // update properties
     113         [ +  - ]:        423 :     ImplAssignGraphicData();
     114                 :        423 : }
     115                 :            : 
     116 [ +  - ][ +  - ]:      28724 : GraphicObject::~GraphicObject()
                 [ +  - ]
     117                 :            : {
     118         [ +  - ]:      28724 :     if( mpMgr )
     119                 :            :     {
     120         [ +  - ]:      28724 :         mpMgr->ImplUnregisterObj( *this );
     121                 :            : 
     122 [ +  - ][ +  + ]:      28724 :         if( ( mpMgr == mpGlobalMgr ) && !mpGlobalMgr->ImplHasObjects() )
                 [ +  + ]
     123 [ +  - ][ +  - ]:         51 :             delete mpGlobalMgr, mpGlobalMgr = NULL;
     124                 :            :     }
     125                 :            : 
     126 [ +  + ][ +  - ]:      28724 :     delete mpSwapOutTimer;
     127                 :      28724 :     delete mpSwapStreamHdl;
     128 [ +  - ][ +  + ]:      28724 :     delete mpLink;
     129 [ +  + ][ +  - ]:      28724 :     delete mpUserData;
     130 [ -  + ][ #  # ]:      28724 :     delete mpSimpleCache;
     131         [ -  + ]:      28942 : }
     132                 :            : 
     133                 :      28975 : void GraphicObject::ImplConstruct()
     134                 :            : {
     135                 :      28975 :     mpMgr = NULL;
     136                 :      28975 :     mpSwapStreamHdl = NULL;
     137                 :      28975 :     mpSwapOutTimer = NULL;
     138                 :      28975 :     mpSimpleCache = NULL;
     139                 :      28975 :     mnAnimationLoopCount = 0;
     140                 :      28975 :     mbAutoSwapped = sal_False;
     141                 :      28975 :     mbIsInSwapIn = sal_False;
     142                 :      28975 :     mbIsInSwapOut = sal_False;
     143                 :      28975 : }
     144                 :            : 
     145                 :      35204 : void GraphicObject::ImplAssignGraphicData()
     146                 :            : {
     147                 :      35204 :     maPrefSize = maGraphic.GetPrefSize();
     148         [ +  - ]:      35204 :     maPrefMapMode = maGraphic.GetPrefMapMode();
     149                 :      35204 :     mnSizeBytes = maGraphic.GetSizeBytes();
     150                 :      35204 :     meType = maGraphic.GetType();
     151                 :      35204 :     mbTransparent = maGraphic.IsTransparent();
     152                 :      35204 :     mbAlpha = maGraphic.IsAlpha();
     153                 :      35204 :     mbAnimated = maGraphic.IsAnimated();
     154                 :      35204 :     mbEPS = maGraphic.IsEPS();
     155                 :      35204 :     mbIsRenderGraphic = maGraphic.IsRenderGraphic();
     156                 :      35204 :     mbHasRenderGraphic = maGraphic.HasRenderGraphic();
     157         [ -  + ]:      35204 :     mnAnimationLoopCount = ( mbAnimated ? maGraphic.GetAnimationLoopCount() : 0 );
     158                 :      35204 : }
     159                 :            : 
     160                 :      28975 : void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const rtl::OString* pID, const GraphicObject* pCopyObj )
     161                 :            : {
     162 [ -  + ][ #  # ]:      28975 :     if( !mpMgr || ( pMgr != mpMgr ) )
     163                 :            :     {
     164 [ +  - ][ -  + ]:      28975 :         if( !pMgr && mpMgr && ( mpMgr == mpGlobalMgr ) )
                 [ #  # ]
     165                 :      28975 :             return;
     166                 :            :         else
     167                 :            :         {
     168         [ -  + ]:      28975 :             if( mpMgr )
     169                 :            :             {
     170                 :          0 :                 mpMgr->ImplUnregisterObj( *this );
     171                 :            : 
     172 [ #  # ][ #  # ]:          0 :                 if( ( mpMgr == mpGlobalMgr ) && !mpGlobalMgr->ImplHasObjects() )
                 [ #  # ]
     173         [ #  # ]:          0 :                     delete mpGlobalMgr, mpGlobalMgr = NULL;
     174                 :            :             }
     175                 :            : 
     176         [ +  - ]:      28975 :             if( !pMgr )
     177                 :            :             {
     178         [ +  + ]:      28975 :                 if( !mpGlobalMgr )
     179                 :            :                 {
     180                 :            :                     mpGlobalMgr = new GraphicManager(
     181                 :            :                         (officecfg::Office::Common::Cache::GraphicManager::
     182                 :            :                          TotalCacheSize::get()),
     183                 :            :                         (officecfg::Office::Common::Cache::GraphicManager::
     184 [ +  - ][ +  - ]:        138 :                          ObjectCacheSize::get()));
     185                 :            :                     mpGlobalMgr->SetCacheTimeout(
     186                 :            :                         officecfg::Office::Common::Cache::GraphicManager::
     187         [ +  - ]:        138 :                         ObjectReleaseTime::get());
     188                 :            :                 }
     189                 :            : 
     190                 :      28975 :                 mpMgr = mpGlobalMgr;
     191                 :            :             }
     192                 :            :             else
     193                 :          0 :                 mpMgr = (GraphicManager*) pMgr;
     194                 :            : 
     195                 :      28975 :             mpMgr->ImplRegisterObj( *this, maGraphic, pID, pCopyObj );
     196                 :            :         }
     197                 :            :     }
     198                 :            : }
     199                 :            : 
     200                 :         83 : void GraphicObject::ImplAutoSwapIn()
     201                 :            : {
     202         [ +  + ]:         83 :     if( IsSwappedOut() )
     203                 :            :     {
     204 [ +  - ][ -  + ]:          8 :         if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
                 [ -  + ]
     205                 :          0 :             mbAutoSwapped = sal_False;
     206                 :            :         else
     207                 :            :         {
     208                 :          8 :             mbIsInSwapIn = sal_True;
     209                 :            : 
     210         [ +  + ]:          8 :             if( maGraphic.SwapIn() )
     211                 :          6 :                 mbAutoSwapped = sal_False;
     212                 :            :             else
     213                 :            :             {
     214                 :          2 :                 SvStream* pStream = GetSwapStream();
     215                 :            : 
     216         [ -  + ]:          2 :                 if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
     217                 :            :                 {
     218         [ #  # ]:          0 :                     if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
     219                 :            :                     {
     220         [ #  # ]:          0 :                         if( HasLink() )
     221                 :            :                         {
     222                 :          0 :                             rtl::OUString aURLStr;
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :                             if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( GetLink(), aURLStr ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     225                 :            :                             {
     226 [ #  # ][ #  # ]:          0 :                                 SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURLStr, STREAM_READ );
                 [ #  # ]
     227                 :            : 
     228         [ #  # ]:          0 :                                 if( pIStm )
     229                 :            :                                 {
     230         [ #  # ]:          0 :                                     (*pIStm) >> maGraphic;
     231         [ #  # ]:          0 :                                     mbAutoSwapped = ( maGraphic.GetType() != GRAPHIC_NONE );
     232 [ #  # ][ #  # ]:          0 :                                     delete pIStm;
     233                 :            :                                 }
     234                 :          0 :                             }
     235                 :            :                         }
     236                 :            :                     }
     237         [ #  # ]:          0 :                     else if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
     238                 :          0 :                         mbAutoSwapped = !maGraphic.SwapIn();
     239         [ #  # ]:          0 :                     else if( GRFMGR_AUTOSWAPSTREAM_LOADED == pStream )
     240                 :          0 :                         mbAutoSwapped = maGraphic.IsSwapOut();
     241                 :            :                     else
     242                 :            :                     {
     243                 :          0 :                         mbAutoSwapped = !maGraphic.SwapIn( pStream );
     244         [ #  # ]:          0 :                         delete pStream;
     245                 :            :                     }
     246                 :            :                 }
     247                 :            :                 else
     248                 :            :                 {
     249                 :            :                     DBG_ASSERT( ( GRAPHIC_NONE == meType ) || ( GRAPHIC_DEFAULT == meType ),
     250                 :            :                                 "GraphicObject::ImplAutoSwapIn: could not get stream to swap in graphic! (=>KA)" );
     251                 :            :                 }
     252                 :            :             }
     253                 :            : 
     254                 :          8 :             mbIsInSwapIn = sal_False;
     255                 :            : 
     256 [ +  + ][ +  - ]:          8 :             if( !mbAutoSwapped && mpMgr )
     257                 :          6 :                 mpMgr->ImplGraphicObjectWasSwappedIn( *this );
     258                 :            :         }
     259                 :            :     }
     260                 :         83 : }
     261                 :            : 
     262                 :          4 : sal_Bool GraphicObject::ImplGetCropParams( OutputDevice* pOut, Point& rPt, Size& rSz, const GraphicAttr* pAttr,
     263                 :            :                                        PolyPolygon& rClipPolyPoly, sal_Bool& bRectClipRegion ) const
     264                 :            : {
     265                 :          4 :     sal_Bool bRet = sal_False;
     266                 :            : 
     267         [ +  - ]:          4 :     if( GetType() != GRAPHIC_NONE )
     268                 :            :     {
     269 [ +  - ][ +  - ]:          4 :         Polygon         aClipPoly( Rectangle( rPt, rSz ) );
     270                 :          4 :         const sal_uInt16    nRot10 = pAttr->GetRotation() % 3600;
     271                 :          4 :         const Point     aOldOrigin( rPt );
     272         [ +  - ]:          4 :         const MapMode   aMap100( MAP_100TH_MM );
     273                 :          4 :         Size            aSize100;
     274                 :            :         long            nTotalWidth, nTotalHeight;
     275                 :            : 
     276         [ -  + ]:          4 :         if( nRot10 )
     277                 :            :         {
     278         [ #  # ]:          0 :             aClipPoly.Rotate( rPt, nRot10 );
     279                 :          0 :             bRectClipRegion = sal_False;
     280                 :            :         }
     281                 :            :         else
     282                 :          4 :             bRectClipRegion = sal_True;
     283                 :            : 
     284 [ +  - ][ +  - ]:          4 :         rClipPolyPoly = aClipPoly;
                 [ +  - ]
     285                 :            : 
     286 [ +  - ][ +  - ]:          4 :         if( maGraphic.GetPrefMapMode() == MAP_PIXEL )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     287 [ +  - ][ +  - ]:          4 :             aSize100 = Application::GetDefaultDevice()->PixelToLogic( maGraphic.GetPrefSize(), aMap100 );
                 [ +  - ]
     288                 :            :         else
     289                 :            :         {
     290         [ #  # ]:          0 :             MapMode m(maGraphic.GetPrefMapMode());
     291 [ #  # ][ #  # ]:          0 :             aSize100 = pOut->LogicToLogic( maGraphic.GetPrefSize(), &m, &aMap100 );
                 [ #  # ]
     292                 :            :         }
     293                 :            : 
     294                 :          4 :         nTotalWidth = aSize100.Width() - pAttr->GetLeftCrop() - pAttr->GetRightCrop();
     295                 :          4 :         nTotalHeight = aSize100.Height() - pAttr->GetTopCrop() - pAttr->GetBottomCrop();
     296                 :            : 
     297 [ #  # ][ #  # ]:          4 :         if( aSize100.Width() > 0 && aSize100.Height() > 0 && nTotalWidth > 0 && nTotalHeight > 0 )
         [ #  # ][ -  + ]
                 [ -  + ]
     298                 :            :         {
     299                 :          0 :             double fScale = (double) aSize100.Width() / nTotalWidth;
     300         [ #  # ]:          0 :             const long nNewLeft = -FRound( ( ( pAttr->GetMirrorFlags() & BMP_MIRROR_HORZ ) ? pAttr->GetRightCrop() : pAttr->GetLeftCrop() ) * fScale );
     301                 :          0 :             const long nNewRight = nNewLeft + FRound( aSize100.Width() * fScale ) - 1;
     302                 :            : 
     303                 :          0 :             fScale = (double) rSz.Width() / aSize100.Width();
     304                 :          0 :             rPt.X() += FRound( nNewLeft * fScale );
     305                 :          0 :             rSz.Width() = FRound( ( nNewRight - nNewLeft + 1 ) * fScale );
     306                 :            : 
     307                 :          0 :             fScale = (double) aSize100.Height() / nTotalHeight;
     308         [ #  # ]:          0 :             const long nNewTop = -FRound( ( ( pAttr->GetMirrorFlags() & BMP_MIRROR_VERT ) ? pAttr->GetBottomCrop() : pAttr->GetTopCrop() ) * fScale );
     309                 :          0 :             const long nNewBottom = nNewTop + FRound( aSize100.Height() * fScale ) - 1;
     310                 :            : 
     311                 :          0 :             fScale = (double) rSz.Height() / aSize100.Height();
     312                 :          0 :             rPt.Y() += FRound( nNewTop * fScale );
     313                 :          0 :             rSz.Height() = FRound( ( nNewBottom - nNewTop + 1 ) * fScale );
     314                 :            : 
     315         [ #  # ]:          0 :             if( nRot10 )
     316                 :            :             {
     317         [ #  # ]:          0 :                 Polygon aOriginPoly( 1 );
     318                 :            : 
     319         [ #  # ]:          0 :                 aOriginPoly[ 0 ] = rPt;
     320         [ #  # ]:          0 :                 aOriginPoly.Rotate( aOldOrigin, nRot10 );
     321 [ #  # ][ #  # ]:          0 :                 rPt = aOriginPoly[ 0 ];
     322                 :            :             }
     323                 :            : 
     324                 :          0 :             bRet = sal_True;
     325 [ +  - ][ +  - ]:          4 :         }
     326                 :            :     }
     327                 :            : 
     328                 :          4 :     return bRet;
     329                 :            : }
     330                 :            : 
     331                 :       5561 : GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
     332                 :            : {
     333         [ +  - ]:       5561 :     if( &rGraphicObj != this )
     334                 :            :     {
     335                 :       5561 :         mpMgr->ImplUnregisterObj( *this );
     336                 :            : 
     337                 :       5561 :         delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
     338         [ -  + ]:       5561 :         delete mpSimpleCache, mpSimpleCache = NULL;
     339         [ -  + ]:       5561 :         delete mpLink;
     340         [ -  + ]:       5561 :         delete mpUserData;
     341                 :            : 
     342                 :       5561 :         maGraphic = rGraphicObj.GetGraphic();
     343                 :       5561 :         maAttr = rGraphicObj.maAttr;
     344 [ #  # ][ -  + ]:       5561 :         mpLink = rGraphicObj.mpLink ? new String( *rGraphicObj.mpLink ) : NULL;
     345 [ +  + ][ +  - ]:       5561 :         mpUserData = rGraphicObj.mpUserData ? new String( *rGraphicObj.mpUserData ) : NULL;
     346                 :       5561 :         ImplAssignGraphicData();
     347                 :       5561 :         mbAutoSwapped = sal_False;
     348                 :       5561 :         mpMgr = rGraphicObj.mpMgr;
     349                 :            : 
     350                 :       5561 :         mpMgr->ImplRegisterObj( *this, maGraphic, NULL, &rGraphicObj );
     351                 :            :     }
     352                 :            : 
     353                 :       5561 :     return *this;
     354                 :            : }
     355                 :            : 
     356                 :         37 : sal_Bool GraphicObject::operator==( const GraphicObject& rGraphicObj ) const
     357                 :            : {
     358         [ +  - ]:         37 :     return( ( rGraphicObj.maGraphic == maGraphic ) &&
     359         [ +  - ]:         37 :             ( rGraphicObj.maAttr == maAttr ) &&
     360 [ +  - ][ +  - ]:         74 :             ( rGraphicObj.GetLink() == GetLink() ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
           [ #  #  #  # ]
     361                 :            : }
     362                 :            : 
     363                 :          0 : void GraphicObject::Load( SvStream& rIStm )
     364                 :            : {
     365                 :          0 :     rIStm >> *this;
     366                 :          0 : }
     367                 :            : 
     368                 :          0 : void GraphicObject::Save( SvStream& rOStm )
     369                 :            : {
     370                 :          0 :     rOStm << *this;
     371                 :          0 : }
     372                 :            : 
     373                 :          0 : void GraphicObject::Assign( const SvDataCopyStream& rCopyStream )
     374                 :            : {
     375                 :          0 :     *this = (const GraphicObject& ) rCopyStream;
     376                 :          0 : }
     377                 :            : 
     378                 :       5521 : rtl::OString GraphicObject::GetUniqueID() const
     379                 :            : {
     380 [ +  - ][ +  - ]:       5521 :     if ( !IsInSwapIn() && ( IsEPS() || IsRenderGraphic() ) )
         [ -  + ][ -  + ]
     381                 :          0 :         const_cast<GraphicObject*>(this)->FireSwapInRequest();
     382                 :            : 
     383                 :       5521 :     rtl::OString aRet;
     384                 :            : 
     385         [ +  - ]:       5521 :     if( mpMgr )
     386         [ +  - ]:       5521 :         aRet = mpMgr->ImplGetUniqueID( *this );
     387                 :            : 
     388                 :       5521 :     return aRet;
     389                 :            : }
     390                 :            : 
     391                 :      17602 : SvStream* GraphicObject::GetSwapStream() const
     392                 :            : {
     393         [ +  + ]:      17602 :     return( HasSwapStreamHdl() ? (SvStream*) mpSwapStreamHdl->Call( (void*) this ) : GRFMGR_AUTOSWAPSTREAM_NONE );
     394                 :            : }
     395                 :            : 
     396                 :          0 : void GraphicObject::SetAttr( const GraphicAttr& rAttr )
     397                 :            : {
     398                 :          0 :     maAttr = rAttr;
     399                 :            : 
     400 [ #  # ][ #  # ]:          0 :     if( mpSimpleCache && ( mpSimpleCache->maAttr != rAttr ) )
                 [ #  # ]
     401         [ #  # ]:          0 :         delete mpSimpleCache, mpSimpleCache = NULL;
     402                 :          0 : }
     403                 :            : 
     404                 :          0 : void GraphicObject::SetLink()
     405                 :            : {
     406         [ #  # ]:          0 :     if( mpLink )
     407         [ #  # ]:          0 :         delete mpLink, mpLink = NULL;
     408                 :          0 : }
     409                 :            : 
     410                 :         11 : void GraphicObject::SetLink( const String& rLink )
     411                 :            : {
     412 [ -  + ][ +  - ]:         11 :     delete mpLink, mpLink = new String( rLink );
     413                 :         11 : }
     414                 :            : 
     415                 :        102 : String GraphicObject::GetLink() const
     416                 :            : {
     417         [ +  + ]:        102 :     if( mpLink )
     418                 :         28 :         return *mpLink;
     419                 :            :     else
     420                 :        102 :         return String();
     421                 :            : }
     422                 :            : 
     423                 :         83 : void GraphicObject::SetUserData()
     424                 :            : {
     425         [ -  + ]:         83 :     if( mpUserData )
     426         [ #  # ]:          0 :         delete mpUserData, mpUserData = NULL;
     427                 :         83 : }
     428                 :            : 
     429                 :         10 : void GraphicObject::SetUserData( const String& rUserData )
     430                 :            : {
     431 [ -  + ][ +  - ]:         10 :     delete mpUserData, mpUserData = new String( rUserData );
     432                 :         10 : }
     433                 :            : 
     434                 :          0 : String GraphicObject::GetUserData() const
     435                 :            : {
     436         [ #  # ]:          0 :     if( mpUserData )
     437                 :          0 :         return *mpUserData;
     438                 :            :     else
     439                 :          0 :         return String();
     440                 :            : }
     441                 :            : 
     442                 :          0 : void GraphicObject::SetSwapStreamHdl()
     443                 :            : {
     444         [ #  # ]:          0 :     if( mpSwapStreamHdl )
     445                 :            :     {
     446         [ #  # ]:          0 :         delete mpSwapOutTimer, mpSwapOutTimer = NULL;
     447                 :          0 :         delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
     448                 :            :     }
     449                 :          0 : }
     450                 :            : 
     451                 :        252 : void GraphicObject::SetSwapStreamHdl( const Link& rHdl, const sal_uLong nSwapOutTimeout )
     452                 :            : {
     453                 :        252 :     delete mpSwapStreamHdl, mpSwapStreamHdl = new Link( rHdl );
     454                 :            : 
     455         [ +  + ]:        252 :     if( nSwapOutTimeout )
     456                 :            :     {
     457         [ +  + ]:        160 :         if( !mpSwapOutTimer )
     458                 :            :         {
     459         [ +  - ]:        118 :             mpSwapOutTimer = new Timer;
     460                 :        118 :             mpSwapOutTimer->SetTimeoutHdl( LINK( this, GraphicObject, ImplAutoSwapOutHdl ) );
     461                 :            :         }
     462                 :            : 
     463                 :        160 :         mpSwapOutTimer->SetTimeout( nSwapOutTimeout );
     464                 :        160 :         mpSwapOutTimer->Start();
     465                 :            :     }
     466                 :            :     else
     467         [ -  + ]:         92 :         delete mpSwapOutTimer, mpSwapOutTimer = NULL;
     468                 :        252 : }
     469                 :            : 
     470                 :         81 : void GraphicObject::FireSwapInRequest()
     471                 :            : {
     472                 :         81 :     ImplAutoSwapIn();
     473                 :         81 : }
     474                 :            : 
     475                 :      17608 : void GraphicObject::FireSwapOutRequest()
     476                 :            : {
     477                 :      17608 :     ImplAutoSwapOutHdl( NULL );
     478                 :      17608 : }
     479                 :            : 
     480                 :          0 : void GraphicObject::GraphicManagerDestroyed()
     481                 :            : {
     482                 :            :     // we're alive, but our manager doesn't live anymore ==> connect to default manager
     483                 :          0 :     mpMgr = NULL;
     484                 :          0 :     ImplSetGraphicManager( NULL );
     485                 :          0 : }
     486                 :            : 
     487                 :         30 : sal_Bool GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Size& rSz,
     488                 :            :                               const GraphicAttr* pAttr, sal_uLong nFlags ) const
     489                 :            : {
     490                 :            :     sal_Bool bRet;
     491                 :            : 
     492         [ +  - ]:         30 :     if( nFlags & GRFMGR_DRAW_CACHED )
     493                 :            :     {
     494                 :         30 :         Point aPt( rPt );
     495                 :         30 :         Size aSz( rSz );
     496         [ +  + ]:         30 :         if ( pAttr->IsCropped() )
     497                 :            :         {
     498         [ +  - ]:          4 :             PolyPolygon aClipPolyPoly;
     499                 :            :             sal_Bool        bRectClip;
     500 [ +  - ][ +  - ]:          4 :             ImplGetCropParams( pOut, aPt, aSz, pAttr, aClipPolyPoly, bRectClip );
     501                 :            :         }
     502 [ -  + ][ +  - ]:         30 :         bRet = mpMgr->IsInCache( pOut, aPt, aSz, *this, ( pAttr ? *pAttr : GetAttr() ) );
     503                 :            :     }
     504                 :            :     else
     505                 :          0 :         bRet = sal_False;
     506                 :            : 
     507                 :         30 :     return bRet;
     508                 :            : }
     509                 :            : 
     510                 :         48 : void GraphicObject::ReleaseFromCache()
     511                 :            : {
     512                 :            : 
     513                 :         48 :     mpMgr->ReleaseFromCache( *this );
     514                 :         48 : }
     515                 :            : 
     516                 :      17560 : bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
     517                 :            :                           const GraphicAttr* pAttr, sal_uLong nFlags )
     518                 :            : {
     519         [ -  + ]:      17560 :     GraphicAttr         aAttr( pAttr ? *pAttr : GetAttr() );
     520                 :      17560 :     Point               aPt( rPt );
     521                 :      17560 :     Size                aSz( rSz );
     522                 :      17560 :     const sal_uInt32    nOldDrawMode = pOut->GetDrawMode();
     523                 :      17560 :     sal_Bool                bCropped = aAttr.IsCropped();
     524                 :      17560 :     sal_Bool                bCached = sal_False;
     525                 :            :     bool bRet;
     526                 :            : 
     527                 :            :     // #i29534# Provide output rects for PDF writer
     528         [ +  - ]:      17560 :     Rectangle           aCropRect;
     529                 :            : 
     530         [ +  - ]:      17560 :     if( !( GRFMGR_DRAW_USE_DRAWMODE_SETTINGS & nFlags ) )
     531         [ +  - ]:      17560 :         pOut->SetDrawMode( nOldDrawMode & ( ~( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ) ) );
     532                 :            : 
     533                 :            :     // mirrored horizontically
     534         [ -  + ]:      17560 :     if( aSz.Width() < 0L )
     535                 :            :     {
     536                 :          0 :         aPt.X() += aSz.Width() + 1;
     537                 :          0 :         aSz.Width() = -aSz.Width();
     538                 :          0 :         aAttr.SetMirrorFlags( aAttr.GetMirrorFlags() ^ BMP_MIRROR_HORZ );
     539                 :            :     }
     540                 :            : 
     541                 :            :     // mirrored vertically
     542         [ -  + ]:      17560 :     if( aSz.Height() < 0L )
     543                 :            :     {
     544                 :          0 :         aPt.Y() += aSz.Height() + 1;
     545                 :          0 :         aSz.Height() = -aSz.Height();
     546                 :          0 :         aAttr.SetMirrorFlags( aAttr.GetMirrorFlags() ^ BMP_MIRROR_VERT );
     547                 :            :     }
     548                 :            : 
     549         [ -  + ]:      17560 :     if( bCropped )
     550                 :            :     {
     551         [ #  # ]:          0 :         PolyPolygon aClipPolyPoly;
     552                 :            :         sal_Bool        bRectClip;
     553         [ #  # ]:          0 :         const sal_Bool  bCrop = ImplGetCropParams( pOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip );
     554                 :            : 
     555         [ #  # ]:          0 :         pOut->Push( PUSH_CLIPREGION );
     556                 :            : 
     557         [ #  # ]:          0 :         if( bCrop )
     558                 :            :         {
     559         [ #  # ]:          0 :             if( bRectClip )
     560                 :            :             {
     561                 :            :                 // #i29534# Store crop rect for later forwarding to
     562                 :            :                 // PDF writer
     563         [ #  # ]:          0 :                 aCropRect = aClipPolyPoly.GetBoundRect();
     564         [ #  # ]:          0 :                 pOut->IntersectClipRegion( aCropRect );
     565                 :            :             }
     566                 :            :             else
     567                 :            :             {
     568 [ #  # ][ #  # ]:          0 :                 pOut->IntersectClipRegion( aClipPolyPoly );
                 [ #  # ]
     569                 :            :             }
     570         [ #  # ]:          0 :         }
     571                 :            :     }
     572                 :            : 
     573         [ +  - ]:      17560 :     bRet = mpMgr->DrawObj( pOut, aPt, aSz, *this, aAttr, nFlags, bCached );
     574                 :            : 
     575         [ -  + ]:      17560 :     if( bCropped )
     576         [ #  # ]:          0 :         pOut->Pop();
     577                 :            : 
     578         [ +  - ]:      17560 :     pOut->SetDrawMode( nOldDrawMode );
     579                 :            : 
     580                 :            :     // #i29534# Moved below OutDev restoration, to avoid multiple swap-ins
     581                 :            :     // (code above needs to call GetGraphic twice)
     582         [ +  + ]:      17560 :     if( bCached )
     583                 :            :     {
     584         [ -  + ]:      17535 :         if( mpSwapOutTimer )
     585         [ #  # ]:          0 :             mpSwapOutTimer->Start();
     586                 :            :         else
     587         [ +  - ]:      17535 :             FireSwapOutRequest();
     588                 :            :     }
     589                 :            : 
     590         [ +  - ]:      17560 :     return bRet;
     591                 :            : }
     592                 :            : 
     593                 :            : // #i105243#
     594                 :          3 : sal_Bool GraphicObject::DrawWithPDFHandling( OutputDevice& rOutDev,
     595                 :            :                                          const Point& rPt, const Size& rSz,
     596                 :            :                                          const GraphicAttr* pGrfAttr,
     597                 :            :                                          const sal_uLong nFlags )
     598                 :            : {
     599         [ -  + ]:          3 :     const GraphicAttr aGrfAttr( pGrfAttr ? *pGrfAttr : GetAttr() );
     600                 :            : 
     601                 :            :     // Notify PDF writer about linked graphic (if any)
     602                 :          3 :     sal_Bool bWritingPdfLinkedGraphic( sal_False );
     603                 :          3 :     Point aPt( rPt );
     604                 :          3 :     Size aSz( rSz );
     605         [ +  - ]:          3 :     Rectangle aCropRect;
     606                 :            :     vcl::PDFExtOutDevData* pPDFExtOutDevData =
     607         [ +  - ]:          3 :             dynamic_cast<vcl::PDFExtOutDevData*>(rOutDev.GetExtOutDevData());
     608         [ -  + ]:          3 :     if( pPDFExtOutDevData )
     609                 :            :     {
     610                 :            :         // only delegate image handling to PDF, if no special treatment is necessary
     611 [ #  # ][ #  # ]:          0 :         if( GetGraphic().IsLink() &&
           [ #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
              # ][ #  # ]
     612                 :          0 :             rSz.Width() > 0L &&
     613                 :          0 :             rSz.Height() > 0L &&
     614                 :          0 :             !aGrfAttr.IsSpecialDrawMode() &&
     615                 :          0 :             !aGrfAttr.IsMirrored() &&
     616                 :          0 :             !aGrfAttr.IsRotated() &&
     617                 :          0 :             !aGrfAttr.IsAdjusted() )
     618                 :            :         {
     619                 :          0 :             bWritingPdfLinkedGraphic = true;
     620                 :            : 
     621         [ #  # ]:          0 :             if( aGrfAttr.IsCropped() )
     622                 :            :             {
     623         [ #  # ]:          0 :                 PolyPolygon aClipPolyPoly;
     624                 :            :                 sal_Bool bRectClip;
     625                 :            :                 const sal_Bool bCrop = ImplGetCropParams( &rOutDev,
     626                 :            :                                                       aPt, aSz,
     627                 :            :                                                       &aGrfAttr,
     628                 :            :                                                       aClipPolyPoly,
     629         [ #  # ]:          0 :                                                       bRectClip );
     630 [ #  # ][ #  # ]:          0 :                 if ( bCrop && bRectClip )
     631                 :            :                 {
     632         [ #  # ]:          0 :                     aCropRect = aClipPolyPoly.GetBoundRect();
     633         [ #  # ]:          0 :                 }
     634                 :            :             }
     635                 :            : 
     636         [ #  # ]:          0 :             pPDFExtOutDevData->BeginGroup();
     637                 :            :         }
     638                 :            :     }
     639                 :            : 
     640         [ +  - ]:          3 :     sal_Bool bRet = Draw( &rOutDev, rPt, rSz, &aGrfAttr, nFlags );
     641                 :            : 
     642                 :            :     // Notify PDF writer about linked graphic (if any)
     643         [ -  + ]:          3 :     if( bWritingPdfLinkedGraphic )
     644                 :            :     {
     645         [ #  # ]:          0 :         pPDFExtOutDevData->EndGroup( const_cast< Graphic& >(GetGraphic()),
     646                 :          0 :                                      aGrfAttr.GetTransparency(),
     647                 :            :                                      Rectangle( aPt, aSz ),
     648 [ #  # ][ #  # ]:          0 :                                      aCropRect );
     649                 :            :     }
     650                 :            : 
     651         [ +  - ]:          3 :     return bRet;
     652                 :            : }
     653                 :            : 
     654                 :          0 : sal_Bool GraphicObject::DrawTiled( OutputDevice* pOut, const Rectangle& rArea, const Size& rSize,
     655                 :            :                                const Size& rOffset, const GraphicAttr* pAttr, sal_uLong nFlags, int nTileCacheSize1D )
     656                 :            : {
     657 [ #  # ][ #  # ]:          0 :     if( pOut == NULL || rSize.Width() == 0 || rSize.Height() == 0 )
         [ #  # ][ #  # ]
     658                 :          0 :         return sal_False;
     659                 :            : 
     660         [ #  # ]:          0 :     const MapMode   aOutMapMode( pOut->GetMapMode() );
     661         [ #  # ]:          0 :     const MapMode   aMapMode( aOutMapMode.GetMapUnit(), Point(), aOutMapMode.GetScaleX(), aOutMapMode.GetScaleY() );
     662                 :            :     // #106258# Clamp size to 1 for zero values. This is okay, since
     663                 :            :     // logical size of zero is handled above already
     664 [ #  # ][ #  # ]:          0 :     const Size      aOutTileSize( ::std::max( 1L, pOut->LogicToPixel( rSize, aOutMapMode ).Width() ),
     665 [ #  # ][ #  # ]:          0 :                                   ::std::max( 1L, pOut->LogicToPixel( rSize, aOutMapMode ).Height() ) );
     666                 :            : 
     667                 :            :     //#i69780 clip final tile size to a sane max size
     668         [ #  # ]:          0 :     while (((sal_Int64)rSize.Width() * nTileCacheSize1D) > SAL_MAX_UINT16)
     669                 :          0 :         nTileCacheSize1D /= 2;
     670         [ #  # ]:          0 :     while (((sal_Int64)rSize.Height() * nTileCacheSize1D) > SAL_MAX_UINT16)
     671                 :          0 :         nTileCacheSize1D /= 2;
     672                 :            : 
     673 [ #  # ][ #  # ]:          0 :     return ImplDrawTiled( pOut, rArea, aOutTileSize, rOffset, pAttr, nFlags, nTileCacheSize1D );
                 [ #  # ]
     674                 :            : }
     675                 :            : 
     676                 :          0 : sal_Bool GraphicObject::StartAnimation( OutputDevice* pOut, const Point& rPt, const Size& rSz,
     677                 :            :                                     long nExtraData, const GraphicAttr* pAttr, sal_uLong /*nFlags*/,
     678                 :            :                                     OutputDevice* pFirstFrameOutDev )
     679                 :            : {
     680                 :          0 :     sal_Bool bRet = sal_False;
     681                 :            : 
     682                 :          0 :     GetGraphic();
     683                 :            : 
     684         [ #  # ]:          0 :     if( !IsSwappedOut() )
     685                 :            :     {
     686         [ #  # ]:          0 :         const GraphicAttr aAttr( pAttr ? *pAttr : GetAttr() );
     687                 :            : 
     688         [ #  # ]:          0 :         if( mbAnimated )
     689                 :            :         {
     690                 :          0 :             Point   aPt( rPt );
     691                 :          0 :             Size    aSz( rSz );
     692                 :          0 :             sal_Bool    bCropped = aAttr.IsCropped();
     693                 :            : 
     694         [ #  # ]:          0 :             if( bCropped )
     695                 :            :             {
     696         [ #  # ]:          0 :                 PolyPolygon aClipPolyPoly;
     697                 :            :                 sal_Bool        bRectClip;
     698         [ #  # ]:          0 :                 const sal_Bool  bCrop = ImplGetCropParams( pOut, aPt, aSz, &aAttr, aClipPolyPoly, bRectClip );
     699                 :            : 
     700         [ #  # ]:          0 :                 pOut->Push( PUSH_CLIPREGION );
     701                 :            : 
     702         [ #  # ]:          0 :                 if( bCrop )
     703                 :            :                 {
     704         [ #  # ]:          0 :                     if( bRectClip )
     705 [ #  # ][ #  # ]:          0 :                         pOut->IntersectClipRegion( aClipPolyPoly.GetBoundRect() );
     706                 :            :                     else
     707 [ #  # ][ #  # ]:          0 :                         pOut->IntersectClipRegion( aClipPolyPoly );
                 [ #  # ]
     708         [ #  # ]:          0 :                 }
     709                 :            :             }
     710                 :            : 
     711 [ #  # ][ #  # ]:          0 :             if( !mpSimpleCache || ( mpSimpleCache->maAttr != aAttr ) || pFirstFrameOutDev )
         [ #  # ][ #  # ]
                 [ #  # ]
     712                 :            :             {
     713         [ #  # ]:          0 :                 if( mpSimpleCache )
     714 [ #  # ][ #  # ]:          0 :                     delete mpSimpleCache;
     715                 :            : 
     716 [ #  # ][ #  # ]:          0 :                 mpSimpleCache = new GrfSimpleCacheObj( GetTransformedGraphic( &aAttr ), aAttr );
         [ #  # ][ #  # ]
     717 [ #  # ][ #  # ]:          0 :                 mpSimpleCache->maGraphic.SetAnimationNotifyHdl( GetAnimationNotifyHdl() );
     718                 :            :             }
     719                 :            : 
     720         [ #  # ]:          0 :             mpSimpleCache->maGraphic.StartAnimation( pOut, aPt, aSz, nExtraData, pFirstFrameOutDev );
     721                 :            : 
     722         [ #  # ]:          0 :             if( bCropped )
     723         [ #  # ]:          0 :                 pOut->Pop();
     724                 :            : 
     725                 :          0 :             bRet = sal_True;
     726                 :            :         }
     727                 :            :         else
     728 [ #  # ][ #  # ]:          0 :             bRet = Draw( pOut, rPt, rSz, &aAttr, GRFMGR_DRAW_STANDARD );
     729                 :            :     }
     730                 :            : 
     731                 :          0 :     return bRet;
     732                 :            : }
     733                 :            : 
     734                 :          0 : void GraphicObject::StopAnimation( OutputDevice* pOut, long nExtraData )
     735                 :            : {
     736         [ #  # ]:          0 :     if( mpSimpleCache )
     737                 :          0 :         mpSimpleCache->maGraphic.StopAnimation( pOut, nExtraData );
     738                 :          0 : }
     739                 :            : 
     740                 :     158848 : const Graphic& GraphicObject::GetGraphic() const
     741                 :            : {
     742         [ +  + ]:     158848 :     if( mbAutoSwapped )
     743                 :          2 :         ( (GraphicObject*) this )->ImplAutoSwapIn();
     744                 :            : 
     745                 :     158848 :     return maGraphic;
     746                 :            : }
     747                 :            : 
     748                 :        245 : void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj )
     749                 :            : {
     750                 :        245 :     mpMgr->ImplUnregisterObj( *this );
     751                 :            : 
     752         [ +  + ]:        245 :     if( mpSwapOutTimer )
     753                 :         71 :         mpSwapOutTimer->Stop();
     754                 :            : 
     755                 :        245 :     maGraphic = rGraphic;
     756                 :        245 :     mbAutoSwapped = sal_False;
     757                 :        245 :     ImplAssignGraphicData();
     758         [ +  + ]:        245 :     delete mpLink, mpLink = NULL;
     759         [ -  + ]:        245 :     delete mpSimpleCache, mpSimpleCache = NULL;
     760                 :            : 
     761                 :        245 :     mpMgr->ImplRegisterObj( *this, maGraphic, 0, pCopyObj);
     762                 :            : 
     763         [ +  + ]:        245 :     if( mpSwapOutTimer )
     764                 :         71 :         mpSwapOutTimer->Start();
     765                 :        245 : }
     766                 :            : 
     767                 :         43 : void GraphicObject::SetGraphic( const Graphic& rGraphic, const String& rLink )
     768                 :            : {
     769                 :         43 :     SetGraphic( rGraphic );
     770         [ +  - ]:         43 :     mpLink = new String( rLink );
     771                 :         43 : }
     772                 :            : 
     773                 :          0 : Graphic GraphicObject::GetTransformedGraphic( const Size& rDestSize, const MapMode& rDestMap, const GraphicAttr& rAttr ) const
     774                 :            : {
     775                 :            :     // #104550# Extracted from svx/source/svdraw/svdograf.cxx
     776         [ #  # ]:          0 :     Graphic             aTransGraphic( maGraphic );
     777                 :          0 :     const GraphicType   eType = GetType();
     778         [ #  # ]:          0 :     const Size          aSrcSize( aTransGraphic.GetPrefSize() );
     779                 :            : 
     780                 :            :     // #104115# Convert the crop margins to graphic object mapmode
     781         [ #  # ]:          0 :     const MapMode aMapGraph( aTransGraphic.GetPrefMapMode() );
     782         [ #  # ]:          0 :     const MapMode aMap100( MAP_100TH_MM );
     783                 :            : 
     784                 :          0 :     Size aCropLeftTop;
     785                 :          0 :     Size aCropRightBottom;
     786                 :            : 
     787         [ #  # ]:          0 :     if( GRAPHIC_GDIMETAFILE == eType )
     788                 :            :     {
     789 [ #  # ][ #  # ]:          0 :         GDIMetaFile aMtf( aTransGraphic.GetGDIMetaFile() );
     790                 :            : 
     791 [ #  # ][ #  # ]:          0 :         if( aMapGraph == MAP_PIXEL )
         [ #  # ][ #  # ]
     792                 :            :         {
     793                 :            :             aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetLeftCrop(),
     794                 :            :                                                                                 rAttr.GetTopCrop() ),
     795 [ #  # ][ #  # ]:          0 :                                                                           aMap100 );
     796                 :            :             aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetRightCrop(),
     797                 :            :                                                                                     rAttr.GetBottomCrop() ),
     798 [ #  # ][ #  # ]:          0 :                                                                               aMap100 );
     799                 :            :         }
     800                 :            :         else
     801                 :            :         {
     802                 :            :             aCropLeftTop = OutputDevice::LogicToLogic( Size( rAttr.GetLeftCrop(),
     803                 :            :                                                              rAttr.GetTopCrop() ),
     804                 :            :                                                        aMap100,
     805         [ #  # ]:          0 :                                                        aMapGraph );
     806                 :            :             aCropRightBottom = OutputDevice::LogicToLogic( Size( rAttr.GetRightCrop(),
     807                 :            :                                                                  rAttr.GetBottomCrop() ),
     808                 :            :                                                            aMap100,
     809         [ #  # ]:          0 :                                                            aMapGraph );
     810                 :            :         }
     811                 :            : 
     812                 :            :         // #104115# If the metafile is cropped, give it a special
     813                 :            :         // treatment: clip against the remaining area, scale up such
     814                 :            :         // that this area later fills the desired size, and move the
     815                 :            :         // origin to the upper left edge of that area.
     816         [ #  # ]:          0 :         if( rAttr.IsCropped() )
     817                 :            :         {
     818         [ #  # ]:          0 :             const MapMode aMtfMapMode( aMtf.GetPrefMapMode() );
     819                 :            : 
     820                 :          0 :             Rectangle aClipRect( aMtfMapMode.GetOrigin().X() + aCropLeftTop.Width(),
     821                 :          0 :                                  aMtfMapMode.GetOrigin().Y() + aCropLeftTop.Height(),
     822                 :          0 :                                  aMtfMapMode.GetOrigin().X() + aSrcSize.Width() - aCropRightBottom.Width(),
     823         [ #  # ]:          0 :                                  aMtfMapMode.GetOrigin().Y() + aSrcSize.Height() - aCropRightBottom.Height() );
     824                 :            : 
     825                 :            :             // #104115# To correctly crop rotated metafiles, clip by view rectangle
     826 [ #  # ][ #  # ]:          0 :             aMtf.AddAction( new MetaISectRectClipRegionAction( aClipRect ), 0 );
                 [ #  # ]
     827                 :            : 
     828                 :            :             // #104115# To crop the metafile, scale larger than the output rectangle
     829                 :          0 :             aMtf.Scale( (double)rDestSize.Width() / (aSrcSize.Width() - aCropLeftTop.Width() - aCropRightBottom.Width()),
     830         [ #  # ]:          0 :                         (double)rDestSize.Height() / (aSrcSize.Height() - aCropLeftTop.Height() - aCropRightBottom.Height()) );
     831                 :            : 
     832                 :            :             // #104115# Adapt the pref size by hand (scale changes it
     833                 :            :             // proportionally, but we want it to be smaller than the
     834                 :            :             // former size, to crop the excess out)
     835                 :          0 :             aMtf.SetPrefSize( Size( (long)((double)rDestSize.Width() *  (1.0 + (aCropLeftTop.Width() + aCropRightBottom.Width()) / aSrcSize.Width())  + .5),
     836                 :          0 :                                     (long)((double)rDestSize.Height() * (1.0 + (aCropLeftTop.Height() + aCropRightBottom.Height()) / aSrcSize.Height()) + .5) ) );
     837                 :            : 
     838                 :            :             // #104115# Adapt the origin of the new mapmode, such that it
     839                 :            :             // is shifted to the place where the cropped output starts
     840                 :          0 :             Point aNewOrigin( (long)((double)aMtfMapMode.GetOrigin().X() + rDestSize.Width() * aCropLeftTop.Width() / (aSrcSize.Width() - aCropLeftTop.Width() - aCropRightBottom.Width()) + .5),
     841                 :          0 :                               (long)((double)aMtfMapMode.GetOrigin().Y() + rDestSize.Height() * aCropLeftTop.Height() / (aSrcSize.Height() - aCropLeftTop.Height() - aCropRightBottom.Height()) + .5) );
     842         [ #  # ]:          0 :             MapMode aNewMap( rDestMap );
     843 [ #  # ][ #  # ]:          0 :             aNewMap.SetOrigin( OutputDevice::LogicToLogic(aNewOrigin, aMtfMapMode, rDestMap) );
     844 [ #  # ][ #  # ]:          0 :             aMtf.SetPrefMapMode( aNewMap );
                 [ #  # ]
     845                 :            :         }
     846                 :            :         else
     847                 :            :         {
     848 [ #  # ][ #  # ]:          0 :             aMtf.Scale( Fraction( rDestSize.Width(), aSrcSize.Width() ), Fraction( rDestSize.Height(), aSrcSize.Height() ) );
                 [ #  # ]
     849         [ #  # ]:          0 :             aMtf.SetPrefMapMode( rDestMap );
     850                 :            :         }
     851                 :            : 
     852 [ #  # ][ #  # ]:          0 :         aTransGraphic = aMtf;
         [ #  # ][ #  # ]
     853                 :            :     }
     854         [ #  # ]:          0 :     else if( GRAPHIC_BITMAP == eType )
     855                 :            :     {
     856         [ #  # ]:          0 :         BitmapEx    aBitmapEx( aTransGraphic.GetBitmapEx() );
     857                 :            : 
     858                 :            :         // convert crops to pixel
     859                 :            :         aCropLeftTop = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetLeftCrop(),
     860                 :            :                                                                             rAttr.GetTopCrop() ),
     861 [ #  # ][ #  # ]:          0 :                                                                       aMap100 );
     862                 :            :         aCropRightBottom = Application::GetDefaultDevice()->LogicToPixel( Size( rAttr.GetRightCrop(),
     863                 :            :                                                                                 rAttr.GetBottomCrop() ),
     864 [ #  # ][ #  # ]:          0 :                                                                           aMap100 );
     865                 :            : 
     866                 :            :         // convert from prefmapmode to pixel
     867                 :            :         const Size aSrcSizePixel( Application::GetDefaultDevice()->LogicToPixel( aSrcSize,
     868 [ #  # ][ #  # ]:          0 :                                                                                  aMapGraph ) );
     869                 :            : 
     870                 :            :         // setup crop rectangle in pixel
     871                 :          0 :         Rectangle aCropRect( aCropLeftTop.Width(), aCropLeftTop.Height(),
     872                 :          0 :                              aSrcSizePixel.Width() - aCropRightBottom.Width(),
     873         [ #  # ]:          0 :                              aSrcSizePixel.Height() - aCropRightBottom.Height() );
     874                 :            : 
     875                 :            :         // #105641# Also crop animations
     876 [ #  # ][ #  # ]:          0 :         if( aTransGraphic.IsAnimated() )
     877                 :            :         {
     878                 :            :             sal_uInt16 nFrame;
     879         [ #  # ]:          0 :             Animation aAnim( aTransGraphic.GetAnimation() );
     880                 :            : 
     881         [ #  # ]:          0 :             for( nFrame=0; nFrame<aAnim.Count(); ++nFrame )
     882                 :            :             {
     883 [ #  # ][ #  # ]:          0 :                 AnimationBitmap aAnimBmp( aAnim.Get( nFrame ) );
     884                 :            : 
     885 [ #  # ][ #  # ]:          0 :                 if( !aCropRect.IsInside( Rectangle(aAnimBmp.aPosPix, aAnimBmp.aSizePix) ) )
                 [ #  # ]
     886                 :            :                 {
     887                 :            :                     // setup actual cropping (relative to frame position)
     888                 :          0 :                     Rectangle aCropRectRel( aCropRect );
     889                 :          0 :                     aCropRectRel.Move( -aAnimBmp.aPosPix.X(),
     890         [ #  # ]:          0 :                                        -aAnimBmp.aPosPix.Y() );
     891                 :            : 
     892                 :            :                     // cropping affects this frame, apply it then
     893                 :            :                     // do _not_ apply enlargement, this is done below
     894                 :            :                     ImplTransformBitmap( aAnimBmp.aBmpEx, rAttr, Size(), Size(),
     895         [ #  # ]:          0 :                                          aCropRectRel, rDestSize, sal_False );
     896                 :            : 
     897         [ #  # ]:          0 :                     aAnim.Replace( aAnimBmp, nFrame );
     898                 :            :                 }
     899                 :            :                 // else: bitmap completely within crop area,
     900                 :            :                 // i.e. nothing is cropped away
     901         [ #  # ]:          0 :             }
     902                 :            : 
     903                 :            :             // now, apply enlargement (if any) through global animation size
     904   [ #  #  #  #  :          0 :             if( aCropLeftTop.Width() < 0 ||
             #  #  #  # ]
                 [ #  # ]
     905                 :          0 :                 aCropLeftTop.Height() < 0 ||
     906                 :          0 :                 aCropRightBottom.Width() < 0 ||
     907                 :          0 :                 aCropRightBottom.Height() < 0 )
     908                 :            :             {
     909                 :          0 :                 Size aNewSize( aAnim.GetDisplaySizePixel() );
     910         [ #  # ]:          0 :                 aNewSize.Width() += aCropRightBottom.Width() < 0 ? -aCropRightBottom.Width() : 0;
     911         [ #  # ]:          0 :                 aNewSize.Width() += aCropLeftTop.Width() < 0 ? -aCropLeftTop.Width() : 0;
     912         [ #  # ]:          0 :                 aNewSize.Height() += aCropRightBottom.Height() < 0 ? -aCropRightBottom.Height() : 0;
     913         [ #  # ]:          0 :                 aNewSize.Height() += aCropLeftTop.Height() < 0 ? -aCropLeftTop.Height() : 0;
     914                 :          0 :                 aAnim.SetDisplaySizePixel( aNewSize );
     915                 :            :             }
     916                 :            : 
     917                 :            :             // if topleft has changed, we must move all frames to the
     918                 :            :             // right and bottom, resp.
     919   [ #  #  #  # ]:          0 :             if( aCropLeftTop.Width() < 0 ||
                 [ #  # ]
     920                 :          0 :                 aCropLeftTop.Height() < 0 )
     921                 :            :             {
     922                 :          0 :                 Point aPosOffset( aCropLeftTop.Width() < 0 ? -aCropLeftTop.Width() : 0,
     923 [ #  # ][ #  # ]:          0 :                                   aCropLeftTop.Height() < 0 ? -aCropLeftTop.Height() : 0 );
     924                 :            : 
     925         [ #  # ]:          0 :                 for( nFrame=0; nFrame<aAnim.Count(); ++nFrame )
     926                 :            :                 {
     927 [ #  # ][ #  # ]:          0 :                     AnimationBitmap aAnimBmp( aAnim.Get( nFrame ) );
     928                 :            : 
     929                 :          0 :                     aAnimBmp.aPosPix += aPosOffset;
     930                 :            : 
     931         [ #  # ]:          0 :                     aAnim.Replace( aAnimBmp, nFrame );
     932         [ #  # ]:          0 :                 }
     933                 :            :             }
     934                 :            : 
     935 [ #  # ][ #  # ]:          0 :             aTransGraphic = aAnim;
         [ #  # ][ #  # ]
     936                 :            :         }
     937                 :            :         else
     938                 :            :         {
     939         [ #  # ]:          0 :             BitmapEx aBmpEx( aTransGraphic.GetBitmapEx() );
     940                 :            : 
     941                 :            :             ImplTransformBitmap( aBmpEx, rAttr, aCropLeftTop, aCropRightBottom,
     942         [ #  # ]:          0 :                                  aCropRect, rDestSize, sal_True );
     943                 :            : 
     944 [ #  # ][ #  # ]:          0 :             aTransGraphic = aBmpEx;
         [ #  # ][ #  # ]
     945                 :            :         }
     946                 :            : 
     947         [ #  # ]:          0 :         aTransGraphic.SetPrefSize( rDestSize );
     948 [ #  # ][ #  # ]:          0 :         aTransGraphic.SetPrefMapMode( rDestMap );
     949                 :            :     }
     950                 :            : 
     951         [ #  # ]:          0 :     GraphicObject aGrfObj( aTransGraphic );
     952 [ #  # ][ #  # ]:          0 :     aTransGraphic = aGrfObj.GetTransformedGraphic( &rAttr );
                 [ #  # ]
     953                 :            : 
     954 [ #  # ][ #  # ]:          0 :     return aTransGraphic;
                 [ #  # ]
     955                 :            : }
     956                 :            : 
     957                 :        123 : Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const // TODO: Change to Impl
     958                 :            : {
     959         [ +  - ]:        123 :     GetGraphic();
     960                 :            : 
     961         [ +  - ]:        123 :     Graphic     aGraphic;
     962         [ +  + ]:        123 :     GraphicAttr aAttr( pAttr ? *pAttr : GetAttr() );
     963                 :            : 
     964 [ +  - ][ +  - ]:        123 :     if( maGraphic.IsSupportedGraphic() && !maGraphic.IsSwapOut() )
         [ +  - ][ +  - ]
                 [ +  - ]
     965                 :            :     {
     966 [ +  - ][ +  - ]:        123 :         if( aAttr.IsSpecialDrawMode() || aAttr.IsAdjusted() || aAttr.IsMirrored() || aAttr.IsRotated() || aAttr.IsTransparent() )
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
     967                 :            :         {
     968         [ #  # ]:          0 :             if( GetType() == GRAPHIC_BITMAP )
     969                 :            :             {
     970         [ #  # ]:          0 :                 if( IsAnimated() )
     971                 :            :                 {
     972         [ #  # ]:          0 :                     Animation aAnimation( maGraphic.GetAnimation() );
     973         [ #  # ]:          0 :                     GraphicManager::ImplAdjust( aAnimation, aAttr, ADJUSTMENT_ALL );
     974         [ #  # ]:          0 :                     aAnimation.SetLoopCount( mnAnimationLoopCount );
     975 [ #  # ][ #  # ]:          0 :                     aGraphic = aAnimation;
         [ #  # ][ #  # ]
     976                 :            :                 }
     977                 :            :                 else
     978                 :            :                 {
     979         [ #  # ]:          0 :                     BitmapEx aBmpEx( maGraphic.GetBitmapEx() );
     980         [ #  # ]:          0 :                     GraphicManager::ImplAdjust( aBmpEx, aAttr, ADJUSTMENT_ALL );
     981 [ #  # ][ #  # ]:          0 :                     aGraphic = aBmpEx;
         [ #  # ][ #  # ]
     982                 :            :                 }
     983                 :            :             }
     984                 :            :             else
     985                 :            :             {
     986 [ #  # ][ #  # ]:          0 :                 GDIMetaFile aMtf( maGraphic.GetGDIMetaFile() );
     987         [ #  # ]:          0 :                 GraphicManager::ImplAdjust( aMtf, aAttr, ADJUSTMENT_ALL );
     988 [ #  # ][ #  # ]:          0 :                 aGraphic = aMtf;
         [ #  # ][ #  # ]
     989                 :            :             }
     990                 :            :         }
     991                 :            :         else
     992                 :            :         {
     993 [ +  + ][ -  + ]:        123 :             if( ( GetType() == GRAPHIC_BITMAP ) && IsAnimated() )
                 [ -  + ]
     994                 :            :             {
     995         [ #  # ]:          0 :                 Animation aAnimation( maGraphic.GetAnimation() );
     996         [ #  # ]:          0 :                 aAnimation.SetLoopCount( mnAnimationLoopCount );
     997 [ #  # ][ #  # ]:          0 :                 aGraphic = aAnimation;
         [ #  # ][ #  # ]
     998                 :            :             }
     999                 :            :             else
    1000         [ +  - ]:        123 :                 aGraphic = maGraphic;
    1001                 :            :         }
    1002                 :            :     }
    1003                 :            : 
    1004         [ +  - ]:        123 :     return aGraphic;
    1005                 :            : }
    1006                 :            : 
    1007                 :         15 : sal_Bool GraphicObject::SwapOut()
    1008                 :            : {
    1009         [ +  - ]:         15 :     sal_Bool bRet = ( !mbAutoSwapped ? maGraphic.SwapOut() : sal_False );
    1010                 :            : 
    1011 [ +  - ][ +  - ]:         15 :     if( bRet && mpMgr )
    1012                 :         15 :         mpMgr->ImplGraphicObjectWasSwappedOut( *this );
    1013                 :            : 
    1014                 :         15 :     return bRet;
    1015                 :            : }
    1016                 :            : 
    1017                 :          0 : sal_Bool GraphicObject::SwapOut( SvStream* pOStm )
    1018                 :            : {
    1019         [ #  # ]:          0 :     sal_Bool bRet = ( !mbAutoSwapped ? maGraphic.SwapOut( pOStm ) : sal_False );
    1020                 :            : 
    1021 [ #  # ][ #  # ]:          0 :     if( bRet && mpMgr )
    1022                 :          0 :         mpMgr->ImplGraphicObjectWasSwappedOut( *this );
    1023                 :            : 
    1024                 :          0 :     return bRet;
    1025                 :            : }
    1026                 :            : 
    1027                 :          0 : sal_Bool GraphicObject::SwapIn()
    1028                 :            : {
    1029                 :            :     sal_Bool bRet;
    1030                 :            : 
    1031         [ #  # ]:          0 :     if( mbAutoSwapped )
    1032                 :            :     {
    1033                 :          0 :         ImplAutoSwapIn();
    1034                 :          0 :         bRet = sal_True;
    1035                 :            :     }
    1036 [ #  # ][ #  # ]:          0 :     else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
                 [ #  # ]
    1037                 :          0 :         bRet = sal_True;
    1038                 :            :     else
    1039                 :            :     {
    1040                 :          0 :         bRet = maGraphic.SwapIn();
    1041                 :            : 
    1042 [ #  # ][ #  # ]:          0 :         if( bRet && mpMgr )
    1043                 :          0 :             mpMgr->ImplGraphicObjectWasSwappedIn( *this );
    1044                 :            :     }
    1045                 :            : 
    1046         [ #  # ]:          0 :     if( bRet )
    1047                 :          0 :         ImplAssignGraphicData();
    1048                 :            : 
    1049                 :          0 :     return bRet;
    1050                 :            : }
    1051                 :            : 
    1052                 :          0 : sal_Bool GraphicObject::SwapIn( SvStream* pIStm )
    1053                 :            : {
    1054                 :            :     sal_Bool bRet;
    1055                 :            : 
    1056         [ #  # ]:          0 :     if( mbAutoSwapped )
    1057                 :            :     {
    1058                 :          0 :         ImplAutoSwapIn();
    1059                 :          0 :         bRet = sal_True;
    1060                 :            :     }
    1061 [ #  # ][ #  # ]:          0 :     else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
                 [ #  # ]
    1062                 :          0 :         bRet = sal_True;
    1063                 :            :     else
    1064                 :            :     {
    1065                 :          0 :         bRet = maGraphic.SwapIn( pIStm );
    1066                 :            : 
    1067 [ #  # ][ #  # ]:          0 :         if( bRet && mpMgr )
    1068                 :          0 :             mpMgr->ImplGraphicObjectWasSwappedIn( *this );
    1069                 :            :     }
    1070                 :            : 
    1071         [ #  # ]:          0 :     if( bRet )
    1072                 :          0 :         ImplAssignGraphicData();
    1073                 :            : 
    1074                 :          0 :     return bRet;
    1075                 :            : }
    1076                 :            : 
    1077                 :         12 : void GraphicObject::SetSwapState()
    1078                 :            : {
    1079         [ +  - ]:         12 :     if( !IsSwappedOut() )
    1080                 :            :     {
    1081                 :         12 :         mbAutoSwapped = sal_True;
    1082                 :            : 
    1083         [ +  - ]:         12 :         if( mpMgr )
    1084                 :         12 :             mpMgr->ImplGraphicObjectWasSwappedOut( *this );
    1085                 :            :     }
    1086                 :         12 : }
    1087                 :            : 
    1088                 :          0 : IMPL_LINK_NOARG(GraphicObject, ImplAutoSwapOutHdl)
    1089                 :            : {
    1090         [ +  + ]:      17608 :     if( !IsSwappedOut() )
    1091                 :            :     {
    1092                 :      17600 :         mbIsInSwapOut = sal_True;
    1093                 :            : 
    1094                 :      17600 :         SvStream* pStream = GetSwapStream();
    1095                 :            : 
    1096         [ +  + ]:      17600 :         if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream )
    1097                 :            :         {
    1098         [ -  + ]:         15 :             if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream )
    1099                 :          0 :                 mbAutoSwapped = SwapOut( NULL );
    1100                 :            :             else
    1101                 :            :             {
    1102         [ +  - ]:         15 :                 if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream )
    1103                 :         15 :                     mbAutoSwapped = SwapOut();
    1104                 :            :                 else
    1105                 :            :                 {
    1106                 :          0 :                     mbAutoSwapped = SwapOut( pStream );
    1107         [ #  # ]:          0 :                     delete pStream;
    1108                 :            :                 }
    1109                 :            :             }
    1110                 :            :         }
    1111                 :            : 
    1112                 :      17600 :         mbIsInSwapOut = sal_False;
    1113                 :            :     }
    1114                 :            : 
    1115         [ +  + ]:      17608 :     if( mpSwapOutTimer )
    1116                 :         73 :         mpSwapOutTimer->Start();
    1117                 :            : 
    1118                 :      17608 :     return 0L;
    1119                 :            : }
    1120                 :            : 
    1121                 :          0 : SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj )
    1122                 :            : {
    1123         [ #  # ]:          0 :     VersionCompat   aCompat( rIStm, STREAM_READ );
    1124         [ #  # ]:          0 :     Graphic         aGraphic;
    1125         [ #  # ]:          0 :     GraphicAttr     aAttr;
    1126                 :            :     sal_Bool            bLink;
    1127                 :            : 
    1128 [ #  # ][ #  # ]:          0 :     rIStm >> aGraphic >> aAttr >> bLink;
                 [ #  # ]
    1129                 :            : 
    1130         [ #  # ]:          0 :     rGraphicObj.SetGraphic( aGraphic );
    1131         [ #  # ]:          0 :     rGraphicObj.SetAttr( aAttr );
    1132                 :            : 
    1133         [ #  # ]:          0 :     if( bLink )
    1134                 :            :     {
    1135         [ #  # ]:          0 :         rtl::OUString aLink = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIStm, RTL_TEXTENCODING_UTF8);
    1136 [ #  # ][ #  # ]:          0 :         rGraphicObj.SetLink(aLink);
                 [ #  # ]
    1137                 :            :     }
    1138                 :            :     else
    1139         [ #  # ]:          0 :         rGraphicObj.SetLink();
    1140                 :            : 
    1141         [ #  # ]:          0 :     rGraphicObj.SetSwapStreamHdl();
    1142                 :            : 
    1143 [ #  # ][ #  # ]:          0 :     return rIStm;
                 [ #  # ]
    1144                 :            : }
    1145                 :            : 
    1146                 :          0 : SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj )
    1147                 :            : {
    1148         [ #  # ]:          0 :     VersionCompat   aCompat( rOStm, STREAM_WRITE, 1 );
    1149                 :          0 :     const sal_Bool      bLink =  rGraphicObj.HasLink();
    1150                 :            : 
    1151 [ #  # ][ #  # ]:          0 :     rOStm << rGraphicObj.GetGraphic() << rGraphicObj.GetAttr() << bLink;
         [ #  # ][ #  # ]
    1152                 :            : 
    1153         [ #  # ]:          0 :     if( bLink )
    1154 [ #  # ][ #  # ]:          0 :         write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rOStm, rGraphicObj.GetLink(), RTL_TEXTENCODING_UTF8);
         [ #  # ][ #  # ]
    1155                 :            : 
    1156         [ #  # ]:          0 :     return rOStm;
    1157                 :            : }
    1158                 :            : 
    1159                 :            : #define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
    1160                 :            : 
    1161                 :        330 : GraphicObject GraphicObject::CreateGraphicObjectFromURL( const ::rtl::OUString &rURL )
    1162                 :            : {
    1163 [ +  - ][ +  - ]:        330 :     const String aURL( rURL ), aPrefix( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX) );
    1164 [ +  - ][ +  - ]:        330 :     if( aURL.Search( aPrefix ) == 0 )
    1165                 :            :     {
    1166                 :            :         // graphic manager url
    1167         [ +  - ]:        330 :         rtl::OString aUniqueID(rtl::OUStringToOString(rURL.copy(sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX) - 1), RTL_TEXTENCODING_UTF8));
    1168         [ +  - ]:        330 :         return GraphicObject( aUniqueID );
    1169                 :            :     }
    1170                 :            :     else
    1171                 :            :     {
    1172         [ #  # ]:          0 :         Graphic     aGraphic;
    1173         [ #  # ]:          0 :         if ( aURL.Len() )
    1174                 :            :         {
    1175         [ #  # ]:          0 :             SvStream*   pStream = utl::UcbStreamHelper::CreateStream( aURL, STREAM_READ );
    1176         [ #  # ]:          0 :             if( pStream )
    1177         [ #  # ]:          0 :                 GraphicConverter::Import( *pStream, aGraphic );
    1178                 :            :         }
    1179                 :            : 
    1180 [ #  # ][ #  # ]:          0 :         return GraphicObject( aGraphic );
    1181 [ +  - ][ +  - ]:        330 :     }
    1182                 :            : }
    1183                 :            : 
    1184                 :            : void
    1185                 :          0 : GraphicObject::InspectForGraphicObjectImageURL( const Reference< XInterface >& xIf,  std::vector< rtl::OUString >& rvEmbedImgUrls )
    1186                 :            : {
    1187 [ #  # ][ #  # ]:          0 :     static rtl::OUString sImageURL(RTL_CONSTASCII_USTRINGPARAM( "ImageURL" ) );
         [ #  # ][ #  # ]
    1188         [ #  # ]:          0 :     Reference< XPropertySet > xProps( xIf, UNO_QUERY );
    1189         [ #  # ]:          0 :     if ( xProps.is() )
    1190                 :            :     {
    1191                 :            : 
    1192 [ #  # ][ #  # ]:          0 :         if ( xProps->getPropertySetInfo()->hasPropertyByName( sImageURL ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1193                 :            :         {
    1194                 :          0 :             rtl::OUString sURL;
    1195 [ #  # ][ #  # ]:          0 :             xProps->getPropertyValue( sImageURL ) >>= sURL;
    1196 [ #  # ][ #  # ]:          0 :             if ( !sURL.isEmpty() && sURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
                 [ #  # ]
    1197         [ #  # ]:          0 :                 rvEmbedImgUrls.push_back( sURL );
    1198                 :            :         }
    1199                 :            :     }
    1200         [ #  # ]:          0 :     Reference< XNameContainer > xContainer( xIf, UNO_QUERY );
    1201         [ #  # ]:          0 :     if ( xContainer.is() )
    1202                 :            :     {
    1203 [ #  # ][ #  # ]:          0 :         Sequence< rtl::OUString > sNames = xContainer->getElementNames();
    1204                 :          0 :         sal_Int32 nContainees = sNames.getLength();
    1205         [ #  # ]:          0 :         for ( sal_Int32 index = 0; index < nContainees; ++index )
    1206                 :            :         {
    1207                 :          0 :             Reference< XInterface > xCtrl;
    1208 [ #  # ][ #  # ]:          0 :             xContainer->getByName( sNames[ index ] ) >>= xCtrl;
         [ #  # ][ #  # ]
    1209         [ #  # ]:          0 :             InspectForGraphicObjectImageURL( xCtrl, rvEmbedImgUrls );
    1210         [ #  # ]:          0 :         }
    1211                 :          0 :     }
    1212                 :          0 : }
    1213                 :            : 
    1214                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10