LibreOffice Module sd (master) 1
unoobj.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <memory>
23#include <string_view>
24#include <utility>
25
26#include <com/sun/star/style/XStyle.hpp>
27#include <com/sun/star/presentation/ClickAction.hpp>
28#include <com/sun/star/beans/PropertyAttribute.hpp>
29#include <com/sun/star/beans/PropertyState.hpp>
30#include <rtl/ustrbuf.hxx>
31#include <svl/itemprop.hxx>
32#include <svl/style.hxx>
33#include <svx/svdpool.hxx>
34#include <sfx2/viewfrm.hxx>
35#include <sfx2/app.hxx>
36#include <svtools/unoimap.hxx>
37#include <svtools/unoevent.hxx>
38#include <sfx2/bindings.hxx>
39#include <sfx2/event.hxx>
40#include <sfx2/sfxsids.hrc>
44#include <svx/unoshape.hxx>
45#include <svx/svdotext.hxx>
46#include <svx/svdopath.hxx>
47#include <svx/svdoole2.hxx>
48#include <svx/svdograf.hxx>
49#include <svx/ImageMapInfo.hxx>
51#include <svl/instrm.hxx>
52#include <editeng/outlobj.hxx>
53#include <Outliner.hxx>
55#include <svx/svdogrp.hxx>
57#include <vcl/svapp.hxx>
58#include <tools/debug.hxx>
59
60#include <anminfo.hxx>
61#include "unoobj.hxx"
62#include <unoprnms.hxx>
63#include <unomodel.hxx>
64#include <drawdoc.hxx>
65#include <sdmod.hxx>
66#include <sdpage.hxx>
67#include <ViewShell.hxx>
68#include <unopage.hxx>
69#include <DrawDocShell.hxx>
70#include <EffectMigration.hxx>
71
72using namespace ::sd;
73using namespace ::com::sun::star;
74using namespace ::com::sun::star::presentation;
75using namespace ::com::sun::star::animations;
76
77using ::com::sun::star::uno::Any;
78using ::com::sun::star::drawing::XShape;
79
80#define WID_EFFECT 1
81#define WID_SPEED 2
82#define WID_TEXTEFFECT 3
83#define WID_BOOKMARK 4
84#define WID_CLICKACTION 5
85#define WID_PLAYFULL 6
86#define WID_SOUNDFILE 7
87#define WID_SOUNDON 8
88#define WID_BLUESCREEN 9
89#define WID_VERB 10
90#define WID_DIMCOLOR 11
91#define WID_DIMHIDE 12
92#define WID_DIMPREV 13
93#define WID_PRESORDER 14
94#define WID_STYLE 15
95#define WID_ANIMPATH 16
96#define WID_IMAGEMAP 17
97#define WID_ISANIMATION 18
98
99#define WID_ISEMPTYPRESOBJ 20
100#define WID_ISPRESOBJ 21
101#define WID_MASTERDEPEND 22
102
103#define WID_NAVORDER 23
104#define WID_PLACEHOLDERTEXT 24
105#define WID_LEGACYFRAGMENT 25
106
107#define IMPRESS_MAP_ENTRIES \
108 { u"" UNO_NAME_OBJ_LEGACYFRAGMENT,WID_LEGACYFRAGMENT, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
109 { u"" UNO_NAME_OBJ_ANIMATIONPATH, WID_ANIMPATH, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
110 { u"" UNO_NAME_OBJ_BOOKMARK, WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
111 { u"" UNO_NAME_OBJ_DIMCOLOR, WID_DIMCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0},\
112 { u"" UNO_NAME_OBJ_DIMHIDE, WID_DIMHIDE, cppu::UnoType<bool>::get(), 0, 0},\
113 { u"" UNO_NAME_OBJ_DIMPREV, WID_DIMPREV, cppu::UnoType<bool>::get(), 0, 0},\
114 { u"" UNO_NAME_OBJ_EFFECT, WID_EFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
115 { u"" UNO_NAME_OBJ_ISEMPTYPRESOBJ,WID_ISEMPTYPRESOBJ, cppu::UnoType<bool>::get(), 0, 0},\
116 { u"" UNO_NAME_OBJ_ISPRESOBJ, WID_ISPRESOBJ, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY, 0},\
117 { u"" UNO_NAME_OBJ_MASTERDEPENDENT,WID_MASTERDEPEND, cppu::UnoType<bool>::get(), 0, 0},\
118 { u"" UNO_NAME_OBJ_CLICKACTION, WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(), 0, 0},\
119 { u"" UNO_NAME_OBJ_PLAYFULL, WID_PLAYFULL, cppu::UnoType<bool>::get(), 0, 0},\
120 { u"" UNO_NAME_OBJ_PRESORDER, WID_PRESORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
121 { u"" UNO_NAME_OBJ_STYLE, WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
122 { u"" UNO_NAME_OBJ_SOUNDFILE, WID_SOUNDFILE, cppu::UnoType<OUString>::get(), 0, 0},\
123 { u"" UNO_NAME_OBJ_SOUNDON, WID_SOUNDON, cppu::UnoType<bool>::get(), 0, 0},\
124 { u"" UNO_NAME_OBJ_SPEED, WID_SPEED, cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},\
125 { u"" UNO_NAME_OBJ_TEXTEFFECT, WID_TEXTEFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
126 { u"" UNO_NAME_OBJ_BLUESCREEN, WID_BLUESCREEN, cppu::UnoType<sal_Int32>::get(), 0, 0},\
127 { u"" UNO_NAME_OBJ_VERB, WID_VERB, cppu::UnoType<sal_Int32>::get(), 0, 0},\
128 { u"IsAnimation", WID_ISANIMATION, cppu::UnoType<bool>::get(), 0, 0},\
129 { u"NavigationOrder", WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
130 { u"PlaceholderText", WID_PLACEHOLDERTEXT, cppu::UnoType<OUString>::get(), 0, 0},\
131
133 {
134 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl[] =
135 {
138 };
139 return aImpress_SdXShapePropertyGraphicMap_Impl;
140 }
141
143 {
144 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl[] =
145 {
147 };
148 return aImpress_SdXShapePropertySimpleMap_Impl;
149 }
150
151 #define DRAW_MAP_ENTRIES\
152 { u"" UNO_NAME_OBJ_BOOKMARK, WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
153 { u"" UNO_NAME_OBJ_CLICKACTION, WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(),0, 0},\
154 { u"" UNO_NAME_OBJ_STYLE, WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
155 { u"NavigationOrder", WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
156
158 {
159 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl[] =
160 {
162 };
163 return aDraw_SdXShapePropertyMap_Impl;
164 }
166 {
167 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl[] =
168 {
171 };
172 return aDraw_SdXShapePropertyGraphicMap_Impl;
173 }
175 {
177 if( bImpress )
178 {
179 if( bGraphicObj )
181 else
183 }
184 else
185 {
186 if( bGraphicObj )
188 else
190 }
191 return pRet;
192
193 }
194 static const SvxItemPropertySet* lcl_ImplGetShapePropertySet( bool bImpress, bool bGraphicObj )
195 {
196 const SvxItemPropertySet* pRet = nullptr;
197 if( bImpress )
198 {
199 if( bGraphicObj )
200 {
202 pRet = &aImpress_SdXShapePropertyGraphicSet_Impl;
203 }
204 else
205 {
207 pRet = &aImpress_SdXShapePropertySet_Impl;
208 }
209 }
210 else
211 {
212 if( bGraphicObj )
213 {
215 pRet = &aDraw_SdXShapePropertyGraphicSet_Impl;
216 }
217 else
218 {
220 pRet = &aDraw_SdXShapePropertySet_Impl;
221 }
222 }
223 return pRet;
224 }
226 {
227 return {};
228 }
229
231 {
233 return &aEmptyPropSet;
234 }
236{
237 static const SvEventDescription aMacroDescriptionsImpl[] =
238 {
239 { SvMacroItemId::OnMouseOver, "OnMouseOver" },
240 { SvMacroItemId::OnMouseOut, "OnMouseOut" },
241 { SvMacroItemId::NONE, nullptr }
242 };
243
244 return aMacroDescriptionsImpl;
245}
246
248: mpShape( pShape ),
249 mpPropSet( pModel?
250 lcl_ImplGetShapePropertySet(pModel->IsImpressDocument(), pShape->getShapeKind() == SdrObjKind::Graphic )
252 mpMap( pModel?
253 lcl_ImplGetShapePropertyMap(pModel->IsImpressDocument(), pShape->getShapeKind() == SdrObjKind::Graphic )
255 mpModel(pModel)
256{
257
258 pShape->setMaster( this );
259}
260
262{
263}
264
266{
267 mpShape->setMaster( nullptr );
268 delete this;
269}
270
272{
273 return mpShape->queryInterface( rType );
274}
275
276void SAL_CALL SdXShape::acquire() noexcept
277{
278 mpShape->acquire();
279}
280
281void SAL_CALL SdXShape::release() noexcept
282{
283 mpShape->release();
284}
285
286bool SdXShape::queryAggregation( const css::uno::Type & rType, css::uno::Any& aAny )
287{
288 if( mpModel && mpModel ->IsImpressDocument() )
289 {
291 {
292 aAny <<= uno::Reference< document::XEventsSupplier >(this);
293 return true;
294 }
295 }
296
297 return false;
298}
299
300uno::Sequence< uno::Type > SAL_CALL SdXShape::getTypes()
301{
303 {
304 return mpShape->_getTypes();
305 }
306 else
307 {
308 SdrObjKind nObjId = mpShape->getShapeKind();
309 uno::Sequence< uno::Type > aTypes;
310 SdTypesCache& gImplTypesCache = SD_MOD()->gImplTypesCache;
311 SdTypesCache::iterator aIter( gImplTypesCache.find( nObjId ) );
312 if( aIter == gImplTypesCache.end() )
313 {
315 sal_uInt32 nCount = aTypes.getLength();
316 aTypes.realloc( nCount+1 );
318
319 gImplTypesCache.insert(std::make_pair(nObjId, aTypes));
320 }
321 else
322 {
323 // use the already computed implementation id
324 aTypes = (*aIter).second;
325 }
326 return aTypes;
327 }
328}
329
330// XPropertyState
331beans::PropertyState SAL_CALL SdXShape::getPropertyState( const OUString& PropertyName )
332{
333 SolarMutexGuard aGuard;
334
335 if( mpPropSet->getPropertyMapEntry(PropertyName) )
336 {
337 return beans::PropertyState_DIRECT_VALUE;
338 }
339 else
340 {
341 SdrObject* pObj = mpShape->GetSdrObject();
342 if( pObj == nullptr || ( pObj->getSdrPageFromSdrObject()->IsMasterPage() && pObj->IsEmptyPresObj() ) )
343 return beans::PropertyState_DEFAULT_VALUE;
344
345 return mpShape->_getPropertyState( PropertyName );
346 }
347}
348
349void SAL_CALL SdXShape::setPropertyToDefault( const OUString& PropertyName )
350{
351 SolarMutexGuard aGuard;
352
353 if( mpPropSet->getPropertyMapEntry(PropertyName) )
354 {
355 return;
356 }
357 else
358 {
359 mpShape->_setPropertyToDefault(PropertyName);
360 }
361}
362
363uno::Any SAL_CALL SdXShape::getPropertyDefault( const OUString& aPropertyName )
364{
365 SolarMutexGuard aGuard;
366
367 if( mpPropSet->getPropertyMapEntry(aPropertyName) )
368 {
369 return getPropertyValue( aPropertyName );
370 }
371 else
372 {
373 uno::Any aRet( mpShape->_getPropertyDefault(aPropertyName) );
374 return aRet;
375 }
376}
377
378//XPropertySet
379css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL SdXShape::getPropertySetInfo()
380{
382 css::uno::Reference<css::beans::XPropertySetInfo> pInfo;
383
385 SD_MOD()->gImplImpressPropertySetInfoCache : SD_MOD()->gImplDrawPropertySetInfoCache;
386
387 SdExtPropertySetInfoCache::iterator aIter( rCache.find( nObjId ) );
388 if( aIter == rCache.end() )
389 {
390 uno::Reference< beans::XPropertySetInfo > xInfo( mpShape->_getPropertySetInfo() );
391 pInfo = new SfxExtItemPropertySetInfo( mpMap, xInfo->getProperties() );
392
393 rCache.insert(std::make_pair(nObjId, pInfo));
394 }
395 else
396 {
397 // use the already computed implementation id
398 pInfo = (*aIter).second;
399 }
400
401 return pInfo;
402}
403
404void SAL_CALL SdXShape::setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue )
405{
406 SolarMutexGuard aGuard;
407
408 const SfxItemPropertyMapEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
409
410 if( pEntry )
411 {
412 SdrObject* pObj = mpShape->GetSdrObject();
413 if( pObj )
414 {
415 switch(pEntry->nWID)
416 {
417 case WID_NAVORDER:
418 {
419 sal_Int32 nNavOrder = 0;
420 if(!(aValue >>= nNavOrder))
421 throw lang::IllegalArgumentException();
422
424 if( pObjList )
425 pObjList->SetObjectNavigationPosition( *pObj, (nNavOrder < 0) ? SAL_MAX_UINT32 : static_cast< sal_uInt32 >( nNavOrder ) );
426 break;
427 }
428
429 case WID_EFFECT:
430 {
431 AnimationEffect eEffect;
432 if(!(aValue >>= eEffect))
433 throw lang::IllegalArgumentException();
434
435 EffectMigration::SetAnimationEffect( mpShape, eEffect );
436 break;
437 }
438 case WID_TEXTEFFECT:
439 {
440 AnimationEffect eEffect;
441 if(!(aValue >>= eEffect))
442 throw lang::IllegalArgumentException();
443
444 EffectMigration::SetTextAnimationEffect( mpShape, eEffect );
445 break;
446 }
447 case WID_SPEED:
448 {
449 AnimationSpeed eSpeed;
450 if(!(aValue>>=eSpeed))
451 throw lang::IllegalArgumentException();
452
453 EffectMigration::SetAnimationSpeed( mpShape, eSpeed );
454 break;
455 }
456 case WID_ISANIMATION:
457 {
458 bool bIsAnimation(false);
459
460 if(!(aValue >>= bIsAnimation))
461 {
462 throw lang::IllegalArgumentException();
463 }
464
465 if(bIsAnimation)
466 {
467 SdrObjGroup* pGroup = dynamic_cast< SdrObjGroup* >(pObj);
468 SdPage* pPage = pGroup ? dynamic_cast< SdPage* >(pGroup->getSdrPageFromSdrObject()) : nullptr;
469
470 if (pPage)
471 {
472 // #i42894# Animated Group object, migrate that effect
473 EffectMigration::CreateAnimatedGroup(*pGroup, *pPage);
474
475 // #i42894# unfortunately when doing this all group members have to
476 // be moved to the page as direct members, else the currently
477 // available forms of animation do not work. If it succeeds,
478 // the group is empty and can be removed and deleted
479 if(!pGroup->GetSubList()->GetObjCount())
480 {
481 pPage->NbcRemoveObject(pGroup->GetOrdNum());
482 }
483 }
484 }
485 //pInfo->mbIsMovie = bIsAnimation;
486 break;
487 }
488 case WID_BOOKMARK:
489 {
490 OUString aString;
491 if(!(aValue >>= aString))
492 throw lang::IllegalArgumentException();
493
494 SdAnimationInfo* pInfo = GetAnimationInfo(true);
496 break;
497 }
498 case WID_CLICKACTION:
499 {
500 SdAnimationInfo* pInfo = GetAnimationInfo(true);
501 ::cppu::any2enum< presentation::ClickAction >( pInfo->meClickAction, aValue);
502 break;
503 }
504// TODO: WID_PLAYFULL:
505 case WID_SOUNDFILE:
506 {
507 OUString aString;
508 if(!(aValue >>= aString))
509 throw lang::IllegalArgumentException();
510 SdAnimationInfo* pInfo = GetAnimationInfo(true);
511 pInfo->maSoundFile = aString;
512 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
513 break;
514 }
515
516 case WID_SOUNDON:
517 {
518 SdAnimationInfo* pInfo = GetAnimationInfo(true);
519 if( !(aValue >>= pInfo->mbSoundOn) )
520 throw lang::IllegalArgumentException();
521 EffectMigration::UpdateSoundEffect( mpShape, pInfo );
522 break;
523 }
524 case WID_VERB:
525 {
526 sal_Int32 nVerb = 0;
527 if(!(aValue >>= nVerb))
528 throw lang::IllegalArgumentException();
529
530 SdAnimationInfo* pInfo = GetAnimationInfo(true);
531 pInfo->mnVerb = static_cast<sal_uInt16>(nVerb);
532 break;
533 }
534 case WID_DIMCOLOR:
535 {
536 sal_Int32 nColor = 0;
537
538 if( !(aValue >>= nColor) )
539 throw lang::IllegalArgumentException();
540
541 EffectMigration::SetDimColor( mpShape, nColor );
542 break;
543 }
544 case WID_DIMHIDE:
545 {
546 bool bDimHide = false;
547 if( !(aValue >>= bDimHide) )
548 throw lang::IllegalArgumentException();
549
550 EffectMigration::SetDimHide( mpShape, bDimHide );
551 break;
552 }
553 case WID_DIMPREV:
554 {
555 bool bDimPrevious = false;
556 if( !(aValue >>= bDimPrevious) )
557 throw lang::IllegalArgumentException();
558
559 EffectMigration::SetDimPrevious( mpShape, bDimPrevious );
560 break;
561 }
562 case WID_PRESORDER:
563 {
564 sal_Int32 nNewPos = 0;
565 if( !(aValue >>= nNewPos) )
566 throw lang::IllegalArgumentException();
567
568 EffectMigration::SetPresentationOrder( mpShape, nNewPos );
569 break;
570 }
571 case WID_STYLE:
572 SetStyleSheet( aValue );
573 break;
575 SetEmptyPresObj( ::cppu::any2bool(aValue) );
576 break;
577 case WID_MASTERDEPEND:
578 SetMasterDepend( ::cppu::any2bool(aValue) );
579 break;
580
582 {
583 uno::Reference< io::XInputStream > xInputStream;
584 aValue >>= xInputStream;
585 if( xInputStream.is() )
586 {
587 SvInputStream aStream( xInputStream );
590 }
591 }
592 break;
593
594 case WID_ANIMPATH:
595 {
596 uno::Reference< drawing::XShape > xShape( aValue, uno::UNO_QUERY );
597 SdrPathObj* pObj2 = xShape.is() ? dynamic_cast<SdrPathObj*>(SdrObject::getSdrObjectFromXShape(xShape)) : nullptr;
598
599 if( pObj2 == nullptr )
600 throw lang::IllegalArgumentException();
601
602 EffectMigration::SetAnimationPath( mpShape, pObj2 );
603 break;
604 }
605 case WID_IMAGEMAP:
606 {
607 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():nullptr;
608 if( pDoc )
609 {
610 ImageMap aImageMap;
611 uno::Reference< uno::XInterface > xImageMap;
612 aValue >>= xImageMap;
613
614 if( !xImageMap.is() || !SvUnoImageMap_fillImageMap( xImageMap, aImageMap ) )
615 throw lang::IllegalArgumentException();
616
617 SvxIMapInfo* pIMapInfo = SvxIMapInfo::GetIMapInfo(pObj);
618 if( pIMapInfo )
619 {
620 // replace existing image map
621 pIMapInfo->SetImageMap( aImageMap );
622 }
623 else
624 {
625 // insert new user data with image map
626 pObj->AppendUserData(std::unique_ptr<SdrObjUserData>(new SvxIMapInfo(aImageMap) ));
627 }
628 }
629 }
630 break;
631 }
632 }
633 }
634 else
635 {
636 mpShape->_setPropertyValue(aPropertyName, aValue);
637 }
638
639 if( mpModel )
641}
642
643css::uno::Any SAL_CALL SdXShape::getPropertyValue( const OUString& PropertyName )
644{
645 SolarMutexGuard aGuard;
646
647 uno::Any aRet;
648
649 const SfxItemPropertyMapEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
650
651 if( pEntry && mpShape->GetSdrObject() )
652 {
654
655 switch(pEntry->nWID)
656 {
657 case WID_NAVORDER:
658 {
659 const sal_uInt32 nNavOrder = mpShape->GetSdrObject()->GetNavigationPosition();
660 aRet <<= nNavOrder == SAL_MAX_UINT32 ? static_cast<sal_Int32>(-1) : static_cast< sal_Int32 >(nNavOrder);
661 }
662 break;
663 case WID_EFFECT:
664 aRet <<= EffectMigration::GetAnimationEffect( mpShape );
665 break;
666 case WID_TEXTEFFECT:
667 aRet <<= EffectMigration::GetTextAnimationEffect( mpShape );
668 break;
669 case WID_ISPRESOBJ:
670 aRet <<= IsPresObj();
671 break;
673 aRet <<= IsEmptyPresObj();
674 break;
675 case WID_MASTERDEPEND:
676 aRet <<= IsMasterDepend();
677 break;
678 case WID_SPEED:
679 aRet <<= EffectMigration::GetAnimationSpeed( mpShape );
680 break;
681 case WID_ISANIMATION:
682 aRet <<= (pInfo && pInfo->mbIsMovie);
683 break;
685 aRet <<= GetPlaceholderText();
686 break;
687 case WID_BOOKMARK:
688 {
689 OUString aString;
690 SdDrawDocument* pDoc = mpModel ? mpModel->GetDoc() : nullptr;
691 if (pInfo && pDoc)
692 {
693 // is the bookmark a page?
694 bool bIsMasterPage;
695 if(pDoc->GetPageByName( pInfo->GetBookmark(), bIsMasterPage ) != SDRPAGE_NOTFOUND)
696 {
698 }
699 else
700 {
701 aString = pInfo->GetBookmark() ;
702 sal_Int32 nPos = aString.lastIndexOf( '#' );
703 if( nPos >= 0 )
704 {
705 OUString aURL( aString.copy( 0, nPos+1 ) );
706 OUString aName( aString.copy( nPos+1 ) );
707 if(pDoc->GetPageByName( aName, bIsMasterPage ) != SDRPAGE_NOTFOUND)
708 {
710 aString = aURL;
711 }
712 }
713 }
714 }
715
716 aRet <<= aString;
717 break;
718 }
719 case WID_CLICKACTION:
720 aRet <<= ( pInfo?pInfo->meClickAction:presentation::ClickAction_NONE );
721 break;
722 case WID_PLAYFULL:
723 aRet <<= ( pInfo && pInfo->mbPlayFull );
724 break;
725 case WID_SOUNDFILE:
726 aRet <<= EffectMigration::GetSoundFile( mpShape );
727 break;
728 case WID_SOUNDON:
729 aRet <<= EffectMigration::GetSoundOn( mpShape );
730 break;
731 case WID_BLUESCREEN:
732 aRet <<= pInfo ? pInfo->maBlueScreen : Color(0x00ffffff);
733 break;
734 case WID_VERB:
735 aRet <<= static_cast<sal_Int32>( pInfo?pInfo->mnVerb:0 );
736 break;
737 case WID_DIMCOLOR:
738 aRet <<= EffectMigration::GetDimColor( mpShape );
739 break;
740 case WID_DIMHIDE:
741 aRet <<= EffectMigration::GetDimHide( mpShape );
742 break;
743 case WID_DIMPREV:
744 aRet <<= EffectMigration::GetDimPrevious( mpShape );
745 break;
746 case WID_PRESORDER:
747 aRet <<= EffectMigration::GetPresentationOrder( mpShape );
748 break;
749 case WID_STYLE:
750 aRet = GetStyleSheet();
751 break;
752 case WID_IMAGEMAP:
753 {
754 uno::Reference< uno::XInterface > xImageMap;
755
756 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():nullptr;
757 if( pDoc )
758 {
759
761 if( pIMapInfo )
762 {
763 const ImageMap& rIMap = pIMapInfo->GetImageMap();
765 }
766 else
767 {
768 xImageMap = SvUnoImageMap_createInstance();
769 }
770 }
771
772 aRet <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
773 break;
774 }
775 }
776 }
777 else
778 {
779 aRet = mpShape->_getPropertyValue(PropertyName);
780 }
781
782 return aRet;
783}
784
787{
788 SdAnimationInfo* pInfo = nullptr;
789
790 SdrObject* pObj = mpShape->GetSdrObject();
791 if(pObj)
792 pInfo = SdDrawDocument::GetShapeUserData(*pObj, bCreate);
793
794 return pInfo;
795}
796
797uno::Sequence< OUString > SAL_CALL SdXShape::getSupportedServiceNames()
798{
799 std::vector<std::u16string_view> aAdd{ u"com.sun.star.presentation.Shape",
800 u"com.sun.star.document.LinkTarget" };
801
802 SdrObject* pObj = mpShape->GetSdrObject();
803 if(pObj && pObj->GetObjInventor() == SdrInventor::Default )
804 {
805 SdrObjKind nInventor = pObj->GetObjIdentifier();
806 switch( nInventor )
807 {
808 case SdrObjKind::TitleText:
809 aAdd.emplace_back(u"com.sun.star.presentation.TitleTextShape");
810 break;
811 case SdrObjKind::OutlineText:
812 aAdd.emplace_back(u"com.sun.star.presentation.OutlinerShape");
813 break;
814 default: ;
815 }
816 }
818}
819
823{
824 SdrObject* pObj = mpShape->GetSdrObject();
825 if(pObj)
826 {
827 SdPage* pPage = dynamic_cast<SdPage* >(pObj->getSdrPageFromSdrObject());
828 if(pPage)
829 return pPage->GetPresObjKind(pObj) != PresObjKind::NONE;
830 }
831 return false;
832}
833
837{
838 SdrObject* pObj = mpShape->GetSdrObject();
839 if( (pObj != nullptr) && pObj->IsEmptyPresObj() )
840 {
841 // check if the object is in edit, then if it's temporarily not empty
842 SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
843 if( pTextObj == nullptr )
844 return true;
845
846 return !pTextObj->CanCreateEditOutlinerParaObject();
847 }
848
849 return false;
850}
851
853{
854 // only possible if this actually *is* a presentation object
855 if( !IsPresObj() )
856 return OUString();
857
858 SdrObject* pObj = mpShape->GetSdrObject();
859 if( pObj == nullptr )
860 return OUString();
861
862 SdPage* pPage = dynamic_cast< SdPage* >(pObj->getSdrPageFromSdrObject());
863 DBG_ASSERT( pPage, "no page?" );
864 if( pPage == nullptr )
865 return OUString();
866
867 return pPage->GetPresObjText( pPage->GetPresObjKind(pObj) );
868}
869
873{
874 // only possible if this actually *is* a presentation object
875 if( !IsPresObj() )
876 return;
877
878 SdrObject* pObj = mpShape->GetSdrObject();
879 if( pObj == nullptr )
880 return;
881
882 if( pObj->IsEmptyPresObj() == bEmpty )
883 return;
884
885 if(!bEmpty)
886 {
887 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
888 const bool bVertical = pOutlinerParaObject && pOutlinerParaObject->IsEffectivelyVertical();
889
890 // really delete SdrOutlinerObj at pObj
891 pObj->NbcSetOutlinerParaObject(std::nullopt);
892 if( bVertical )
893 if (auto pTextObj = DynCastSdrTextObj( pObj ) )
894 pTextObj->SetVerticalWriting( true );
895
896 SdrGrafObj* pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj );
897 if( pGraphicObj )
898 {
899 Graphic aEmpty;
900 pGraphicObj->SetGraphic(aEmpty);
901 }
902 else
903 {
904 SdrOle2Obj* pOleObj = dynamic_cast< SdrOle2Obj* >( pObj );
905 if( pOleObj )
906 {
907 pOleObj->ClearGraphic();
908 }
909 }
910 }
911 else
912 {
913 // now set an empty OutlinerParaObject at pObj without
914 // any content but with the style of the old OutlinerParaObjects
915 // first paragraph
916 do
917 {
918 SdDrawDocument* pDoc = mpModel?mpModel->GetDoc():nullptr;
919 DBG_ASSERT( pDoc, "no document?" );
920 if( pDoc == nullptr)
921 break;
922
923 SdOutliner* pOutliner = pDoc->GetInternalOutliner();
924 DBG_ASSERT( pOutliner, "no outliner?" );
925 if( pOutliner == nullptr )
926 break;
927
928 SdPage* pPage = dynamic_cast< SdPage* >(pObj->getSdrPageFromSdrObject());
929 DBG_ASSERT( pPage, "no page?" );
930 if( pPage == nullptr )
931 break;
932
933 OutlinerParaObject* pOutlinerParaObject = pObj->GetOutlinerParaObject();
934 pOutliner->SetText( *pOutlinerParaObject );
935 const bool bVertical = pOutliner->IsVertical();
936
937 pOutliner->Clear();
938 pOutliner->SetVertical( bVertical );
939 pOutliner->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(pDoc->GetStyleSheetPool()) );
940 pOutliner->SetStyleSheet( 0, pPage->GetTextStyleSheetForObject( pObj ) );
941 pOutliner->Insert( pPage->GetPresObjText( pPage->GetPresObjKind(pObj) ) );
942 pObj->SetOutlinerParaObject( pOutliner->CreateParaObject() );
943 pOutliner->Clear();
944 }
945 while(false);
946 }
947
948 pObj->SetEmptyPresObj(bEmpty);
949}
950
951bool SdXShape::IsMasterDepend() const noexcept
952{
953 SdrObject* pObj = mpShape->GetSdrObject();
954 return pObj && pObj->GetUserCall() != nullptr;
955}
956
957void SdXShape::SetMasterDepend( bool bDepend ) noexcept
958{
959 if( IsMasterDepend() == bDepend )
960 return;
961
962 SdrObject* pObj = mpShape->GetSdrObject();
963 if( pObj )
964 {
965 if( bDepend )
966 {
967 SdPage* pPage = dynamic_cast< SdPage* >(pObj->getSdrPageFromSdrObject());
968 pObj->SetUserCall( pPage );
969 }
970 else
971 {
972 pObj->SetUserCall( nullptr );
973 }
974 }
975}
976
978{
979 SdrObject* pObj = mpShape->GetSdrObject();
980 if( pObj == nullptr )
981 throw beans::UnknownPropertyException();
982
983 uno::Reference< style::XStyle > xStyle( rAny, uno::UNO_QUERY );
984 SfxStyleSheet* pStyleSheet = SfxUnoStyleSheet::getUnoStyleSheet( xStyle );
985
986 const SfxStyleSheet* pOldStyleSheet = pObj->GetStyleSheet();
987 if( pOldStyleSheet == pStyleSheet )
988 return;
989
990 if( pStyleSheet == nullptr || (pStyleSheet->GetFamily() != SfxStyleFamily::Para && pStyleSheet->GetFamily() != SfxStyleFamily::Page) )
991 throw lang::IllegalArgumentException();
992
993 pObj->SetStyleSheet( pStyleSheet, false );
994
995 SdDrawDocument* pDoc = mpModel? mpModel->GetDoc() : nullptr;
996 if( pDoc )
997 {
998 ::sd::DrawDocShell* pDocSh = pDoc->GetDocSh();
999 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : nullptr;
1000
1001 if( pViewSh )
1002 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2 );
1003 }
1004}
1005
1007{
1008 SdrObject* pObj = mpShape->GetSdrObject();
1009 if( pObj == nullptr )
1010 throw beans::UnknownPropertyException();
1011
1012 SfxStyleSheet* pStyleSheet = pObj->GetStyleSheet();
1013 // it is possible for shapes inside a draw to have a presentation style
1014 // but we don't want this for the api
1015 if( (pStyleSheet == nullptr) || ((pStyleSheet->GetFamily() != SfxStyleFamily::Para) && !mpModel->IsImpressDocument()) )
1016 return Any();
1017
1018 return Any( uno::Reference< style::XStyle >( dynamic_cast< SfxUnoStyleSheet* >( pStyleSheet ) ) );
1019}
1020
1021class SdUnoEventsAccess : public cppu::WeakImplHelper< css::container::XNameReplace, css::lang::XServiceInfo >
1022{
1023private:
1025
1026public:
1027 explicit SdUnoEventsAccess(SdXShape* pShape) noexcept;
1028
1029 // XNameReplace
1030 virtual void SAL_CALL replaceByName( const OUString& aName, const css::uno::Any& aElement ) override;
1031
1032 // XNameAccess
1033 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
1034 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
1035 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
1036
1037 // XElementAccess
1038 virtual css::uno::Type SAL_CALL getElementType( ) override;
1039 virtual sal_Bool SAL_CALL hasElements( ) override;
1040
1041 // XServiceInfo
1042 virtual OUString SAL_CALL getImplementationName( ) override;
1043 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1044 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
1045};
1046
1047// XEventsSupplier
1048uno::Reference< container::XNameReplace > SAL_CALL SdXShape::getEvents( )
1049{
1050 return new SdUnoEventsAccess( this );
1051}
1052
1053constexpr OUStringLiteral gaStrOnClick( u"OnClick" );
1054constexpr OUStringLiteral gaStrServiceName( u"com.sun.star.documents.Events" );
1055constexpr OUStringLiteral gaStrEventType( u"EventType" );
1056constexpr OUStringLiteral gaStrPresentation( u"Presentation" );
1057constexpr OUStringLiteral gaStrLibrary(u"Library");
1058constexpr OUStringLiteral gaStrMacroName(u"MacroName");
1059constexpr OUStringLiteral gaStrClickAction( u"ClickAction" );
1060constexpr OUStringLiteral gaStrBookmark( u"Bookmark" );
1061constexpr OUStringLiteral gaStrEffect( u"Effect" );
1062constexpr OUStringLiteral gaStrPlayFull( u"PlayFull" );
1063constexpr OUStringLiteral gaStrVerb( u"Verb" );
1064constexpr OUStringLiteral gaStrSoundURL( u"SoundURL" );
1065constexpr OUStringLiteral gaStrSpeed( u"Speed" );
1066constexpr OUStringLiteral gaStrStarBasic( u"StarBasic" );
1067constexpr OUStringLiteral gaStrScript( u"Script" );
1068
1070 : mpShape( pShape )
1071{
1072}
1073
1074namespace {
1075
1076enum class FoundFlags {
1077 NONE = 0x0000,
1078 ClickAction = 0x0001,
1079 Bookmark = 0x0002,
1080 Effect = 0x0004,
1081 PlayFull = 0x0008,
1082 Verb = 0x0010,
1083 SoundUrl = 0x0020,
1084 Speed = 0x0040,
1085 EventType = 0x0080,
1086 Macro = 0x0100,
1087 Library = 0x0200,
1088};
1089
1090}
1091
1092namespace o3tl {
1093 template<> struct typed_flags<FoundFlags> : is_typed_flags<FoundFlags, 0x03ff> {};
1094}
1095
1097{
1098 pInfo->SetBookmark( "" );
1099 pInfo->mbSecondSoundOn = false;
1100 pInfo->mbSecondPlayFull = false;
1101 pInfo->meClickAction = presentation::ClickAction_NONE;
1102 pInfo->meSecondEffect = presentation::AnimationEffect_NONE;
1103 pInfo->meSecondSpeed = presentation::AnimationSpeed_MEDIUM;
1104 pInfo->mnVerb = 0;
1105}
1106
1107// XNameReplace
1108void SAL_CALL SdUnoEventsAccess::replaceByName( const OUString& aName, const uno::Any& aElement )
1109{
1110 if( mpShape == nullptr || aName != gaStrOnClick )
1111 throw container::NoSuchElementException();
1112
1113 uno::Sequence< beans::PropertyValue > aProperties;
1114 if( !aElement.hasValue() || aElement.getValueType() != getElementType() || !(aElement >>= aProperties) )
1115 throw lang::IllegalArgumentException();
1116
1117 FoundFlags nFound = FoundFlags::NONE;
1118
1119 OUString aStrEventType;
1120 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1121 presentation::AnimationEffect eEffect = presentation::AnimationEffect_NONE;
1122 presentation::AnimationSpeed eSpeed = presentation::AnimationSpeed_MEDIUM;
1123 OUString aStrSoundURL;
1124 bool bPlayFull = false;
1125 sal_Int32 nVerb = 0;
1126 OUString aStrMacro;
1127 OUString aStrLibrary;
1128 OUString aStrBookmark;
1129
1130 for( const beans::PropertyValue& rProperty : std::as_const(aProperties) )
1131 {
1132 if( !( nFound & FoundFlags::EventType ) && rProperty.Name == gaStrEventType )
1133 {
1134 if( rProperty.Value >>= aStrEventType )
1135 {
1136 nFound |= FoundFlags::EventType;
1137 continue;
1138 }
1139 }
1140 else if( !( nFound & FoundFlags::ClickAction ) && rProperty.Name == gaStrClickAction )
1141 {
1142 if( rProperty.Value >>= eClickAction )
1143 {
1144 nFound |= FoundFlags::ClickAction;
1145 continue;
1146 }
1147 }
1148 else if( !( nFound & FoundFlags::Macro ) && ( rProperty.Name == gaStrMacroName || rProperty.Name == gaStrScript ) )
1149 {
1150 if( rProperty.Value >>= aStrMacro )
1151 {
1152 nFound |= FoundFlags::Macro;
1153 continue;
1154 }
1155 }
1156 else if( !( nFound & FoundFlags::Library ) && rProperty.Name == gaStrLibrary )
1157 {
1158 if( rProperty.Value >>= aStrLibrary )
1159 {
1160 nFound |= FoundFlags::Library;
1161 continue;
1162 }
1163 }
1164 else if( !( nFound & FoundFlags::Effect ) && rProperty.Name == gaStrEffect )
1165 {
1166 if( rProperty.Value >>= eEffect )
1167 {
1168 nFound |= FoundFlags::Effect;
1169 continue;
1170 }
1171 }
1172 else if( !( nFound & FoundFlags::Bookmark ) && rProperty.Name == gaStrBookmark )
1173 {
1174 if( rProperty.Value >>= aStrBookmark )
1175 {
1176 nFound |= FoundFlags::Bookmark;
1177 continue;
1178 }
1179 }
1180 else if( !( nFound & FoundFlags::Speed ) && rProperty.Name == gaStrSpeed )
1181 {
1182 if( rProperty.Value >>= eSpeed )
1183 {
1184 nFound |= FoundFlags::Speed;
1185 continue;
1186 }
1187 }
1188 else if( !( nFound & FoundFlags::SoundUrl ) && rProperty.Name == gaStrSoundURL )
1189 {
1190 if( rProperty.Value >>= aStrSoundURL )
1191 {
1192 nFound |= FoundFlags::SoundUrl;
1193 continue;
1194 }
1195 }
1196 else if( !( nFound & FoundFlags::PlayFull ) && rProperty.Name == gaStrPlayFull )
1197 {
1198 if( rProperty.Value >>= bPlayFull )
1199 {
1200 nFound |= FoundFlags::PlayFull;
1201 continue;
1202 }
1203 }
1204 else if( !( nFound & FoundFlags::Verb ) && rProperty.Name == gaStrVerb )
1205 {
1206 if( rProperty.Value >>= nVerb )
1207 {
1208 nFound |= FoundFlags::Verb;
1209 continue;
1210 }
1211 }
1212
1213 throw lang::IllegalArgumentException();
1214 }
1215
1216 bool bOk = false;
1217 do
1218 {
1219 if( !( nFound & FoundFlags::EventType ) )
1220 break;
1221
1222 if( aStrEventType == gaStrPresentation )
1223 {
1224 if( !( nFound & FoundFlags::ClickAction ) )
1225 break;
1226
1228 if( presentation::ClickAction_NONE == eClickAction && nullptr == pInfo )
1229 {
1230 bOk = true;
1231 break;
1232 }
1233
1234 if( nullptr == pInfo )
1235 pInfo = mpShape->GetAnimationInfo( true );
1236
1237 DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1238 if( nullptr == pInfo )
1239 break;
1240
1242 pInfo->meClickAction = eClickAction;
1243
1244 switch( eClickAction )
1245 {
1246 case presentation::ClickAction_NONE:
1247 case presentation::ClickAction_PREVPAGE:
1248 case presentation::ClickAction_NEXTPAGE:
1249 case presentation::ClickAction_FIRSTPAGE:
1250 case presentation::ClickAction_LASTPAGE:
1251 case presentation::ClickAction_INVISIBLE:
1252 case presentation::ClickAction_STOPPRESENTATION:
1253 {
1254 bOk = true;
1255 }
1256 break;
1257
1258 case presentation::ClickAction_PROGRAM:
1259 case presentation::ClickAction_BOOKMARK:
1260 case presentation::ClickAction_DOCUMENT:
1261 if( nFound & FoundFlags::Bookmark )
1262 {
1263 if( eClickAction == presentation::ClickAction_BOOKMARK )
1264 {
1265 aStrBookmark = getUiNameFromPageApiNameImpl( aStrBookmark );
1266 }
1267 else if( eClickAction == presentation::ClickAction_DOCUMENT )
1268 {
1269 sal_Int32 nPos = aStrBookmark.lastIndexOf( '#' );
1270 if( nPos >= 0 )
1271 {
1272 OUString aURL = aStrBookmark.subView( 0, nPos+1 )
1273 + getUiNameFromPageApiNameImpl( aStrBookmark.copy( nPos+1 ) );
1274 aStrBookmark = aURL;
1275 }
1276 }
1277
1278 pInfo->SetBookmark( aStrBookmark );
1279 bOk = true;
1280 }
1281 break;
1282
1283 case presentation::ClickAction_MACRO:
1284 if( nFound & FoundFlags::Macro )
1285 {
1286 pInfo->SetBookmark( aStrMacro );
1287 bOk = true;
1288 }
1289 break;
1290
1291 case presentation::ClickAction_VERB:
1292 if( nFound & FoundFlags::Verb )
1293 {
1294 pInfo->mnVerb = static_cast<sal_uInt16>(nVerb);
1295 bOk = true;
1296 }
1297 break;
1298
1299 case presentation::ClickAction_VANISH:
1300 if( !( nFound & FoundFlags::Effect ) )
1301 break;
1302
1303 pInfo->meSecondEffect = eEffect;
1304 pInfo->meSecondSpeed = nFound & FoundFlags::Speed ? eSpeed : presentation::AnimationSpeed_MEDIUM;
1305
1306 bOk = true;
1307
1308 [[fallthrough]];
1309
1310 case presentation::ClickAction_SOUND:
1311 if( nFound & FoundFlags::SoundUrl )
1312 {
1313 pInfo->SetBookmark( aStrSoundURL );
1314 if( eClickAction != presentation::ClickAction_SOUND )
1315 pInfo->mbSecondSoundOn = !aStrSoundURL.isEmpty();
1316 pInfo->mbSecondPlayFull = (nFound & FoundFlags::PlayFull) && bPlayFull;
1317
1318 bOk = true;
1319 }
1320 break;
1321 default:
1322 break;
1323 }
1324 }
1325 else
1326 {
1327 SdAnimationInfo* pInfo = mpShape->GetAnimationInfo( true );
1328
1329 DBG_ASSERT( pInfo, "shape animation info could not be created!" );
1330 if( nullptr == pInfo )
1331 break;
1332
1334 pInfo->meClickAction = presentation::ClickAction_MACRO;
1335
1336 if ( SfxApplication::IsXScriptURL( aStrMacro ) )
1337 {
1338 pInfo->SetBookmark( aStrMacro );
1339 }
1340 else
1341 {
1342 sal_Int32 nIdx{ 0 };
1343 const std::u16string_view aLibName = o3tl::getToken(aStrMacro, 0, '.', nIdx);
1344 const std::u16string_view aModulName = o3tl::getToken(aStrMacro, 0, '.', nIdx);
1345 const std::u16string_view aMacroName = o3tl::getToken(aStrMacro, 0, '.', nIdx);
1346
1347 OUStringBuffer sBuffer(
1348 OUString::Concat(aMacroName) + OUStringChar('.') + aModulName + OUStringChar('.') + aLibName + OUStringChar('.') );
1349
1350 if ( aStrLibrary == "StarOffice" )
1351 {
1352 sBuffer.append( "BASIC" );
1353 }
1354 else
1355 {
1356 sBuffer.append( aStrLibrary );
1357 }
1358
1359 pInfo->SetBookmark( sBuffer.makeStringAndClear() );
1360 }
1361 bOk = true;
1362 }
1363 }
1364 while(false);
1365
1366 if( !bOk )
1367 throw lang::IllegalArgumentException();
1368}
1369
1370// XNameAccess
1371uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName )
1372{
1373 if( mpShape == nullptr || aName != gaStrOnClick )
1374 throw container::NoSuchElementException();
1375
1377
1378 presentation::ClickAction eClickAction = presentation::ClickAction_NONE;
1379 if( pInfo )
1380 eClickAction = pInfo->meClickAction;
1381
1382 sal_Int32 nPropertyCount = 2;
1383 switch( eClickAction )
1384 {
1385 case presentation::ClickAction_NONE:
1386 case presentation::ClickAction_PREVPAGE:
1387 case presentation::ClickAction_NEXTPAGE:
1388 case presentation::ClickAction_FIRSTPAGE:
1389 case presentation::ClickAction_LASTPAGE:
1390 case presentation::ClickAction_INVISIBLE:
1391 case presentation::ClickAction_STOPPRESENTATION:
1392 break;
1393 case presentation::ClickAction_PROGRAM:
1394 case presentation::ClickAction_VERB:
1395 case presentation::ClickAction_BOOKMARK:
1396 case presentation::ClickAction_DOCUMENT:
1397 case presentation::ClickAction_MACRO:
1398 if ( !SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1399 nPropertyCount += 1;
1400 break;
1401
1402 case presentation::ClickAction_SOUND:
1403 nPropertyCount += 2;
1404 break;
1405
1406 case presentation::ClickAction_VANISH:
1407 nPropertyCount += 4;
1408 break;
1409 default:
1410 break;
1411 }
1412
1413 uno::Sequence< beans::PropertyValue > aProperties( nPropertyCount );
1414 beans::PropertyValue* pProperties = aProperties.getArray();
1415
1416 uno::Any aAny;
1417
1418 if( eClickAction == presentation::ClickAction_MACRO )
1419 {
1420 if ( SfxApplication::IsXScriptURL( pInfo->GetBookmark() ) )
1421 {
1422 // Scripting Framework URL
1423 aAny <<= OUString(gaStrScript);
1424 pProperties->Name = gaStrEventType;
1425 pProperties->Handle = -1;
1426 pProperties->Value = aAny;
1427 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1428 pProperties++;
1429
1430 aAny <<= pInfo->GetBookmark();
1431 pProperties->Name = gaStrScript;
1432 pProperties->Handle = -1;
1433 pProperties->Value = aAny;
1434 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1435 pProperties++;
1436 }
1437 else
1438 {
1439 // Old Basic macro URL
1440 aAny <<= OUString(gaStrStarBasic);
1441 pProperties->Name = gaStrEventType;
1442 pProperties->Handle = -1;
1443 pProperties->Value = aAny;
1444 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1445 pProperties++;
1446
1447 OUString aMacro = pInfo->GetBookmark();
1448
1449 // aMacro has got following format:
1450 // "Macroname.Modulname.Libname.Documentname" or
1451 // "Macroname.Modulname.Libname.Applicationname"
1452 sal_Int32 nIdx{ 0 };
1453 const std::u16string_view aMacroName = o3tl::getToken(aMacro, 0, '.', nIdx);
1454 const std::u16string_view aModulName = o3tl::getToken(aMacro, 0, '.', nIdx);
1455 const std::u16string_view aLibName = o3tl::getToken(aMacro, 0, '.', nIdx);
1456
1457 OUString sBuffer = OUString::Concat(aLibName) +
1458 "." +
1459 aModulName +
1460 "." +
1461 aMacroName;
1462
1463 aAny <<= sBuffer;
1464 pProperties->Name = gaStrMacroName;
1465 pProperties->Handle = -1;
1466 pProperties->Value = aAny;
1467 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1468 pProperties++;
1469
1470 aAny <<= OUString( "StarOffice" );
1471 pProperties->Name = gaStrLibrary;
1472 pProperties->Handle = -1;
1473 pProperties->Value = aAny;
1474 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1475 }
1476 }
1477 else
1478 {
1479 aAny <<= OUString(gaStrPresentation);
1480 pProperties->Name = gaStrEventType;
1481 pProperties->Handle = -1;
1482 pProperties->Value = aAny;
1483 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1484 pProperties++;
1485
1486 aAny <<= eClickAction;
1487 pProperties->Name = gaStrClickAction;
1488 pProperties->Handle = -1;
1489 pProperties->Value = aAny;
1490 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1491 pProperties++;
1492
1493 switch( eClickAction )
1494 {
1495 case presentation::ClickAction_NONE:
1496 case presentation::ClickAction_PREVPAGE:
1497 case presentation::ClickAction_NEXTPAGE:
1498 case presentation::ClickAction_FIRSTPAGE:
1499 case presentation::ClickAction_LASTPAGE:
1500 case presentation::ClickAction_INVISIBLE:
1501 case presentation::ClickAction_STOPPRESENTATION:
1502 break;
1503 case presentation::ClickAction_BOOKMARK:
1504 {
1505 const OUString aStrBookmark( getPageApiNameFromUiName( pInfo->GetBookmark()) );
1506 pProperties->Name = gaStrBookmark;
1507 pProperties->Handle = -1;
1508 pProperties->Value <<= aStrBookmark;
1509 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1510 }
1511 break;
1512
1513 case presentation::ClickAction_DOCUMENT:
1514 case presentation::ClickAction_PROGRAM:
1515 {
1516 OUString aString( pInfo->GetBookmark());
1517 sal_Int32 nPos = aString.lastIndexOf( '#' );
1518 if( nPos >= 0 )
1519 {
1520 OUString aURL = aString.subView( 0, nPos+1 ) +
1521 getPageApiNameFromUiName( aString.copy( nPos+1 ) );
1522 aString = aURL;
1523 }
1524 pProperties->Name = gaStrBookmark;
1525 pProperties->Handle = -1;
1526 pProperties->Value <<= aString;
1527 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1528 }
1529 break;
1530
1531 case presentation::ClickAction_VANISH:
1532 aAny <<= pInfo->meSecondEffect;
1533 pProperties->Name = gaStrEffect;
1534 pProperties->Handle = -1;
1535 pProperties->Value = aAny;
1536 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1537 pProperties++;
1538
1539 aAny <<= pInfo->meSecondSpeed;
1540 pProperties->Name = gaStrSpeed;
1541 pProperties->Handle = -1;
1542 pProperties->Value = aAny;
1543 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1544 pProperties++;
1545
1546 [[fallthrough]];
1547
1548 case presentation::ClickAction_SOUND:
1549 if( eClickAction == presentation::ClickAction_SOUND || pInfo->mbSecondSoundOn )
1550 {
1551 aAny <<= pInfo->GetBookmark();
1552 pProperties->Name = gaStrSoundURL;
1553 pProperties->Handle = -1;
1554 pProperties->Value = aAny;
1555 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1556 pProperties++;
1557
1558 pProperties->Name = gaStrPlayFull;
1559 pProperties->Handle = -1;
1560 pProperties->Value <<= pInfo->mbSecondPlayFull;
1561 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1562 }
1563 break;
1564
1565 case presentation::ClickAction_VERB:
1566 aAny <<= static_cast<sal_Int32>(pInfo->mnVerb);
1567 pProperties->Name = gaStrVerb;
1568 pProperties->Handle = -1;
1569 pProperties->Value = aAny;
1570 pProperties->State = beans::PropertyState_DIRECT_VALUE;
1571 break;
1572 default:
1573 break;
1574 }
1575 }
1576
1577 aAny <<= aProperties;
1578 return aAny;
1579}
1580
1581uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getElementNames( )
1582{
1583 return { gaStrOnClick };
1584}
1585
1586sal_Bool SAL_CALL SdUnoEventsAccess::hasByName( const OUString& aName )
1587{
1588 return aName == gaStrOnClick;
1589}
1590
1591// XElementAccess
1593{
1595}
1596
1598{
1599 return true;
1600}
1601
1602// XServiceInfo
1604{
1605 return "SdUnoEventsAccess";
1606}
1607
1608sal_Bool SAL_CALL SdUnoEventsAccess::supportsService( const OUString& ServiceName )
1609{
1610 return cppu::supportsService(this, ServiceName);
1611}
1612
1613uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getSupportedServiceNames( )
1614{
1615 return { gaStrServiceName };
1616}
1617
1618/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertiesInfo aProperties
AnimatableShapeSharedPtr mpShape
bool IsEffectivelyVertical() const
bool mbPlayFull
play sound completely.
Definition: anminfo.hxx:47
void SetBookmark(const OUString &rBookmark)
Definition: anminfo.cxx:95
css::presentation::ClickAction meClickAction
Action at mouse click.
Definition: anminfo.hxx:48
bool mbIsMovie
if group object than it is a sequence of them.
Definition: anminfo.hxx:41
Color maBlueScreen
identifies "background pixels"
Definition: anminfo.hxx:43
sal_uInt16 mnVerb
for OLE object
Definition: anminfo.hxx:54
css::presentation::AnimationEffect meSecondEffect
for object fading.
Definition: anminfo.hxx:49
bool mbSecondSoundOn
for object fading.
Definition: anminfo.hxx:52
OUString GetBookmark() const
Definition: anminfo.cxx:110
OUString maSoundFile
Path to the sound file in MS DOS notation.
Definition: anminfo.hxx:45
bool mbSoundOn
Sound on / off.
Definition: anminfo.hxx:46
bool mbSecondPlayFull
for object fading.
Definition: anminfo.hxx:53
css::presentation::AnimationSpeed meSecondSpeed
for object fading.
Definition: anminfo.hxx:50
static SdAnimationInfo * GetShapeUserData(SdrObject &rObject, bool bCreate=false)
Definition: drawdoc2.cxx:959
SdOutliner * GetInternalOutliner(bool bCreateOutliner=true)
Definition: drawdoc.cxx:930
SAL_DLLPRIVATE sal_uInt16 GetPageByName(std::u16string_view rPgName, bool &rbIsMasterPage) const
Return the first page that has the given name.
Definition: drawdoc2.cxx:126
SAL_DLLPRIVATE::sd::DrawDocShell * GetDocSh() const
Definition: drawdoc.hxx:242
static OUString getPageApiNameFromUiName(const OUString &rUIName)
Definition: unopage.cxx:2192
static OUString getUiNameFromPageApiName(const OUString &rApiName)
Definition: unopage.cxx:2230
The main purpose of this class is searching and replacing as well as spelling of impress documents.
Definition: Outliner.hxx:123
virtual rtl::Reference< SdrObject > NbcRemoveObject(size_t nObjNum) override
Definition: sdpage.cxx:1718
virtual SfxStyleSheet * GetTextStyleSheetForObject(SdrObject *pObj) const override
Definition: sdpage2.cxx:437
OUString GetPresObjText(PresObjKind eObjKind) const
Definition: sdpage.cxx:2581
PresObjKind GetPresObjKind(SdrObject *pObj) const
Definition: sdpage.cxx:2309
SdUnoEventsAccess(SdXShape *pShape) noexcept
Definition: unoobj.cxx:1069
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: unoobj.cxx:1371
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: unoobj.cxx:1586
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:1613
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: unoobj.cxx:1108
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj.cxx:1592
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: unoobj.cxx:1581
SdXShape * mpShape
Definition: unoobj.cxx:1024
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:1603
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoobj.cxx:1608
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:1597
SdDrawDocument * GetDoc() const
Definition: unomodel.hxx:141
void SetModified() noexcept
Definition: unomodel.cxx:593
bool IsImpressDocument() const
Definition: unomodel.hxx:142
bool IsMasterDepend() const noexcept
Definition: unoobj.cxx:951
SdXShape(SvxShape *pShape, SdXImpressDocument *pModel)
Definition: unoobj.cxx:247
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unoobj.cxx:300
o3tl::span< const SfxItemPropertyMapEntry > mpMap
Definition: unoobj.hxx:41
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:797
virtual bool queryAggregation(const css::uno::Type &rType, css::uno::Any &aAny) override
Definition: unoobj.cxx:286
virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents() override
Definition: unoobj.cxx:1048
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unoobj.cxx:271
const SvxItemPropertySet * mpPropSet
Definition: unoobj.hxx:40
void SetStyleSheet(const css::uno::Any &rAny)
Definition: unoobj.cxx:977
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:379
OUString GetPlaceholderText() const
Definition: unoobj.cxx:852
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoobj.cxx:404
void SetMasterDepend(bool bDepend) noexcept
Definition: unoobj.cxx:957
virtual ~SdXShape() noexcept
Definition: unoobj.cxx:261
friend class SdUnoEventsAccess
Definition: unoobj.hxx:36
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoobj.cxx:643
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unoobj.cxx:349
virtual void SAL_CALL acquire() noexcept override
Definition: unoobj.cxx:276
void SetEmptyPresObj(bool bEmpty)
sets/reset the empty status of a presentation object
Definition: unoobj.cxx:872
SvxShape * mpShape
Definition: unoobj.hxx:39
css::uno::Any GetStyleSheet() const
Definition: unoobj.cxx:1006
bool IsPresObj() const
checks if this is a presentation object
Definition: unoobj.cxx:822
virtual void dispose() override
Definition: unoobj.cxx:265
bool IsEmptyPresObj() const
checks if this presentation object is empty
Definition: unoobj.cxx:836
SdAnimationInfo * GetAnimationInfo(bool bCreate=false) const
Definition: unoobj.cxx:786
SdXImpressDocument * mpModel
Definition: unoobj.hxx:42
virtual void SAL_CALL release() noexcept override
Definition: unoobj.cxx:281
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unoobj.cxx:363
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unoobj.cxx:331
void SetGraphic(const Graphic &rGrf)
SfxStyleSheetBasePool * GetStyleSheetPool() const
virtual SdrObjList * GetSubList() const override
void SetObjectNavigationPosition(SdrObject &rObject, const sal_uInt32 nNewNavigationPosition)
size_t GetObjCount() const
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
SdrObjUserCall * GetUserCall() const
virtual void NbcSetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
void SetOutlinerParaObject(std::optional< OutlinerParaObject > pTextObject)
void AppendUserData(std::unique_ptr< SdrObjUserData > pData)
static SdrItemPool & GetGlobalDrawObjectItemPool()
void SetUserCall(SdrObjUserCall *pUser)
void SetEmptyPresObj(bool bEpt)
void SetStyleSheet(SfxStyleSheet *pNewStyleSheet, bool bDontRemoveHardAttr)
virtual SdrInventor GetObjInventor() const
virtual OutlinerParaObject * GetOutlinerParaObject() const
sal_uInt32 GetOrdNum() const
bool IsEmptyPresObj() const
SdrObjList * getParentSdrObjListFromSdrObject() const
SfxStyleSheet * GetStyleSheet() const
virtual SdrObjKind GetObjIdentifier() const
sal_uInt32 GetNavigationPosition() const
SdrPage * getSdrPageFromSdrObject() const
void ClearGraphic()
bool IsMasterPage() const
bool CanCreateEditOutlinerParaObject() const
static bool IsXScriptURL(const OUString &rScriptURL)
void Invalidate(sal_uInt16 nId)
SfxStyleFamily GetFamily() const
static SfxUnoStyleSheet * getUnoStyleSheet(const css::uno::Reference< css::style::XStyle > &xStyle)
SfxBindings & GetBindings()
void SetImageMap(const ImageMap &rIMap)
static SvxIMapInfo * GetIMapInfo(const SdrObject *pObject)
const ImageMap & GetImageMap() const
const SfxItemPropertyMapEntry * getPropertyMapEntry(std::u16string_view rName) const
static void ReadObjText(SvStream &rStream, SdrObject *pObj)
o3tl::span< const SfxItemPropertyMapEntry > getPropertyMapEntries() const
void _setPropertyToDefault(const OUString &PropertyName)
void setMaster(SvxShapeMaster *pMaster)
css::uno::Sequence< OUString > _getSupportedServiceNames()
css::uno::Sequence< css::uno::Type > const & _getTypes()
css::beans::PropertyState _getPropertyState(const OUString &PropertyName)
css::uno::Any _getPropertyDefault(const OUString &aPropertyName)
css::uno::Reference< css::beans::XPropertySetInfo > const & _getPropertySetInfo()
SdrObjKind getShapeKind() const
css::uno::Any _getPropertyValue(const OUString &PropertyName)
void _setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue)
SdrObject * GetSdrObject() const
css::uno::Type const & get()
sd::ViewShell * GetViewShell()
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
int nCount
#define DBG_ASSERT(sCon, aError)
URL aURL
float u
EmbeddedObjectRef * pObject
OUString aName
sal_uInt16 nPos
NONE
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::map< SdrObjKind, css::uno::Sequence< css::uno::Type > > SdTypesCache
Definition: sdmod.hxx:71
std::map< o3tl::span< SfxItemPropertyMapEntry const >, css::uno::Reference< css::beans::XPropertySetInfo >, SdExtPropertySetInfoCacheCompare > SdExtPropertySetInfoCache
Definition: sdmod.hxx:70
#define SD_MOD()
Definition: sdmod.hxx:184
bool hasValue()
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SdrObjKind
#define SDRPAGE_NOTFOUND
unsigned char sal_Bool
#define SAL_MAX_UINT32
SVT_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvUnoImageMap_createInstance()
SVT_DLLPUBLIC bool SvUnoImageMap_fillImageMap(const css::uno::Reference< css::uno::XInterface > &xImageMap, ImageMap &rMap)
OUString getPageApiNameFromUiName(const OUString &rUIName)
Definition: unopage.cxx:2174
constexpr OUStringLiteral gaStrScript(u"Script")
constexpr OUStringLiteral gaStrMacroName(u"MacroName")
#define IMPRESS_MAP_ENTRIES
Definition: unoobj.cxx:107
#define DRAW_MAP_ENTRIES
Definition: unoobj.cxx:151
#define WID_TEXTEFFECT
Definition: unoobj.cxx:82
#define WID_ANIMPATH
Definition: unoobj.cxx:95
#define WID_CLICKACTION
Definition: unoobj.cxx:84
#define WID_BOOKMARK
Definition: unoobj.cxx:83
constexpr OUStringLiteral gaStrPresentation(u"Presentation")
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
Definition: unoobj.cxx:157
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetEmpty_SdXShapePropertyMap_Impl()
Definition: unoobj.cxx:225
#define WID_ISPRESOBJ
Definition: unoobj.cxx:100
static const SvxItemPropertySet * lcl_GetEmpty_SdXShapePropertySet_Impl()
Definition: unoobj.cxx:230
#define WID_SPEED
Definition: unoobj.cxx:81
#define WID_PLACEHOLDERTEXT
Definition: unoobj.cxx:104
constexpr OUStringLiteral gaStrStarBasic(u"StarBasic")
constexpr OUStringLiteral gaStrSoundURL(u"SoundURL")
#define WID_PLAYFULL
Definition: unoobj.cxx:85
constexpr OUStringLiteral gaStrVerb(u"Verb")
#define WID_LEGACYFRAGMENT
Definition: unoobj.cxx:105
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
Definition: unoobj.cxx:142
#define WID_SOUNDON
Definition: unoobj.cxx:87
#define WID_STYLE
Definition: unoobj.cxx:94
constexpr OUStringLiteral gaStrEffect(u"Effect")
#define WID_NAVORDER
Definition: unoobj.cxx:103
static o3tl::span< const SfxItemPropertyMapEntry > lcl_ImplGetShapePropertyMap(bool bImpress, bool bGraphicObj)
Definition: unoobj.cxx:174
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
Definition: unoobj.cxx:165
#define WID_DIMCOLOR
Definition: unoobj.cxx:90
static const SvxItemPropertySet * lcl_ImplGetShapePropertySet(bool bImpress, bool bGraphicObj)
Definition: unoobj.cxx:194
constexpr OUStringLiteral gaStrBookmark(u"Bookmark")
static void clearEventsInAnimationInfo(SdAnimationInfo *pInfo)
Definition: unoobj.cxx:1096
constexpr OUStringLiteral gaStrServiceName(u"com.sun.star.documents.Events")
#define WID_IMAGEMAP
Definition: unoobj.cxx:96
const SvEventDescription * ImplGetSupportedMacroItems()
Definition: unoobj.cxx:235
static o3tl::span< const SfxItemPropertyMapEntry > lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
Definition: unoobj.cxx:132
#define WID_PRESORDER
Definition: unoobj.cxx:93
constexpr OUStringLiteral gaStrClickAction(u"ClickAction")
#define WID_SOUNDFILE
Definition: unoobj.cxx:86
constexpr OUStringLiteral gaStrPlayFull(u"PlayFull")
constexpr OUStringLiteral gaStrEventType(u"EventType")
#define WID_EFFECT
Definition: unoobj.cxx:80
#define WID_ISANIMATION
Definition: unoobj.cxx:97
#define WID_DIMPREV
Definition: unoobj.cxx:92
constexpr OUStringLiteral gaStrSpeed(u"Speed")
#define WID_DIMHIDE
Definition: unoobj.cxx:91
#define WID_MASTERDEPEND
Definition: unoobj.cxx:101
constexpr OUStringLiteral gaStrLibrary(u"Library")
#define WID_ISEMPTYPRESOBJ
Definition: unoobj.cxx:99
#define WID_VERB
Definition: unoobj.cxx:89
constexpr OUStringLiteral gaStrOnClick(u"OnClick")
#define WID_BLUESCREEN
Definition: unoobj.cxx:88
OUString getUiNameFromPageApiNameImpl(const OUString &rApiName)
Definition: unopage.cxx:2197
const SvXMLTokenMapEntry aTypes[]