1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_VCL_GFXLINK_HXX
21 #define INCLUDED_VCL_GFXLINK_HXX
23 #include <rtl/ustring.hxx>
24 #include <tools/gen.hxx>
25 #include <tools/solar.h>
26 #include <vcl/dllapi.h>
27 #include <vcl/mapmod.hxx>
32 enum class GfxLinkType
36 NativeGif
= 2, // Don't forget to update the following defines
37 NativeJpg
= 3, // Don't forget to update the following defines
38 NativePng
= 4, // Don't forget to update the following defines
39 NativeTif
= 5, // Don't forget to update the following defines
40 NativeWmf
= 6, // Don't forget to update the following defines
41 NativeMet
= 7, // Don't forget to update the following defines
42 NativePct
= 8, // Don't forget to update the following defines
43 NativeSvg
= 9, // Don't forget to update the following defines
44 NativeMov
= 10, // Don't forget to update the following defines
46 NativePdf
= 12 // Don't forget to update the following defines
49 #define GFX_LINK_FIRST_NATIVE_ID GfxLinkType::NativeGif
50 #define GFX_LINK_LAST_NATIVE_ID GfxLinkType::NativePdf
54 class VCL_DLLPUBLIC GfxLink
60 SwapOutData(const OUString
&aURL
);
63 OUString maURL
; // File is removed in the destructor
67 GfxLinkType meType
= GfxLinkType::NONE
;
68 sal_uInt32 mnUserId
= 0;
70 std::shared_ptr
<sal_uInt8
> mpSwapInData
;
71 std::shared_ptr
<SwapOutData
> mpSwapOutData
;
73 sal_uInt32 mnSwapInDataSize
= 0;
74 MapMode maPrefMapMode
;
76 bool mbPrefMapModeValid
= false;
77 bool mbPrefSizeValid
= false;
79 SAL_DLLPRIVATE
std::shared_ptr
<sal_uInt8
> GetSwapInData() const;
83 // pBuff = The Graphic data. This class takes ownership of this
84 GfxLink( std::unique_ptr
<sal_uInt8
[]> pBuf
, sal_uInt32 nBufSize
, GfxLinkType nType
);
86 bool IsEqual( const GfxLink
& ) const;
88 GfxLinkType
GetType() const { return meType
;}
90 void SetUserId( sal_uInt32 nUserId
) { mnUserId
= nUserId
; }
91 sal_uInt32
GetUserId() const { return mnUserId
; }
93 sal_uInt32
GetDataSize() const { return mnSwapInDataSize
;}
94 const sal_uInt8
* GetData() const;
96 const Size
& GetPrefSize() const { return maPrefSize
;}
97 void SetPrefSize( const Size
& rPrefSize
);
98 bool IsPrefSizeValid() { return mbPrefSizeValid
;}
100 const MapMode
& GetPrefMapMode() const { return maPrefMapMode
;}
101 void SetPrefMapMode( const MapMode
& rPrefMapMode
);
102 bool IsPrefMapModeValid() { return mbPrefMapModeValid
;}
104 bool IsNative() const;
106 bool LoadNative( Graphic
& rGraphic
);
108 bool ExportNative( SvStream
& rOStream
) const;
112 bool IsSwappedOut() const { return( bool(mpSwapOutData
) ); }
116 friend VCL_DLLPUBLIC SvStream
& WriteGfxLink( SvStream
& rOStream
, const GfxLink
& rGfxLink
);
117 friend VCL_DLLPUBLIC SvStream
& ReadGfxLink( SvStream
& rIStream
, GfxLink
& rGfxLink
);
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */