1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SV_IMPGRAPH_HXX 29 #define _SV_IMPGRAPH_HXX 30 31 #include <tools/urlobj.hxx> 32 #include <vcl/bitmap.hxx> 33 #include <vcl/bitmapex.hxx> 34 #include <vcl/animate.hxx> 35 #include <vcl/gdimtf.hxx> 36 #include <vcl/rendergraphic.hxx> 37 #include <vcl/graph.h> 38 39 // --------------- 40 // - ImpSwapInfo - 41 // --------------- 42 43 struct ImpSwapInfo 44 { 45 MapMode maPrefMapMode; 46 Size maPrefSize; 47 }; 48 49 // -------------- 50 // - ImpGraphic - 51 // -------------- 52 53 class OutputDevice; 54 class GfxLink; 55 struct ImpSwapFile; 56 class GraphicConversionParameters; 57 58 class ImpGraphic 59 { 60 friend class Graphic; 61 62 private: 63 64 GDIMetaFile maMetaFile; 65 BitmapEx maEx; 66 ImpSwapInfo maSwapInfo; 67 Animation* mpAnimation; 68 GraphicReader* mpContext; 69 ImpSwapFile* mpSwapFile; 70 GfxLink* mpGfxLink; 71 GraphicType meType; 72 String maDocFileURLStr; 73 sal_uLong mnDocFilePos; 74 mutable sal_uLong mnSizeBytes; 75 sal_uLong mnRefCount; 76 sal_Bool mbSwapOut; 77 sal_Bool mbSwapUnderway; 78 79 private: 80 81 ImpGraphic(); 82 ImpGraphic( const ImpGraphic& rImpGraphic ); 83 ImpGraphic( const Bitmap& rBmp ); 84 ImpGraphic( const BitmapEx& rBmpEx ); 85 ImpGraphic( const Animation& rAnimation ); 86 ImpGraphic( const GDIMetaFile& rMtf ); 87 virtual ~ImpGraphic(); 88 89 ImpGraphic& operator=( const ImpGraphic& rImpGraphic ); 90 sal_Bool operator==( const ImpGraphic& rImpGraphic ) const; 91 sal_Bool operator!=( const ImpGraphic& rImpGraphic ) const { return !( *this == rImpGraphic ); } 92 93 void ImplClearGraphics( sal_Bool bCreateSwapInfo ); 94 void ImplClear(); 95 96 GraphicType ImplGetType() const; 97 void ImplSetDefaultType(); 98 sal_Bool ImplIsSupportedGraphic() const; 99 100 sal_Bool ImplIsTransparent() const; 101 sal_Bool ImplIsAlpha() const; 102 sal_Bool ImplIsAnimated() const; 103 sal_Bool ImplIsEPS() const; 104 sal_Bool ImplIsRenderGraphic() const; 105 sal_Bool ImplHasRenderGraphic() const; 106 107 Bitmap ImplGetBitmap(const GraphicConversionParameters& rParameters) const; 108 BitmapEx ImplGetBitmapEx(const GraphicConversionParameters& rParameters) const; 109 Animation ImplGetAnimation() const; 110 const GDIMetaFile& ImplGetGDIMetaFile() const; 111 ::vcl::RenderGraphic ImplGetRenderGraphic() const; 112 113 114 Size ImplGetPrefSize() const; 115 void ImplSetPrefSize( const Size& rPrefSize ); 116 117 MapMode ImplGetPrefMapMode() const; 118 void ImplSetPrefMapMode( const MapMode& rPrefMapMode ); 119 120 sal_uLong ImplGetSizeBytes() const; 121 122 void ImplDraw( OutputDevice* pOutDev, 123 const Point& rDestPt ) const; 124 void ImplDraw( OutputDevice* pOutDev, 125 const Point& rDestPt, 126 const Size& rDestSize ) const; 127 128 void ImplStartAnimation( OutputDevice* pOutDev, 129 const Point& rDestPt, 130 long nExtraData = 0, 131 OutputDevice* pFirstFrameOutDev = NULL ); 132 void ImplStartAnimation( OutputDevice* pOutDev, 133 const Point& rDestPt, 134 const Size& rDestSize, 135 long nExtraData = 0, 136 OutputDevice* pFirstFrameOutDev = NULL ); 137 void ImplStopAnimation( OutputDevice* pOutputDevice = NULL, 138 long nExtraData = 0 ); 139 140 void ImplSetAnimationNotifyHdl( const Link& rLink ); 141 Link ImplGetAnimationNotifyHdl() const; 142 143 sal_uLong ImplGetAnimationLoopCount() const; 144 void ImplResetAnimationLoopCount(); 145 146 List* ImplGetAnimationInfoList() const; 147 148 private: 149 150 GraphicReader* ImplGetContext(); 151 void ImplSetContext( GraphicReader* pReader ); 152 153 private: 154 155 void ImplSetDocFileName( const String& rName, sal_uLong nFilePos ); 156 const String& ImplGetDocFileName() const; 157 sal_uLong ImplGetDocFilePos() const; 158 159 sal_Bool ImplReadEmbedded( SvStream& rIStream, sal_Bool bSwap = sal_False ); 160 sal_Bool ImplWriteEmbedded( SvStream& rOStream ); 161 162 sal_Bool ImplSwapIn(); 163 sal_Bool ImplSwapIn( SvStream* pIStm ); 164 165 sal_Bool ImplSwapOut(); 166 sal_Bool ImplSwapOut( SvStream* pOStm ); 167 168 sal_Bool ImplIsSwapOut() const; 169 170 void ImplSetLink( const GfxLink& ); 171 GfxLink ImplGetLink(); 172 sal_Bool ImplIsLink() const; 173 174 sal_uLong ImplGetChecksum() const; 175 176 sal_Bool ImplExportNative( SvStream& rOStm ) const; 177 178 friend SvStream& operator<<( SvStream& rOStm, const ImpGraphic& rImpGraphic ); 179 friend SvStream& operator>>( SvStream& rIStm, ImpGraphic& rImpGraphic ); 180 }; 181 182 #endif // _SV_IMPGRAPH_HXX 183