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_VECTORGRAPHICDATA_HXX
21 #define INCLUDED_VCL_VECTORGRAPHICDATA_HXX
23 #include <basegfx/range/b2drange.hxx>
24 #include <com/sun/star/graphic/XPrimitive2D.hpp>
25 #include <vcl/bitmapex.hxx>
26 #include <vcl/wmfexternal.hxx>
27 #include <rtl/ustring.hxx>
32 typedef css::uno::Sequence
<sal_Int8
> VectorGraphicDataArray
;
35 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
36 // using default parameters and graphic::XPrimitive2DRenderer
38 BitmapEx VCL_DLLPUBLIC
convertPrimitive2DSequenceToBitmapEx(
39 const std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> >& rSequence
,
40 const basegfx::B2DRange
& rTargetRange
,
41 const sal_uInt32 nMaximumQuadraticPixels
= 500000);
44 enum class VectorGraphicDataType
51 class VCL_DLLPUBLIC VectorGraphicData
54 // the file and length
55 VectorGraphicDataArray maVectorGraphicDataArray
;
57 // The absolute Path if available
60 // on demand created content
61 bool mbSequenceCreated
;
62 basegfx::B2DRange maRange
;
63 std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> > maSequence
;
64 BitmapEx maReplacement
;
65 size_t mNestedBitmapSize
;
66 VectorGraphicDataType meVectorGraphicDataType
;
69 std::unique_ptr
<WmfExternal
> mpExternalHeader
;
72 void ensureReplacement();
73 void ensureSequenceAndRange();
75 VectorGraphicData(const VectorGraphicData
&) = delete;
76 VectorGraphicData
& operator=(const VectorGraphicData
&) = delete;
80 const VectorGraphicDataArray
& rVectorGraphicDataArray
,
81 const OUString
& rPath
,
82 VectorGraphicDataType eVectorDataType
);
84 const OUString
& rPath
,
85 VectorGraphicDataType eVectorDataType
);
89 bool operator==(const VectorGraphicData
& rCandidate
) const;
91 /// special: needed for emf/wmf, maybe replaced by scaling the result later (?)
92 void setWmfExternalHeader(const WmfExternal
& aExtHeader
);
95 const VectorGraphicDataArray
& getVectorGraphicDataArray() const { return maVectorGraphicDataArray
; }
96 sal_uInt32
getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray
.getLength(); }
97 enum class State
{ UNPARSED
, PARSED
};
98 std::pair
<State
, size_t> getSizeBytes();
99 const OUString
& getPath() const { return maPath
; }
100 const VectorGraphicDataType
& getVectorGraphicDataType() const { return meVectorGraphicDataType
; }
102 /// data read and evtl. on demand creation
103 const basegfx::B2DRange
& getRange() const;
104 const std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> >& getPrimitive2DSequence() const;
105 const BitmapEx
& getReplacement() const;
108 typedef std::shared_ptr
< VectorGraphicData
> VectorGraphicDataPtr
;
110 #endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */