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