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 == cppu::UnoType<xint>::get() ) \
70 : aAny <<= Reference< xint >(this)
71 :
72 54690 : SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw() :
73 164070 : SvxShape( pObj, getSvxMapProvider().GetMap(SVXMAP_GROUP), getSvxMapProvider().GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ),
74 164070 : mxPage( pDrawPage )
75 : {
76 54690 : }
77 :
78 :
79 109142 : SvxShapeGroup::~SvxShapeGroup() throw()
80 : {
81 109142 : }
82 :
83 :
84 34283 : void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
85 : {
86 34283 : SvxShape::Create( pNewObj, pNewPage );
87 34283 : mxPage = pNewPage;
88 34283 : }
89 :
90 :
91 722231 : uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType )
92 : throw(uno::RuntimeException, std::exception)
93 : {
94 722231 : return SvxShape::queryInterface( rType );
95 : }
96 :
97 728409 : uno::Any SAL_CALL SvxShapeGroup::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
98 : {
99 728409 : uno::Any aAny;
100 :
101 728409 : QUERYINT( drawing::XShapeGroup );
102 688991 : else QUERYINT( drawing::XShapes );
103 615210 : else QUERYINT( drawing::XShapes2 );
104 614280 : else QUERYINT( container::XIndexAccess );
105 612625 : else QUERYINT( container::XElementAccess );
106 : else
107 612625 : return SvxShape::queryAggregation( rType );
108 :
109 115784 : return aAny;
110 : }
111 :
112 1936655 : void SAL_CALL SvxShapeGroup::acquire() throw ( )
113 : {
114 1936655 : SvxShape::acquire();
115 1936655 : }
116 :
117 1936480 : void SAL_CALL SvxShapeGroup::release() throw ( )
118 : {
119 1936480 : SvxShape::release();
120 1936480 : }
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 69129 : OUString SAL_CALL SvxShapeGroup::getShapeType()
138 : throw( uno::RuntimeException, std::exception )
139 : {
140 69129 : return SvxShape::getShapeType();
141 : }
142 :
143 38071 : awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException, std::exception)
144 : {
145 38071 : return SvxShape::getPosition();
146 : }
147 :
148 :
149 38249 : void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException, std::exception)
150 : {
151 38249 : SvxShape::setPosition(Position);
152 38249 : }
153 :
154 :
155 :
156 39260 : awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException, std::exception)
157 : {
158 39260 : return SvxShape::getSize();
159 : }
160 :
161 :
162 68064 : void SAL_CALL SvxShapeGroup::setSize( const awt::Size& rSize )
163 : throw(beans::PropertyVetoException, uno::RuntimeException, std::exception)
164 : {
165 68064 : SvxShape::setSize( rSize );
166 68064 : }
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 85171 : void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape, size_t nPos )
185 : {
186 85171 : if (!mpObj.is() || !mxPage.is())
187 : {
188 : OSL_FAIL("could not add XShape to group shape!");
189 0 : return;
190 : }
191 :
192 85171 : SvxShape* pShape = SvxShape::getImplementation( xShape );
193 85171 : if (!pShape)
194 : {
195 : OSL_FAIL("could not add XShape to group shape!");
196 7 : return;
197 : }
198 :
199 85164 : SdrObject* pSdrShape = pShape->GetSdrObject();
200 85164 : if( pSdrShape == NULL )
201 85164 : pSdrShape = mxPage->_CreateSdrObject( xShape );
202 :
203 85164 : if( pSdrShape->IsInserted() )
204 0 : pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
205 :
206 85164 : mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
207 85164 : 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 85164 : pShape->Create( pSdrShape, mxPage.get() );
221 :
222 85164 : if( mpModel )
223 85164 : mpModel->SetChanged();
224 : }
225 :
226 : // XShapes
227 84241 : void SAL_CALL SvxShapeGroup::add( const uno::Reference< drawing::XShape >& xShape )
228 : throw( uno::RuntimeException, std::exception )
229 : {
230 84241 : ::SolarMutexGuard aGuard;
231 :
232 : // Add to the top of the stack (i.e. bottom of the list) by default.
233 84241 : addUnoShape(xShape, SAL_MAX_SIZE);
234 84241 : }
235 :
236 :
237 16420 : void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xShape )
238 : throw( uno::RuntimeException, std::exception )
239 : {
240 16420 : ::SolarMutexGuard aGuard;
241 :
242 16420 : SdrObject* pSdrShape = NULL;
243 16420 : SvxShape* pShape = SvxShape::getImplementation( xShape );
244 :
245 16420 : if( pShape )
246 16420 : pSdrShape = pShape->GetSdrObject();
247 :
248 16420 : if( !mpObj.is() || pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
249 0 : throw uno::RuntimeException();
250 :
251 16420 : SdrObjList& rList = *pSdrShape->GetObjList();
252 :
253 16420 : const size_t nObjCount = rList.GetObjCount();
254 16420 : size_t nObjNum = 0;
255 52444 : while( nObjNum < nObjCount )
256 : {
257 36024 : if(rList.GetObj( nObjNum ) == pSdrShape )
258 16420 : break;
259 19604 : nObjNum++;
260 : }
261 :
262 16420 : 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 16420 : SdrViewIter aIter( pSdrShape );
268 :
269 16420 : 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 16420 : SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
278 16420 : SdrObject::Free( pObject );
279 : }
280 : else
281 : {
282 : DBG_ASSERT( false, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
283 : }
284 :
285 16420 : if( mpModel )
286 16420 : mpModel->SetChanged();
287 16420 : }
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 930 : void SAL_CALL SvxShapeGroup::addBottom( const uno::Reference< drawing::XShape >& xShape )
299 : throw( uno::RuntimeException, std::exception )
300 : {
301 930 : SolarMutexGuard aGuard;
302 :
303 : // Add to the bottom of the stack (i.e. top of the list).
304 930 : addUnoShape(xShape, 0);
305 930 : }
306 :
307 : // XIndexAccess
308 :
309 :
310 68300 : sal_Int32 SAL_CALL SvxShapeGroup::getCount() throw( uno::RuntimeException, std::exception )
311 : {
312 68300 : ::SolarMutexGuard aGuard;
313 :
314 68300 : sal_Int32 nRetval = 0;
315 :
316 68300 : if(mpObj.is() && mpObj->GetSubList())
317 68300 : nRetval = mpObj->GetSubList()->GetObjCount();
318 : else
319 0 : throw uno::RuntimeException();
320 :
321 68300 : return nRetval;
322 : }
323 :
324 :
325 80968 : uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
326 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
327 : {
328 80968 : ::SolarMutexGuard aGuard;
329 :
330 80968 : if( !mpObj.is() || mpObj->GetSubList() == NULL )
331 0 : throw uno::RuntimeException();
332 :
333 80968 : if( Index<0 || mpObj->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
334 0 : throw lang::IndexOutOfBoundsException();
335 :
336 80968 : SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
337 :
338 80968 : if(pDestObj == NULL)
339 0 : throw lang::IndexOutOfBoundsException();
340 :
341 161936 : Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY );
342 161936 : 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 278 : sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException, std::exception )
355 : {
356 278 : ::SolarMutexGuard aGuard;
357 :
358 278 : return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
359 : }
360 :
361 :
362 : // ::com::sun::star::lang::XServiceInfo
363 :
364 686 : uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
365 : throw(uno::RuntimeException, std::exception)
366 : {
367 686 : return SvxShape::getSupportedServiceNames();
368 : }
369 61 : SvxShapeConnector::SvxShapeConnector( SdrObject* pObj ) throw() :
370 61 : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONNECTOR), getSvxMapProvider().GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
371 : {
372 61 : }
373 :
374 :
375 122 : SvxShapeConnector::~SvxShapeConnector() throw()
376 : {
377 122 : }
378 :
379 :
380 :
381 739 : uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType )
382 : throw(uno::RuntimeException, std::exception)
383 : {
384 739 : return SvxShapeText::queryInterface( rType );
385 : }
386 :
387 1578 : uno::Any SAL_CALL SvxShapeConnector::queryAggregation( const uno::Type & rType )
388 : throw(uno::RuntimeException, std::exception)
389 : {
390 1578 : uno::Any aAny;
391 :
392 1578 : QUERYINT( drawing::XConnectorShape );
393 : else
394 1578 : return SvxShapeText::queryAggregation( rType );
395 :
396 0 : return aAny;
397 : }
398 :
399 4847 : void SAL_CALL SvxShapeConnector::acquire() throw ( )
400 : {
401 4847 : SvxShapeText::acquire();
402 4847 : }
403 :
404 4847 : void SAL_CALL SvxShapeConnector::release() throw ( )
405 : {
406 4847 : SvxShapeText::release();
407 4847 : }
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 57 : OUString SAL_CALL SvxShapeConnector::getShapeType()
426 : throw( uno::RuntimeException, std::exception )
427 : {
428 57 : return SvxShapeText::getShapeType();
429 : }
430 :
431 1 : awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException, std::exception)
432 : {
433 1 : return SvxShapeText::getPosition();
434 : }
435 :
436 :
437 1 : void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException, std::exception)
438 : {
439 1 : SvxShapeText::setPosition(Position);
440 1 : }
441 :
442 :
443 :
444 82 : awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException, std::exception)
445 : {
446 82 : return SvxShapeText::getSize();
447 : }
448 :
449 :
450 1 : void SAL_CALL SvxShapeConnector::setSize( const awt::Size& rSize )
451 : throw(beans::PropertyVetoException, uno::RuntimeException, std::exception)
452 : {
453 1 : SvxShapeText::setSize( rSize );
454 1 : }
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 430 : SvxShapeControl::SvxShapeControl( SdrObject* pObj ) throw() :
525 430 : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CONTROL), getSvxMapProvider().GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) )
526 : {
527 430 : setShapeKind( OBJ_UNO );
528 430 : }
529 :
530 :
531 860 : SvxShapeControl::~SvxShapeControl() throw()
532 : {
533 860 : }
534 :
535 :
536 5770 : uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType )
537 : throw(uno::RuntimeException, std::exception)
538 : {
539 5770 : return SvxShapeText::queryInterface( rType );
540 : }
541 :
542 4809 : uno::Any SAL_CALL SvxShapeControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException, std::exception)
543 : {
544 4809 : uno::Any aAny;
545 :
546 4809 : QUERYINT( drawing::XControlShape );
547 : else
548 4114 : return SvxShapeText::queryAggregation( rType );
549 :
550 695 : return aAny;
551 : }
552 :
553 20078 : void SAL_CALL SvxShapeControl::acquire() throw ( )
554 : {
555 20078 : SvxShapeText::acquire();
556 20078 : }
557 :
558 20078 : void SAL_CALL SvxShapeControl::release() throw ( )
559 : {
560 20078 : SvxShapeText::release();
561 20078 : }
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 28 : OUString SAL_CALL SvxShapeControl::getShapeType()
580 : throw( uno::RuntimeException, std::exception )
581 : {
582 28 : return SvxShapeText::getShapeType();
583 : }
584 :
585 290 : awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException, std::exception)
586 : {
587 290 : return SvxShapeText::getPosition();
588 : }
589 :
590 :
591 785 : void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException, std::exception)
592 : {
593 785 : SvxShapeText::setPosition(Position);
594 785 : }
595 :
596 :
597 :
598 2 : awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException, std::exception)
599 : {
600 2 : return SvxShapeText::getSize();
601 : }
602 :
603 :
604 562 : void SAL_CALL SvxShapeControl::setSize( const awt::Size& rSize )
605 : throw(beans::PropertyVetoException, uno::RuntimeException, std::exception)
606 : {
607 562 : SvxShapeText::setSize( rSize );
608 562 : }
609 :
610 :
611 : // XControlShape
612 :
613 730 : Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
614 : throw( uno::RuntimeException, std::exception )
615 : {
616 730 : ::SolarMutexGuard aGuard;
617 :
618 730 : Reference< awt::XControlModel > xModel;
619 :
620 730 : SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
621 730 : if( pUnoObj )
622 729 : xModel = pUnoObj->GetUnoControlModel();
623 :
624 730 : return xModel;
625 : }
626 :
627 :
628 338 : void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >& xControl )
629 : throw( uno::RuntimeException, std::exception )
630 : {
631 338 : ::SolarMutexGuard aGuard;
632 :
633 338 : SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
634 338 : if( pUnoObj )
635 338 : pUnoObj->SetUnoControlModel( xControl );
636 :
637 338 : if( mpModel )
638 42 : mpModel->SetChanged();
639 338 : }
640 :
641 : // XServiceInfo
642 1 : uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
643 : {
644 1 : 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("CharBackTransparent"), RTL_CONSTASCII_STRINGPARAM("CharBackTransparent") },
673 : { RTL_CONSTASCII_STRINGPARAM("CharRelief"), RTL_CONSTASCII_STRINGPARAM("FontRelief") },
674 : { RTL_CONSTASCII_STRINGPARAM("CharUnderlineColor"), RTL_CONSTASCII_STRINGPARAM("TextLineColor") },
675 : { RTL_CONSTASCII_STRINGPARAM(UNO_NAME_EDIT_PARA_ADJUST), RTL_CONSTASCII_STRINGPARAM("Align") },
676 : { RTL_CONSTASCII_STRINGPARAM("TextVerticalAdjust"), RTL_CONSTASCII_STRINGPARAM("VerticalAlign") },
677 : { RTL_CONSTASCII_STRINGPARAM("ControlBackground"), RTL_CONSTASCII_STRINGPARAM("BackgroundColor") },
678 : { RTL_CONSTASCII_STRINGPARAM("ControlSymbolColor"), RTL_CONSTASCII_STRINGPARAM("SymbolColor") },
679 : { RTL_CONSTASCII_STRINGPARAM("ControlBorder"), RTL_CONSTASCII_STRINGPARAM("Border") },
680 : { RTL_CONSTASCII_STRINGPARAM("ControlBorderColor"), RTL_CONSTASCII_STRINGPARAM("BorderColor") },
681 : { RTL_CONSTASCII_STRINGPARAM("ControlTextEmphasis"), RTL_CONSTASCII_STRINGPARAM("FontEmphasisMark") },
682 : { RTL_CONSTASCII_STRINGPARAM("ImageScaleMode"), RTL_CONSTASCII_STRINGPARAM("ScaleMode") },
683 : { RTL_CONSTASCII_STRINGPARAM("ControlWritingMode"), RTL_CONSTASCII_STRINGPARAM("WritingMode") },
684 : //added for exporting OCX control
685 : { RTL_CONSTASCII_STRINGPARAM("ControlTypeinMSO"), RTL_CONSTASCII_STRINGPARAM("ControlTypeinMSO") },
686 : { RTL_CONSTASCII_STRINGPARAM("ObjIDinMSO"), RTL_CONSTASCII_STRINGPARAM("ObjIDinMSO") },
687 : { RTL_CONSTASCII_STRINGPARAM("CharCaseMap"), RTL_CONSTASCII_STRINGPARAM("CharCaseMap") },
688 : { NULL,0, NULL, 0 }
689 : };
690 :
691 : namespace
692 : {
693 263 : static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
694 : {
695 263 : sal_uInt16 i = 0;
696 8153 : while( SvxShapeControlPropertyMapping[i].mpAPIName )
697 : {
698 7627 : if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 )
699 : {
700 102 : rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US );
701 : }
702 7627 : ++i;
703 : }
704 263 : return !rInternalName.isEmpty();
705 : }
706 :
707 : struct EnumConversionMap
708 : {
709 : sal_Int16 nAPIValue;
710 : sal_Int16 nFormValue;
711 : };
712 :
713 : EnumConversionMap aMapAdjustToAlign[] =
714 : {
715 : // note that order matters:
716 : // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
717 : // and use the first matching entry
718 : {style::ParagraphAdjust_LEFT, (sal_Int16)awt::TextAlign::LEFT},
719 : {style::ParagraphAdjust_CENTER, (sal_Int16)awt::TextAlign::CENTER},
720 : {style::ParagraphAdjust_RIGHT, (sal_Int16)awt::TextAlign::RIGHT},
721 : {style::ParagraphAdjust_BLOCK, (sal_Int16)awt::TextAlign::RIGHT},
722 : {style::ParagraphAdjust_STRETCH, (sal_Int16)awt::TextAlign::LEFT},
723 : {-1,-1}
724 : };
725 :
726 2 : static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap )
727 : {
728 2 : sal_Int16 nValue = sal_Int16();
729 2 : OSL_VERIFY( _rValue >>= nValue );
730 :
731 2 : const EnumConversionMap* pEntry = _pMap;
732 6 : while ( pEntry && ( pEntry->nFormValue != -1 ) )
733 : {
734 4 : if ( nValue == pEntry->nFormValue )
735 : {
736 2 : _rValue <<= pEntry->nAPIValue;
737 4 : return;
738 : }
739 2 : ++pEntry;
740 : }
741 : }
742 :
743 19 : static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap )
744 : {
745 19 : sal_Int32 nValue = 0;
746 19 : OSL_VERIFY( _rValue >>= nValue );
747 :
748 19 : const EnumConversionMap* pEntry = _pMap;
749 49 : while ( pEntry && ( pEntry->nAPIValue != -1 ) )
750 : {
751 30 : if ( nValue == pEntry->nAPIValue )
752 : {
753 19 : _rValue <<= pEntry->nFormValue;
754 38 : return;
755 : }
756 11 : ++pEntry;
757 : }
758 : }
759 :
760 2 : static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue )
761 : {
762 2 : lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign );
763 2 : }
764 :
765 19 : static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue )
766 : {
767 19 : lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign );
768 19 : }
769 :
770 0 : void convertVerticalAdjustToVerticalAlign( Any& _rValue )
771 : {
772 0 : if ( !_rValue.hasValue() )
773 0 : return;
774 :
775 0 : drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
776 0 : style::VerticalAlignment eAlign = style::VerticalAlignment_TOP;
777 0 : if ( !( _rValue >>= eAdjust ) )
778 0 : throw lang::IllegalArgumentException();
779 0 : switch ( eAdjust )
780 : {
781 0 : case drawing::TextVerticalAdjust_TOP: eAlign = style::VerticalAlignment_TOP; break;
782 0 : case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break;
783 0 : default: eAlign = style::VerticalAlignment_MIDDLE; break;
784 : }
785 0 : _rValue <<= eAlign;
786 : }
787 :
788 0 : void convertVerticalAlignToVerticalAdjust( Any& _rValue )
789 : {
790 0 : if ( !_rValue.hasValue() )
791 0 : return;
792 0 : style::VerticalAlignment eAlign = style::VerticalAlignment_TOP;
793 0 : drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
794 0 : OSL_VERIFY( _rValue >>= eAlign );
795 0 : switch ( eAlign )
796 : {
797 0 : case style::VerticalAlignment_TOP: eAdjust = drawing::TextVerticalAdjust_TOP; break;
798 0 : case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break;
799 0 : default: eAdjust = drawing::TextVerticalAdjust_CENTER; break;
800 : }
801 0 : _rValue <<= eAdjust;
802 : }
803 : }
804 :
805 169 : void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
806 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException, std::exception)
807 : {
808 169 : OUString aFormsName;
809 169 : if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
810 : {
811 44 : uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
812 44 : if( xControl.is() )
813 : {
814 44 : uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
815 44 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
816 : {
817 44 : uno::Any aConvertedValue( aValue );
818 44 : if ( aFormsName == "FontSlant" )
819 : {
820 : awt::FontSlant nSlant;
821 1 : if( !(aValue >>= nSlant ) )
822 0 : throw lang::IllegalArgumentException();
823 1 : aConvertedValue <<= (sal_Int16)nSlant;
824 : }
825 43 : else if ( aFormsName == "Align" )
826 : {
827 19 : lcl_convertParaAdjustmentToTextAlignment( aConvertedValue );
828 : }
829 24 : else if ( aFormsName == "VerticalAlign" )
830 : {
831 0 : convertVerticalAdjustToVerticalAlign( aConvertedValue );
832 : }
833 :
834 44 : xControl->setPropertyValue( aFormsName, aConvertedValue );
835 44 : }
836 44 : }
837 : }
838 : else
839 : {
840 125 : SvxShape::setPropertyValue( aPropertyName, aValue );
841 169 : }
842 169 : }
843 :
844 30 : uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName )
845 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
846 : {
847 30 : OUString aFormsName;
848 30 : if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
849 : {
850 2 : uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
851 :
852 4 : uno::Any aValue;
853 2 : if( xControl.is() )
854 : {
855 2 : uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
856 2 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
857 : {
858 2 : aValue = xControl->getPropertyValue( aFormsName );
859 2 : if ( aFormsName == "FontSlant" )
860 : {
861 0 : awt::FontSlant eSlant = awt::FontSlant_NONE;
862 0 : sal_Int16 nSlant = sal_Int16();
863 0 : if ( aValue >>= nSlant )
864 : {
865 0 : eSlant = (awt::FontSlant)nSlant;
866 : }
867 : else
868 : {
869 0 : OSL_VERIFY( aValue >>= eSlant );
870 : }
871 0 : aValue <<= eSlant;
872 : }
873 2 : else if ( aFormsName == "Align" )
874 : {
875 2 : lcl_convertTextAlignmentToParaAdjustment( aValue );
876 : }
877 0 : else if ( aFormsName == "VerticalAlign" )
878 : {
879 0 : convertVerticalAlignToVerticalAdjust( aValue );
880 : }
881 2 : }
882 : }
883 :
884 4 : return aValue;
885 : }
886 : else
887 : {
888 28 : return SvxShape::getPropertyValue( aPropertyName );
889 30 : }
890 :
891 : }
892 :
893 : // XPropertyState
894 64 : beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
895 : {
896 64 : OUString aFormsName;
897 64 : if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
898 : {
899 56 : uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
900 112 : uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
901 :
902 56 : if( xControl.is() && xPropSet.is() )
903 : {
904 56 : uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
905 56 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
906 : {
907 42 : return xControl->getPropertyState( aFormsName );
908 14 : }
909 : }
910 :
911 70 : return beans::PropertyState_DEFAULT_VALUE;
912 : }
913 : else
914 : {
915 8 : return SvxShape::getPropertyState( PropertyName );
916 64 : }
917 : }
918 :
919 0 : void SAL_CALL SvxShapeControl::setPropertyToDefault( const OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
920 : {
921 0 : OUString aFormsName;
922 0 : if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
923 : {
924 0 : uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
925 0 : uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
926 :
927 0 : if( xControl.is() && xPropSet.is() )
928 : {
929 0 : uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
930 0 : if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
931 : {
932 0 : xControl->setPropertyToDefault( aFormsName );
933 0 : }
934 0 : }
935 : }
936 : else
937 : {
938 0 : SvxShape::setPropertyToDefault( PropertyName );
939 0 : }
940 0 : }
941 :
942 0 : uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const OUString& aPropertyName )
943 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
944 : {
945 0 : OUString aFormsName;
946 0 : if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
947 : {
948 0 : uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
949 :
950 0 : if( xControl.is() )
951 : {
952 0 : Any aDefault( xControl->getPropertyDefault( aFormsName ) );
953 0 : if ( aFormsName == "FontSlant" )
954 : {
955 0 : sal_Int16 nSlant( 0 );
956 0 : aDefault >>= nSlant;
957 0 : aDefault <<= (awt::FontSlant)nSlant;
958 : }
959 0 : else if ( aFormsName == "Align" )
960 : {
961 0 : lcl_convertTextAlignmentToParaAdjustment( aDefault );
962 : }
963 0 : else if ( aFormsName == "VerticalAlign" )
964 : {
965 0 : convertVerticalAlignToVerticalAdjust( aDefault );
966 : }
967 0 : return aDefault;
968 : }
969 :
970 0 : throw beans::UnknownPropertyException();
971 : }
972 : else
973 : {
974 0 : return SvxShape::getPropertyDefault( aPropertyName );
975 0 : }
976 : }
977 :
978 27 : SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw()
979 27 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_DIMENSIONING), getSvxMapProvider().GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) )
980 : {
981 27 : }
982 :
983 :
984 54 : SvxShapeDimensioning::~SvxShapeDimensioning() throw()
985 : {
986 54 : }
987 :
988 : // ::com::sun::star::lang::XServiceInfo
989 6 : uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
990 : {
991 6 : return SvxShapeText::getSupportedServiceNames();
992 : }
993 219 : SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
994 219 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CIRCLE), getSvxMapProvider().GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
995 : {
996 219 : }
997 :
998 :
999 438 : SvxShapeCircle::~SvxShapeCircle() throw()
1000 : {
1001 438 : }
1002 :
1003 : // ::com::sun::star::lang::XServiceInfo
1004 : // XServiceInfo
1005 6 : uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
1006 : {
1007 6 : return SvxShapeText::getSupportedServiceNames();
1008 : }
1009 : #include <svx/svdopath.hxx>
1010 :
1011 :
1012 35611 : SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
1013 : throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
1014 106833 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGON), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
1015 106833 : , mePolygonKind( eNew )
1016 : {
1017 35611 : }
1018 :
1019 :
1020 71220 : SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
1021 : {
1022 71220 : }
1023 :
1024 17131 : basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw()
1025 : {
1026 17131 : basegfx::B2DPolyPolygon aRetval;
1027 :
1028 : // get pointer to internal sequences
1029 17131 : const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray();
1030 17131 : const drawing::PointSequence* pInnerSeqEnd = pInnerSequence + pOuterSequence->getLength();
1031 :
1032 57905 : for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence)
1033 : {
1034 : // prepare new polygon
1035 40774 : basegfx::B2DPolygon aNewPolygon;
1036 :
1037 : // get pointer to arrays
1038 40774 : const awt::Point* pArray = pInnerSequence->getConstArray();
1039 40774 : const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength();
1040 :
1041 169677 : for(;pArray != pArrayEnd;++pArray)
1042 : {
1043 128903 : aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
1044 : }
1045 :
1046 : // check for closed state flag
1047 40774 : basegfx::tools::checkClosed(aNewPolygon);
1048 :
1049 : // add new subpolygon
1050 40774 : aRetval.append(aNewPolygon);
1051 40774 : }
1052 :
1053 17131 : return aRetval;
1054 : }
1055 :
1056 :
1057 :
1058 247405 : 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)
1059 : {
1060 247405 : switch( pProperty->nWID )
1061 : {
1062 : case OWN_ATTR_VALUE_POLYPOLYGON:
1063 : {
1064 16594 : if( rValue.getValue() && (rValue.getValueType() == cppu::UnoType<drawing::PointSequenceSequence>::get() ) )
1065 : {
1066 16594 : basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( static_cast<drawing::PointSequenceSequence const *>(rValue.getValue())));
1067 16594 : SetPolygon(aNewPolyPolygon);
1068 16594 : return true;
1069 : }
1070 0 : break;
1071 : }
1072 : case OWN_ATTR_BASE_GEOMETRY:
1073 : {
1074 537 : if( rValue.getValue() && (rValue.getValueType() == cppu::UnoType<drawing::PointSequenceSequence>::get()))
1075 : {
1076 537 : if( mpObj.is() )
1077 : {
1078 537 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1079 1074 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1080 :
1081 537 : mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1082 537 : aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon(static_cast<drawing::PointSequenceSequence const *>(rValue.getValue()));
1083 1074 : mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1084 : }
1085 537 : return true;
1086 : }
1087 0 : break;
1088 : }
1089 : case OWN_ATTR_VALUE_POLYGON:
1090 : {
1091 0 : if( rValue.getValue() && (rValue.getValueType() == cppu::UnoType<drawing::PointSequenceSequence>::get() ))
1092 : {
1093 0 : drawing::PointSequence const * pSequence = static_cast<drawing::PointSequence const *>(rValue.getValue());
1094 :
1095 : // prepare new polygon
1096 0 : basegfx::B2DPolygon aNewPolygon;
1097 :
1098 : // get pointer to arrays
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 : // set polygon
1111 0 : SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon));
1112 0 : return true;
1113 : }
1114 0 : break;
1115 : }
1116 : default:
1117 230274 : return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1118 : }
1119 :
1120 0 : throw lang::IllegalArgumentException();
1121 : }
1122 :
1123 198 : void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval )
1124 : {
1125 198 : if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() )
1126 0 : rRetval.realloc( rPolyPoly.count() );
1127 :
1128 : // get pointer to external arrays
1129 198 : drawing::PointSequence* pOuterSequence = rRetval.getArray();
1130 :
1131 396 : for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++)
1132 : {
1133 : // get single polygon
1134 198 : 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 198 : const sal_uInt32 nPointCount(aPoly.count());
1140 198 : const bool bIsClosed(aPoly.isClosed());
1141 :
1142 : // create space in arrays
1143 198 : pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount);
1144 :
1145 : // get pointer to arrays
1146 198 : awt::Point* pInnerSequence = pOuterSequence->getArray();
1147 :
1148 6246 : for(sal_uInt32 b(0L); b < nPointCount; b++)
1149 : {
1150 6048 : const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
1151 6048 : *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
1152 6048 : pInnerSequence++;
1153 6048 : }
1154 :
1155 : // #i75974# copy first point
1156 198 : if(bIsClosed)
1157 : {
1158 135 : *pInnerSequence = *pOuterSequence->getArray();
1159 : }
1160 :
1161 198 : pOuterSequence++;
1162 198 : }
1163 198 : }
1164 :
1165 :
1166 :
1167 4177 : 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 4177 : switch( pProperty->nWID )
1170 : {
1171 : case OWN_ATTR_VALUE_POLYPOLYGON:
1172 : {
1173 : // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1174 179 : const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1175 358 : drawing::PointSequenceSequence aRetval( rPolyPoly.count() );
1176 :
1177 179 : B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval );
1178 :
1179 179 : rValue <<= aRetval;
1180 358 : break;
1181 : }
1182 : case OWN_ATTR_BASE_GEOMETRY:
1183 : {
1184 : // pack a tools::PolyPolygon in struct PolyPolygon
1185 19 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1186 38 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1187 :
1188 19 : if(mpObj.is())
1189 19 : mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1190 :
1191 38 : drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
1192 19 : B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
1193 19 : rValue <<= aRetval;
1194 38 : break;
1195 : }
1196 : case OWN_ATTR_VALUE_POLYGON:
1197 : {
1198 : // pack a tools::PolyPolygon in a struct tools::PolyPolygon
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 : // get single polygon
1210 0 : const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L));
1211 :
1212 : // get pointer to arrays
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 7 : rValue <<= GetPolygonKind();
1228 7 : break;
1229 : }
1230 : default:
1231 3972 : return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1232 : }
1233 :
1234 205 : return true;
1235 : }
1236 :
1237 :
1238 :
1239 :
1240 16594 : void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw(uno::RuntimeException)
1241 : {
1242 16594 : ::SolarMutexGuard aGuard;
1243 :
1244 16594 : if(mpObj.is())
1245 16594 : static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
1246 16594 : }
1247 :
1248 :
1249 179 : basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
1250 : {
1251 179 : ::SolarMutexGuard aGuard;
1252 :
1253 179 : if(mpObj.is())
1254 : {
1255 179 : return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
1256 : }
1257 : else
1258 : {
1259 0 : return basegfx::B2DPolyPolygon();
1260 179 : }
1261 : }
1262 :
1263 : // ::com::sun::star::lang::XServiceInfo
1264 586 : uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
1265 : {
1266 586 : return SvxShapeText::getSupportedServiceNames();
1267 : }
1268 :
1269 : #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
1270 : #include <com/sun/star/drawing/FlagSequence.hpp>
1271 :
1272 1610 : SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw()
1273 4830 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_POLYPOLYGONBEZIER), getSvxMapProvider().GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) )
1274 4830 : , mePolygonKind( eNew )
1275 : {
1276 1610 : }
1277 :
1278 :
1279 3220 : SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw()
1280 : {
1281 3220 : }
1282 :
1283 :
1284 :
1285 11934 : 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 11934 : switch( pProperty->nWID )
1288 : {
1289 : case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1290 : {
1291 593 : if( rValue.getValue() && (rValue.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get()) )
1292 : {
1293 : basegfx::B2DPolyPolygon aNewPolyPolygon(
1294 : basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
1295 593 : *static_cast<drawing::PolyPolygonBezierCoords const *>(rValue.getValue())));
1296 593 : SetPolygon(aNewPolyPolygon);
1297 593 : return true;
1298 : }
1299 0 : break;
1300 : }
1301 : case OWN_ATTR_BASE_GEOMETRY:
1302 : {
1303 273 : if( rValue.getValue() && (rValue.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get()) )
1304 : {
1305 273 : if( mpObj.is() )
1306 : {
1307 273 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1308 546 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1309 :
1310 273 : mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1311 546 : aNewPolyPolygon = basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
1312 546 : *static_cast<drawing::PolyPolygonBezierCoords const *>(rValue.getValue()));
1313 546 : mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1314 : }
1315 273 : return true;
1316 : }
1317 0 : break;
1318 : }
1319 : default:
1320 11068 : return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1321 : }
1322 :
1323 0 : throw IllegalArgumentException();
1324 : }
1325 :
1326 :
1327 :
1328 2807 : 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 2807 : switch( pProperty->nWID )
1331 : {
1332 : case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
1333 : {
1334 : // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1335 143 : const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
1336 286 : drawing::PolyPolygonBezierCoords aRetval;
1337 143 : basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval);
1338 :
1339 143 : rValue <<= aRetval;
1340 286 : break;
1341 : }
1342 : case OWN_ATTR_BASE_GEOMETRY:
1343 : {
1344 : // pack a tools::PolyPolygon in a struct tools::PolyPolygon
1345 4 : basegfx::B2DPolyPolygon aNewPolyPolygon;
1346 8 : basegfx::B2DHomMatrix aNewHomogenMatrix;
1347 4 : mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
1348 8 : drawing::PolyPolygonBezierCoords aRetval;
1349 4 : basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
1350 :
1351 4 : rValue <<= aRetval;
1352 8 : break;
1353 : }
1354 : case OWN_ATTR_VALUE_POLYGONKIND:
1355 : {
1356 4 : rValue <<= GetPolygonKind();
1357 4 : break;
1358 : }
1359 : default:
1360 2656 : return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
1361 : }
1362 151 : return true;
1363 : }
1364 :
1365 :
1366 :
1367 :
1368 593 : void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw(uno::RuntimeException)
1369 : {
1370 593 : ::SolarMutexGuard aGuard;
1371 :
1372 593 : if(mpObj.is())
1373 593 : static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
1374 593 : }
1375 :
1376 :
1377 143 : basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
1378 : {
1379 143 : ::SolarMutexGuard aGuard;
1380 :
1381 143 : if(mpObj.is())
1382 : {
1383 143 : return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
1384 : }
1385 : else
1386 : {
1387 0 : return basegfx::B2DPolyPolygon();
1388 143 : }
1389 : }
1390 :
1391 :
1392 : // ::com::sun::star::lang::XServiceInfo
1393 1145 : uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
1394 : {
1395 1145 : 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 938 : SvxGraphicObject::SvxGraphicObject( SdrObject* pObj, OUString const & referer ) throw()
1409 938 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_GRAPHICOBJECT), getSvxMapProvider().GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) ), referer_(referer)
1410 : {
1411 938 : }
1412 :
1413 1876 : SvxGraphicObject::~SvxGraphicObject() throw()
1414 : {
1415 1876 : }
1416 :
1417 9037 : 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 9037 : bool bOk = false;
1420 9037 : switch( pProperty->nWID )
1421 : {
1422 : case OWN_ATTR_VALUE_FILLBITMAP:
1423 : {
1424 0 : if( rValue.getValue() )
1425 : {
1426 0 : if( rValue.getValueType() == cppu::UnoType<uno::Sequence< sal_Int8 >>::get() )
1427 : {
1428 0 : uno::Sequence<sal_Int8> const * pSeq( static_cast<uno::Sequence<sal_Int8> const *>(rValue.getValue()) );
1429 0 : SvMemoryStream aMemStm;
1430 0 : Graphic aGraphic;
1431 :
1432 0 : aMemStm.SetBuffer( const_cast<css::uno::Sequence<sal_Int8> *>(pSeq)->getArray(), 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 : // pack bitmap in the object
1452 0 : Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
1453 0 : if( xBmp.is() )
1454 : {
1455 : // apply bitmap
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 586 : OUString aURL;
1467 586 : if( rValue >>= aURL )
1468 : {
1469 586 : if( aURL.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) )
1470 : {
1471 : // graphic manager url
1472 512 : aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
1473 512 : OUString aTmpStr(aURL);
1474 1024 : OString aUniqueID(OUStringToOString(aTmpStr, RTL_TEXTENCODING_UTF8));
1475 1024 : 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 512 : if( mpObj.is() )
1481 : {
1482 512 : static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink();
1483 512 : static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj );
1484 512 : }
1485 : }
1486 74 : else if( !aURL.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) )
1487 : {
1488 : // normal link
1489 12 : OUString aFilterName;
1490 12 : const SfxFilter* pSfxFilter = NULL;
1491 24 : SfxMedium aSfxMedium( aURL, referer_, StreamMode::READ | StreamMode::SHARE_DENYNONE );
1492 :
1493 12 : SfxGetpApp()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SfxFilterFlags::IMPORT, SFX_FILTER_NOTINSTALLED | SfxFilterFlags::EXECUTABLE );
1494 :
1495 12 : if( !pSfxFilter )
1496 : {
1497 6 : INetURLObject aURLObj( aURL );
1498 :
1499 6 : if( aURLObj.GetProtocol() == INetProtocol::NotValid )
1500 : {
1501 0 : OUString aValidURL;
1502 :
1503 0 : if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) )
1504 0 : aURLObj = INetURLObject( aValidURL );
1505 : }
1506 :
1507 6 : if( aURLObj.GetProtocol() != INetProtocol::NotValid )
1508 : {
1509 6 : GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter();
1510 6 : aFilterName = rGrfFilter.GetImportFormatName( rGrfFilter.GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
1511 6 : }
1512 : }
1513 : else
1514 6 : 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 12 : if( mpObj.is() )
1520 24 : static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, referer_, aFilterName );
1521 :
1522 : }
1523 586 : bOk = true;
1524 : }
1525 586 : break;
1526 : }
1527 :
1528 : case OWN_ATTR_GRAFSTREAMURL:
1529 : {
1530 98 : OUString aStreamURL;
1531 :
1532 98 : if( rValue >>= aStreamURL )
1533 : {
1534 98 : if( !aStreamURL.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) )
1535 26 : aStreamURL.clear();
1536 :
1537 98 : if( mpObj.is() )
1538 : {
1539 98 : static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
1540 : }
1541 98 : bOk = true;
1542 : }
1543 98 : break;
1544 : }
1545 :
1546 : case OWN_ATTR_VALUE_GRAPHIC:
1547 : {
1548 333 : Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
1549 333 : if( xGraphic.is() )
1550 : {
1551 333 : static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
1552 333 : bOk = true;
1553 : }
1554 333 : break;
1555 : }
1556 : default:
1557 8020 : return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
1558 : }
1559 :
1560 1017 : if( !bOk )
1561 0 : throw lang::IllegalArgumentException();
1562 :
1563 1017 : if( mpModel )
1564 1017 : mpModel->SetChanged();
1565 :
1566 1017 : return true;
1567 : }
1568 :
1569 :
1570 :
1571 8068 : 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)
1572 : {
1573 8068 : switch( pProperty->nWID )
1574 : {
1575 : case OWN_ATTR_VALUE_FILLBITMAP:
1576 : {
1577 0 : const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
1578 :
1579 0 : if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
1580 : {
1581 : // pack object in a bitmap
1582 0 : Reference< ::com::sun::star::awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
1583 0 : rValue <<= xBitmap;
1584 : }
1585 : else
1586 : {
1587 0 : SvMemoryStream aDestStrm( 65535, 65535 );
1588 :
1589 0 : ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, false );
1590 : const uno::Sequence<sal_Int8> aSeq(
1591 0 : static_cast< const sal_Int8* >(aDestStrm.GetData()),
1592 0 : aDestStrm.GetEndOfData());
1593 0 : rValue <<= aSeq;
1594 : }
1595 0 : break;
1596 : }
1597 :
1598 : case OWN_ATTR_GRAFURL:
1599 : {
1600 577 : if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() )
1601 : {
1602 12 : rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() );
1603 : }
1604 : else
1605 : {
1606 565 : const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
1607 565 : OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX);
1608 565 : aURL += OStringToOUString(rGrafObj.GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
1609 565 : rValue <<= aURL;
1610 : }
1611 577 : break;
1612 : }
1613 :
1614 : case OWN_ATTR_REPLACEMENTGRAFURL:
1615 : {
1616 13 : const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(mpObj.get())->GetReplacementGraphicObject();
1617 :
1618 13 : if(pGrafObj)
1619 : {
1620 0 : OUString aURL(UNO_NAME_GRAPHOBJ_URLPREFIX);
1621 0 : aURL += OStringToOUString(pGrafObj->GetUniqueID(), RTL_TEXTENCODING_ASCII_US);
1622 0 : rValue <<= aURL;
1623 : }
1624 :
1625 13 : break;
1626 : }
1627 :
1628 : case OWN_ATTR_GRAFSTREAMURL:
1629 : {
1630 15 : const OUString aStreamURL( static_cast<SdrGrafObj*>( mpObj.get() )->GetGrafStreamURL() );
1631 15 : if( !aStreamURL.isEmpty() )
1632 12 : rValue <<= aStreamURL;
1633 15 : break;
1634 : }
1635 :
1636 : case OWN_ATTR_VALUE_GRAPHIC:
1637 : {
1638 32 : Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
1639 32 : rValue <<= xGraphic;
1640 32 : break;
1641 : }
1642 :
1643 : case OWN_ATTR_GRAPHIC_STREAM:
1644 : {
1645 0 : rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
1646 0 : break;
1647 : }
1648 : default:
1649 7431 : return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
1650 : }
1651 :
1652 637 : return true;
1653 : }
1654 :
1655 :
1656 :
1657 31 : SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw()
1658 31 : : SvxShapeText( pObj, getSvxMapProvider().GetMap(SVXMAP_CAPTION), getSvxMapProvider().GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) )
1659 : {
1660 31 : }
1661 :
1662 62 : SvxShapeCaption::~SvxShapeCaption() throw()
1663 : {
1664 62 : }
1665 :
1666 8253 : SvxCustomShape::SvxCustomShape( SdrObject* pObj ) throw() :
1667 8253 : SvxShapeText( pObj, getSvxMapProvider().GetMap( SVXMAP_CUSTOMSHAPE ), getSvxMapProvider().GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) )
1668 : {
1669 8253 : }
1670 :
1671 :
1672 16494 : SvxCustomShape::~SvxCustomShape() throw()
1673 : {
1674 16494 : }
1675 :
1676 :
1677 :
1678 2250 : void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
1679 : {
1680 2250 : SvxShapeText::Create( pNewObj, pNewPage );
1681 2250 : }
1682 :
1683 :
1684 :
1685 104767 : uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType )
1686 : throw(uno::RuntimeException, std::exception)
1687 : {
1688 104767 : return SvxShapeText::queryInterface( rType );
1689 : }
1690 :
1691 243482 : uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType )
1692 : throw(uno::RuntimeException, std::exception)
1693 : {
1694 243482 : ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType );
1695 243482 : if ( !aReturn.hasValue() )
1696 2655 : aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) );
1697 243482 : return aReturn;
1698 : }
1699 :
1700 758817 : void SAL_CALL SvxCustomShape::acquire() throw ( )
1701 : {
1702 758817 : SvxShapeText::acquire();
1703 758817 : }
1704 :
1705 758789 : void SAL_CALL SvxCustomShape::release() throw ( )
1706 : {
1707 758789 : SvxShapeText::release();
1708 758789 : }
1709 :
1710 :
1711 :
1712 0 : uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes()
1713 : throw (uno::RuntimeException, std::exception)
1714 : {
1715 0 : return SvxShapeText::getTypes();
1716 : }
1717 :
1718 0 : uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
1719 : throw (uno::RuntimeException, std::exception)
1720 : {
1721 0 : return css::uno::Sequence<sal_Int8>();
1722 : }
1723 :
1724 : // ::com::sun::star::drawing::XShape
1725 :
1726 :
1727 6379 : OUString SAL_CALL SvxCustomShape::getShapeType()
1728 : throw( uno::RuntimeException, std::exception )
1729 : {
1730 6379 : return SvxShape::getShapeType();
1731 : }
1732 :
1733 1852 : awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException, std::exception)
1734 : {
1735 1852 : ::SolarMutexGuard aGuard;
1736 1852 : if ( mpModel && mpObj.is() )
1737 : {
1738 1328 : SdrAShapeObjGeoData aCustomShapeGeoData;
1739 1328 : static_cast<SdrObjCustomShape*>(mpObj.get())->SaveGeoData( aCustomShapeGeoData );
1740 :
1741 1328 : bool bMirroredX = false;
1742 1328 : bool bMirroredY = false;
1743 :
1744 1328 : if ( mpObj.is() )
1745 : {
1746 1328 : bMirroredX = static_cast<SdrObjCustomShape*>(mpObj.get())->IsMirroredX();
1747 1328 : bMirroredY = static_cast<SdrObjCustomShape*>(mpObj.get())->IsMirroredY();
1748 : }
1749 : // get aRect, this is the unrotated snaprect
1750 1328 : Rectangle aRect(static_cast<SdrObjCustomShape*>(mpObj.get())->GetLogicRect());
1751 1328 : Rectangle aRectangle( aRect );
1752 :
1753 1328 : if ( bMirroredX || bMirroredY )
1754 : { // we have to retrieve the unmirrored rect
1755 :
1756 7 : GeoStat aNewGeo( aCustomShapeGeoData.aGeo );
1757 7 : if ( bMirroredX )
1758 : {
1759 7 : Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
1760 7 : Rectangle aBoundRect( aPol.GetBoundRect() );
1761 :
1762 7 : Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
1763 7 : Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
1764 : sal_uInt16 i;
1765 7 : sal_uInt16 nPointCount=aPol.GetSize();
1766 42 : for (i=0; i<nPointCount; i++)
1767 : {
1768 35 : MirrorPoint(aPol[i],aRef1,aRef2);
1769 : }
1770 : // turn and move polygon
1771 14 : Polygon aPol0(aPol);
1772 7 : aPol[0]=aPol0[1];
1773 7 : aPol[1]=aPol0[0];
1774 7 : aPol[2]=aPol0[3];
1775 7 : aPol[3]=aPol0[2];
1776 7 : aPol[4]=aPol0[1];
1777 14 : Poly2Rect(aPol,aRectangle,aNewGeo);
1778 : }
1779 7 : if ( bMirroredY )
1780 : {
1781 0 : Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
1782 0 : Rectangle aBoundRect( aPol.GetBoundRect() );
1783 :
1784 0 : Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
1785 0 : Point aRef2( aRef1.X() + 1000, aRef1.Y() );
1786 : sal_uInt16 i;
1787 0 : sal_uInt16 nPointCount=aPol.GetSize();
1788 0 : for (i=0; i<nPointCount; i++)
1789 : {
1790 0 : MirrorPoint(aPol[i],aRef1,aRef2);
1791 : }
1792 : // turn and move polygon
1793 0 : Polygon aPol0(aPol);
1794 0 : aPol[0]=aPol0[1];
1795 0 : aPol[1]=aPol0[0];
1796 0 : aPol[2]=aPol0[3];
1797 0 : aPol[3]=aPol0[2];
1798 0 : aPol[4]=aPol0[1];
1799 0 : Poly2Rect( aPol, aRectangle, aNewGeo );
1800 : }
1801 : }
1802 1328 : Point aPt( aRectangle.TopLeft() );
1803 :
1804 1328 : if( mpModel->IsWriter() )
1805 958 : aPt -= mpObj->GetAnchorPos();
1806 :
1807 1328 : ForceMetricTo100th_mm(aPt);
1808 1328 : return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
1809 : }
1810 : else
1811 524 : return SvxShape::getPosition();
1812 : }
1813 :
1814 :
1815 3375 : void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException, std::exception)
1816 : {
1817 3375 : SvxShapeText::setPosition(Position);
1818 3375 : }
1819 :
1820 :
1821 :
1822 5598 : awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException, std::exception)
1823 : {
1824 5598 : return SvxShapeText::getSize();
1825 : }
1826 :
1827 :
1828 3255 : void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize )
1829 : throw(beans::PropertyVetoException, uno::RuntimeException, std::exception)
1830 : {
1831 3255 : SvxShapeText::setSize( rSize );
1832 3255 : }
1833 :
1834 :
1835 :
1836 :
1837 50864 : void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
1838 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException, std::exception)
1839 : {
1840 50864 : ::SolarMutexGuard aGuard;
1841 50864 : SdrObject* pObject = mpObj.get();
1842 :
1843 50864 : bool bCustomShapeGeometry = pObject && aPropertyName == "CustomShapeGeometry";
1844 :
1845 50864 : bool bMirroredX = false;
1846 50864 : bool bMirroredY = false;
1847 :
1848 50864 : if ( bCustomShapeGeometry )
1849 : {
1850 2532 : bMirroredX = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredX();
1851 2532 : bMirroredY = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredY();
1852 : }
1853 :
1854 50864 : SvxShape::setPropertyValue( aPropertyName, aValue );
1855 :
1856 50854 : if ( bCustomShapeGeometry )
1857 : {
1858 2532 : static_cast<SdrObjCustomShape*>(pObject)->MergeDefaultAttributes(0);
1859 2532 : Rectangle aRect( pObject->GetSnapRect() );
1860 :
1861 : // #i38892#
1862 2532 : bool bNeedsMirrorX = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredX() != bMirroredX;
1863 2532 : bool bNeedsMirrorY = static_cast<SdrObjCustomShape*>(pObject)->IsMirroredY() != bMirroredY;
1864 :
1865 2532 : boost::scoped_ptr< SdrGluePointList > pListCopy;
1866 2532 : if( bNeedsMirrorX || bNeedsMirrorY )
1867 : {
1868 113 : const SdrGluePointList* pList = pObject->GetGluePointList();
1869 113 : if( pList )
1870 0 : pListCopy.reset( new SdrGluePointList(*pList) );
1871 : }
1872 :
1873 2532 : if ( bNeedsMirrorX )
1874 : {
1875 19 : Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
1876 19 : Point aBottom( aTop.X(), aTop.Y() + 1000 );
1877 19 : pObject->NbcMirror( aTop, aBottom );
1878 : // NbcMirroring is flipping the current mirror state,
1879 : // so we have to set the correct state again
1880 19 : static_cast<SdrObjCustomShape*>(pObject)->SetMirroredX( !bMirroredX );
1881 : }
1882 2532 : if ( bNeedsMirrorY )
1883 : {
1884 100 : Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
1885 100 : Point aRight( aLeft.X() + 1000, aLeft.Y() );
1886 100 : pObject->NbcMirror( aLeft, aRight );
1887 : // NbcMirroring is flipping the current mirror state,
1888 : // so we have to set the correct state again
1889 100 : static_cast<SdrObjCustomShape*>(pObject)->SetMirroredY( !bMirroredY );
1890 : }
1891 :
1892 2532 : if( pListCopy )
1893 : {
1894 0 : SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
1895 0 : if(pNewList)
1896 0 : *pNewList = *pListCopy;
1897 2532 : }
1898 50864 : }
1899 50854 : }
1900 :
1901 50451 : 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)
1902 : {
1903 50451 : switch( pProperty->nWID )
1904 : {
1905 : case SDRATTR_ROTATEANGLE:
1906 : {
1907 868 : double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
1908 868 : fAngle *= 100;
1909 868 : rValue <<= (sal_Int32)fAngle;
1910 868 : return true;
1911 : }
1912 : default:
1913 49583 : return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
1914 : }
1915 : }
1916 :
1917 :
1918 267 : void SvxCustomShape::createCustomShapeDefaults( const OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException, std::exception)
1919 : {
1920 267 : static_cast<SdrObjCustomShape*>(mpObj.get())->MergeDefaultAttributes( &rValueType );
1921 702 : }
1922 :
1923 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|