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