LCOV - code coverage report
Current view: top level - include/svtools - grfmgr.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 49 62 79.0 %
Date: 2015-06-13 12:38:46 Functions: 42 55 76.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SVTOOLS_GRFMGR_HXX
      21             : #define INCLUDED_SVTOOLS_GRFMGR_HXX
      22             : 
      23             : #include <vcl/graph.hxx>
      24             : #include <svtools/svtdllapi.h>
      25             : #include <o3tl/typed_flags_set.hxx>
      26             : 
      27             : enum class GraphicManagerDrawFlags
      28             : {
      29             :     CACHED                  = 0x01,
      30             :     SMOOTHSCALE             = 0x02,
      31             :     USE_DRAWMODE_SETTINGS   = 0x04,
      32             :     SUBSTITUTE              = 0x08,
      33             :     NO_SUBSTITUTE           = 0x10,
      34             :     STANDARD                = (CACHED|SMOOTHSCALE),
      35             : };
      36             : namespace o3tl
      37             : {
      38             :     template<> struct typed_flags<GraphicManagerDrawFlags> : is_typed_flags<GraphicManagerDrawFlags, 0x1f> {};
      39             : }
      40             : 
      41             : // AutoSwap defines
      42             : 
      43             : #define GRFMGR_AUTOSWAPSTREAM_LINK nullptr
      44             : #define GRFMGR_AUTOSWAPSTREAM_LOADED reinterpret_cast<SvStream*>(sal_IntPtr(-3))
      45             : #define GRFMGR_AUTOSWAPSTREAM_TEMP   reinterpret_cast<SvStream*>(sal_IntPtr(-2))
      46             : #define GRFMGR_AUTOSWAPSTREAM_NONE   reinterpret_cast<SvStream*>(sal_IntPtr(-1))
      47             : 
      48             : // Adjustment defines
      49             : enum class GraphicAdjustmentFlags
      50             : {
      51             :     NONE                 = 0x00,
      52             :     DRAWMODE             = 0x01,
      53             :     COLORS               = 0x02,
      54             :     MIRROR               = 0x04,
      55             :     ROTATE               = 0x08,
      56             :     TRANSPARENCY         = 0x10,
      57             :     ALL                  = 0x1f,
      58             : };
      59             : namespace o3tl
      60             : {
      61             :     template<> struct typed_flags<GraphicAdjustmentFlags> : is_typed_flags<GraphicAdjustmentFlags, 0x1f> {};
      62             : }
      63             : 
      64             : enum GraphicDrawMode
      65             : {
      66             :     GRAPHICDRAWMODE_STANDARD = 0,
      67             :     GRAPHICDRAWMODE_GREYS = 1,
      68             :     GRAPHICDRAWMODE_MONO = 2,
      69             :     GRAPHICDRAWMODE_WATERMARK = 3
      70             : };
      71             : 
      72             : class GraphicManager;
      73             : class SvStream;
      74             : class BitmapWriteAccess;
      75             : class GraphicCache;
      76             : class VirtualDevice;
      77             : struct GrfSimpleCacheObj;
      78             : struct ImplTileInfo;
      79             : 
      80             : class SVT_DLLPUBLIC GraphicAttr
      81             : {
      82             : private:
      83             : 
      84             :     double          mfGamma;
      85             :     BmpMirrorFlags  mnMirrFlags;
      86             :     long            mnLeftCrop;
      87             :     long            mnTopCrop;
      88             :     long            mnRightCrop;
      89             :     long            mnBottomCrop;
      90             :     sal_uInt16      mnRotate10;
      91             :     short           mnContPercent;
      92             :     short           mnLumPercent;
      93             :     short           mnRPercent;
      94             :     short           mnGPercent;
      95             :     short           mnBPercent;
      96             :     bool            mbInvert;
      97             :     sal_uInt8       mcTransparency;
      98             :     GraphicDrawMode meDrawMode;
      99             : 
     100             : public:
     101             : 
     102             :                     GraphicAttr();
     103             :                     ~GraphicAttr();
     104             : 
     105             :     bool            operator==( const GraphicAttr& rAttr ) const;
     106           0 :     bool            operator!=( const GraphicAttr& rAttr ) const { return !( *this == rAttr ); }
     107             : 
     108        4693 :     void            SetDrawMode( GraphicDrawMode eDrawMode ) { meDrawMode = eDrawMode; }
     109         304 :     GraphicDrawMode GetDrawMode() const { return meDrawMode; }
     110             : 
     111         405 :     void            SetMirrorFlags( BmpMirrorFlags nMirrFlags ) { mnMirrFlags = nMirrFlags; }
     112           0 :     BmpMirrorFlags  GetMirrorFlags() const { return mnMirrFlags; }
     113             : 
     114        4997 :     void            SetCrop( long nLeft_100TH_MM, long nTop_100TH_MM, long nRight_100TH_MM, long nBottom_100TH_MM )
     115             :                     {
     116        4997 :                         mnLeftCrop = nLeft_100TH_MM; mnTopCrop = nTop_100TH_MM;
     117        4997 :                         mnRightCrop = nRight_100TH_MM; mnBottomCrop = nBottom_100TH_MM;
     118        4997 :                     }
     119           6 :     long            GetLeftCrop() const { return mnLeftCrop; }
     120           6 :     long            GetTopCrop() const { return mnTopCrop; }
     121           6 :     long            GetRightCrop() const { return mnRightCrop; }
     122           6 :     long            GetBottomCrop() const { return mnBottomCrop; }
     123             : 
     124        1587 :     void            SetRotation( sal_uInt16 nRotate10 ) { mnRotate10 = nRotate10; }
     125           0 :     sal_uInt16      GetRotation() const { return mnRotate10; }
     126             : 
     127        4693 :     void            SetLuminance( short nLuminancePercent ) { mnLumPercent = nLuminancePercent; }
     128           0 :     short           GetLuminance() const { return mnLumPercent; }
     129             : 
     130        4693 :     void            SetContrast( short nContrastPercent ) { mnContPercent = nContrastPercent; }
     131           0 :     short           GetContrast() const { return mnContPercent; }
     132             : 
     133        4693 :     void            SetChannelR( short nChannelRPercent ) { mnRPercent = nChannelRPercent; }
     134           0 :     short           GetChannelR() const { return mnRPercent; }
     135             : 
     136        4693 :     void            SetChannelG( short nChannelGPercent ) { mnGPercent = nChannelGPercent; }
     137           0 :     short           GetChannelG() const { return mnGPercent; }
     138             : 
     139        4693 :     void            SetChannelB( short nChannelBPercent ) { mnBPercent = nChannelBPercent; }
     140           0 :     short           GetChannelB() const { return mnBPercent; }
     141             : 
     142        4693 :     void            SetGamma( double fGamma ) { mfGamma = fGamma; }
     143           0 :     double          GetGamma() const { return mfGamma; }
     144             : 
     145        4693 :     void            SetInvert( bool bInvert ) { mbInvert = bInvert; }
     146           0 :     bool            IsInvert() const { return mbInvert; }
     147             : 
     148        5074 :     void            SetTransparency( sal_uInt8 cTransparency ) { mcTransparency = cTransparency; }
     149        2167 :     sal_uInt8       GetTransparency() const { return mcTransparency; }
     150             : 
     151         255 :     bool            IsSpecialDrawMode() const { return( meDrawMode != GRAPHICDRAWMODE_STANDARD ); }
     152         559 :     bool            IsMirrored() const { return mnMirrFlags != BmpMirrorFlags::NONE; }
     153         274 :     bool            IsCropped() const
     154             :                     {
     155         816 :                         return( mnLeftCrop != 0 || mnTopCrop != 0 ||
     156         816 :                                 mnRightCrop != 0 || mnBottomCrop != 0 );
     157             :                     }
     158         255 :     bool            IsRotated() const { return( ( mnRotate10 % 3600 ) != 0 ); }
     159         529 :     bool            IsTransparent() const { return( mcTransparency > 0 ); }
     160         559 :     bool            IsAdjusted() const
     161             :                     {
     162        1677 :                         return( mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 ||
     163        1677 :                                 mnGPercent != 0 || mnBPercent != 0 || mfGamma != 1.0 || mbInvert );
     164             :                     }
     165             : 
     166             :     friend SvStream& WriteGraphicAttr( SvStream& rOStm, const GraphicAttr& rAttr );
     167             :     friend SvStream& ReadGraphicAttr( SvStream& rIStm, GraphicAttr& rAttr );
     168             : };
     169             : 
     170             : class SVT_DLLPUBLIC GraphicObject : public SvDataCopyStream
     171             : {
     172             :     friend class GraphicManager;
     173             :     friend class SdrGrafObj;
     174             : 
     175             : private:
     176             : 
     177             :     static GraphicManager*  mpGlobalMgr;
     178             : 
     179             :     Graphic                 maGraphic;
     180             :     GraphicAttr             maAttr;
     181             :     Size                    maPrefSize;
     182             :     MapMode                 maPrefMapMode;
     183             :     sal_uLong               mnSizeBytes;
     184             :     GraphicType             meType;
     185             :     GraphicManager*         mpMgr;
     186             :     OUString                maLink;
     187             :     Link<>*                 mpSwapStreamHdl;
     188             :     OUString                maUserData;
     189             :     Timer*                  mpSwapOutTimer;
     190             :     GrfSimpleCacheObj*      mpSimpleCache;
     191             :     sal_uLong               mnAnimationLoopCount;
     192             : 
     193             :     // a unique increasing ID to be able to say which data change is older
     194             :     sal_uLong               mnDataChangeTimeStamp;
     195             : 
     196             :     bool                    mbAutoSwapped   : 1;
     197             :     bool                    mbTransparent   : 1;
     198             :     bool                    mbAnimated      : 1;
     199             :     bool                    mbEPS           : 1;
     200             :     bool                    mbIsInSwapIn    : 1;
     201             :     bool                    mbIsInSwapOut   : 1;
     202             :     bool                    mbAlpha         : 1;
     203             : 
     204             :     void                    SVT_DLLPRIVATE ImplConstruct();
     205             :     void                    SVT_DLLPRIVATE ImplAssignGraphicData();
     206             :     void                    SVT_DLLPRIVATE ImplSetGraphicManager(
     207             :                                 const GraphicManager* pMgr,
     208             :                                 const OString* pID = NULL,
     209             :                                 const GraphicObject* pCopyObj = NULL
     210             :                             );
     211             :     void                    SVT_DLLPRIVATE ImplAutoSwapIn();
     212             :     bool                    SVT_DLLPRIVATE ImplIsAutoSwapped() const { return mbAutoSwapped; }
     213             :     bool                    SVT_DLLPRIVATE ImplGetCropParams(
     214             :                                 OutputDevice* pOut,
     215             :                                 Point& rPt,
     216             :                                 Size& rSz,
     217             :                                 const GraphicAttr* pAttr,
     218             :                                 tools::PolyPolygon& rClipPolyPoly,
     219             :                                 bool& bRectClipRegion
     220             :                             ) const;
     221             : 
     222             :     /** Render a given number of tiles in an optimized way
     223             : 
     224             :         This method recursively subdivides the tile rendering problem
     225             :         in smaller parts, i.e. rendering output size x with few tiles
     226             :         of size y, which in turn are generated from the original
     227             :         bitmap in a recursive fashion. The subdivision size can be
     228             :         controlled by the exponent argument, which specifies the
     229             :         minimal number of smaller tiles used in one recursion
     230             :         step. The resulting tile size is given as the integer number
     231             :         of repetitions of the original bitmap along x and y. As the
     232             :         exponent need not necessarily divide these numbers without
     233             :         remainder, the repetition counts are effectively converted to
     234             :         base-exponent numbers, where each place denotes the number of
     235             :         times the corresponding tile size is rendered.
     236             : 
     237             :         @param rVDev
     238             :         Virtual device to render everything into
     239             : 
     240             :         @param nExponent
     241             :         Number of repetitions per subdivision step, _must_ be greater than 1
     242             : 
     243             :         @param nNumTilesX
     244             :         Number of original tiles to generate in x direction
     245             : 
     246             :         @param nNumTilesY
     247             :         Number of original tiles to generate in y direction
     248             : 
     249             :         @param rTileSizePixel
     250             :         Size in pixel of the original tile bitmap to render it in
     251             : 
     252             :         @param pAttr
     253             :         Graphic attributes to be used for rendering
     254             : 
     255             :         @param nFlags
     256             :         Graphic flags to be used for rendering
     257             : 
     258             :         @param rCurrPos
     259             :         Current output point for this recursion level (should start with (0,0))
     260             : 
     261             :         @return true, if everything was successfully rendered.
     262             :     */
     263             :     bool SVT_DLLPRIVATE     ImplRenderTempTile(
     264             :                                 VirtualDevice& rVDev,
     265             :                                 int nExponent,
     266             :                                 int nNumTilesX,
     267             :                                 int nNumTilesY,
     268             :                                 const Size& rTileSizePixel,
     269             :                                 const GraphicAttr* pAttr,
     270             :                                 GraphicManagerDrawFlags nFlags
     271             :                             );
     272             : 
     273             :     /// internally called by ImplRenderTempTile()
     274             :     bool SVT_DLLPRIVATE     ImplRenderTileRecursive(
     275             :                                 VirtualDevice& rVDev,
     276             :                                 int nExponent,
     277             :                                 int nMSBFactor,
     278             :                                 int nNumOrigTilesX,
     279             :                                 int nNumOrigTilesY,
     280             :                                 int nRemainderTilesX,
     281             :                                 int nRemainderTilesY,
     282             :                                 const Size& rTileSizePixel,
     283             :                                 const GraphicAttr* pAttr,
     284             :                                 GraphicManagerDrawFlags nFlags,
     285             :                                 ImplTileInfo& rTileInfo
     286             :                             );
     287             : 
     288             :     bool SVT_DLLPRIVATE     ImplDrawTiled(
     289             :                                 OutputDevice* pOut,
     290             :                                 const Rectangle& rArea,
     291             :                                 const Size& rSizePixel,
     292             :                                 const Size& rOffset,
     293             :                                 const GraphicAttr* pAttr,
     294             :                                 GraphicManagerDrawFlags nFlags,
     295             :                                 int nTileCacheSize1D
     296             :                             );
     297             : 
     298             :     bool SVT_DLLPRIVATE     ImplDrawTiled(
     299             :                                 OutputDevice& rOut,
     300             :                                 const Point& rPos,
     301             :                                 int nNumTilesX,
     302             :                                 int nNumTilesY,
     303             :                                 const Size& rTileSize,
     304             :                                 const GraphicAttr* pAttr,
     305             :                                 GraphicManagerDrawFlags nFlags
     306             :                             );
     307             : 
     308             :     void SVT_DLLPRIVATE     ImplTransformBitmap(
     309             :                                 BitmapEx&           rBmpEx,
     310             :                                 const GraphicAttr&  rAttr,
     311             :                                 const Size&         rCropLeftTop,
     312             :                                 const Size&         rCropRightBottom,
     313             :                                 const Rectangle&    rCropRect,
     314             :                                 const Size&         rDstSize,
     315             :                                 bool                bEnlarge
     316             :                             ) const;
     317             : 
     318             :                             DECL_LINK_TYPED( ImplAutoSwapOutHdl, Timer*, void );
     319             : 
     320             :     // restart SwapOut timer; this is like touching in a cache to reset to the full timeout value
     321             :     void SVT_DLLPRIVATE     restartSwapOutTimer() const;
     322             : 
     323             :     // Handle evtl. needed AfterDataChanges, needs to be called when new
     324             :     // graphic data is swapped in/added to the GraphicManager
     325             :     void SVT_DLLPRIVATE     ImplAfterDataChange();
     326             : protected:
     327             : 
     328             :     void                    GraphicManagerDestroyed();
     329             :     SvStream*               GetSwapStream() const;
     330             :     void                    SetSwapState();
     331             : 
     332             :     virtual void            Load( SvStream& ) SAL_OVERRIDE;
     333             :     virtual void            Save( SvStream& ) SAL_OVERRIDE;
     334             :     virtual void            Assign( const SvDataCopyStream& ) SAL_OVERRIDE;
     335             : 
     336             : public:
     337             : 
     338             :                             TYPEINFO_OVERRIDE();
     339             : 
     340             :                             GraphicObject( const GraphicManager* pMgr = NULL );
     341             :                             GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr = NULL );
     342             :                             GraphicObject( const GraphicObject& rCacheObj, const GraphicManager* pMgr = NULL );
     343             :                             explicit GraphicObject( const OString& rUniqueID, const GraphicManager* pMgr = NULL );
     344             :                             virtual ~GraphicObject();
     345             : 
     346             :     GraphicObject&          operator=( const GraphicObject& rCacheObj );
     347             :     bool                    operator==( const GraphicObject& rCacheObj ) const;
     348           0 :     bool                    operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); }
     349             : 
     350         470 :     bool                    HasSwapStreamHdl() const { return( mpSwapStreamHdl != NULL && mpSwapStreamHdl->IsSet() ); }
     351             :     void                    SetSwapStreamHdl();
     352             :     void                    SetSwapStreamHdl(const Link<>& rHdl);
     353             :     sal_uLong               GetSwapOutTimeout() const { return( mpSwapOutTimer ? mpSwapOutTimer->GetTimeout() : 0 ); }
     354             : 
     355             :     void                    FireSwapInRequest();
     356             :     void                    FireSwapOutRequest();
     357             : 
     358          52 :     GraphicManager&         GetGraphicManager() const { return *mpMgr; }
     359             : 
     360             :     bool                    IsCached(
     361             :                                 OutputDevice* pOut,
     362             :                                 const Point& rPt,
     363             :                                 const Size& rSz,
     364             :                                 const GraphicAttr* pAttr = NULL,
     365             :                                 GraphicManagerDrawFlags nFlags = GraphicManagerDrawFlags::STANDARD
     366             :                             ) const;
     367             : 
     368             :     const Graphic&          GetGraphic() const;
     369             :     void                    SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = 0);
     370             :     void                    SetGraphic( const Graphic& rGraphic, const OUString& rLink );
     371             : 
     372             :     /** Get graphic transformed according to given attributes
     373             : 
     374             :         This method returns a Graphic transformed, cropped and scaled
     375             :         to the given parameters, ready to be rendered to printer or
     376             :         display. The returned graphic has the same visual appearance
     377             :         as if it had been drawn via GraphicObject::Draw() to a
     378             :         specific output device.
     379             : 
     380             :         @param rDestSize
     381             :         Desired output size in logical coordinates. The mapmode to
     382             :         interpret these logical coordinates in is given by the second
     383             :         parameter, rDestMap.
     384             : 
     385             :         @param rDestMap
     386             :         Mapmode the output should be interpreted in. This is used to
     387             :         interpret rDestSize, to set the appropriate PrefMapMode on the
     388             :         returned Graphic, and to deal correctly with metafile graphics.
     389             : 
     390             :         @param rAttr
     391             :         Graphic attributes used to transform the graphic. This
     392             :         includes cropping, rotation, mirroring, and various color
     393             :         adjustment parameters.
     394             : 
     395             :         @return the readily transformed Graphic
     396             :      */
     397             :     Graphic                 GetTransformedGraphic(
     398             :                                 const Size& rDestSize,
     399             :                                 const MapMode& rDestMap,
     400             :                                 const GraphicAttr& rAttr
     401             :                             ) const;
     402             :     Graphic                 GetTransformedGraphic( const GraphicAttr* pAttr = NULL ) const; // TODO: Change to Impl
     403             : 
     404             :     void                    SetAttr( const GraphicAttr& rAttr );
     405         333 :     const GraphicAttr&      GetAttr() const { return maAttr; }
     406             : 
     407           0 :     bool                    HasLink() const { return !maLink.isEmpty(); }
     408             :     void                    SetLink();
     409             :     void                    SetLink( const OUString& rLink );
     410       19452 :     OUString                GetLink() const { return maLink; }
     411             : 
     412       11541 :     bool                    HasUserData() const { return !maUserData.isEmpty(); }
     413             :     void                    SetUserData();
     414             :     void                    SetUserData( const OUString& rUserData );
     415         241 :     OUString                GetUserData() const { return maUserData; }
     416             : 
     417             :     OString                 GetUniqueID() const;
     418             : 
     419       32354 :     GraphicType             GetType() const { return meType; }
     420         358 :     const Size&             GetPrefSize() const { return maPrefSize; }
     421         359 :     const MapMode&          GetPrefMapMode() const { return maPrefMapMode; }
     422        3133 :     sal_uLong               GetSizeBytes() const { return mnSizeBytes; }
     423         122 :     bool                    IsTransparent() const { return mbTransparent; }
     424             :     bool                    IsAlpha() const { return mbAlpha; }
     425        2568 :     bool                    IsAnimated() const { return mbAnimated; }
     426        2371 :     bool                    IsEPS() const { return mbEPS; }
     427             : 
     428           0 :     Link<>                  GetAnimationNotifyHdl() const { return GetGraphic().GetAnimationNotifyHdl(); }
     429             : 
     430             :     bool                    SwapOut();
     431             :     bool                    SwapOut( SvStream* pOStm );
     432             :     bool                    SwapIn();
     433             : 
     434        2429 :     bool                    IsInSwapIn() const { return mbIsInSwapIn; }
     435         234 :     bool                    IsInSwapOut() const { return mbIsInSwapOut; }
     436       91150 :     bool                    IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); }
     437             : 
     438             :     bool                    Draw(
     439             :                                 OutputDevice* pOut,
     440             :                                 const Point& rPt,
     441             :                                 const Size& rSz,
     442             :                                 const GraphicAttr* pAttr = NULL,
     443             :                                 GraphicManagerDrawFlags nFlags = GraphicManagerDrawFlags::STANDARD
     444             :                             );
     445             : 
     446             :     /** Draw the graphic repeatedly into the given output rectangle
     447             : 
     448             :         @param pOut
     449             :         OutputDevice where the rendering should take place
     450             : 
     451             :         @param rArea
     452             :         The output area that is filled with tiled instances of this graphic
     453             : 
     454             :         @param rSize
     455             :         The actual size of a single tile
     456             : 
     457             :         @param rOffset
     458             :         Offset from the left, top position of rArea, where to start
     459             :         the tiling. The upper left corner of the graphic tilings will
     460             :         virtually start at this position. Concretely, only that many
     461             :         tiles are drawn to completely fill the given output area.
     462             : 
     463             :         @param pAttr
     464             :         Optional GraphicAttr
     465             : 
     466             :         @param nFlags
     467             :         Optional rendering flags
     468             : 
     469             :         @param nTileCacheSize1D
     470             :         Optional dimension of the generated cache tiles. The pOut sees
     471             :         a number of tile draws, which have approximately
     472             :         nTileCacheSize1D times nTileCacheSize1D bitmap sizes if the
     473             :         tile bitmap is smaller. Otherwise, the tile is drawn as
     474             :         is. This is useful if e.g. you want only a few, very large
     475             :         bitmap drawings appear on the outdev.
     476             : 
     477             :         @return sal_True, if drawing completed successfully
     478             :      */
     479             :     bool                    DrawTiled(
     480             :                                 OutputDevice* pOut,
     481             :                                 const Rectangle& rArea,
     482             :                                 const Size& rSize,
     483             :                                 const Size& rOffset,
     484             :                                 const GraphicAttr* pAttr = NULL,
     485             :                                 GraphicManagerDrawFlags nFlags = GraphicManagerDrawFlags::STANDARD,
     486             :                                 int nTileCacheSize1D=128
     487             :                             );
     488             : 
     489             :     bool                    StartAnimation(
     490             :                                 OutputDevice* pOut,
     491             :                                 const Point& rPt,
     492             :                                 const Size& rSz,
     493             :                                 long nExtraData = 0L,
     494             :                                 const GraphicAttr* pAttr = NULL,
     495             :                                 GraphicManagerDrawFlags nFlags = GraphicManagerDrawFlags::STANDARD,
     496             :                                 OutputDevice* pFirstFrameOutDev = NULL
     497             :                             );
     498             : 
     499             :     void                    StopAnimation( OutputDevice* pOut = NULL, long nExtraData = 0L );
     500             : 
     501             :     friend SvStream&        WriteGraphicObject( SvStream& rOStm, const GraphicObject& rGraphicObj );
     502             :     friend SvStream&        ReadGraphicObject( SvStream& rIStm, GraphicObject& rGraphicObj );
     503             : 
     504             :     static GraphicObject    CreateGraphicObjectFromURL( const OUString &rURL );
     505             :     // will inspect an object ( e.g. a control ) for any 'ImageURL'
     506             :     // properties and return these in a vector. Note: this implementation
     507             :     // will cater for XNameContainer objects and deepinspect any containees
     508             :     // if they exist
     509             :     static void InspectForGraphicObjectImageURL( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIf, std::vector< OUString >& rvEmbedImgUrls );
     510             : 
     511             :     // create CropScaling information
     512             :     // fWidth, fHeight: object size
     513             :     // f*Crop: crop values relative to original bitmap size
     514             :     basegfx::B2DVector calculateCropScaling(
     515             :         double fWidth,
     516             :         double fHeight,
     517             :         double fLeftCrop,
     518             :         double fTopCrop,
     519             :         double fRightCrop,
     520             :         double fBottomCrop) const;
     521             : 
     522             :     // read access
     523       10854 :     sal_uLong GetDataChangeTimeStamp() const { return mnDataChangeTimeStamp; }
     524             : };
     525             : 
     526             : typedef ::std::vector< GraphicObject* > GraphicObjectList_impl;
     527             : 
     528             : class SVT_DLLPUBLIC GraphicManager
     529             : {
     530             :     friend class GraphicObject;
     531             :     friend class GraphicDisplayCacheEntry;
     532             : 
     533             : private:
     534             : 
     535             :     GraphicObjectList_impl  maObjList;
     536             :     sal_uLong               mnUsedSize; // currently used memory footprint of all swapped in graphics
     537             :     GraphicCache*           mpCache;
     538             : 
     539             :                         GraphicManager( const GraphicManager& ) {}
     540             :     GraphicManager&     operator=( const GraphicManager& ) { return *this; }
     541             : 
     542             :     bool SVT_DLLPRIVATE ImplDraw(
     543             :                             OutputDevice* pOut,
     544             :                             const Point& rPt,
     545             :                             const Size& rSz,
     546             :                             GraphicObject& rObj,
     547             :                             const GraphicAttr& rAttr,
     548             :                             const GraphicManagerDrawFlags nFlags,
     549             :                             bool& rCached
     550             :                         );
     551             : 
     552             :     static bool SVT_DLLPRIVATE ImplCreateOutput(
     553             :                             OutputDevice* pOut,
     554             :                             const Point& rPt,
     555             :                             const Size& rSz,
     556             :                             const BitmapEx& rBmpEx,
     557             :                             const GraphicAttr& rAttr,
     558             :                             const GraphicManagerDrawFlags nFlags,
     559             :                             BitmapEx* pBmpEx = NULL
     560             :                         );
     561             :     static bool SVT_DLLPRIVATE ImplCreateOutput(
     562             :                             OutputDevice* pOut,
     563             :                             const Point& rPt,
     564             :                             const Size& rSz,
     565             :                             const GDIMetaFile& rMtf,
     566             :                             const GraphicAttr& rAttr,
     567             :                             const GraphicManagerDrawFlags nFlags,
     568             :                             GDIMetaFile& rOutMtf,
     569             :                             BitmapEx& rOutBmpEx
     570             :                         );
     571             : 
     572             :     static void SVT_DLLPRIVATE ImplAdjust(
     573             :                             BitmapEx& rBmpEx,
     574             :                             const GraphicAttr& rAttr,
     575             :                             GraphicAdjustmentFlags nAdjustmentFlags
     576             :                         );
     577             :     static void SVT_DLLPRIVATE ImplAdjust(
     578             :                             GDIMetaFile& rMtf,
     579             :                             const GraphicAttr& rAttr,
     580             :                             GraphicAdjustmentFlags nAdjustmentFlags
     581             :                         );
     582             :     static void SVT_DLLPRIVATE ImplAdjust(
     583             :                             Animation& rAnimation,
     584             :                             const GraphicAttr& rAttr,
     585             :                             GraphicAdjustmentFlags nAdjustmentFlags
     586             :                         );
     587             : 
     588             :     static void SVT_DLLPRIVATE ImplDraw(
     589             :                             OutputDevice* pOut,
     590             :                             const Point& rPt,
     591             :                             const Size& rSz,
     592             :                             const GDIMetaFile& rMtf,
     593             :                             const GraphicAttr& rAttr
     594             :                         );
     595             : 
     596             :                     // Only used by GraphicObject's Ctor's and Dtor's
     597             :     void SVT_DLLPRIVATE ImplRegisterObj(
     598             :                             const GraphicObject& rObj,
     599             :                             Graphic& rSubstitute,
     600             :                             const OString* pID = NULL,
     601             :                             const GraphicObject* pCopyObj = NULL
     602             :                         );
     603             :     void SVT_DLLPRIVATE ImplUnregisterObj( const GraphicObject& rObj );
     604       20028 :     inline bool SVT_DLLPRIVATE ImplHasObjects() const { return !maObjList.empty(); }
     605             : 
     606             :                     // Only used in swap case by GraphicObject
     607             :     void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj );
     608             :     void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj );
     609             : 
     610             :     OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const;
     611             : 
     612             :     // This method allows to check memory footprint for all currently swapped in GraphicObjects on this GraphicManager
     613             :     // which are based on Bitmaps. This is needed on 32Bit systems and only does something on those systems. The problem
     614             :     // to solve is that normally the SwapOut is timer-driven, but even with short timer settings there are situations
     615             :     // where this does not trigger - or in other words: A maximum limitation for GraphicManagers was not in place before.
     616             :     // For 32Bit systems this leads to situations where graphics will be missing. This method will actively swap out
     617             :     // the longest swapped in graphics until a maximum memory boundary (derived from user settings in tools/options/memory)
     618             :     // is no longer exceeded
     619             :     void SVT_DLLPRIVATE ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGraphicToIgnore);
     620             : public:
     621             : 
     622             :                         GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
     623             :                         ~GraphicManager();
     624             : 
     625             :     void                SetMaxCacheSize( sal_uLong nNewCacheSize );
     626             :     sal_uLong           GetMaxCacheSize() const;
     627             : 
     628             :     void                SetMaxObjCacheSize(
     629             :                             sal_uLong nNewMaxObjSize,
     630             :                             bool bDestroyGreaterCached = false
     631             :                         );
     632             : 
     633             :     void                SetCacheTimeout( sal_uLong nTimeoutSeconds );
     634             : 
     635             :     bool                IsInCache(
     636             :                             OutputDevice* pOut,
     637             :                             const Point& rPt,
     638             :                             const Size& rSz,
     639             :                             const GraphicObject& rObj,
     640             :                             const GraphicAttr& rAttr
     641             :                         ) const;
     642             : 
     643             :     bool                DrawObj(
     644             :                             OutputDevice* pOut,
     645             :                             const Point& rPt,
     646             :                             const Size& rSz,
     647             :                             GraphicObject& rObj,
     648             :                             const GraphicAttr& rAttr,
     649             :                             const GraphicManagerDrawFlags nFlags,
     650             :                             bool& rCached
     651             :                         );
     652             : };
     653             : 
     654             : #endif // INCLUDED_SVTOOLS_GRFMGR_HXX
     655             : 
     656             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11