LibreOffice Module vcl (master)  1
vectorgraphicdata.hxx
Go to the documentation of this file.
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_VECTORGRAPHICDATA_HXX
21 #define INCLUDED_VCL_VECTORGRAPHICDATA_HXX
22 
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <vcl/bitmapex.hxx>
26 #include <rtl/ustring.hxx>
27 #include <deque>
28 #include <memory>
29 #include <algorithm>
30 
31 namespace com::sun::star::graphic { class XPrimitive2D; }
32 struct WmfExternal;
33 
34 typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray;
35 
36 
37 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
38 // using default parameters and graphic::XPrimitive2DRenderer
39 
41  const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
42  const basegfx::B2DRange& rTargetRange,
43  const sal_uInt32 nMaximumQuadraticPixels = 500000);
44 
45 
47 {
48  Svg = 0,
49  Emf = 1,
50  Wmf = 2,
51  Pdf = 3
52 };
53 
55 {
56 private:
57  // the file and length
59 
60  // The absolute Path if available
61  OUString maPath;
62 
63  // on demand created content
66  std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence;
70 
71  // extra:
72  std::unique_ptr<WmfExternal> mpExternalHeader;
73 
74  // If the vector format has more pages this denotes which page to render
75  sal_Int32 mnPageIndex;
76 
77  // on demand creators
78  void ensurePdfReplacement();
79  void ensureReplacement();
80  void ensureSequenceAndRange();
81 
82  VectorGraphicData(const VectorGraphicData&) = delete;
83  VectorGraphicData& operator=(const VectorGraphicData&) = delete;
84 
85 public:
87  const VectorGraphicDataArray& rVectorGraphicDataArray,
88  const OUString& rPath,
89  VectorGraphicDataType eVectorDataType,
90  sal_Int32 nPageIndex = -1);
91  VectorGraphicData(const OUString& rPath, VectorGraphicDataType eVectorDataType);
93 
95  bool operator==(const VectorGraphicData& rCandidate) const;
96 
98  void setWmfExternalHeader(const WmfExternal& aExtHeader);
99 
101  const VectorGraphicDataArray& getVectorGraphicDataArray() const { return maVectorGraphicDataArray; }
102  sal_uInt32 getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray.getLength(); }
103  enum class State { UNPARSED, PARSED };
104  std::pair<State, size_t> getSizeBytes() const;
105  const OUString& getPath() const { return maPath; }
106  const VectorGraphicDataType& getVectorGraphicDataType() const { return meVectorGraphicDataType; }
107 
109  const basegfx::B2DRange& getRange() const;
110  const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const;
111  const BitmapEx& getReplacement() const;
112  BitmapChecksum GetChecksum() const;
113 
114  sal_Int32 getPageIndex() const { return std::max(sal_Int32(0), mnPageIndex); }
115 
116  bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
117 };
118 
119 #endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX
120 
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VectorGraphicDataType
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
const VectorGraphicDataArray & getVectorGraphicDataArray() const
data read
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
const OUString & getPath() const
const VectorGraphicDataType & getVectorGraphicDataType() const
VectorGraphicDataArray maVectorGraphicDataArray
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > &rSequence, const basegfx::B2DRange &rTargetRange, const sal_uInt32 nMaximumQuadraticPixels=500000)
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:206
basegfx::B2DRange maRange
bool isPrimitiveSequenceCreated() const
sal_Int32 getPageIndex() const
B2DRange getRange(const B2DPolygon &rCandidate)
css::uno::Sequence< sal_Int8 > VectorGraphicDataArray
std::unique_ptr< WmfExternal > mpExternalHeader
VectorGraphicDataType meVectorGraphicDataType
sal_uInt32 getVectorGraphicDataArrayLength() const
std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence