Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / svgdata.hxx
blob7ab2d8ce89c8309742ea6101a53476a760d46ae1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SVGDATA_HXX
21 #define INCLUDED_VCL_SVGDATA_HXX
23 #include <basegfx/range/b2drange.hxx>
24 #include <com/sun/star/graphic/XPrimitive2D.hpp>
25 #include <vcl/bitmapex.hxx>
26 #include <rtl/ustring.hxx>
27 #include <deque>
30 typedef css::uno::Sequence<sal_Int8> SvgDataArray;
33 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
34 // using default parameters and graphic::XPrimitive2DRenderer
36 BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
37 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence,
38 const basegfx::B2DRange& rTargetRange,
39 const sal_uInt32 nMaximumQuadraticPixels = 500000);
42 class VCL_DLLPUBLIC SvgData
44 private:
45 // the file and length
46 SvgDataArray maSvgDataArray;
48 // The absolute Path if available
49 OUString maPath;
51 // on demand created content
52 basegfx::B2DRange maRange;
53 std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >
54 maSequence;
55 BitmapEx maReplacement;
56 size_t mNestedBitmapSize;
58 // on demand creators
59 void ensureReplacement();
60 void ensureSequenceAndRange();
62 SvgData(const SvgData&) = delete;
63 SvgData& operator=(const SvgData&) = delete;
65 public:
66 SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath);
67 SvgData(const OUString& rPath);
69 /// data read
70 const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
71 sal_uInt32 getSvgDataArrayLength() const { return maSvgDataArray.getLength(); }
72 enum class State { UNPARSED, PARSED };
73 std::pair<State, size_t> getSizeBytes();
74 const OUString& getPath() const { return maPath; }
76 /// data read and evtl. on demand creation
77 const basegfx::B2DRange& getRange() const;
78 const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const;
79 const BitmapEx& getReplacement() const;
82 typedef std::shared_ptr< SvgData > SvgDataPtr;
84 #endif // INCLUDED_VCL_SVGDATA_HXX
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */