Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <com/sun/star/lang/DisposedException.hpp>
30 : : #include <com/sun/star/awt/FontSlant.hpp>
31 : : #include <com/sun/star/style/VerticalAlignment.hpp>
32 : : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
33 : : #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
34 : : #include <com/sun/star/awt/TextAlign.hpp>
35 : : #include <com/sun/star/style/ParagraphAdjust.hpp>
36 : : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
37 : : #include <com/sun/star/drawing/PointSequence.hpp>
38 : : #include <com/sun/star/graphic/XGraphic.hpp>
39 : : #include <tools/urlobj.hxx>
40 : : #include <unotools/localfilehelper.hxx>
41 : : #include <vcl/svapp.hxx>
42 : : #include <osl/mutex.hxx>
43 : : #include <svtools/fltcall.hxx>
44 : : #include <svtools/filter.hxx>
45 : :
46 : : #include <boost/scoped_ptr.hpp>
47 : : #include <svx/svdpool.hxx>
48 : : #include <rtl/memory.h>
49 : :
50 : : #include <editeng/unoprnms.hxx>
51 : : #include <svx/unoshape.hxx>
52 : : #include <svx/unopage.hxx>
53 : : #include <svx/svdobj.hxx>
54 : : #include <svx/svdpage.hxx>
55 : : #include <svx/svdmodel.hxx>
56 : : #include <svx/svdouno.hxx>
57 : : #include "shapeimpl.hxx"
58 : : #include "svx/unoshprp.hxx"
59 : : #include <svx/svdoashp.hxx>
60 : :
61 : : // #i29181#
62 : : #include "svx/svdviter.hxx"
63 : : #include <svx/svdview.hxx>
64 : : #include <basegfx/matrix/b2dhommatrix.hxx>
65 : : #include <basegfx/polygon/b2dpolygon.hxx>
66 : : #include <basegfx/point/b2dpoint.hxx>
67 : : #include <basegfx/polygon/b2dpolygontools.hxx>
68 : : #include <basegfx/tools/unotools.hxx>
69 : :
70 : : #include <comphelper/servicehelper.hxx>
71 : : #include <svtools/wmf.hxx>
72 : :
73 : : using ::rtl::OUString;
74 : : using namespace ::osl;
75 : : using namespace ::cppu;
76 : : using namespace ::com::sun::star;
77 : : using namespace ::com::sun::star::uno;
78 : : using namespace ::com::sun::star::lang;
79 : : using namespace ::com::sun::star::container;
80 : :
81 : : #define QUERYINT( xint ) \
82 : : if( rType == ::getCppuType((const Reference< xint >*)0) ) \
83 : : aAny <<= Reference< xint >(this)
84 : :
85 : : /***********************************************************************
86 : : * class SvxShapeGroup *
87 : : ***********************************************************************/
88 : :
89 : 57568 : SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw() :
90 : 115136 : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_GROUP), getSvxMapProvider().GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ),
91 : 115136 : mxPage( pDrawPage )
92 : : {
93 : 57568 : }
94 : :
95 : : //----------------------------------------------------------------------
96 : 57568 : SvxShapeGroup::~SvxShapeGroup() throw()
97 : : {
98 [ - + ]: 115136 : }
99 : :
100 : : //----------------------------------------------------------------------
101 : 34769 : void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
102 : : {
103 : 34769 : SvxShape::Create( pNewObj, pNewPage );
104 : 34769 : mxPage = pNewPage;
105 : 34769 : }
106 : :
107 : : //----------------------------------------------------------------------
108 : 442458 : uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType )
109 : : throw(uno::RuntimeException)
110 : : {
111 : 442458 : return SvxShape::queryInterface( rType );
112 : : }
113 : :
114 : 442509 : uno::Any SAL_CALL SvxShapeGroup::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
115 : : {
116 : 442509 : uno::Any aAny;
117 : :
118 [ + + ][ + - ]: 442509 : QUERYINT( drawing::XShapeGroup );
[ + - ][ + - ]
119 [ + - ][ + + ]: 402331 : else QUERYINT( drawing::XShapes );
[ + - ][ + - ]
120 [ + - ][ + + ]: 331501 : else QUERYINT( container::XIndexAccess );
[ + - ][ + - ]
121 [ + - ][ - + ]: 331492 : else QUERYINT( container::XElementAccess );
[ # # ][ # # ]
122 : : else
123 [ + - ]: 331492 : return SvxShape::queryAggregation( rType );
124 : :
125 : 442509 : return aAny;
126 : : }
127 : :
128 : 1190192 : void SAL_CALL SvxShapeGroup::acquire() throw ( )
129 : : {
130 : 1190192 : SvxShape::acquire();
131 : 1190192 : }
132 : :
133 : 1190192 : void SAL_CALL SvxShapeGroup::release() throw ( )
134 : : {
135 : 1190192 : SvxShape::release();
136 : 1190192 : }
137 : :
138 : 0 : uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes()
139 : : throw (uno::RuntimeException)
140 : : {
141 : 0 : return SvxShape::getTypes();
142 : : }
143 : :
144 : : namespace
145 : : {
146 : : class theSvxShapeGroupImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxShapeGroupImplementationId > {};
147 : : }
148 : :
149 : 0 : uno::Sequence< sal_Int8 > SAL_CALL SvxShapeGroup::getImplementationId()
150 : : throw (uno::RuntimeException)
151 : : {
152 : 0 : return theSvxShapeGroupImplementationId::get().getSeq();
153 : : }
154 : :
155 : : // ::com::sun::star::drawing::XShape
156 : :
157 : : //----------------------------------------------------------------------
158 : 69544 : OUString SAL_CALL SvxShapeGroup::getShapeType()
159 : : throw( uno::RuntimeException )
160 : : {
161 : 69544 : return SvxShape::getShapeType();
162 : : }
163 : :
164 : : //------------------------------------------------------------------1----
165 : 37095 : awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException)
166 : : {
167 : 37095 : return SvxShape::getPosition();
168 : : }
169 : :
170 : : //----------------------------------------------------------------------
171 : 38945 : void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
172 : : {
173 : 38945 : SvxShape::setPosition(Position);
174 : 38945 : }
175 : :
176 : : //----------------------------------------------------------------------
177 : :
178 : 38048 : awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException)
179 : : {
180 : 38048 : return SvxShape::getSize();
181 : : }
182 : :
183 : : //----------------------------------------------------------------------
184 : 65371 : void SAL_CALL SvxShapeGroup::setSize( const awt::Size& rSize )
185 : : throw(beans::PropertyVetoException, uno::RuntimeException)
186 : : {
187 : 65371 : SvxShape::setSize( rSize );
188 : 65371 : }
189 : :
190 : : // drawing::XShapeGroup
191 : :
192 : : //----------------------------------------------------------------------
193 : 0 : void SAL_CALL SvxShapeGroup::enterGroup( ) throw(uno::RuntimeException)
194 : : {
195 : : // Todo
196 : : // pDrView->EnterMarkedGroup();
197 : 0 : }
198 : :
199 : : //----------------------------------------------------------------------
200 : 0 : void SAL_CALL SvxShapeGroup::leaveGroup( ) throw(uno::RuntimeException)
201 : : {
202 : : // Todo
203 : : // pDrView->LeaveOneGroup();
204 : 0 : }
205 : :
206 : : //----------------------------------------------------------------------
207 : :
208 : : // XShapes
209 : 85865 : void SAL_CALL SvxShapeGroup::add( const uno::Reference< drawing::XShape >& xShape )
210 : : throw( uno::RuntimeException )
211 : : {
212 [ + - ]: 85865 : ::SolarMutexGuard aGuard;
213 : :
214 [ + - ]: 85865 : SvxShape* pShape = SvxShape::getImplementation( xShape );
215 : :
216 [ + - ][ + - ]: 85865 : if( mpObj.is()&& mxPage.is() && pShape )
[ + - ][ + - ]
217 : : {
218 [ + - ]: 85865 : SdrObject* pSdrShape = pShape->GetSdrObject();
219 [ + - ]: 85865 : if( pSdrShape == NULL )
220 : 85865 : pSdrShape = mxPage->_CreateSdrObject( xShape );
221 : :
222 [ + - ][ - + ]: 85865 : if( pSdrShape->IsInserted() )
223 [ # # ][ # # ]: 0 : pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
[ # # ]
224 : :
225 [ + - ][ + - ]: 85865 : mpObj->GetSubList()->InsertObject( pSdrShape );
226 [ + - ][ + - ]: 85865 : pSdrShape->SetModel(mpObj->GetModel());
227 : :
228 : : // #85922# It makes no sense to set the layer asked
229 : : // from the group object since these is an iteration
230 : : // over the contained objects. In consequence, this
231 : : // statement erases all layer information from the draw
232 : : // objects. Layers need to be set at draw objects directly
233 : : // and have nothing to do with grouping at all.
234 : : // pSdrShape->SetLayer(pObject->GetLayer());
235 : :
236 : : // Establish connection between new SdrObject and its wrapper before
237 : : // inserting the new shape into the group. There a new wrapper
238 : : // would be created when this connection would not already exist.
239 [ + - ]: 85865 : pShape->Create( pSdrShape, mxPage.get() );
240 : :
241 [ + - ]: 85865 : if( mpModel )
242 [ + - ]: 85865 : mpModel->SetChanged();
243 : : }
244 : : else
245 : : {
246 : : OSL_FAIL("could not add XShape to group shape!");
247 [ + - ]: 85865 : }
248 : 85865 : }
249 : :
250 : : //----------------------------------------------------------------------
251 : 18538 : void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xShape )
252 : : throw( uno::RuntimeException )
253 : : {
254 [ + - ]: 18538 : ::SolarMutexGuard aGuard;
255 : :
256 : 18538 : SdrObject* pSdrShape = NULL;
257 [ + - ]: 18538 : SvxShape* pShape = SvxShape::getImplementation( xShape );
258 : :
259 [ + - ]: 18538 : if( pShape )
260 [ + - ]: 18538 : pSdrShape = pShape->GetSdrObject();
261 : :
262 [ + - ][ + - ]: 18538 : if( !mpObj.is() || pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
[ + - ][ - + ]
[ - + ]
263 [ # # ]: 0 : throw uno::RuntimeException();
264 : :
265 [ + - ]: 18538 : SdrObjList& rList = *pSdrShape->GetObjList();
266 : :
267 [ + - ]: 18538 : const sal_uInt32 nObjCount = rList.GetObjCount();
268 : 18538 : sal_uInt32 nObjNum = 0;
269 [ + - ]: 39607 : while( nObjNum < nObjCount )
270 : : {
271 [ + - ][ + + ]: 39607 : if(rList.GetObj( nObjNum ) == pSdrShape )
272 : 18538 : break;
273 : 21069 : nObjNum++;
274 : : }
275 : :
276 [ + - ]: 18538 : if( nObjNum < nObjCount )
277 : : {
278 : : // #i29181#
279 : : // If the SdrObject which is about to be deleted is in any selection,
280 : : // deselect it first.
281 [ + - ]: 18538 : SdrViewIter aIter( pSdrShape );
282 : :
283 [ + - ][ # # ]: 18538 : for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
[ - + ]
284 : : {
285 [ # # ][ # # ]: 0 : if(CONTAINER_ENTRY_NOTFOUND != pView->TryToFindMarkedObject(pSdrShape))
286 : : {
287 [ # # ]: 0 : pView->MarkObj(pSdrShape, pView->GetSdrPageView(), sal_True, sal_False);
288 : : }
289 : : }
290 : :
291 [ + - ]: 18538 : SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
292 [ + - ]: 18538 : SdrObject::Free( pObject );
293 : : }
294 : : else
295 : : {
296 : : DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
297 : : }
298 : :
299 [ + - ]: 18538 : if( mpModel )
300 [ + - ][ + - ]: 18538 : mpModel->SetChanged();
301 : 18538 : }
302 : :
303 : : // XIndexAccess
304 : :
305 : : //----------------------------------------------------------------------
306 : 69408 : sal_Int32 SAL_CALL SvxShapeGroup::getCount() throw( uno::RuntimeException )
307 : : {
308 [ + - ]: 69408 : ::SolarMutexGuard aGuard;
309 : :
310 : 69408 : sal_Int32 nRetval = 0;
311 : :
312 [ + - ][ + - ]: 69408 : if(mpObj.is() && mpObj->GetSubList())
[ + - ][ + - ]
313 [ + - ][ + - ]: 69408 : nRetval = mpObj->GetSubList()->GetObjCount();
314 : : else
315 [ # # ]: 69408 : throw uno::RuntimeException();
316 : :
317 [ + - ]: 138816 : return nRetval;
318 : : }
319 : :
320 : : //----------------------------------------------------------------------
321 : 80916 : uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
322 : : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
323 : : {
324 [ + - ]: 80916 : ::SolarMutexGuard aGuard;
325 : :
326 [ + - ][ + - ]: 80916 : if( !mpObj.is() || mpObj->GetSubList() == NULL )
[ - + ][ - + ]
327 [ # # ]: 0 : throw uno::RuntimeException();
328 : :
329 [ + - ][ + - ]: 80916 : if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index )
[ - + ]
330 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
331 : :
332 [ + - ][ + - ]: 80916 : SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
333 : :
334 [ - + ]: 80916 : if(pDestObj == NULL)
335 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
336 : :
337 [ + - ][ + - ]: 80916 : Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY );
338 [ + - ][ + - ]: 80916 : return uno::makeAny( xShape );
339 : : }
340 : :
341 : : // ::com::sun::star::container::XElementAccess
342 : :
343 : : //----------------------------------------------------------------------
344 : 0 : uno::Type SAL_CALL SvxShapeGroup::getElementType() throw( uno::RuntimeException )
345 : : {
346 : 0 : return ::getCppuType(( const Reference< drawing::XShape >*)0);
347 : : }
348 : :
349 : : //----------------------------------------------------------------------
350 : 6 : sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException )
351 : : {
352 [ + - ]: 6 : ::SolarMutexGuard aGuard;
353 : :
354 [ + - ][ + - ]: 6 : return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ]
355 : : }
356 : :
357 : : //----------------------------------------------------------------------
358 : : // ::com::sun::star::lang::XServiceInfo
359 : :
360 : 0 : uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
361 : : throw(uno::RuntimeException)
362 : : {
363 : 0 : return SvxShape::getSupportedServiceNames();
364 : : }
365 : :
366 : : /***********************************************************************
367 : : * *
368 : : ***********************************************************************/
369 : :
370 : 1 : SvxShapeConnector::SvxShapeConnector( SdrObject* pObj ) throw() :
371 [ + - ][ + - ]: 1 : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
[ + - ][ + - ]
[ + - ]
372 : : {
373 : 1 : }
374 : :
375 : : //----------------------------------------------------------------------
376 : 1 : SvxShapeConnector::~SvxShapeConnector() throw()
377 : : {
378 [ - + ]: 2 : }
379 : :
380 : : //----------------------------------------------------------------------
381 : :
382 : 6 : uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType )
383 : : throw(uno::RuntimeException)
384 : : {
385 : 6 : return SvxShapeText::queryInterface( rType );
386 : : }
387 : :
388 : 5 : uno::Any SAL_CALL SvxShapeConnector::queryAggregation( const uno::Type & rType )
389 : : throw(uno::RuntimeException)
390 : : {
391 : 5 : uno::Any aAny;
392 : :
393 [ - + ][ # # ]: 5 : QUERYINT( drawing::XConnectorShape );
[ # # ][ + - ]
394 : : else
395 [ + - ]: 5 : return SvxShapeText::queryAggregation( rType );
396 : :
397 : 5 : return aAny;
398 : : }
399 : :
400 : 21 : void SAL_CALL SvxShapeConnector::acquire() throw ( )
401 : : {
402 : 21 : SvxShapeText::acquire();
403 : 21 : }
404 : :
405 : 21 : void SAL_CALL SvxShapeConnector::release() throw ( )
406 : : {
407 : 21 : SvxShapeText::release();
408 : 21 : }
409 : : // XTypeProvider
410 : :
411 : 0 : uno::Sequence< uno::Type > SAL_CALL SvxShapeConnector::getTypes()
412 : : throw (uno::RuntimeException)
413 : : {
414 : 0 : return SvxShape::getTypes();
415 : : }
416 : :
417 : : namespace
418 : : {
419 : : class theSvxShapeConnectorImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxShapeConnectorImplementationId > {};
420 : : }
421 : :
422 : 0 : uno::Sequence< sal_Int8 > SAL_CALL SvxShapeConnector::getImplementationId()
423 : : throw (uno::RuntimeException)
424 : : {
425 : 0 : return theSvxShapeConnectorImplementationId::get().getSeq();
426 : : }
427 : :
428 : : // ::com::sun::star::drawing::XShape
429 : :
430 : : //----------------------------------------------------------------------
431 : 0 : OUString SAL_CALL SvxShapeConnector::getShapeType()
432 : : throw( uno::RuntimeException )
433 : : {
434 : 0 : return SvxShapeText::getShapeType();
435 : : }
436 : :
437 : : //------------------------------------------------------------------1----
438 : 0 : awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException)
439 : : {
440 : 0 : return SvxShapeText::getPosition();
441 : : }
442 : :
443 : : //----------------------------------------------------------------------
444 : 0 : void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
445 : : {
446 : 0 : SvxShapeText::setPosition(Position);
447 : 0 : }
448 : :
449 : : //----------------------------------------------------------------------
450 : :
451 : 0 : awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException)
452 : : {
453 : 0 : return SvxShapeText::getSize();
454 : : }
455 : :
456 : : //----------------------------------------------------------------------
457 : 0 : void SAL_CALL SvxShapeConnector::setSize( const awt::Size& rSize )
458 : : throw(beans::PropertyVetoException, uno::RuntimeException)
459 : : {
460 : 0 : SvxShapeText::setSize( rSize );
461 : 0 : }
462 : :
463 : : //----------------------------------------------------------------------
464 : :
465 : : // XConnectorShape
466 : :
467 : 0 : void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType ) throw( uno::RuntimeException )
468 : : {
469 [ # # ]: 0 : ::SolarMutexGuard aGuard;
470 : :
471 [ # # ]: 0 : Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
472 [ # # ]: 0 : SvxShape* pShape = SvxShape::getImplementation( xRef );
473 : :
474 [ # # ]: 0 : if( pShape )
475 [ # # ]: 0 : mpObj->ConnectToNode( sal_True, pShape->mpObj.get() );
476 : :
477 [ # # ]: 0 : if( mpModel )
478 [ # # ][ # # ]: 0 : mpModel->SetChanged();
479 : 0 : }
480 : :
481 : : //----------------------------------------------------------------------
482 : 0 : void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType )
483 : : throw( uno::RuntimeException )
484 : : {
485 [ # # ]: 0 : ::SolarMutexGuard aGuard;
486 : :
487 [ # # ]: 0 : Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
488 [ # # ]: 0 : SvxShape* pShape = SvxShape::getImplementation( xRef );
489 : :
490 [ # # ][ # # ]: 0 : if( mpObj.is() && pShape )
[ # # ]
491 [ # # ]: 0 : mpObj->ConnectToNode( sal_False, pShape->mpObj.get() );
492 : :
493 [ # # ]: 0 : if( mpModel )
494 [ # # ][ # # ]: 0 : mpModel->SetChanged();
495 : 0 : }
496 : :
497 : : //----------------------------------------------------------------------
498 : 0 : void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing::XConnectableShape >& )
499 : : throw( uno::RuntimeException )
500 : : {
501 [ # # ]: 0 : ::SolarMutexGuard aGuard;
502 : :
503 [ # # ]: 0 : if(mpObj.is())
504 [ # # ]: 0 : mpObj->DisconnectFromNode( sal_True );
505 : :
506 [ # # ]: 0 : if( mpModel )
507 [ # # ][ # # ]: 0 : mpModel->SetChanged();
508 : 0 : }
509 : :
510 : : //----------------------------------------------------------------------
511 : 0 : void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::XConnectableShape >& )
512 : : throw( uno::RuntimeException )
513 : : {
514 [ # # ]: 0 : ::SolarMutexGuard aGuard;
515 : :
516 [ # # ]: 0 : if(mpObj.is())
517 [ # # ]: 0 : mpObj->DisconnectFromNode( sal_False );
518 : :
519 [ # # ]: 0 : if( mpModel )
520 [ # # ][ # # ]: 0 : mpModel->SetChanged();
521 : 0 : }
522 : :
523 : : //----------------------------------------------------------------------
524 : : // ::com::sun::star::lang::XServiceInfo
525 : : //----------------------------------------------------------------------
526 : 0 : uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException )
527 : : {
528 : 0 : return SvxShapeText::getSupportedServiceNames();
529 : : }
530 : :
531 : : /***********************************************************************
532 : : * class SvxShapeControl *
533 : : ***********************************************************************/
534 : : DBG_NAME(SvxShapeControl)
535 : :
536 : 542 : SvxShapeControl::SvxShapeControl( SdrObject* pObj ) throw() :
537 [ + - ][ + - ]: 542 : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONTROL), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) )
[ + - ][ + - ]
[ + - ]
538 : : {
539 : : DBG_CTOR(SvxShapeControl,NULL);
540 [ + - ]: 542 : setShapeKind( OBJ_UNO );
541 : 542 : }
542 : :
543 : : //----------------------------------------------------------------------
544 : 542 : SvxShapeControl::~SvxShapeControl() throw()
545 : : {
546 : : DBG_DTOR(SvxShapeControl,NULL);
547 [ - + ]: 1084 : }
548 : :
549 : : //----------------------------------------------------------------------
550 : 4663 : uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType )
551 : : throw(uno::RuntimeException)
552 : : {
553 : 4663 : return SvxShapeText::queryInterface( rType );
554 : : }
555 : :
556 : 5452 : uno::Any SAL_CALL SvxShapeControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
557 : : {
558 : 5452 : uno::Any aAny;
559 : :
560 [ + + ][ + - ]: 5452 : QUERYINT( drawing::XControlShape );
[ + - ][ + - ]
561 : : else
562 [ + - ]: 4834 : return SvxShapeText::queryAggregation( rType );
563 : :
564 : 5452 : return aAny;
565 : : }
566 : :
567 : 21536 : void SAL_CALL SvxShapeControl::acquire() throw ( )
568 : : {
569 : 21536 : SvxShapeText::acquire();
570 : 21536 : }
571 : :
572 : 21536 : void SAL_CALL SvxShapeControl::release() throw ( )
573 : : {
574 : 21536 : SvxShapeText::release();
575 : 21536 : }
576 : : // XTypeProvider
577 : :
578 : 0 : uno::Sequence< uno::Type > SAL_CALL SvxShapeControl::getTypes()
579 : : throw (uno::RuntimeException)
580 : : {
581 : 0 : return SvxShape::getTypes();
582 : : }
583 : :
584 : : namespace
585 : : {
586 : : class theSvxShapeControlImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxShapeControlImplementationId > {};
587 : : }
588 : :
589 : 0 : uno::Sequence< sal_Int8 > SAL_CALL SvxShapeControl::getImplementationId()
590 : : throw (uno::RuntimeException)
591 : : {
592 : 0 : return theSvxShapeControlImplementationId::get().getSeq();
593 : : }
594 : :
595 : : // ::com::sun::star::drawing::XShape
596 : :
597 : : //----------------------------------------------------------------------
598 : 20 : OUString SAL_CALL SvxShapeControl::getShapeType()
599 : : throw( uno::RuntimeException )
600 : : {
601 : 20 : return SvxShapeText::getShapeType();
602 : : }
603 : :
604 : : //------------------------------------------------------------------1----
605 : 487 : awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException)
606 : : {
607 : 487 : return SvxShapeText::getPosition();
608 : : }
609 : :
610 : : //----------------------------------------------------------------------
611 : 1434 : void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
612 : : {
613 : 1434 : SvxShapeText::setPosition(Position);
614 : 1434 : }
615 : :
616 : : //----------------------------------------------------------------------
617 : :
618 : 0 : awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException)
619 : : {
620 : 0 : return SvxShapeText::getSize();
621 : : }
622 : :
623 : : //----------------------------------------------------------------------
624 : 970 : void SAL_CALL SvxShapeControl::setSize( const awt::Size& rSize )
625 : : throw(beans::PropertyVetoException, uno::RuntimeException)
626 : : {
627 : 970 : SvxShapeText::setSize( rSize );
628 : 970 : }
629 : :
630 : : //----------------------------------------------------------------------
631 : : // XControlShape
632 : :
633 : 584 : Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
634 : : throw( uno::RuntimeException )
635 : : {
636 [ + - ]: 584 : ::SolarMutexGuard aGuard;
637 : :
638 : 584 : Reference< awt::XControlModel > xModel;
639 : :
640 [ - + ]: 584 : SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
641 [ + - ]: 584 : if( pUnoObj )
642 [ + - ][ + - ]: 584 : xModel = pUnoObj->GetUnoControlModel();
643 : :
644 [ + - ]: 584 : return xModel;
645 : : }
646 : :
647 : : //----------------------------------------------------------------------
648 : 533 : void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >& xControl )
649 : : throw( uno::RuntimeException )
650 : : {
651 [ + - ]: 533 : ::SolarMutexGuard aGuard;
652 : :
653 [ - + ]: 533 : SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
654 [ + - ]: 533 : if( pUnoObj )
655 [ + - ]: 533 : pUnoObj->SetUnoControlModel( xControl );
656 : :
657 [ + + ]: 533 : if( mpModel )
658 [ + - ][ + - ]: 533 : mpModel->SetChanged();
659 : 533 : }
660 : :
661 : : // XServiceInfo
662 : 0 : uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException )
663 : : {
664 : 0 : return SvxShapeText::getSupportedServiceNames();
665 : : }
666 : :
667 : : static struct
668 : : {
669 : : const sal_Char* mpAPIName;
670 : : sal_uInt16 mnAPINameLen;
671 : :
672 : : const sal_Char* mpFormName;
673 : : sal_uInt16 mnFormNameLen;
674 : : }
675 : : SvxShapeControlPropertyMapping[] =
676 : : {
677 : : // Warning: The first entry must be FontSlant because the any needs to be converted
678 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), MAP_CHAR_LEN("FontSlant") }, // const sal_Int16 => ::com::sun::star::awt::FontSlant
679 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), MAP_CHAR_LEN("FontName") },
680 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), MAP_CHAR_LEN("FontStyleName") },
681 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), MAP_CHAR_LEN("FontFamily") },
682 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), MAP_CHAR_LEN("FontCharset") },
683 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), MAP_CHAR_LEN("FontHeight") },
684 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), MAP_CHAR_LEN("FontPitch" ) },
685 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), MAP_CHAR_LEN("FontWeight" ) },
686 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), MAP_CHAR_LEN("FontUnderline") },
687 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), MAP_CHAR_LEN("FontStrikeout") },
688 : : { MAP_CHAR_LEN("CharKerning"), MAP_CHAR_LEN("FontKerning") },
689 : : { MAP_CHAR_LEN("CharWordMode"), MAP_CHAR_LEN("FontWordLineMode" ) },
690 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR), MAP_CHAR_LEN("TextColor") },
691 : : { MAP_CHAR_LEN("CharRelief"), MAP_CHAR_LEN("FontRelief") },
692 : : { MAP_CHAR_LEN("CharUnderlineColor"), MAP_CHAR_LEN("TextLineColor") },
693 : : { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), MAP_CHAR_LEN("Align") },
694 : : { MAP_CHAR_LEN("TextVerticalAdjust"), MAP_CHAR_LEN("VerticalAlign") },
695 : : { MAP_CHAR_LEN("ControlBackground"), MAP_CHAR_LEN("BackgroundColor") },
696 : : { MAP_CHAR_LEN("ControlSymbolColor"), MAP_CHAR_LEN("SymbolColor") },
697 : : { MAP_CHAR_LEN("ControlBorder"), MAP_CHAR_LEN("Border") },
698 : : { MAP_CHAR_LEN("ControlBorderColor"), MAP_CHAR_LEN("BorderColor") },
699 : : { MAP_CHAR_LEN("ControlTextEmphasis"), MAP_CHAR_LEN("FontEmphasisMark") },
700 : : { MAP_CHAR_LEN("ImageScaleMode"), MAP_CHAR_LEN("ScaleMode") },
701 : : { MAP_CHAR_LEN("ControlWritingMode"), MAP_CHAR_LEN("WritingMode") },
702 : : { NULL,0, NULL, 0 }
703 : : };
704 : :
705 : : namespace
706 : : {
707 : 106 : static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
708 : : {
709 : 106 : sal_uInt16 i = 0;
710 [ + + ]: 2650 : while( SvxShapeControlPropertyMapping[i].mpAPIName )
711 : : {
712 [ + + ]: 2544 : if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 )
713 : : {
714 : 47 : rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US );
715 : : }
716 : 2544 : ++i;
717 : : }
718 : 106 : return !rInternalName.isEmpty();
719 : : }
720 : :
721 : : struct EnumConversionMap
722 : : {
723 : : sal_Int16 nAPIValue;
724 : : sal_Int16 nFormValue;
725 : : };
726 : :
727 : : EnumConversionMap aMapAdjustToAlign[] =
728 : : {
729 : : // note that order matters:
730 : : // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
731 : : // and use the first matching entry
732 : : {style::ParagraphAdjust_LEFT, (sal_Int16)awt::TextAlign::LEFT},
733 : : {style::ParagraphAdjust_CENTER, (sal_Int16)awt::TextAlign::CENTER},
734 : : {style::ParagraphAdjust_RIGHT, (sal_Int16)awt::TextAlign::RIGHT},
735 : : {style::ParagraphAdjust_BLOCK, (sal_Int16)awt::TextAlign::RIGHT},
736 : : {style::ParagraphAdjust_STRETCH, (sal_Int16)awt::TextAlign::LEFT},
737 : : {-1,-1}
738 : : };
739 : :
740 : 0 : static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap )
741 : : {
742 : 0 : sal_Int16 nValue = sal_Int16();
743 : 0 : OSL_VERIFY( _rValue >>= nValue );
744 : :
745 : 0 : const EnumConversionMap* pEntry = _pMap;
746 [ # # ][ # # ]: 0 : while ( pEntry && ( pEntry->nFormValue != -1 ) )
[ # # ]
747 : : {
748 [ # # ]: 0 : if ( nValue == pEntry->nFormValue )
749 : : {
750 [ # # ]: 0 : _rValue <<= pEntry->nAPIValue;
751 : 0 : return;
752 : : }
753 : 0 : ++pEntry;
754 : : }
755 : : }
756 : :
757 : 17 : static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap )
758 : : {
759 : 17 : sal_Int32 nValue = 0;
760 : 17 : OSL_VERIFY( _rValue >>= nValue );
761 : :
762 : 17 : const EnumConversionMap* pEntry = _pMap;
763 [ + - ][ + - ]: 48 : while ( pEntry && ( pEntry->nAPIValue != -1 ) )
[ + - ]
764 : : {
765 [ + + ]: 31 : if ( nValue == pEntry->nAPIValue )
766 : : {
767 [ + - ]: 17 : _rValue <<= pEntry->nFormValue;
768 : 17 : return;
769 : : }
770 : 14 : ++pEntry;
771 : : }
772 : : }
773 : :
774 : 0 : static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue )
775 : : {
776 : 0 : lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign );
777 : 0 : }
778 : :
779 : 17 : static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue )
780 : : {
781 : 17 : lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign );
782 : 17 : }
783 : :
784 : 0 : void convertVerticalAdjustToVerticalAlign( Any& _rValue ) SAL_THROW( ( lang::IllegalArgumentException ) )
785 : : {
786 [ # # ]: 0 : if ( !_rValue.hasValue() )
787 : 0 : return;
788 : :
789 : 0 : drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
790 : 0 : style::VerticalAlignment eAlign = style::VerticalAlignment_TOP;
791 [ # # ][ # # ]: 0 : if ( !( _rValue >>= eAdjust ) )
792 [ # # ]: 0 : throw lang::IllegalArgumentException();
793 [ # # # ]: 0 : switch ( eAdjust )
794 : : {
795 : 0 : case drawing::TextVerticalAdjust_TOP: eAlign = style::VerticalAlignment_TOP; break;
796 : 0 : case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break;
797 : 0 : default: eAlign = style::VerticalAlignment_MIDDLE; break;
798 : : }
799 [ # # ]: 0 : _rValue <<= eAlign;
800 : : }
801 : :
802 : 0 : void convertVerticalAlignToVerticalAdjust( Any& _rValue )
803 : : {
804 [ # # ]: 0 : if ( !_rValue.hasValue() )
805 : 0 : return;
806 : 0 : style::VerticalAlignment eAlign = style::VerticalAlignment_TOP;
807 : 0 : drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
808 [ # # ]: 0 : OSL_VERIFY( _rValue >>= eAlign );
809 [ # # # ]: 0 : switch ( eAlign )
810 : : {
811 : 0 : case style::VerticalAlignment_TOP: eAdjust = drawing::TextVerticalAdjust_TOP; break;
812 : 0 : case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break;
813 : 0 : default: eAdjust = drawing::TextVerticalAdjust_CENTER; break;
814 : : }
815 [ # # ]: 0 : _rValue <<= eAdjust;
816 : : }
817 : : }
818 : :
819 : 106 : void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
820 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
821 : : {
822 : 106 : OUString aFormsName;
823 [ + + ][ + - ]: 106 : if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
824 : : {
825 [ + - ][ + - ]: 47 : uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
826 [ + - ]: 47 : if( xControl.is() )
827 : : {
828 [ + - ][ + - ]: 47 : uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
829 [ + - ][ + - ]: 47 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
[ + - ][ + - ]
[ + - ]
830 : : {
831 : 47 : uno::Any aConvertedValue( aValue );
832 [ + + ]: 47 : if ( aFormsName == "FontSlant" )
833 : : {
834 : : awt::FontSlant nSlant;
835 [ + - ][ - + ]: 3 : if( !(aValue >>= nSlant ) )
836 [ # # ]: 0 : throw lang::IllegalArgumentException();
837 [ + - ]: 3 : aConvertedValue <<= (sal_Int16)nSlant;
838 : : }
839 [ + + ]: 44 : else if ( aFormsName == "Align" )
840 : : {
841 [ + - ]: 17 : lcl_convertParaAdjustmentToTextAlignment( aConvertedValue );
842 : : }
843 [ - + ]: 27 : else if ( aFormsName == "VerticalAlign" )
844 : : {
845 [ # # ]: 0 : convertVerticalAdjustToVerticalAlign( aConvertedValue );
846 : : }
847 : :
848 [ + - ][ + - ]: 47 : xControl->setPropertyValue( aFormsName, aConvertedValue );
849 : 47 : }
850 : 47 : }
851 : : }
852 : : else
853 : : {
854 [ + - ]: 59 : SvxShape::setPropertyValue( aPropertyName, aValue );
855 : 106 : }
856 : 106 : }
857 : :
858 : 0 : uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName )
859 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
860 : : {
861 : 0 : OUString aFormsName;
862 [ # # ][ # # ]: 0 : if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
863 : : {
864 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
865 : :
866 : 0 : uno::Any aValue;
867 [ # # ]: 0 : if( xControl.is() )
868 : : {
869 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
870 [ # # ][ # # ]: 0 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
[ # # ][ # # ]
[ # # ]
871 : : {
872 [ # # ][ # # ]: 0 : aValue = xControl->getPropertyValue( aFormsName );
873 [ # # ]: 0 : if ( aFormsName == "FontSlant" )
874 : : {
875 : 0 : awt::FontSlant eSlant = awt::FontSlant_NONE;
876 : 0 : sal_Int16 nSlant = sal_Int16();
877 [ # # ]: 0 : if ( aValue >>= nSlant )
878 : : {
879 : 0 : eSlant = (awt::FontSlant)nSlant;
880 : : }
881 : : else
882 : : {
883 [ # # ]: 0 : OSL_VERIFY( aValue >>= eSlant );
884 : : }
885 [ # # ]: 0 : aValue <<= eSlant;
886 : : }
887 [ # # ]: 0 : else if ( aFormsName == "Align" )
888 : : {
889 [ # # ]: 0 : lcl_convertTextAlignmentToParaAdjustment( aValue );
890 : : }
891 [ # # ]: 0 : else if ( aFormsName == "VerticalAlign" )
892 : : {
893 [ # # ]: 0 : convertVerticalAlignToVerticalAdjust( aValue );
894 : : }
895 : 0 : }
896 : : }
897 : :
898 : 0 : return aValue;
899 : : }
900 : : else
901 : : {
902 [ # # ]: 0 : return SvxShape::getPropertyValue( aPropertyName );
903 : 0 : }
904 : :
905 : : }
906 : :
907 : : // XPropertyState
908 : 0 : beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
909 : : {
910 : 0 : OUString aFormsName;
911 [ # # ][ # # ]: 0 : if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
912 : : {
913 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
914 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
915 : :
916 [ # # ][ # # ]: 0 : if( xControl.is() && xPropSet.is() )
[ # # ]
917 : : {
918 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
919 [ # # ][ # # ]: 0 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
[ # # ][ # # ]
[ # # ]
920 : : {
921 [ # # ][ # # ]: 0 : return xControl->getPropertyState( aFormsName );
922 [ # # ]: 0 : }
923 : : }
924 : :
925 : 0 : return beans::PropertyState_DEFAULT_VALUE;
926 : : }
927 : : else
928 : : {
929 [ # # ]: 0 : return SvxShape::getPropertyState( PropertyName );
930 : 0 : }
931 : : }
932 : :
933 : 0 : void SAL_CALL SvxShapeControl::setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
934 : : {
935 : 0 : OUString aFormsName;
936 [ # # ][ # # ]: 0 : if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
937 : : {
938 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
939 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
940 : :
941 [ # # ][ # # ]: 0 : if( xControl.is() && xPropSet.is() )
[ # # ]
942 : : {
943 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
944 [ # # ][ # # ]: 0 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
[ # # ][ # # ]
[ # # ]
945 : : {
946 [ # # ][ # # ]: 0 : xControl->setPropertyToDefault( aFormsName );
947 : 0 : }
948 : 0 : }
949 : : }
950 : : else
951 : : {
952 [ # # ]: 0 : SvxShape::setPropertyToDefault( PropertyName );
953 : 0 : }
954 : 0 : }
955 : :
956 : 0 : uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const ::rtl::OUString& aPropertyName )
957 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
958 : : {
959 : 0 : OUString aFormsName;
960 [ # # ][ # # ]: 0 : if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
961 : : {
962 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
963 : :
964 [ # # ]: 0 : if( xControl.is() )
965 : : {
966 [ # # ][ # # ]: 0 : Any aDefault( xControl->getPropertyDefault( aFormsName ) );
967 [ # # ]: 0 : if ( aFormsName == "FontSlant" )
968 : : {
969 : 0 : sal_Int16 nSlant( 0 );
970 : 0 : aDefault >>= nSlant;
971 [ # # ]: 0 : aDefault <<= (awt::FontSlant)nSlant;
972 : : }
973 [ # # ]: 0 : else if ( aFormsName == "Align" )
974 : : {
975 [ # # ]: 0 : lcl_convertTextAlignmentToParaAdjustment( aDefault );
976 : : }
977 [ # # ]: 0 : else if ( aFormsName == "VerticalAlign" )
978 : : {
979 [ # # ]: 0 : convertVerticalAlignToVerticalAdjust( aDefault );
980 : : }
981 : 0 : return aDefault;
982 : : }
983 : :
984 [ # # ]: 0 : throw beans::UnknownPropertyException();
985 : : }
986 : : else
987 : : {
988 [ # # ]: 0 : return SvxShape::getPropertyDefault( aPropertyName );
989 : 0 : }
990 : : }
991 : :
992 : :
993 : : /***********************************************************************
994 : : * class SvxShapeDimensioning *
995 : : ***********************************************************************/
996 : :
997 : : //----------------------------------------------------------------------
998 : 1 : SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw()
999 : 1 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_DIMENSIONING), getSvxMapProvider().GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) )
1000 : : {
1001 : 1 : }
1002 : :
1003 : : //----------------------------------------------------------------------
1004 : 1 : SvxShapeDimensioning::~SvxShapeDimensioning() throw()
1005 : : {
1006 [ - + ]: 2 : }
1007 : :
1008 : : // ::com::sun::star::lang::XServiceInfo
1009 : 0 : uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException )
1010 : : {
1011 : 0 : return SvxShapeText::getSupportedServiceNames();
1012 : : }
1013 : :
1014 : : /***********************************************************************
1015 : : * *
1016 : : ***********************************************************************/
1017 : :
1018 : : //----------------------------------------------------------------------
1019 : 104 : SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
1020 : 104 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CIRCLE), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
1021 : : {
1022 : 104 : }
1023 : :
1024 : : //----------------------------------------------------------------------
1025 : 104 : SvxShapeCircle::~SvxShapeCircle() throw()
1026 : : {
1027 [ - + ]: 208 : }
1028 : :
1029 : : // ::com::sun::star::lang::XServiceInfo
1030 : : // XServiceInfo
1031 : 0 : uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException )
1032 : : {
1033 : 0 : return SvxShapeText::getSupportedServiceNames();
1034 : : }
1035 : :
1036 : : /***********************************************************************
1037 : : * *
1038 : : ***********************************************************************/
1039 : :
1040 : : #include <svx/svdopath.hxx>
1041 : :
1042 : : //----------------------------------------------------------------------
1043 : 35156 : SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
1044 : : throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
1045 : 70312 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
1046 : 70312 : , mePolygonKind( eNew )
1047 : : {
1048 : 35156 : }
1049 : :
1050 : : //----------------------------------------------------------------------
1051 : 35156 : SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
1052 : : {
1053 [ - + ]: 70312 : }
1054 : :
1055 : 17119 : basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw()
1056 : : {
1057 : 17119 : basegfx::B2DPolyPolygon aRetval;
1058 : :
1059 : : // Zeiger auf innere sequences holen
1060 : 17119 : const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray();
1061 : 17119 : const drawing::PointSequence* pInnerSeqEnd = pInnerSequence + pOuterSequence->getLength();
1062 : :
1063 [ + + ]: 58492 : for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence)
1064 : : {
1065 : : // Neues Polygon vorbereiten
1066 [ + - ]: 41373 : basegfx::B2DPolygon aNewPolygon;
1067 : :
1068 : : // Zeiger auf Arrays holen
1069 : 41373 : const awt::Point* pArray = pInnerSequence->getConstArray();
1070 : 41373 : const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength();
1071 : :
1072 [ + + ]: 162529 : for(;pArray != pArrayEnd;++pArray)
1073 : : {
1074 [ + - ]: 121156 : aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1075 : : }
1076 : :
1077 : : // check for closed state flag
1078 [ + - ]: 41373 : basegfx::tools::checkClosed(aNewPolygon);
1079 : :
1080 : : // Neues Teilpolygon einfuegen
1081 [ + - ]: 41373 : aRetval.append(aNewPolygon);
1082 [ + - ]: 41373 : }
1083 : :
1084 : 17119 : return aRetval;
1085 : : }
1086 : :
1087 : : //----------------------------------------------------------------------
1088 : :
1089 : 261382 : bool SvxShapePolyPolygon::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1090 : : {
1091 [ + + - + ]: 261382 : switch( pProperty->nWID )
1092 : : {
1093 : : case OWN_ATTR_VALUE_POLYPOLYGON:
1094 : : {
1095 [ + - ][ + - ]: 17093 : if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ) )
[ + - ]
1096 : : {
1097 : 17093 : basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( (drawing::PointSequenceSequence*)rValue.getValue()));
1098 : 17093 : SetPolygon(aNewPolyPolygon);
1099 [ + - ]: 17093 : return true;
1100 : : }
1101 : 0 : break;
1102 : : }
1103 : : case OWN_ATTR_BASE_GEOMETRY:
1104 : : {
1105 [ + - ][ + - ]: 26 : if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0)))
[ + - ]
1106 : : {
1107 [ + - ]: 26 : if( mpObj.is() )
1108 : : {
1109 [ + - ]: 26 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1110 [ + - ]: 26 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1111 : :
1112 [ + - ]: 26 : mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1113 [ + - ][ + - ]: 26 : aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon((drawing::PointSequenceSequence*)rValue.getValue());
1114 [ + - ][ + - ]: 26 : mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
[ + - ]
1115 : : }
1116 : 26 : return true;
1117 : : }
1118 : 0 : break;
1119 : : }
1120 : : case OWN_ATTR_VALUE_POLYGON:
1121 : : {
1122 [ # # ][ # # ]: 0 : if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ))
[ # # ]
1123 : : {
1124 : 0 : drawing::PointSequence* pSequence = (drawing::PointSequence*)rValue.getValue();
1125 : :
1126 : : // Neues Polygon vorbereiten
1127 [ # # ]: 0 : basegfx::B2DPolygon aNewPolygon;
1128 : :
1129 : : // Zeiger auf Arrays holen
1130 : : // Zeiger auf Arrays holen
1131 : 0 : const awt::Point* pArray = pSequence->getConstArray();
1132 : 0 : const awt::Point* pArrayEnd = pArray + pSequence->getLength();
1133 : :
1134 [ # # ]: 0 : for(;pArray != pArrayEnd;++pArray)
1135 : : {
1136 [ # # ]: 0 : aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1137 : : }
1138 : :
1139 : : // check for closed state flag
1140 [ # # ]: 0 : basegfx::tools::checkClosed(aNewPolygon);
1141 : :
1142 : : // Polygon setzen
1143 [ # # ][ # # ]: 0 : SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon));
1144 [ # # ]: 0 : return true;
1145 : : }
1146 : 0 : break;
1147 : : }
1148 : : default:
1149 : 244263 : return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1150 : : }
1151 : :
1152 [ # # ]: 261382 : throw lang::IllegalArgumentException();
1153 : : }
1154 : :
1155 : 42 : void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval )
1156 : : {
1157 [ - + ]: 42 : if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() )
1158 : 0 : rRetval.realloc( rPolyPoly.count() );
1159 : :
1160 : : // Zeiger auf aeussere Arrays holen
1161 : 42 : drawing::PointSequence* pOuterSequence = rRetval.getArray();
1162 : :
1163 [ + + ]: 84 : for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++)
1164 : : {
1165 : : // Einzelpolygon holen
1166 [ + - ]: 42 : const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(a));
1167 : :
1168 : : // #i75974# take closed stae into account, the API polygon still uses the old closed definition
1169 : : // with last/first point are identical (cannot hold information about open polygons with identical
1170 : : // first and last point, though)
1171 [ + - ]: 42 : const sal_uInt32 nPointCount(aPoly.count());
1172 [ + - ]: 42 : const bool bIsClosed(aPoly.isClosed());
1173 : :
1174 : : // Platz in Arrays schaffen
1175 [ + + ][ + - ]: 42 : pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount);
1176 : :
1177 : : // Pointer auf arrays holen
1178 [ + - ]: 42 : awt::Point* pInnerSequence = pOuterSequence->getArray();
1179 : :
1180 [ + + ]: 318 : for(sal_uInt32 b(0L); b < nPointCount; b++)
1181 : : {
1182 [ + - ]: 276 : const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1183 : 276 : *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1184 : 276 : pInnerSequence++;
1185 : 276 : }
1186 : :
1187 : : // #i75974# copy first point
1188 [ + + ]: 42 : if(bIsClosed)
1189 : : {
1190 [ + - ]: 18 : *pInnerSequence = *pOuterSequence->getArray();
1191 : : }
1192 : :
1193 : 42 : pOuterSequence++;
1194 [ + - ]: 42 : }
1195 : 42 : }
1196 : :
1197 : : //----------------------------------------------------------------------
1198 : :
1199 : 1374 : bool SvxShapePolyPolygon::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1200 : : {
1201 [ + + - + : 1374 : switch( pProperty->nWID )
+ ]
1202 : : {
1203 : : case OWN_ATTR_VALUE_POLYPOLYGON:
1204 : : {
1205 : : // PolyPolygon in eine struct PolyPolygon packen
1206 : 21 : const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1207 [ + - ][ + - ]: 21 : drawing::PointSequenceSequence aRetval( rPolyPoly.count() );
1208 : :
1209 [ + - ]: 21 : B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval );
1210 : :
1211 [ + - ]: 21 : rValue <<= aRetval;
1212 [ + - ][ + - ]: 21 : break;
1213 : : }
1214 : : case OWN_ATTR_BASE_GEOMETRY:
1215 : : {
1216 : : // pack a PolyPolygon in struct PolyPolygon
1217 [ + - ]: 21 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1218 [ + - ]: 21 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1219 : :
1220 [ + - ]: 21 : if(mpObj.is())
1221 [ + - ]: 21 : mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1222 : :
1223 [ + - ][ + - ]: 21 : drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
1224 [ + - ]: 21 : B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
1225 [ + - ]: 21 : rValue <<= aRetval;
1226 [ + - ][ + - ]: 21 : break;
[ + - ]
1227 : : }
1228 : : case OWN_ATTR_VALUE_POLYGON:
1229 : : {
1230 : : // PolyPolygon in eine struct PolyPolygon packen
1231 : 0 : const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1232 : :
1233 : 0 : sal_Int32 nCount = 0;
1234 [ # # ][ # # ]: 0 : if( rPolyPoly.count() > 0 )
1235 [ # # ][ # # ]: 0 : nCount = rPolyPoly.getB2DPolygon(0L).count();
[ # # ]
1236 : :
1237 [ # # ]: 0 : drawing::PointSequence aRetval( nCount );
1238 : :
1239 [ # # ]: 0 : if( nCount > 0 )
1240 : : {
1241 : : // Einzelpolygon holen
1242 [ # # ]: 0 : const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L));
1243 : :
1244 : : // Pointer auf arrays holen
1245 [ # # ]: 0 : awt::Point* pSequence = aRetval.getArray();
1246 : :
1247 [ # # ]: 0 : for(sal_Int32 b=0;b<nCount;b++)
1248 : : {
1249 [ # # ]: 0 : const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1250 : 0 : *pSequence++ = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1251 [ # # ]: 0 : }
1252 : : }
1253 : :
1254 [ # # ]: 0 : rValue <<= aRetval;
1255 [ # # ][ # # ]: 0 : break;
1256 : : }
1257 : : case OWN_ATTR_VALUE_POLYGONKIND:
1258 : : {
1259 [ + - ]: 21 : rValue <<= GetPolygonKind();
1260 : 21 : break;
1261 : : }
1262 : : default:
1263 : 1311 : return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1264 : : }
1265 : :
1266 : 1374 : return true;
1267 : : }
1268 : :
1269 : : //----------------------------------------------------------------------
1270 : 21 : drawing::PolygonKind SvxShapePolyPolygon::GetPolygonKind() const throw()
1271 : : {
1272 : 21 : return mePolygonKind;
1273 : : }
1274 : :
1275 : : //----------------------------------------------------------------------
1276 : 17093 : void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
1277 : : {
1278 [ + - ]: 17093 : ::SolarMutexGuard aGuard;
1279 : :
1280 [ + - ]: 17093 : if(mpObj.is())
1281 [ + - ][ + - ]: 17093 : ((SdrPathObj*)mpObj.get())->SetPathPoly(rNew);
1282 : 17093 : }
1283 : :
1284 : : //----------------------------------------------------------------------
1285 : 21 : basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
1286 : : {
1287 [ + - ]: 21 : ::SolarMutexGuard aGuard;
1288 : :
1289 [ + - ]: 21 : if(mpObj.is())
1290 : : {
1291 [ + - ]: 21 : return ((SdrPathObj*)mpObj.get())->GetPathPoly();
1292 : : }
1293 : : else
1294 : : {
1295 [ # # ]: 0 : return basegfx::B2DPolyPolygon();
1296 [ + - ]: 21 : }
1297 : : }
1298 : :
1299 : : // ::com::sun::star::lang::XServiceInfo
1300 : 372 : uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException )
1301 : : {
1302 : 372 : return SvxShapeText::getSupportedServiceNames();
1303 : : }
1304 : :
1305 : : /***********************************************************************
1306 : : * class SvxShapePolyPolygonBezier *
1307 : : ***********************************************************************/
1308 : : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
1309 : : #include <com/sun/star/drawing/FlagSequence.hpp>
1310 : : //----------------------------------------------------------------------
1311 : 456 : SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw()
1312 : 912 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGONBEZIER), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) )
1313 : 912 : , mePolygonKind( eNew )
1314 : : {
1315 : 456 : }
1316 : :
1317 : : //----------------------------------------------------------------------
1318 : 456 : SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw()
1319 : : {
1320 [ - + ]: 912 : }
1321 : :
1322 : : //----------------------------------------------------------------------
1323 : :
1324 : 2954 : bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1325 : : {
1326 [ + + + ]: 2954 : switch( pProperty->nWID )
1327 : : {
1328 : : case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1329 : : {
1330 [ + - ][ + - ]: 152 : if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0) ) )
[ + - ]
1331 : : {
1332 : : basegfx::B2DPolyPolygon aNewPolyPolygon(
1333 : : basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
1334 [ + - ]: 152 : *(drawing::PolyPolygonBezierCoords*)rValue.getValue()));
1335 : 152 : SetPolygon(aNewPolyPolygon);
1336 [ + - ]: 152 : return true;
1337 : : }
1338 : 0 : break;
1339 : : }
1340 : : case OWN_ATTR_BASE_GEOMETRY:
1341 : : {
1342 [ + - ][ + - ]: 12 : if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0)) )
[ + - ]
1343 : : {
1344 [ + - ]: 12 : if( mpObj.is() )
1345 : : {
1346 [ + - ]: 12 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1347 [ + - ]: 12 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1348 : :
1349 [ + - ]: 12 : mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1350 : : aNewPolyPolygon = basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
1351 [ + - ][ + - ]: 12 : *(drawing::PolyPolygonBezierCoords*)rValue.getValue());
[ + - ]
1352 [ + - ][ + - ]: 12 : mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
[ + - ]
1353 : : }
1354 : 12 : return true;
1355 : : }
1356 : 0 : break;
1357 : : }
1358 : : default:
1359 : 2790 : return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1360 : : }
1361 : :
1362 [ # # ]: 2954 : throw IllegalArgumentException();
1363 : : }
1364 : :
1365 : : //----------------------------------------------------------------------
1366 : :
1367 : 948 : bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1368 : : {
1369 [ + + + + ]: 948 : switch( pProperty->nWID )
1370 : : {
1371 : : case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1372 : : {
1373 : : // PolyPolygon in eine struct PolyPolygon packen
1374 : 12 : const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1375 [ + - ]: 12 : drawing::PolyPolygonBezierCoords aRetval;
1376 [ + - ]: 12 : basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval);
1377 : :
1378 [ + - ]: 12 : rValue <<= aRetval;
1379 [ + - ][ + - ]: 12 : break;
1380 : : }
1381 : : case OWN_ATTR_BASE_GEOMETRY:
1382 : : {
1383 : : // PolyPolygon in eine struct PolyPolygon packen
1384 [ + - ]: 12 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1385 [ + - ]: 12 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1386 [ + - ]: 12 : mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1387 [ + - ]: 12 : drawing::PolyPolygonBezierCoords aRetval;
1388 [ + - ]: 12 : basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
1389 : :
1390 [ + - ]: 12 : rValue <<= aRetval;
1391 [ + - ][ + - ]: 12 : break;
[ + - ]
1392 : : }
1393 : : case OWN_ATTR_VALUE_POLYGONKIND:
1394 : : {
1395 [ + - ]: 12 : rValue <<= GetPolygonKind();
1396 : 12 : break;
1397 : : }
1398 : : default:
1399 : 912 : return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1400 : : }
1401 : 948 : return true;
1402 : : }
1403 : :
1404 : : //----------------------------------------------------------------------
1405 : 12 : drawing::PolygonKind SvxShapePolyPolygonBezier::GetPolygonKind() const throw()
1406 : : {
1407 : 12 : return mePolygonKind;
1408 : : }
1409 : :
1410 : : //----------------------------------------------------------------------
1411 : 152 : void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
1412 : : {
1413 [ + - ]: 152 : ::SolarMutexGuard aGuard;
1414 : :
1415 [ + - ]: 152 : if(mpObj.is())
1416 [ + - ][ + - ]: 152 : static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
1417 : 152 : }
1418 : :
1419 : : //----------------------------------------------------------------------
1420 : 12 : basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
1421 : : {
1422 [ + - ]: 12 : ::SolarMutexGuard aGuard;
1423 : :
1424 [ + - ]: 12 : if(mpObj.is())
1425 : : {
1426 [ + - ]: 12 : return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
1427 : : }
1428 : : else
1429 : : {
1430 [ # # ]: 0 : return basegfx::B2DPolyPolygon();
1431 [ + - ]: 12 : }
1432 : : }
1433 : :
1434 : :
1435 : : // ::com::sun::star::lang::XServiceInfo
1436 : 192 : uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException )
1437 : : {
1438 : 192 : return SvxShapeText::getSupportedServiceNames();
1439 : : }
1440 : :
1441 : : /***********************************************************************
1442 : : * class SvxGraphicObject *
1443 : : ***********************************************************************/
1444 : : #include <com/sun/star/awt/XBitmap.hpp>
1445 : : #include <vcl/cvtgrf.hxx>
1446 : : #include <svx/svdograf.hxx>
1447 : : #include <sfx2/docfile.hxx>
1448 : : #include <sfx2/app.hxx>
1449 : : #include <sfx2/fcontnr.hxx>
1450 : :
1451 : : #include "toolkit/unohlp.hxx"
1452 : :
1453 : : //----------------------------------------------------------------------
1454 : 75 : SvxGraphicObject::SvxGraphicObject( SdrObject* pObj ) throw()
1455 : 75 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
1456 : : {
1457 : 75 : }
1458 : :
1459 : : //----------------------------------------------------------------------
1460 : 75 : SvxGraphicObject::~SvxGraphicObject() throw()
1461 : : {
1462 [ - + ]: 150 : }
1463 : :
1464 : : //----------------------------------------------------------------------
1465 : :
1466 : 442 : bool SvxGraphicObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1467 : : {
1468 : 442 : bool bOk = false;
1469 [ - + + - : 442 : switch( pProperty->nWID )
+ ]
1470 : : {
1471 : : case OWN_ATTR_VALUE_FILLBITMAP:
1472 : : {
1473 [ # # ]: 0 : if( rValue.getValue() )
1474 : : {
1475 [ # # ]: 0 : if( rValue.getValueType() == ::getCppuType(( const uno::Sequence< sal_Int8 >*)0) )
1476 : : {
1477 : 0 : uno::Sequence<sal_Int8>* pSeq( (uno::Sequence<sal_Int8>*)rValue.getValue() );
1478 [ # # ]: 0 : SvMemoryStream aMemStm;
1479 [ # # ]: 0 : Graphic aGraphic;
1480 : :
1481 [ # # ]: 0 : aMemStm.SetBuffer( (char*)pSeq->getConstArray(), pSeq->getLength(), sal_False, pSeq->getLength() );
1482 : :
1483 [ # # ][ # # ]: 0 : if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
1484 : : {
1485 [ # # ]: 0 : static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
1486 : 0 : bOk = true;
1487 [ # # ][ # # ]: 0 : }
1488 : : }
1489 : : }
1490 [ # # ][ # # ]: 0 : else if( (rValue.getValueType() == awt::XBitmap::static_type()) || (rValue.getValueType() == graphic::XGraphic::static_type()))
[ # # ]
1491 : : {
1492 [ # # ]: 0 : Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY );
1493 [ # # ]: 0 : if( xGraphic.is() )
1494 : : {
1495 [ # # ][ # # ]: 0 : ((SdrGrafObj*)mpObj.get())->SetGraphic(Graphic(xGraphic));
[ # # ]
1496 : 0 : bOk = true;
1497 : : }
1498 : : else
1499 : : {
1500 : : // Bitmap in das Objekt packen
1501 [ # # ]: 0 : Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
1502 [ # # ]: 0 : if( xBmp.is() )
1503 : : {
1504 : : // Bitmap einsetzen
1505 [ # # ][ # # ]: 0 : Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp ));
[ # # ]
1506 [ # # ]: 0 : ((SdrGrafObj*)mpObj.get())->SetGraphic(aGraphic);
1507 [ # # ]: 0 : bOk = true;
1508 : 0 : }
1509 : 0 : }
1510 : : }
1511 : 0 : break;
1512 : : }
1513 : : case OWN_ATTR_GRAFURL:
1514 : : {
1515 : 50 : OUString aURL;
1516 [ + - ]: 50 : if( rValue >>= aURL )
1517 : : {
1518 [ + + ]: 50 : if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
1519 : : {
1520 : : // graphic manager url
1521 : 42 : aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
1522 [ + - ]: 42 : String aTmpStr(aURL);
1523 [ + - ][ + - ]: 42 : rtl::OString aUniqueID(rtl::OUStringToOString(aTmpStr, RTL_TEXTENCODING_UTF8));
1524 [ + - ]: 42 : GraphicObject aGrafObj(aUniqueID);
1525 : :
1526 : : // #101808# since loading a graphic can cause a reschedule of the office
1527 : : // it is possible that our shape is removed while where in this
1528 : : // method.
1529 [ + - ]: 42 : if( mpObj.is() )
1530 : : {
1531 [ + - ]: 42 : static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink();
1532 [ + - ]: 42 : static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj );
1533 [ + - ][ + - ]: 42 : }
1534 : : }
1535 [ - + ]: 8 : else if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
1536 : : {
1537 : : // normal link
1538 [ # # ]: 0 : String aFilterName;
1539 : 0 : const SfxFilter* pSfxFilter = NULL;
1540 [ # # ][ # # ]: 0 : SfxMedium aSfxMedium( aURL, STREAM_READ | STREAM_SHARE_DENYNONE );
[ # # ]
1541 : :
1542 [ # # ][ # # ]: 0 : SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
[ # # ]
1543 : :
1544 [ # # ]: 0 : if( !pSfxFilter )
1545 : : {
1546 [ # # ]: 0 : INetURLObject aURLObj( aURL );
1547 : :
1548 [ # # ]: 0 : if( aURLObj.GetProtocol() == INET_PROT_NOT_VALID )
1549 : : {
1550 : 0 : rtl::OUString aValidURL;
1551 : :
1552 [ # # ][ # # ]: 0 : if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) )
1553 [ # # ][ # # ]: 0 : aURLObj = INetURLObject( aValidURL );
[ # # ]
1554 : : }
1555 : :
1556 [ # # ]: 0 : if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID )
1557 : : {
1558 [ # # ]: 0 : GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter();
1559 [ # # ][ # # ]: 0 : aFilterName = rGrfFilter.GetImportFormatName( rGrfFilter.GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1560 [ # # ]: 0 : }
1561 : : }
1562 : : else
1563 [ # # ]: 0 : aFilterName = pSfxFilter->GetFilterName();
1564 : :
1565 : : // #101808# since loading a graphic can cause a reschedule of the office
1566 : : // it is possible that our shape is removed while where in this
1567 : : // method.
1568 [ # # ]: 0 : if( mpObj.is() )
1569 [ # # ][ # # ]: 0 : static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, aFilterName );
[ # # ]
1570 : :
1571 : : }
1572 : 50 : bOk = true;
1573 : : }
1574 : 50 : break;
1575 : : }
1576 : :
1577 : : case OWN_ATTR_GRAFSTREAMURL:
1578 : : {
1579 : 8 : OUString aStreamURL;
1580 : :
1581 [ + - ]: 8 : if( rValue >>= aStreamURL )
1582 : : {
1583 [ - + ]: 8 : if( aStreamURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
1584 : 0 : aStreamURL = OUString();
1585 : :
1586 [ + - ]: 8 : if( mpObj.is() )
1587 : : {
1588 [ + - ][ + - ]: 8 : static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
[ + - ]
1589 [ + - ]: 8 : static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut();
1590 : : }
1591 : 8 : bOk = true;
1592 : : }
1593 : 8 : break;
1594 : : }
1595 : :
1596 : : case OWN_ATTR_VALUE_GRAPHIC:
1597 : : {
1598 [ # # ]: 0 : Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
1599 [ # # ]: 0 : if( xGraphic.is() )
1600 : : {
1601 [ # # ][ # # ]: 0 : static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
[ # # ]
1602 : 0 : bOk = true;
1603 : : }
1604 : 0 : break;
1605 : : }
1606 : : default:
1607 : 384 : return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1608 : : }
1609 : :
1610 [ - + ]: 58 : if( !bOk )
1611 [ # # ]: 0 : throw lang::IllegalArgumentException();
1612 : :
1613 [ + - ]: 58 : if( mpModel )
1614 : 58 : mpModel->SetChanged();
1615 : :
1616 : 442 : return true;
1617 : : }
1618 : :
1619 : : //----------------------------------------------------------------------
1620 : :
1621 : 156 : bool SvxGraphicObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1622 : : {
1623 [ - + - + : 156 : switch( pProperty->nWID )
- + ]
1624 : : {
1625 : : case OWN_ATTR_VALUE_FILLBITMAP:
1626 : : {
1627 : 0 : sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1628 : 0 : const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
1629 : :
1630 [ # # ]: 0 : if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
1631 : : {
1632 : : // Objekt in eine Bitmap packen
1633 [ # # ][ # # ]: 0 : Reference< ::com::sun::star::awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
[ # # ][ # # ]
1634 [ # # ]: 0 : rValue <<= xBitmap;
1635 : : }
1636 : : else
1637 : : {
1638 [ # # ]: 0 : SvMemoryStream aDestStrm( 65535, 65535 );
1639 : :
1640 [ # # ][ # # ]: 0 : ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False );
1641 : : const uno::Sequence<sal_Int8> aSeq(
1642 [ # # ]: 0 : static_cast< const sal_Int8* >(aDestStrm.GetData()),
1643 [ # # ]: 0 : aDestStrm.GetEndOfData());
1644 [ # # ][ # # ]: 0 : rValue <<= aSeq;
[ # # ]
1645 : : }
1646 [ # # ]: 0 : if ( bSwapped )
1647 : 0 : static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1648 : 0 : break;
1649 : : }
1650 : :
1651 : : case OWN_ATTR_GRAFURL:
1652 : : {
1653 [ - + ]: 27 : if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() )
1654 : : {
1655 [ # # ]: 0 : rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() );
1656 : : }
1657 : : else
1658 : : {
1659 [ + - ]: 27 : sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1660 [ + - ]: 27 : const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
1661 [ + - ]: 27 : OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
1662 [ + - ][ + - ]: 27 : aURL += OStringToOUString(rGrafObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
1663 [ + - ]: 27 : rValue <<= aURL;
1664 [ - + ]: 27 : if ( bSwapped )
1665 [ # # ]: 27 : static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1666 : : }
1667 : 27 : break;
1668 : : }
1669 : :
1670 : : case OWN_ATTR_GRAFSTREAMURL:
1671 : : {
1672 [ # # ][ # # ]: 0 : const OUString aStreamURL( ( (SdrGrafObj*) mpObj.get() )->GetGrafStreamURL() );
[ # # ]
1673 [ # # ]: 0 : if( !aStreamURL.isEmpty() )
1674 [ # # ]: 0 : rValue <<= aStreamURL;
1675 : 0 : break;
1676 : : }
1677 : :
1678 : : case OWN_ATTR_VALUE_GRAPHIC:
1679 : : {
1680 [ + - ]: 6 : sal_Bool bSwapped = static_cast< SdrGrafObj* >( mpObj.get() )->IsSwappedOut();
1681 [ + - ][ + - ]: 6 : Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
1682 [ + - ]: 6 : rValue <<= xGraphic;
1683 [ - + ]: 6 : if ( bSwapped )
1684 [ # # ]: 0 : static_cast< SdrGrafObj* >( mpObj.get() )->ForceSwapOut();
1685 : 6 : break;
1686 : : }
1687 : :
1688 : : case OWN_ATTR_GRAPHIC_STREAM:
1689 : : {
1690 [ # # ]: 0 : rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
1691 : 0 : break;
1692 : : }
1693 : : default:
1694 : 123 : return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
1695 : : }
1696 : :
1697 : 156 : return true;
1698 : : }
1699 : :
1700 : : ///////////////////////////////////////////////////////////////////////
1701 : :
1702 : 12 : SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw()
1703 : 12 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CAPTION), getSvxMapProvider().GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) )
1704 : : {
1705 : 12 : }
1706 : :
1707 : 12 : SvxShapeCaption::~SvxShapeCaption() throw()
1708 : : {
1709 [ - + ]: 24 : }
1710 : :
1711 : : /***********************************************************************
1712 : : * class SvxCustomShape *
1713 : : ***********************************************************************/
1714 : :
1715 : 4144 : SvxCustomShape::SvxCustomShape( SdrObject* pObj ) throw() :
1716 [ + - ]: 4144 : SvxShapeText( pObj, getSvxMapProvider().GetMap( SVXMAP_CUSTOMSHAPE ), getSvxMapProvider().GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) )
1717 : : {
1718 : 4144 : }
1719 : :
1720 : : //----------------------------------------------------------------------
1721 [ + - ]: 4144 : SvxCustomShape::~SvxCustomShape() throw()
1722 : : {
1723 [ - + ]: 8288 : }
1724 : :
1725 : : //----------------------------------------------------------------------
1726 : :
1727 : 246 : void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
1728 : : {
1729 : 246 : SvxShapeText::Create( pNewObj, pNewPage );
1730 : 246 : }
1731 : :
1732 : : //----------------------------------------------------------------------
1733 : :
1734 : 20145 : uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType )
1735 : : throw(uno::RuntimeException)
1736 : : {
1737 : 20145 : return SvxShapeText::queryInterface( rType );
1738 : : }
1739 : :
1740 : 21956 : uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType )
1741 : : throw(uno::RuntimeException)
1742 : : {
1743 : 21956 : ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType );
1744 [ + + ]: 21956 : if ( !aReturn.hasValue() )
1745 [ + - ]: 438 : aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) );
1746 : 21956 : return aReturn;
1747 : : }
1748 : :
1749 : 72927 : void SAL_CALL SvxCustomShape::acquire() throw ( )
1750 : : {
1751 : 72927 : SvxShapeText::acquire();
1752 : 72927 : }
1753 : :
1754 : 72927 : void SAL_CALL SvxCustomShape::release() throw ( )
1755 : : {
1756 : 72927 : SvxShapeText::release();
1757 : 72927 : }
1758 : :
1759 : : //----------------------------------------------------------------------
1760 : :
1761 : 0 : uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes()
1762 : : throw (uno::RuntimeException)
1763 : : {
1764 : 0 : return SvxShapeText::getTypes();
1765 : : }
1766 : :
1767 : : namespace
1768 : : {
1769 : : class theSvxCustomShapeImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxCustomShapeImplementationId > {};
1770 : : }
1771 : :
1772 : 0 : uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
1773 : : throw (uno::RuntimeException)
1774 : : {
1775 : 0 : return theSvxCustomShapeImplementationId::get().getSeq();
1776 : : }
1777 : :
1778 : : // ::com::sun::star::drawing::XShape
1779 : :
1780 : : //----------------------------------------------------------------------
1781 : 891 : OUString SAL_CALL SvxCustomShape::getShapeType()
1782 : : throw( uno::RuntimeException )
1783 : : {
1784 : 891 : return SvxShape::getShapeType();
1785 : : }
1786 : :
1787 : : //------------------------------------------------------------------1----
1788 : 429 : awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException)
1789 : : {
1790 [ + - ]: 429 : ::SolarMutexGuard aGuard;
1791 [ + + ][ + - ]: 429 : if ( mpModel && mpObj.is() )
[ + + ]
1792 : : {
1793 [ + - ]: 228 : SdrAShapeObjGeoData aCustomShapeGeoData;
1794 [ + - ]: 228 : ((SdrObjCustomShape*)mpObj.get())->SaveGeoData( aCustomShapeGeoData );
1795 : :
1796 : 228 : sal_Bool bMirroredX = sal_False;
1797 : 228 : sal_Bool bMirroredY = sal_False;
1798 : :
1799 [ + - ]: 228 : if ( mpObj.is() )
1800 : : {
1801 [ + - ]: 228 : bMirroredX = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredX() );
1802 [ + - ]: 228 : bMirroredY = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredY() );
1803 : : }
1804 : : // get aRect, this is the unrotated snaprect
1805 [ + - ]: 228 : Rectangle aRect(((SdrObjCustomShape*)mpObj.get())->GetLogicRect());
1806 : 228 : Rectangle aRectangle( aRect );
1807 : :
1808 [ + + ][ - + ]: 228 : if ( bMirroredX || bMirroredY )
1809 : : { // we have to retrieve the unmirrored rect
1810 : :
1811 : 9 : GeoStat aNewGeo( aCustomShapeGeoData.aGeo );
1812 [ + - ]: 9 : if ( bMirroredX )
1813 : : {
1814 [ + - ]: 9 : Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
1815 [ + - ]: 9 : Rectangle aBoundRect( aPol.GetBoundRect() );
1816 : :
1817 : 9 : Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
1818 : 9 : Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
1819 : : sal_uInt16 i;
1820 [ + - ]: 9 : sal_uInt16 nPntAnz=aPol.GetSize();
1821 [ + + ]: 54 : for (i=0; i<nPntAnz; i++)
1822 : : {
1823 [ + - ][ + - ]: 45 : MirrorPoint(aPol[i],aRef1,aRef2);
1824 : : }
1825 : : // Polygon wenden und etwas schieben
1826 [ + - ]: 9 : Polygon aPol0(aPol);
1827 [ + - ][ + - ]: 9 : aPol[0]=aPol0[1];
1828 [ + - ][ + - ]: 9 : aPol[1]=aPol0[0];
1829 [ + - ][ + - ]: 9 : aPol[2]=aPol0[3];
1830 [ + - ][ + - ]: 9 : aPol[3]=aPol0[2];
1831 [ + - ][ + - ]: 9 : aPol[4]=aPol0[1];
1832 [ + - ][ + - ]: 9 : Poly2Rect(aPol,aRectangle,aNewGeo);
[ + - ]
1833 : : }
1834 [ - + ]: 9 : if ( bMirroredY )
1835 : : {
1836 [ # # ]: 0 : Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
1837 [ # # ]: 0 : Rectangle aBoundRect( aPol.GetBoundRect() );
1838 : :
1839 : 0 : Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
1840 : 0 : Point aRef2( aRef1.X() + 1000, aRef1.Y() );
1841 : : sal_uInt16 i;
1842 [ # # ]: 0 : sal_uInt16 nPntAnz=aPol.GetSize();
1843 [ # # ]: 0 : for (i=0; i<nPntAnz; i++)
1844 : : {
1845 [ # # ][ # # ]: 0 : MirrorPoint(aPol[i],aRef1,aRef2);
1846 : : }
1847 : : // Polygon wenden und etwas schieben
1848 [ # # ]: 0 : Polygon aPol0(aPol);
1849 [ # # ][ # # ]: 0 : aPol[0]=aPol0[1];
1850 [ # # ][ # # ]: 0 : aPol[1]=aPol0[0];
1851 [ # # ][ # # ]: 0 : aPol[2]=aPol0[3];
1852 [ # # ][ # # ]: 0 : aPol[3]=aPol0[2];
1853 [ # # ][ # # ]: 0 : aPol[4]=aPol0[1];
1854 [ # # ][ # # ]: 9 : Poly2Rect( aPol, aRectangle, aNewGeo );
[ # # ]
1855 : : }
1856 : : }
1857 : 228 : Point aPt( aRectangle.TopLeft() );
1858 : :
1859 [ + + ]: 228 : if( mpModel->IsWriter() )
1860 [ + - ]: 33 : aPt -= mpObj->GetAnchorPos();
1861 : :
1862 : 228 : ForceMetricTo100th_mm(aPt);
1863 [ + - ]: 228 : return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
1864 : : }
1865 : : else
1866 [ + - ][ + - ]: 429 : return SvxShape::getPosition();
1867 : : }
1868 : :
1869 : : //----------------------------------------------------------------------
1870 : 309 : void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
1871 : : {
1872 : 309 : SvxShapeText::setPosition(Position);
1873 : 309 : }
1874 : :
1875 : : //----------------------------------------------------------------------
1876 : :
1877 : 459 : awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException)
1878 : : {
1879 : 459 : return SvxShapeText::getSize();
1880 : : }
1881 : :
1882 : : //----------------------------------------------------------------------
1883 : 276 : void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize )
1884 : : throw(beans::PropertyVetoException, uno::RuntimeException)
1885 : : {
1886 : 276 : SvxShapeText::setSize( rSize );
1887 : 276 : }
1888 : :
1889 : : //----------------------------------------------------------------------
1890 : :
1891 : : //----------------------------------------------------------------------
1892 : 2358 : void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1893 : : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
1894 : : {
1895 [ + - ]: 2358 : ::SolarMutexGuard aGuard;
1896 : 2358 : SdrObject* pObject = mpObj.get();
1897 : :
1898 [ + + ][ + + ]: 2358 : sal_Bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) );
1899 : :
1900 : 2358 : sal_Bool bMirroredX = sal_False;
1901 : 2358 : sal_Bool bMirroredY = sal_False;
1902 : :
1903 [ + + ]: 2358 : if ( bCustomShapeGeometry )
1904 : : {
1905 [ + - ]: 219 : bMirroredX = ( ((SdrObjCustomShape*)pObject)->IsMirroredX() );
1906 [ + - ]: 219 : bMirroredY = ( ((SdrObjCustomShape*)pObject)->IsMirroredY() );
1907 : : }
1908 : :
1909 [ + - ]: 2358 : SvxShape::setPropertyValue( aPropertyName, aValue );
1910 : :
1911 [ + + ]: 2358 : if ( bCustomShapeGeometry )
1912 : : {
1913 [ + - ]: 219 : ((SdrObjCustomShape*)pObject)->MergeDefaultAttributes(0);
1914 [ + - ]: 219 : Rectangle aRect( pObject->GetSnapRect() );
1915 : :
1916 : : // #i38892#
1917 [ + - ]: 219 : bool bNeedsMirrorX = ((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX;
1918 [ + - ]: 219 : bool bNeedsMirrorY = ((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY;
1919 : :
1920 : 219 : boost::scoped_ptr< SdrGluePointList > pListCopy;
1921 [ - + ][ + + ]: 219 : if( bNeedsMirrorX || bNeedsMirrorY )
1922 : : {
1923 [ + - ]: 9 : const SdrGluePointList* pList = pObject->GetGluePointList();
1924 [ - + ]: 9 : if( pList )
1925 [ # # ][ # # ]: 0 : pListCopy.reset( new SdrGluePointList(*pList) );
[ # # ]
1926 : : }
1927 : :
1928 [ + + ]: 219 : if ( bNeedsMirrorX )
1929 : : {
1930 : 9 : Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
1931 : 9 : Point aBottom( aTop.X(), aTop.Y() + 1000 );
1932 [ + - ]: 9 : pObject->NbcMirror( aTop, aBottom );
1933 : : // NbcMirroring is flipping the current mirror state,
1934 : : // so we have to set the correct state again
1935 [ + - ]: 9 : ((SdrObjCustomShape*)pObject)->SetMirroredX( bMirroredX ? sal_False : sal_True );
1936 : : }
1937 [ - + ]: 219 : if ( bNeedsMirrorY )
1938 : : {
1939 : 0 : Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
1940 : 0 : Point aRight( aLeft.X() + 1000, aLeft.Y() );
1941 [ # # ]: 0 : pObject->NbcMirror( aLeft, aRight );
1942 : : // NbcMirroring is flipping the current mirror state,
1943 : : // so we have to set the correct state again
1944 [ # # ]: 0 : ((SdrObjCustomShape*)pObject)->SetMirroredY( bMirroredY ? sal_False : sal_True );
1945 : : }
1946 : :
1947 [ - + ]: 219 : if( pListCopy )
1948 : : {
1949 [ # # ]: 0 : SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
1950 [ # # ]: 0 : if(pNewList)
1951 [ # # ]: 0 : *pNewList = *pListCopy;
1952 [ + - ]: 219 : }
1953 [ + - ]: 2358 : }
1954 : 2358 : }
1955 : :
1956 : 14532 : bool SvxCustomShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1957 : : {
1958 [ + + ]: 14532 : switch( pProperty->nWID )
1959 : : {
1960 : : case SDRATTR_ROTATEANGLE:
1961 : : {
1962 : 6 : double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
1963 : 6 : fAngle *= 100;
1964 [ + - ]: 6 : rValue <<= (sal_Int32)fAngle;
1965 : 6 : return true;
1966 : : }
1967 : : default:
1968 : 14532 : return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
1969 : : }
1970 : : }
1971 : : //----------------------------------------------------------------------
1972 : :
1973 : 42 : void SvxCustomShape::createCustomShapeDefaults( const rtl::OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException)
1974 : : {
1975 : 42 : ((SdrObjCustomShape*)mpObj.get())->MergeDefaultAttributes( &rValueType );
1976 : 42 : }
1977 : :
1978 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|