1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
23 #include <string_view>
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>
41 #include <comphelper/extract.hxx>
42 #include <cppuhelper/implbase.hxx>
43 #include <cppuhelper/supportsservice.hxx>
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>
50 #include <filter/msfilter/msdffimp.hxx>
51 #include <svl/instrm.hxx>
52 #include <editeng/outlobj.hxx>
53 #include <Outliner.hxx>
54 #include <comphelper/sequence.hxx>
55 #include <svx/svdogrp.hxx>
56 #include <o3tl/typed_flags_set.hxx>
57 #include <vcl/svapp.hxx>
58 #include <tools/debug.hxx>
60 #include <anminfo.hxx>
62 #include <unoprnms.hxx>
63 #include <unomodel.hxx>
64 #include <drawdoc.hxx>
67 #include <ViewShell.hxx>
68 #include <unopage.hxx>
69 #include <DrawDocShell.hxx>
70 #include <EffectMigration.hxx>
73 using namespace ::com::sun::star
;
74 using namespace ::com::sun::star::presentation
;
75 using namespace ::com::sun::star::animations
;
77 using ::com::sun::star::uno::Any
;
78 using ::com::sun::star::drawing::XShape
;
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
88 #define WID_BLUESCREEN 9
90 #define WID_DIMCOLOR 11
91 #define WID_DIMHIDE 12
92 #define WID_DIMPREV 13
93 #define WID_PRESORDER 14
95 #define WID_ANIMPATH 16
96 #define WID_IMAGEMAP 17
97 #define WID_ISANIMATION 18
99 #define WID_ISEMPTYPRESOBJ 20
100 #define WID_ISPRESOBJ 21
101 #define WID_MASTERDEPEND 22
103 #define WID_NAVORDER 23
104 #define WID_PLACEHOLDERTEXT 24
105 #define WID_LEGACYFRAGMENT 25
107 #define IMPRESS_MAP_ENTRIES \
108 { u"" UNO_NAME_OBJ_LEGACYFRAGMENT ""_ustr,WID_LEGACYFRAGMENT, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
109 { u"" UNO_NAME_OBJ_ANIMATIONPATH ""_ustr, WID_ANIMPATH, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
110 { u"" UNO_NAME_OBJ_BOOKMARK ""_ustr, WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
111 { u"" UNO_NAME_OBJ_DIMCOLOR ""_ustr, WID_DIMCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0},\
112 { u"" UNO_NAME_OBJ_DIMHIDE ""_ustr, WID_DIMHIDE, cppu::UnoType<bool>::get(), 0, 0},\
113 { u"" UNO_NAME_OBJ_DIMPREV ""_ustr, WID_DIMPREV, cppu::UnoType<bool>::get(), 0, 0},\
114 { u"" UNO_NAME_OBJ_EFFECT ""_ustr, WID_EFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
115 { u"" UNO_NAME_OBJ_ISEMPTYPRESOBJ_SD ""_ustr,WID_ISEMPTYPRESOBJ, cppu::UnoType<bool>::get(), 0, 0},\
116 { u"" UNO_NAME_OBJ_ISPRESOBJ ""_ustr, WID_ISPRESOBJ, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY, 0},\
117 { u"" UNO_NAME_OBJ_MASTERDEPENDENT ""_ustr,WID_MASTERDEPEND, cppu::UnoType<bool>::get(), 0, 0},\
118 { u"" UNO_NAME_OBJ_CLICKACTION ""_ustr, WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(), 0, 0},\
119 { u"" UNO_NAME_OBJ_PLAYFULL ""_ustr, WID_PLAYFULL, cppu::UnoType<bool>::get(), 0, 0},\
120 { u"" UNO_NAME_OBJ_PRESORDER ""_ustr, WID_PRESORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
121 { u"" UNO_NAME_OBJ_STYLE ""_ustr, WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
122 { u"" UNO_NAME_OBJ_SOUNDFILE ""_ustr, WID_SOUNDFILE, cppu::UnoType<OUString>::get(), 0, 0},\
123 { u"" UNO_NAME_OBJ_SOUNDON ""_ustr, WID_SOUNDON, cppu::UnoType<bool>::get(), 0, 0},\
124 { u"" UNO_NAME_OBJ_SPEED ""_ustr, WID_SPEED, cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},\
125 { u"" UNO_NAME_OBJ_TEXTEFFECT ""_ustr, WID_TEXTEFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
126 { u"" UNO_NAME_OBJ_BLUESCREEN ""_ustr, WID_BLUESCREEN, cppu::UnoType<sal_Int32>::get(), 0, 0},\
127 { u"" UNO_NAME_OBJ_VERB ""_ustr, WID_VERB, cppu::UnoType<sal_Int32>::get(), 0, 0},\
128 { u"IsAnimation"_ustr, WID_ISANIMATION, cppu::UnoType<bool>::get(), 0, 0},\
129 { u"NavigationOrder"_ustr, WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
130 { u"PlaceholderText"_ustr, WID_PLACEHOLDERTEXT, cppu::UnoType<OUString>::get(), 0, 0},\
132 static std::span<const SfxItemPropertyMapEntry> lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
134 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl
[] =
136 { u
"ImageMap"_ustr
, WID_IMAGEMAP
, cppu::UnoType
<container::XIndexContainer
>::get(), 0, 0 },
139 return aImpress_SdXShapePropertyGraphicMap_Impl
;
142 static std::span
<const SfxItemPropertyMapEntry
> lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
144 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl
[] =
148 return aImpress_SdXShapePropertySimpleMap_Impl
;
151 #define DRAW_MAP_ENTRIES\
152 { u"" UNO_NAME_OBJ_BOOKMARK ""_ustr, WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
153 { u"" UNO_NAME_OBJ_CLICKACTION ""_ustr, WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(),0, 0},\
154 { u"" UNO_NAME_OBJ_STYLE ""_ustr, WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
155 { u"NavigationOrder"_ustr, WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
157 static std::span<const SfxItemPropertyMapEntry> lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
159 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl
[] =
163 return aDraw_SdXShapePropertyMap_Impl
;
165 static std::span
<const SfxItemPropertyMapEntry
> lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
167 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl
[] =
169 { u
"ImageMap"_ustr
, WID_IMAGEMAP
, cppu::UnoType
<container::XIndexContainer
>::get(), 0, 0 },
172 return aDraw_SdXShapePropertyGraphicMap_Impl
;
174 static std::span
<const SfxItemPropertyMapEntry
> lcl_ImplGetShapePropertyMap( bool bImpress
, bool bGraphicObj
)
176 std::span
<const SfxItemPropertyMapEntry
> pRet
;
180 pRet
= lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
182 pRet
= lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
187 pRet
= lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
189 pRet
= lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
194 static const SvxItemPropertySet
* lcl_ImplGetShapePropertySet( bool bImpress
, bool bGraphicObj
)
196 const SvxItemPropertySet
* pRet
= nullptr;
201 static SvxItemPropertySet
aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
202 pRet
= &aImpress_SdXShapePropertyGraphicSet_Impl
;
206 static SvxItemPropertySet
aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
207 pRet
= &aImpress_SdXShapePropertySet_Impl
;
214 static SvxItemPropertySet
aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
215 pRet
= &aDraw_SdXShapePropertyGraphicSet_Impl
;
219 static SvxItemPropertySet
aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
220 pRet
= &aDraw_SdXShapePropertySet_Impl
;
225 static std::span
<const SfxItemPropertyMapEntry
> lcl_GetEmpty_SdXShapePropertyMap_Impl()
230 static const SvxItemPropertySet
* lcl_GetEmpty_SdXShapePropertySet_Impl()
232 static SvxItemPropertySet
aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool() );
233 return &aEmptyPropSet
;
235 const SvEventDescription
* ImplGetSupportedMacroItems()
237 static const SvEventDescription aMacroDescriptionsImpl
[] =
239 { SvMacroItemId::OnMouseOver
, "OnMouseOver" },
240 { SvMacroItemId::OnMouseOut
, "OnMouseOut" },
241 { SvMacroItemId::NONE
, nullptr }
244 return aMacroDescriptionsImpl
;
247 SdXShape::SdXShape(SvxShape
* pShape
, SdXImpressDocument
* pModel
)
250 lcl_ImplGetShapePropertySet(pModel
->IsImpressDocument(), pShape
->getShapeKind() == SdrObjKind::Graphic
)
251 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
253 lcl_ImplGetShapePropertyMap(pModel
->IsImpressDocument(), pShape
->getShapeKind() == SdrObjKind::Graphic
)
254 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
258 pShape
->setMaster( this );
261 SdXShape::~SdXShape() noexcept
265 void SdXShape::dispose()
267 mpShape
->setMaster( nullptr );
271 uno::Any SAL_CALL
SdXShape::queryInterface( const uno::Type
& rType
)
273 return mpShape
->queryInterface( rType
);
276 void SAL_CALL
SdXShape::acquire() noexcept
281 void SAL_CALL
SdXShape::release() noexcept
286 bool SdXShape::queryAggregation( const css::uno::Type
& rType
, css::uno::Any
& aAny
)
288 if( mpModel
&& mpModel
->IsImpressDocument() )
290 if( rType
== cppu::UnoType
<document::XEventsSupplier
>::get())
292 aAny
<<= uno::Reference
< document::XEventsSupplier
>(this);
300 uno::Sequence
< uno::Type
> SAL_CALL
SdXShape::getTypes()
302 if( mpModel
&& !mpModel
->IsImpressDocument() )
304 return mpShape
->_getTypes();
308 SdrObjKind nObjId
= mpShape
->getShapeKind();
309 uno::Sequence
< uno::Type
> aTypes
;
310 SdTypesCache
& gImplTypesCache
= SdModule::get()->gImplTypesCache
;
311 SdTypesCache::iterator
aIter( gImplTypesCache
.find( nObjId
) );
312 if( aIter
== gImplTypesCache
.end() )
314 aTypes
= mpShape
->_getTypes();
315 sal_uInt32 nCount
= aTypes
.getLength();
316 aTypes
.realloc( nCount
+1 );
317 aTypes
.getArray()[nCount
] = cppu::UnoType
<lang::XTypeProvider
>::get();
319 gImplTypesCache
.insert(std::make_pair(nObjId
, aTypes
));
323 // use the already computed implementation id
324 aTypes
= (*aIter
).second
;
331 beans::PropertyState SAL_CALL
SdXShape::getPropertyState( const OUString
& PropertyName
)
333 SolarMutexGuard aGuard
;
335 if( mpPropSet
->getPropertyMapEntry(PropertyName
) )
337 return beans::PropertyState_DIRECT_VALUE
;
341 SdrObject
* pObj
= mpShape
->GetSdrObject();
342 if( pObj
== nullptr || ( pObj
->getSdrPageFromSdrObject()->IsMasterPage() && pObj
->IsEmptyPresObj() ) )
343 return beans::PropertyState_DEFAULT_VALUE
;
345 return mpShape
->_getPropertyState( PropertyName
);
349 void SAL_CALL
SdXShape::setPropertyToDefault( const OUString
& PropertyName
)
351 SolarMutexGuard aGuard
;
353 if( mpPropSet
->getPropertyMapEntry(PropertyName
) )
359 mpShape
->_setPropertyToDefault(PropertyName
);
363 uno::Any SAL_CALL
SdXShape::getPropertyDefault( const OUString
& aPropertyName
)
365 SolarMutexGuard aGuard
;
367 if( mpPropSet
->getPropertyMapEntry(aPropertyName
) )
369 return getPropertyValue( aPropertyName
);
373 uno::Any
aRet( mpShape
->_getPropertyDefault(aPropertyName
) );
379 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
SdXShape::getPropertySetInfo()
381 std::span
<SfxItemPropertyMapEntry
const> nObjId
= mpShape
->getPropertyMapEntries();
382 css::uno::Reference
<css::beans::XPropertySetInfo
> pInfo
;
384 SdExtPropertySetInfoCache
& rCache
= (mpModel
&& mpModel
->IsImpressDocument()) ?
385 SdModule::get()->gImplImpressPropertySetInfoCache
: SdModule::get()->gImplDrawPropertySetInfoCache
;
387 SdExtPropertySetInfoCache::iterator
aIter( rCache
.find( nObjId
) );
388 if( aIter
== rCache
.end() )
390 uno::Reference
< beans::XPropertySetInfo
> xInfo( mpShape
->_getPropertySetInfo() );
391 pInfo
= new SfxExtItemPropertySetInfo( mpMap
, xInfo
->getProperties() );
393 rCache
.insert(std::make_pair(nObjId
, pInfo
));
397 // use the already computed implementation id
398 pInfo
= (*aIter
).second
;
404 void SAL_CALL
SdXShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
)
406 SolarMutexGuard aGuard
;
408 const SfxItemPropertyMapEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
412 SdrObject
* pObj
= mpShape
->GetSdrObject();
419 sal_Int32 nNavOrder
= 0;
420 if(!(aValue
>>= nNavOrder
))
421 throw lang::IllegalArgumentException();
423 SdrObjList
* pObjList
= pObj
->getParentSdrObjListFromSdrObject();
425 pObjList
->SetObjectNavigationPosition( *pObj
, (nNavOrder
< 0) ? SAL_MAX_UINT32
: static_cast< sal_uInt32
>( nNavOrder
) );
431 AnimationEffect eEffect
;
432 if(!(aValue
>>= eEffect
))
433 throw lang::IllegalArgumentException();
435 EffectMigration::SetAnimationEffect( mpShape
, eEffect
);
440 AnimationEffect eEffect
;
441 if(!(aValue
>>= eEffect
))
442 throw lang::IllegalArgumentException();
444 EffectMigration::SetTextAnimationEffect( mpShape
, eEffect
);
449 AnimationSpeed eSpeed
;
450 if(!(aValue
>>=eSpeed
))
451 throw lang::IllegalArgumentException();
453 EffectMigration::SetAnimationSpeed( mpShape
, eSpeed
);
456 case WID_ISANIMATION
:
458 bool bIsAnimation(false);
460 if(!(aValue
>>= bIsAnimation
))
462 throw lang::IllegalArgumentException();
467 SdrObjGroup
* pGroup
= dynamic_cast< SdrObjGroup
* >(pObj
);
468 SdPage
* pPage
= pGroup
? dynamic_cast< SdPage
* >(pGroup
->getSdrPageFromSdrObject()) : nullptr;
472 // #i42894# Animated Group object, migrate that effect
473 EffectMigration::CreateAnimatedGroup(*pGroup
, *pPage
);
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())
481 pPage
->NbcRemoveObject(pGroup
->GetOrdNum());
485 //pInfo->mbIsMovie = bIsAnimation;
491 if(!(aValue
>>= aString
))
492 throw lang::IllegalArgumentException();
494 SdAnimationInfo
* pInfo
= GetAnimationInfo(true);
495 pInfo
->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString
) );
498 case WID_CLICKACTION
:
500 SdAnimationInfo
* pInfo
= GetAnimationInfo(true);
501 ::cppu::any2enum
< presentation::ClickAction
>( pInfo
->meClickAction
, aValue
);
504 // TODO: WID_PLAYFULL:
508 if(!(aValue
>>= aString
))
509 throw lang::IllegalArgumentException();
510 SdAnimationInfo
* pInfo
= GetAnimationInfo(true);
511 pInfo
->maSoundFile
= aString
;
512 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
518 SdAnimationInfo
* pInfo
= GetAnimationInfo(true);
519 if( !(aValue
>>= pInfo
->mbSoundOn
) )
520 throw lang::IllegalArgumentException();
521 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
527 if(!(aValue
>>= nVerb
))
528 throw lang::IllegalArgumentException();
530 SdAnimationInfo
* pInfo
= GetAnimationInfo(true);
531 pInfo
->mnVerb
= static_cast<sal_uInt16
>(nVerb
);
536 sal_Int32 nColor
= 0;
538 if( !(aValue
>>= nColor
) )
539 throw lang::IllegalArgumentException();
541 EffectMigration::SetDimColor( mpShape
, nColor
);
546 bool bDimHide
= false;
547 if( !(aValue
>>= bDimHide
) )
548 throw lang::IllegalArgumentException();
550 EffectMigration::SetDimHide( mpShape
, bDimHide
);
555 bool bDimPrevious
= false;
556 if( !(aValue
>>= bDimPrevious
) )
557 throw lang::IllegalArgumentException();
559 EffectMigration::SetDimPrevious( mpShape
, bDimPrevious
);
564 sal_Int32 nNewPos
= 0;
565 if( !(aValue
>>= nNewPos
) )
566 throw lang::IllegalArgumentException();
568 EffectMigration::SetPresentationOrder( mpShape
, nNewPos
);
572 SetStyleSheet( aValue
);
574 case WID_ISEMPTYPRESOBJ
:
575 SetEmptyPresObj( ::cppu::any2bool(aValue
) );
577 case WID_MASTERDEPEND
:
578 SetMasterDepend( ::cppu::any2bool(aValue
) );
581 case WID_LEGACYFRAGMENT
:
583 uno::Reference
< io::XInputStream
> xInputStream
;
584 aValue
>>= xInputStream
;
585 if( xInputStream
.is() )
587 SvInputStream
aStream( xInputStream
);
588 SdrObject
* pObject
= mpShape
->GetSdrObject();
589 SvxMSDffManager::ReadObjText( aStream
, pObject
);
596 uno::Reference
< drawing::XShape
> xShape( aValue
, uno::UNO_QUERY
);
597 SdrPathObj
* pObj2
= xShape
.is() ? dynamic_cast<SdrPathObj
*>(SdrObject::getSdrObjectFromXShape(xShape
)) : nullptr;
599 if( pObj2
== nullptr )
600 throw lang::IllegalArgumentException();
602 EffectMigration::SetAnimationPath( mpShape
, pObj2
);
607 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
611 uno::Reference
< uno::XInterface
> xImageMap
;
612 aValue
>>= xImageMap
;
614 if( !xImageMap
.is() || !SvUnoImageMap_fillImageMap( xImageMap
, aImageMap
) )
615 throw lang::IllegalArgumentException();
617 SvxIMapInfo
* pIMapInfo
= SvxIMapInfo::GetIMapInfo(pObj
);
620 // replace existing image map
621 pIMapInfo
->SetImageMap( aImageMap
);
625 // insert new user data with image map
626 pObj
->AppendUserData(std::unique_ptr
<SdrObjUserData
>(new SvxIMapInfo(aImageMap
) ));
636 mpShape
->_setPropertyValue(aPropertyName
, aValue
);
640 mpModel
->SetModified();
643 css::uno::Any SAL_CALL
SdXShape::getPropertyValue( const OUString
& PropertyName
)
645 SolarMutexGuard aGuard
;
649 const SfxItemPropertyMapEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(PropertyName
);
651 if( pEntry
&& mpShape
->GetSdrObject() )
653 SdAnimationInfo
* pInfo
= GetAnimationInfo();
659 const sal_uInt32 nNavOrder
= mpShape
->GetSdrObject()->GetNavigationPosition();
660 aRet
<<= nNavOrder
== SAL_MAX_UINT32
? static_cast<sal_Int32
>(-1) : static_cast< sal_Int32
>(nNavOrder
);
664 aRet
<<= EffectMigration::GetAnimationEffect( mpShape
);
667 aRet
<<= EffectMigration::GetTextAnimationEffect( mpShape
);
670 aRet
<<= IsPresObj();
672 case WID_ISEMPTYPRESOBJ
:
673 aRet
<<= IsEmptyPresObj();
675 case WID_MASTERDEPEND
:
676 aRet
<<= IsMasterDepend();
679 aRet
<<= EffectMigration::GetAnimationSpeed( mpShape
);
681 case WID_ISANIMATION
:
682 aRet
<<= (pInfo
&& pInfo
->mbIsMovie
);
684 case WID_PLACEHOLDERTEXT
:
685 aRet
<<= GetPlaceholderText();
690 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : nullptr;
693 // is the bookmark a page?
695 if(pDoc
->GetPageByName( pInfo
->GetBookmark(), bIsMasterPage
) != SDRPAGE_NOTFOUND
)
697 aString
= SdDrawPage::getPageApiNameFromUiName( pInfo
->GetBookmark() );
701 aString
= pInfo
->GetBookmark() ;
702 sal_Int32 nPos
= aString
.lastIndexOf( '#' );
705 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
706 OUString
aName( aString
.copy( nPos
+1 ) );
707 if(pDoc
->GetPageByName( aName
, bIsMasterPage
) != SDRPAGE_NOTFOUND
)
709 aURL
+= SdDrawPage::getPageApiNameFromUiName( aName
);
719 case WID_CLICKACTION
:
720 aRet
<<= ( pInfo
?pInfo
->meClickAction
:presentation::ClickAction_NONE
);
723 aRet
<<= ( pInfo
&& pInfo
->mbPlayFull
);
726 aRet
<<= EffectMigration::GetSoundFile( mpShape
);
729 aRet
<<= EffectMigration::GetSoundOn( mpShape
);
732 aRet
<<= pInfo
? pInfo
->maBlueScreen
: Color(0x00ffffff);
735 aRet
<<= static_cast<sal_Int32
>( pInfo
?pInfo
->mnVerb
:0 );
738 aRet
<<= EffectMigration::GetDimColor( mpShape
);
741 aRet
<<= EffectMigration::GetDimHide( mpShape
);
744 aRet
<<= EffectMigration::GetDimPrevious( mpShape
);
747 aRet
<<= EffectMigration::GetPresentationOrder( mpShape
);
750 aRet
= GetStyleSheet();
754 uno::Reference
< uno::XInterface
> xImageMap
;
756 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
760 SvxIMapInfo
* pIMapInfo
= SvxIMapInfo::GetIMapInfo(mpShape
->GetSdrObject());
763 const ImageMap
& rIMap
= pIMapInfo
->GetImageMap();
764 xImageMap
= SvUnoImageMap_createInstance( rIMap
, ImplGetSupportedMacroItems() );
768 xImageMap
= SvUnoImageMap_createInstance();
772 aRet
<<= uno::Reference
< container::XIndexContainer
>::query( xImageMap
);
779 aRet
= mpShape
->_getPropertyValue(PropertyName
);
786 SdAnimationInfo
* SdXShape::GetAnimationInfo( bool bCreate
) const
788 SdAnimationInfo
* pInfo
= nullptr;
790 SdrObject
* pObj
= mpShape
->GetSdrObject();
792 pInfo
= SdDrawDocument::GetShapeUserData(*pObj
, bCreate
);
797 uno::Sequence
< OUString
> SAL_CALL
SdXShape::getSupportedServiceNames()
799 std::vector
<std::u16string_view
> aAdd
{ u
"com.sun.star.presentation.Shape",
800 u
"com.sun.star.document.LinkTarget" };
802 SdrObject
* pObj
= mpShape
->GetSdrObject();
803 if(pObj
&& pObj
->GetObjInventor() == SdrInventor::Default
)
805 SdrObjKind nInventor
= pObj
->GetObjIdentifier();
808 case SdrObjKind::TitleText
:
809 aAdd
.emplace_back(u
"com.sun.star.presentation.TitleTextShape");
811 case SdrObjKind::OutlineText
:
812 aAdd
.emplace_back(u
"com.sun.star.presentation.OutlinerShape");
817 return comphelper::concatSequences(mpShape
->_getSupportedServiceNames(), aAdd
);
820 /** checks if this is a presentation object
822 bool SdXShape::IsPresObj() const
824 SdrObject
* pObj
= mpShape
->GetSdrObject();
827 SdPage
* pPage
= dynamic_cast<SdPage
* >(pObj
->getSdrPageFromSdrObject());
829 return pPage
->GetPresObjKind(pObj
) != PresObjKind::NONE
;
834 /** checks if this presentation object is empty
836 bool SdXShape::IsEmptyPresObj() const
838 SdrObject
* pObj
= mpShape
->GetSdrObject();
839 if( (pObj
!= nullptr) && pObj
->IsEmptyPresObj() )
841 // check if the object is in edit, then if it's temporarily not empty
842 SdrTextObj
* pTextObj
= DynCastSdrTextObj( pObj
);
843 if( pTextObj
== nullptr )
846 return !pTextObj
->CanCreateEditOutlinerParaObject();
852 OUString
SdXShape::GetPlaceholderText() const
854 // only possible if this actually *is* a presentation object
858 SdrObject
* pObj
= mpShape
->GetSdrObject();
859 if( pObj
== nullptr )
862 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
863 DBG_ASSERT( pPage
, "no page?" );
864 if( pPage
== nullptr )
867 return pPage
->GetPresObjText( pPage
->GetPresObjKind(pObj
) );
870 /** sets/reset the empty status of a presentation object
872 void SdXShape::SetEmptyPresObj(bool bEmpty
)
874 // only possible if this actually *is* a presentation object
878 SdrObject
* pObj
= mpShape
->GetSdrObject();
879 if( pObj
== nullptr )
882 if( pObj
->IsEmptyPresObj() == bEmpty
)
887 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
888 const bool bVertical
= pOutlinerParaObject
&& pOutlinerParaObject
->IsEffectivelyVertical();
890 // really delete SdrOutlinerObj at pObj
891 pObj
->NbcSetOutlinerParaObject(std::nullopt
);
893 if (auto pTextObj
= DynCastSdrTextObj( pObj
) )
894 pTextObj
->SetVerticalWriting( true );
896 SdrGrafObj
* pGraphicObj
= dynamic_cast<SdrGrafObj
*>( pObj
);
900 pGraphicObj
->SetGraphic(aEmpty
);
904 SdrOle2Obj
* pOleObj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
907 pOleObj
->ClearGraphic();
913 // now set an empty OutlinerParaObject at pObj without
914 // any content but with the style of the old OutlinerParaObjects
918 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
919 DBG_ASSERT( pDoc
, "no document?" );
923 SdOutliner
* pOutliner
= pDoc
->GetInternalOutliner();
924 DBG_ASSERT( pOutliner
, "no outliner?" );
925 if( pOutliner
== nullptr )
928 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
929 DBG_ASSERT( pPage
, "no page?" );
930 if( pPage
== nullptr )
933 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
934 pOutliner
->SetText( *pOutlinerParaObject
);
935 const bool bVertical
= pOutliner
->IsVertical();
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() );
948 pObj
->SetEmptyPresObj(bEmpty
);
951 bool SdXShape::IsMasterDepend() const noexcept
953 SdrObject
* pObj
= mpShape
->GetSdrObject();
954 return pObj
&& pObj
->GetUserCall() != nullptr;
957 void SdXShape::SetMasterDepend( bool bDepend
) noexcept
959 if( IsMasterDepend() == bDepend
)
962 SdrObject
* pObj
= mpShape
->GetSdrObject();
967 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
968 pObj
->SetUserCall( pPage
);
972 pObj
->SetUserCall( nullptr );
977 void SdXShape::SetStyleSheet( const uno::Any
& rAny
)
979 SdrObject
* pObj
= mpShape
->GetSdrObject();
980 if( pObj
== nullptr )
981 throw beans::UnknownPropertyException();
983 uno::Reference
< style::XStyle
> xStyle( rAny
, uno::UNO_QUERY
);
984 SfxStyleSheet
* pStyleSheet
= SfxUnoStyleSheet::getUnoStyleSheet( xStyle
);
986 const SfxStyleSheet
* pOldStyleSheet
= pObj
->GetStyleSheet();
987 if( pOldStyleSheet
== pStyleSheet
)
990 if( pStyleSheet
== nullptr || (pStyleSheet
->GetFamily() != SfxStyleFamily::Para
&& pStyleSheet
->GetFamily() != SfxStyleFamily::Page
) )
991 throw lang::IllegalArgumentException();
993 pObj
->SetStyleSheet( pStyleSheet
, false );
995 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : nullptr;
998 ::sd::DrawDocShell
* pDocSh
= pDoc
->GetDocSh();
999 ::sd::ViewShell
* pViewSh
= pDocSh
? pDocSh
->GetViewShell() : nullptr;
1002 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2
);
1006 uno::Any
SdXShape::GetStyleSheet() const
1008 SdrObject
* pObj
= mpShape
->GetSdrObject();
1009 if( pObj
== nullptr )
1010 throw beans::UnknownPropertyException();
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()) )
1018 return Any( uno::Reference
< style::XStyle
>( dynamic_cast< SfxUnoStyleSheet
* >( pStyleSheet
) ) );
1021 class SdUnoEventsAccess
: public cppu::WeakImplHelper
< css::container::XNameReplace
, css::lang::XServiceInfo
>
1027 explicit SdUnoEventsAccess(SdXShape
* pShape
) noexcept
;
1030 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
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
;
1038 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
1039 virtual sal_Bool SAL_CALL
hasElements( ) override
;
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
;
1048 uno::Reference
< container::XNameReplace
> SAL_CALL
SdXShape::getEvents( )
1050 return new SdUnoEventsAccess( this );
1053 constexpr OUString
gaStrOnClick( u
"OnClick"_ustr
);
1054 constexpr OUString
gaStrServiceName( u
"com.sun.star.documents.Events"_ustr
);
1055 constexpr OUString
gaStrEventType( u
"EventType"_ustr
);
1056 constexpr OUString
gaStrPresentation( u
"Presentation"_ustr
);
1057 constexpr OUString
gaStrLibrary(u
"Library"_ustr
);
1058 constexpr OUString
gaStrMacroName(u
"MacroName"_ustr
);
1059 constexpr OUString
gaStrClickAction( u
"ClickAction"_ustr
);
1060 constexpr OUString
gaStrBookmark( u
"Bookmark"_ustr
);
1061 constexpr OUString
gaStrEffect( u
"Effect"_ustr
);
1062 constexpr OUString
gaStrPlayFull( u
"PlayFull"_ustr
);
1063 constexpr OUString
gaStrVerb( u
"Verb"_ustr
);
1064 constexpr OUString
gaStrSoundURL( u
"SoundURL"_ustr
);
1065 constexpr OUString
gaStrSpeed( u
"Speed"_ustr
);
1066 constexpr OUStringLiteral
gaStrStarBasic( u
"StarBasic" );
1067 constexpr OUString
gaStrScript( u
"Script"_ustr
);
1069 SdUnoEventsAccess::SdUnoEventsAccess( SdXShape
* pShape
) noexcept
1076 enum class FoundFlags
{
1078 ClickAction
= 0x0001,
1093 template<> struct typed_flags
<FoundFlags
> : is_typed_flags
<FoundFlags
, 0x03ff> {};
1096 static void clearEventsInAnimationInfo( SdAnimationInfo
* pInfo
)
1098 pInfo
->SetBookmark( u
""_ustr
);
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
;
1108 void SAL_CALL
SdUnoEventsAccess::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
1110 if( mpShape
== nullptr || aName
!= gaStrOnClick
)
1111 throw container::NoSuchElementException();
1113 uno::Sequence
< beans::PropertyValue
> aProperties
;
1114 if( !aElement
.hasValue() || aElement
.getValueType() != getElementType() || !(aElement
>>= aProperties
) )
1115 throw lang::IllegalArgumentException();
1117 FoundFlags nFound
= FoundFlags::NONE
;
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;
1127 OUString aStrLibrary
;
1128 OUString aStrBookmark
;
1130 for (const beans::PropertyValue
& rProperty
: aProperties
)
1132 if( !( nFound
& FoundFlags::EventType
) && rProperty
.Name
== gaStrEventType
)
1134 if( rProperty
.Value
>>= aStrEventType
)
1136 nFound
|= FoundFlags::EventType
;
1140 else if( !( nFound
& FoundFlags::ClickAction
) && rProperty
.Name
== gaStrClickAction
)
1142 if( rProperty
.Value
>>= eClickAction
)
1144 nFound
|= FoundFlags::ClickAction
;
1148 else if( !( nFound
& FoundFlags::Macro
) && ( rProperty
.Name
== gaStrMacroName
|| rProperty
.Name
== gaStrScript
) )
1150 if( rProperty
.Value
>>= aStrMacro
)
1152 nFound
|= FoundFlags::Macro
;
1156 else if( !( nFound
& FoundFlags::Library
) && rProperty
.Name
== gaStrLibrary
)
1158 if( rProperty
.Value
>>= aStrLibrary
)
1160 nFound
|= FoundFlags::Library
;
1164 else if( !( nFound
& FoundFlags::Effect
) && rProperty
.Name
== gaStrEffect
)
1166 if( rProperty
.Value
>>= eEffect
)
1168 nFound
|= FoundFlags::Effect
;
1172 else if( !( nFound
& FoundFlags::Bookmark
) && rProperty
.Name
== gaStrBookmark
)
1174 if( rProperty
.Value
>>= aStrBookmark
)
1176 nFound
|= FoundFlags::Bookmark
;
1180 else if( !( nFound
& FoundFlags::Speed
) && rProperty
.Name
== gaStrSpeed
)
1182 if( rProperty
.Value
>>= eSpeed
)
1184 nFound
|= FoundFlags::Speed
;
1188 else if( !( nFound
& FoundFlags::SoundUrl
) && rProperty
.Name
== gaStrSoundURL
)
1190 if( rProperty
.Value
>>= aStrSoundURL
)
1192 nFound
|= FoundFlags::SoundUrl
;
1196 else if( !( nFound
& FoundFlags::PlayFull
) && rProperty
.Name
== gaStrPlayFull
)
1198 if( rProperty
.Value
>>= bPlayFull
)
1200 nFound
|= FoundFlags::PlayFull
;
1204 else if( !( nFound
& FoundFlags::Verb
) && rProperty
.Name
== gaStrVerb
)
1206 if( rProperty
.Value
>>= nVerb
)
1208 nFound
|= FoundFlags::Verb
;
1213 throw lang::IllegalArgumentException();
1219 if( !( nFound
& FoundFlags::EventType
) )
1222 if( aStrEventType
== gaStrPresentation
)
1224 if( !( nFound
& FoundFlags::ClickAction
) )
1227 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo();
1228 if( presentation::ClickAction_NONE
== eClickAction
&& nullptr == pInfo
)
1234 if( nullptr == pInfo
)
1235 pInfo
= mpShape
->GetAnimationInfo( true );
1237 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1238 if( nullptr == pInfo
)
1241 clearEventsInAnimationInfo( pInfo
);
1242 pInfo
->meClickAction
= eClickAction
;
1244 switch( eClickAction
)
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
:
1258 case presentation::ClickAction_PROGRAM
:
1259 case presentation::ClickAction_BOOKMARK
:
1260 case presentation::ClickAction_DOCUMENT
:
1261 if( nFound
& FoundFlags::Bookmark
)
1263 if( eClickAction
== presentation::ClickAction_BOOKMARK
)
1265 aStrBookmark
= getUiNameFromPageApiNameImpl( aStrBookmark
);
1267 else if( eClickAction
== presentation::ClickAction_DOCUMENT
)
1269 sal_Int32 nPos
= aStrBookmark
.lastIndexOf( '#' );
1272 aStrBookmark
= aStrBookmark
.subView( 0, nPos
+1 )
1273 + getUiNameFromPageApiNameImpl( aStrBookmark
.copy( nPos
+1 ) );
1277 pInfo
->SetBookmark( aStrBookmark
);
1282 case presentation::ClickAction_MACRO
:
1283 if( nFound
& FoundFlags::Macro
)
1285 pInfo
->SetBookmark( aStrMacro
);
1290 case presentation::ClickAction_VERB
:
1291 if( nFound
& FoundFlags::Verb
)
1293 pInfo
->mnVerb
= static_cast<sal_uInt16
>(nVerb
);
1298 case presentation::ClickAction_VANISH
:
1299 if( !( nFound
& FoundFlags::Effect
) )
1302 pInfo
->meSecondEffect
= eEffect
;
1303 pInfo
->meSecondSpeed
= nFound
& FoundFlags::Speed
? eSpeed
: presentation::AnimationSpeed_MEDIUM
;
1309 case presentation::ClickAction_SOUND
:
1310 if( nFound
& FoundFlags::SoundUrl
)
1312 pInfo
->SetBookmark( aStrSoundURL
);
1313 if( eClickAction
!= presentation::ClickAction_SOUND
)
1314 pInfo
->mbSecondSoundOn
= !aStrSoundURL
.isEmpty();
1315 pInfo
->mbSecondPlayFull
= (nFound
& FoundFlags::PlayFull
) && bPlayFull
;
1326 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( true );
1328 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1329 if( nullptr == pInfo
)
1332 clearEventsInAnimationInfo( pInfo
);
1333 pInfo
->meClickAction
= presentation::ClickAction_MACRO
;
1335 if ( SfxApplication::IsXScriptURL( aStrMacro
) )
1337 pInfo
->SetBookmark( aStrMacro
);
1341 sal_Int32 nIdx
{ 0 };
1342 const std::u16string_view aLibName
= o3tl::getToken(aStrMacro
, 0, '.', nIdx
);
1343 const std::u16string_view aModulName
= o3tl::getToken(aStrMacro
, 0, '.', nIdx
);
1344 const std::u16string_view aMacroName
= o3tl::getToken(aStrMacro
, 0, '.', nIdx
);
1346 OUStringBuffer
sBuffer(
1347 OUString::Concat(aMacroName
) + OUStringChar('.') + aModulName
+ OUStringChar('.') + aLibName
+ OUStringChar('.') );
1349 if ( aStrLibrary
== "StarOffice" )
1351 sBuffer
.append( "BASIC" );
1355 sBuffer
.append( aStrLibrary
);
1358 pInfo
->SetBookmark( sBuffer
.makeStringAndClear() );
1366 throw lang::IllegalArgumentException();
1370 uno::Any SAL_CALL
SdUnoEventsAccess::getByName( const OUString
& aName
)
1372 if( mpShape
== nullptr || aName
!= gaStrOnClick
)
1373 throw container::NoSuchElementException();
1375 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo();
1377 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1379 eClickAction
= pInfo
->meClickAction
;
1381 sal_Int32 nPropertyCount
= 2;
1382 switch( eClickAction
)
1384 case presentation::ClickAction_NONE
:
1385 case presentation::ClickAction_PREVPAGE
:
1386 case presentation::ClickAction_NEXTPAGE
:
1387 case presentation::ClickAction_FIRSTPAGE
:
1388 case presentation::ClickAction_LASTPAGE
:
1389 case presentation::ClickAction_INVISIBLE
:
1390 case presentation::ClickAction_STOPPRESENTATION
:
1392 case presentation::ClickAction_PROGRAM
:
1393 case presentation::ClickAction_VERB
:
1394 case presentation::ClickAction_BOOKMARK
:
1395 case presentation::ClickAction_DOCUMENT
:
1396 case presentation::ClickAction_MACRO
:
1397 if ( !SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1398 nPropertyCount
+= 1;
1401 case presentation::ClickAction_SOUND
:
1402 nPropertyCount
+= 2;
1405 case presentation::ClickAction_VANISH
:
1406 nPropertyCount
+= 4;
1412 uno::Sequence
< beans::PropertyValue
> aProperties( nPropertyCount
);
1413 beans::PropertyValue
* pProperties
= aProperties
.getArray();
1417 if( eClickAction
== presentation::ClickAction_MACRO
)
1419 if ( SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1421 // Scripting Framework URL
1422 aAny
<<= gaStrScript
;
1423 pProperties
->Name
= gaStrEventType
;
1424 pProperties
->Handle
= -1;
1425 pProperties
->Value
= aAny
;
1426 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1429 aAny
<<= pInfo
->GetBookmark();
1430 pProperties
->Name
= gaStrScript
;
1431 pProperties
->Handle
= -1;
1432 pProperties
->Value
= aAny
;
1433 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1438 // Old Basic macro URL
1439 aAny
<<= OUString(gaStrStarBasic
);
1440 pProperties
->Name
= gaStrEventType
;
1441 pProperties
->Handle
= -1;
1442 pProperties
->Value
= aAny
;
1443 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1446 OUString aMacro
= pInfo
->GetBookmark();
1448 // aMacro has got following format:
1449 // "Macroname.Modulname.Libname.Documentname" or
1450 // "Macroname.Modulname.Libname.Applicationname"
1451 sal_Int32 nIdx
{ 0 };
1452 const std::u16string_view aMacroName
= o3tl::getToken(aMacro
, 0, '.', nIdx
);
1453 const std::u16string_view aModulName
= o3tl::getToken(aMacro
, 0, '.', nIdx
);
1454 const std::u16string_view aLibName
= o3tl::getToken(aMacro
, 0, '.', nIdx
);
1456 OUString sBuffer
= OUString::Concat(aLibName
) +
1463 pProperties
->Name
= gaStrMacroName
;
1464 pProperties
->Handle
= -1;
1465 pProperties
->Value
= aAny
;
1466 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1469 aAny
<<= u
"StarOffice"_ustr
;
1470 pProperties
->Name
= gaStrLibrary
;
1471 pProperties
->Handle
= -1;
1472 pProperties
->Value
= aAny
;
1473 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1478 aAny
<<= gaStrPresentation
;
1479 pProperties
->Name
= gaStrEventType
;
1480 pProperties
->Handle
= -1;
1481 pProperties
->Value
= aAny
;
1482 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1485 aAny
<<= eClickAction
;
1486 pProperties
->Name
= gaStrClickAction
;
1487 pProperties
->Handle
= -1;
1488 pProperties
->Value
= aAny
;
1489 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1492 switch( eClickAction
)
1494 case presentation::ClickAction_NONE
:
1495 case presentation::ClickAction_PREVPAGE
:
1496 case presentation::ClickAction_NEXTPAGE
:
1497 case presentation::ClickAction_FIRSTPAGE
:
1498 case presentation::ClickAction_LASTPAGE
:
1499 case presentation::ClickAction_INVISIBLE
:
1500 case presentation::ClickAction_STOPPRESENTATION
:
1502 case presentation::ClickAction_BOOKMARK
:
1504 const OUString
aStrBookmark( getPageApiNameFromUiName( pInfo
->GetBookmark()) );
1505 pProperties
->Name
= gaStrBookmark
;
1506 pProperties
->Handle
= -1;
1507 pProperties
->Value
<<= aStrBookmark
;
1508 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1512 case presentation::ClickAction_DOCUMENT
:
1513 case presentation::ClickAction_PROGRAM
:
1515 OUString
aString( pInfo
->GetBookmark());
1516 sal_Int32 nPos
= aString
.lastIndexOf( '#' );
1519 aString
= aString
.subView( 0, nPos
+1 ) +
1520 getPageApiNameFromUiName( aString
.copy( nPos
+1 ) );
1522 pProperties
->Name
= gaStrBookmark
;
1523 pProperties
->Handle
= -1;
1524 pProperties
->Value
<<= aString
;
1525 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1529 case presentation::ClickAction_VANISH
:
1530 aAny
<<= pInfo
->meSecondEffect
;
1531 pProperties
->Name
= gaStrEffect
;
1532 pProperties
->Handle
= -1;
1533 pProperties
->Value
= aAny
;
1534 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1537 aAny
<<= pInfo
->meSecondSpeed
;
1538 pProperties
->Name
= gaStrSpeed
;
1539 pProperties
->Handle
= -1;
1540 pProperties
->Value
= aAny
;
1541 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1546 case presentation::ClickAction_SOUND
:
1547 if( eClickAction
== presentation::ClickAction_SOUND
|| pInfo
->mbSecondSoundOn
)
1549 aAny
<<= pInfo
->GetBookmark();
1550 pProperties
->Name
= gaStrSoundURL
;
1551 pProperties
->Handle
= -1;
1552 pProperties
->Value
= aAny
;
1553 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1556 pProperties
->Name
= gaStrPlayFull
;
1557 pProperties
->Handle
= -1;
1558 pProperties
->Value
<<= pInfo
->mbSecondPlayFull
;
1559 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1563 case presentation::ClickAction_VERB
:
1564 aAny
<<= static_cast<sal_Int32
>(pInfo
->mnVerb
);
1565 pProperties
->Name
= gaStrVerb
;
1566 pProperties
->Handle
= -1;
1567 pProperties
->Value
= aAny
;
1568 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1575 aAny
<<= aProperties
;
1579 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getElementNames( )
1581 return { gaStrOnClick
};
1584 sal_Bool SAL_CALL
SdUnoEventsAccess::hasByName( const OUString
& aName
)
1586 return aName
== gaStrOnClick
;
1590 uno::Type SAL_CALL
SdUnoEventsAccess::getElementType( )
1592 return cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get();
1595 sal_Bool SAL_CALL
SdUnoEventsAccess::hasElements( )
1601 OUString SAL_CALL
SdUnoEventsAccess::getImplementationName( )
1603 return u
"SdUnoEventsAccess"_ustr
;
1606 sal_Bool SAL_CALL
SdUnoEventsAccess::supportsService( const OUString
& ServiceName
)
1608 return cppu::supportsService(this, ServiceName
);
1611 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getSupportedServiceNames( )
1613 return { gaStrServiceName
};
1616 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */