1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 #ifndef _SV_SVGDATA_HXX 22 #define _SV_SVGDATA_HXX 23 24 #include <basegfx/range/b2drange.hxx> 25 #include <boost/shared_array.hpp> 26 #include <boost/shared_ptr.hpp> 27 #include <boost/utility.hpp> 28 #include <com/sun/star/graphic/XPrimitive2D.hpp> 29 #include <vcl/bitmapex.hxx> 30 #include <rtl/ustring.hxx> 31 32 ////////////////////////////////////////////////////////////////////////////// 33 34 typedef boost::shared_array< sal_uInt8 > SvgDataArray; 35 typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference; 36 typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence; 37 38 ////////////////////////////////////////////////////////////////////////////// 39 // helper to convert any Primitive2DSequence to a good quality BitmapEx, 40 // using default parameters and graphic::XPrimitive2DRenderer 41 42 BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( 43 const Primitive2DSequence& rSequence, 44 const basegfx::B2DRange& rTargetRange, 45 const sal_uInt32 nMaximumQuadraticPixels = 500000); 46 47 ////////////////////////////////////////////////////////////////////////////// 48 49 class VCL_DLLPUBLIC SvgData : private boost::noncopyable 50 { 51 private: 52 // the file and length 53 SvgDataArray maSvgDataArray; 54 sal_uInt32 mnSvgDataArrayLength; 55 56 // The absolute Path if available 57 rtl::OUString maPath; 58 59 // on demand created content 60 basegfx::B2DRange maRange; 61 Primitive2DSequence maSequence; 62 BitmapEx maReplacement; 63 64 // on demand creators 65 void ensureReplacement(); 66 void ensureSequenceAndRange(); 67 68 public: 69 SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const rtl::OUString& rPath); 70 71 /// data read getSvgDataArray() const72 const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; } getSvgDataArrayLength() const73 sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; } getPath() const74 const rtl::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 ////////////////////////////////////////////////////////////////////////////// 83 84 typedef boost::shared_ptr< SvgData > SvgDataPtr; 85 86 ////////////////////////////////////////////////////////////////////////////// 87 88 #endif // _SV_SVGDATA_HXX 89 90 ////////////////////////////////////////////////////////////////////////////// 91 // eof 92