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 : : #ifndef _GRFMGR_HXX
30 : : #define _GRFMGR_HXX
31 : :
32 : : #include <vcl/graph.hxx>
33 : : #include <svtools/svtdllapi.h>
34 : :
35 : : // -----------
36 : : // - Defines -
37 : : // -----------
38 : :
39 : : #define GRFMGR_DRAW_NOTCACHED 0x00000000UL
40 : : #define GRFMGR_DRAW_CACHED 0x00000001UL
41 : : #define GRFMGR_DRAW_SMOOTHSCALE 0x00000002UL
42 : : #define GRFMGR_DRAW_USE_DRAWMODE_SETTINGS 0x00000004UL
43 : : #define GRFMGR_DRAW_SUBSTITUTE 0x00000008UL
44 : : #define GRFMGR_DRAW_NO_SUBSTITUTE 0x00000010UL
45 : : #define GRFMGR_DRAW_STANDARD (GRFMGR_DRAW_CACHED|GRFMGR_DRAW_SMOOTHSCALE)
46 : :
47 : : // --------------------
48 : : // - AutoSwap Defines -
49 : : // --------------------
50 : :
51 : : #define GRFMGR_AUTOSWAPSTREAM_LINK ((SvStream*)0x00000000UL)
52 : : #define GRFMGR_AUTOSWAPSTREAM_LOADED ((SvStream*)0xfffffffdUL)
53 : : #define GRFMGR_AUTOSWAPSTREAM_TEMP ((SvStream*)0xfffffffeUL)
54 : : #define GRFMGR_AUTOSWAPSTREAM_NONE ((SvStream*)0xffffffffUL)
55 : :
56 : : // ----------------------
57 : : // - Adjustment Defines -
58 : : // ----------------------
59 : :
60 : : #define ADJUSTMENT_NONE 0x00000000UL
61 : : #define ADJUSTMENT_DRAWMODE 0x00000001UL
62 : : #define ADJUSTMENT_COLORS 0x00000002UL
63 : : #define ADJUSTMENT_MIRROR 0x00000004UL
64 : : #define ADJUSTMENT_ROTATE 0x00000008UL
65 : : #define ADJUSTMENT_TRANSPARENCY 0x00000010UL
66 : : #define ADJUSTMENT_ALL 0xFFFFFFFFUL
67 : :
68 : : // ---------
69 : : // - Enums -
70 : : // ---------
71 : :
72 : : enum GraphicDrawMode
73 : : {
74 : : GRAPHICDRAWMODE_STANDARD = 0,
75 : : GRAPHICDRAWMODE_GREYS = 1,
76 : : GRAPHICDRAWMODE_MONO = 2,
77 : : GRAPHICDRAWMODE_WATERMARK = 3
78 : : };
79 : :
80 : : // ------------
81 : : // - Forwards -
82 : : // ------------
83 : :
84 : : class GraphicManager;
85 : : class SvStream;
86 : : class BitmapWriteAccess;
87 : : class GraphicCache;
88 : : class VirtualDevice;
89 : : struct GrfSimpleCacheObj;
90 : : struct ImplTileInfo;
91 : :
92 : : // ---------------
93 : : // - GraphicAttr -
94 : : // ---------------
95 : :
96 : : class SVT_DLLPUBLIC GraphicAttr
97 : : {
98 : : private:
99 : :
100 : : double mfGamma;
101 : : sal_uInt32 mnMirrFlags;
102 : : long mnLeftCrop;
103 : : long mnTopCrop;
104 : : long mnRightCrop;
105 : : long mnBottomCrop;
106 : : sal_uInt16 mnRotate10;
107 : : short mnContPercent;
108 : : short mnLumPercent;
109 : : short mnRPercent;
110 : : short mnGPercent;
111 : : short mnBPercent;
112 : : sal_Bool mbInvert;
113 : : sal_uInt8 mcTransparency;
114 : : GraphicDrawMode meDrawMode;
115 : :
116 : : public:
117 : :
118 : : GraphicAttr();
119 : : ~GraphicAttr();
120 : :
121 : : sal_Bool operator==( const GraphicAttr& rAttr ) const;
122 : 0 : sal_Bool operator!=( const GraphicAttr& rAttr ) const { return !( *this == rAttr ); }
123 : :
124 : 420 : void SetDrawMode( GraphicDrawMode eDrawMode ) { meDrawMode = eDrawMode; }
125 : 0 : GraphicDrawMode GetDrawMode() const { return meDrawMode; }
126 : :
127 : 17701 : void SetMirrorFlags( sal_uLong nMirrFlags ) { mnMirrFlags = nMirrFlags; }
128 : 35068 : sal_uLong GetMirrorFlags() const { return mnMirrFlags; }
129 : :
130 : 500 : void SetCrop( long nLeft_100TH_MM, long nTop_100TH_MM, long nRight_100TH_MM, long nBottom_100TH_MM )
131 : : {
132 : 500 : mnLeftCrop = nLeft_100TH_MM; mnTopCrop = nTop_100TH_MM;
133 : 500 : mnRightCrop = nRight_100TH_MM; mnBottomCrop = nBottom_100TH_MM;
134 : 500 : }
135 : 4 : long GetLeftCrop() const { return mnLeftCrop; }
136 : 4 : long GetTopCrop() const { return mnTopCrop; }
137 : 4 : long GetRightCrop() const { return mnRightCrop; }
138 : 4 : long GetBottomCrop() const { return mnBottomCrop; }
139 : :
140 : 243 : void SetRotation( sal_uInt16 nRotate10 ) { mnRotate10 = nRotate10; }
141 : 17572 : sal_uInt16 GetRotation() const { return mnRotate10; }
142 : :
143 : 420 : void SetLuminance( short nLuminancePercent ) { mnLumPercent = nLuminancePercent; }
144 : 0 : short GetLuminance() const { return mnLumPercent; }
145 : :
146 : 420 : void SetContrast( short nContrastPercent ) { mnContPercent = nContrastPercent; }
147 : 0 : short GetContrast() const { return mnContPercent; }
148 : :
149 : 420 : void SetChannelR( short nChannelRPercent ) { mnRPercent = nChannelRPercent; }
150 : 0 : short GetChannelR() const { return mnRPercent; }
151 : :
152 : 420 : void SetChannelG( short nChannelGPercent ) { mnGPercent = nChannelGPercent; }
153 : 0 : short GetChannelG() const { return mnGPercent; }
154 : :
155 : 420 : void SetChannelB( short nChannelBPercent ) { mnBPercent = nChannelBPercent; }
156 : 0 : short GetChannelB() const { return mnBPercent; }
157 : :
158 : 420 : void SetGamma( double fGamma ) { mfGamma = fGamma; }
159 : 0 : double GetGamma() const { return mfGamma; }
160 : :
161 : 420 : void SetInvert( sal_Bool bInvert ) { mbInvert = bInvert; }
162 : 0 : sal_Bool IsInvert() const { return mbInvert; }
163 : :
164 : 420 : void SetTransparency( sal_uInt8 cTransparency ) { mcTransparency = cTransparency; }
165 : 254 : sal_uInt8 GetTransparency() const { return mcTransparency; }
166 : :
167 : 17657 : sal_Bool IsSpecialDrawMode() const { return( meDrawMode != GRAPHICDRAWMODE_STANDARD ); }
168 : 203 : sal_Bool IsMirrored() const { return( mnMirrFlags != 0UL ); }
169 : 17670 : sal_Bool IsCropped() const
170 : : {
171 : : return( mnLeftCrop != 0 || mnTopCrop != 0 ||
172 [ + + ][ + - ]: 17670 : mnRightCrop != 0 || mnBottomCrop != 0 );
[ + - ][ - + ]
173 : : }
174 : 124 : sal_Bool IsRotated() const { return( ( mnRotate10 % 3600 ) != 0 ); }
175 : 35191 : sal_Bool IsTransparent() const { return( mcTransparency > 0 ); }
176 : 17657 : sal_Bool IsAdjusted() const
177 : : {
178 : : return( mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 ||
179 [ + - ][ + - ]: 17657 : mnGPercent != 0 || mnBPercent != 0 || mfGamma != 1.0 || mbInvert );
[ + - ][ + - ]
[ + - ][ + - ]
[ - + ]
180 : : }
181 : :
182 : : friend SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr );
183 : : friend SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr );
184 : : };
185 : :
186 : : // -----------------
187 : : // - GraphicObject -
188 : : // -----------------
189 : :
190 : : class SVT_DLLPUBLIC GraphicObject : public SvDataCopyStream
191 : : {
192 : : friend class GraphicManager;
193 : :
194 : : private:
195 : :
196 : : static GraphicManager* mpGlobalMgr;
197 : :
198 : : Graphic maGraphic;
199 : : GraphicAttr maAttr;
200 : : Size maPrefSize;
201 : : MapMode maPrefMapMode;
202 : : sal_uLong mnSizeBytes;
203 : : GraphicType meType;
204 : : GraphicManager* mpMgr;
205 : : String* mpLink;
206 : : Link* mpSwapStreamHdl;
207 : : String* mpUserData;
208 : : Timer* mpSwapOutTimer;
209 : : GrfSimpleCacheObj* mpSimpleCache;
210 : : sal_uLong mnAnimationLoopCount;
211 : : void* mpDummy1;
212 : : void* mpDummy2;
213 : : sal_Bool mbAutoSwapped : 1;
214 : : sal_Bool mbTransparent : 1;
215 : : sal_Bool mbAnimated : 1;
216 : : sal_Bool mbEPS : 1;
217 : : sal_Bool mbIsInSwapIn : 1;
218 : : sal_Bool mbIsInSwapOut : 1;
219 : : sal_Bool mbAlpha : 1;
220 : : sal_Bool mbDummyFlag8 : 1;
221 : : sal_Bool mbIsRenderGraphic : 1;
222 : : sal_Bool mbHasRenderGraphic : 1;
223 : :
224 : : void SVT_DLLPRIVATE ImplConstruct();
225 : : void SVT_DLLPRIVATE ImplAssignGraphicData();
226 : : void SVT_DLLPRIVATE ImplSetGraphicManager(
227 : : const GraphicManager* pMgr,
228 : : const rtl::OString* pID = NULL,
229 : : const GraphicObject* pCopyObj = NULL
230 : : );
231 : : void SVT_DLLPRIVATE ImplAutoSwapIn();
232 : : sal_Bool SVT_DLLPRIVATE ImplIsAutoSwapped() const { return mbAutoSwapped; }
233 : : sal_Bool SVT_DLLPRIVATE ImplGetCropParams(
234 : : OutputDevice* pOut,
235 : : Point& rPt,
236 : : Size& rSz,
237 : : const GraphicAttr* pAttr,
238 : : PolyPolygon& rClipPolyPoly,
239 : : sal_Bool& bRectClipRegion
240 : : ) const;
241 : :
242 : : /** Render a given number of tiles in an optimized way
243 : :
244 : : This method recursively subdivides the tile rendering problem
245 : : in smaller parts, i.e. rendering output size x with few tiles
246 : : of size y, which in turn are generated from the original
247 : : bitmap in a recursive fashion. The subdivision size can be
248 : : controlled by the exponent argument, which specifies the
249 : : minimal number of smaller tiles used in one recursion
250 : : step. The resulting tile size is given as the integer number
251 : : of repetitions of the original bitmap along x and y. As the
252 : : exponent need not necessarily divide these numbers without
253 : : remainder, the repetition counts are effectively converted to
254 : : base-exponent numbers, where each place denotes the number of
255 : : times the corresponding tile size is rendered.
256 : :
257 : : @param rVDev
258 : : Virtual device to render everything into
259 : :
260 : : @param nExponent
261 : : Number of repetitions per subdivision step, _must_ be greater than 1
262 : :
263 : : @param nNumTilesX
264 : : Number of original tiles to generate in x direction
265 : :
266 : : @param nNumTilesY
267 : : Number of original tiles to generate in y direction
268 : :
269 : : @param rTileSizePixel
270 : : Size in pixel of the original tile bitmap to render it in
271 : :
272 : : @param pAttr
273 : : Graphic attributes to be used for rendering
274 : :
275 : : @param nFlags
276 : : Graphic flags to be used for rendering
277 : :
278 : : @param rCurrPos
279 : : Current output point for this recursion level (should start with (0,0))
280 : :
281 : : @return true, if everything was successfully rendered.
282 : : */
283 : : bool SVT_DLLPRIVATE ImplRenderTempTile(
284 : : VirtualDevice& rVDev,
285 : : int nExponent,
286 : : int nNumTilesX,
287 : : int nNumTilesY,
288 : : const Size& rTileSizePixel,
289 : : const GraphicAttr* pAttr,
290 : : sal_uLong nFlags
291 : : );
292 : :
293 : : /// internally called by ImplRenderTempTile()
294 : : bool SVT_DLLPRIVATE ImplRenderTileRecursive(
295 : : VirtualDevice& rVDev,
296 : : int nExponent,
297 : : int nMSBFactor,
298 : : int nNumOrigTilesX,
299 : : int nNumOrigTilesY,
300 : : int nRemainderTilesX,
301 : : int nRemainderTilesY,
302 : : const Size& rTileSizePixel,
303 : : const GraphicAttr* pAttr,
304 : : sal_uLong nFlags,
305 : : ImplTileInfo& rTileInfo
306 : : );
307 : :
308 : : bool SVT_DLLPRIVATE ImplDrawTiled(
309 : : OutputDevice* pOut,
310 : : const Rectangle& rArea,
311 : : const Size& rSizePixel,
312 : : const Size& rOffset,
313 : : const GraphicAttr* pAttr,
314 : : sal_uLong nFlags,
315 : : int nTileCacheSize1D
316 : : );
317 : :
318 : : bool SVT_DLLPRIVATE ImplDrawTiled(
319 : : OutputDevice& rOut,
320 : : const Point& rPos,
321 : : int nNumTilesX,
322 : : int nNumTilesY,
323 : : const Size& rTileSize,
324 : : const GraphicAttr* pAttr,
325 : : sal_uLong nFlags
326 : : );
327 : :
328 : : void SVT_DLLPRIVATE ImplTransformBitmap(
329 : : BitmapEx& rBmpEx,
330 : : const GraphicAttr& rAttr,
331 : : const Size& rCropLeftTop,
332 : : const Size& rCropRightBottom,
333 : : const Rectangle& rCropRect,
334 : : const Size& rDstSize,
335 : : sal_Bool bEnlarge
336 : : ) const;
337 : :
338 : : DECL_LINK( ImplAutoSwapOutHdl, void* );
339 : :
340 : : protected:
341 : :
342 : : virtual void GraphicManagerDestroyed();
343 : : virtual SvStream* GetSwapStream() const;
344 : :
345 : : virtual void Load( SvStream& );
346 : : virtual void Save( SvStream& );
347 : : virtual void Assign( const SvDataCopyStream& );
348 : :
349 : : public:
350 : :
351 : : TYPEINFO();
352 : :
353 : : GraphicObject( const GraphicManager* pMgr = NULL );
354 : : GraphicObject( const Graphic& rGraphic, const GraphicManager* pMgr = NULL );
355 : : GraphicObject( const GraphicObject& rCacheObj, const GraphicManager* pMgr = NULL );
356 : : explicit GraphicObject( const rtl::OString& rUniqueID, const GraphicManager* pMgr = NULL );
357 : : ~GraphicObject();
358 : :
359 : : GraphicObject& operator=( const GraphicObject& rCacheObj );
360 : : sal_Bool operator==( const GraphicObject& rCacheObj ) const;
361 : 11 : sal_Bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); }
362 : :
363 [ + + ][ + - ]: 17602 : sal_Bool HasSwapStreamHdl() const { return( mpSwapStreamHdl != NULL && mpSwapStreamHdl->IsSet() ); }
364 : : void SetSwapStreamHdl();
365 : : void SetSwapStreamHdl( const Link& rHdl, const sal_uLong nSwapOutTimeout = 0UL );
366 : : sal_uLong GetSwapOutTimeout() const { return( mpSwapOutTimer ? mpSwapOutTimer->GetTimeout() : 0 ); }
367 : :
368 : : void FireSwapInRequest();
369 : : void FireSwapOutRequest();
370 : :
371 : 0 : GraphicManager& GetGraphicManager() const { return *mpMgr; }
372 : :
373 : : sal_Bool IsCached(
374 : : OutputDevice* pOut,
375 : : const Point& rPt,
376 : : const Size& rSz,
377 : : const GraphicAttr* pAttr = NULL,
378 : : sal_uLong nFlags = GRFMGR_DRAW_STANDARD
379 : : ) const;
380 : : void ReleaseFromCache();
381 : :
382 : : const Graphic& GetGraphic() const;
383 : : void SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = 0);
384 : : void SetGraphic( const Graphic& rGraphic, const String& rLink );
385 : :
386 : : /** Get graphic transformed according to given attributes
387 : :
388 : : This method returns a Graphic transformed, cropped and scaled
389 : : to the given parameters, ready to be rendered to printer or
390 : : display. The returned graphic has the same visual appearance
391 : : as if it had been drawn via GraphicObject::Draw() to a
392 : : specific output device.
393 : :
394 : : @param rDestSize
395 : : Desired output size in logical coordinates. The mapmode to
396 : : interpret these logical coordinates in is given by the second
397 : : parameter, rDestMap.
398 : :
399 : : @param rDestMap
400 : : Mapmode the output should be interpreted in. This is used to
401 : : interpret rDestSize, to set the appropriate PrefMapMode on the
402 : : returned Graphic, and to deal correctly with metafile graphics.
403 : :
404 : : @param rAttr
405 : : Graphic attributes used to transform the graphic. This
406 : : includes cropping, rotation, mirroring, and various color
407 : : adjustment parameters.
408 : :
409 : : @return the readily transformed Graphic
410 : : */
411 : : Graphic GetTransformedGraphic(
412 : : const Size& rDestSize,
413 : : const MapMode& rDestMap,
414 : : const GraphicAttr& rAttr
415 : : ) const;
416 : : Graphic GetTransformedGraphic( const GraphicAttr* pAttr = NULL ) const; // TODO: Change to Impl
417 : :
418 : : void SetAttr( const GraphicAttr& rAttr );
419 : 18 : const GraphicAttr& GetAttr() const { return maAttr; }
420 : :
421 [ # # ][ # # ]: 0 : sal_Bool HasLink() const { return( mpLink != NULL && mpLink->Len() > 0 ); }
422 : : void SetLink();
423 : : void SetLink( const String& rLink );
424 : : String GetLink() const;
425 : :
426 [ + + ][ + - ]: 233 : sal_Bool HasUserData() const { return( mpUserData != NULL && mpUserData->Len() > 0 ); }
427 : : void SetUserData();
428 : : void SetUserData( const String& rUserData );
429 : : String GetUserData() const;
430 : :
431 : : rtl::OString GetUniqueID() const;
432 : :
433 : 56534 : GraphicType GetType() const { return meType; }
434 : 6 : const Size& GetPrefSize() const { return maPrefSize; }
435 : 6 : const MapMode& GetPrefMapMode() const { return maPrefMapMode; }
436 : 77 : sal_uLong GetSizeBytes() const { return mnSizeBytes; }
437 : 53025 : sal_Bool IsTransparent() const { return mbTransparent; }
438 : : sal_Bool IsAlpha() const { return mbAlpha; }
439 : 17857 : sal_Bool IsAnimated() const { return mbAnimated; }
440 : 5521 : sal_Bool IsEPS() const { return mbEPS; }
441 : 5521 : sal_Bool IsRenderGraphic() const { return mbIsRenderGraphic; }
442 : 0 : sal_Bool HasRenderGraphic() const { return mbHasRenderGraphic; }
443 : :
444 : 0 : Link GetAnimationNotifyHdl() const { return maGraphic.GetAnimationNotifyHdl(); }
445 : :
446 : : sal_Bool SwapOut();
447 : : sal_Bool SwapOut( SvStream* pOStm );
448 : : sal_Bool SwapIn();
449 : : sal_Bool SwapIn( SvStream* pIStm );
450 : :
451 : 5521 : sal_Bool IsInSwapIn() const { return mbIsInSwapIn; }
452 : 68 : sal_Bool IsInSwapOut() const { return mbIsInSwapOut; }
453 : : sal_Bool IsInSwap() const { return( mbIsInSwapOut || mbIsInSwapOut ); }
454 [ + + ][ + + ]: 84006 : sal_Bool IsSwappedOut() const { return( mbAutoSwapped || maGraphic.IsSwapOut() ); }
455 : : void SetSwapState();
456 : :
457 : : bool Draw(
458 : : OutputDevice* pOut,
459 : : const Point& rPt,
460 : : const Size& rSz,
461 : : const GraphicAttr* pAttr = NULL,
462 : : sal_uLong nFlags = GRFMGR_DRAW_STANDARD
463 : : );
464 : :
465 : : sal_Bool DrawWithPDFHandling(
466 : : OutputDevice& rOutDev,
467 : : const Point& rPt,
468 : : const Size& rSz,
469 : : const GraphicAttr* pGrfAttr = NULL,
470 : : const sal_uLong nFlags = GRFMGR_DRAW_STANDARD
471 : : );
472 : :
473 : : /** Draw the graphic repeatedly into the given output rectangle
474 : :
475 : : @param pOut
476 : : OutputDevice where the rendering should take place
477 : :
478 : : @param rArea
479 : : The output area that is filled with tiled instances of this graphic
480 : :
481 : : @param rSize
482 : : The actual size of a single tile
483 : :
484 : : @param rOffset
485 : : Offset from the left, top position of rArea, where to start
486 : : the tiling. The upper left corner of the graphic tilings will
487 : : virtually start at this position. Concretely, only that many
488 : : tiles are drawn to completely fill the given output area.
489 : :
490 : : @param pAttr
491 : : Optional GraphicAttr
492 : :
493 : : @param nFlags
494 : : Optional rendering flags
495 : :
496 : : @param nTileCacheSize1D
497 : : Optional dimension of the generated cache tiles. The pOut sees
498 : : a number of tile draws, which have approximately
499 : : nTileCacheSize1D times nTileCacheSize1D bitmap sizes if the
500 : : tile bitmap is smaller. Otherwise, the tile is drawn as
501 : : is. This is useful if e.g. you want only a few, very large
502 : : bitmap drawings appear on the outdev.
503 : :
504 : : @return sal_True, if drawing completed successfully
505 : : */
506 : : sal_Bool DrawTiled(
507 : : OutputDevice* pOut,
508 : : const Rectangle& rArea,
509 : : const Size& rSize,
510 : : const Size& rOffset,
511 : : const GraphicAttr* pAttr = NULL,
512 : : sal_uLong nFlags = GRFMGR_DRAW_STANDARD,
513 : : int nTileCacheSize1D=128
514 : : );
515 : :
516 : : sal_Bool StartAnimation(
517 : : OutputDevice* pOut,
518 : : const Point& rPt,
519 : : const Size& rSz,
520 : : long nExtraData = 0L,
521 : : const GraphicAttr* pAttr = NULL,
522 : : sal_uLong nFlags = GRFMGR_DRAW_STANDARD,
523 : : OutputDevice* pFirstFrameOutDev = NULL
524 : : );
525 : :
526 : : void StopAnimation( OutputDevice* pOut = NULL, long nExtraData = 0L );
527 : :
528 : : friend SvStream& operator<<( SvStream& rOStm, const GraphicObject& rGraphicObj );
529 : : friend SvStream& operator>>( SvStream& rIStm, GraphicObject& rGraphicObj );
530 : :
531 : : static GraphicObject CreateGraphicObjectFromURL( const ::rtl::OUString &rURL );
532 : : // will inspect an object ( e.g. a control ) for any 'ImageURL'
533 : : // properties and return these in a vector. Note: this implementation
534 : : // will cater for XNameContainer objects and deepinspect any containees
535 : : // if they exist
536 : : static void InspectForGraphicObjectImageURL( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIf, std::vector< rtl::OUString >& rvEmbedImgUrls );
537 : : };
538 : :
539 : : // ------------------
540 : : // - GraphicManager -
541 : : // ------------------
542 : :
543 : : typedef ::std::vector< GraphicObject* > GraphicObjectList_impl;
544 : :
545 : : class SVT_DLLPUBLIC GraphicManager
546 : : {
547 : : friend class GraphicObject;
548 : : friend class GraphicDisplayCacheEntry;
549 : :
550 : : private:
551 : :
552 : : GraphicObjectList_impl maObjList;
553 : : GraphicCache* mpCache;
554 : :
555 : : GraphicManager( const GraphicManager& ) {}
556 : : GraphicManager& operator=( const GraphicManager& ) { return *this; }
557 : :
558 : : sal_Bool SVT_DLLPRIVATE ImplDraw(
559 : : OutputDevice* pOut,
560 : : const Point& rPt,
561 : : const Size& rSz,
562 : : GraphicObject& rObj,
563 : : const GraphicAttr& rAttr,
564 : : const sal_uLong nFlags,
565 : : sal_Bool& rCached
566 : : );
567 : :
568 : : sal_Bool SVT_DLLPRIVATE ImplCreateOutput(
569 : : OutputDevice* pOut,
570 : : const Point& rPt,
571 : : const Size& rSz,
572 : : const BitmapEx& rBmpEx,
573 : : const GraphicAttr& rAttr,
574 : : const sal_uLong nFlags,
575 : : BitmapEx* pBmpEx = NULL
576 : : );
577 : : sal_Bool SVT_DLLPRIVATE ImplCreateOutput(
578 : : OutputDevice* pOut,
579 : : const Point& rPt,
580 : : const Size& rSz,
581 : : const GDIMetaFile& rMtf,
582 : : const GraphicAttr& rAttr,
583 : : const sal_uLong nFlags,
584 : : GDIMetaFile& rOutMtf,
585 : : BitmapEx& rOutBmpEx
586 : : );
587 : :
588 : : static void SVT_DLLPRIVATE ImplAdjust(
589 : : BitmapEx& rBmpEx,
590 : : const GraphicAttr& rAttr,
591 : : sal_uLong nAdjustmentFlags
592 : : );
593 : : static void SVT_DLLPRIVATE ImplAdjust(
594 : : GDIMetaFile& rMtf,
595 : : const GraphicAttr& rAttr,
596 : : sal_uLong nAdjustmentFlags
597 : : );
598 : : static void SVT_DLLPRIVATE ImplAdjust(
599 : : Animation& rAnimation,
600 : : const GraphicAttr& rAttr,
601 : : sal_uLong nAdjustmentFlags
602 : : );
603 : :
604 : : static void SVT_DLLPRIVATE ImplDraw(
605 : : OutputDevice* pOut,
606 : : const Point& rPt,
607 : : const Size& rSz,
608 : : const GDIMetaFile& rMtf,
609 : : const GraphicAttr& rAttr
610 : : );
611 : :
612 : : // Only used by GraphicObject's Ctor's and Dtor's
613 : : void SVT_DLLPRIVATE ImplRegisterObj(
614 : : const GraphicObject& rObj,
615 : : Graphic& rSubstitute,
616 : : const rtl::OString* pID = NULL,
617 : : const GraphicObject* pCopyObj = NULL
618 : : );
619 : : void SVT_DLLPRIVATE ImplUnregisterObj( const GraphicObject& rObj );
620 : 28724 : inline sal_Bool SVT_DLLPRIVATE ImplHasObjects() const { return !maObjList.empty(); }
621 : :
622 : : // Only used in swap case by GraphicObject
623 : : void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj );
624 : : sal_Bool SVT_DLLPRIVATE ImplFillSwappedGraphicObject(
625 : : const GraphicObject& rObj,
626 : : Graphic& rSubstitute
627 : : );
628 : : void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj );
629 : :
630 : : rtl::OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const;
631 : :
632 : : public:
633 : :
634 : : GraphicManager( sal_uLong nCacheSize = 10000000UL, sal_uLong nMaxObjCacheSize = 2400000UL );
635 : : ~GraphicManager();
636 : :
637 : : void SetMaxCacheSize( sal_uLong nNewCacheSize );
638 : :
639 : : void SetMaxObjCacheSize(
640 : : sal_uLong nNewMaxObjSize,
641 : : sal_Bool bDestroyGreaterCached = sal_False
642 : : );
643 : :
644 : : void SetCacheTimeout( sal_uLong nTimeoutSeconds );
645 : :
646 : : void ReleaseFromCache( const GraphicObject& rObj );
647 : :
648 : : sal_Bool IsInCache(
649 : : OutputDevice* pOut,
650 : : const Point& rPt,
651 : : const Size& rSz,
652 : : const GraphicObject& rObj,
653 : : const GraphicAttr& rAttr
654 : : ) const;
655 : :
656 : : sal_Bool DrawObj(
657 : : OutputDevice* pOut,
658 : : const Point& rPt,
659 : : const Size& rSz,
660 : : GraphicObject& rObj,
661 : : const GraphicAttr& rAttr,
662 : : const sal_uLong nFlags,
663 : : sal_Bool& rCached
664 : : );
665 : : };
666 : :
667 : : #endif // _GRFMGR_HXX
668 : :
669 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|