10d63794cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 30d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 40d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file 50d63794cSAndrew Rist * distributed with this work for additional information 60d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 70d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the 80d63794cSAndrew Rist * "License"); you may not use this file except in compliance 90d63794cSAndrew Rist * with the License. You may obtain a copy of the License at 100d63794cSAndrew Rist * 110d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 120d63794cSAndrew Rist * 130d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing, 140d63794cSAndrew Rist * software distributed under the License is distributed on an 150d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 160d63794cSAndrew Rist * KIND, either express or implied. See the License for the 170d63794cSAndrew Rist * specific language governing permissions and limitations 180d63794cSAndrew Rist * under the License. 190d63794cSAndrew Rist * 200d63794cSAndrew Rist *************************************************************/ 210d63794cSAndrew Rist 220d63794cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SV_GFXLINK_HXX 25cdf0e10cSrcweir #define _SV_GFXLINK_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/dllapi.h> 28cdf0e10cSrcweir #include <vcl/sv.h> 29cdf0e10cSrcweir #include <vcl/mapmod.hxx> 30cdf0e10cSrcweir #include <tools/stream.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir // ------------- 33cdf0e10cSrcweir // - ImpBuffer - 34cdf0e10cSrcweir // ------------- 35cdf0e10cSrcweir 36cdf0e10cSrcweir struct ImpBuffer 37cdf0e10cSrcweir { 38cdf0e10cSrcweir sal_uLong mnRefCount; 39cdf0e10cSrcweir sal_uInt8* mpBuffer; 40cdf0e10cSrcweir ImpBufferImpBuffer41cdf0e10cSrcweir ImpBuffer( sal_uLong nSize ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir mnRefCount = 1UL; 44cdf0e10cSrcweir mpBuffer = nSize ? new sal_uInt8[ nSize ] : NULL; 45cdf0e10cSrcweir } 46cdf0e10cSrcweir ImpBufferImpBuffer47cdf0e10cSrcweir ImpBuffer( sal_uInt8* pBuf ) { mnRefCount = 1UL; mpBuffer = pBuf; } 48cdf0e10cSrcweir ~ImpBufferImpBuffer49cdf0e10cSrcweir ~ImpBuffer() { delete[] mpBuffer; } 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir // ----------- 53cdf0e10cSrcweir // - ImpSwap - 54cdf0e10cSrcweir // ----------- 55cdf0e10cSrcweir 56cdf0e10cSrcweir struct ImpSwap 57cdf0e10cSrcweir { 58cdf0e10cSrcweir rtl::OUString maURL; 59cdf0e10cSrcweir sal_uLong mnDataSize; 60cdf0e10cSrcweir sal_uLong mnRefCount; 61cdf0e10cSrcweir 62cdf0e10cSrcweir ImpSwap( sal_uInt8* pData, sal_uLong nDataSize ); 63cdf0e10cSrcweir ~ImpSwap(); 64cdf0e10cSrcweir 65cdf0e10cSrcweir sal_uInt8* GetData() const; 66cdf0e10cSrcweir IsSwappedImpSwap67cdf0e10cSrcweir sal_Bool IsSwapped() const { return maURL.getLength() > 0; } 68cdf0e10cSrcweir 69cdf0e10cSrcweir void WriteTo( SvStream& rOStm ) const; 70cdf0e10cSrcweir }; 71cdf0e10cSrcweir 72cdf0e10cSrcweir // -------------- 73cdf0e10cSrcweir // - ImpGfxLink - 74cdf0e10cSrcweir // -------------- 75cdf0e10cSrcweir 76cdf0e10cSrcweir struct ImpGfxLink 77cdf0e10cSrcweir { 78cdf0e10cSrcweir MapMode maPrefMapMode; 79cdf0e10cSrcweir Size maPrefSize; 80cdf0e10cSrcweir bool mbPrefMapModeValid; 81cdf0e10cSrcweir bool mbPrefSizeValid; 82cdf0e10cSrcweir ImpGfxLinkImpGfxLink83cdf0e10cSrcweir ImpGfxLink() : 84cdf0e10cSrcweir maPrefMapMode(), 85cdf0e10cSrcweir maPrefSize(), 86cdf0e10cSrcweir mbPrefMapModeValid( false ), 87cdf0e10cSrcweir mbPrefSizeValid( false ) 88cdf0e10cSrcweir {} 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir //#endif // __PRIVATE 92cdf0e10cSrcweir 93cdf0e10cSrcweir // --------------- 94cdf0e10cSrcweir // - GfxLinkType - 95cdf0e10cSrcweir // --------------- 96cdf0e10cSrcweir 97cdf0e10cSrcweir enum GfxLinkType 98cdf0e10cSrcweir { 99cdf0e10cSrcweir GFX_LINK_TYPE_NONE = 0, 100cdf0e10cSrcweir GFX_LINK_TYPE_EPS_BUFFER = 1, 101cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_GIF = 2, // Don't forget to update the following defines 102cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_JPG = 3, // Don't forget to update the following defines 103cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_PNG = 4, // Don't forget to update the following defines 104cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_TIF = 5, // Don't forget to update the following defines 105cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_WMF = 6, // Don't forget to update the following defines 106cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_MET = 7, // Don't forget to update the following defines 107cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_PCT = 8, // Don't forget to update the following defines 108cdf0e10cSrcweir GFX_LINK_TYPE_NATIVE_SVG = 9, // Don't forget to update the following defines 109*270a30dfSArmin Le Grand 110*270a30dfSArmin Le Grand // #15508# added BMP type support 111*270a30dfSArmin Le Grand GFX_LINK_TYPE_NATIVE_BMP = 10, // Don't forget to update the following defines 112*270a30dfSArmin Le Grand 113cdf0e10cSrcweir GFX_LINK_TYPE_USER = 0xffff 114cdf0e10cSrcweir }; 115cdf0e10cSrcweir 116cdf0e10cSrcweir #define GFX_LINK_FIRST_NATIVE_ID GFX_LINK_TYPE_NATIVE_GIF 117*270a30dfSArmin Le Grand #define GFX_LINK_LAST_NATIVE_ID GFX_LINK_TYPE_NATIVE_BMP 118cdf0e10cSrcweir 119cdf0e10cSrcweir // ----------- 120cdf0e10cSrcweir // - GfxLink - 121cdf0e10cSrcweir // ----------- 122cdf0e10cSrcweir 123cdf0e10cSrcweir struct ImpBuffer; 124cdf0e10cSrcweir struct ImpSwap; 125cdf0e10cSrcweir struct ImpGfxLink; 126cdf0e10cSrcweir class Graphic; 127cdf0e10cSrcweir 128cdf0e10cSrcweir class VCL_DLLPUBLIC GfxLink 129cdf0e10cSrcweir { 130cdf0e10cSrcweir private: 131cdf0e10cSrcweir 132cdf0e10cSrcweir GfxLinkType meType; 133cdf0e10cSrcweir ImpBuffer* mpBuf; 134cdf0e10cSrcweir ImpSwap* mpSwap; 135cdf0e10cSrcweir sal_uInt32 mnBufSize; 136cdf0e10cSrcweir sal_uInt32 mnUserId; 137cdf0e10cSrcweir ImpGfxLink* mpImpData; 138cdf0e10cSrcweir sal_uLong mnExtra2; 139cdf0e10cSrcweir 140cdf0e10cSrcweir SAL_DLLPRIVATE void ImplCopy( const GfxLink& rGfxLink ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir public: 143cdf0e10cSrcweir GfxLink(); 144cdf0e10cSrcweir GfxLink( const GfxLink& ); 145cdf0e10cSrcweir GfxLink( const String& rPath, GfxLinkType nType ); 146cdf0e10cSrcweir GfxLink( sal_uInt8* pBuf, sal_uInt32 nBufSize, GfxLinkType nType, sal_Bool bOwns ); 147cdf0e10cSrcweir ~GfxLink(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir GfxLink& operator=( const GfxLink& ); 150cdf0e10cSrcweir sal_Bool IsEqual( const GfxLink& ) const; 151cdf0e10cSrcweir 152cdf0e10cSrcweir GfxLinkType GetType() const; 153cdf0e10cSrcweir SetUserId(sal_uInt32 nUserId)154cdf0e10cSrcweir void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; } GetUserId() const155cdf0e10cSrcweir sal_uInt32 GetUserId() const { return mnUserId; } 156cdf0e10cSrcweir 157cdf0e10cSrcweir sal_uInt32 GetDataSize() const; 158cdf0e10cSrcweir void SetData( sal_uInt8* pBuf, sal_uInt32 nSize, GfxLinkType nType, sal_Bool bOwns ); 159cdf0e10cSrcweir const sal_uInt8* GetData() const; 160cdf0e10cSrcweir 161cdf0e10cSrcweir const Size& GetPrefSize() const; 162cdf0e10cSrcweir void SetPrefSize( const Size& rPrefSize ); 163cdf0e10cSrcweir bool IsPrefSizeValid(); 164cdf0e10cSrcweir 165cdf0e10cSrcweir const MapMode& GetPrefMapMode() const; 166cdf0e10cSrcweir void SetPrefMapMode( const MapMode& rPrefMapMode ); 167cdf0e10cSrcweir bool IsPrefMapModeValid(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir sal_Bool IsNative() const; IsUser() const170cdf0e10cSrcweir sal_Bool IsUser() const { return( GFX_LINK_TYPE_USER == meType ); } 171cdf0e10cSrcweir 172cdf0e10cSrcweir sal_Bool LoadNative( Graphic& rGraphic ); 173cdf0e10cSrcweir 174cdf0e10cSrcweir sal_Bool ExportNative( SvStream& rOStream ) const; 175cdf0e10cSrcweir 176cdf0e10cSrcweir void SwapOut(); 177cdf0e10cSrcweir void SwapIn(); IsSwappedOut() const178cdf0e10cSrcweir sal_Bool IsSwappedOut() const { return( mpSwap != NULL ); } 179cdf0e10cSrcweir 180cdf0e10cSrcweir public: 181cdf0e10cSrcweir 182cdf0e10cSrcweir friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const GfxLink& rGfxLink ); 183cdf0e10cSrcweir friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, GfxLink& rGfxLink ); 184cdf0e10cSrcweir }; 185cdf0e10cSrcweir 186cdf0e10cSrcweir #endif 187