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 _SV_GRAPH_HXX
30 : : #define _SV_GRAPH_HXX
31 : :
32 : : #include <tools/stream.hxx>
33 : : #include <vcl/dllapi.h>
34 : : #include <tools/solar.h>
35 : : #include <vcl/bitmap.hxx>
36 : : #include <vcl/bitmapex.hxx>
37 : : #include <vcl/animate.hxx>
38 : : #include <vcl/gdimtf.hxx>
39 : : #include <vcl/rendergraphic.hxx>
40 : : #include <vcl/graph.h>
41 : : #include <vcl/gfxlink.hxx>
42 : : #include <com/sun/star/uno/Reference.hxx>
43 : : #include <com/sun/star/uno/Sequence.hxx>
44 : :
45 : : namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
46 : :
47 : : // -----------
48 : : // - Graphic -
49 : : // -----------
50 : :
51 : : class ImpGraphic;
52 : : class OutputDevice;
53 : : class Font;
54 : : class GfxLink;
55 : :
56 : : class VCL_DLLPUBLIC GraphicConversionParameters
57 : : {
58 : : private:
59 : : Size maSizePixel; // default is (0,0)
60 : :
61 : : // bitfield
62 : : unsigned mbUnlimitedSize : 1; // default is false
63 : : unsigned mbAntiAliase : 1; // default is false
64 : : unsigned mbSnapHorVerLines : 1; // default is false
65 : :
66 : : public:
67 : 249662 : GraphicConversionParameters(
68 : : const Size& rSizePixel = Size(),
69 : : bool bUnlimitedSize = false,
70 : : bool bAntiAliase = false,
71 : : bool bSnapHorVerLines = false)
72 : : : maSizePixel(rSizePixel),
73 : : mbUnlimitedSize(bUnlimitedSize),
74 : : mbAntiAliase(bAntiAliase),
75 : 249662 : mbSnapHorVerLines(bSnapHorVerLines)
76 : : {
77 : 249662 : }
78 : :
79 : : // data read access
80 : 298074 : const Size getSizePixel() const { return maSizePixel; }
81 : 0 : bool getUnlimitedSize() const { return mbUnlimitedSize; }
82 : 0 : bool getAntiAliase() const { return mbAntiAliase; }
83 : 0 : bool getSnapHorVerLines() const { return mbSnapHorVerLines; }
84 : : };
85 : :
86 : : class VCL_DLLPUBLIC Graphic : public SvDataCopyStream
87 : : {
88 : : private:
89 : :
90 : : ImpGraphic* mpImpGraphic;
91 : :
92 : : public:
93 : :
94 : : SAL_DLLPRIVATE void ImplTestRefCount();
95 : 6 : SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mpImpGraphic; }
96 : :
97 : : public:
98 : : static com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelId();
99 : :
100 : : TYPEINFO();
101 : :
102 : : Graphic();
103 : : Graphic( const Graphic& rGraphic );
104 : : Graphic( const Bitmap& rBmp );
105 : : Graphic( const BitmapEx& rBmpEx );
106 : : Graphic( const Animation& rAnimation );
107 : : Graphic( const GDIMetaFile& rMtf );
108 : : Graphic( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic );
109 : : virtual ~Graphic();
110 : :
111 : : Graphic& operator=( const Graphic& rGraphic );
112 : : sal_Bool operator==( const Graphic& rGraphic ) const;
113 : : sal_Bool operator!=( const Graphic& rGraphic ) const;
114 : : sal_Bool operator!() const;
115 : :
116 : : void Clear();
117 : :
118 : : GraphicType GetType() const;
119 : : void SetDefaultType();
120 : : sal_Bool IsSupportedGraphic() const;
121 : :
122 : : sal_Bool IsTransparent() const;
123 : : sal_Bool IsAlpha() const;
124 : : sal_Bool IsAnimated() const;
125 : : sal_Bool IsEPS() const;
126 : : sal_Bool IsRenderGraphic() const;
127 : : sal_Bool HasRenderGraphic() const;
128 : :
129 : : // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic
130 : : // if it is a MetaFile. To be able to control this conversion it is necessary to
131 : : // allow giving parameters which control AntiAliasing and LineSnapping of the
132 : : // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as
133 : : // before.
134 : : Bitmap GetBitmap(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const;
135 : : BitmapEx GetBitmapEx(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const;
136 : :
137 : : Animation GetAnimation() const;
138 : : const GDIMetaFile& GetGDIMetaFile() const;
139 : : ::vcl::RenderGraphic GetRenderGraphic() const;
140 : :
141 : : ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const;
142 : :
143 : : Size GetPrefSize() const;
144 : : void SetPrefSize( const Size& rPrefSize );
145 : :
146 : : MapMode GetPrefMapMode() const;
147 : : void SetPrefMapMode( const MapMode& rPrefMapMode );
148 : :
149 : : Size GetSizePixel( const OutputDevice* pRefDevice = NULL ) const;
150 : :
151 : : sal_uLong GetSizeBytes() const;
152 : :
153 : : void Draw( OutputDevice* pOutDev,
154 : : const Point& rDestPt ) const;
155 : : void Draw( OutputDevice* pOutDev,
156 : : const Point& rDestPt,
157 : : const Size& rDestSize ) const;
158 : : static void DrawEx( OutputDevice* pOutDev, const String& rText,
159 : : Font& rFont, const BitmapEx& rBitmap,
160 : : const Point& rDestPt, const Size& rDestSize );
161 : :
162 : : void StartAnimation( OutputDevice* pOutDev,
163 : : const Point& rDestPt,
164 : : const Size& rDestSize,
165 : : long nExtraData = 0L,
166 : : OutputDevice* pFirstFrameOutDev = NULL );
167 : : void StopAnimation( OutputDevice* pOutputDevice = NULL,
168 : : long nExtraData = 0L );
169 : :
170 : : void SetAnimationNotifyHdl( const Link& rLink );
171 : : Link GetAnimationNotifyHdl() const;
172 : :
173 : : sal_uLong GetAnimationLoopCount() const;
174 : :
175 : : sal_uLong GetChecksum() const;
176 : :
177 : : public:
178 : :
179 : : GraphicReader* GetContext();
180 : : void SetContext( GraphicReader* pReader );
181 : :
182 : : public:
183 : :
184 : : void SetDocFileName( const String& rName, sal_uLong nFilePos );
185 : : const String& GetDocFileName() const;
186 : : sal_uLong GetDocFilePos() const;
187 : :
188 : : sal_Bool ReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False );
189 : :
190 : : sal_Bool SwapOut();
191 : : sal_Bool SwapOut( SvStream* pOStm );
192 : : sal_Bool SwapIn();
193 : : sal_Bool SwapIn( SvStream* pIStm );
194 : : sal_Bool IsSwapOut() const;
195 : :
196 : : void SetLink( const GfxLink& );
197 : : GfxLink GetLink() const;
198 : : sal_Bool IsLink() const;
199 : :
200 : : sal_Bool ExportNative( SvStream& rOStream ) const;
201 : :
202 : : friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const Graphic& rGraphic );
203 : : friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, Graphic& rGraphic );
204 : :
205 : : public:
206 : :
207 : : virtual void Load( SvStream& );
208 : : virtual void Save( SvStream& );
209 : : virtual void Assign( const SvDataCopyStream& );
210 : : };
211 : :
212 : : #endif // _SV_GRAPH_HXX
213 : :
214 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|