Line data Source code
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_SVGDATA_HXX
21 : #define INCLUDED_VCL_SVGDATA_HXX
22 :
23 : #include <basegfx/range/b2drange.hxx>
24 : #include <boost/shared_array.hpp>
25 : #include <boost/shared_ptr.hpp>
26 : #include <boost/utility.hpp>
27 : #include <com/sun/star/graphic/XPrimitive2D.hpp>
28 : #include <vcl/bitmapex.hxx>
29 : #include <rtl/ustring.hxx>
30 :
31 :
32 :
33 : typedef boost::shared_array< sal_uInt8 > SvgDataArray;
34 : typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference;
35 : typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence;
36 :
37 :
38 : // helper to convert any Primitive2DSequence to a good quality BitmapEx,
39 : // using default parameters and graphic::XPrimitive2DRenderer
40 :
41 : BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx(
42 : const Primitive2DSequence& rSequence,
43 : const basegfx::B2DRange& rTargetRange,
44 : const sal_uInt32 nMaximumQuadraticPixels = 500000);
45 :
46 :
47 :
48 0 : class VCL_DLLPUBLIC SvgData : private boost::noncopyable
49 : {
50 : private:
51 : // the file and length
52 : SvgDataArray maSvgDataArray;
53 : sal_uInt32 mnSvgDataArrayLength;
54 :
55 : // The absolute Path if available
56 : OUString maPath;
57 :
58 : // on demand created content
59 : basegfx::B2DRange maRange;
60 : Primitive2DSequence maSequence;
61 : BitmapEx maReplacement;
62 :
63 : // on demand creators
64 : void ensureReplacement();
65 : void ensureSequenceAndRange();
66 :
67 : public:
68 : SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const OUString& rPath);
69 : SvgData(const OUString& rPath);
70 :
71 : /// data read
72 0 : const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
73 0 : sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; }
74 0 : const OUString& getPath() const { return maPath; }
75 :
76 : /// data read and evtl. on demand creation
77 : const basegfx::B2DRange& getRange() const;
78 : const Primitive2DSequence& getPrimitive2DSequence() const;
79 : const BitmapEx& getReplacement() const;
80 : };
81 :
82 : typedef boost::shared_ptr< SvgData > SvgDataPtr;
83 :
84 : #endif // INCLUDED_VCL_SVGDATA_HXX
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|