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 
30 namespace com { namespace sun { namespace star { namespace graphic { class XPrimitive2D; } } } }
31 struct WmfExternal;
32 
33 typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray;
34 
35 
36 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
37 // using default parameters and graphic::XPrimitive2DRenderer
38 
40  const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
41  const basegfx::B2DRange& rTargetRange,
42  const sal_uInt32 nMaximumQuadraticPixels = 500000);
43 
44 
46 {
47  Svg = 0,
48  Emf = 1,
49  Wmf = 2,
50  Pdf = 3
51 };
52 
54 {
55 private:
56  // the file and length
58 
59  // The absolute Path if available
60  OUString maPath;
61 
62  // on demand created content
65  std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence;
69 
70  // extra:
71  std::unique_ptr<WmfExternal> mpExternalHeader;
72 
73  // If the vector format has more pages this denotes which page to render
74  sal_Int32 mnPageIndex;
75 
76  // on demand creators
77  void ensurePdfReplacement();
78  void ensureReplacement();
79  void ensureSequenceAndRange();
80 
81  VectorGraphicData(const VectorGraphicData&) = delete;
82  VectorGraphicData& operator=(const VectorGraphicData&) = delete;
83 
84 public:
86  const VectorGraphicDataArray& rVectorGraphicDataArray,
87  const OUString& rPath,
88  VectorGraphicDataType eVectorDataType,
89  sal_Int32 nPageIndex = -1);
90  VectorGraphicData(const OUString& rPath, VectorGraphicDataType eVectorDataType);
92 
94  bool operator==(const VectorGraphicData& rCandidate) const;
95 
97  void setWmfExternalHeader(const WmfExternal& aExtHeader);
98 
100  const VectorGraphicDataArray& getVectorGraphicDataArray() const { return maVectorGraphicDataArray; }
101  sal_uInt32 getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray.getLength(); }
102  enum class State { UNPARSED, PARSED };
103  std::pair<State, size_t> getSizeBytes() const;
104  const OUString& getPath() const { return maPath; }
105  const VectorGraphicDataType& getVectorGraphicDataType() const { return meVectorGraphicDataType; }
106 
108  const basegfx::B2DRange& getRange() const;
109  const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const;
110  const BitmapEx& getReplacement() const;
111  BitmapChecksum GetChecksum() const;
112 
113  sal_Int32 getPageIndex() const { return mnPageIndex; }
114 
115  bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
116 };
117 
118 typedef std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr;
119 
120 #endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX
121 
122 /* 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)
std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr
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