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