1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _GRFMGR_HXX 25 #define _GRFMGR_HXX 26 27 #include <vcl/graph.hxx> 28 #include <svtools/svtdllapi.h> 29 30 // ----------- 31 // - Defines - 32 // ----------- 33 34 #define GRFMGR_DRAW_NOTCACHED 0x00000000UL 35 #define GRFMGR_DRAW_CACHED 0x00000001UL 36 #define GRFMGR_DRAW_BILINEAR 0x00000002UL 37 #define GRFMGR_DRAW_USE_DRAWMODE_SETTINGS 0x00000004UL 38 #define GRFMGR_DRAW_SUBSTITUTE 0x00000008UL 39 #define GRFMGR_DRAW_NO_SUBSTITUTE 0x00000010UL 40 #define GRFMGR_DRAW_STANDARD (GRFMGR_DRAW_CACHED|GRFMGR_DRAW_BILINEAR) 41 42 // -------------------- 43 // - AutoSwap Defines - 44 // -------------------- 45 46 /* These four are not streams: they are sentinels that a swap handler returns 47 in place of one. The handler hands them back through Link::Call(), whose 48 return type is long -- 32 bit on Windows x64 -- so a 64-bit pointer value 49 makes the round trip only if it survives truncation to long and the cast 50 back. Spelling the sentinels as negative sal_IntPtr does that: the bits 51 are unchanged where long is pointer-sized, and where it is not, the cast 52 back sign-extends to exactly these values, so the comparisons in 53 GraphicObject::ImplAutoSwapOutHdl()/ImplAutoSwapIn() still match. Written 54 as 0xffffffffUL they did not, and _NONE arrived there as a stream to write 55 to. */ 56 #define GRFMGR_AUTOSWAPSTREAM_LINK ((SvStream*)(sal_IntPtr) 0) 57 #define GRFMGR_AUTOSWAPSTREAM_LOADED ((SvStream*)(sal_IntPtr)-3) 58 #define GRFMGR_AUTOSWAPSTREAM_TEMP ((SvStream*)(sal_IntPtr)-2) 59 #define GRFMGR_AUTOSWAPSTREAM_NONE ((SvStream*)(sal_IntPtr)-1) 60 61 // ---------------------- 62 // - Adjustment Defines - 63 // ---------------------- 64 65 #define ADJUSTMENT_NONE 0x00000000UL 66 #define ADJUSTMENT_DRAWMODE 0x00000001UL 67 #define ADJUSTMENT_COLORS 0x00000002UL 68 #define ADJUSTMENT_MIRROR 0x00000004UL 69 #define ADJUSTMENT_ROTATE 0x00000008UL 70 #define ADJUSTMENT_TRANSPARENCY 0x00000010UL 71 #define ADJUSTMENT_ALL 0xFFFFFFFFUL 72 73 // --------- 74 // - Enums - 75 // --------- 76 77 enum GraphicDrawMode 78 { 79 GRAPHICDRAWMODE_STANDARD = 0, 80 GRAPHICDRAWMODE_GREYS = 1, 81 GRAPHICDRAWMODE_MONO = 2, 82 GRAPHICDRAWMODE_WATERMARK = 3 83 }; 84 85 // ------------ 86 // - Forwards - 87 // ------------ 88 89 class GraphicManager; 90 class SvStream; 91 class BitmapWriteAccess; 92 class GraphicCache; 93 class VirtualDevice; 94 struct GrfSimpleCacheObj; 95 struct ImplTileInfo; 96 97 // --------------- 98 // - GraphicAttr - 99 // --------------- 100 101 class SVT_DLLPUBLIC GraphicAttr 102 { 103 private: 104 105 long mnDummy1; 106 long mnDummy2; 107 double mfGamma; 108 sal_uInt32 mnMirrFlags; 109 long mnLeftCrop; 110 long mnTopCrop; 111 long mnRightCrop; 112 long mnBottomCrop; 113 sal_uInt16 mnRotate10; 114 short mnContPercent; 115 short mnLumPercent; 116 short mnRPercent; 117 short mnGPercent; 118 short mnBPercent; 119 sal_Bool mbInvert; 120 sal_uInt8 mcTransparency; 121 GraphicDrawMode meDrawMode; 122 123 void* mpDummy; 124 125 public: 126 127 GraphicAttr(); 128 ~GraphicAttr(); 129 130 sal_Bool operator==( const GraphicAttr& rAttr ) const; operator !=(const GraphicAttr & rAttr) const131 sal_Bool operator!=( const GraphicAttr& rAttr ) const { return !( *this == rAttr ); } 132 SetDrawMode(GraphicDrawMode eDrawMode)133 void SetDrawMode( GraphicDrawMode eDrawMode ) { meDrawMode = eDrawMode; } GetDrawMode() const134 GraphicDrawMode GetDrawMode() const { return meDrawMode; } 135 SetMirrorFlags(sal_uLong nMirrFlags)136 void SetMirrorFlags( sal_uLong nMirrFlags ) { mnMirrFlags = nMirrFlags; } GetMirrorFlags() const137 sal_uLong GetMirrorFlags() const { return mnMirrFlags; } 138 SetCrop(long nLeft_100TH_MM,long nTop_100TH_MM,long nRight_100TH_MM,long nBottom_100TH_MM)139 void SetCrop( long nLeft_100TH_MM, long nTop_100TH_MM, long nRight_100TH_MM, long nBottom_100TH_MM ) 140 { 141 mnLeftCrop = nLeft_100TH_MM; mnTopCrop = nTop_100TH_MM; 142 mnRightCrop = nRight_100TH_MM; mnBottomCrop = nBottom_100TH_MM; 143 } GetLeftCrop() const144 long GetLeftCrop() const { return mnLeftCrop; } GetTopCrop() const145 long GetTopCrop() const { return mnTopCrop; } GetRightCrop() const146 long GetRightCrop() const { return mnRightCrop; } GetBottomCrop() const147 long GetBottomCrop() const { return mnBottomCrop; } 148 SetRotation(sal_uInt16 nRotate10)149 void SetRotation( sal_uInt16 nRotate10 ) { mnRotate10 = nRotate10; } GetRotation() const150 sal_uInt16 GetRotation() const { return mnRotate10; } 151 SetLuminance(short nLuminancePercent)152 void SetLuminance( short nLuminancePercent ) { mnLumPercent = nLuminancePercent; } GetLuminance() const153 short GetLuminance() const { return mnLumPercent; } 154 SetContrast(short nContrastPercent)155 void SetContrast( short nContrastPercent ) { mnContPercent = nContrastPercent; } GetContrast() const156 short GetContrast() const { return mnContPercent; } 157 SetChannelR(short nChannelRPercent)158 void SetChannelR( short nChannelRPercent ) { mnRPercent = nChannelRPercent; } GetChannelR() const159 short GetChannelR() const { return mnRPercent; } 160 SetChannelG(short nChannelGPercent)161 void SetChannelG( short nChannelGPercent ) { mnGPercent = nChannelGPercent; } GetChannelG() const162 short GetChannelG() const { return mnGPercent; } 163 SetChannelB(short nChannelBPercent)164 void SetChannelB( short nChannelBPercent ) { mnBPercent = nChannelBPercent; } GetChannelB() const165 short GetChannelB() const { return mnBPercent; } 166 SetGamma(double fGamma)167 void SetGamma( double fGamma ) { mfGamma = fGamma; } GetGamma() const168 double GetGamma() const { return mfGamma; } 169 SetInvert(sal_Bool bInvert)170 void SetInvert( sal_Bool bInvert ) { mbInvert = bInvert; } IsInvert() const171 sal_Bool IsInvert() const { return mbInvert; } 172 SetTransparency(sal_uInt8 cTransparency)173 void SetTransparency( sal_uInt8 cTransparency ) { mcTransparency = cTransparency; } GetTransparency() const174 sal_uInt8 GetTransparency() const { return mcTransparency; } 175 IsSpecialDrawMode() const176 sal_Bool IsSpecialDrawMode() const { return( meDrawMode != GRAPHICDRAWMODE_STANDARD ); } IsMirrored() const177 sal_Bool IsMirrored() const { return( mnMirrFlags != 0UL ); } IsCropped() const178 sal_Bool IsCropped() const 179 { 180 return( mnLeftCrop != 0 || mnTopCrop != 0 || 181 mnRightCrop != 0 || mnBottomCrop != 0 ); 182 } IsRotated() const183 sal_Bool IsRotated() const { return( ( mnRotate10 % 3600 ) != 0 ); } IsTransparent() const184 sal_Bool IsTransparent() const { return( mcTransparency > 0 ); } IsAdjusted() const185 sal_Bool IsAdjusted() const 186 { 187 return( mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 || 188 mnGPercent != 0 || mnBPercent != 0 || mfGamma != 1.0 || mbInvert ); 189 } 190 191 friend SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr ); 192 friend SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr ); 193 }; 194 195 // ----------------- 196 // - GraphicObject - 197 // ----------------- 198 199 class SVT_DLLPUBLIC GraphicObject : public SvDataCopyStream 200 { 201 friend class GraphicManager; 202 203 private: 204 205 static GraphicManager* mpGlobalMgr; 206 207 Graphic maGraphic; 208 GraphicAttr maAttr; 209 Size maPrefSize; 210 MapMode maPrefMapMode; 211 sal_uLong mnSizeBytes; 212 GraphicType meType; 213 GraphicManager* mpMgr; 214 String* mpLink; 215 Link* mpSwapStreamHdl; 216 String* mpUserData; 217 Timer* mpSwapOutTimer; 218 GrfSimpleCacheObj* mpSimpleCache; 219 sal_uLong mnAnimationLoopCount; 220 221 // a unique increasing ID to be able to say which data change is older 222 sal_uLong mnDataChangeTimeStamp; 223 224 void* mpDummy2; 225 sal_Bool mbAutoSwapped : 1; 226 sal_Bool mbTransparent : 1; 227 sal_Bool mbAnimated : 1; 228 sal_Bool mbEPS : 1; 229 sal_Bool mbIsInSwapIn : 1; 230 sal_Bool mbIsInSwapOut : 1; 231 sal_Bool mbAlpha : 1; 232 sal_Bool mbDummyFlag8 : 1; 233 234 void SVT_DLLPRIVATE ImplConstruct(); 235 void SVT_DLLPRIVATE ImplAssignGraphicData(); 236 void SVT_DLLPRIVATE ImplSetGraphicManager( const GraphicManager* pMgr, 237 const ByteString* pID = NULL, 238 const GraphicObject* pCopyObj = NULL ); 239 void SVT_DLLPRIVATE ImplAutoSwapIn(); ImplIsAutoSwapped() const240 sal_Bool SVT_DLLPRIVATE ImplIsAutoSwapped() const { return mbAutoSwapped; } 241 sal_Bool SVT_DLLPRIVATE ImplGetCropParams( OutputDevice* pOut, Point& rPt, Size& rSz, const GraphicAttr* pAttr, 242 PolyPolygon& rClipPolyPoly, sal_Bool& bRectClipRegion ) const; 243 244 /** Render a given number of tiles in an optimized way 245 246 This method recursively subdivides the tile rendering problem 247 in smaller parts, i.e. rendering output size x with few tiles 248 of size y, which in turn are generated from the original 249 bitmap in a recursive fashion. The subdivision size can be 250 controlled by the exponent argument, which specifies the 251 minimal number of smaller tiles used in one recursion 252 step. The resulting tile size is given as the integer number 253 of repetitions of the original bitmap along x and y. As the 254 exponent need not necessarily divide these numbers without 255 remainder, the repetition counts are effectively converted to 256 base-exponent numbers, where each place denotes the number of 257 times the corresponding tile size is rendered. 258 259 @param rVDev 260 Virtual device to render everything into 261 262 @param nExponent 263 Number of repetitions per subdivision step, _must_ be greater than 1 264 265 @param nNumTilesX 266 Number of original tiles to generate in x direction 267 268 @param nNumTilesY 269 Number of original tiles to generate in y direction 270 271 @param rTileSizePixel 272 Size in pixel of the original tile bitmap to render it in 273 274 @param pAttr 275 Graphic attributes to be used for rendering 276 277 @param nFlags 278 Graphic flags to be used for rendering 279 280 @param rCurrPos 281 Current output point for this recursion level (should start with (0,0)) 282 283 @return true, if everything was successfully rendered. 284 */ 285 bool SVT_DLLPRIVATE ImplRenderTempTile( VirtualDevice& rVDev, int nExponent, 286 int nNumTilesX, int nNumTilesY, 287 const Size& rTileSizePixel, 288 const GraphicAttr* pAttr, sal_uLong nFlags ); 289 290 /// internally called by ImplRenderTempTile() 291 bool SVT_DLLPRIVATE ImplRenderTileRecursive( VirtualDevice& rVDev, int nExponent, int nMSBFactor, 292 int nNumOrigTilesX, int nNumOrigTilesY, 293 int nRemainderTilesX, int nRemainderTilesY, 294 const Size& rTileSizePixel, const GraphicAttr* pAttr, 295 sal_uLong nFlags, ImplTileInfo& rTileInfo ); 296 297 bool SVT_DLLPRIVATE ImplDrawTiled( OutputDevice* pOut, const Rectangle& rArea, const Size& rSizePixel, 298 const Size& rOffset, const GraphicAttr* pAttr, sal_uLong nFlags, int nTileCacheSize1D ); 299 300 bool SVT_DLLPRIVATE ImplDrawTiled( OutputDevice& rOut, const Point& rPos, 301 int nNumTilesX, int nNumTilesY, 302 const Size& rTileSize, 303 const GraphicAttr* pAttr, sal_uLong nFlags ); 304 305 void SVT_DLLPRIVATE ImplTransformBitmap( BitmapEx& rBmpEx, 306 const GraphicAttr& rAttr, 307 const Size& rCropLeftTop, 308 const Size& rCropRightBottom, 309 const Rectangle& rCropRect, 310 const Size& rDstSize, 311 sal_Bool bEnlarge ) const; 312 313 DECL_LINK( ImplAutoSwapOutHdl, void* ); 314 315 // Handle evtl. needed AfterDataChanges, needs to be called when new 316 // graphic data is swapped in/added to the GraphicManager 317 void ImplAfterDataChange(); 318 319 protected: 320 321 virtual void GraphicManagerDestroyed(); 322 virtual SvStream* GetSwapStream() const; 323 324 // !!! to be removed 325 virtual sal_uLong GetReleaseFromCache() const; 326 327 virtual void Load( SvStream& ); 328 virtual void Save( SvStream& ); 329 virtual void Assign( const SvDataCopyStream& ); 330 331 public: 332 333 TYPEINFO(); 334 335 GraphicObject( const GraphicManager* pMgr = NULL ); 336 GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr = NULL ); 337 GraphicObject( const Graphic& rGraphic, const String& rLink, const GraphicManager* pMgr = NULL ); 338 GraphicObject( const GraphicObject& rCacheObj, const GraphicManager* pMgr = NULL ); 339 GraphicObject( const ByteString& rUniqueID, const GraphicManager* pMgr = NULL ); 340 ~GraphicObject(); 341 342 GraphicObject& operator=( const GraphicObject& rCacheObj ); 343 sal_Bool operator==( const GraphicObject& rCacheObj ) const; operator !=(const GraphicObject & rCacheObj) const344 sal_Bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); } 345 HasSwapStreamHdl() const346 sal_Bool HasSwapStreamHdl() const { return( mpSwapStreamHdl != NULL && mpSwapStreamHdl->IsSet() ); } 347 void SetSwapStreamHdl(); 348 void SetSwapStreamHdl( const Link& rHdl, const sal_uLong nSwapOutTimeout = 0UL ); 349 Link GetSwapStreamHdl() const; GetSwapOutTimeout() const350 sal_uLong GetSwapOutTimeout() const { return( mpSwapOutTimer ? mpSwapOutTimer->GetTimeout() : 0 ); } 351 352 void FireSwapInRequest(); 353 void FireSwapOutRequest(); 354 355 void SetGraphicManager( const GraphicManager& rMgr ); GetGraphicManager() const356 GraphicManager& GetGraphicManager() const { return *mpMgr; } 357 358 sal_Bool IsCached( OutputDevice* pOut, const Point& rPt, const Size& rSz, 359 const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD) const; 360 void ReleaseFromCache(); 361 362 const Graphic& GetGraphic() const; 363 void SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = 0); 364 void SetGraphic( const Graphic& rGraphic, const String& rLink ); 365 366 /** Get graphic transformed according to given attributes 367 368 This method returns a Graphic transformed, cropped and scaled 369 to the given parameters, ready to be rendered to printer or 370 display. The returned graphic has the same visual appearance 371 as if it had been drawn via GraphicObject::Draw() to a 372 specific output device. 373 374 @param rDestSize 375 Desired output size in logical coordinates. The mapmode to 376 interpret these logical coordinates in is given by the second 377 parameter, rDestMap. 378 379 @param rDestMap 380 Mapmode the output should be interpreted in. This is used to 381 interpret rDestSize, to set the appropriate PrefMapMode on the 382 returned Graphic, and to deal correctly with metafile graphics. 383 384 @param rAttr 385 Graphic attributes used to transform the graphic. This 386 includes cropping, rotation, mirroring, and various color 387 adjustment parameters. 388 389 @return the readily transformed Graphic 390 */ 391 Graphic GetTransformedGraphic( const Size& rDestSize, const MapMode& rDestMap, const GraphicAttr& rAttr ) const; 392 Graphic GetTransformedGraphic( const GraphicAttr* pAttr = NULL ) const; // TODO: Change to Impl 393 394 void SetAttr( const GraphicAttr& rAttr ); GetAttr() const395 const GraphicAttr& GetAttr() const { return maAttr; } 396 HasLink() const397 sal_Bool HasLink() const { return( mpLink != NULL && mpLink->Len() > 0 ); } 398 void SetLink(); 399 void SetLink( const String& rLink ); 400 String GetLink() const; 401 HasUserData() const402 sal_Bool HasUserData() const { return( mpUserData != NULL && mpUserData->Len() > 0 ); } 403 void SetUserData(); 404 void SetUserData( const String& rUserData ); 405 String GetUserData() const; 406 407 ByteString GetUniqueID() const; 408 GetType() const409 GraphicType GetType() const { return meType; } GetPrefSize() const410 const Size& GetPrefSize() const { return maPrefSize; } GetPrefMapMode() const411 const MapMode& GetPrefMapMode() const { return maPrefMapMode; } GetSizeBytes() const412 sal_uLong GetSizeBytes() const { return mnSizeBytes; } 413 sal_uLong GetChecksum() const; IsTransparent() const414 sal_Bool IsTransparent() const { return mbTransparent; } IsAlpha() const415 sal_Bool IsAlpha() const { return mbAlpha; } IsAnimated() const416 sal_Bool IsAnimated() const { return mbAnimated; } IsEPS() const417 sal_Bool IsEPS() const { return mbEPS; } 418 419 void ResetAnimationLoopCount(); 420 List* GetAnimationInfoList() const; GetAnimationNotifyHdl() const421 Link GetAnimationNotifyHdl() const { return maGraphic.GetAnimationNotifyHdl(); } 422 void SetAnimationNotifyHdl( const Link& rLink ); 423 424 sal_Bool SwapOut(); 425 sal_Bool SwapOut( SvStream* pOStm ); 426 sal_Bool SwapIn(); 427 sal_Bool SwapIn( SvStream* pIStm ); 428 IsInSwapIn() const429 sal_Bool IsInSwapIn() const { return mbIsInSwapIn; } IsInSwapOut() const430 sal_Bool IsInSwapOut() const { return mbIsInSwapOut; } IsInSwap() const431 sal_Bool IsInSwap() const { return( mbIsInSwapOut || mbIsInSwapOut ); } IsSwappedOut() const432 sal_Bool IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); } 433 void SetSwapState(); 434 435 sal_Bool Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz, 436 const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD ); 437 438 sal_Bool DrawWithPDFHandling( OutputDevice& rOutDev, 439 const Point& rPt, const Size& rSz, 440 const GraphicAttr* pGrfAttr = NULL, 441 const sal_uLong nFlags = GRFMGR_DRAW_STANDARD ); 442 443 /** Draw the graphic repeatedly into the given output rectangle 444 445 @param pOut 446 OutputDevice where the rendering should take place 447 448 @param rArea 449 The output area that is filled with tiled instances of this graphic 450 451 @param rSize 452 The actual size of a single tile 453 454 @param rOffset 455 Offset from the left, top position of rArea, where to start 456 the tiling. The upper left corner of the graphic tilings will 457 virtually start at this position. Concretely, only that many 458 tiles are drawn to completely fill the given output area. 459 460 @param pAttr 461 Optional GraphicAttr 462 463 @param nFlags 464 Optional rendering flags 465 466 @param nTileCacheSize1D 467 Optional dimension of the generated cache tiles. The pOut sees 468 a number of tile draws, which have approximately 469 nTileCacheSize1D times nTileCacheSize1D bitmap sizes if the 470 tile bitmap is smaller. Otherwise, the tile is drawn as 471 is. This is useful if e.g. you want only a few, very large 472 bitmap drawings appear on the outdev. 473 474 @return sal_True, if drawing completed successfully 475 */ 476 sal_Bool DrawTiled( OutputDevice* pOut, const Rectangle& rArea, const Size& rSize, 477 const Size& rOffset, const GraphicAttr* pAttr = NULL, 478 sal_uLong nFlags = GRFMGR_DRAW_STANDARD, int nTileCacheSize1D=128 ); 479 480 sal_Bool StartAnimation( OutputDevice* pOut, const Point& rPt, const Size& rSz, long nExtraData = 0L, 481 const GraphicAttr* pAttr = NULL, sal_uLong nFlags = GRFMGR_DRAW_STANDARD, 482 OutputDevice* pFirstFrameOutDev = NULL ); 483 484 void StopAnimation( OutputDevice* pOut = NULL, long nExtraData = 0L ); 485 486 friend SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj ); 487 friend SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj ); 488 489 static GraphicObject CreateGraphicObjectFromURL( const ::rtl::OUString &rURL ); 490 491 // create CropScaling information 492 // fWidth, fHeight: object size 493 // f*Crop: crop values relative to original bitmap size 494 basegfx::B2DVector calculateCropScaling( 495 double fWidth, 496 double fHeight, 497 double fLeftCrop, 498 double fTopCrop, 499 double fRightCrop, 500 double fBottomCrop) const; 501 502 // read access GetDataChangeTimeStamp() const503 sal_uLong GetDataChangeTimeStamp() const { return mnDataChangeTimeStamp; } 504 505 // restart SwapOut timer; this is like touching in a cache to reset to the full timeout value 506 void restartSwapOutTimer() const; 507 }; 508 509 // ------------------ 510 // - GraphicManager - 511 // ------------------ 512 513 class SVT_DLLPUBLIC GraphicManager 514 { 515 friend class GraphicObject; 516 friend class GraphicDisplayCacheEntry; 517 518 private: 519 520 List maObjList; 521 GraphicCache* mpCache; 522 GraphicManager(const GraphicManager &)523 GraphicManager( const GraphicManager& ) {} operator =(const GraphicManager &)524 GraphicManager& operator=( const GraphicManager& ) { return *this; } 525 526 sal_Bool SVT_DLLPRIVATE ImplDraw( OutputDevice* pOut, const Point& rPt, 527 const Size& rSz, GraphicObject& rObj, 528 const GraphicAttr& rAttr, 529 const sal_uLong nFlags, sal_Bool& rCached ); 530 531 sal_Bool SVT_DLLPRIVATE ImplCreateOutput( OutputDevice* pOut, const Point& rPt, const Size& rSz, 532 const BitmapEx& rBmpEx, const GraphicAttr& rAttr, 533 const sal_uLong nFlags, BitmapEx* pBmpEx = NULL ); 534 sal_Bool SVT_DLLPRIVATE ImplCreateOutput( OutputDevice* pOut, 535 const Point& rPt, const Size& rSz, 536 const GDIMetaFile& rMtf, const GraphicAttr& rAttr, 537 const sal_uLong nFlags, GDIMetaFile& rOutMtf, BitmapEx& rOutBmpEx ); 538 539 sal_Bool SVT_DLLPRIVATE ImplCreateScaled( const BitmapEx& rBmpEx, 540 long* pMapIX, long* pMapFX, long* pMapIY, long* pMapFY, 541 long nStartX, long nEndX, long nStartY, long nEndY, 542 BitmapEx& rOutBmpEx ); 543 544 sal_Bool SVT_DLLPRIVATE ImplCreateRotatedScaled( const BitmapEx& rBmpEx, 545 sal_uInt16 nRot10, const Size& rOutSzPix, const Size& rUntSzPix, 546 long* pMapIX, long* pMapFX, long* pMapIY, long* pMapFY, 547 long nStartX, long nEndX, long nStartY, long nEndY, 548 BitmapEx& rOutBmpEx ); 549 550 static void SVT_DLLPRIVATE ImplAdjust( BitmapEx& rBmpEx, const GraphicAttr& rAttr, sal_uLong nAdjustmentFlags ); 551 static void SVT_DLLPRIVATE ImplAdjust( GDIMetaFile& rMtf, const GraphicAttr& rAttr, sal_uLong nAdjustmentFlags ); 552 static void SVT_DLLPRIVATE ImplAdjust( Animation& rAnimation, const GraphicAttr& rAttr, sal_uLong nAdjustmentFlags ); 553 554 static void SVT_DLLPRIVATE ImplDraw( OutputDevice* pOut, const Point& rPt, const Size& rSz, 555 const GDIMetaFile& rMtf, const GraphicAttr& rAttr ); 556 557 // Only used by GraphicObject's Ctor's and Dtor's 558 void SVT_DLLPRIVATE ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, 559 const ByteString* pID = NULL, 560 const GraphicObject* pCopyObj = NULL ); 561 void SVT_DLLPRIVATE ImplUnregisterObj( const GraphicObject& rObj ); ImplHasObjects() const562 inline sal_Bool SVT_DLLPRIVATE ImplHasObjects() const { return( maObjList.Count() > 0UL ); } 563 564 // Only used in swap case by GraphicObject 565 void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj ); 566 sal_Bool SVT_DLLPRIVATE ImplFillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute ); 567 void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj ); 568 569 ByteString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const; 570 571 // This method allows to check memory footprint for all currently swapped in GraphicObjects on this GraphicManager 572 // which are based on Bitmaps. This is needed on 32Bit systems and only does something on those systems. The problem 573 // to solve is that normally the SwapOut is timer-driven, but even with short timer settings there are situations 574 // where this does not trigger - or in other words: A maximum limitation for GraphicManagers was not in place before. 575 // For 32Bit systems this leads to situations where graphics will be missing. This method will actively swap out 576 // the longest swapped in graphics until a maximum memory boundary (derived from user settings in tools/options/memory) 577 // is no longer exceeded 578 void ImplCheckSizeOfSwappedInGraphics(); 579 580 public: 581 582 GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL ); 583 ~GraphicManager(); 584 585 void SetMaxCacheSize( sal_uLong nNewCacheSize ); 586 sal_uLong GetMaxCacheSize() const; 587 588 void SetMaxObjCacheSize( sal_uLong nNewMaxObjSize, sal_Bool bDestroyGreaterCached = sal_False ); 589 sal_uLong GetMaxObjCacheSize() const; 590 591 sal_uLong GetUsedCacheSize() const; 592 sal_uLong GetFreeCacheSize() const; 593 594 void SetCacheTimeout( sal_uLong nTimeoutSeconds ); 595 sal_uLong GetCacheTimeout() const; 596 597 void ClearCache(); 598 599 void ReleaseFromCache( const GraphicObject& rObj ); 600 601 sal_Bool IsInCache( OutputDevice* pOut, const Point& rPt, const Size& rSz, 602 const GraphicObject& rObj, const GraphicAttr& rAttr ) const; 603 604 sal_Bool DrawObj( OutputDevice* pOut, const Point& rPt, const Size& rSz, 605 GraphicObject& rObj, const GraphicAttr& rAttr, 606 const sal_uLong nFlags, sal_Bool& rCached ); 607 }; 608 609 #endif // _GRFMGR_HXX 610