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_GFXLINK_HXX 29 #define _SV_GFXLINK_HXX 30 31 #include <vcl/dllapi.h> 32 #include <vcl/sv.h> 33 #include <vcl/mapmod.hxx> 34 #include <tools/stream.hxx> 35 36 // ------------- 37 // - ImpBuffer - 38 // ------------- 39 40 struct ImpBuffer 41 { 42 sal_uLong mnRefCount; 43 sal_uInt8* mpBuffer; 44 45 ImpBuffer( sal_uLong nSize ) 46 { 47 mnRefCount = 1UL; 48 mpBuffer = nSize ? new sal_uInt8[ nSize ] : NULL; 49 } 50 51 ImpBuffer( sal_uInt8* pBuf ) { mnRefCount = 1UL; mpBuffer = pBuf; } 52 53 ~ImpBuffer() { delete[] mpBuffer; } 54 }; 55 56 // ----------- 57 // - ImpSwap - 58 // ----------- 59 60 struct ImpSwap 61 { 62 rtl::OUString maURL; 63 sal_uLong mnDataSize; 64 sal_uLong mnRefCount; 65 66 ImpSwap( sal_uInt8* pData, sal_uLong nDataSize ); 67 ~ImpSwap(); 68 69 sal_uInt8* GetData() const; 70 71 sal_Bool IsSwapped() const { return maURL.getLength() > 0; } 72 73 void WriteTo( SvStream& rOStm ) const; 74 }; 75 76 // -------------- 77 // - ImpGfxLink - 78 // -------------- 79 80 struct ImpGfxLink 81 { 82 MapMode maPrefMapMode; 83 Size maPrefSize; 84 bool mbPrefMapModeValid; 85 bool mbPrefSizeValid; 86 87 ImpGfxLink() : 88 maPrefMapMode(), 89 maPrefSize(), 90 mbPrefMapModeValid( false ), 91 mbPrefSizeValid( false ) 92 {} 93 }; 94 95 //#endif // __PRIVATE 96 97 // --------------- 98 // - GfxLinkType - 99 // --------------- 100 101 enum GfxLinkType 102 { 103 GFX_LINK_TYPE_NONE = 0, 104 GFX_LINK_TYPE_EPS_BUFFER = 1, 105 GFX_LINK_TYPE_NATIVE_GIF = 2, // Don't forget to update the following defines 106 GFX_LINK_TYPE_NATIVE_JPG = 3, // Don't forget to update the following defines 107 GFX_LINK_TYPE_NATIVE_PNG = 4, // Don't forget to update the following defines 108 GFX_LINK_TYPE_NATIVE_TIF = 5, // Don't forget to update the following defines 109 GFX_LINK_TYPE_NATIVE_WMF = 6, // Don't forget to update the following defines 110 GFX_LINK_TYPE_NATIVE_MET = 7, // Don't forget to update the following defines 111 GFX_LINK_TYPE_NATIVE_PCT = 8, // Don't forget to update the following defines 112 GFX_LINK_TYPE_NATIVE_SVG = 9, // Don't forget to update the following defines 113 GFX_LINK_TYPE_USER = 0xffff 114 }; 115 116 #define GFX_LINK_FIRST_NATIVE_ID GFX_LINK_TYPE_NATIVE_GIF 117 #define GFX_LINK_LAST_NATIVE_ID GFX_LINK_TYPE_NATIVE_SVG 118 119 // ----------- 120 // - GfxLink - 121 // ----------- 122 123 struct ImpBuffer; 124 struct ImpSwap; 125 struct ImpGfxLink; 126 class Graphic; 127 128 class VCL_DLLPUBLIC GfxLink 129 { 130 private: 131 132 GfxLinkType meType; 133 ImpBuffer* mpBuf; 134 ImpSwap* mpSwap; 135 sal_uInt32 mnBufSize; 136 sal_uInt32 mnUserId; 137 ImpGfxLink* mpImpData; 138 sal_uLong mnExtra2; 139 140 SAL_DLLPRIVATE void ImplCopy( const GfxLink& rGfxLink ); 141 142 public: 143 GfxLink(); 144 GfxLink( const GfxLink& ); 145 GfxLink( const String& rPath, GfxLinkType nType ); 146 GfxLink( sal_uInt8* pBuf, sal_uInt32 nBufSize, GfxLinkType nType, sal_Bool bOwns ); 147 ~GfxLink(); 148 149 GfxLink& operator=( const GfxLink& ); 150 sal_Bool IsEqual( const GfxLink& ) const; 151 152 GfxLinkType GetType() const; 153 154 void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; } 155 sal_uInt32 GetUserId() const { return mnUserId; } 156 157 sal_uInt32 GetDataSize() const; 158 void SetData( sal_uInt8* pBuf, sal_uInt32 nSize, GfxLinkType nType, sal_Bool bOwns ); 159 const sal_uInt8* GetData() const; 160 161 const Size& GetPrefSize() const; 162 void SetPrefSize( const Size& rPrefSize ); 163 bool IsPrefSizeValid(); 164 165 const MapMode& GetPrefMapMode() const; 166 void SetPrefMapMode( const MapMode& rPrefMapMode ); 167 bool IsPrefMapModeValid(); 168 169 sal_Bool IsNative() const; 170 sal_Bool IsUser() const { return( GFX_LINK_TYPE_USER == meType ); } 171 172 sal_Bool LoadNative( Graphic& rGraphic ); 173 174 sal_Bool ExportNative( SvStream& rOStream ) const; 175 176 void SwapOut(); 177 void SwapIn(); 178 sal_Bool IsSwappedOut() const { return( mpSwap != NULL ); } 179 180 public: 181 182 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const GfxLink& rGfxLink ); 183 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, GfxLink& rGfxLink ); 184 }; 185 186 #endif 187