/src/libreoffice/svx/source/unodraw/unoshap3.cxx
Line | Count | Source (jump to first uncovered line) |
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 <sal/config.h> |
21 | | |
22 | | #include <initializer_list> |
23 | | #include <string_view> |
24 | | |
25 | | #include <com/sun/star/drawing/HomogenMatrix.hpp> |
26 | | #include <com/sun/star/drawing/Position3D.hpp> |
27 | | #include <com/sun/star/drawing/Direction3D.hpp> |
28 | | #include <com/sun/star/drawing/DoubleSequence.hpp> |
29 | | #include <com/sun/star/drawing/CameraGeometry.hpp> |
30 | | #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> |
31 | | #include <o3tl/safeint.hxx> |
32 | | #include <vcl/svapp.hxx> |
33 | | #include <comphelper/sequence.hxx> |
34 | | #include <sal/log.hxx> |
35 | | |
36 | | #include <svx/svdpool.hxx> |
37 | | #include <svx/svditer.hxx> |
38 | | #include <svx/unoshape.hxx> |
39 | | #include <svx/unopage.hxx> |
40 | | #include <svx/cube3d.hxx> |
41 | | #include <svx/sphere3d.hxx> |
42 | | #include <svx/lathe3d.hxx> |
43 | | #include <extrud3d.hxx> |
44 | | #include <polygn3d.hxx> |
45 | | #include <svx/unoshprp.hxx> |
46 | | #include <svx/svdmodel.hxx> |
47 | | #include <svx/scene3d.hxx> |
48 | | #include <basegfx/polygon/b3dpolygon.hxx> |
49 | | #include <basegfx/polygon/b3dpolygontools.hxx> |
50 | | #include <com/sun/star/drawing/PolyPolygonShape3D.hpp> |
51 | | #include <basegfx/polygon/b2dpolypolygontools.hxx> |
52 | | #include <basegfx/matrix/b3dhommatrixtools.hxx> |
53 | | #include "shapeimpl.hxx" |
54 | | |
55 | | using namespace ::cppu; |
56 | | using namespace ::com::sun::star; |
57 | | using namespace ::com::sun::star::uno; |
58 | | using namespace ::com::sun::star::lang; |
59 | | using namespace ::com::sun::star::container; |
60 | | |
61 | | #define QUERYINT( xint ) \ |
62 | 78.5k | if( rType == cppu::UnoType<xint>::get() ) \ |
63 | 78.5k | aAny <<= Reference< xint >(this) |
64 | | |
65 | | Svx3DSceneObject::Svx3DSceneObject(SdrObject* pObj, SvxDrawPage* pDrawPage) |
66 | 3.19k | : SvxShapeGroupAnyD( pObj, getSvxMapProvider().GetMap(SVXMAP_3DSCENEOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_3DSCENEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) |
67 | 3.19k | , mxPage( pDrawPage ) |
68 | 3.19k | { |
69 | 3.19k | } |
70 | | |
71 | | |
72 | | Svx3DSceneObject::~Svx3DSceneObject() noexcept |
73 | 3.19k | { |
74 | 3.19k | } |
75 | | |
76 | | |
77 | | void Svx3DSceneObject::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) |
78 | 0 | { |
79 | 0 | SvxShape::Create( pNewObj, pNewPage ); |
80 | 0 | mxPage = pNewPage; |
81 | 0 | } |
82 | | |
83 | | |
84 | | uno::Any SAL_CALL Svx3DSceneObject::queryAggregation( const uno::Type & rType ) |
85 | 26.1k | { |
86 | 26.1k | uno::Any aAny; |
87 | | |
88 | 26.1k | QUERYINT( drawing::XShapes ); |
89 | 26.1k | else QUERYINT( container::XIndexAccess ); |
90 | 26.1k | else QUERYINT( container::XElementAccess ); |
91 | 26.1k | else |
92 | 26.1k | return SvxShape::queryAggregation( rType ); |
93 | | |
94 | 0 | return aAny; |
95 | 26.1k | } |
96 | | |
97 | | uno::Any SAL_CALL Svx3DSceneObject::queryInterface( const uno::Type & rType ) |
98 | 26.1k | { |
99 | 26.1k | return SvxShape::queryInterface( rType ); |
100 | 26.1k | } |
101 | | |
102 | | // XTypeProvider |
103 | | |
104 | | uno::Sequence< sal_Int8 > SAL_CALL Svx3DSceneObject::getImplementationId() |
105 | 0 | { |
106 | 0 | return css::uno::Sequence<sal_Int8>(); |
107 | 0 | } |
108 | | |
109 | | |
110 | | void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape ) |
111 | 0 | { |
112 | 0 | SolarMutexGuard aGuard; |
113 | |
|
114 | 0 | SvxShape* pShape = comphelper::getFromUnoTunnel<SvxShape>( xShape ); |
115 | |
|
116 | 0 | if(!HasSdrObject() || !mxPage.is() || pShape == nullptr || nullptr != pShape->GetSdrObject() ) |
117 | 0 | throw uno::RuntimeException(); |
118 | | |
119 | 0 | rtl::Reference<SdrObject> pSdrShape = mxPage->CreateSdrObject_( xShape ); |
120 | 0 | if( DynCastE3dObject(pSdrShape.get()) ) |
121 | 0 | { |
122 | 0 | GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape.get() ); |
123 | 0 | pShape->Create(pSdrShape.get(), mxPage.get()); |
124 | 0 | } |
125 | 0 | else |
126 | 0 | { |
127 | 0 | pSdrShape.clear(); |
128 | 0 | throw uno::RuntimeException(); |
129 | 0 | } |
130 | | |
131 | 0 | GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); |
132 | 0 | } |
133 | | |
134 | | void Svx3DSceneObject::addShape( SvxShape& rShape ) |
135 | 0 | { |
136 | 0 | SolarMutexGuard aGuard; |
137 | |
|
138 | 0 | if(!HasSdrObject() || !mxPage.is() || nullptr != rShape.GetSdrObject() ) |
139 | 0 | throw uno::RuntimeException(); |
140 | | |
141 | 0 | rtl::Reference<SdrObject> pSdrShape = mxPage->CreateSdrObject_( &rShape ); |
142 | 0 | if( DynCastE3dObject(pSdrShape.get()) ) |
143 | 0 | { |
144 | 0 | GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape.get() ); |
145 | 0 | rShape.Create(pSdrShape.get(), mxPage.get()); |
146 | 0 | } |
147 | 0 | else |
148 | 0 | { |
149 | 0 | pSdrShape.clear(); |
150 | 0 | throw uno::RuntimeException(); |
151 | 0 | } |
152 | | |
153 | 0 | GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); |
154 | 0 | } |
155 | | |
156 | | void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xShape ) |
157 | 0 | { |
158 | 0 | SolarMutexGuard aGuard; |
159 | |
|
160 | 0 | SdrObject* pSdrShape = SdrObject::getSdrObjectFromXShape( xShape ); |
161 | |
|
162 | 0 | if(!HasSdrObject() || !pSdrShape || |
163 | 0 | pSdrShape->getParentSdrObjectFromSdrObject() != GetSdrObject()) |
164 | 0 | throw uno::RuntimeException(); |
165 | | |
166 | 0 | SdrObjList& rList = *pSdrShape->getParentSdrObjListFromSdrObject(); |
167 | |
|
168 | 0 | const size_t nObjCount = rList.GetObjCount(); |
169 | 0 | size_t nObjNum = 0; |
170 | 0 | while( nObjNum < nObjCount ) |
171 | 0 | { |
172 | 0 | if(rList.GetObj( nObjNum ) == pSdrShape ) |
173 | 0 | break; |
174 | 0 | nObjNum++; |
175 | 0 | } |
176 | |
|
177 | 0 | if( nObjNum < nObjCount ) |
178 | 0 | { |
179 | 0 | rList.NbcRemoveObject( nObjNum ); |
180 | 0 | } |
181 | 0 | else |
182 | 0 | { |
183 | 0 | SAL_WARN( "svx", "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" ); |
184 | 0 | } |
185 | 0 | } |
186 | | |
187 | | |
188 | | sal_Int32 SAL_CALL Svx3DSceneObject::getCount() |
189 | 0 | { |
190 | 0 | SolarMutexGuard aGuard; |
191 | |
|
192 | 0 | sal_Int32 nRetval = 0; |
193 | |
|
194 | 0 | if(HasSdrObject() && DynCastE3dScene(GetSdrObject()) && GetSdrObject()->GetSubList()) |
195 | 0 | nRetval = GetSdrObject()->GetSubList()->GetObjCount(); |
196 | 0 | return nRetval; |
197 | 0 | } |
198 | | |
199 | | |
200 | | uno::Any SAL_CALL Svx3DSceneObject::getByIndex( sal_Int32 Index ) |
201 | 0 | { |
202 | 0 | SolarMutexGuard aGuard; |
203 | |
|
204 | 0 | if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr ) |
205 | 0 | throw uno::RuntimeException(); |
206 | | |
207 | 0 | if( Index<0 || GetSdrObject()->GetSubList()->GetObjCount() <= o3tl::make_unsigned(Index) ) |
208 | 0 | throw lang::IndexOutOfBoundsException(); |
209 | | |
210 | 0 | SdrObject* pDestObj = GetSdrObject()->GetSubList()->GetObj( Index ); |
211 | 0 | if(pDestObj == nullptr) |
212 | 0 | throw lang::IndexOutOfBoundsException(); |
213 | | |
214 | 0 | Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY ); |
215 | 0 | return uno::Any(xShape); |
216 | 0 | } |
217 | | |
218 | | |
219 | | // css::container::XElementAccess |
220 | | |
221 | | uno::Type SAL_CALL Svx3DSceneObject::getElementType() |
222 | 0 | { |
223 | 0 | return cppu::UnoType<drawing::XShape>::get(); |
224 | 0 | } |
225 | | |
226 | | |
227 | | sal_Bool SAL_CALL Svx3DSceneObject::hasElements() |
228 | 0 | { |
229 | 0 | SolarMutexGuard aGuard; |
230 | |
|
231 | 0 | return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0); |
232 | 0 | } |
233 | | |
234 | | |
235 | | static bool ConvertHomogenMatrixToObject( E3dObject* pObject, const Any& rValue ) |
236 | 0 | { |
237 | 0 | drawing::HomogenMatrix aMat; |
238 | 0 | if( rValue >>= aMat ) |
239 | 0 | { |
240 | 0 | pObject->SetTransform(basegfx::utils::UnoHomogenMatrixToB3DHomMatrix(aMat)); |
241 | 0 | return true; |
242 | 0 | } |
243 | 0 | return false; |
244 | 0 | } |
245 | | |
246 | | static void ConvertObjectToHomogenMatric( E3dObject const * pObject, Any& rValue ) |
247 | 0 | { |
248 | 0 | drawing::HomogenMatrix aHomMat; |
249 | 0 | const basegfx::B3DHomMatrix& rMat = pObject->GetTransform(); |
250 | 0 | basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(rMat, aHomMat); |
251 | 0 | rValue <<= aHomMat; |
252 | 0 | } |
253 | | |
254 | | namespace { |
255 | | |
256 | | struct ImpRememberTransAndRect |
257 | | { |
258 | | basegfx::B3DHomMatrix maMat; |
259 | | tools::Rectangle maRect; |
260 | | }; |
261 | | |
262 | | } |
263 | | |
264 | | bool Svx3DSceneObject::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) |
265 | 0 | { |
266 | 0 | switch( pProperty->nWID ) |
267 | 0 | { |
268 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
269 | 0 | { |
270 | | // patch transformation matrix to the object |
271 | 0 | if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) ) |
272 | 0 | return true; |
273 | 0 | break; |
274 | 0 | } |
275 | 0 | case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY: |
276 | 0 | { |
277 | | // set CameraGeometry at scene |
278 | 0 | E3dScene* pScene = static_cast< E3dScene* >( GetSdrObject() ); |
279 | 0 | drawing::CameraGeometry aCamGeo; |
280 | |
|
281 | 0 | if(rValue >>= aCamGeo) |
282 | 0 | { |
283 | 0 | basegfx::B3DPoint aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ); |
284 | 0 | basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ); |
285 | 0 | basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ); |
286 | | |
287 | | // rescue scene transformation |
288 | 0 | ImpRememberTransAndRect aSceneTAR; |
289 | 0 | aSceneTAR.maMat = pScene->GetTransform(); |
290 | 0 | aSceneTAR.maRect = pScene->GetSnapRect(); |
291 | | |
292 | | // rescue object transformations |
293 | 0 | SdrObjListIter aIter(pScene->GetSubList(), SdrIterMode::DeepWithGroups); |
294 | 0 | std::vector<basegfx::B3DHomMatrix*> aObjTrans; |
295 | 0 | while(aIter.IsMore()) |
296 | 0 | { |
297 | 0 | E3dObject* p3DObj = static_cast<E3dObject*>(aIter.Next()); |
298 | 0 | basegfx::B3DHomMatrix* pNew = new basegfx::B3DHomMatrix; |
299 | 0 | *pNew = p3DObj->GetTransform(); |
300 | 0 | aObjTrans.push_back(pNew); |
301 | 0 | } |
302 | | |
303 | | // reset object transformations |
304 | 0 | aIter.Reset(); |
305 | 0 | while(aIter.IsMore()) |
306 | 0 | { |
307 | 0 | E3dObject* p3DObj = static_cast<E3dObject*>(aIter.Next()); |
308 | 0 | p3DObj->NbcSetTransform(basegfx::B3DHomMatrix()); |
309 | 0 | } |
310 | | |
311 | | // reset scene transformation and make a complete recalc |
312 | 0 | pScene->NbcSetTransform(basegfx::B3DHomMatrix()); |
313 | | |
314 | | // fill old camera from new parameters |
315 | 0 | Camera3D aCam(pScene->GetCamera()); |
316 | 0 | const basegfx::B3DRange& rVolume = pScene->GetBoundVolume(); |
317 | 0 | double fW = rVolume.getWidth(); |
318 | 0 | double fH = rVolume.getHeight(); |
319 | |
|
320 | 0 | const SfxItemSet& rSceneSet = pScene->GetMergedItemSet(); |
321 | 0 | double fCamPosZ = |
322 | 0 | static_cast<double>(rSceneSet.Get(SDRATTR_3DSCENE_DISTANCE).GetValue()); |
323 | 0 | double fCamFocal = |
324 | 0 | static_cast<double>(rSceneSet.Get(SDRATTR_3DSCENE_FOCAL_LENGTH).GetValue()); |
325 | |
|
326 | 0 | aCam.SetAutoAdjustProjection(false); |
327 | 0 | aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH); |
328 | 0 | basegfx::B3DPoint aLookAt; |
329 | 0 | basegfx::B3DPoint aCamPos(0.0, 0.0, fCamPosZ); |
330 | 0 | aCam.SetPosAndLookAt(aCamPos, aLookAt); |
331 | 0 | aCam.SetFocalLength(fCamFocal / 100.0); |
332 | 0 | aCam.SetDeviceWindow(tools::Rectangle(0, 0, static_cast<tools::Long>(fW), static_cast<tools::Long>(fH))); |
333 | | |
334 | | // set at scene |
335 | 0 | pScene->SetCamera(aCam); |
336 | | |
337 | | // #91047# use imported VRP, VPN and VUP (if used) |
338 | 0 | bool bVRPUsed(!aVRP.equal(basegfx::B3DPoint(0.0, 0.0, 1.0))); |
339 | 0 | bool bVPNUsed(!aVPN.equal(basegfx::B3DVector(0.0, 0.0, 1.0))); |
340 | 0 | bool bVUPUsed(!aVUP.equal(basegfx::B3DVector(0.0, 1.0, 0.0))); |
341 | |
|
342 | 0 | if(bVRPUsed || bVPNUsed || bVUPUsed) |
343 | 0 | { |
344 | 0 | pScene->GetCameraSet().SetViewportValues(aVRP, aVPN, aVUP); |
345 | 0 | } |
346 | | |
347 | | // set object transformations again at objects |
348 | 0 | aIter.Reset(); |
349 | 0 | sal_uInt32 nIndex(0); |
350 | 0 | while(aIter.IsMore()) |
351 | 0 | { |
352 | 0 | E3dObject* p3DObj = static_cast<E3dObject*>(aIter.Next()); |
353 | 0 | basegfx::B3DHomMatrix* pMat = aObjTrans[nIndex++]; |
354 | 0 | p3DObj->NbcSetTransform(*pMat); |
355 | 0 | delete pMat; |
356 | 0 | } |
357 | | |
358 | | // set scene transformation again at scene |
359 | 0 | pScene->NbcSetTransform(aSceneTAR.maMat); |
360 | 0 | pScene->NbcSetSnapRect(aSceneTAR.maRect); |
361 | |
|
362 | 0 | return true; |
363 | 0 | } |
364 | 0 | break; |
365 | 0 | } |
366 | 0 | default: |
367 | 0 | return SvxShape::setPropertyValueImpl(rName, pProperty, rValue); |
368 | 0 | } |
369 | | |
370 | 0 | throw IllegalArgumentException(); |
371 | 0 | } |
372 | | |
373 | | |
374 | | bool Svx3DSceneObject::getPropertyValueImpl(const OUString& rName, const SfxItemPropertyMapEntry* pProperty, |
375 | | css::uno::Any& rValue) |
376 | 0 | { |
377 | 0 | switch( pProperty->nWID ) |
378 | 0 | { |
379 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
380 | 0 | { |
381 | | // patch object to a homogeneous 4x4 matrix |
382 | 0 | ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue ); |
383 | 0 | break; |
384 | 0 | } |
385 | 0 | case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY: |
386 | 0 | { |
387 | | // get CameraGeometry from scene |
388 | 0 | E3dScene* pScene = static_cast< E3dScene* >( GetSdrObject() ); |
389 | 0 | drawing::CameraGeometry aCamGeo; |
390 | | |
391 | | // fill Vectors from scene camera |
392 | 0 | B3dCamera& aCameraSet = pScene->GetCameraSet(); |
393 | 0 | basegfx::B3DPoint aVRP(aCameraSet.GetVRP()); |
394 | 0 | basegfx::B3DVector aVPN(aCameraSet.GetVPN()); |
395 | 0 | basegfx::B3DVector aVUP(aCameraSet.GetVUV()); |
396 | | |
397 | | // transfer to structure |
398 | 0 | aCamGeo.vrp.PositionX = aVRP.getX(); |
399 | 0 | aCamGeo.vrp.PositionY = aVRP.getY(); |
400 | 0 | aCamGeo.vrp.PositionZ = aVRP.getZ(); |
401 | 0 | aCamGeo.vpn.DirectionX = aVPN.getX(); |
402 | 0 | aCamGeo.vpn.DirectionY = aVPN.getY(); |
403 | 0 | aCamGeo.vpn.DirectionZ = aVPN.getZ(); |
404 | 0 | aCamGeo.vup.DirectionX = aVUP.getX(); |
405 | 0 | aCamGeo.vup.DirectionY = aVUP.getY(); |
406 | 0 | aCamGeo.vup.DirectionZ = aVUP.getZ(); |
407 | |
|
408 | 0 | rValue <<= aCamGeo; |
409 | 0 | break; |
410 | 0 | } |
411 | 0 | default: |
412 | 0 | return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); |
413 | 0 | } |
414 | | |
415 | 0 | return true; |
416 | 0 | } |
417 | | |
418 | | // css::lang::XServiceInfo |
419 | | uno::Sequence< OUString > SAL_CALL Svx3DSceneObject::getSupportedServiceNames() |
420 | 0 | { |
421 | 0 | return comphelper::concatSequences( |
422 | 0 | SvxShape::getSupportedServiceNames(), |
423 | 0 | std::initializer_list<OUString>{ u"com.sun.star.drawing.Shape3DScene"_ustr }); |
424 | 0 | } |
425 | | |
426 | | Svx3DCubeObject::Svx3DCubeObject(SdrObject* pObj) |
427 | 0 | : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_3DCUBEOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_3DCUBEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) |
428 | 0 | { |
429 | 0 | } |
430 | | |
431 | | Svx3DCubeObject::~Svx3DCubeObject() noexcept |
432 | 0 | { |
433 | 0 | } |
434 | | |
435 | | bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) |
436 | 0 | { |
437 | 0 | SolarMutexGuard aGuard; |
438 | |
|
439 | 0 | switch( pProperty->nWID ) |
440 | 0 | { |
441 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
442 | 0 | { |
443 | | // pack transformationmatrix to the object |
444 | 0 | if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) ) |
445 | 0 | return true; |
446 | 0 | break; |
447 | 0 | } |
448 | 0 | case OWN_ATTR_3D_VALUE_POSITION: |
449 | 0 | { |
450 | | // pack position to the object |
451 | 0 | drawing::Position3D aUnoPos; |
452 | 0 | if( rValue >>= aUnoPos ) |
453 | 0 | { |
454 | 0 | basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ); |
455 | 0 | static_cast< E3dCubeObj* >( GetSdrObject() )->SetCubePos(aPos); |
456 | 0 | return true; |
457 | 0 | } |
458 | 0 | break; |
459 | 0 | } |
460 | 0 | case OWN_ATTR_3D_VALUE_SIZE: |
461 | 0 | { |
462 | | // pack size to the object |
463 | 0 | drawing::Direction3D aDirection; |
464 | 0 | if( rValue >>= aDirection ) |
465 | 0 | { |
466 | 0 | basegfx::B3DVector aSize(aDirection.DirectionX, aDirection.DirectionY, aDirection.DirectionZ); |
467 | 0 | static_cast< E3dCubeObj* >( GetSdrObject() )->SetCubeSize(aSize); |
468 | 0 | return true; |
469 | 0 | } |
470 | 0 | break; |
471 | 0 | } |
472 | 0 | case OWN_ATTR_3D_VALUE_POS_IS_CENTER: |
473 | 0 | { |
474 | 0 | bool bNew = false; |
475 | | // pack sal_Bool bPosIsCenter to the object |
476 | 0 | if( rValue >>= bNew ) |
477 | 0 | { |
478 | 0 | static_cast< E3dCubeObj* >( GetSdrObject() )->SetPosIsCenter(bNew); |
479 | 0 | return true; |
480 | 0 | } |
481 | 0 | break; |
482 | 0 | } |
483 | 0 | default: |
484 | 0 | return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); |
485 | 0 | } |
486 | | |
487 | 0 | throw IllegalArgumentException(); |
488 | 0 | } |
489 | | |
490 | | bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) |
491 | 0 | { |
492 | 0 | switch( pProperty->nWID ) |
493 | 0 | { |
494 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
495 | 0 | { |
496 | | // pack transformation to a homogeneous matrix |
497 | 0 | ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue ); |
498 | 0 | break; |
499 | 0 | } |
500 | 0 | case OWN_ATTR_3D_VALUE_POSITION: |
501 | 0 | { |
502 | | // pack position |
503 | 0 | const basegfx::B3DPoint& rPos = static_cast<E3dCubeObj*>(GetSdrObject())->GetCubePos(); |
504 | 0 | drawing::Position3D aPos; |
505 | |
|
506 | 0 | aPos.PositionX = rPos.getX(); |
507 | 0 | aPos.PositionY = rPos.getY(); |
508 | 0 | aPos.PositionZ = rPos.getZ(); |
509 | |
|
510 | 0 | rValue <<= aPos; |
511 | 0 | break; |
512 | 0 | } |
513 | 0 | case OWN_ATTR_3D_VALUE_SIZE: |
514 | 0 | { |
515 | | // pack size |
516 | 0 | const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(GetSdrObject())->GetCubeSize(); |
517 | 0 | drawing::Direction3D aDir; |
518 | |
|
519 | 0 | aDir.DirectionX = rSize.getX(); |
520 | 0 | aDir.DirectionY = rSize.getY(); |
521 | 0 | aDir.DirectionZ = rSize.getZ(); |
522 | |
|
523 | 0 | rValue <<= aDir; |
524 | 0 | break; |
525 | 0 | } |
526 | 0 | case OWN_ATTR_3D_VALUE_POS_IS_CENTER: |
527 | 0 | { |
528 | 0 | rValue <<= static_cast<E3dCubeObj*>(GetSdrObject())->GetPosIsCenter(); |
529 | 0 | break; |
530 | 0 | } |
531 | 0 | default: |
532 | 0 | return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); |
533 | 0 | } |
534 | | |
535 | 0 | return true; |
536 | 0 | } |
537 | | |
538 | | // css::lang::XServiceInfo |
539 | | uno::Sequence< OUString > SAL_CALL Svx3DCubeObject::getSupportedServiceNames() |
540 | 0 | { |
541 | 0 | return comphelper::concatSequences( |
542 | 0 | SvxShape::getSupportedServiceNames(), |
543 | 0 | std::initializer_list<OUString>{ u"com.sun.star.drawing.Shape3D"_ustr, |
544 | 0 | u"com.sun.star.drawing.Shape3DCube"_ustr }); |
545 | 0 | } |
546 | | |
547 | | Svx3DSphereObject::Svx3DSphereObject(SdrObject* pObj) |
548 | 0 | : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_3DSPHEREOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_3DSPHEREOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) |
549 | 0 | { |
550 | 0 | } |
551 | | |
552 | | Svx3DSphereObject::~Svx3DSphereObject() noexcept |
553 | 0 | { |
554 | 0 | } |
555 | | |
556 | | bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) |
557 | 0 | { |
558 | 0 | switch( pProperty->nWID ) |
559 | 0 | { |
560 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
561 | 0 | { |
562 | | // pack transformation matrix to the object |
563 | 0 | if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) ) |
564 | 0 | return true; |
565 | 0 | break; |
566 | 0 | } |
567 | | |
568 | 0 | case OWN_ATTR_3D_VALUE_POSITION: |
569 | 0 | { |
570 | | // pack position to the object |
571 | 0 | drawing::Position3D aUnoPos; |
572 | 0 | if( rValue >>= aUnoPos ) |
573 | 0 | { |
574 | 0 | basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ); |
575 | 0 | static_cast<E3dSphereObj*>(GetSdrObject())->SetCenter(aPos); |
576 | 0 | return true; |
577 | 0 | } |
578 | 0 | break; |
579 | 0 | } |
580 | | |
581 | 0 | case OWN_ATTR_3D_VALUE_SIZE: |
582 | 0 | { |
583 | | // pack size to the object |
584 | 0 | drawing::Direction3D aDir; |
585 | 0 | if( rValue >>= aDir ) |
586 | 0 | { |
587 | 0 | basegfx::B3DVector aPos(aDir.DirectionX, aDir.DirectionY, aDir.DirectionZ); |
588 | 0 | static_cast<E3dSphereObj*>(GetSdrObject())->SetSize(aPos); |
589 | 0 | return true; |
590 | 0 | } |
591 | 0 | break; |
592 | 0 | } |
593 | 0 | default: |
594 | 0 | return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); |
595 | 0 | } |
596 | | |
597 | 0 | throw IllegalArgumentException(); |
598 | 0 | } |
599 | | |
600 | | bool Svx3DSphereObject::getPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) |
601 | 0 | { |
602 | 0 | switch( pProperty->nWID ) |
603 | 0 | { |
604 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
605 | 0 | { |
606 | | // pack transformation to a homogeneous matrix |
607 | 0 | ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue ); |
608 | 0 | break; |
609 | 0 | } |
610 | 0 | case OWN_ATTR_3D_VALUE_POSITION: |
611 | 0 | { |
612 | | // pack position |
613 | 0 | const basegfx::B3DPoint& rPos = static_cast<E3dSphereObj*>(GetSdrObject())->Center(); |
614 | 0 | drawing::Position3D aPos; |
615 | |
|
616 | 0 | aPos.PositionX = rPos.getX(); |
617 | 0 | aPos.PositionY = rPos.getY(); |
618 | 0 | aPos.PositionZ = rPos.getZ(); |
619 | |
|
620 | 0 | rValue <<= aPos; |
621 | 0 | break; |
622 | 0 | } |
623 | 0 | case OWN_ATTR_3D_VALUE_SIZE: |
624 | 0 | { |
625 | | // pack size |
626 | 0 | const basegfx::B3DVector& rSize = static_cast<E3dSphereObj*>(GetSdrObject())->Size(); |
627 | 0 | drawing::Direction3D aDir; |
628 | |
|
629 | 0 | aDir.DirectionX = rSize.getX(); |
630 | 0 | aDir.DirectionY = rSize.getY(); |
631 | 0 | aDir.DirectionZ = rSize.getZ(); |
632 | |
|
633 | 0 | rValue <<= aDir; |
634 | 0 | break; |
635 | 0 | } |
636 | 0 | default: |
637 | 0 | return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); |
638 | 0 | } |
639 | | |
640 | 0 | return true; |
641 | 0 | } |
642 | | |
643 | | // css::lang::XServiceInfo |
644 | | uno::Sequence< OUString > SAL_CALL Svx3DSphereObject::getSupportedServiceNames() |
645 | 0 | { |
646 | 0 | return comphelper::concatSequences( |
647 | 0 | SvxShape::getSupportedServiceNames(), |
648 | 0 | std::initializer_list<OUString>{ u"com.sun.star.drawing.Shape3D"_ustr, |
649 | 0 | u"com.sun.star.drawing.Shape3DSphere"_ustr }); |
650 | 0 | } |
651 | | |
652 | | Svx3DLatheObject::Svx3DLatheObject(SdrObject* pObj) |
653 | 0 | : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_3DLATHEOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_3DLATHEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) |
654 | 0 | { |
655 | 0 | } |
656 | | |
657 | | Svx3DLatheObject::~Svx3DLatheObject() noexcept |
658 | 0 | { |
659 | 0 | } |
660 | | |
661 | | static bool PolyPolygonShape3D_to_B3dPolyPolygon( |
662 | | const Any& rValue, |
663 | | basegfx::B3DPolyPolygon& rResultPolygon, |
664 | | bool bCorrectPolygon) |
665 | 0 | { |
666 | 0 | drawing::PolyPolygonShape3D aSourcePolyPolygon; |
667 | 0 | if( !(rValue >>= aSourcePolyPolygon) ) |
668 | 0 | return false; |
669 | | |
670 | 0 | sal_Int32 nOuterSequenceCount = aSourcePolyPolygon.SequenceX.getLength(); |
671 | 0 | if(nOuterSequenceCount != aSourcePolyPolygon.SequenceY.getLength() || nOuterSequenceCount != aSourcePolyPolygon.SequenceZ.getLength()) |
672 | 0 | return false; |
673 | | |
674 | 0 | const drawing::DoubleSequence* pInnerSequenceX = aSourcePolyPolygon.SequenceX.getConstArray(); |
675 | 0 | const drawing::DoubleSequence* pInnerSequenceY = aSourcePolyPolygon.SequenceY.getConstArray(); |
676 | 0 | const drawing::DoubleSequence* pInnerSequenceZ = aSourcePolyPolygon.SequenceZ.getConstArray(); |
677 | 0 | for(sal_Int32 a(0);a<nOuterSequenceCount;a++) |
678 | 0 | { |
679 | 0 | sal_Int32 nInnerSequenceCount = pInnerSequenceX->getLength(); |
680 | 0 | if(nInnerSequenceCount != pInnerSequenceY->getLength() || nInnerSequenceCount != pInnerSequenceZ->getLength()) |
681 | 0 | { |
682 | 0 | return false; |
683 | 0 | } |
684 | 0 | basegfx::B3DPolygon aNewPolygon; |
685 | 0 | const double* pArrayX = pInnerSequenceX->getConstArray(); |
686 | 0 | const double* pArrayY = pInnerSequenceY->getConstArray(); |
687 | 0 | const double* pArrayZ = pInnerSequenceZ->getConstArray(); |
688 | 0 | for(sal_Int32 b(0);b<nInnerSequenceCount;b++) |
689 | 0 | { |
690 | 0 | aNewPolygon.append(basegfx::B3DPoint(*pArrayX++,*pArrayY++,*pArrayZ++)); |
691 | 0 | } |
692 | 0 | pInnerSequenceX++; |
693 | 0 | pInnerSequenceY++; |
694 | 0 | pInnerSequenceZ++; |
695 | | |
696 | | // #i101520# correction is needed for imported polygons of old format, |
697 | | // see callers |
698 | 0 | if(bCorrectPolygon) |
699 | 0 | { |
700 | 0 | basegfx::utils::checkClosed(aNewPolygon); |
701 | 0 | } |
702 | |
|
703 | 0 | rResultPolygon.append(aNewPolygon); |
704 | 0 | } |
705 | 0 | return true; |
706 | 0 | } |
707 | | |
708 | | static void B3dPolyPolygon_to_PolyPolygonShape3D( const basegfx::B3DPolyPolygon& rSourcePolyPolygon, Any& rValue ) |
709 | 0 | { |
710 | 0 | drawing::PolyPolygonShape3D aRetval; |
711 | 0 | aRetval.SequenceX.realloc(rSourcePolyPolygon.count()); |
712 | 0 | aRetval.SequenceY.realloc(rSourcePolyPolygon.count()); |
713 | 0 | aRetval.SequenceZ.realloc(rSourcePolyPolygon.count()); |
714 | 0 | drawing::DoubleSequence* pOuterSequenceX = aRetval.SequenceX.getArray(); |
715 | 0 | drawing::DoubleSequence* pOuterSequenceY = aRetval.SequenceY.getArray(); |
716 | 0 | drawing::DoubleSequence* pOuterSequenceZ = aRetval.SequenceZ.getArray(); |
717 | 0 | for(sal_uInt32 a(0);a<rSourcePolyPolygon.count();a++) |
718 | 0 | { |
719 | 0 | const basegfx::B3DPolygon& aPoly(rSourcePolyPolygon.getB3DPolygon(a)); |
720 | 0 | sal_Int32 nPointCount(aPoly.count()); |
721 | 0 | if(aPoly.isClosed()) nPointCount++; |
722 | 0 | pOuterSequenceX->realloc(nPointCount); |
723 | 0 | pOuterSequenceY->realloc(nPointCount); |
724 | 0 | pOuterSequenceZ->realloc(nPointCount); |
725 | 0 | double* pInnerSequenceX = pOuterSequenceX->getArray(); |
726 | 0 | double* pInnerSequenceY = pOuterSequenceY->getArray(); |
727 | 0 | double* pInnerSequenceZ = pOuterSequenceZ->getArray(); |
728 | 0 | for(sal_uInt32 b(0);b<aPoly.count();b++) |
729 | 0 | { |
730 | 0 | const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(b)); |
731 | 0 | *pInnerSequenceX++ = aPoint.getX(); |
732 | 0 | *pInnerSequenceY++ = aPoint.getY(); |
733 | 0 | *pInnerSequenceZ++ = aPoint.getZ(); |
734 | 0 | } |
735 | 0 | if(aPoly.isClosed()) |
736 | 0 | { |
737 | 0 | const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(0)); |
738 | 0 | *pInnerSequenceX++ = aPoint.getX(); |
739 | 0 | *pInnerSequenceY++ = aPoint.getY(); |
740 | 0 | *pInnerSequenceZ++ = aPoint.getZ(); |
741 | 0 | } |
742 | 0 | pOuterSequenceX++; |
743 | 0 | pOuterSequenceY++; |
744 | 0 | pOuterSequenceZ++; |
745 | 0 | } |
746 | 0 | rValue <<= aRetval; |
747 | 0 | } |
748 | | |
749 | | bool Svx3DLatheObject::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) |
750 | 0 | { |
751 | 0 | switch( pProperty->nWID ) |
752 | 0 | { |
753 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
754 | 0 | { |
755 | | // pack transformation matrix to the object |
756 | 0 | if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) ) |
757 | 0 | return true; |
758 | 0 | break; |
759 | 0 | } |
760 | 0 | case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: |
761 | 0 | { |
762 | | // pack polygon definition to the object |
763 | 0 | basegfx::B3DPolyPolygon aNewB3DPolyPolygon; |
764 | | |
765 | | // #i101520# Probably imported |
766 | 0 | if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) ) |
767 | 0 | { |
768 | | // #105127# SetPolyPoly3D sets the Svx3DVerticalSegmentsItem to the number |
769 | | // of points of the polygon. Thus, value gets lost. To avoid this, rescue |
770 | | // item here and re-set after setting the polygon. |
771 | 0 | const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(GetSdrObject())->GetVerticalSegments()); |
772 | | |
773 | | // set polygon |
774 | 0 | const basegfx::B3DHomMatrix aIdentity; |
775 | 0 | const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); |
776 | 0 | static_cast<E3dLatheObj*>(GetSdrObject())->SetPolyPoly2D(aB2DPolyPolygon); |
777 | 0 | const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(GetSdrObject())->GetVerticalSegments()); |
778 | |
|
779 | 0 | if(nPrevVerticalSegs != nPostVerticalSegs) |
780 | 0 | { |
781 | | // restore the vertical segment count |
782 | 0 | static_cast<E3dLatheObj*>(GetSdrObject())->SetMergedItem(makeSvx3DVerticalSegmentsItem(nPrevVerticalSegs)); |
783 | 0 | } |
784 | 0 | return true; |
785 | 0 | } |
786 | 0 | break; |
787 | 0 | } |
788 | 0 | default: |
789 | 0 | return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); |
790 | 0 | } |
791 | | |
792 | 0 | throw IllegalArgumentException(); |
793 | 0 | } |
794 | | |
795 | | bool Svx3DLatheObject::getPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) |
796 | 0 | { |
797 | 0 | switch( pProperty->nWID ) |
798 | 0 | { |
799 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
800 | 0 | { |
801 | | // pack transformation to a homogeneous matrix |
802 | 0 | drawing::HomogenMatrix aHomMat; |
803 | 0 | basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(GetSdrObject())->GetTransform(); |
804 | 0 | basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat); |
805 | 0 | rValue <<= aHomMat; |
806 | 0 | break; |
807 | 0 | } |
808 | 0 | case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: |
809 | 0 | { |
810 | 0 | const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(GetSdrObject())->GetPolyPoly2D(); |
811 | 0 | const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); |
812 | |
|
813 | 0 | B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue); |
814 | 0 | break; |
815 | 0 | } |
816 | 0 | default: |
817 | 0 | return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); |
818 | 0 | } |
819 | | |
820 | 0 | return true; |
821 | 0 | } |
822 | | |
823 | | // css::lang::XServiceInfo |
824 | | uno::Sequence< OUString > SAL_CALL Svx3DLatheObject::getSupportedServiceNames() |
825 | 0 | { |
826 | 0 | return comphelper::concatSequences( |
827 | 0 | SvxShape::getSupportedServiceNames(), |
828 | 0 | std::initializer_list<OUString>{ u"com.sun.star.drawing.Shape3D"_ustr, |
829 | 0 | u"com.sun.star.drawing.Shape3DLathe"_ustr }); |
830 | 0 | } |
831 | | |
832 | | Svx3DExtrudeObject::Svx3DExtrudeObject(SdrObject* pObj) |
833 | 0 | : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_3DEXTRUDEOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_3DEXTRUDEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) |
834 | 0 | { |
835 | 0 | } |
836 | | |
837 | | Svx3DExtrudeObject::~Svx3DExtrudeObject() noexcept |
838 | 0 | { |
839 | 0 | } |
840 | | |
841 | | bool Svx3DExtrudeObject::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) |
842 | 0 | { |
843 | 0 | switch( pProperty->nWID ) |
844 | 0 | { |
845 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
846 | 0 | { |
847 | | // pack transformation matrix to the object |
848 | 0 | if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) ) |
849 | 0 | return true; |
850 | 0 | break; |
851 | 0 | } |
852 | | |
853 | 0 | case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: |
854 | 0 | { |
855 | | // pack polygon definition to the object |
856 | 0 | basegfx::B3DPolyPolygon aNewB3DPolyPolygon; |
857 | | |
858 | | // #i101520# Probably imported |
859 | 0 | if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) ) |
860 | 0 | { |
861 | | // set polygon |
862 | 0 | const basegfx::B3DHomMatrix aIdentity; |
863 | 0 | const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); |
864 | 0 | static_cast<E3dExtrudeObj*>(GetSdrObject())->SetExtrudePolygon(aB2DPolyPolygon); |
865 | 0 | return true; |
866 | 0 | } |
867 | 0 | break; |
868 | 0 | } |
869 | 0 | default: |
870 | 0 | return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); |
871 | 0 | } |
872 | | |
873 | 0 | throw IllegalArgumentException(); |
874 | 0 | } |
875 | | |
876 | | bool Svx3DExtrudeObject::getPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) |
877 | 0 | { |
878 | 0 | switch( pProperty->nWID ) |
879 | 0 | { |
880 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
881 | 0 | { |
882 | | // pack transformation to a homogeneous matrix |
883 | 0 | drawing::HomogenMatrix aHomMat; |
884 | 0 | basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(GetSdrObject())->GetTransform(); |
885 | 0 | basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat); |
886 | 0 | rValue <<= aHomMat; |
887 | 0 | break; |
888 | 0 | } |
889 | | |
890 | 0 | case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: |
891 | 0 | { |
892 | | // pack polygon definition |
893 | 0 | const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(GetSdrObject())->GetExtrudePolygon(); |
894 | 0 | const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); |
895 | |
|
896 | 0 | B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue); |
897 | 0 | break; |
898 | 0 | } |
899 | 0 | default: |
900 | 0 | return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); |
901 | 0 | } |
902 | | |
903 | 0 | return true; |
904 | 0 | } |
905 | | |
906 | | // css::lang::XServiceInfo |
907 | | uno::Sequence< OUString > SAL_CALL Svx3DExtrudeObject::getSupportedServiceNames() |
908 | 0 | { |
909 | 0 | return comphelper::concatSequences( |
910 | 0 | SvxShape::getSupportedServiceNames(), |
911 | 0 | std::initializer_list<OUString>{ u"com.sun.star.drawing.Shape3D"_ustr, |
912 | 0 | u"com.sun.star.drawing.Shape3DExtrude"_ustr }); |
913 | 0 | } |
914 | | |
915 | | Svx3DPolygonObject::Svx3DPolygonObject(SdrObject* pObj) |
916 | 0 | : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_3DPOLYGONOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_3DPOLYGONOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ) |
917 | 0 | { |
918 | 0 | } |
919 | | |
920 | | Svx3DPolygonObject::~Svx3DPolygonObject() noexcept |
921 | 0 | { |
922 | 0 | } |
923 | | |
924 | | bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, const css::uno::Any& rValue ) |
925 | 0 | { |
926 | 0 | switch( pProperty->nWID ) |
927 | 0 | { |
928 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
929 | 0 | { |
930 | | // pack transformation matrix to the object |
931 | 0 | if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) ) |
932 | 0 | return true; |
933 | 0 | break; |
934 | 0 | } |
935 | | |
936 | 0 | case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: |
937 | 0 | { |
938 | | // pack polygon definition to the object |
939 | 0 | basegfx::B3DPolyPolygon aNewB3DPolyPolygon; |
940 | | |
941 | | // #i101520# Direct API data (e.g. from chart) |
942 | 0 | if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) |
943 | 0 | { |
944 | | // set polygon |
945 | 0 | static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyPolygon3D(aNewB3DPolyPolygon); |
946 | 0 | return true; |
947 | 0 | } |
948 | 0 | break; |
949 | 0 | } |
950 | 0 | case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D: |
951 | 0 | { |
952 | | // pack perpendicular definition to the object |
953 | 0 | basegfx::B3DPolyPolygon aNewB3DPolyPolygon; |
954 | | |
955 | | // #i101520# Direct API data (e.g. from chart) |
956 | 0 | if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) |
957 | 0 | { |
958 | | // set polygon |
959 | 0 | static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyNormals3D(aNewB3DPolyPolygon); |
960 | 0 | return true; |
961 | 0 | } |
962 | 0 | break; |
963 | 0 | } |
964 | 0 | case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D: |
965 | 0 | { |
966 | | // pack texture definition to the object |
967 | 0 | basegfx::B3DPolyPolygon aNewB3DPolyPolygon; |
968 | | |
969 | | // #i101520# Direct API data (e.g. from chart) |
970 | 0 | if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) ) |
971 | 0 | { |
972 | | // set polygon |
973 | 0 | const basegfx::B3DHomMatrix aIdentity; |
974 | 0 | const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity)); |
975 | 0 | static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyTexture2D(aB2DPolyPolygon); |
976 | 0 | return true; |
977 | 0 | } |
978 | 0 | break; |
979 | 0 | } |
980 | 0 | case OWN_ATTR_3D_VALUE_LINEONLY: |
981 | 0 | { |
982 | 0 | bool bNew = false; |
983 | 0 | if( rValue >>= bNew ) |
984 | 0 | { |
985 | 0 | static_cast<E3dPolygonObj*>(GetSdrObject())->SetLineOnly(bNew); |
986 | 0 | return true; |
987 | 0 | } |
988 | 0 | break; |
989 | 0 | } |
990 | 0 | default: |
991 | 0 | return SvxShape::setPropertyValueImpl( rName, pProperty, rValue ); |
992 | 0 | } |
993 | | |
994 | 0 | throw IllegalArgumentException(); |
995 | 0 | } |
996 | | |
997 | | bool Svx3DPolygonObject::getPropertyValueImpl( const OUString& rName, const SfxItemPropertyMapEntry* pProperty, css::uno::Any& rValue ) |
998 | 0 | { |
999 | 0 | switch( pProperty->nWID ) |
1000 | 0 | { |
1001 | 0 | case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX: |
1002 | 0 | { |
1003 | 0 | ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue ); |
1004 | 0 | break; |
1005 | 0 | } |
1006 | | |
1007 | 0 | case OWN_ATTR_3D_VALUE_POLYPOLYGON3D: |
1008 | 0 | { |
1009 | 0 | B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyPolygon3D(),rValue); |
1010 | 0 | break; |
1011 | 0 | } |
1012 | | |
1013 | 0 | case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D: |
1014 | 0 | { |
1015 | 0 | B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyNormals3D(),rValue); |
1016 | 0 | break; |
1017 | 0 | } |
1018 | | |
1019 | 0 | case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D: |
1020 | 0 | { |
1021 | | // pack texture definition |
1022 | 0 | const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyTexture2D(); |
1023 | 0 | const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly)); |
1024 | |
|
1025 | 0 | B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon,rValue); |
1026 | 0 | break; |
1027 | 0 | } |
1028 | | |
1029 | 0 | case OWN_ATTR_3D_VALUE_LINEONLY: |
1030 | 0 | { |
1031 | 0 | rValue <<= static_cast<E3dPolygonObj*>(GetSdrObject())->GetLineOnly(); |
1032 | 0 | break; |
1033 | 0 | } |
1034 | | |
1035 | 0 | default: |
1036 | 0 | return SvxShape::getPropertyValueImpl( rName, pProperty, rValue ); |
1037 | 0 | } |
1038 | | |
1039 | 0 | return true; |
1040 | 0 | } |
1041 | | |
1042 | | // css::lang::XServiceInfo |
1043 | | uno::Sequence< OUString > SAL_CALL Svx3DPolygonObject::getSupportedServiceNames() |
1044 | 0 | { |
1045 | 0 | return comphelper::concatSequences( |
1046 | 0 | SvxShape::getSupportedServiceNames(), |
1047 | 0 | std::initializer_list<OUString>{ u"com.sun.star.drawing.Shape3D"_ustr, |
1048 | 0 | u"com.sun.star.drawing.Shape3DPolygon"_ustr }); |
1049 | 0 | } |
1050 | | |
1051 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |