1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _XEXPTRANSFORM_HXX 29 #define _XEXPTRANSFORM_HXX 30 31 #include <rtl/ustring.hxx> 32 #include <com/sun/star/drawing/PointSequenceSequence.hpp> 33 #include <com/sun/star/drawing/PointSequence.hpp> 34 #include <com/sun/star/awt/Size.hpp> 35 #include <com/sun/star/drawing/FlagSequenceSequence.hpp> 36 #include <com/sun/star/drawing/FlagSequence.hpp> 37 #include <com/sun/star/drawing/HomogenMatrix.hpp> 38 #include <tools/mapunit.hxx> 39 40 #include <vector> 41 42 ////////////////////////////////////////////////////////////////////////////// 43 // predeclarations 44 45 struct ImpSdXMLExpTransObj2DBase; 46 struct ImpSdXMLExpTransObj3DBase; 47 class SvXMLUnitConverter; 48 49 namespace basegfx 50 { 51 class B2DTuple; 52 class B2DHomMatrix; 53 class B3DTuple; 54 class B3DHomMatrix; 55 } // end of namespace basegfx 56 57 ////////////////////////////////////////////////////////////////////////////// 58 59 typedef ::std::vector< ImpSdXMLExpTransObj2DBase* > ImpSdXMLExpTransObj2DBaseList; 60 typedef ::std::vector< ImpSdXMLExpTransObj3DBase* > ImpSdXMLExpTransObj3DBaseList; 61 62 ////////////////////////////////////////////////////////////////////////////// 63 64 class SdXMLImExTransform2D 65 { 66 ImpSdXMLExpTransObj2DBaseList maList; 67 rtl::OUString msString; 68 69 void EmptyList(); 70 71 public: 72 SdXMLImExTransform2D() {} 73 SdXMLImExTransform2D(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); 74 ~SdXMLImExTransform2D() { EmptyList(); } 75 76 void AddRotate(double fNew); 77 void AddScale(const ::basegfx::B2DTuple& rNew); 78 void AddTranslate(const ::basegfx::B2DTuple& rNew); 79 void AddSkewX(double fNew); 80 void AddSkewY(double fNew); 81 void AddMatrix(const ::basegfx::B2DHomMatrix& rNew); 82 83 bool NeedsAction() const { return !maList.empty(); } 84 void GetFullTransform(::basegfx::B2DHomMatrix& rFullTrans); 85 const rtl::OUString& GetExportString(const SvXMLUnitConverter& rConv); 86 void SetString(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); 87 }; 88 89 ////////////////////////////////////////////////////////////////////////////// 90 91 class SdXMLImExTransform3D 92 { 93 ImpSdXMLExpTransObj3DBaseList maList; 94 rtl::OUString msString; 95 96 void EmptyList(); 97 98 public: 99 SdXMLImExTransform3D() {} 100 SdXMLImExTransform3D(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); 101 ~SdXMLImExTransform3D() { EmptyList(); } 102 103 void AddRotateX(double fNew); 104 void AddRotateY(double fNew); 105 void AddRotateZ(double fNew); 106 void AddScale(const ::basegfx::B3DTuple& rNew); 107 void AddTranslate(const ::basegfx::B3DTuple& rNew); 108 void AddMatrix(const ::basegfx::B3DHomMatrix& rNew); 109 110 void AddHomogenMatrix(const com::sun::star::drawing::HomogenMatrix& xHomMat); 111 bool NeedsAction() const { return !maList.empty(); } 112 void GetFullTransform(::basegfx::B3DHomMatrix& rFullTrans); 113 bool GetFullHomogenTransform(com::sun::star::drawing::HomogenMatrix& xHomMat); 114 const rtl::OUString& GetExportString(const SvXMLUnitConverter& rConv); 115 void SetString(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); 116 }; 117 118 ////////////////////////////////////////////////////////////////////////////// 119 120 class SdXMLImExViewBox 121 { 122 rtl::OUString msString; 123 sal_Int32 mnX; 124 sal_Int32 mnY; 125 sal_Int32 mnW; 126 sal_Int32 mnH; 127 128 public: 129 SdXMLImExViewBox(sal_Int32 nX = 0L, sal_Int32 nY = 0L, sal_Int32 nW = 1000L, sal_Int32 nH = 1000L); 130 SdXMLImExViewBox(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv); 131 132 sal_Int32 GetX() const { return mnX; } 133 sal_Int32 GetY() const { return mnY; } 134 sal_Int32 GetWidth() const { return mnW; } 135 sal_Int32 GetHeight() const { return mnH; } 136 const rtl::OUString& GetExportString(); 137 }; 138 139 ////////////////////////////////////////////////////////////////////////////// 140 141 class SdXMLImExPointsElement 142 { 143 rtl::OUString msString; 144 com::sun::star::drawing::PointSequenceSequence maPoly; 145 146 public: 147 SdXMLImExPointsElement(com::sun::star::drawing::PointSequence* pPoints, 148 const SdXMLImExViewBox& rViewBox, 149 const com::sun::star::awt::Point& rObjectPos, 150 const com::sun::star::awt::Size& rObjectSize, 151 // #96328# 152 const bool bClosed = true); 153 SdXMLImExPointsElement(const rtl::OUString& rNew, 154 const SdXMLImExViewBox& rViewBox, 155 const com::sun::star::awt::Point& rObjectPos, 156 const com::sun::star::awt::Size& rObjectSize, 157 const SvXMLUnitConverter& rConv); 158 159 const rtl::OUString& GetExportString() const { return msString; } 160 const com::sun::star::drawing::PointSequenceSequence& GetPointSequenceSequence() const { return maPoly; } 161 }; 162 163 ////////////////////////////////////////////////////////////////////////////// 164 165 class SdXMLImExSvgDElement 166 { 167 rtl::OUString msString; 168 const SdXMLImExViewBox& mrViewBox; 169 bool mbIsClosed; 170 bool mbIsCurve; 171 172 sal_Int32 mnLastX; 173 sal_Int32 mnLastY; 174 175 com::sun::star::drawing::PointSequenceSequence maPoly; 176 com::sun::star::drawing::FlagSequenceSequence maFlag; 177 178 public: 179 SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox); 180 SdXMLImExSvgDElement(const rtl::OUString& rNew, 181 const SdXMLImExViewBox& rViewBox, 182 const com::sun::star::awt::Point& rObjectPos, 183 const com::sun::star::awt::Size& rObjectSize, 184 const SvXMLUnitConverter& rConv); 185 186 void AddPolygon( 187 com::sun::star::drawing::PointSequence* pPoints, 188 com::sun::star::drawing::FlagSequence* pFlags, 189 const com::sun::star::awt::Point& rObjectPos, 190 const com::sun::star::awt::Size& rObjectSize, 191 bool bClosed = false, bool bRelative = true); 192 193 const rtl::OUString& GetExportString() const { return msString; } 194 bool IsClosed() const { return mbIsClosed; } 195 bool IsCurve() const { return mbIsCurve; } 196 const com::sun::star::drawing::PointSequenceSequence& GetPointSequenceSequence() const { return maPoly; } 197 const com::sun::star::drawing::FlagSequenceSequence& GetFlagSequenceSequence() const { return maFlag; } 198 }; 199 200 201 #endif // _XEXPTRANSFORM_HXX 202