Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / svgdata.hxx
blob15d27565b6700e8e667dcf4eca008a818bc376df
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 <boost/shared_array.hpp>
25 #include <com/sun/star/graphic/XPrimitive2D.hpp>
26 #include <vcl/bitmapex.hxx>
27 #include <rtl/ustring.hxx>
30 typedef boost::shared_array< sal_uInt8 > SvgDataArray;
31 typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference;
32 typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence;
35 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
36 // using default parameters and graphic::XPrimitive2DRenderer
38 BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
39 const Primitive2DSequence& rSequence,
40 const basegfx::B2DRange& rTargetRange,
41 const sal_uInt32 nMaximumQuadraticPixels = 500000);
44 class VCL_DLLPUBLIC SvgData
46 private:
47 // the file and length
48 SvgDataArray maSvgDataArray;
49 sal_uInt32 mnSvgDataArrayLength;
51 // The absolute Path if available
52 OUString maPath;
54 // on demand created content
55 basegfx::B2DRange maRange;
56 Primitive2DSequence maSequence;
57 BitmapEx maReplacement;
59 // on demand creators
60 void ensureReplacement();
61 void ensureSequenceAndRange();
63 SvgData(const SvgData&) SAL_DELETED_FUNCTION;
64 SvgData& operator=(const SvgData&) SAL_DELETED_FUNCTION;
66 public:
67 SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const OUString& rPath);
68 SvgData(const OUString& rPath);
70 /// data read
71 const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
72 sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; }
73 const OUString& getPath() const { return maPath; }
75 /// data read and evtl. on demand creation
76 const basegfx::B2DRange& getRange() const;
77 const Primitive2DSequence& getPrimitive2DSequence() const;
78 const BitmapEx& getReplacement() const;
81 typedef std::shared_ptr< SvgData > SvgDataPtr;
83 #endif // INCLUDED_VCL_SVGDATA_HXX
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */