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_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>
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
45 // the file and length
46 SvgDataArray maSvgDataArray
;
48 // The absolute Path if available
51 // on demand created content
52 basegfx::B2DRange maRange
;
53 std::deque
< css::uno::Reference
< css::graphic::XPrimitive2D
> >
55 BitmapEx maReplacement
;
56 size_t mNestedBitmapSize
;
59 void ensureReplacement();
60 void ensureSequenceAndRange();
62 SvgData(const SvgData
&) = delete;
63 SvgData
& operator=(const SvgData
&) = delete;
66 SvgData(const SvgDataArray
& rSvgDataArray
, const OUString
& rPath
);
67 SvgData(const OUString
& rPath
);
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: */