update credits
[LibreOffice.git] / include / vcl / gfxlink.hxx
blob380298b500b8ac140a4b84e2a5f984e01d0f31b7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _SV_GFXLINK_HXX
21 #define _SV_GFXLINK_HXX
23 #include <vcl/dllapi.h>
24 #include <tools/solar.h>
25 #include <vcl/mapmod.hxx>
26 #include <tools/stream.hxx>
28 // -------------
29 // - ImpBuffer -
30 // -------------
32 struct ImpBuffer
34 sal_uLong mnRefCount;
35 sal_uInt8* mpBuffer;
37 ImpBuffer( sal_uLong nSize )
39 mnRefCount = 1UL;
40 mpBuffer = nSize ? new sal_uInt8[ nSize ] : NULL;
43 ImpBuffer( sal_uInt8* pBuf ) { mnRefCount = 1UL; mpBuffer = pBuf; }
45 ~ImpBuffer() { delete[] mpBuffer; }
48 // -----------
49 // - ImpSwap -
50 // -----------
52 struct ImpSwap
54 OUString maURL;
55 sal_uLong mnDataSize;
56 sal_uLong mnRefCount;
58 ImpSwap( sal_uInt8* pData, sal_uLong nDataSize );
59 ~ImpSwap();
61 sal_uInt8* GetData() const;
63 sal_Bool IsSwapped() const { return maURL.getLength() > 0; }
65 void WriteTo( SvStream& rOStm ) const;
68 // --------------
69 // - ImpGfxLink -
70 // --------------
72 struct ImpGfxLink
74 MapMode maPrefMapMode;
75 Size maPrefSize;
76 bool mbPrefMapModeValid;
77 bool mbPrefSizeValid;
79 ImpGfxLink() :
80 maPrefMapMode(),
81 maPrefSize(),
82 mbPrefMapModeValid( false ),
83 mbPrefSizeValid( false )
87 //#endif // __PRIVATE
89 // ---------------
90 // - GfxLinkType -
91 // ---------------
93 enum GfxLinkType
95 GFX_LINK_TYPE_NONE = 0,
96 GFX_LINK_TYPE_EPS_BUFFER = 1,
97 GFX_LINK_TYPE_NATIVE_GIF = 2, // Don't forget to update the following defines
98 GFX_LINK_TYPE_NATIVE_JPG = 3, // Don't forget to update the following defines
99 GFX_LINK_TYPE_NATIVE_PNG = 4, // Don't forget to update the following defines
100 GFX_LINK_TYPE_NATIVE_TIF = 5, // Don't forget to update the following defines
101 GFX_LINK_TYPE_NATIVE_WMF = 6, // Don't forget to update the following defines
102 GFX_LINK_TYPE_NATIVE_MET = 7, // Don't forget to update the following defines
103 GFX_LINK_TYPE_NATIVE_PCT = 8, // Don't forget to update the following defines
104 GFX_LINK_TYPE_NATIVE_SVG = 9, // Don't forget to update the following defines
105 GFX_LINK_TYPE_USER = 0xffff
108 #define GFX_LINK_FIRST_NATIVE_ID GFX_LINK_TYPE_NATIVE_GIF
109 #define GFX_LINK_LAST_NATIVE_ID GFX_LINK_TYPE_NATIVE_SVG
111 // -----------
112 // - GfxLink -
113 // -----------
115 struct ImpBuffer;
116 struct ImpSwap;
117 struct ImpGfxLink;
118 class Graphic;
120 class VCL_DLLPUBLIC GfxLink
122 private:
124 GfxLinkType meType;
125 ImpBuffer* mpBuf;
126 ImpSwap* mpSwap;
127 sal_uInt32 mnBufSize;
128 sal_uInt32 mnUserId;
129 ImpGfxLink* mpImpData;
130 sal_uLong mnExtra2;
132 SAL_DLLPRIVATE void ImplCopy( const GfxLink& rGfxLink );
134 public:
135 GfxLink();
136 GfxLink( const GfxLink& );
137 GfxLink( const String& rPath, GfxLinkType nType );
138 GfxLink( sal_uInt8* pBuf, sal_uInt32 nBufSize, GfxLinkType nType, sal_Bool bOwns );
139 ~GfxLink();
141 GfxLink& operator=( const GfxLink& );
142 sal_Bool IsEqual( const GfxLink& ) const;
144 GfxLinkType GetType() const;
146 void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; }
147 sal_uInt32 GetUserId() const { return mnUserId; }
149 sal_uInt32 GetDataSize() const;
150 void SetData( sal_uInt8* pBuf, sal_uInt32 nSize, GfxLinkType nType, sal_Bool bOwns );
151 const sal_uInt8* GetData() const;
153 const Size& GetPrefSize() const;
154 void SetPrefSize( const Size& rPrefSize );
155 bool IsPrefSizeValid();
157 const MapMode& GetPrefMapMode() const;
158 void SetPrefMapMode( const MapMode& rPrefMapMode );
159 bool IsPrefMapModeValid();
161 sal_Bool IsNative() const;
162 sal_Bool IsUser() const { return( GFX_LINK_TYPE_USER == meType ); }
164 sal_Bool LoadNative( Graphic& rGraphic );
166 sal_Bool ExportNative( SvStream& rOStream ) const;
168 void SwapOut();
169 void SwapIn();
170 sal_Bool IsSwappedOut() const { return( mpSwap != NULL ); }
172 public:
174 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStream, const GfxLink& rGfxLink );
175 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStream, GfxLink& rGfxLink );
178 #endif
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */