xref: /aoo41x/main/xmloff/inc/xexptran.hxx (revision ecfe53c5)
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 
22 
23 
24 #ifndef _XEXPTRANSFORM_HXX
25 #define _XEXPTRANSFORM_HXX
26 
27 #include <rtl/ustring.hxx>
28 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
29 #include <com/sun/star/drawing/PointSequence.hpp>
30 #include <com/sun/star/awt/Size.hpp>
31 #include <com/sun/star/drawing/FlagSequenceSequence.hpp>
32 #include <com/sun/star/drawing/FlagSequence.hpp>
33 #include <com/sun/star/drawing/HomogenMatrix.hpp>
34 #include <tools/mapunit.hxx>
35 
36 #include <vector>
37 
38 //////////////////////////////////////////////////////////////////////////////
39 // predeclarations
40 
41 struct ImpSdXMLExpTransObj2DBase;
42 struct ImpSdXMLExpTransObj3DBase;
43 class SvXMLUnitConverter;
44 
45 namespace basegfx
46 {
47 	class B2DTuple;
48 	class B2DHomMatrix;
49 	class B3DTuple;
50 	class B3DHomMatrix;
51 } // end of namespace basegfx
52 
53 //////////////////////////////////////////////////////////////////////////////
54 
55 typedef ::std::vector< ImpSdXMLExpTransObj2DBase* > ImpSdXMLExpTransObj2DBaseList;
56 typedef ::std::vector< ImpSdXMLExpTransObj3DBase* > ImpSdXMLExpTransObj3DBaseList;
57 
58 //////////////////////////////////////////////////////////////////////////////
59 
60 class SdXMLImExTransform2D
61 {
62 	ImpSdXMLExpTransObj2DBaseList	maList;
63 	rtl::OUString					msString;
64 
65 	void EmptyList();
66 
67 public:
68 	SdXMLImExTransform2D() {}
69 	SdXMLImExTransform2D(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv);
70 	~SdXMLImExTransform2D() { EmptyList(); }
71 
72 	void AddRotate(double fNew);
73 	void AddScale(const ::basegfx::B2DTuple& rNew);
74 	void AddTranslate(const ::basegfx::B2DTuple& rNew);
75 	void AddSkewX(double fNew);
76 	void AddSkewY(double fNew);
77 	void AddMatrix(const ::basegfx::B2DHomMatrix& rNew);
78 
79 	bool NeedsAction() const { return !maList.empty(); }
80 	void GetFullTransform(::basegfx::B2DHomMatrix& rFullTrans);
81 	const rtl::OUString& GetExportString(const SvXMLUnitConverter& rConv);
82 	void SetString(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv);
83 };
84 
85 //////////////////////////////////////////////////////////////////////////////
86 
87 class SdXMLImExTransform3D
88 {
89 	ImpSdXMLExpTransObj3DBaseList	maList;
90 	rtl::OUString					msString;
91 
92 	void EmptyList();
93 
94 public:
95 	SdXMLImExTransform3D() {}
96 	SdXMLImExTransform3D(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv);
97 	~SdXMLImExTransform3D() { EmptyList(); }
98 
99 	void AddRotateX(double fNew);
100 	void AddRotateY(double fNew);
101 	void AddRotateZ(double fNew);
102 	void AddScale(const ::basegfx::B3DTuple& rNew);
103 	void AddTranslate(const ::basegfx::B3DTuple& rNew);
104 	void AddMatrix(const ::basegfx::B3DHomMatrix& rNew);
105 
106 	void AddHomogenMatrix(const com::sun::star::drawing::HomogenMatrix& xHomMat);
107 	bool NeedsAction() const { return !maList.empty(); }
108 	void GetFullTransform(::basegfx::B3DHomMatrix& rFullTrans);
109 	bool GetFullHomogenTransform(com::sun::star::drawing::HomogenMatrix& xHomMat);
110 	const rtl::OUString& GetExportString(const SvXMLUnitConverter& rConv);
111 	void SetString(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv);
112 };
113 
114 //////////////////////////////////////////////////////////////////////////////
115 
116 class SdXMLImExViewBox
117 {
118 	rtl::OUString				msString;
119 	sal_Int32					mnX;
120 	sal_Int32					mnY;
121 	sal_Int32					mnW;
122 	sal_Int32					mnH;
123 
124 public:
125 	SdXMLImExViewBox(sal_Int32 nX = 0L, sal_Int32 nY = 0L, sal_Int32 nW = 1000L, sal_Int32 nH = 1000L);
126 	SdXMLImExViewBox(const rtl::OUString& rNew, const SvXMLUnitConverter& rConv);
127 
128 	sal_Int32 GetX() const { return mnX; }
129 	sal_Int32 GetY() const { return mnY; }
130 	sal_Int32 GetWidth() const { return mnW; }
131 	sal_Int32 GetHeight() const { return mnH; }
132 	const rtl::OUString& GetExportString();
133 };
134 
135 //////////////////////////////////////////////////////////////////////////////
136 
137 class SdXMLImExPointsElement
138 {
139 	rtl::OUString				msString;
140 	com::sun::star::drawing::PointSequenceSequence	maPoly;
141 
142 public:
143 	SdXMLImExPointsElement(com::sun::star::drawing::PointSequence* pPoints,
144 		const SdXMLImExViewBox& rViewBox,
145 		const com::sun::star::awt::Point& rObjectPos,
146 		const com::sun::star::awt::Size& rObjectSize,
147 		// #96328#
148 		const bool bClosed = true);
149 	SdXMLImExPointsElement(const rtl::OUString& rNew,
150 		const SdXMLImExViewBox& rViewBox,
151 		const com::sun::star::awt::Point& rObjectPos,
152 		const com::sun::star::awt::Size& rObjectSize,
153 		const SvXMLUnitConverter& rConv);
154 
155 	const rtl::OUString& GetExportString() const { return msString; }
156 	const com::sun::star::drawing::PointSequenceSequence& GetPointSequenceSequence() const { return maPoly; }
157 };
158 
159 //////////////////////////////////////////////////////////////////////////////
160 
161 class SdXMLImExSvgDElement
162 {
163 	rtl::OUString					msString;
164 	const SdXMLImExViewBox&			mrViewBox;
165 	bool							mbIsClosed;
166 	bool							mbIsCurve;
167 
168 	sal_Int32						mnLastX;
169 	sal_Int32						mnLastY;
170 
171 	com::sun::star::drawing::PointSequenceSequence		maPoly;
172 	com::sun::star::drawing::FlagSequenceSequence		maFlag;
173 
174 public:
175 	SdXMLImExSvgDElement(const SdXMLImExViewBox& rViewBox);
176 	SdXMLImExSvgDElement(const rtl::OUString& rNew,
177 		const SdXMLImExViewBox& rViewBox,
178 		const com::sun::star::awt::Point& rObjectPos,
179 		const com::sun::star::awt::Size& rObjectSize,
180 		const SvXMLUnitConverter& rConv);
181 
182 	void AddPolygon(
183 		com::sun::star::drawing::PointSequence* pPoints,
184 		com::sun::star::drawing::FlagSequence* pFlags,
185 		const com::sun::star::awt::Point& rObjectPos,
186 		const com::sun::star::awt::Size& rObjectSize,
187 		bool bClosed = false, bool bRelative = true);
188 
189 	const rtl::OUString& GetExportString() const { return msString; }
190 	bool IsClosed() const { return mbIsClosed; }
191 	bool IsCurve() const { return mbIsCurve; }
192 	const com::sun::star::drawing::PointSequenceSequence& GetPointSequenceSequence() const { return maPoly; }
193 	const com::sun::star::drawing::FlagSequenceSequence& GetFlagSequenceSequence() const { return maFlag; }
194 };
195 
196 
197 #endif	//  _XEXPTRANSFORM_HXX
198