/src/libreoffice/chart2/source/view/main/ShapeFactory.cxx
Line | Count | Source |
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 | | #include <ShapeFactory.hxx> |
21 | | #include <BaseGFXHelper.hxx> |
22 | | #include <ViewDefines.hxx> |
23 | | #include <Stripe.hxx> |
24 | | #include <CommonConverters.hxx> |
25 | | #include <RelativeSizeHelper.hxx> |
26 | | #include <PropertyMapper.hxx> |
27 | | #include <VLineProperties.hxx> |
28 | | #include <com/sun/star/beans/XPropertySet.hpp> |
29 | | #include <com/sun/star/chart2/XFormattedString.hpp> |
30 | | #include <com/sun/star/drawing/CircleKind.hpp> |
31 | | #include <com/sun/star/drawing/DoubleSequence.hpp> |
32 | | #include <com/sun/star/drawing/FlagSequence.hpp> |
33 | | #include <com/sun/star/drawing/FillStyle.hpp> |
34 | | #include <com/sun/star/drawing/LineStyle.hpp> |
35 | | #include <com/sun/star/drawing/NormalsKind.hpp> |
36 | | #include <com/sun/star/drawing/PointSequence.hpp> |
37 | | #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> |
38 | | #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> |
39 | | #include <com/sun/star/drawing/TextureProjectionMode.hpp> |
40 | | #include <com/sun/star/drawing/TextVerticalAdjust.hpp> |
41 | | #include <com/sun/star/drawing/XShapes2.hpp> |
42 | | #include <com/sun/star/graphic/XGraphic.hpp> |
43 | | #include <com/sun/star/style/ParagraphAdjust.hpp> |
44 | | #include <com/sun/star/uno/Sequence.hxx> |
45 | | #include <com/sun/star/uno/Any.hxx> |
46 | | |
47 | | #include <editeng/unoprnms.hxx> |
48 | | #include <rtl/math.hxx> |
49 | | |
50 | | #include <basegfx/point/b2dpoint.hxx> |
51 | | #include <basegfx/matrix/b3dhommatrix.hxx> |
52 | | #include <svx/svdpage.hxx> |
53 | | #include <svx/svdopath.hxx> |
54 | | #include <svx/svdorect.hxx> |
55 | | #include <comphelper/diagnose_ex.hxx> |
56 | | #include <tools/helpers.hxx> |
57 | | #include <tools/UnitConversion.hxx> |
58 | | #include <sal/log.hxx> |
59 | | |
60 | | #include <algorithm> |
61 | | #include <cmath> |
62 | | #include <cstddef> |
63 | | #include <numbers> |
64 | | |
65 | | using namespace ::com::sun::star; |
66 | | using ::com::sun::star::uno::Reference; |
67 | | |
68 | | namespace chart |
69 | | { |
70 | | |
71 | | namespace |
72 | | { |
73 | | |
74 | | void lcl_addProperty(uno::Sequence<OUString> & rPropertyNames, uno::Sequence<uno::Any> & rPropertyValues, |
75 | | OUString const & rName, uno::Any const & rAny) |
76 | 0 | { |
77 | 0 | rPropertyNames.realloc(rPropertyNames.getLength() + 1); |
78 | 0 | rPropertyNames.getArray()[rPropertyNames.getLength() - 1] = rName; |
79 | |
|
80 | 0 | rPropertyValues.realloc(rPropertyValues.getLength() + 1); |
81 | 0 | rPropertyValues.getArray()[rPropertyValues.getLength() - 1] = rAny; |
82 | 0 | } |
83 | | |
84 | | css::drawing::PolyPolygonShape3D toPolyPolygonShape3D(const std::vector<std::vector<css::drawing::Position3D>>& rPoints) |
85 | 0 | { |
86 | 0 | css::drawing::PolyPolygonShape3D aUnoPoly; |
87 | 0 | aUnoPoly.SequenceX.realloc(rPoints.size()); |
88 | 0 | aUnoPoly.SequenceY.realloc(rPoints.size()); |
89 | 0 | aUnoPoly.SequenceZ.realloc(rPoints.size()); |
90 | 0 | for (std::size_t nPolygonIndex=0; nPolygonIndex<rPoints.size(); ++nPolygonIndex) |
91 | 0 | { |
92 | 0 | drawing::DoubleSequence* pOuterSequenceX = &aUnoPoly.SequenceX.getArray()[nPolygonIndex]; |
93 | 0 | drawing::DoubleSequence* pOuterSequenceY = &aUnoPoly.SequenceY.getArray()[nPolygonIndex]; |
94 | 0 | drawing::DoubleSequence* pOuterSequenceZ = &aUnoPoly.SequenceZ.getArray()[nPolygonIndex]; |
95 | 0 | pOuterSequenceX->realloc(rPoints[nPolygonIndex].size()); |
96 | 0 | pOuterSequenceY->realloc(rPoints[nPolygonIndex].size()); |
97 | 0 | pOuterSequenceZ->realloc(rPoints[nPolygonIndex].size()); |
98 | 0 | double* pInnerSequenceX = pOuterSequenceX->getArray(); |
99 | 0 | double* pInnerSequenceY = pOuterSequenceY->getArray(); |
100 | 0 | double* pInnerSequenceZ = pOuterSequenceZ->getArray(); |
101 | 0 | for (std::size_t nPointIndex=0; nPointIndex<rPoints[nPolygonIndex].size(); ++nPointIndex) |
102 | 0 | { |
103 | 0 | auto& rPos = rPoints[nPolygonIndex][nPointIndex]; |
104 | 0 | pInnerSequenceX[nPointIndex] = rPos.PositionX; |
105 | 0 | pInnerSequenceY[nPointIndex] = rPos.PositionY; |
106 | 0 | pInnerSequenceZ[nPointIndex] = rPos.PositionZ; |
107 | 0 | } |
108 | 0 | } |
109 | 0 | return aUnoPoly; |
110 | 0 | } |
111 | | |
112 | | } // end anonymous namespace |
113 | | |
114 | | rtl::Reference<SvxShapeGroupAnyD> ShapeFactory::getOrCreateChartRootShape( |
115 | | const rtl::Reference<SvxDrawPage>& xDrawPage ) |
116 | 0 | { |
117 | 0 | rtl::Reference<SvxShapeGroupAnyD> xRet = ShapeFactory::getChartRootShape(xDrawPage); |
118 | 0 | if (xRet.is()) |
119 | 0 | return xRet; |
120 | | |
121 | | // Create a new root shape and set it to the bottom of the page. The root |
122 | | // shape is identified by having the name com.sun.star.chart2.shapes. |
123 | 0 | rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr); |
124 | 0 | xShapeGroup->setShapeKind(SdrObjKind::Group); |
125 | | // cast to resolve ambiguity in converting to XShape |
126 | 0 | xDrawPage->addBottom(static_cast<SvxShape*>(xShapeGroup.get())); |
127 | |
|
128 | 0 | setShapeName(xShapeGroup, u"com.sun.star.chart2.shapes"_ustr); |
129 | 0 | xShapeGroup->setSize(awt::Size(0,0)); |
130 | |
|
131 | 0 | return xShapeGroup; |
132 | 0 | } |
133 | | |
134 | 0 | void ShapeFactory::setPageSize(const rtl::Reference<SvxShapeGroupAnyD>&, const awt::Size&) {} |
135 | | |
136 | | // diverse tools::PolyPolygon create methods |
137 | | |
138 | | static uno::Any createPolyPolygon_Cube( |
139 | | const drawing::Direction3D& rSize, double fRoundedEdge, bool bRounded ) |
140 | 0 | { |
141 | 0 | OSL_PRECOND(fRoundedEdge>=0, "fRoundedEdge needs to be >= 0"); |
142 | | |
143 | | // always use extra points, so set percent diagonal to 0.4 which is 0% in the UI (old Chart comment) |
144 | 0 | if( fRoundedEdge == 0.0 && bRounded) |
145 | 0 | fRoundedEdge = 0.4 / 200.0; |
146 | 0 | else if(!bRounded) |
147 | 0 | fRoundedEdge = 0.0; |
148 | | |
149 | | //fWidthH stands for Half Width |
150 | 0 | const double fWidthH = rSize.DirectionX >=0.0? rSize.DirectionX/2.0 : -rSize.DirectionX/2.0; |
151 | 0 | const double fHeight = rSize.DirectionY; |
152 | |
|
153 | 0 | const double fHeightSign = fHeight >= 0.0 ? 1.0 : -1.0; |
154 | |
|
155 | 0 | const double fOffset = (fWidthH * fRoundedEdge) * 1.05; // increase by 5% for safety |
156 | 0 | const bool bRoundEdges = fRoundedEdge && fOffset < fWidthH && 2.0 * fOffset < fHeightSign*fHeight; |
157 | 0 | const sal_Int32 nPointCount = bRoundEdges ? 13 : 5; |
158 | |
|
159 | 0 | drawing::PolyPolygonShape3D aPP; |
160 | |
|
161 | 0 | aPP.SequenceX.realloc(1); |
162 | 0 | aPP.SequenceY.realloc(1); |
163 | 0 | aPP.SequenceZ.realloc(1); |
164 | |
|
165 | 0 | drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); |
166 | 0 | drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); |
167 | 0 | drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); |
168 | |
|
169 | 0 | pOuterSequenceX->realloc(nPointCount); |
170 | 0 | pOuterSequenceY->realloc(nPointCount); |
171 | 0 | pOuterSequenceZ->realloc(nPointCount); |
172 | |
|
173 | 0 | double* pInnerSequenceX = pOuterSequenceX->getArray(); |
174 | 0 | double* pInnerSequenceY = pOuterSequenceY->getArray(); |
175 | 0 | double* pInnerSequenceZ = pOuterSequenceZ->getArray(); |
176 | |
|
177 | 0 | for(sal_Int32 nN = nPointCount; nN--;) |
178 | 0 | *pInnerSequenceZ++ = 0.0; |
179 | |
|
180 | 0 | if(nPointCount == 5) |
181 | 0 | { |
182 | 0 | *pInnerSequenceY++ = 0.0; |
183 | 0 | *pInnerSequenceY++ = 0.0; |
184 | 0 | *pInnerSequenceY++ = fHeight; |
185 | 0 | *pInnerSequenceY++ = fHeight; |
186 | 0 | *pInnerSequenceY++ = 0.0; |
187 | |
|
188 | 0 | *pInnerSequenceX++ = -fWidthH; |
189 | 0 | *pInnerSequenceX++ = fWidthH; |
190 | 0 | *pInnerSequenceX++ = fWidthH; |
191 | 0 | *pInnerSequenceX++ = -fWidthH; |
192 | 0 | *pInnerSequenceX++ = -fWidthH; |
193 | 0 | } |
194 | 0 | else |
195 | 0 | { |
196 | 0 | *pInnerSequenceY++ = 0.0; |
197 | 0 | *pInnerSequenceY++ = 0.0; |
198 | 0 | *pInnerSequenceY++ = 0.0; |
199 | 0 | *pInnerSequenceY++ = fHeightSign*fOffset; |
200 | 0 | *pInnerSequenceY++ = fHeight - fHeightSign*fOffset; |
201 | 0 | *pInnerSequenceY++ = fHeight; |
202 | 0 | *pInnerSequenceY++ = fHeight; |
203 | 0 | *pInnerSequenceY++ = fHeight; |
204 | 0 | *pInnerSequenceY++ = fHeight; |
205 | 0 | *pInnerSequenceY++ = fHeight - fHeightSign*fOffset; |
206 | 0 | *pInnerSequenceY++ = fHeightSign*fOffset; |
207 | 0 | *pInnerSequenceY++ = 0.0; |
208 | 0 | *pInnerSequenceY++ = 0.0; |
209 | |
|
210 | 0 | *pInnerSequenceX++ = -fWidthH + fOffset; |
211 | 0 | *pInnerSequenceX++ = fWidthH - fOffset; |
212 | 0 | *pInnerSequenceX++ = fWidthH; |
213 | 0 | *pInnerSequenceX++ = fWidthH; |
214 | 0 | *pInnerSequenceX++ = fWidthH; |
215 | 0 | *pInnerSequenceX++ = fWidthH; |
216 | 0 | *pInnerSequenceX++ = fWidthH - fOffset; |
217 | 0 | *pInnerSequenceX++ = -fWidthH + fOffset; |
218 | 0 | *pInnerSequenceX++ = -fWidthH; |
219 | 0 | *pInnerSequenceX++ = -fWidthH; |
220 | 0 | *pInnerSequenceX++ = -fWidthH; |
221 | 0 | *pInnerSequenceX++ = -fWidthH; |
222 | 0 | *pInnerSequenceX++ = -fWidthH + fOffset; |
223 | 0 | } |
224 | 0 | return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get()); |
225 | 0 | } |
226 | | |
227 | | static uno::Any createPolyPolygon_Cylinder( |
228 | | double fHeight |
229 | | , double fRadius |
230 | | , sal_Int32& nVerticalSegmentCount ) |
231 | 0 | { |
232 | | //fHeight may be negative |
233 | 0 | OSL_PRECOND(fRadius>0, "The radius of a cylinder needs to be > 0"); |
234 | |
|
235 | 0 | drawing::PolyPolygonShape3D aPP; |
236 | |
|
237 | 0 | nVerticalSegmentCount=1; |
238 | |
|
239 | 0 | aPP.SequenceX.realloc(3); |
240 | 0 | aPP.SequenceY.realloc(3); |
241 | 0 | aPP.SequenceZ.realloc(3); |
242 | |
|
243 | 0 | drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); |
244 | 0 | drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); |
245 | 0 | drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); |
246 | |
|
247 | 0 | pOuterSequenceX->realloc(2); |
248 | 0 | pOuterSequenceY->realloc(2); |
249 | 0 | pOuterSequenceZ->realloc(2); |
250 | |
|
251 | 0 | double* pInnerSequenceX = pOuterSequenceX->getArray(); |
252 | 0 | double* pInnerSequenceY = pOuterSequenceY->getArray(); |
253 | 0 | double* pInnerSequenceZ = pOuterSequenceZ->getArray(); |
254 | |
|
255 | 0 | double fY1 = 0.0; |
256 | 0 | double fY2 = fHeight; |
257 | |
|
258 | 0 | if( fHeight<0.0 ) |
259 | 0 | std::swap(fY1,fY2); |
260 | |
|
261 | 0 | for(sal_Int32 nN = 2; nN--;) |
262 | 0 | *pInnerSequenceZ++ = 0.0; |
263 | |
|
264 | 0 | *pInnerSequenceX++ = 0.0; |
265 | 0 | *pInnerSequenceY++ = fY1; |
266 | |
|
267 | 0 | *pInnerSequenceX++ = fRadius; |
268 | 0 | *pInnerSequenceY++ = fY1; |
269 | |
|
270 | 0 | pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++; |
271 | 0 | pOuterSequenceX->realloc(2); |
272 | 0 | pOuterSequenceY->realloc(2); |
273 | 0 | pOuterSequenceZ->realloc(2); |
274 | |
|
275 | 0 | pInnerSequenceX = pOuterSequenceX->getArray(); |
276 | 0 | pInnerSequenceY = pOuterSequenceY->getArray(); |
277 | 0 | pInnerSequenceZ = pOuterSequenceZ->getArray(); |
278 | |
|
279 | 0 | for(sal_Int32 nN = 2; nN--;) |
280 | 0 | *pInnerSequenceZ++ = 0.0; |
281 | |
|
282 | 0 | *pInnerSequenceX++ = fRadius; |
283 | 0 | *pInnerSequenceY++ = fY1; |
284 | |
|
285 | 0 | *pInnerSequenceX++ = fRadius; |
286 | 0 | *pInnerSequenceY++ = fY2; |
287 | |
|
288 | 0 | pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++; |
289 | 0 | pOuterSequenceX->realloc(2); |
290 | 0 | pOuterSequenceY->realloc(2); |
291 | 0 | pOuterSequenceZ->realloc(2); |
292 | |
|
293 | 0 | pInnerSequenceX = pOuterSequenceX->getArray(); |
294 | 0 | pInnerSequenceY = pOuterSequenceY->getArray(); |
295 | 0 | pInnerSequenceZ = pOuterSequenceZ->getArray(); |
296 | |
|
297 | 0 | for(sal_Int32 nN = 2; nN--;) |
298 | 0 | *pInnerSequenceZ++ = 0.0; |
299 | |
|
300 | 0 | *pInnerSequenceX++ = fRadius; |
301 | 0 | *pInnerSequenceY++ = fY2; |
302 | |
|
303 | 0 | *pInnerSequenceX++ = 0.0; |
304 | 0 | *pInnerSequenceY++ = fY2; |
305 | |
|
306 | 0 | return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get()); |
307 | 0 | } |
308 | | |
309 | | static uno::Any createPolyPolygon_Cone( double fHeight, double fRadius, double fTopHeight |
310 | | , sal_Int32& nVerticalSegmentCount ) |
311 | 0 | { |
312 | 0 | OSL_PRECOND(fRadius>0, "The radius of a cone needs to be > 0"); |
313 | | |
314 | | //for stacked charts we need cones without top -> fTopHeight != 0 resp. bTopless == true |
315 | | //fTopHeight indicates the high of the cutted top only (not the full height) |
316 | 0 | bool bTopless = !::rtl::math::approxEqual( fHeight, fHeight + fTopHeight ); |
317 | |
|
318 | 0 | double r1= 0.0, r2 = fRadius; |
319 | 0 | if(bTopless) |
320 | | // #i63212# fHeight may be negative, fTopHeight is always positive -> use fabs(fHeight) |
321 | 0 | r1 = fRadius * fTopHeight/(fabs(fHeight)+fTopHeight); |
322 | |
|
323 | 0 | nVerticalSegmentCount=1; |
324 | 0 | drawing::PolyPolygonShape3D aPP; |
325 | |
|
326 | 0 | aPP.SequenceX.realloc(2); |
327 | 0 | aPP.SequenceY.realloc(2); |
328 | 0 | aPP.SequenceZ.realloc(2); |
329 | |
|
330 | 0 | drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray(); |
331 | 0 | drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray(); |
332 | 0 | drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray(); |
333 | |
|
334 | 0 | pOuterSequenceX->realloc(2); |
335 | 0 | pOuterSequenceY->realloc(2); |
336 | 0 | pOuterSequenceZ->realloc(2); |
337 | |
|
338 | 0 | double* pInnerSequenceX = pOuterSequenceX->getArray(); |
339 | 0 | double* pInnerSequenceY = pOuterSequenceY->getArray(); |
340 | 0 | double* pInnerSequenceZ = pOuterSequenceZ->getArray(); |
341 | |
|
342 | 0 | double fX1 = 0.0; |
343 | 0 | double fX2 = r2; |
344 | 0 | double fX3 = r1; |
345 | |
|
346 | 0 | double fY1 = 0.0; |
347 | 0 | double fY2 = 0.0; |
348 | 0 | double fY3 = fHeight; |
349 | |
|
350 | 0 | if( fHeight<0.0 ) |
351 | 0 | { |
352 | 0 | std::swap(fX1,fX3); |
353 | 0 | std::swap(fY1,fY3); |
354 | 0 | } |
355 | |
|
356 | 0 | for(sal_Int32 nN = 2; nN--;) |
357 | 0 | *pInnerSequenceZ++ = 0.0; |
358 | |
|
359 | 0 | *pInnerSequenceY++ = fY1; |
360 | 0 | *pInnerSequenceX++ = fX1; |
361 | |
|
362 | 0 | *pInnerSequenceY++ = fY2; |
363 | 0 | *pInnerSequenceX++ = fX2; |
364 | |
|
365 | 0 | pOuterSequenceX++;pOuterSequenceY++;pOuterSequenceZ++; |
366 | 0 | pOuterSequenceX->realloc(2); |
367 | 0 | pOuterSequenceY->realloc(2); |
368 | 0 | pOuterSequenceZ->realloc(2); |
369 | |
|
370 | 0 | pInnerSequenceX = pOuterSequenceX->getArray(); |
371 | 0 | pInnerSequenceY = pOuterSequenceY->getArray(); |
372 | 0 | pInnerSequenceZ = pOuterSequenceZ->getArray(); |
373 | |
|
374 | 0 | for(sal_Int32 nN = 2; nN--;) |
375 | 0 | *pInnerSequenceZ++ = 0.0; |
376 | |
|
377 | 0 | *pInnerSequenceY++ = fY2; |
378 | 0 | *pInnerSequenceX++ = fX2; |
379 | |
|
380 | 0 | *pInnerSequenceY++ = fY3; |
381 | 0 | *pInnerSequenceX++ = fX3; |
382 | |
|
383 | 0 | return uno::Any( &aPP, cppu::UnoType<drawing::PolyPolygonShape3D>::get()); |
384 | 0 | } |
385 | | |
386 | | // methods for 3D shape creation |
387 | | |
388 | | rtl::Reference<Svx3DExtrudeObject> |
389 | | ShapeFactory::createCube( |
390 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
391 | | , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize |
392 | | , sal_Int32 nRotateZAngleHundredthDegree |
393 | | , const uno::Reference< beans::XPropertySet >& xSourceProp |
394 | | , const tPropertyNameMap& rPropertyNameMap |
395 | | , bool bRounded ) |
396 | 0 | { |
397 | 0 | if( !xTarget.is() ) |
398 | 0 | return nullptr; |
399 | 0 | if( bRounded ) |
400 | 0 | { |
401 | 0 | try |
402 | 0 | { |
403 | 0 | if( xSourceProp.is() ) |
404 | 0 | { |
405 | 0 | drawing::LineStyle aLineStyle; |
406 | 0 | xSourceProp->getPropertyValue( u"BorderStyle"_ustr ) >>= aLineStyle; |
407 | 0 | if( aLineStyle == drawing::LineStyle_SOLID ) |
408 | 0 | bRounded = false; |
409 | 0 | } |
410 | 0 | } |
411 | 0 | catch( const uno::Exception& ) |
412 | 0 | { |
413 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
414 | 0 | } |
415 | 0 | } |
416 | 0 | rtl::Reference<Svx3DExtrudeObject> xShape = impl_createCube( xTarget, rPosition, rSize, nRotateZAngleHundredthDegree, bRounded ); |
417 | 0 | if( xSourceProp.is()) |
418 | 0 | PropertyMapper::setMappedProperties( *xShape, xSourceProp, rPropertyNameMap ); |
419 | 0 | return xShape; |
420 | 0 | } |
421 | | |
422 | | rtl::Reference<Svx3DExtrudeObject> |
423 | | ShapeFactory::impl_createCube( |
424 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
425 | | , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize |
426 | | , sal_Int32 nRotateZAngleHundredthDegree |
427 | | , bool bRounded ) |
428 | 0 | { |
429 | 0 | if( !xTarget.is() ) |
430 | 0 | return nullptr; |
431 | | |
432 | | //create shape |
433 | 0 | rtl::Reference<Svx3DExtrudeObject> xShape = new Svx3DExtrudeObject(nullptr); |
434 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Extrusion); |
435 | 0 | xTarget->addShape(*xShape); |
436 | | |
437 | | //set properties |
438 | 0 | try |
439 | 0 | { |
440 | | //depth |
441 | 0 | double fDepth = rSize.DirectionZ; |
442 | 0 | if (fDepth<0) |
443 | 0 | fDepth*=-1.0; |
444 | | |
445 | | //PercentDiagonal |
446 | 0 | sal_Int16 nPercentDiagonal = bRounded ? 3 : 0; |
447 | | |
448 | | //Matrix for position |
449 | 0 | basegfx::B3DHomMatrix aHomMatrix; |
450 | 0 | if (nRotateZAngleHundredthDegree != 0) |
451 | 0 | aHomMatrix.rotate(0.0, 0.0, -basegfx::deg2rad<100>(nRotateZAngleHundredthDegree)); |
452 | 0 | aHomMatrix.translate(rPosition.PositionX, rPosition.PositionY, |
453 | 0 | rPosition.PositionZ - (fDepth / 2.0)); |
454 | |
|
455 | 0 | uno::Sequence<OUString> aPropertyNames { |
456 | 0 | UNO_NAME_3D_EXTRUDE_DEPTH, |
457 | 0 | UNO_NAME_3D_PERCENT_DIAGONAL, |
458 | 0 | UNO_NAME_3D_POLYPOLYGON3D, |
459 | 0 | UNO_NAME_3D_TRANSFORM_MATRIX, |
460 | 0 | }; |
461 | |
|
462 | 0 | uno::Sequence<uno::Any> aPropertyValues { |
463 | 0 | uno::Any(sal_Int32(fDepth)), // Depth |
464 | 0 | uno::Any(nPercentDiagonal), // PercentDiagonal |
465 | 0 | createPolyPolygon_Cube(rSize, double(nPercentDiagonal) / 200.0, bRounded), |
466 | 0 | uno::Any(B3DHomMatrixToHomogenMatrix(aHomMatrix)) |
467 | 0 | }; |
468 | |
|
469 | 0 | xShape->setPropertyValues(aPropertyNames, aPropertyValues); |
470 | 0 | } |
471 | 0 | catch( const uno::Exception& ) |
472 | 0 | { |
473 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
474 | 0 | } |
475 | 0 | return xShape; |
476 | 0 | } |
477 | | |
478 | | rtl::Reference<Svx3DLatheObject> |
479 | | ShapeFactory::createCylinder( |
480 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
481 | | , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize |
482 | | , sal_Int32 nRotateZAngleHundredthDegree ) |
483 | 0 | { |
484 | 0 | return impl_createConeOrCylinder( |
485 | 0 | xTarget, rPosition, rSize, 0.0, nRotateZAngleHundredthDegree, true ); |
486 | 0 | } |
487 | | |
488 | | rtl::Reference<Svx3DSceneObject> |
489 | | ShapeFactory::createPyramid( |
490 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
491 | | , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize |
492 | | , double fTopHeight, bool bRotateZ |
493 | | , const uno::Reference< beans::XPropertySet >& xSourceProp |
494 | | , const tPropertyNameMap& rPropertyNameMap ) |
495 | 0 | { |
496 | 0 | if( !xTarget.is() ) |
497 | 0 | return nullptr; |
498 | | |
499 | 0 | rtl::Reference<Svx3DSceneObject> xGroup( ShapeFactory::createGroup3D( xTarget ) ); |
500 | |
|
501 | 0 | bool bDoubleSided = false; |
502 | 0 | short nRotatedTexture = 0; |
503 | |
|
504 | 0 | const double fWidth = rSize.DirectionX; |
505 | 0 | const double fDepth = rSize.DirectionZ; |
506 | 0 | const double fHeight = rSize.DirectionY; |
507 | |
|
508 | 0 | drawing::Position3D aBottomP1( rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ - fDepth/2.0 ); |
509 | 0 | if(bRotateZ) |
510 | 0 | aBottomP1.PositionY -= fWidth/2.0; |
511 | 0 | else |
512 | 0 | aBottomP1.PositionX -= fWidth/2.0; |
513 | 0 | drawing::Position3D aBottomP2( aBottomP1 ); |
514 | 0 | if(bRotateZ) |
515 | 0 | aBottomP2.PositionY += fWidth; |
516 | 0 | else |
517 | 0 | aBottomP2.PositionX += fWidth; |
518 | 0 | drawing::Position3D aBottomP3( aBottomP2 ); |
519 | 0 | drawing::Position3D aBottomP4( aBottomP1 ); |
520 | 0 | aBottomP3.PositionZ += fDepth; |
521 | 0 | aBottomP4.PositionZ += fDepth; |
522 | |
|
523 | 0 | const double fTopFactor = fTopHeight/(fabs(fHeight)+fTopHeight); |
524 | 0 | drawing::Position3D aTopP1( rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ - fDepth*fTopFactor/2.0 ); |
525 | 0 | if(bRotateZ) |
526 | 0 | { |
527 | 0 | aTopP1.PositionY -= fWidth*fTopFactor/2.0; |
528 | 0 | aTopP1.PositionX += fHeight; |
529 | 0 | } |
530 | 0 | else |
531 | 0 | { |
532 | 0 | aTopP1.PositionX -= fWidth*fTopFactor/2.0; |
533 | 0 | aTopP1.PositionY += fHeight; |
534 | 0 | } |
535 | 0 | drawing::Position3D aTopP2( aTopP1 ); |
536 | 0 | if(bRotateZ) |
537 | 0 | aTopP2.PositionY += fWidth*fTopFactor; |
538 | 0 | else |
539 | 0 | aTopP2.PositionX += fWidth*fTopFactor; |
540 | 0 | drawing::Position3D aTopP3( aTopP2 ); |
541 | 0 | drawing::Position3D aTopP4( aTopP1 ); |
542 | 0 | aTopP3.PositionZ += fDepth*fTopFactor; |
543 | 0 | aTopP4.PositionZ += fDepth*fTopFactor; |
544 | |
|
545 | 0 | Stripe aStripeBottom( aBottomP1, aBottomP4, aBottomP3, aBottomP2 ); |
546 | |
|
547 | 0 | drawing::Position3D aNormalsBottomP1( aBottomP1 ); |
548 | 0 | drawing::Position3D aNormalsBottomP2( aBottomP2 ); |
549 | 0 | drawing::Position3D aNormalsBottomP3( aBottomP3 ); |
550 | 0 | drawing::Position3D aNormalsBottomP4( aBottomP4 ); |
551 | 0 | drawing::Position3D aNormalsTopP1( aBottomP1 ); |
552 | 0 | drawing::Position3D aNormalsTopP2( aBottomP2 ); |
553 | 0 | drawing::Position3D aNormalsTopP3( aBottomP3 ); |
554 | 0 | drawing::Position3D aNormalsTopP4( aBottomP4 ); |
555 | 0 | if( bRotateZ ) |
556 | 0 | { |
557 | 0 | aNormalsTopP1.PositionX += fHeight; |
558 | 0 | aNormalsTopP2.PositionX += fHeight; |
559 | 0 | aNormalsTopP3.PositionX += fHeight; |
560 | 0 | aNormalsTopP4.PositionX += fHeight; |
561 | 0 | } |
562 | 0 | else |
563 | 0 | { |
564 | 0 | aNormalsTopP1.PositionY += fHeight; |
565 | 0 | aNormalsTopP2.PositionY += fHeight; |
566 | 0 | aNormalsTopP3.PositionY += fHeight; |
567 | 0 | aNormalsTopP4.PositionY += fHeight; |
568 | 0 | } |
569 | |
|
570 | 0 | bool bInvertPolygon = false; |
571 | 0 | bool bInvertNormals = false; |
572 | |
|
573 | 0 | if(bRotateZ) |
574 | 0 | { |
575 | | //bars |
576 | 0 | if(fHeight>=0.0) |
577 | 0 | { |
578 | 0 | nRotatedTexture = 2; |
579 | 0 | bInvertNormals = true; |
580 | 0 | aStripeBottom = Stripe( aBottomP1, aBottomP4, aBottomP3, aBottomP2 ); |
581 | 0 | } |
582 | 0 | else |
583 | 0 | { |
584 | 0 | bInvertPolygon = true; |
585 | 0 | nRotatedTexture = 1; |
586 | 0 | aStripeBottom = Stripe( aBottomP2, aBottomP3, aBottomP4, aBottomP1 ); |
587 | 0 | } |
588 | 0 | } |
589 | 0 | else |
590 | 0 | { |
591 | | //columns |
592 | 0 | if(fHeight>=0.0) |
593 | 0 | { |
594 | 0 | bInvertPolygon = true; |
595 | 0 | nRotatedTexture = 2; |
596 | 0 | aStripeBottom = Stripe( aBottomP2, aBottomP3, aBottomP4, aBottomP1 ); |
597 | 0 | } |
598 | 0 | else |
599 | 0 | { |
600 | 0 | nRotatedTexture = 3; |
601 | 0 | bInvertNormals = true; |
602 | 0 | aStripeBottom = Stripe( aBottomP4, aBottomP3, aBottomP2, aBottomP1 ); |
603 | 0 | } |
604 | 0 | } |
605 | 0 | aStripeBottom.InvertNormal(true); |
606 | |
|
607 | 0 | Stripe aStripe1( aTopP2, aTopP1, aBottomP1, aBottomP2 ); |
608 | 0 | Stripe aStripe2( aTopP3, aTopP2, aBottomP2, aBottomP3 ); |
609 | 0 | Stripe aStripe3( aTopP4, aTopP3, aBottomP3, aBottomP4 ); |
610 | 0 | Stripe aStripe4( aTopP1, aTopP4, aBottomP4, aBottomP1 ); |
611 | |
|
612 | 0 | if( bInvertPolygon ) |
613 | 0 | { |
614 | 0 | aStripe1 = Stripe( aBottomP1, aTopP1, aTopP2, aBottomP2 ); |
615 | 0 | aStripe2 = Stripe( aBottomP2, aTopP2, aTopP3, aBottomP3 ); |
616 | 0 | aStripe3 = Stripe( aBottomP3, aTopP3, aTopP4, aBottomP4 ); |
617 | 0 | aStripe4 = Stripe( aBottomP4, aTopP4, aTopP1, aBottomP1 ); |
618 | 0 | } |
619 | |
|
620 | 0 | Stripe aNormalsStripe1( aNormalsTopP1, aNormalsBottomP1, aNormalsBottomP2, aNormalsTopP2 ); |
621 | 0 | Stripe aNormalsStripe2( aNormalsTopP2, aNormalsBottomP2, aNormalsBottomP3, aNormalsTopP3 ); |
622 | 0 | Stripe aNormalsStripe3( aNormalsTopP3, aNormalsBottomP3, aNormalsBottomP4, aNormalsTopP4 ); |
623 | 0 | Stripe aNormalsStripe4( aNormalsTopP4, aNormalsBottomP4, aNormalsBottomP1, aNormalsTopP1 ); |
624 | |
|
625 | 0 | if( bInvertNormals ) |
626 | 0 | { |
627 | 0 | aNormalsStripe1 = Stripe( aNormalsTopP2, aNormalsBottomP2, aNormalsBottomP1, aNormalsTopP1 ); |
628 | 0 | aNormalsStripe2 = Stripe( aNormalsTopP3, aNormalsBottomP3, aNormalsBottomP2, aNormalsTopP2 ); |
629 | 0 | aNormalsStripe3 = Stripe( aNormalsTopP4, aNormalsBottomP4, aNormalsBottomP3, aNormalsTopP3 ); |
630 | 0 | aNormalsStripe4 = Stripe( aNormalsTopP1, aNormalsBottomP1, aNormalsBottomP4, aNormalsTopP4 ); |
631 | 0 | } |
632 | |
|
633 | 0 | aStripe1.SetManualNormal( aNormalsStripe1.getNormal() ); |
634 | 0 | aStripe2.SetManualNormal( aNormalsStripe2.getNormal() ); |
635 | 0 | aStripe3.SetManualNormal( aNormalsStripe3.getNormal() ); |
636 | 0 | aStripe4.SetManualNormal( aNormalsStripe4.getNormal() ); |
637 | |
|
638 | 0 | const bool bFlatNormals = false; |
639 | 0 | ShapeFactory::createStripe( xGroup, aStripe1, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); |
640 | 0 | ShapeFactory::createStripe( xGroup, aStripe2, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); |
641 | 0 | ShapeFactory::createStripe( xGroup, aStripe3, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); |
642 | 0 | ShapeFactory::createStripe( xGroup, aStripe4, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); |
643 | 0 | ShapeFactory::createStripe( xGroup, aStripeBottom, xSourceProp, rPropertyNameMap, bDoubleSided, nRotatedTexture, bFlatNormals ); |
644 | |
|
645 | 0 | return xGroup; |
646 | 0 | } |
647 | | |
648 | | rtl::Reference<Svx3DLatheObject> |
649 | | ShapeFactory::createCone( |
650 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
651 | | , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize |
652 | | , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree ) |
653 | 0 | { |
654 | 0 | return impl_createConeOrCylinder( xTarget, rPosition, rSize, fTopHeight, nRotateZAngleHundredthDegree, false ); |
655 | 0 | } |
656 | | |
657 | | rtl::Reference<Svx3DLatheObject> |
658 | | ShapeFactory::impl_createConeOrCylinder( |
659 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
660 | | , const drawing::Position3D& rPosition, const drawing::Direction3D& rSize |
661 | | , double fTopHeight, sal_Int32 nRotateZAngleHundredthDegree |
662 | | , bool bCylinder ) |
663 | 0 | { |
664 | 0 | if( !xTarget.is() ) |
665 | 0 | return nullptr; |
666 | | |
667 | | //create shape |
668 | 0 | rtl::Reference<Svx3DLatheObject> xShape = new Svx3DLatheObject(nullptr); |
669 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Lathe); |
670 | 0 | xTarget->addShape(*xShape); |
671 | |
|
672 | 0 | double fWidth = rSize.DirectionX/2.0; //The depth will be corrected within Matrix |
673 | 0 | double fRadius = fWidth; //!!!!!!!! problem in drawing layer: rotation object calculates wrong needed size -> wrong camera (it's a problem with bounding boxes) |
674 | 0 | double fHeight = rSize.DirectionY; |
675 | | |
676 | | //set properties |
677 | 0 | try |
678 | 0 | { |
679 | | //Polygon |
680 | 0 | sal_Int32 nVerticalSegmentCount = 0; |
681 | 0 | uno::Any aPPolygon = bCylinder |
682 | 0 | ? createPolyPolygon_Cylinder(fHeight, fRadius, nVerticalSegmentCount) |
683 | 0 | : createPolyPolygon_Cone(fHeight, fRadius, fTopHeight, nVerticalSegmentCount); |
684 | | |
685 | | //Matrix for position |
686 | 0 | basegfx::B3DHomMatrix aHomMatrix; |
687 | 0 | if (nRotateZAngleHundredthDegree != 0) |
688 | 0 | aHomMatrix.rotate(0.0,0.0,-basegfx::deg2rad<100>(nRotateZAngleHundredthDegree)); |
689 | | //stretch the symmetric objects to given depth |
690 | 0 | aHomMatrix.scale(1.0,1.0,rSize.DirectionZ/rSize.DirectionX); |
691 | 0 | aHomMatrix.translate(rPosition.PositionX, rPosition.PositionY, rPosition.PositionZ); |
692 | |
|
693 | 0 | uno::Sequence<OUString> aPropertyNames{ |
694 | 0 | UNO_NAME_3D_PERCENT_DIAGONAL, |
695 | 0 | UNO_NAME_3D_POLYPOLYGON3D, |
696 | 0 | UNO_NAME_3D_TRANSFORM_MATRIX, |
697 | 0 | UNO_NAME_3D_HORZ_SEGS, |
698 | 0 | UNO_NAME_3D_VERT_SEGS, |
699 | 0 | UNO_NAME_3D_REDUCED_LINE_GEOMETRY |
700 | 0 | }; |
701 | |
|
702 | 0 | uno::Sequence<uno::Any> aPropertyValues { |
703 | 0 | uno::Any(sal_Int16(5)), // PercentDiagonal |
704 | 0 | aPPolygon, // Polygon |
705 | 0 | uno::Any(B3DHomMatrixToHomogenMatrix(aHomMatrix)), // Matrix |
706 | 0 | uno::Any(CHART_3DOBJECT_SEGMENTCOUNT), // Horizontal Segments |
707 | 0 | uno::Any(nVerticalSegmentCount), // Vertical Segments |
708 | 0 | uno::Any(true) // Reduced lines |
709 | 0 | }; |
710 | |
|
711 | 0 | xShape->setPropertyValues(aPropertyNames, aPropertyValues); |
712 | 0 | } |
713 | 0 | catch( const uno::Exception& ) |
714 | 0 | { |
715 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
716 | 0 | } |
717 | 0 | return xShape; |
718 | 0 | } |
719 | | |
720 | | static void appendAndCloseBezierCoords( drawing::PolyPolygonBezierCoords& rReturn, const drawing::PolyPolygonBezierCoords& rAdd, bool bAppendInverse ) |
721 | 0 | { |
722 | 0 | if(!rAdd.Coordinates.hasElements()) |
723 | 0 | return; |
724 | 0 | sal_Int32 nAddCount = rAdd.Coordinates[0].getLength(); |
725 | 0 | if(!nAddCount) |
726 | 0 | return; |
727 | | |
728 | 0 | sal_Int32 nOldCount = rReturn.Coordinates[0].getLength(); |
729 | |
|
730 | 0 | auto pCoordinates = rReturn.Coordinates.getArray(); |
731 | 0 | pCoordinates[0].realloc(nOldCount + nAddCount + 1); |
732 | 0 | auto pCoordinates0 = pCoordinates[0].getArray(); |
733 | 0 | auto pFlags = rReturn.Flags.getArray(); |
734 | 0 | pFlags[0].realloc(nOldCount+nAddCount+1); |
735 | 0 | auto pFlags0 = pFlags[0].getArray(); |
736 | |
|
737 | 0 | for(sal_Int32 nN=0;nN<nAddCount; nN++ ) |
738 | 0 | { |
739 | 0 | sal_Int32 nAdd = bAppendInverse ? (nAddCount-1-nN) : nN; |
740 | 0 | pCoordinates0[nOldCount+nN] = rAdd.Coordinates[0][nAdd]; |
741 | 0 | pFlags0[nOldCount+nN] = rAdd.Flags[0][nAdd]; |
742 | 0 | } |
743 | | |
744 | | //close |
745 | 0 | pCoordinates0[nOldCount+nAddCount] = rReturn.Coordinates[0][0]; |
746 | 0 | pFlags0[nOldCount+nAddCount] = rReturn.Flags[0][0]; |
747 | 0 | } |
748 | | |
749 | | static drawing::PolyPolygonBezierCoords getCircularArcBezierCoords( |
750 | | double fStartAngleRadian, double fWidthAngleRadian, double fUnitRadius |
751 | | , const ::basegfx::B2DHomMatrix& rTransformationFromUnitCircle |
752 | | , const double fAngleSubdivisionRadian ) |
753 | 0 | { |
754 | | //at least one polygon is created using two normal and two control points |
755 | | //if the angle is larger it is separated into multiple sub angles |
756 | |
|
757 | 0 | drawing::PolyPolygonBezierCoords aReturn; |
758 | 0 | sal_Int32 nSegmentCount = static_cast< sal_Int32 >( fWidthAngleRadian/fAngleSubdivisionRadian ); |
759 | 0 | if( fWidthAngleRadian > fAngleSubdivisionRadian*nSegmentCount ) |
760 | 0 | nSegmentCount++; |
761 | |
|
762 | 0 | double fFirstSegmentAngle = fAngleSubdivisionRadian; |
763 | 0 | double fLastSegmentAngle = fAngleSubdivisionRadian; |
764 | 0 | if(nSegmentCount==1) |
765 | 0 | { |
766 | 0 | fFirstSegmentAngle = fWidthAngleRadian; |
767 | 0 | fLastSegmentAngle = 0.0; |
768 | 0 | } |
769 | 0 | else |
770 | 0 | { |
771 | 0 | double fFirstAngleOnSubDivision = (static_cast<sal_Int32>(fStartAngleRadian/fAngleSubdivisionRadian)+1)*fAngleSubdivisionRadian; |
772 | 0 | if( !::rtl::math::approxEqual( fStartAngleRadian, fFirstAngleOnSubDivision ) ) |
773 | 0 | fFirstSegmentAngle = fFirstAngleOnSubDivision-fStartAngleRadian; |
774 | |
|
775 | 0 | if(nSegmentCount>1) |
776 | 0 | { |
777 | 0 | fLastSegmentAngle = fWidthAngleRadian-fFirstSegmentAngle-fAngleSubdivisionRadian*(nSegmentCount-2); |
778 | 0 | if( fLastSegmentAngle<0 ) |
779 | 0 | nSegmentCount--; |
780 | 0 | if( fLastSegmentAngle>fAngleSubdivisionRadian ) |
781 | 0 | { |
782 | 0 | fLastSegmentAngle-=fAngleSubdivisionRadian; |
783 | 0 | nSegmentCount++; |
784 | 0 | } |
785 | 0 | } |
786 | 0 | } |
787 | |
|
788 | 0 | sal_Int32 nPointCount = 1 + 3*nSegmentCount; //first point of next segment equals last point of former segment |
789 | |
|
790 | 0 | drawing::PointSequence aPoints(nPointCount); |
791 | 0 | auto pPoints = aPoints.getArray(); |
792 | 0 | drawing::FlagSequence aFlags(nPointCount); |
793 | 0 | auto pFlags = aFlags.getArray(); |
794 | | |
795 | | //!! applying matrix to vector does ignore translation, so it is important to use a B2DPoint here instead of B2DVector |
796 | 0 | ::basegfx::B2DPoint P0,P1,P2,P3; |
797 | |
|
798 | 0 | sal_Int32 nPoint=0; |
799 | 0 | double fCurrentRotateAngle = fStartAngleRadian; |
800 | 0 | for(sal_Int32 nSegment=0; nSegment<nSegmentCount; nSegment++) |
801 | 0 | { |
802 | 0 | double fCurrentSegmentAngle = fAngleSubdivisionRadian; |
803 | 0 | if(nSegment==0)//first segment gets only a smaller peace until the next subdivision |
804 | 0 | fCurrentSegmentAngle = fFirstSegmentAngle; |
805 | 0 | else if(nSegment==(nSegmentCount-1)) //the last segment gets the rest angle that does not fit into equal pieces |
806 | 0 | fCurrentSegmentAngle = fLastSegmentAngle; |
807 | | |
808 | | //first create untransformed points for a unit circle arc: |
809 | 0 | const double fCos = cos(fCurrentSegmentAngle/2.0); |
810 | 0 | const double fSin = sin(fCurrentSegmentAngle/2.0); |
811 | 0 | P0.setX(fCos); |
812 | 0 | P3.setX(fCos); |
813 | 0 | P0.setY(-fSin); |
814 | 0 | P3.setY(-P0.getY()); |
815 | |
|
816 | 0 | P1.setX((4.0-fCos)/3.0); |
817 | 0 | P2.setX(P1.getX()); |
818 | 0 | P1.setY((1.0-fCos)*(fCos-3.0)/(3.0*fSin)); |
819 | 0 | P2.setY(-P1.getY()); |
820 | | //transform thus startangle equals NULL |
821 | 0 | ::basegfx::B2DHomMatrix aStart; |
822 | 0 | aStart.rotate(fCurrentSegmentAngle/2.0 + fCurrentRotateAngle ); |
823 | 0 | fCurrentRotateAngle+=fCurrentSegmentAngle; |
824 | |
|
825 | 0 | aStart.scale( fUnitRadius, fUnitRadius ); |
826 | | |
827 | | //apply given transformation to get final points |
828 | 0 | P0 = rTransformationFromUnitCircle*(aStart*P0); |
829 | 0 | P1 = rTransformationFromUnitCircle*(aStart*P1); |
830 | 0 | P2 = rTransformationFromUnitCircle*(aStart*P2); |
831 | 0 | P3 = rTransformationFromUnitCircle*(aStart*P3); |
832 | |
|
833 | 0 | pPoints[nPoint].X = static_cast< sal_Int32 >( P0.getX()); |
834 | 0 | pPoints[nPoint].Y = static_cast< sal_Int32 >( P0.getY()); |
835 | 0 | pFlags [nPoint++] = drawing::PolygonFlags_NORMAL; |
836 | |
|
837 | 0 | pPoints[nPoint].X = static_cast< sal_Int32 >( P1.getX()); |
838 | 0 | pPoints[nPoint].Y = static_cast< sal_Int32 >( P1.getY()); |
839 | 0 | pFlags[nPoint++] = drawing::PolygonFlags_CONTROL; |
840 | |
|
841 | 0 | pPoints[nPoint].X = static_cast< sal_Int32 >( P2.getX()); |
842 | 0 | pPoints[nPoint].Y = static_cast< sal_Int32 >( P2.getY()); |
843 | 0 | pFlags [nPoint++] = drawing::PolygonFlags_CONTROL; |
844 | |
|
845 | 0 | if(nSegment==(nSegmentCount-1)) |
846 | 0 | { |
847 | 0 | pPoints[nPoint].X = static_cast< sal_Int32 >( P3.getX()); |
848 | 0 | pPoints[nPoint].Y = static_cast< sal_Int32 >( P3.getY()); |
849 | 0 | pFlags [nPoint++] = drawing::PolygonFlags_NORMAL; |
850 | 0 | } |
851 | 0 | } |
852 | |
|
853 | 0 | aReturn.Coordinates = { aPoints }; |
854 | 0 | aReturn.Flags = { aFlags }; |
855 | |
|
856 | 0 | return aReturn; |
857 | 0 | } |
858 | | |
859 | | static drawing::PolyPolygonBezierCoords getRingBezierCoords( |
860 | | double fUnitCircleInnerRadius |
861 | | , double fUnitCircleOuterRadius |
862 | | , double fStartAngleRadian, double fWidthAngleRadian |
863 | | , const ::basegfx::B2DHomMatrix& aTransformationFromUnitCircle |
864 | | , const double fAngleSubdivisionRadian ) |
865 | 0 | { |
866 | 0 | drawing::PolyPolygonBezierCoords aReturn; |
867 | |
|
868 | 0 | drawing::PolyPolygonBezierCoords aOuterArc = getCircularArcBezierCoords( |
869 | 0 | fStartAngleRadian, fWidthAngleRadian, fUnitCircleOuterRadius, aTransformationFromUnitCircle, fAngleSubdivisionRadian ); |
870 | 0 | aReturn.Coordinates = { aOuterArc.Coordinates[0] }; |
871 | 0 | aReturn.Flags = { aOuterArc.Flags[0] }; |
872 | |
|
873 | 0 | drawing::PolyPolygonBezierCoords aInnerArc = getCircularArcBezierCoords( |
874 | 0 | fStartAngleRadian, fWidthAngleRadian, fUnitCircleInnerRadius, aTransformationFromUnitCircle, fAngleSubdivisionRadian ); |
875 | 0 | appendAndCloseBezierCoords( aReturn, aInnerArc, true ); |
876 | |
|
877 | 0 | return aReturn; |
878 | 0 | } |
879 | | |
880 | | rtl::Reference<SvxShapePolyPolygon> |
881 | | ShapeFactory::createPieSegment2D( |
882 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
883 | | , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree |
884 | | , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius |
885 | | , const drawing::Direction3D& rOffset |
886 | | , const drawing::HomogenMatrix& rUnitCircleToScene ) |
887 | 0 | { |
888 | 0 | if( !xTarget.is() ) |
889 | 0 | return nullptr; |
890 | | |
891 | | // tdf#123504: both 0 and 360 are valid and different values here! |
892 | 0 | while (fUnitCircleWidthAngleDegree > 360) |
893 | 0 | fUnitCircleWidthAngleDegree -= 360.0; |
894 | 0 | while (fUnitCircleWidthAngleDegree < 0) |
895 | 0 | fUnitCircleWidthAngleDegree += 360.0; |
896 | | |
897 | | //create shape |
898 | 0 | rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); |
899 | 0 | xShape->setShapeKind(SdrObjKind::PathFill); // aka ClosedBezierShape |
900 | 0 | xTarget->addShape(*xShape); //need to add the shape before setting of properties |
901 | |
|
902 | 0 | if (std::isnan(fUnitCircleWidthAngleDegree)) |
903 | 0 | { |
904 | 0 | SAL_WARN("chart2", "fUnitCircleWidthAngleDegree isNaN"); |
905 | 0 | return xShape; |
906 | 0 | } |
907 | | |
908 | | //set properties |
909 | 0 | try |
910 | 0 | { |
911 | 0 | ::basegfx::B2DHomMatrix aTransformationFromUnitCircle( IgnoreZ( HomogenMatrixToB3DHomMatrix(rUnitCircleToScene) ) ); |
912 | 0 | aTransformationFromUnitCircle.translate(rOffset.DirectionX,rOffset.DirectionY); |
913 | |
|
914 | 0 | const double fAngleSubdivisionRadian = M_PI/10.0; |
915 | |
|
916 | 0 | drawing::PolyPolygonBezierCoords aCoords |
917 | 0 | = getRingBezierCoords(fUnitCircleInnerRadius, fUnitCircleOuterRadius, |
918 | 0 | basegfx::deg2rad(fUnitCircleStartAngleDegree), |
919 | 0 | basegfx::deg2rad(fUnitCircleWidthAngleDegree), |
920 | 0 | aTransformationFromUnitCircle, fAngleSubdivisionRadian); |
921 | |
|
922 | 0 | xShape->SvxShape::setPropertyValue( u"PolyPolygonBezier"_ustr, uno::Any( aCoords ) ); |
923 | 0 | } |
924 | 0 | catch( const uno::Exception& ) |
925 | 0 | { |
926 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
927 | 0 | } |
928 | | |
929 | 0 | return xShape; |
930 | 0 | } |
931 | | |
932 | | rtl::Reference<Svx3DExtrudeObject> |
933 | | ShapeFactory::createPieSegment( |
934 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
935 | | , double fUnitCircleStartAngleDegree, double fUnitCircleWidthAngleDegree |
936 | | , double fUnitCircleInnerRadius, double fUnitCircleOuterRadius |
937 | | , const drawing::Direction3D& rOffset |
938 | | , const drawing::HomogenMatrix& rUnitCircleToScene |
939 | | , double fDepth ) |
940 | 0 | { |
941 | 0 | if( !xTarget.is() ) |
942 | 0 | return nullptr; |
943 | | |
944 | | // tdf#123504: both 0 and 360 are valid and different values here! |
945 | 0 | while (fUnitCircleWidthAngleDegree > 360) |
946 | 0 | fUnitCircleWidthAngleDegree -= 360.0; |
947 | 0 | while (fUnitCircleWidthAngleDegree < 0) |
948 | 0 | fUnitCircleWidthAngleDegree += 360.0; |
949 | | |
950 | | //create shape |
951 | 0 | rtl::Reference<Svx3DExtrudeObject> xShape = new Svx3DExtrudeObject(nullptr); |
952 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Extrusion); |
953 | 0 | xTarget->addShape(*xShape); //need to add the shape before setting of properties |
954 | | |
955 | | //set properties |
956 | 0 | try |
957 | 0 | { |
958 | 0 | ::basegfx::B2DHomMatrix aTransformationFromUnitCircle( IgnoreZ( HomogenMatrixToB3DHomMatrix(rUnitCircleToScene) ) ); |
959 | 0 | aTransformationFromUnitCircle.translate(rOffset.DirectionX,rOffset.DirectionY); |
960 | |
|
961 | 0 | const double fAngleSubdivisionRadian = M_PI/32.0; |
962 | |
|
963 | 0 | drawing::PolyPolygonBezierCoords aCoords |
964 | 0 | = getRingBezierCoords(fUnitCircleInnerRadius, fUnitCircleOuterRadius, |
965 | 0 | basegfx::deg2rad(fUnitCircleStartAngleDegree), |
966 | 0 | basegfx::deg2rad(fUnitCircleWidthAngleDegree), |
967 | 0 | aTransformationFromUnitCircle, fAngleSubdivisionRadian); |
968 | | |
969 | | //depth |
970 | 0 | xShape->setPropertyValue( UNO_NAME_3D_EXTRUDE_DEPTH |
971 | 0 | , uno::Any(static_cast<sal_Int32>(fDepth)) ); |
972 | | |
973 | | //PercentDiagonal |
974 | 0 | xShape->setPropertyValue( UNO_NAME_3D_PERCENT_DIAGONAL |
975 | 0 | , uno::Any( sal_Int16(0) ) ); |
976 | | |
977 | | //Polygon |
978 | 0 | drawing::PolyPolygonShape3D aPoly( BezierToPoly(aCoords) ); |
979 | 0 | ShapeFactory::closePolygon( aPoly ); |
980 | 0 | xShape->setPropertyValue( UNO_NAME_3D_POLYPOLYGON3D |
981 | 0 | , uno::Any( aPoly ) ); |
982 | | |
983 | | //DoubleSided |
984 | 0 | xShape->setPropertyValue( UNO_NAME_3D_DOUBLE_SIDED |
985 | 0 | , uno::Any( true ) ); |
986 | | |
987 | | //Reduced lines |
988 | 0 | xShape->setPropertyValue( UNO_NAME_3D_REDUCED_LINE_GEOMETRY |
989 | 0 | , uno::Any( true ) ); |
990 | | |
991 | | //TextureProjectionMode |
992 | 0 | xShape->setPropertyValue( UNO_NAME_3D_TEXTURE_PROJ_Y |
993 | 0 | , uno::Any( drawing::TextureProjectionMode_OBJECTSPECIFIC ) ); |
994 | | |
995 | | //TextureProjectionMode |
996 | 0 | xShape->setPropertyValue( UNO_NAME_3D_TEXTURE_PROJ_X |
997 | 0 | , uno::Any( drawing::TextureProjectionMode_PARALLEL ) ); |
998 | 0 | xShape->setPropertyValue( UNO_NAME_3D_TEXTURE_PROJ_Y |
999 | 0 | , uno::Any( drawing::TextureProjectionMode_OBJECTSPECIFIC ) ); |
1000 | 0 | } |
1001 | 0 | catch( const uno::Exception& ) |
1002 | 0 | { |
1003 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1004 | 0 | } |
1005 | 0 | return xShape; |
1006 | 0 | } |
1007 | | |
1008 | | rtl::Reference<Svx3DPolygonObject> |
1009 | | ShapeFactory::createStripe( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1010 | | , const Stripe& rStripe |
1011 | | , const uno::Reference< beans::XPropertySet >& xSourceProp |
1012 | | , const tPropertyNameMap& rPropertyNameMap |
1013 | | , bool bDoubleSided |
1014 | | , short nRotatedTexture |
1015 | | , bool bFlatNormals ) |
1016 | 0 | { |
1017 | 0 | if( !xTarget.is() ) |
1018 | 0 | return nullptr; |
1019 | | |
1020 | | //create shape |
1021 | 0 | rtl::Reference<Svx3DPolygonObject> xShape = new Svx3DPolygonObject(nullptr); |
1022 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Polygon); |
1023 | 0 | xTarget->addShape(*xShape); |
1024 | | |
1025 | | //set properties |
1026 | 0 | try |
1027 | 0 | { |
1028 | 0 | uno::Sequence<OUString> aPropertyNames{ |
1029 | 0 | UNO_NAME_3D_POLYPOLYGON3D, |
1030 | 0 | UNO_NAME_3D_TEXTUREPOLYGON3D, |
1031 | 0 | UNO_NAME_3D_NORMALSPOLYGON3D, |
1032 | 0 | UNO_NAME_3D_LINEONLY, |
1033 | 0 | UNO_NAME_3D_DOUBLE_SIDED |
1034 | 0 | }; |
1035 | |
|
1036 | 0 | uno::Sequence<uno::Any> aPropertyValues { |
1037 | 0 | rStripe.getPolyPolygonShape3D(), // Polygon |
1038 | 0 | Stripe::getTexturePolygon(nRotatedTexture), // TexturePolygon |
1039 | 0 | rStripe.getNormalsPolygon(), // Normals Polygon |
1040 | 0 | uno::Any(false), // LineOnly |
1041 | 0 | uno::Any(bDoubleSided) // DoubleSided |
1042 | 0 | }; |
1043 | | |
1044 | | //NormalsKind |
1045 | 0 | if (bFlatNormals) |
1046 | 0 | lcl_addProperty(aPropertyNames, aPropertyValues, |
1047 | 0 | UNO_NAME_3D_NORMALS_KIND, uno::Any(drawing::NormalsKind_FLAT)); |
1048 | |
|
1049 | 0 | xShape->setPropertyValues(aPropertyNames, aPropertyValues); |
1050 | |
|
1051 | 0 | if (xSourceProp) |
1052 | 0 | { |
1053 | 0 | PropertyMapper::setMappedProperties(*xShape, xSourceProp, rPropertyNameMap); |
1054 | 0 | } |
1055 | 0 | } |
1056 | 0 | catch( const uno::Exception& ) |
1057 | 0 | { |
1058 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1059 | 0 | } |
1060 | 0 | return xShape; |
1061 | 0 | } |
1062 | | |
1063 | | rtl::Reference<Svx3DExtrudeObject> |
1064 | | ShapeFactory::createArea3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1065 | | , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon |
1066 | | , double fDepth ) |
1067 | 0 | { |
1068 | 0 | if( !xTarget.is() ) |
1069 | 0 | return nullptr; |
1070 | | |
1071 | 0 | if( rPolyPolygon.empty() ) |
1072 | 0 | return nullptr; |
1073 | | |
1074 | | //create shape |
1075 | 0 | rtl::Reference<Svx3DExtrudeObject> xShape = new Svx3DExtrudeObject(nullptr); |
1076 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Extrusion); |
1077 | 0 | xTarget->addShape(*xShape); |
1078 | |
|
1079 | 0 | css::drawing::PolyPolygonShape3D aUnoPolyPolygon = toPolyPolygonShape3D(rPolyPolygon); |
1080 | | |
1081 | | //set properties |
1082 | 0 | try |
1083 | 0 | { |
1084 | 0 | uno::Sequence<OUString> aPropertyNames{ |
1085 | 0 | UNO_NAME_3D_EXTRUDE_DEPTH, |
1086 | 0 | UNO_NAME_3D_PERCENT_DIAGONAL, |
1087 | 0 | UNO_NAME_3D_POLYPOLYGON3D, |
1088 | 0 | UNO_NAME_3D_DOUBLE_SIDED, |
1089 | 0 | }; |
1090 | |
|
1091 | 0 | uno::Sequence<uno::Any> aPropertyValues { |
1092 | 0 | uno::Any(sal_Int32(fDepth)), // depth |
1093 | 0 | uno::Any(sal_Int16(0)), // PercentDiagonal |
1094 | 0 | uno::Any(aUnoPolyPolygon), // Polygon |
1095 | 0 | uno::Any(true) // DoubleSided |
1096 | 0 | }; |
1097 | | |
1098 | | //the z component of the polygon is now ignored by the drawing layer, |
1099 | | //so we need to translate the object via transformation matrix |
1100 | | |
1101 | | //Matrix for position |
1102 | 0 | if (!rPolyPolygon[0].empty()) |
1103 | 0 | { |
1104 | 0 | basegfx::B3DHomMatrix aM; |
1105 | 0 | aM.translate(0, 0, rPolyPolygon[0][0].PositionZ); |
1106 | 0 | drawing::HomogenMatrix aHM = B3DHomMatrixToHomogenMatrix(aM); |
1107 | 0 | lcl_addProperty(aPropertyNames, aPropertyValues, UNO_NAME_3D_TRANSFORM_MATRIX, uno::Any(aHM)); |
1108 | 0 | } |
1109 | 0 | xShape->setPropertyValues(aPropertyNames, aPropertyValues); |
1110 | 0 | } |
1111 | 0 | catch( const uno::Exception& ) |
1112 | 0 | { |
1113 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1114 | 0 | } |
1115 | 0 | return xShape; |
1116 | 0 | } |
1117 | | |
1118 | | rtl::Reference<SvxShapePolyPolygon> |
1119 | | ShapeFactory::createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1120 | | , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon ) |
1121 | 0 | { |
1122 | 0 | if( !xTarget.is() ) |
1123 | 0 | return nullptr; |
1124 | | |
1125 | | //create shape |
1126 | 0 | rtl::Reference<SdrPathObj> pPath = new SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), SdrObjKind::Polygon); |
1127 | 0 | xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath.get()); |
1128 | | |
1129 | | //set properties |
1130 | 0 | try |
1131 | 0 | { |
1132 | | // Polygon |
1133 | 0 | basegfx::B2DPolyPolygon aNewPolyPolygon( PolyToB2DPolyPolygon(rPolyPolygon) ); |
1134 | | // tdf#117145 metric of SdrModel is app-specific, metric of UNO API is 100thmm |
1135 | 0 | pPath->ForceMetricToItemPoolMetric(aNewPolyPolygon); |
1136 | 0 | pPath->SetPathPoly(aNewPolyPolygon); |
1137 | 0 | } |
1138 | 0 | catch( const uno::Exception& ) |
1139 | 0 | { |
1140 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1141 | 0 | } |
1142 | 0 | return static_cast<SvxShapePolyPolygon*>(pPath->getUnoShape().get()); |
1143 | 0 | } |
1144 | | |
1145 | | static drawing::PointSequenceSequence createPolyPolygon_Symbol( const drawing::Position3D& rPos |
1146 | | , const drawing::Direction3D& rSize |
1147 | | , sal_Int32 nStandardSymbol ) |
1148 | 0 | { |
1149 | 0 | if(nStandardSymbol<0) |
1150 | 0 | nStandardSymbol*=-1; |
1151 | 0 | nStandardSymbol = nStandardSymbol%ShapeFactory::getSymbolCount(); |
1152 | 0 | SymbolEnum eSymbolType=static_cast<SymbolEnum>(nStandardSymbol); |
1153 | |
|
1154 | 0 | const double& fX = rPos.PositionX; |
1155 | 0 | const double& fY = rPos.PositionY; |
1156 | |
|
1157 | 0 | const double fWidthH = rSize.DirectionX/2.0; //fWidthH stands for Half Width |
1158 | 0 | const double fHeightH = rSize.DirectionY/2.0; //fHeightH stands for Half Height |
1159 | |
|
1160 | 0 | const sal_Int32 nQuarterCount = 35; // points inside a quadrant, used in case circle |
1161 | |
|
1162 | 0 | sal_Int32 nPointCount = 4; //all arrow symbols only need 4 points |
1163 | 0 | switch( eSymbolType ) |
1164 | 0 | { |
1165 | 0 | case Symbol_Square: |
1166 | 0 | case Symbol_Diamond: |
1167 | 0 | case Symbol_Bowtie: |
1168 | 0 | case Symbol_Sandglass: |
1169 | 0 | case Symbol_HorizontalBar: |
1170 | 0 | case Symbol_VerticalBar: |
1171 | 0 | nPointCount = 5; |
1172 | 0 | break; |
1173 | 0 | case Symbol_X: |
1174 | 0 | case Symbol_Plus: |
1175 | 0 | nPointCount = 13; |
1176 | 0 | break; |
1177 | 0 | case Symbol_Star: |
1178 | 0 | nPointCount = 9; |
1179 | 0 | break; |
1180 | 0 | case Symbol_Asterisk: |
1181 | 0 | nPointCount = 19; |
1182 | 0 | break; |
1183 | 0 | case Symbol_Circle: |
1184 | 0 | nPointCount = 5 + 4 * nQuarterCount; |
1185 | 0 | break; |
1186 | 0 | default: |
1187 | 0 | break; |
1188 | 0 | } |
1189 | | |
1190 | 0 | drawing::PointSequenceSequence aPP; |
1191 | |
|
1192 | 0 | aPP.realloc(1); |
1193 | |
|
1194 | 0 | uno::Sequence<awt::Point>* pOuterSequence = aPP.getArray(); |
1195 | |
|
1196 | 0 | pOuterSequence->realloc(nPointCount); |
1197 | |
|
1198 | 0 | awt::Point* pInnerSequence = pOuterSequence->getArray(); |
1199 | |
|
1200 | 0 | auto toPoint = [](double x, double y) -> awt::Point |
1201 | 0 | { |
1202 | 0 | return { static_cast<sal_Int32>(x), static_cast<sal_Int32>(y) }; |
1203 | 0 | }; |
1204 | 0 | switch(eSymbolType) |
1205 | 0 | { |
1206 | 0 | case Symbol_Square: |
1207 | 0 | { |
1208 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1209 | |
|
1210 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1211 | |
|
1212 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH ); |
1213 | |
|
1214 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH ); |
1215 | |
|
1216 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1217 | 0 | break; |
1218 | 0 | } |
1219 | 0 | case Symbol_UpArrow: |
1220 | 0 | { |
1221 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1222 | |
|
1223 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH ); |
1224 | |
|
1225 | 0 | *pInnerSequence++ = toPoint( fX, fY-fHeightH ); |
1226 | |
|
1227 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1228 | 0 | break; |
1229 | 0 | } |
1230 | 0 | case Symbol_DownArrow: |
1231 | 0 | { |
1232 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1233 | |
|
1234 | 0 | *pInnerSequence++ = toPoint( fX, fY+fHeightH ); |
1235 | |
|
1236 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH ); |
1237 | |
|
1238 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1239 | 0 | break; |
1240 | 0 | } |
1241 | 0 | case Symbol_RightArrow: |
1242 | 0 | { |
1243 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1244 | |
|
1245 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1246 | |
|
1247 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY ); |
1248 | |
|
1249 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1250 | 0 | break; |
1251 | 0 | } |
1252 | 0 | case Symbol_LeftArrow: |
1253 | 0 | { |
1254 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY ); |
1255 | |
|
1256 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH ); |
1257 | |
|
1258 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH ); |
1259 | |
|
1260 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY ); |
1261 | 0 | break; |
1262 | 0 | } |
1263 | 0 | case Symbol_Bowtie: |
1264 | 0 | { |
1265 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1266 | |
|
1267 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1268 | |
|
1269 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH ); |
1270 | |
|
1271 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH ); |
1272 | |
|
1273 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1274 | 0 | break; |
1275 | 0 | } |
1276 | 0 | case Symbol_Sandglass: |
1277 | 0 | { |
1278 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1279 | |
|
1280 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH ); |
1281 | |
|
1282 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1283 | |
|
1284 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH ); |
1285 | |
|
1286 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1287 | 0 | break; |
1288 | 0 | } |
1289 | 0 | case Symbol_Diamond: |
1290 | 0 | { |
1291 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY ); |
1292 | |
|
1293 | 0 | *pInnerSequence++ = toPoint( fX, fY+fHeightH ); |
1294 | |
|
1295 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY ); |
1296 | |
|
1297 | 0 | *pInnerSequence++ = toPoint( fX, fY-fHeightH ); |
1298 | |
|
1299 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY ); |
1300 | 0 | break; |
1301 | 0 | } |
1302 | 0 | case Symbol_HorizontalBar: |
1303 | 0 | { |
1304 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-0.2*fHeightH ); |
1305 | |
|
1306 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-0.2*fHeightH ); |
1307 | |
|
1308 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+0.2*fHeightH ); |
1309 | |
|
1310 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+0.2*fHeightH ); |
1311 | |
|
1312 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-0.2*fHeightH ); |
1313 | 0 | break; |
1314 | 0 | } |
1315 | 0 | case Symbol_VerticalBar: |
1316 | 0 | { |
1317 | 0 | *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY-fHeightH ); |
1318 | |
|
1319 | 0 | *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY-fHeightH ); |
1320 | |
|
1321 | 0 | *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY+fHeightH ); |
1322 | |
|
1323 | 0 | *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY+fHeightH ); |
1324 | |
|
1325 | 0 | *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY-fHeightH ); |
1326 | |
|
1327 | 0 | break; |
1328 | 0 | } |
1329 | 0 | case Symbol_Circle: |
1330 | 0 | { |
1331 | 0 | double fOmega = M_PI_2 / (nQuarterCount + 1.0); |
1332 | | // one point in the middle of each edge to get full size bounding rectangle |
1333 | 0 | *pInnerSequence++ = toPoint( fX + fWidthH, fY ); |
1334 | | // 0 to PI/2 |
1335 | 0 | for (sal_Int32 i = 1; i <= nQuarterCount; ++i) |
1336 | 0 | { |
1337 | 0 | *pInnerSequence++ = toPoint( fX + fWidthH * cos( i * fOmega ), fY - fHeightH * sin( i * fOmega ) ); |
1338 | 0 | } |
1339 | | // PI/2 to PI |
1340 | 0 | *pInnerSequence++ = toPoint( fX, fY - fHeightH ); |
1341 | 0 | for (sal_Int32 i = 1; i <= nQuarterCount; ++i) |
1342 | 0 | { |
1343 | 0 | *pInnerSequence++ = toPoint( fX - fWidthH * sin( i * fOmega), fY - fHeightH * cos( i * fOmega) ); |
1344 | 0 | } |
1345 | | // PI to 3/2*PI |
1346 | 0 | *pInnerSequence++ = toPoint( fX - fWidthH, fY ); |
1347 | 0 | for (sal_Int32 i = 1; i <= nQuarterCount; ++i) |
1348 | 0 | { |
1349 | 0 | *pInnerSequence++ = toPoint( fX - fWidthH * cos( i * fOmega), fY + fHeightH * sin( i * fOmega) ); |
1350 | 0 | } |
1351 | | // 3/2*PI to 2*PI |
1352 | 0 | *pInnerSequence++ = toPoint( fX, fY + fHeightH ); |
1353 | 0 | for (sal_Int32 i = 1; i <= nQuarterCount; ++i) |
1354 | 0 | { |
1355 | 0 | *pInnerSequence++ = toPoint( fX + fWidthH * sin(i * fOmega), fY + fHeightH * cos(i * fOmega) ); |
1356 | 0 | } |
1357 | | // close polygon |
1358 | 0 | *pInnerSequence++ = toPoint( fX + fWidthH, fY ); |
1359 | 0 | break; |
1360 | 0 | } |
1361 | 0 | case Symbol_Star: |
1362 | 0 | { |
1363 | 0 | *pInnerSequence++ = toPoint( fX, fY-fHeightH ); |
1364 | |
|
1365 | 0 | *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY-0.2*fHeightH ); |
1366 | |
|
1367 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY ); |
1368 | |
|
1369 | 0 | *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY+0.2*fHeightH ); |
1370 | |
|
1371 | 0 | *pInnerSequence++ = toPoint( fX, fY+fHeightH ); |
1372 | |
|
1373 | 0 | *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY+0.2*fHeightH ); |
1374 | |
|
1375 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY ); |
1376 | |
|
1377 | 0 | *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY-0.2*fHeightH ); |
1378 | |
|
1379 | 0 | *pInnerSequence++ = toPoint( fX, fY-fHeightH ); |
1380 | 0 | break; |
1381 | 0 | } |
1382 | 0 | case Symbol_X: |
1383 | 0 | { |
1384 | 0 | const double fScaleX = fWidthH / 128.0; |
1385 | 0 | const double fScaleY = fHeightH / 128.0; |
1386 | 0 | constexpr double fSmall = std::numbers::sqrt2 * 10; |
1387 | 0 | constexpr double fLarge = 128.0 - fSmall; |
1388 | |
|
1389 | 0 | *pInnerSequence++ = toPoint( fX, fY - fScaleY * fSmall ); |
1390 | |
|
1391 | 0 | *pInnerSequence++ = toPoint( fX - fScaleX * fLarge, fY - fHeightH ); |
1392 | |
|
1393 | 0 | *pInnerSequence++ = toPoint( fX - fWidthH, fY - fScaleY * fLarge ); |
1394 | |
|
1395 | 0 | *pInnerSequence++ = toPoint( fX - fScaleX * fSmall, fY ); |
1396 | |
|
1397 | 0 | *pInnerSequence++ = toPoint( fX - fWidthH, fY + fScaleY * fLarge ); |
1398 | |
|
1399 | 0 | *pInnerSequence++ = toPoint( fX - fScaleX * fLarge, fY + fHeightH ); |
1400 | |
|
1401 | 0 | *pInnerSequence++ = toPoint( fX, fY + fScaleY * fSmall ); |
1402 | |
|
1403 | 0 | *pInnerSequence++ = toPoint( fX + fScaleX * fLarge, fY + fHeightH ); |
1404 | |
|
1405 | 0 | *pInnerSequence++ = toPoint( fX + fWidthH, fY + fScaleY * fLarge ); |
1406 | |
|
1407 | 0 | *pInnerSequence++ = toPoint( fX + fScaleX * fSmall, fY ); |
1408 | |
|
1409 | 0 | *pInnerSequence++ = toPoint( fX + fWidthH, fY - fScaleY * fLarge ); |
1410 | |
|
1411 | 0 | *pInnerSequence++ = toPoint( fX + fScaleX * fLarge, fY - fHeightH ); |
1412 | |
|
1413 | 0 | *pInnerSequence++ = toPoint( fX, fY - fScaleY * fSmall ); |
1414 | 0 | break; |
1415 | | |
1416 | 0 | } |
1417 | 0 | case Symbol_Plus: |
1418 | 0 | { |
1419 | 0 | const double fScaleX = fWidthH / 128.0; |
1420 | 0 | const double fScaleY = fHeightH / 128.0; |
1421 | 0 | constexpr double fHalf = 10.0; //half line width on 256 size square |
1422 | 0 | const double fdX = fScaleX * fHalf; |
1423 | 0 | const double fdY = fScaleY * fHalf; |
1424 | |
|
1425 | 0 | *pInnerSequence++ = toPoint( fX-fdX, fY-fHeightH ); |
1426 | |
|
1427 | 0 | *pInnerSequence++ = toPoint( fX-fdX, fY-fdY ); |
1428 | |
|
1429 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fdY ); |
1430 | |
|
1431 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fdY ); |
1432 | |
|
1433 | 0 | *pInnerSequence++ = toPoint( fX-fdX, fY+fdY ); |
1434 | |
|
1435 | 0 | *pInnerSequence++ = toPoint( fX-fdX, fY+fHeightH ); |
1436 | |
|
1437 | 0 | *pInnerSequence++ = toPoint( fX+fdX, fY+fHeightH ); |
1438 | |
|
1439 | 0 | *pInnerSequence++ = toPoint( fX+fdX, fY+fdY ); |
1440 | |
|
1441 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fdY ); |
1442 | |
|
1443 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fdY ); |
1444 | |
|
1445 | 0 | *pInnerSequence++ = toPoint( fX+fdX, fY-fdY ); |
1446 | |
|
1447 | 0 | *pInnerSequence++ = toPoint( fX+fdY, fY-fHeightH ); |
1448 | |
|
1449 | 0 | *pInnerSequence++ = toPoint( fX-fdX, fY-fHeightH ); |
1450 | 0 | break; |
1451 | | |
1452 | 0 | } |
1453 | 0 | case Symbol_Asterisk: |
1454 | 0 | { |
1455 | 0 | constexpr double fHalf = 10.0; // half line width on 256 size square |
1456 | 0 | constexpr double fTwoY = fHalf * std::numbers::sqrt3; |
1457 | 0 | constexpr double fFourY = (128.0 - 2.0 * fHalf ) * std::numbers::inv_sqrt3; |
1458 | 0 | constexpr double fThreeX = 128.0 - fHalf; |
1459 | 0 | constexpr double fThreeY = fHalf * std::numbers::sqrt3 + fFourY; |
1460 | 0 | constexpr double fFiveX = 2.0 * fHalf; |
1461 | |
|
1462 | 0 | const double fScaleX = fWidthH / 128.0; |
1463 | 0 | const double fScaleY = fHeightH / 128.0; |
1464 | | |
1465 | | //1 |
1466 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY-fHeightH ); |
1467 | | //2 |
1468 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY-fScaleY * fTwoY ); |
1469 | | //3 |
1470 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fThreeX, fY-fScaleY * fThreeY ); |
1471 | | //4 |
1472 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fScaleY * fFourY ); |
1473 | | //5 |
1474 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fFiveX, fY ); |
1475 | | //6 as 4 |
1476 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fScaleY * fFourY ); |
1477 | | //7 as 3 |
1478 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fThreeX, fY+fScaleY * fThreeY ); |
1479 | | //8 as 2 |
1480 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY+fScaleY * fTwoY ); |
1481 | | //9 as 1 |
1482 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY+fHeightH ); |
1483 | | //10 as 1 |
1484 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY+fHeightH ); |
1485 | | //11 as 2 |
1486 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY+fScaleY * fTwoY ); |
1487 | | //12 as 3 |
1488 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fThreeX, fY+fScaleY * fThreeY ); |
1489 | | //13 as 4 |
1490 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fScaleY * fFourY ); |
1491 | | //14 as 5 |
1492 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fFiveX, fY ); |
1493 | | //15 as 4 |
1494 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fScaleY * fFourY ); |
1495 | | //16 as 3 |
1496 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fThreeX, fY-fScaleY * fThreeY ); |
1497 | | //17 as 2 |
1498 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY-fScaleY * fTwoY ); |
1499 | | // 18 as 1 |
1500 | 0 | *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY-fHeightH ); |
1501 | | // 19 = 1, closing |
1502 | 0 | *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY-fHeightH ); |
1503 | 0 | break; |
1504 | 0 | } |
1505 | 0 | default: //case Symbol_Square: |
1506 | 0 | { |
1507 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1508 | |
|
1509 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH ); |
1510 | |
|
1511 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH ); |
1512 | |
|
1513 | 0 | *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH ); |
1514 | |
|
1515 | 0 | *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH ); |
1516 | 0 | break; |
1517 | 0 | } |
1518 | 0 | } |
1519 | | |
1520 | 0 | return aPP; |
1521 | 0 | } |
1522 | | |
1523 | | rtl::Reference<SvxShapePolyPolygon> |
1524 | | ShapeFactory::createSymbol2D( |
1525 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1526 | | , const drawing::Position3D& rPosition |
1527 | | , const drawing::Direction3D& rSize |
1528 | | , sal_Int32 nStandardSymbol |
1529 | | , sal_Int32 nBorderColor |
1530 | | , sal_Int32 nFillColor ) |
1531 | 0 | { |
1532 | 0 | if( !xTarget.is() ) |
1533 | 0 | return nullptr; |
1534 | | |
1535 | | //create shape |
1536 | 0 | rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); |
1537 | 0 | xShape->setShapeKind(SdrObjKind::Polygon); |
1538 | 0 | xTarget->addShape(*xShape); |
1539 | | |
1540 | | //set properties |
1541 | 0 | try |
1542 | 0 | { |
1543 | 0 | drawing::PointSequenceSequence aPoints = |
1544 | 0 | createPolyPolygon_Symbol( rPosition, rSize, nStandardSymbol ); |
1545 | | |
1546 | | //Polygon |
1547 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_POLYPOLYGON |
1548 | 0 | , uno::Any( aPoints ) ); |
1549 | | |
1550 | | //LineColor |
1551 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINECOLOR |
1552 | 0 | , uno::Any( nBorderColor ) ); |
1553 | | |
1554 | | //FillColor |
1555 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_FILLCOLOR |
1556 | 0 | , uno::Any( nFillColor ) ); |
1557 | 0 | } |
1558 | 0 | catch( const uno::Exception& ) |
1559 | 0 | { |
1560 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1561 | 0 | } |
1562 | 0 | return xShape; |
1563 | 0 | } |
1564 | | |
1565 | | rtl::Reference<SvxGraphicObject> |
1566 | | ShapeFactory::createGraphic2D( |
1567 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1568 | | , const drawing::Position3D& rPosition |
1569 | | , const drawing::Direction3D& rSize |
1570 | | , const uno::Reference< graphic::XGraphic >& xGraphic ) |
1571 | 0 | { |
1572 | 0 | if( !xTarget.is() || !xGraphic.is() ) |
1573 | 0 | return nullptr; |
1574 | | |
1575 | | // @todo: change this to a rectangle shape with a fill bitmap for |
1576 | | // performance reasons (ask AW, said CL) |
1577 | | |
1578 | | //create shape |
1579 | 0 | rtl::Reference<SvxGraphicObject> xShape = new SvxGraphicObject(nullptr); |
1580 | 0 | xShape->setShapeKind(SdrObjKind::Graphic); |
1581 | 0 | xTarget->addShape(*xShape); |
1582 | |
|
1583 | 0 | try |
1584 | 0 | { |
1585 | | // assume position is upper left corner. Transform to center. |
1586 | 0 | drawing::Position3D aCenterPosition( |
1587 | 0 | rPosition.PositionX - (rSize.DirectionX / 2.0), |
1588 | 0 | rPosition.PositionY - (rSize.DirectionY / 2.0), |
1589 | 0 | rPosition.PositionZ ); |
1590 | 0 | xShape->setPosition( Position3DToAWTPoint( aCenterPosition )); |
1591 | 0 | xShape->setSize( Direction3DToAWTSize( rSize )); |
1592 | 0 | } |
1593 | 0 | catch( const uno::Exception & ) |
1594 | 0 | { |
1595 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1596 | 0 | } |
1597 | 0 | try |
1598 | 0 | { |
1599 | 0 | xShape->SvxShape::setPropertyValue( u"Graphic"_ustr, uno::Any( xGraphic )); |
1600 | 0 | } |
1601 | 0 | catch( const uno::Exception& ) |
1602 | 0 | { |
1603 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1604 | 0 | } |
1605 | 0 | return xShape; |
1606 | 0 | } |
1607 | | |
1608 | | rtl::Reference< SvxShapeGroup > |
1609 | | ShapeFactory::createGroup2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1610 | | , const OUString& aName ) |
1611 | 0 | { |
1612 | 0 | if( !xTarget.is() ) |
1613 | 0 | return nullptr; |
1614 | 0 | try |
1615 | 0 | { |
1616 | | //create and add to target |
1617 | 0 | rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr); |
1618 | 0 | xShapeGroup->setShapeKind(SdrObjKind::Group); |
1619 | | // cast to resolve ambiguity in converting to XShape |
1620 | 0 | xTarget->addShape(*xShapeGroup); |
1621 | | |
1622 | | //set name |
1623 | 0 | if(!aName.isEmpty()) |
1624 | 0 | setShapeName( xShapeGroup, aName ); |
1625 | |
|
1626 | 0 | {//workaround |
1627 | | //need this null size as otherwise empty group shapes where painted with a gray border |
1628 | 0 | xShapeGroup->setSize(awt::Size(0,0)); |
1629 | 0 | } |
1630 | |
|
1631 | 0 | return xShapeGroup; |
1632 | 0 | } |
1633 | 0 | catch( const uno::Exception& ) |
1634 | 0 | { |
1635 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1636 | 0 | } |
1637 | 0 | return nullptr; |
1638 | 0 | } |
1639 | | |
1640 | | rtl::Reference< SvxShapeGroup > |
1641 | | ShapeFactory::createGroup2D( const rtl::Reference<SvxDrawPage>& xTarget |
1642 | | , const OUString& aName ) |
1643 | 0 | { |
1644 | 0 | if( !xTarget.is() ) |
1645 | 0 | return nullptr; |
1646 | 0 | try |
1647 | 0 | { |
1648 | | //create and add to target |
1649 | 0 | rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr); |
1650 | 0 | xShapeGroup->setShapeKind(SdrObjKind::Group); |
1651 | | // cast to resolve ambiguity in converting to XShape |
1652 | 0 | xTarget->add(static_cast<SvxShape*>(xShapeGroup.get())); |
1653 | | |
1654 | | //set name |
1655 | 0 | if(!aName.isEmpty()) |
1656 | 0 | setShapeName( xShapeGroup, aName ); |
1657 | |
|
1658 | 0 | {//workaround |
1659 | | //need this null size as otherwise empty group shapes where painted with a gray border |
1660 | 0 | xShapeGroup->setSize(awt::Size(0,0)); |
1661 | 0 | } |
1662 | |
|
1663 | 0 | return xShapeGroup; |
1664 | 0 | } |
1665 | 0 | catch( const uno::Exception& ) |
1666 | 0 | { |
1667 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1668 | 0 | } |
1669 | 0 | return nullptr; |
1670 | 0 | } |
1671 | | |
1672 | | rtl::Reference<Svx3DSceneObject> |
1673 | | ShapeFactory::createGroup3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1674 | | , const OUString& aName ) |
1675 | 0 | { |
1676 | 0 | if( !xTarget.is() ) |
1677 | 0 | return nullptr; |
1678 | 0 | try |
1679 | 0 | { |
1680 | | //create shape |
1681 | 0 | rtl::Reference<Svx3DSceneObject> xShape = new Svx3DSceneObject(nullptr, nullptr); |
1682 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Scene); |
1683 | 0 | xTarget->addShape(*xShape); |
1684 | | |
1685 | | //it is necessary to set the transform matrix to initialize the scene properly |
1686 | | //otherwise all objects which are placed into this Group will not be visible |
1687 | | //the following should be unnecessary after the bug is fixed |
1688 | | //set properties |
1689 | 0 | try |
1690 | 0 | { |
1691 | 0 | ::basegfx::B3DHomMatrix aM; |
1692 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_3D_TRANSFORM_MATRIX |
1693 | 0 | , uno::Any(B3DHomMatrixToHomogenMatrix(aM)) ); |
1694 | 0 | } |
1695 | 0 | catch( const uno::Exception& ) |
1696 | 0 | { |
1697 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1698 | 0 | } |
1699 | | |
1700 | | //set name |
1701 | 0 | if(!aName.isEmpty()) |
1702 | 0 | setShapeName( xShape , aName ); |
1703 | | |
1704 | | //return |
1705 | 0 | return xShape; |
1706 | 0 | } |
1707 | 0 | catch( const uno::Exception& ) |
1708 | 0 | { |
1709 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1710 | 0 | } |
1711 | 0 | return nullptr; |
1712 | 0 | } |
1713 | | |
1714 | | rtl::Reference<SvxShapeCircle> |
1715 | | ShapeFactory::createCircle2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1716 | | , const drawing::Position3D& rPosition |
1717 | | , const drawing::Direction3D& rSize ) |
1718 | 0 | { |
1719 | 0 | if( !xTarget.is() ) |
1720 | 0 | return nullptr; |
1721 | | |
1722 | | //create shape |
1723 | 0 | rtl::Reference<SvxShapeCircle> xShape = new SvxShapeCircle(nullptr); |
1724 | 0 | xShape->setShapeKind(SdrObjKind::CircleOrEllipse); |
1725 | 0 | xTarget->addShape(*xShape); |
1726 | |
|
1727 | 0 | try |
1728 | 0 | { |
1729 | 0 | drawing::Position3D aCenterPosition( |
1730 | 0 | rPosition.PositionX - (rSize.DirectionX / 2.0), |
1731 | 0 | rPosition.PositionY - (rSize.DirectionY / 2.0), |
1732 | 0 | rPosition.PositionZ ); |
1733 | 0 | xShape->setPosition( Position3DToAWTPoint( aCenterPosition )); |
1734 | 0 | xShape->setSize( Direction3DToAWTSize( rSize )); |
1735 | 0 | } |
1736 | 0 | catch( const uno::Exception & ) |
1737 | 0 | { |
1738 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1739 | 0 | } |
1740 | | |
1741 | | //set properties |
1742 | 0 | try |
1743 | 0 | { |
1744 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_CIRCKIND, uno::Any( drawing::CircleKind_FULL ) ); |
1745 | 0 | } |
1746 | 0 | catch( const uno::Exception& ) |
1747 | 0 | { |
1748 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1749 | 0 | } |
1750 | 0 | return xShape; |
1751 | 0 | } |
1752 | | |
1753 | | rtl::Reference<SvxShapeCircle> |
1754 | | ShapeFactory::createCircle( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1755 | | , const awt::Size& rSize |
1756 | | , const awt::Point& rPosition ) |
1757 | 0 | { |
1758 | 0 | rtl::Reference<SvxShapeCircle> xShape = new SvxShapeCircle(nullptr); |
1759 | 0 | xShape->setShapeKind(SdrObjKind::CircleOrEllipse); |
1760 | 0 | xTarget->addShape(*xShape); |
1761 | 0 | xShape->setSize( rSize ); |
1762 | 0 | xShape->setPosition( rPosition ); |
1763 | |
|
1764 | 0 | return xShape; |
1765 | 0 | } |
1766 | | |
1767 | | rtl::Reference<Svx3DPolygonObject> |
1768 | | ShapeFactory::createLine3D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1769 | | , const std::vector<std::vector<css::drawing::Position3D>>& rPoints |
1770 | | , const VLineProperties& rLineProperties ) |
1771 | 0 | { |
1772 | 0 | if( !xTarget.is() ) |
1773 | 0 | return nullptr; |
1774 | | |
1775 | 0 | if(rPoints.empty()) |
1776 | 0 | return nullptr; |
1777 | | |
1778 | | //create shape |
1779 | 0 | rtl::Reference<Svx3DPolygonObject> xShape = new Svx3DPolygonObject(nullptr); |
1780 | 0 | xShape->setShapeKind(SdrObjKind::E3D_Polygon); |
1781 | 0 | xTarget->addShape(*xShape); |
1782 | |
|
1783 | 0 | css::drawing::PolyPolygonShape3D aUnoPoly = toPolyPolygonShape3D(rPoints); |
1784 | | |
1785 | | //set properties |
1786 | 0 | try |
1787 | 0 | { |
1788 | 0 | uno::Sequence<OUString> aPropertyNames { |
1789 | 0 | UNO_NAME_3D_POLYPOLYGON3D, |
1790 | 0 | UNO_NAME_3D_LINEONLY |
1791 | 0 | }; |
1792 | |
|
1793 | 0 | uno::Sequence<uno::Any> aPropertyValues { |
1794 | 0 | uno::Any(aUnoPoly), // Polygon |
1795 | 0 | uno::Any(true) // LineOnly |
1796 | 0 | }; |
1797 | | |
1798 | | //Transparency |
1799 | 0 | if(rLineProperties.Transparence.hasValue()) |
1800 | 0 | { |
1801 | 0 | lcl_addProperty(aPropertyNames, aPropertyValues, |
1802 | 0 | UNO_NAME_LINETRANSPARENCE, |
1803 | 0 | rLineProperties.Transparence); |
1804 | 0 | } |
1805 | | |
1806 | | //LineStyle |
1807 | 0 | if(rLineProperties.LineStyle.hasValue()) |
1808 | 0 | { |
1809 | 0 | lcl_addProperty(aPropertyNames, aPropertyValues, |
1810 | 0 | UNO_NAME_LINESTYLE, |
1811 | 0 | rLineProperties.LineStyle); |
1812 | 0 | } |
1813 | | |
1814 | | //LineWidth |
1815 | 0 | if(rLineProperties.Width.hasValue()) |
1816 | 0 | { |
1817 | 0 | lcl_addProperty(aPropertyNames, aPropertyValues, |
1818 | 0 | UNO_NAME_LINEWIDTH, |
1819 | 0 | rLineProperties.Width); |
1820 | 0 | } |
1821 | | |
1822 | | //LineColor |
1823 | 0 | if(rLineProperties.Color.hasValue()) |
1824 | 0 | { |
1825 | 0 | lcl_addProperty(aPropertyNames, aPropertyValues, |
1826 | 0 | UNO_NAME_LINECOLOR, |
1827 | 0 | rLineProperties.Color); |
1828 | 0 | } |
1829 | 0 | xShape->setPropertyValues(aPropertyNames, aPropertyValues); |
1830 | 0 | } |
1831 | 0 | catch( const uno::Exception& ) |
1832 | 0 | { |
1833 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1834 | 0 | } |
1835 | 0 | return xShape; |
1836 | 0 | } |
1837 | | |
1838 | | rtl::Reference<SvxShapePolyPolygon> |
1839 | | ShapeFactory::createLine2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1840 | | , const drawing::PointSequenceSequence& rPoints |
1841 | | , const VLineProperties* pLineProperties ) |
1842 | 0 | { |
1843 | 0 | if( !xTarget.is() ) |
1844 | 0 | return nullptr; |
1845 | | |
1846 | 0 | if(!rPoints.hasElements()) |
1847 | 0 | return nullptr; |
1848 | | |
1849 | | //create shape |
1850 | 0 | rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); |
1851 | 0 | xShape->setShapeKind(SdrObjKind::PolyLine); |
1852 | 0 | xTarget->addShape(*xShape); |
1853 | | |
1854 | | //set properties |
1855 | 0 | try |
1856 | 0 | { |
1857 | | //Polygon |
1858 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_POLYPOLYGON |
1859 | 0 | , uno::Any( rPoints ) ); |
1860 | |
|
1861 | 0 | if(pLineProperties) |
1862 | 0 | { |
1863 | | //Transparency |
1864 | 0 | if(pLineProperties->Transparence.hasValue()) |
1865 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINETRANSPARENCE |
1866 | 0 | , pLineProperties->Transparence ); |
1867 | | |
1868 | | //LineStyle |
1869 | 0 | if(pLineProperties->LineStyle.hasValue()) |
1870 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINESTYLE |
1871 | 0 | , pLineProperties->LineStyle ); |
1872 | | |
1873 | | //LineWidth |
1874 | 0 | if(pLineProperties->Width.hasValue()) |
1875 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINEWIDTH |
1876 | 0 | , pLineProperties->Width ); |
1877 | | |
1878 | | //LineColor |
1879 | 0 | if(pLineProperties->Color.hasValue()) |
1880 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINECOLOR |
1881 | 0 | , pLineProperties->Color ); |
1882 | | |
1883 | | //LineDashName |
1884 | 0 | if(pLineProperties->DashName.hasValue()) |
1885 | 0 | xShape->SvxShape::setPropertyValue( u"LineDashName"_ustr |
1886 | 0 | , pLineProperties->DashName ); |
1887 | | |
1888 | | //LineCap |
1889 | 0 | if(pLineProperties->LineCap.hasValue()) |
1890 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINECAP |
1891 | 0 | , pLineProperties->LineCap ); |
1892 | 0 | } |
1893 | 0 | } |
1894 | 0 | catch( const uno::Exception& ) |
1895 | 0 | { |
1896 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1897 | 0 | } |
1898 | 0 | return xShape; |
1899 | 0 | } |
1900 | | |
1901 | | rtl::Reference<SvxShapePolyPolygon> |
1902 | | ShapeFactory::createLine2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1903 | | , const std::vector<std::vector<css::drawing::Position3D>>& rPoints |
1904 | | , const VLineProperties* pLineProperties ) |
1905 | 0 | { |
1906 | 0 | if( !xTarget.is() ) |
1907 | 0 | return nullptr; |
1908 | | |
1909 | 0 | if(rPoints.empty()) |
1910 | 0 | return nullptr; |
1911 | | |
1912 | | //create shape |
1913 | 0 | rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); |
1914 | 0 | xShape->setShapeKind(SdrObjKind::PolyLine); |
1915 | 0 | xTarget->addShape(*xShape); |
1916 | |
|
1917 | 0 | drawing::PointSequenceSequence aAnyPoints = PolyToPointSequence(rPoints); |
1918 | | |
1919 | | //set properties |
1920 | 0 | try |
1921 | 0 | { |
1922 | | //Polygon |
1923 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_POLYPOLYGON |
1924 | 0 | , uno::Any( aAnyPoints ) ); |
1925 | |
|
1926 | 0 | if(pLineProperties) |
1927 | 0 | { |
1928 | | //Transparency |
1929 | 0 | if(pLineProperties->Transparence.hasValue()) |
1930 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINETRANSPARENCE |
1931 | 0 | , pLineProperties->Transparence ); |
1932 | | |
1933 | | //LineStyle |
1934 | 0 | if(pLineProperties->LineStyle.hasValue()) |
1935 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINESTYLE |
1936 | 0 | , pLineProperties->LineStyle ); |
1937 | | |
1938 | | //LineWidth |
1939 | 0 | if(pLineProperties->Width.hasValue()) |
1940 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINEWIDTH |
1941 | 0 | , pLineProperties->Width ); |
1942 | | |
1943 | | //LineColor |
1944 | 0 | if(pLineProperties->Color.hasValue()) |
1945 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINECOLOR |
1946 | 0 | , pLineProperties->Color ); |
1947 | | |
1948 | | //LineDashName |
1949 | 0 | if(pLineProperties->DashName.hasValue()) |
1950 | 0 | xShape->SvxShape::setPropertyValue( u"LineDashName"_ustr |
1951 | 0 | , pLineProperties->DashName ); |
1952 | | |
1953 | | //LineCap |
1954 | 0 | if(pLineProperties->LineCap.hasValue()) |
1955 | 0 | xShape->SvxShape::setPropertyValue( UNO_NAME_LINECAP |
1956 | 0 | , pLineProperties->LineCap ); |
1957 | 0 | } |
1958 | 0 | } |
1959 | 0 | catch( const uno::Exception& ) |
1960 | 0 | { |
1961 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
1962 | 0 | } |
1963 | 0 | return xShape; |
1964 | 0 | } |
1965 | | |
1966 | | rtl::Reference<SvxShapePolyPolygon> |
1967 | | ShapeFactory::createLine ( const rtl::Reference<SvxShapeGroupAnyD>& xTarget, |
1968 | | const awt::Size& rSize, const awt::Point& rPosition ) |
1969 | 0 | { |
1970 | | //create shape |
1971 | 0 | rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr); |
1972 | 0 | xShape->setShapeKind(SdrObjKind::Line); |
1973 | 0 | xTarget->addShape(*xShape); |
1974 | 0 | xShape->setSize( rSize ); |
1975 | 0 | xShape->setPosition( rPosition ); |
1976 | |
|
1977 | 0 | return xShape; |
1978 | 0 | } |
1979 | | |
1980 | | rtl::Reference<SvxShapeRect> ShapeFactory::createInvisibleRectangle( |
1981 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
1982 | | , const awt::Size& rSize ) |
1983 | 0 | { |
1984 | 0 | try |
1985 | 0 | { |
1986 | 0 | if(!xTarget.is()) |
1987 | 0 | return nullptr; |
1988 | | |
1989 | 0 | rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr); |
1990 | 0 | xShape->setShapeKind(SdrObjKind::Rectangle); |
1991 | 0 | xTarget->addShape( *xShape ); |
1992 | 0 | ShapeFactory::makeShapeInvisible( xShape ); |
1993 | 0 | xShape->setSize( rSize ); |
1994 | 0 | return xShape; |
1995 | 0 | } |
1996 | 0 | catch( const uno::Exception & ) |
1997 | 0 | { |
1998 | 0 | DBG_UNHANDLED_EXCEPTION("chart2"); |
1999 | 0 | } |
2000 | 0 | return nullptr; |
2001 | 0 | } |
2002 | | |
2003 | | rtl::Reference<SvxShapeRect> ShapeFactory::createRectangle( |
2004 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget, |
2005 | | const awt::Size& rSize, |
2006 | | const awt::Point& rPosition, |
2007 | | const tNameSequence& rPropNames, |
2008 | | const tAnySequence& rPropValues, |
2009 | | StackPosition ePos ) |
2010 | 0 | { |
2011 | 0 | rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr); |
2012 | 0 | xShape->setShapeKind(SdrObjKind::Rectangle); |
2013 | 0 | if (ePos == StackPosition::Bottom) |
2014 | 0 | { |
2015 | 0 | uno::Reference<drawing::XShapes2> xTarget2(static_cast<cppu::OWeakObject*>(xTarget.get()), uno::UNO_QUERY); |
2016 | 0 | assert(xTarget2); |
2017 | 0 | if (xTarget2.is()) |
2018 | 0 | xTarget2->addBottom(xShape); |
2019 | 0 | } |
2020 | 0 | else |
2021 | 0 | xTarget->addShape(*xShape); |
2022 | |
|
2023 | 0 | xShape->setPosition( rPosition ); |
2024 | 0 | xShape->setSize( rSize ); |
2025 | 0 | PropertyMapper::setMultiProperties( rPropNames, rPropValues, *xShape ); |
2026 | |
|
2027 | 0 | return xShape; |
2028 | 0 | } |
2029 | | |
2030 | | rtl::Reference<SvxShapeRect> |
2031 | | ShapeFactory::createRectangle( |
2032 | | const rtl::Reference<SvxShapeGroupAnyD>& xTarget ) |
2033 | 0 | { |
2034 | 0 | rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr); |
2035 | 0 | xShape->setShapeKind(SdrObjKind::Rectangle); |
2036 | 0 | xTarget->addShape( *xShape ); |
2037 | |
|
2038 | 0 | return xShape; |
2039 | 0 | } |
2040 | | |
2041 | | rtl::Reference<SvxShapeText> |
2042 | | ShapeFactory::createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
2043 | | , const OUString& rText |
2044 | | , const tNameSequence& rPropNames |
2045 | | , const tAnySequence& rPropValues |
2046 | | , const uno::Any& rATransformation ) |
2047 | 0 | { |
2048 | 0 | if( !xTarget.is() ) |
2049 | 0 | return nullptr; |
2050 | | |
2051 | 0 | if(rText.isEmpty()) |
2052 | 0 | return nullptr; |
2053 | | |
2054 | | //create shape and add to page |
2055 | 0 | rtl::Reference<SvxShapeText> xShape = new SvxShapeText(nullptr); |
2056 | 0 | xShape->setShapeKind(SdrObjKind::Text); |
2057 | 0 | xTarget->addShape(*xShape); |
2058 | | |
2059 | | //set text |
2060 | 0 | xShape->setString( rText ); |
2061 | | |
2062 | | //set properties |
2063 | 0 | PropertyMapper::setMultiProperties( rPropNames, rPropValues, *xShape ); |
2064 | | |
2065 | | //set position matrix |
2066 | | //the matrix needs to be set at the end behind autogrow and such position influencing properties |
2067 | 0 | try |
2068 | 0 | { |
2069 | 0 | if (rATransformation.hasValue()) |
2070 | 0 | xShape->SvxShape::setPropertyValue( u"Transformation"_ustr, rATransformation ); |
2071 | 0 | else |
2072 | 0 | SAL_INFO("chart2", "No rATransformation value is given to ShapeFactory::createText()"); |
2073 | |
|
2074 | 0 | } |
2075 | 0 | catch( const uno::Exception& ) |
2076 | 0 | { |
2077 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2078 | 0 | } |
2079 | 0 | return xShape; |
2080 | 0 | } |
2081 | | |
2082 | | rtl::Reference<SvxShapeText> |
2083 | | ShapeFactory::createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget |
2084 | | , const uno::Sequence< uno::Reference< chart2::XFormattedString > >& xFormattedString |
2085 | | , const tNameSequence& rPropNames |
2086 | | , const tAnySequence& rPropValues |
2087 | | , const uno::Any& rATransformation ) |
2088 | 0 | { |
2089 | 0 | if( !xTarget.is() ) |
2090 | 0 | return nullptr; |
2091 | | |
2092 | 0 | if( !xFormattedString.hasElements() ) |
2093 | 0 | return nullptr; |
2094 | | |
2095 | 0 | sal_Int32 nNumberOfParagraphs = xFormattedString.getLength(); |
2096 | |
|
2097 | 0 | bool bNotEmpty = false; |
2098 | 0 | for( sal_Int32 nN = 0; nN < nNumberOfParagraphs; ++nN ) |
2099 | 0 | { |
2100 | 0 | if( !xFormattedString[nN]->getString().isEmpty() ) |
2101 | 0 | { |
2102 | 0 | bNotEmpty = true; |
2103 | 0 | break; |
2104 | 0 | } |
2105 | 0 | } |
2106 | 0 | if( !bNotEmpty ) |
2107 | 0 | return nullptr; |
2108 | | |
2109 | | //create shape and add to page |
2110 | 0 | rtl::Reference<SvxShapeText> xShape = new SvxShapeText(nullptr); |
2111 | 0 | xShape->setShapeKind(SdrObjKind::Text); |
2112 | 0 | xTarget->addShape(*xShape); |
2113 | | |
2114 | | //set paragraph properties |
2115 | 0 | bNotEmpty = false; |
2116 | | // the first cursor is used for appending the next paragraph, |
2117 | | // after a new string has been inserted the cursor is moved at the end |
2118 | | // of the inserted string |
2119 | | // the second cursor is used for selecting the paragraph and apply the |
2120 | | // passed text properties |
2121 | 0 | Reference< text::XTextCursor > xInsertCursor = xShape->createTextCursor(); |
2122 | 0 | Reference< text::XTextCursor > xSelectionCursor = xShape->createTextCursor(); |
2123 | 0 | if( xInsertCursor.is() && xSelectionCursor.is() ) |
2124 | 0 | { |
2125 | 0 | uno::Reference< beans::XPropertySet > xSelectionProp( xSelectionCursor, uno::UNO_QUERY ); |
2126 | 0 | if( xSelectionProp.is() ) |
2127 | 0 | { |
2128 | 0 | for( sal_Int32 nN = 0; nN < nNumberOfParagraphs; ++nN ) |
2129 | 0 | { |
2130 | 0 | if( !xFormattedString[nN]->getString().isEmpty() ) |
2131 | 0 | { |
2132 | 0 | xInsertCursor->gotoEnd( false ); |
2133 | 0 | xSelectionCursor->gotoEnd( false ); |
2134 | 0 | xShape->insertString( xInsertCursor, xFormattedString[nN]->getString(), false ); |
2135 | 0 | bNotEmpty = true; |
2136 | 0 | xSelectionCursor->gotoEnd( true ); // select current paragraph |
2137 | 0 | uno::Reference< beans::XPropertySet > xStringProperties( xFormattedString[nN], uno::UNO_QUERY ); |
2138 | 0 | PropertyMapper::setMappedProperties( xSelectionProp, xStringProperties, |
2139 | 0 | PropertyMapper::getPropertyNameMapForTextShapeProperties() ); |
2140 | 0 | } |
2141 | 0 | } |
2142 | 0 | } |
2143 | 0 | } |
2144 | |
|
2145 | 0 | if( !bNotEmpty ) |
2146 | 0 | return nullptr; |
2147 | | |
2148 | | //set whole text shape properties |
2149 | 0 | PropertyMapper::setMultiProperties( rPropNames, rPropValues, *xShape ); |
2150 | |
|
2151 | 0 | if( rATransformation.hasValue() ) |
2152 | 0 | { |
2153 | | //set position matrix |
2154 | | //the matrix needs to be set at the end behind autogrow and such position influencing properties |
2155 | 0 | try |
2156 | 0 | { |
2157 | 0 | xShape->SvxShape::setPropertyValue( u"Transformation"_ustr, rATransformation ); |
2158 | 0 | } |
2159 | 0 | catch( const uno::Exception& ) |
2160 | 0 | { |
2161 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2162 | 0 | } |
2163 | 0 | } |
2164 | 0 | return xShape; |
2165 | 0 | } |
2166 | | |
2167 | | rtl::Reference<SvxShapeText> |
2168 | | ShapeFactory::createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget, |
2169 | | const awt::Size& rSize, |
2170 | | const awt::Point& rPos, |
2171 | | uno::Sequence< uno::Reference< chart2::XFormattedString > >& xFormattedString, |
2172 | | const uno::Reference< |
2173 | | beans::XPropertySet > & xTextProperties, |
2174 | | double nRotation, const OUString& aName, sal_Int32 nTextMaxWidth ) |
2175 | 0 | { |
2176 | | //create shape and add to page |
2177 | 0 | rtl::Reference<SvxShapeText> xShape = new SvxShapeText(nullptr); |
2178 | 0 | xShape->setShapeKind(SdrObjKind::Text); |
2179 | 0 | try |
2180 | 0 | { |
2181 | 0 | xTarget->addShape(*xShape); |
2182 | | |
2183 | | //set text and text properties |
2184 | 0 | uno::Reference< text::XTextCursor > xTextCursor( xShape->createTextCursor() ); |
2185 | 0 | uno::Reference< text::XTextCursor > xSelectionCursor( xShape->createTextCursor() ); |
2186 | 0 | if( !xTextCursor.is() || !xSelectionCursor.is() ) |
2187 | 0 | return xShape; |
2188 | | |
2189 | 0 | tPropertyNameValueMap aValueMap; |
2190 | | //fill line-, fill- and paragraph-properties into the ValueMap |
2191 | 0 | { |
2192 | 0 | tPropertyNameMap aNameMap = PropertyMapper::getPropertyNameMapForParagraphProperties(); |
2193 | 0 | auto const & add = PropertyMapper::getPropertyNameMapForFillAndLineProperties(); |
2194 | 0 | aNameMap.insert(add.begin(), add.end()); |
2195 | |
|
2196 | 0 | PropertyMapper::getValueMap( aValueMap, aNameMap, xTextProperties ); |
2197 | 0 | } |
2198 | | |
2199 | | //fill some more shape properties into the ValueMap |
2200 | 0 | { |
2201 | 0 | aValueMap.insert( { u"TextHorizontalAdjust"_ustr, uno::Any(drawing::TextHorizontalAdjust_CENTER) } ); // drawing::TextHorizontalAdjust |
2202 | 0 | aValueMap.insert( { u"TextVerticalAdjust"_ustr, uno::Any(drawing::TextVerticalAdjust_CENTER) } ); //drawing::TextVerticalAdjust |
2203 | 0 | aValueMap.insert( { u"TextAutoGrowHeight"_ustr, uno::Any(true) } ); // sal_Bool |
2204 | 0 | aValueMap.insert( { u"TextAutoGrowWidth"_ustr, uno::Any(true) } ); // sal_Bool |
2205 | 0 | aValueMap.insert( { u"TextMaximumFrameWidth"_ustr, uno::Any(nTextMaxWidth) } ); // sal_Int32 |
2206 | | |
2207 | | //set name/classified ObjectID (CID) |
2208 | 0 | if( !aName.isEmpty() ) |
2209 | 0 | aValueMap.emplace( u"Name"_ustr, uno::Any( aName ) ); //CID OUString |
2210 | 0 | } |
2211 | | |
2212 | | //set global title properties |
2213 | 0 | { |
2214 | 0 | tNameSequence aPropNames; |
2215 | 0 | tAnySequence aPropValues; |
2216 | 0 | PropertyMapper::getMultiPropertyListsFromValueMap( aPropNames, aPropValues, aValueMap ); |
2217 | 0 | PropertyMapper::setMultiProperties( aPropNames, aPropValues, *xShape ); |
2218 | 0 | } |
2219 | |
|
2220 | 0 | if( xFormattedString.hasElements() ) |
2221 | 0 | { |
2222 | 0 | bool bStackCharacters(false); |
2223 | 0 | try |
2224 | 0 | { |
2225 | 0 | xTextProperties->getPropertyValue( u"StackCharacters"_ustr ) >>= bStackCharacters; |
2226 | 0 | } |
2227 | 0 | catch( const uno::Exception& ) |
2228 | 0 | { |
2229 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2230 | 0 | } |
2231 | | |
2232 | | // Lock during property update to prevent unnecessary layout work. |
2233 | 0 | xShape->addActionLock(); |
2234 | |
|
2235 | 0 | if(bStackCharacters) |
2236 | 0 | { |
2237 | | //if the characters should be stacked we use only the first character properties for code simplicity |
2238 | 0 | size_t nLBreaks = xFormattedString.size() - 1; |
2239 | 0 | for (const uno::Reference<chart2::XFormattedString>& rxFS : xFormattedString) |
2240 | 0 | { |
2241 | 0 | if (!rxFS->getString().isEmpty()) |
2242 | 0 | { |
2243 | 0 | OUString aLabel = ShapeFactory::getStackedString(rxFS->getString(), bStackCharacters); |
2244 | 0 | if (nLBreaks-- > 0) |
2245 | 0 | aLabel += OUStringChar('\r'); |
2246 | 0 | uno::Reference< beans::XPropertySet > xSourceProps(rxFS, uno::UNO_QUERY); |
2247 | 0 | uno::Sequence<beans::PropertyValue> aPropVals = |
2248 | 0 | PropertyMapper::getPropVals(xSourceProps, |
2249 | 0 | PropertyMapper::getPropertyNameMapForTextShapeProperties()); |
2250 | 0 | xShape->appendTextPortion(aLabel, aPropVals); |
2251 | 0 | } |
2252 | 0 | } |
2253 | 0 | } |
2254 | 0 | else |
2255 | 0 | { |
2256 | 0 | for (const uno::Reference<chart2::XFormattedString>& rxFS : xFormattedString) |
2257 | 0 | { |
2258 | 0 | if (!rxFS->getString().isEmpty()) |
2259 | 0 | { |
2260 | 0 | uno::Reference< beans::XPropertySet > xSourceProps(rxFS, uno::UNO_QUERY); |
2261 | 0 | uno::Sequence<beans::PropertyValue> aPropVals = |
2262 | 0 | PropertyMapper::getPropVals(xSourceProps, |
2263 | 0 | PropertyMapper::getPropertyNameMapForTextShapeProperties()); |
2264 | 0 | xShape->appendTextPortion(rxFS->getString(), aPropVals); |
2265 | 0 | } |
2266 | 0 | } |
2267 | 0 | } |
2268 | |
|
2269 | 0 | xShape->removeActionLock(); |
2270 | | |
2271 | | // adapt font size according to page size |
2272 | 0 | awt::Size aOldRefSize; |
2273 | 0 | if( xTextProperties->getPropertyValue(u"ReferencePageSize"_ustr) >>= aOldRefSize ) |
2274 | 0 | { |
2275 | 0 | RelativeSizeHelper::adaptFontSizes( *xShape, aOldRefSize, rSize ); |
2276 | 0 | } |
2277 | 0 | } |
2278 | | |
2279 | | // #i109336# Improve auto positioning in chart |
2280 | 0 | float fFontHeight = 0.0; |
2281 | 0 | if ( xShape->SvxShape::getPropertyValue( u"CharHeight"_ustr ) >>= fFontHeight ) |
2282 | 0 | { |
2283 | 0 | fFontHeight = convertPointToMm100(fFontHeight); |
2284 | 0 | sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.18f ) ); |
2285 | 0 | sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.30f ) ); |
2286 | 0 | uno::Sequence<OUString> aPropNames { |
2287 | 0 | u"TextLeftDistance"_ustr, |
2288 | 0 | u"TextRightDistance"_ustr, |
2289 | 0 | u"TextUpperDistance"_ustr, |
2290 | 0 | u"TextLowerDistance"_ustr, |
2291 | 0 | }; |
2292 | 0 | uno::Sequence<uno::Any> aPropVals { |
2293 | 0 | uno::Any( nXDistance ), |
2294 | 0 | uno::Any( nXDistance ), |
2295 | 0 | uno::Any( nYDistance ), |
2296 | 0 | uno::Any( nYDistance ), |
2297 | 0 | }; |
2298 | 0 | xShape->SvxShape::setPropertyValues( aPropNames, aPropVals ); |
2299 | 0 | } |
2300 | 0 | sal_Int32 nXPos = rPos.X; |
2301 | 0 | sal_Int32 nYPos = rPos.Y; |
2302 | | |
2303 | | //set position matrix |
2304 | | //the matrix needs to be set at the end behind autogrow and such position influencing properties |
2305 | 0 | ::basegfx::B2DHomMatrix aM; |
2306 | 0 | aM.rotate( -basegfx::deg2rad(nRotation) );//#i78696#->#i80521# |
2307 | 0 | aM.translate( nXPos, nYPos ); |
2308 | 0 | uno::Sequence<OUString> aPropNames { |
2309 | 0 | u"Transformation"_ustr, |
2310 | 0 | u"ParaAdjust"_ustr |
2311 | 0 | }; |
2312 | 0 | uno::Sequence<uno::Any> aPropVals { |
2313 | 0 | uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ), |
2314 | 0 | uno::Any( style::ParagraphAdjust_CENTER ) |
2315 | 0 | }; |
2316 | 0 | xShape->SvxShape::setPropertyValues( aPropNames, aPropVals ); |
2317 | 0 | } |
2318 | 0 | catch( const uno::Exception& ) |
2319 | 0 | { |
2320 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2321 | 0 | } |
2322 | 0 | return xShape; |
2323 | 0 | } |
2324 | | |
2325 | | rtl::Reference<SvxShapeGroupAnyD> ShapeFactory::getChartRootShape( |
2326 | | const rtl::Reference<SvxDrawPage>& xDrawPage ) |
2327 | 0 | { |
2328 | 0 | rtl::Reference<SvxShapeGroupAnyD> xRet; |
2329 | 0 | if( xDrawPage.is() ) |
2330 | 0 | { |
2331 | 0 | sal_Int32 nCount = xDrawPage->getCount(); |
2332 | 0 | uno::Reference< drawing::XShape > xShape; |
2333 | 0 | for( sal_Int32 nN = nCount; nN--; ) |
2334 | 0 | { |
2335 | 0 | if( xDrawPage->getByIndex( nN ) >>= xShape ) |
2336 | 0 | { |
2337 | 0 | if( ShapeFactory::getShapeName( xShape ) == "com.sun.star.chart2.shapes" ) |
2338 | 0 | { |
2339 | 0 | xRet = dynamic_cast<SvxShapeGroupAnyD*>(xShape.get()); |
2340 | 0 | assert(xRet); |
2341 | 0 | break; |
2342 | 0 | } |
2343 | 0 | } |
2344 | 0 | } |
2345 | 0 | } |
2346 | 0 | return xRet; |
2347 | 0 | } |
2348 | | |
2349 | | void ShapeFactory::makeShapeInvisible( const rtl::Reference< SvxShape >& xShape ) |
2350 | 0 | { |
2351 | 0 | try |
2352 | 0 | { |
2353 | 0 | xShape->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE )); |
2354 | 0 | xShape->setPropertyValue( u"FillStyle"_ustr, uno::Any( drawing::FillStyle_NONE )); |
2355 | 0 | } |
2356 | 0 | catch( const uno::Exception& ) |
2357 | 0 | { |
2358 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2359 | 0 | } |
2360 | 0 | } |
2361 | | |
2362 | | // set a name/CID at a shape (is used for selection handling) |
2363 | | |
2364 | | void ShapeFactory::setShapeName( const rtl::Reference< SvxShape >& xShape |
2365 | | , const OUString& rName ) |
2366 | 0 | { |
2367 | 0 | if(!xShape.is()) |
2368 | 0 | return; |
2369 | 0 | try |
2370 | 0 | { |
2371 | 0 | xShape->setPropertyValue( UNO_NAME_MISC_OBJ_NAME |
2372 | 0 | , uno::Any( rName ) ); |
2373 | 0 | } |
2374 | 0 | catch( const uno::Exception& ) |
2375 | 0 | { |
2376 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2377 | 0 | } |
2378 | 0 | } |
2379 | | |
2380 | | OUString ShapeFactory::getShapeName( const uno::Reference< drawing::XShape >& xShape ) |
2381 | 0 | { |
2382 | 0 | OUString aRet; |
2383 | |
|
2384 | 0 | uno::Reference< beans::XPropertySet > xProp( xShape, uno::UNO_QUERY ); |
2385 | 0 | OSL_ENSURE(xProp.is(), "shape offers no XPropertySet"); |
2386 | 0 | if( xProp.is()) |
2387 | 0 | { |
2388 | 0 | try |
2389 | 0 | { |
2390 | 0 | xProp->getPropertyValue( UNO_NAME_MISC_OBJ_NAME ) >>= aRet; |
2391 | 0 | } |
2392 | 0 | catch( const uno::Exception& ) |
2393 | 0 | { |
2394 | 0 | TOOLS_WARN_EXCEPTION("chart2", "" ); |
2395 | 0 | } |
2396 | 0 | } |
2397 | | |
2398 | 0 | return aRet; |
2399 | 0 | } |
2400 | | |
2401 | | uno::Any ShapeFactory::makeTransformation( const awt::Point& rScreenPosition2D, double fRotationAnglePi ) |
2402 | 0 | { |
2403 | 0 | ::basegfx::B2DHomMatrix aM; |
2404 | | //As autogrow is active the rectangle is automatically expanded to that side |
2405 | | //to which the text is not adjusted. |
2406 | | // aM.scale( 1, 1 ); Oops? A scale with this parameters is neutral, line commented out |
2407 | 0 | aM.rotate( fRotationAnglePi ); |
2408 | 0 | aM.translate( rScreenPosition2D.X, rScreenPosition2D.Y ); |
2409 | 0 | uno::Any aATransformation( B2DHomMatrixToHomogenMatrix3(aM) ); |
2410 | 0 | return aATransformation; |
2411 | 0 | } |
2412 | | |
2413 | | OUString ShapeFactory::getStackedString( const OUString& rString, bool bStacked ) |
2414 | 0 | { |
2415 | 0 | sal_Int32 nLen = rString.getLength(); |
2416 | 0 | if(!bStacked || !nLen) |
2417 | 0 | return rString; |
2418 | | |
2419 | 0 | OUStringBuffer aStackStr; |
2420 | | |
2421 | | //add a newline after each letter |
2422 | | //as we do not no letters here add a newline after each char |
2423 | 0 | for( sal_Int32 nPosSrc=0; nPosSrc < nLen; nPosSrc++ ) |
2424 | 0 | { |
2425 | 0 | if( nPosSrc ) |
2426 | 0 | aStackStr.append( '\r' ); |
2427 | 0 | aStackStr.append(rString[nPosSrc]); |
2428 | 0 | } |
2429 | 0 | return aStackStr.makeStringAndClear(); |
2430 | 0 | } |
2431 | | |
2432 | | bool ShapeFactory::hasPolygonAnyLines( const std::vector<std::vector<css::drawing::Position3D>>& rPoly) |
2433 | 0 | { |
2434 | | // #i67757# check all contained polygons, if at least one polygon contains 2 or more points, return true |
2435 | 0 | for( auto const & i : rPoly ) |
2436 | 0 | if( i.size() > 1 ) |
2437 | 0 | return true; |
2438 | 0 | return false; |
2439 | 0 | } |
2440 | | |
2441 | | bool ShapeFactory::isPolygonEmptyOrSinglePoint( const drawing::PolyPolygonShape3D& rPoly) |
2442 | 0 | { |
2443 | | // true, if empty polypolygon or one polygon with one point |
2444 | 0 | return !rPoly.SequenceX.hasElements() || |
2445 | 0 | ((rPoly.SequenceX.getLength() == 1) && (rPoly.SequenceX[0].getLength() <= 1)); |
2446 | 0 | } |
2447 | | |
2448 | | bool ShapeFactory::isPolygonEmptyOrSinglePoint( const std::vector<std::vector<css::drawing::Position3D>>& rPoly) |
2449 | 0 | { |
2450 | | // true, if empty polypolygon or one polygon with one point |
2451 | 0 | return rPoly.empty() || ((rPoly.size() == 1) && (rPoly[0].size() <= 1)); |
2452 | 0 | } |
2453 | | |
2454 | | void ShapeFactory::closePolygon( drawing::PolyPolygonShape3D& rPoly) |
2455 | 0 | { |
2456 | 0 | OSL_ENSURE( rPoly.SequenceX.getLength() <= 1, "ShapeFactory::closePolygon - single polygon expected" ); |
2457 | | //add a last point == first point |
2458 | 0 | if(isPolygonEmptyOrSinglePoint(rPoly)) |
2459 | 0 | return; |
2460 | 0 | drawing::Position3D aFirst(rPoly.SequenceX[0][0],rPoly.SequenceY[0][0],rPoly.SequenceZ[0][0]); |
2461 | 0 | AddPointToPoly( rPoly, aFirst ); |
2462 | 0 | } |
2463 | | |
2464 | | void ShapeFactory::closePolygon( std::vector<std::vector<css::drawing::Position3D>>& rPoly) |
2465 | 0 | { |
2466 | 0 | OSL_ENSURE( rPoly.size() <= 1, "ShapeFactory::closePolygon - single polygon expected" ); |
2467 | | //add a last point == first point |
2468 | 0 | if(isPolygonEmptyOrSinglePoint(rPoly)) |
2469 | 0 | return; |
2470 | 0 | drawing::Position3D aFirst(rPoly[0][0]); |
2471 | 0 | AddPointToPoly( rPoly, aFirst ); |
2472 | 0 | } |
2473 | | |
2474 | | awt::Size ShapeFactory::calculateNewSizeRespectingAspectRatio( |
2475 | | const awt::Size& rTargetSize |
2476 | | , const awt::Size& rSourceSizeWithCorrectAspectRatio ) |
2477 | 0 | { |
2478 | 0 | awt::Size aNewSize; |
2479 | |
|
2480 | 0 | double fFactorWidth = double(rTargetSize.Width)/double(rSourceSizeWithCorrectAspectRatio.Width); |
2481 | 0 | double fFactorHeight = double(rTargetSize.Height)/double(rSourceSizeWithCorrectAspectRatio.Height); |
2482 | 0 | double fFactor = std::min(fFactorWidth,fFactorHeight); |
2483 | 0 | aNewSize.Width=static_cast<sal_Int32>(fFactor*rSourceSizeWithCorrectAspectRatio.Width); |
2484 | 0 | aNewSize.Height=static_cast<sal_Int32>(fFactor*rSourceSizeWithCorrectAspectRatio.Height); |
2485 | |
|
2486 | 0 | return aNewSize; |
2487 | 0 | } |
2488 | | |
2489 | | awt::Point ShapeFactory::calculateTopLeftPositionToCenterObject( |
2490 | | const awt::Point& rTargetAreaPosition |
2491 | | , const awt::Size& rTargetAreaSize |
2492 | | , const awt::Size& rObjectSize ) |
2493 | 0 | { |
2494 | 0 | awt::Point aNewPosition(rTargetAreaPosition); |
2495 | 0 | aNewPosition.X += static_cast<sal_Int32>(double(rTargetAreaSize.Width-rObjectSize.Width)/2.0); |
2496 | 0 | aNewPosition.Y += static_cast<sal_Int32>(double(rTargetAreaSize.Height-rObjectSize.Height)/2.0); |
2497 | 0 | return aNewPosition; |
2498 | 0 | } |
2499 | | |
2500 | | ::basegfx::B2IRectangle ShapeFactory::getRectangleOfShape( SvxShape& rShape ) |
2501 | 0 | { |
2502 | 0 | ::basegfx::B2IRectangle aRet; |
2503 | |
|
2504 | 0 | awt::Point aPos = rShape.getPosition(); |
2505 | 0 | awt::Size aSize = rShape.getSize(); |
2506 | 0 | aRet = BaseGFXHelper::makeRectangle(aPos,aSize); |
2507 | |
|
2508 | 0 | return aRet; |
2509 | 0 | } |
2510 | | |
2511 | | awt::Size ShapeFactory::getSizeAfterRotation( |
2512 | | SvxShape& rShape, double fRotationAngleDegree ) |
2513 | 0 | { |
2514 | 0 | awt::Size aRet(0,0); |
2515 | 0 | const awt::Size aSize( rShape.getSize() ); |
2516 | |
|
2517 | 0 | if( fRotationAngleDegree == 0.0 ) |
2518 | 0 | aRet = aSize; |
2519 | 0 | else |
2520 | 0 | { |
2521 | 0 | fRotationAngleDegree = NormAngle360(fRotationAngleDegree); |
2522 | 0 | if(fRotationAngleDegree>270.0) |
2523 | 0 | fRotationAngleDegree=360.0-fRotationAngleDegree; |
2524 | 0 | else if(fRotationAngleDegree>180.0) |
2525 | 0 | fRotationAngleDegree=fRotationAngleDegree-180.0; |
2526 | 0 | else if(fRotationAngleDegree>90.0) |
2527 | 0 | fRotationAngleDegree=180.0-fRotationAngleDegree; |
2528 | |
|
2529 | 0 | const double fAnglePi = basegfx::deg2rad(fRotationAngleDegree); |
2530 | |
|
2531 | 0 | aRet.Height = static_cast<sal_Int32>( |
2532 | 0 | aSize.Width*std::sin( fAnglePi ) |
2533 | 0 | + aSize.Height*std::cos( fAnglePi )); |
2534 | 0 | aRet.Width = static_cast<sal_Int32>( |
2535 | 0 | aSize.Width*std::cos( fAnglePi ) |
2536 | 0 | + aSize.Height*std::sin( fAnglePi )); |
2537 | 0 | } |
2538 | 0 | return aRet; |
2539 | 0 | } |
2540 | | |
2541 | | void ShapeFactory::removeSubShapes( const rtl::Reference<SvxShapeGroupAnyD>& xShapes ) |
2542 | 0 | { |
2543 | 0 | if( xShapes.is() ) |
2544 | 0 | { |
2545 | 0 | sal_Int32 nSubCount = xShapes->getCount(); |
2546 | 0 | uno::Reference< drawing::XShape > xShape; |
2547 | 0 | for( sal_Int32 nS = nSubCount; nS--; ) |
2548 | 0 | { |
2549 | 0 | if( xShapes->getByIndex( nS ) >>= xShape ) |
2550 | 0 | xShapes->remove( xShape ); |
2551 | 0 | } |
2552 | 0 | } |
2553 | 0 | } |
2554 | | |
2555 | | rtl::Reference<SvxTableShape> |
2556 | | ShapeFactory::createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget, OUString const& rName) |
2557 | 0 | { |
2558 | 0 | if (!xTarget.is()) |
2559 | 0 | return nullptr; |
2560 | | |
2561 | | //create table shape |
2562 | 0 | rtl::Reference<SvxTableShape> xShape = new SvxTableShape(nullptr); |
2563 | 0 | xShape->setShapeKind(SdrObjKind::Table); |
2564 | 0 | xTarget->addShape(*xShape); |
2565 | 0 | if (!rName.isEmpty()) |
2566 | 0 | setShapeName(xShape, rName); |
2567 | 0 | return xShape; |
2568 | 0 | } |
2569 | | |
2570 | | } //namespace chart |
2571 | | |
2572 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |