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