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/uno/Sequence.hxx>
25 #include <vcl/bitmapex.hxx>
26 #include <rtl/ustring.hxx>
30 namespace com
{ namespace sun
{ namespace star
{ namespace graphic
{ class XPrimitive2D
; } } } }
33 typedef css::uno::Sequence
<sal_Int8
> VectorGraphicDataArray
;
36 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
37 // using default parameters and graphic::XPrimitive2DRenderer
39 BitmapEx VCL_DLLPUBLIC
convertPrimitive2DSequenceToBitmapEx(
40 const std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> >& rSequence
,
41 const basegfx::B2DRange
& rTargetRange
,
42 const sal_uInt32 nMaximumQuadraticPixels
= 500000);
45 enum class VectorGraphicDataType
52 class VCL_DLLPUBLIC VectorGraphicData
55 // the file and length
56 VectorGraphicDataArray maVectorGraphicDataArray
;
58 // The absolute Path if available
59 OUString
const maPath
;
61 // on demand created content
62 bool mbSequenceCreated
;
63 basegfx::B2DRange maRange
;
64 std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> > maSequence
;
65 BitmapEx maReplacement
;
66 size_t mNestedBitmapSize
;
67 VectorGraphicDataType
const meVectorGraphicDataType
;
70 std::unique_ptr
<WmfExternal
> mpExternalHeader
;
73 void ensureReplacement();
74 void ensureSequenceAndRange();
76 VectorGraphicData(const VectorGraphicData
&) = delete;
77 VectorGraphicData
& operator=(const VectorGraphicData
&) = delete;
81 const VectorGraphicDataArray
& rVectorGraphicDataArray
,
82 const OUString
& rPath
,
83 VectorGraphicDataType eVectorDataType
);
85 const OUString
& rPath
,
86 VectorGraphicDataType eVectorDataType
);
90 bool operator==(const VectorGraphicData
& rCandidate
) const;
92 /// special: needed for emf/wmf, maybe replaced by scaling the result later (?)
93 void setWmfExternalHeader(const WmfExternal
& aExtHeader
);
96 const VectorGraphicDataArray
& getVectorGraphicDataArray() const { return maVectorGraphicDataArray
; }
97 sal_uInt32
getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray
.getLength(); }
98 enum class State
{ UNPARSED
, PARSED
};
99 std::pair
<State
, size_t> getSizeBytes() const;
100 const OUString
& getPath() const { return maPath
; }
101 const VectorGraphicDataType
& getVectorGraphicDataType() const { return meVectorGraphicDataType
; }
103 /// data read and evtl. on demand creation
104 const basegfx::B2DRange
& getRange() const;
105 const std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> >& getPrimitive2DSequence() const;
106 const BitmapEx
& getReplacement() const;
107 BitmapChecksum
GetChecksum() const;
110 typedef std::shared_ptr
< VectorGraphicData
> VectorGraphicDataPtr
;
112 #endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */