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>
27#include <rtl/ustring.hxx>
28#include <deque>
29#include <memory>
30#include <algorithm>
31#include <optional>
32
33namespace com::sun::star::graphic { class XPrimitive2D; }
34
35typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray;
36
37
38// helper to convert any Primitive2DSequence to a good quality BitmapEx,
39// using default parameters and graphic::XPrimitive2DRenderer
40
42 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
43 const basegfx::B2DRange& rTargetRange,
44 const sal_uInt32 nMaximumQuadraticPixels = 500000,
45 const o3tl::Length eTargetUnit = o3tl::Length::mm100,
46 const std::optional<Size>& rTargetDPI = std::nullopt);
47
48
50{
51 Svg = 0,
52 Emf = 1,
53 Wmf = 2,
54 Pdf = 3
55};
56
58{
59private:
60 // the file and length
62
63 // on demand created content
66 std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence;
70
72 sal_Int32 mnPageIndex;
73
76
77 bool mbEnableEMFPlus = true;
78
79 // on demand creators
80 void ensurePdfReplacement();
81 void ensureReplacement();
82 void ensureSequenceAndRange();
83
86
87public:
88 VectorGraphicData(const OUString& rPath, VectorGraphicDataType eVectorDataType);
90 BinaryDataContainer aDataContainer,
91 VectorGraphicDataType eVectorDataType,
92 sal_Int32 nPageIndex = -1);
94
96 bool operator==(const VectorGraphicData& rCandidate) const;
97
100 {
101 return maDataContainer;
102 }
103
104 enum class State { UNPARSED, PARSED };
105 std::pair<State, size_t> getSizeBytes() const;
106
107 const VectorGraphicDataType& getType() const { return meType; }
108
110 const basegfx::B2DRange& getRange() const;
111 const std::deque<css::uno::Reference<css::graphic::XPrimitive2D>>& getPrimitive2DSequence() const;
112 const BitmapEx& getReplacement() const;
113 BitmapChecksum GetChecksum() const;
114
115 sal_Int32 getPageIndex() const
116 {
117 return std::max(sal_Int32(0), mnPageIndex);
118 }
119
120 void setPageIndex(sal_Int32 nPageIndex)
121 {
122 mnPageIndex = nPageIndex;
123 }
124
125 void setSizeHint(const basegfx::B2DTuple& rSizeHint)
126 {
127 maSizeHint = rSizeHint;
128 }
129
130 const basegfx::B2DTuple& getSizeHint() const { return maSizeHint; }
131
132 void setEnableEMFPlus(bool bEnableEMFPlus) { mbEnableEMFPlus = bEnableEMFPlus; }
133
134 bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
135};
136
137#endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX
138
139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
Container for the binary data, whose responsibility is to manage the make it as simple as possible to...
bool isPrimitiveSequenceCreated() const
void setSizeHint(const basegfx::B2DTuple &rSizeHint)
sal_Int32 getPageIndex() const
VectorGraphicDataType meType
void setPageIndex(sal_Int32 nPageIndex)
std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence
void setEnableEMFPlus(bool bEnableEMFPlus)
VectorGraphicData(const VectorGraphicData &)=delete
const basegfx::B2DTuple & getSizeHint() const
BinaryDataContainer maDataContainer
basegfx::B2DRange maRange
VectorGraphicData & operator=(const VectorGraphicData &)=delete
basegfx::B2DTuple maSizeHint
Useful for PDF, which is vector-based, but still rendered to a bitmap.
sal_Int32 mnPageIndex
If the vector format has more pages this denotes which page to render.
const VectorGraphicDataType & getType() const
const BinaryDataContainer & getBinaryDataContainer() const
data read
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
B2DRange getRange(const B2DPolygon &rCandidate)
bool operator==(const ItalicMatrix &a, const ItalicMatrix &b)
Definition: vclenum.hxx:182
BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > &rSequence, const basegfx::B2DRange &rTargetRange, const sal_uInt32 nMaximumQuadraticPixels=500000, const o3tl::Length eTargetUnit=o3tl::Length::mm100, const std::optional< Size > &rTargetDPI=std::nullopt)
css::uno::Sequence< sal_Int8 > VectorGraphicDataArray
VectorGraphicDataType
RedlineType meType
basegfx::B2DTuple maSizeHint