/src/libreoffice/include/vcl/gfxlink.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_VCL_GFXLINK_HXX |
21 | | #define INCLUDED_VCL_GFXLINK_HXX |
22 | | |
23 | | #include <tools/gen.hxx> |
24 | | #include <vcl/dllapi.h> |
25 | | #include <vcl/mapmod.hxx> |
26 | | #include <vcl/filter/embedfontinfo.hxx> |
27 | | #include <vcl/BinaryDataContainer.hxx> |
28 | | |
29 | | class SvStream; |
30 | | |
31 | | /** GfxLink graphic types that are supported by GfxLink. |
32 | | * |
33 | | * It is important that the numbers for native types stay the same, because |
34 | | * they are used in serialization to MTF. |
35 | | */ |
36 | | enum class GfxLinkType |
37 | | { |
38 | | NONE = 0, |
39 | | EpsBuffer = 1, |
40 | | NativeGif = 2, |
41 | | NativeJpg = 3, |
42 | | NativePng = 4, |
43 | | NativeTif = 5, |
44 | | NativeWmf = 6, |
45 | | NativeMet = 7, |
46 | | NativePct = 8, |
47 | | NativeSvg = 9, |
48 | | NativeMov = 10, |
49 | | NativeBmp = 11, |
50 | | NativePdf = 12, |
51 | | NativeWebp = 13, // If a new type is added, make sure to change NativeLast too |
52 | | |
53 | | // Alias for when the first native type starts and last native |
54 | | // type ends. |
55 | | NativeFirst = NativeGif, |
56 | | NativeLast = NativeWebp, |
57 | | }; |
58 | | |
59 | | class Graphic; |
60 | | |
61 | | class VCL_DLLPUBLIC GfxLink |
62 | | { |
63 | | private: |
64 | | GfxLinkType meType; |
65 | | sal_uInt32 mnUserId; |
66 | | BinaryDataContainer maDataContainer; |
67 | | /// Useful for PDF, where multiple Graphics referring to individual pages |
68 | | /// of a single PDF share a GfxLink, to describe PDF fonts that are already |
69 | | /// imported from the PDF. |
70 | | std::shared_ptr<ImportedFontMap> mxImportedFonts; |
71 | | mutable size_t maHash; |
72 | | MapMode maPrefMapMode; |
73 | | Size maPrefSize; |
74 | | bool mbPrefMapModeValid; |
75 | | bool mbPrefSizeValid; |
76 | | |
77 | | public: |
78 | | GfxLink(); |
79 | | explicit GfxLink(BinaryDataContainer aDataConainer, GfxLinkType nType); |
80 | | |
81 | | bool operator==( const GfxLink& ) const; |
82 | | |
83 | 438 | GfxLinkType GetType() const { return meType;} |
84 | | |
85 | | size_t GetHash() const; |
86 | | |
87 | 1.89k | void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; } |
88 | 0 | sal_uInt32 GetUserId() const { return mnUserId; } |
89 | | |
90 | 34.6k | sal_uInt32 GetDataSize() const { return maDataContainer.getSize(); } |
91 | | const sal_uInt8* GetData() const; |
92 | | |
93 | | /// return the in-memory size as of now. |
94 | 0 | size_t getSizeBytes() const { return maDataContainer.getSizeBytes(); } |
95 | | |
96 | | const BinaryDataContainer& getDataContainer() const |
97 | 213 | { |
98 | 213 | return maDataContainer; |
99 | 213 | } |
100 | | |
101 | 0 | const Size& GetPrefSize() const { return maPrefSize;} |
102 | | void SetPrefSize( const Size& rPrefSize ); |
103 | 0 | bool IsPrefSizeValid() const { return mbPrefSizeValid;} |
104 | | |
105 | 0 | const MapMode& GetPrefMapMode() const { return maPrefMapMode;} |
106 | | void SetPrefMapMode( const MapMode& rPrefMapMode ); |
107 | 0 | bool IsPrefMapModeValid() const { return mbPrefMapModeValid;} |
108 | | |
109 | 162 | void setImportedFonts(const std::shared_ptr<ImportedFontMap>& rImportedFonts) { mxImportedFonts = rImportedFonts; } |
110 | 213 | const std::shared_ptr<ImportedFontMap>& getImportedFonts() const { return mxImportedFonts; } |
111 | | |
112 | | bool IsNative() const; |
113 | | |
114 | | bool LoadNative(Graphic& rGraphic, sal_Int32 nPageNum = -1) const; |
115 | | |
116 | | bool ExportNative( SvStream& rOStream ) const; |
117 | | |
118 | | bool IsEMF() const; // WMF & EMF stored under the same type (NativeWmf) |
119 | | }; |
120 | | |
121 | | #endif |
122 | | |
123 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |