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 _SV_GRAPH_HXX 25 #define _SV_GRAPH_HXX 26 27 #include <tools/stream.hxx> 28 #include <vcl/dllapi.h> 29 #include <vcl/sv.h> 30 #include <vcl/bitmap.hxx> 31 #include <vcl/bitmapex.hxx> 32 #include <vcl/animate.hxx> 33 #include <vcl/gdimtf.hxx> 34 #include <vcl/graph.h> 35 #include <vcl/gfxlink.hxx> 36 #include <com/sun/star/uno/Reference.hxx> 37 #include <vcl/svgdata.hxx> 38 39 namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } } 40 41 // ----------- 42 // - Graphic - 43 // ----------- 44 45 class ImpGraphic; 46 class OutputDevice; 47 class Font; 48 class GfxLink; 49 50 class VCL_DLLPUBLIC GraphicConversionParameters 51 { 52 private: 53 Size maSizePixel; // default is (0,0) 54 55 // bitfield 56 unsigned mbUnlimitedSize : 1; // default is false 57 unsigned mbAntiAliase : 1; // default is false 58 unsigned mbSnapHorVerLines : 1; // default is false 59 unsigned mbScaleHighQuality : 1; // default is false 60 61 public: GraphicConversionParameters(const Size & rSizePixel=Size (),bool bUnlimitedSize=false,bool bAntiAliase=false,bool bSnapHorVerLines=false,bool bScaleHighQuality=false)62 GraphicConversionParameters( 63 const Size& rSizePixel = Size(), 64 bool bUnlimitedSize = false, 65 bool bAntiAliase = false, 66 bool bSnapHorVerLines = false, 67 bool bScaleHighQuality = false) 68 : maSizePixel(rSizePixel), 69 mbUnlimitedSize(bUnlimitedSize), 70 mbAntiAliase(bAntiAliase), 71 mbSnapHorVerLines(bSnapHorVerLines), 72 mbScaleHighQuality(bScaleHighQuality) 73 { 74 } 75 76 // data read access getSizePixel() const77 const Size getSizePixel() const { return maSizePixel; } getUnlimitedSize() const78 bool getUnlimitedSize() const { return mbUnlimitedSize; } getAntiAliase() const79 bool getAntiAliase() const { return mbAntiAliase; } getSnapHorVerLines() const80 bool getSnapHorVerLines() const { return mbSnapHorVerLines; } getScaleHighQuality() const81 bool getScaleHighQuality() const { return mbScaleHighQuality; } 82 }; 83 84 class VCL_DLLPUBLIC Graphic : public SvDataCopyStream 85 { 86 private: 87 88 ImpGraphic* mpImpGraphic; 89 90 //#if 0 // _SOLAR__PRIVATE 91 92 public: 93 94 SAL_DLLPRIVATE void ImplTestRefCount(); ImplGetImpGraphic() const95 SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mpImpGraphic; } 96 97 //#endif 98 99 public: 100 101 TYPEINFO(); 102 103 Graphic(); 104 Graphic( const Graphic& rGraphic ); 105 Graphic( const Bitmap& rBmp ); 106 Graphic( const BitmapEx& rBmpEx ); 107 Graphic(const SvgDataPtr& rSvgDataPtr); 108 Graphic( const Animation& rAnimation ); 109 Graphic( const GDIMetaFile& rMtf ); 110 Graphic( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ); 111 virtual ~Graphic(); 112 113 Graphic& operator=( const Graphic& rGraphic ); 114 sal_Bool operator==( const Graphic& rGraphic ) const; 115 sal_Bool operator!=( const Graphic& rGraphic ) const; 116 sal_Bool operator!() const; 117 118 void Clear(); 119 120 GraphicType GetType() const; 121 void SetDefaultType(); 122 sal_Bool IsSupportedGraphic() const; 123 124 sal_Bool IsTransparent() const; 125 sal_Bool IsAlpha() const; 126 sal_Bool IsAnimated() const; 127 sal_Bool IsEPS() 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 140 ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const; 141 142 Size GetPrefSize() const; 143 void SetPrefSize( const Size& rPrefSize ); 144 145 MapMode GetPrefMapMode() const; 146 void SetPrefMapMode( const MapMode& rPrefMapMode ); 147 148 Size GetSizePixel( const OutputDevice* pRefDevice = NULL ) const; 149 150 sal_uLong GetSizeBytes() const; 151 152 void Draw( OutputDevice* pOutDev, 153 const Point& rDestPt ) const; 154 void Draw( OutputDevice* pOutDev, 155 const Point& rDestPt, 156 const Size& rDestSize ) const; 157 static void Draw( OutputDevice* pOutDev, const String& rText, 158 Font& rFont, const Bitmap& rBitmap, 159 const Point& rDestPt, const Size& rDestSize ); 160 static void DrawEx( OutputDevice* pOutDev, const String& rText, 161 Font& rFont, const BitmapEx& rBitmap, 162 const Point& rDestPt, const Size& rDestSize ); 163 164 void StartAnimation( OutputDevice* pOutDev, 165 const Point& rDestPt, 166 long nExtraData = 0L, 167 OutputDevice* pFirstFrameOutDev = NULL ); 168 void StartAnimation( OutputDevice* pOutDev, 169 const Point& rDestPt, 170 const Size& rDestSize, 171 long nExtraData = 0L, 172 OutputDevice* pFirstFrameOutDev = NULL ); 173 void StopAnimation( OutputDevice* pOutputDevice = NULL, 174 long nExtraData = 0L ); 175 176 void SetAnimationNotifyHdl( const Link& rLink ); 177 Link GetAnimationNotifyHdl() const; 178 179 sal_uLong GetAnimationLoopCount() const; 180 void ResetAnimationLoopCount(); 181 182 List* GetAnimationInfoList() const; 183 184 sal_uLong GetChecksum() const; 185 186 public: 187 188 GraphicReader* GetContext(); 189 void SetContext( GraphicReader* pReader ); 190 191 public: 192 193 static sal_uInt16 GetGraphicsCompressMode( SvStream& rIStm ); 194 195 void SetDocFileName( const String& rName, sal_uLong nFilePos ); 196 const String& GetDocFileName() const; 197 sal_uLong GetDocFilePos() const; 198 199 sal_Bool ReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False ); 200 sal_Bool WriteEmbedded( SvStream& rOStream ); 201 202 sal_Bool SwapOut(); 203 sal_Bool SwapOut( SvStream* pOStm ); 204 sal_Bool SwapIn(); 205 sal_Bool SwapIn( SvStream* pIStm ); 206 sal_Bool IsSwapOut() const; 207 208 void SetLink( const GfxLink& ); 209 GfxLink GetLink() const; 210 sal_Bool IsLink() const; 211 212 sal_Bool ExportNative( SvStream& rOStream ) const; 213 214 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const Graphic& rGraphic ); 215 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, Graphic& rGraphic ); 216 217 public: 218 219 virtual void Load( SvStream& ); 220 virtual void Save( SvStream& ); 221 virtual void Assign( const SvDataCopyStream& ); 222 223 // SvgData support 224 const SvgDataPtr& getSvgData() const; 225 }; 226 227 #endif // _SV_GRAPH_HXX 228