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_VCL_INC_IMPGRAPH_HXX
21 : #define INCLUDED_VCL_INC_IMPGRAPH_HXX
22 :
23 : #include <vcl/bitmap.hxx>
24 : #include <vcl/bitmapex.hxx>
25 : #include <vcl/animate.hxx>
26 : #include <vcl/gdimtf.hxx>
27 : #include <vcl/graph.h>
28 : #include <vcl/svgdata.hxx>
29 :
30 : // - ImpSwapInfo -
31 :
32 0 : struct ImpSwapInfo
33 : {
34 : MapMode maPrefMapMode;
35 : Size maPrefSize;
36 : };
37 :
38 : // - ImpGraphic -
39 :
40 : class OutputDevice;
41 : class GfxLink;
42 : struct ImpSwapFile;
43 : class GraphicConversionParameters;
44 :
45 : class ImpGraphic
46 : {
47 : friend class Graphic;
48 :
49 : private:
50 :
51 : GDIMetaFile maMetaFile;
52 : BitmapEx maEx;
53 : ImpSwapInfo maSwapInfo;
54 : Animation* mpAnimation;
55 : GraphicReader* mpContext;
56 : ImpSwapFile* mpSwapFile;
57 : GfxLink* mpGfxLink;
58 : GraphicType meType;
59 : OUString maDocFileURLStr;
60 : sal_uLong mnDocFilePos;
61 : mutable sal_uLong mnSizeBytes;
62 : sal_uLong mnRefCount;
63 : bool mbSwapOut;
64 : bool mbSwapUnderway;
65 :
66 : // SvgData support
67 : SvgDataPtr maSvgData;
68 :
69 : private:
70 :
71 : ImpGraphic();
72 : ImpGraphic( const ImpGraphic& rImpGraphic );
73 : ImpGraphic( const Bitmap& rBmp );
74 : ImpGraphic( const BitmapEx& rBmpEx );
75 : ImpGraphic(const SvgDataPtr& rSvgDataPtr);
76 : ImpGraphic( const Animation& rAnimation );
77 : ImpGraphic( const GDIMetaFile& rMtf );
78 : virtual ~ImpGraphic();
79 :
80 : ImpGraphic& operator=( const ImpGraphic& rImpGraphic );
81 : bool operator==( const ImpGraphic& rImpGraphic ) const;
82 0 : bool operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); }
83 :
84 : void ImplClearGraphics( bool bCreateSwapInfo );
85 : void ImplClear();
86 :
87 : GraphicType ImplGetType() const;
88 : void ImplSetDefaultType();
89 : bool ImplIsSupportedGraphic() const;
90 :
91 : bool ImplIsTransparent() const;
92 : bool ImplIsAlpha() const;
93 : bool ImplIsAnimated() const;
94 : bool ImplIsEPS() const;
95 :
96 : Bitmap ImplGetBitmap(const GraphicConversionParameters& rParameters) const;
97 : BitmapEx ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const;
98 : Animation ImplGetAnimation() const;
99 : const GDIMetaFile& ImplGetGDIMetaFile() const;
100 :
101 : Size ImplGetPrefSize() const;
102 : void ImplSetPrefSize( const Size& rPrefSize );
103 :
104 : MapMode ImplGetPrefMapMode() const;
105 : void ImplSetPrefMapMode( const MapMode& rPrefMapMode );
106 :
107 : sal_uLong ImplGetSizeBytes() const;
108 :
109 : void ImplDraw( OutputDevice* pOutDev,
110 : const Point& rDestPt ) const;
111 : void ImplDraw( OutputDevice* pOutDev,
112 : const Point& rDestPt,
113 : const Size& rDestSize ) const;
114 :
115 : void ImplStartAnimation( OutputDevice* pOutDev,
116 : const Point& rDestPt,
117 : const Size& rDestSize,
118 : long nExtraData = 0,
119 : OutputDevice* pFirstFrameOutDev = NULL );
120 : void ImplStopAnimation( OutputDevice* pOutputDevice = NULL,
121 : long nExtraData = 0 );
122 :
123 : void ImplSetAnimationNotifyHdl( const Link& rLink );
124 : Link ImplGetAnimationNotifyHdl() const;
125 :
126 : sal_uLong ImplGetAnimationLoopCount() const;
127 :
128 : private:
129 :
130 : GraphicReader* ImplGetContext();
131 : void ImplSetContext( GraphicReader* pReader );
132 :
133 : private:
134 :
135 : void ImplSetDocFileName( const OUString& rName, sal_uLong nFilePos );
136 : const OUString& ImplGetDocFileName() const;
137 : sal_uLong ImplGetDocFilePos() const;
138 :
139 : bool ImplReadEmbedded( SvStream& rIStream, bool bSwap = false );
140 : bool ImplWriteEmbedded( SvStream& rOStream );
141 :
142 : bool ImplSwapIn();
143 : bool ImplSwapIn( SvStream* pIStm );
144 :
145 : bool ImplSwapOut();
146 : bool ImplSwapOut( SvStream* pOStm );
147 :
148 : bool ImplIsSwapOut() const;
149 :
150 : void ImplSetLink( const GfxLink& );
151 : GfxLink ImplGetLink();
152 : bool ImplIsLink() const;
153 :
154 : sal_uLong ImplGetChecksum() const;
155 :
156 : bool ImplExportNative( SvStream& rOStm ) const;
157 :
158 : friend SvStream& WriteImpGraphic( SvStream& rOStm, const ImpGraphic& rImpGraphic );
159 : friend SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic );
160 :
161 : // SvgData support
162 : const SvgDataPtr& getSvgData() const;
163 : };
164 :
165 : #endif // INCLUDED_VCL_INC_IMPGRAPH_HXX
166 :
167 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|