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>
25 #include <com/sun/star/style/XStyle.hpp>
26 #include <com/sun/star/presentation/ClickAction.hpp>
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 #include <com/sun/star/beans/PropertyState.hpp>
29 #include <rtl/ustrbuf.hxx>
30 #include <svl/itemprop.hxx>
31 #include <svl/style.hxx>
32 #include <svx/svdpool.hxx>
33 #include <sfx2/viewfrm.hxx>
34 #include <sfx2/app.hxx>
35 #include <svtools/unoimap.hxx>
36 #include <svtools/unoevent.hxx>
37 #include <sfx2/bindings.hxx>
38 #include <sfx2/event.hxx>
39 #include <sfx2/sfxsids.hrc>
40 #include <comphelper/extract.hxx>
41 #include <cppuhelper/implbase.hxx>
42 #include <cppuhelper/supportsservice.hxx>
43 #include <svx/unoshape.hxx>
44 #include <svx/svdotext.hxx>
45 #include <svx/unoapi.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/serviceinfohelper.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::makeAny
;
78 using ::com::sun::star::uno::Any
;
79 using ::com::sun::star::drawing::XShape
;
83 #define WID_TEXTEFFECT 3
84 #define WID_BOOKMARK 4
85 #define WID_CLICKACTION 5
86 #define WID_PLAYFULL 6
87 #define WID_SOUNDFILE 7
89 #define WID_BLUESCREEN 9
91 #define WID_DIMCOLOR 11
92 #define WID_DIMHIDE 12
93 #define WID_DIMPREV 13
94 #define WID_PRESORDER 14
96 #define WID_ANIMPATH 16
97 #define WID_IMAGEMAP 17
98 #define WID_ISANIMATION 18
99 #define WID_THAT_NEED_ANIMINFO 19
101 #define WID_ISEMPTYPRESOBJ 20
102 #define WID_ISPRESOBJ 21
103 #define WID_MASTERDEPEND 22
105 #define WID_NAVORDER 23
106 #define WID_PLACEHOLDERTEXT 24
107 #define WID_LEGACYFRAGMENT 25
109 #define IMPRESS_MAP_ENTRIES \
110 { OUString(UNO_NAME_OBJ_LEGACYFRAGMENT),WID_LEGACYFRAGMENT, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
111 { OUString(UNO_NAME_OBJ_ANIMATIONPATH), WID_ANIMPATH, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
112 { OUString(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
113 { OUString(UNO_NAME_OBJ_DIMCOLOR), WID_DIMCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0},\
114 { OUString(UNO_NAME_OBJ_DIMHIDE), WID_DIMHIDE, cppu::UnoType<bool>::get(), 0, 0},\
115 { OUString(UNO_NAME_OBJ_DIMPREV), WID_DIMPREV, cppu::UnoType<bool>::get(), 0, 0},\
116 { OUString(UNO_NAME_OBJ_EFFECT), WID_EFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
117 { OUString(UNO_NAME_OBJ_ISEMPTYPRESOBJ),WID_ISEMPTYPRESOBJ, cppu::UnoType<bool>::get(), 0, 0},\
118 { OUString(UNO_NAME_OBJ_ISPRESOBJ), WID_ISPRESOBJ, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY, 0},\
119 { OUString(UNO_NAME_OBJ_MASTERDEPENDENT),WID_MASTERDEPEND, cppu::UnoType<bool>::get(), 0, 0},\
120 { OUString(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(), 0, 0},\
121 { OUString(UNO_NAME_OBJ_PLAYFULL), WID_PLAYFULL, cppu::UnoType<bool>::get(), 0, 0},\
122 { OUString(UNO_NAME_OBJ_PRESORDER), WID_PRESORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
123 { OUString(UNO_NAME_OBJ_STYLE), WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
124 { OUString(UNO_NAME_OBJ_SOUNDFILE), WID_SOUNDFILE, cppu::UnoType<OUString>::get(), 0, 0},\
125 { OUString(UNO_NAME_OBJ_SOUNDON), WID_SOUNDON, cppu::UnoType<bool>::get(), 0, 0},\
126 { OUString(UNO_NAME_OBJ_SPEED), WID_SPEED, cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},\
127 { OUString(UNO_NAME_OBJ_TEXTEFFECT), WID_TEXTEFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
128 { OUString(UNO_NAME_OBJ_BLUESCREEN), WID_BLUESCREEN, cppu::UnoType<sal_Int32>::get(), 0, 0},\
129 { OUString(UNO_NAME_OBJ_VERB), WID_VERB, cppu::UnoType<sal_Int32>::get(), 0, 0},\
130 { OUString("IsAnimation"), WID_ISANIMATION, cppu::UnoType<bool>::get(), 0, 0},\
131 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
132 { OUString("PlaceholderText"), WID_PLACEHOLDERTEXT, cppu::UnoType<OUString>::get(), 0, 0},\
133 { OUString(), 0, css::uno::Type(), 0, 0 }
135 static const SfxItemPropertyMapEntry
* lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
138 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl
[] =
140 { OUString("ImageMap"), WID_IMAGEMAP
, cppu::UnoType
<container::XIndexContainer
>::get(), 0, 0 },
143 return aImpress_SdXShapePropertyGraphicMap_Impl
;
146 static const SfxItemPropertyMapEntry
* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
149 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl
[] =
153 return aImpress_SdXShapePropertySimpleMap_Impl
;
156 #define DRAW_MAP_ENTRIES\
157 { OUString(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
158 { OUString(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(),0, 0},\
159 { OUString(UNO_NAME_OBJ_STYLE), WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
160 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
161 { OUString(), 0, css::uno::Type(), 0, 0 }
163 static const SfxItemPropertyMapEntry
* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
165 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl
[] =
169 return aDraw_SdXShapePropertyMap_Impl
;
171 static const SfxItemPropertyMapEntry
* lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
173 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl
[] =
175 { OUString("ImageMap"), WID_IMAGEMAP
, cppu::UnoType
<container::XIndexContainer
>::get(), 0, 0 },
178 return aDraw_SdXShapePropertyGraphicMap_Impl
;
180 static const SfxItemPropertyMapEntry
* lcl_ImplGetShapePropertyMap( bool bImpress
, bool bGraphicObj
)
182 const SfxItemPropertyMapEntry
* pRet
= nullptr;
186 pRet
= lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
188 pRet
= lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
193 pRet
= lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
195 pRet
= lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
200 static const SvxItemPropertySet
* lcl_ImplGetShapePropertySet( bool bImpress
, bool bGraphicObj
)
202 const SvxItemPropertySet
* pRet
= nullptr;
207 static SvxItemPropertySet
aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
208 pRet
= &aImpress_SdXShapePropertyGraphicSet_Impl
;
212 static SvxItemPropertySet
aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
213 pRet
= &aImpress_SdXShapePropertySet_Impl
;
220 static SvxItemPropertySet
aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
221 pRet
= &aDraw_SdXShapePropertyGraphicSet_Impl
;
225 static SvxItemPropertySet
aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
226 pRet
= &aDraw_SdXShapePropertySet_Impl
;
231 static const SfxItemPropertyMapEntry
* lcl_GetEmpty_SdXShapePropertyMap_Impl()
233 static const SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl
[] =
235 { OUString(), 0, css::uno::Type(), 0, 0 }
237 return aEmpty_SdXShapePropertyMap_Impl
;
240 static const SvxItemPropertySet
* lcl_GetEmpty_SdXShapePropertySet_Impl()
242 static SvxItemPropertySet
aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool() );
243 return &aEmptyPropSet
;
245 const SvEventDescription
* ImplGetSupportedMacroItems()
247 static const SvEventDescription aMacroDescriptionsImpl
[] =
249 { SvMacroItemId::OnMouseOver
, "OnMouseOver" },
250 { SvMacroItemId::OnMouseOut
, "OnMouseOut" },
251 { SvMacroItemId::NONE
, nullptr }
254 return aMacroDescriptionsImpl
;
257 SdXShape::SdXShape(SvxShape
* pShape
, SdXImpressDocument
* pModel
)
260 lcl_ImplGetShapePropertySet(pModel
->IsImpressDocument(), pShape
->getShapeKind() == OBJ_GRAF
)
261 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
263 lcl_ImplGetShapePropertyMap(pModel
->IsImpressDocument(), pShape
->getShapeKind() == OBJ_GRAF
)
264 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
268 pShape
->setMaster( this );
271 SdXShape::~SdXShape() throw()
275 void SdXShape::dispose()
277 mpShape
->setMaster( nullptr );
281 uno::Any SAL_CALL
SdXShape::queryInterface( const uno::Type
& rType
)
283 return mpShape
->queryInterface( rType
);
286 void SAL_CALL
SdXShape::acquire() throw()
291 void SAL_CALL
SdXShape::release() throw()
296 bool SdXShape::queryAggregation( const css::uno::Type
& rType
, css::uno::Any
& aAny
)
298 if( mpModel
&& mpModel
->IsImpressDocument() )
300 if( rType
== cppu::UnoType
<document::XEventsSupplier
>::get())
302 aAny
<<= uno::Reference
< document::XEventsSupplier
>(this);
310 uno::Sequence
< uno::Type
> SAL_CALL
SdXShape::getTypes()
312 if( mpModel
&& !mpModel
->IsImpressDocument() )
314 return mpShape
->_getTypes();
318 sal_uInt32 nObjId
= mpShape
->getShapeKind();
319 uno::Sequence
< uno::Type
> aTypes
;
320 SdTypesCache
& gImplTypesCache
= SD_MOD()->gImplTypesCache
;
321 SdTypesCache::iterator
aIter( gImplTypesCache
.find( nObjId
) );
322 if( aIter
== gImplTypesCache
.end() )
324 aTypes
= mpShape
->_getTypes();
325 sal_uInt32 nCount
= aTypes
.getLength();
326 aTypes
.realloc( nCount
+1 );
327 aTypes
[nCount
] = cppu::UnoType
<lang::XTypeProvider
>::get();
329 gImplTypesCache
.insert(std::make_pair(nObjId
, aTypes
));
333 // use the already computed implementation id
334 aTypes
= (*aIter
).second
;
341 beans::PropertyState SAL_CALL
SdXShape::getPropertyState( const OUString
& PropertyName
)
343 SolarMutexGuard aGuard
;
345 if( mpPropSet
->getPropertyMapEntry(PropertyName
) )
347 return beans::PropertyState_DIRECT_VALUE
;
351 SdrObject
* pObj
= mpShape
->GetSdrObject();
352 if( pObj
== nullptr || ( pObj
->getSdrPageFromSdrObject()->IsMasterPage() && pObj
->IsEmptyPresObj() ) )
353 return beans::PropertyState_DEFAULT_VALUE
;
355 return mpShape
->_getPropertyState( PropertyName
);
359 void SAL_CALL
SdXShape::setPropertyToDefault( const OUString
& PropertyName
)
361 SolarMutexGuard aGuard
;
363 if( mpPropSet
->getPropertyMapEntry(PropertyName
) )
369 mpShape
->_setPropertyToDefault(PropertyName
);
373 uno::Any SAL_CALL
SdXShape::getPropertyDefault( const OUString
& aPropertyName
)
375 SolarMutexGuard aGuard
;
377 if( mpPropSet
->getPropertyMapEntry(aPropertyName
) )
379 return getPropertyValue( aPropertyName
);
383 uno::Any
aRet( mpShape
->_getPropertyDefault(aPropertyName
) );
389 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
SdXShape::getPropertySetInfo()
391 SfxItemPropertyMapEntry
const * nObjId
= mpShape
->getPropertyMapEntries();
392 css::uno::Reference
<css::beans::XPropertySetInfo
> pInfo
;
394 SdExtPropertySetInfoCache
& rCache
= (mpModel
&& mpModel
->IsImpressDocument()) ?
395 SD_MOD()->gImplImpressPropertySetInfoCache
: SD_MOD()->gImplDrawPropertySetInfoCache
;
397 SdExtPropertySetInfoCache::iterator
aIter( rCache
.find( nObjId
) );
398 if( aIter
== rCache
.end() )
400 uno::Reference
< beans::XPropertySetInfo
> xInfo( mpShape
->_getPropertySetInfo() );
401 pInfo
= new SfxExtItemPropertySetInfo( mpMap
, xInfo
->getProperties() );
403 rCache
.insert(std::make_pair(nObjId
, pInfo
));
407 // use the already computed implementation id
408 pInfo
= (*aIter
).second
;
414 void SAL_CALL
SdXShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
)
416 SolarMutexGuard aGuard
;
418 const SfxItemPropertySimpleEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
422 SdrObject
* pObj
= mpShape
->GetSdrObject();
425 SdAnimationInfo
* pInfo
= GetAnimationInfo(pEntry
->nWID
<= WID_THAT_NEED_ANIMINFO
);
431 sal_Int32 nNavOrder
= 0;
432 if(!(aValue
>>= nNavOrder
))
433 throw lang::IllegalArgumentException();
435 SdrObjList
* pObjList
= pObj
->getParentSdrObjListFromSdrObject();
437 pObjList
->SetObjectNavigationPosition( *pObj
, (nNavOrder
< 0) ? SAL_MAX_UINT32
: static_cast< sal_uInt32
>( nNavOrder
) );
443 AnimationEffect eEffect
;
444 if(!(aValue
>>= eEffect
))
445 throw lang::IllegalArgumentException();
447 EffectMigration::SetAnimationEffect( mpShape
, eEffect
);
452 AnimationEffect eEffect
;
453 if(!(aValue
>>= eEffect
))
454 throw lang::IllegalArgumentException();
456 EffectMigration::SetTextAnimationEffect( mpShape
, eEffect
);
461 AnimationSpeed eSpeed
;
462 if(!(aValue
>>=eSpeed
))
463 throw lang::IllegalArgumentException();
465 EffectMigration::SetAnimationSpeed( mpShape
, eSpeed
);
468 case WID_ISANIMATION
:
470 bool bIsAnimation(false);
472 if(!(aValue
>>= bIsAnimation
))
474 throw lang::IllegalArgumentException();
479 SdrObjGroup
* pGroup
= dynamic_cast< SdrObjGroup
* >(pObj
);
480 SdPage
* pPage
= pGroup
? dynamic_cast< SdPage
* >(pGroup
->getSdrPageFromSdrObject()) : nullptr;
484 // #i42894# Animated Group object, migrate that effect
485 EffectMigration::CreateAnimatedGroup(*pGroup
, *pPage
);
487 // #i42894# unfortunately when doing this all group members have to
488 // be moved to the page as direct members, else the currently
489 // available forms of animation do not work. If it succeeds,
490 // the group is empty and can be removed and deleted
491 if(!pGroup
->GetSubList()->GetObjCount())
493 pPage
->NbcRemoveObject(pGroup
->GetOrdNum());
495 // always use SdrObject::Free(...) for SdrObjects (!)
496 SdrObject
* pTemp(pGroup
);
497 SdrObject::Free(pTemp
);
501 //pInfo->mbIsMovie = bIsAnimation;
507 if(!(aValue
>>= aString
))
508 throw lang::IllegalArgumentException();
510 pInfo
->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString
) );
513 case WID_CLICKACTION
:
514 ::cppu::any2enum
< presentation::ClickAction
>( pInfo
->meClickAction
, aValue
);
517 // TODO: WID_PLAYFULL:
521 if(!(aValue
>>= aString
))
522 throw lang::IllegalArgumentException();
523 pInfo
->maSoundFile
= aString
;
524 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
530 if( !(aValue
>>= pInfo
->mbSoundOn
) )
531 throw lang::IllegalArgumentException();
532 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
538 if(!(aValue
>>= nVerb
))
539 throw lang::IllegalArgumentException();
541 pInfo
->mnVerb
= static_cast<sal_uInt16
>(nVerb
);
546 sal_Int32 nColor
= 0;
548 if( !(aValue
>>= nColor
) )
549 throw lang::IllegalArgumentException();
551 EffectMigration::SetDimColor( mpShape
, nColor
);
556 bool bDimHide
= false;
557 if( !(aValue
>>= bDimHide
) )
558 throw lang::IllegalArgumentException();
560 EffectMigration::SetDimHide( mpShape
, bDimHide
);
565 bool bDimPrevious
= false;
566 if( !(aValue
>>= bDimPrevious
) )
567 throw lang::IllegalArgumentException();
569 EffectMigration::SetDimPrevious( mpShape
, bDimPrevious
);
574 sal_Int32 nNewPos
= 0;
575 if( !(aValue
>>= nNewPos
) )
576 throw lang::IllegalArgumentException();
578 EffectMigration::SetPresentationOrder( mpShape
, nNewPos
);
582 SetStyleSheet( aValue
);
584 case WID_ISEMPTYPRESOBJ
:
585 SetEmptyPresObj( ::cppu::any2bool(aValue
) );
587 case WID_MASTERDEPEND
:
588 SetMasterDepend( ::cppu::any2bool(aValue
) );
591 case WID_LEGACYFRAGMENT
:
593 uno::Reference
< io::XInputStream
> xInputStream
;
594 aValue
>>= xInputStream
;
595 if( xInputStream
.is() )
597 SvInputStream
aStream( xInputStream
);
598 SdrObject
* pObject
= mpShape
->GetSdrObject();
599 SvxMSDffManager::ReadObjText( aStream
, pObject
);
606 uno::Reference
< drawing::XShape
> xShape( aValue
, uno::UNO_QUERY
);
607 SdrPathObj
* pObj2
= xShape
.is() ? dynamic_cast< SdrPathObj
* >( GetSdrObjectFromXShape( xShape
) ) : nullptr;
609 if( pObj2
== nullptr )
610 throw lang::IllegalArgumentException();
612 EffectMigration::SetAnimationPath( mpShape
, pObj2
);
617 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
621 uno::Reference
< uno::XInterface
> xImageMap
;
622 aValue
>>= xImageMap
;
624 if( !xImageMap
.is() || !SvUnoImageMap_fillImageMap( xImageMap
, aImageMap
) )
625 throw lang::IllegalArgumentException();
627 SvxIMapInfo
* pIMapInfo
= SvxIMapInfo::GetIMapInfo(pObj
);
630 // replace existing image map
631 pIMapInfo
->SetImageMap( aImageMap
);
635 // insert new user data with image map
636 pObj
->AppendUserData(std::unique_ptr
<SdrObjUserData
>(new SvxIMapInfo(aImageMap
) ));
646 mpShape
->_setPropertyValue(aPropertyName
, aValue
);
650 mpModel
->SetModified();
653 css::uno::Any SAL_CALL
SdXShape::getPropertyValue( const OUString
& PropertyName
)
655 SolarMutexGuard aGuard
;
659 const SfxItemPropertySimpleEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(PropertyName
);
661 if( pEntry
&& mpShape
->GetSdrObject() )
663 SdAnimationInfo
* pInfo
= GetAnimationInfo();
669 const sal_uInt32 nNavOrder
= mpShape
->GetSdrObject()->GetNavigationPosition();
670 aRet
<<= nNavOrder
== SAL_MAX_UINT32
? static_cast<sal_Int32
>(-1) : static_cast< sal_Int32
>(nNavOrder
);
674 aRet
<<= EffectMigration::GetAnimationEffect( mpShape
);
677 aRet
<<= EffectMigration::GetTextAnimationEffect( mpShape
);
680 aRet
<<= IsPresObj();
682 case WID_ISEMPTYPRESOBJ
:
683 aRet
<<= IsEmptyPresObj();
685 case WID_MASTERDEPEND
:
686 aRet
<<= IsMasterDepend();
689 aRet
<<= EffectMigration::GetAnimationSpeed( mpShape
);
691 case WID_ISANIMATION
:
692 aRet
<<= (pInfo
&& pInfo
->mbIsMovie
);
694 case WID_PLACEHOLDERTEXT
:
695 aRet
<<= GetPlaceholderText();
700 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : nullptr;
703 // is the bookmark a page?
705 if(pDoc
->GetPageByName( pInfo
->GetBookmark(), bIsMasterPage
) != SDRPAGE_NOTFOUND
)
707 aString
= SdDrawPage::getPageApiNameFromUiName( pInfo
->GetBookmark() );
711 aString
= pInfo
->GetBookmark() ;
712 sal_Int32 nPos
= aString
.lastIndexOf( '#' );
715 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
716 OUString
aName( aString
.copy( nPos
+1 ) );
717 if(pDoc
->GetPageByName( aName
, bIsMasterPage
) != SDRPAGE_NOTFOUND
)
719 aURL
+= SdDrawPage::getPageApiNameFromUiName( aName
);
729 case WID_CLICKACTION
:
730 aRet
<<= ( pInfo
?pInfo
->meClickAction
:presentation::ClickAction_NONE
);
733 aRet
<<= ( pInfo
&& pInfo
->mbPlayFull
);
736 aRet
<<= EffectMigration::GetSoundFile( mpShape
);
739 aRet
<<= EffectMigration::GetSoundOn( mpShape
);
742 aRet
<<= pInfo
? pInfo
->maBlueScreen
: Color(0x00ffffff);
745 aRet
<<= static_cast<sal_Int32
>( pInfo
?pInfo
->mnVerb
:0 );
748 aRet
<<= EffectMigration::GetDimColor( mpShape
);
751 aRet
<<= EffectMigration::GetDimHide( mpShape
);
754 aRet
<<= EffectMigration::GetDimPrevious( mpShape
);
757 aRet
<<= EffectMigration::GetPresentationOrder( mpShape
);
760 aRet
= GetStyleSheet();
764 uno::Reference
< uno::XInterface
> xImageMap
;
766 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
770 SvxIMapInfo
* pIMapInfo
= SvxIMapInfo::GetIMapInfo(mpShape
->GetSdrObject());
773 const ImageMap
& rIMap
= pIMapInfo
->GetImageMap();
774 xImageMap
= SvUnoImageMap_createInstance( rIMap
, ImplGetSupportedMacroItems() );
778 xImageMap
= SvUnoImageMap_createInstance();
782 aRet
<<= uno::Reference
< container::XIndexContainer
>::query( xImageMap
);
789 aRet
= mpShape
->_getPropertyValue(PropertyName
);
796 SdAnimationInfo
* SdXShape::GetAnimationInfo( bool bCreate
) const
798 SdAnimationInfo
* pInfo
= nullptr;
800 SdrObject
* pObj
= mpShape
->GetSdrObject();
802 pInfo
= SdDrawDocument::GetShapeUserData(*pObj
, bCreate
);
807 uno::Sequence
< OUString
> SAL_CALL
SdXShape::getSupportedServiceNames()
809 uno::Sequence
< OUString
> aSeq( mpShape
->_getSupportedServiceNames() );
811 comphelper::ServiceInfoHelper::addToSequence( aSeq
, {"com.sun.star.presentation.Shape",
812 "com.sun.star.document.LinkTarget"} );
814 SdrObject
* pObj
= mpShape
->GetSdrObject();
815 if(pObj
&& pObj
->GetObjInventor() == SdrInventor::Default
)
817 sal_uInt32 nInventor
= pObj
->GetObjIdentifier();
821 comphelper::ServiceInfoHelper::addToSequence( aSeq
, {"com.sun.star.presentation.TitleTextShape"} );
823 case OBJ_OUTLINETEXT
:
824 comphelper::ServiceInfoHelper::addToSequence( aSeq
, {"com.sun.star.presentation.OutlinerShape"} );
831 /** checks if this is a presentation object
833 bool SdXShape::IsPresObj() const
835 SdrObject
* pObj
= mpShape
->GetSdrObject();
838 SdPage
* pPage
= dynamic_cast<SdPage
* >(pObj
->getSdrPageFromSdrObject());
840 return pPage
->GetPresObjKind(pObj
) != PRESOBJ_NONE
;
845 /** checks if this presentation object is empty
847 bool SdXShape::IsEmptyPresObj() const
849 SdrObject
* pObj
= mpShape
->GetSdrObject();
850 if( (pObj
!= nullptr) && pObj
->IsEmptyPresObj() )
852 // check if the object is in edit, then if it's temporarily not empty
853 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( pObj
);
854 if( pTextObj
== nullptr )
857 return !pTextObj
->CanCreateEditOutlinerParaObject();
863 OUString
SdXShape::GetPlaceholderText() const
865 // only possible if this actually *is* a presentation object
869 SdrObject
* pObj
= mpShape
->GetSdrObject();
870 if( pObj
== nullptr )
873 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
874 DBG_ASSERT( pPage
, "no page?" );
875 if( pPage
== nullptr )
878 return pPage
->GetPresObjText( pPage
->GetPresObjKind(pObj
) );
881 /** sets/reset the empty status of a presentation object
883 void SdXShape::SetEmptyPresObj(bool bEmpty
)
885 // only possible if this actually *is* a presentation object
889 SdrObject
* pObj
= mpShape
->GetSdrObject();
890 if( pObj
== nullptr )
893 if( pObj
->IsEmptyPresObj() == bEmpty
)
898 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
899 const bool bVertical
= pOutlinerParaObject
&& pOutlinerParaObject
->IsVertical();
901 // really delete SdrOutlinerObj at pObj
902 pObj
->NbcSetOutlinerParaObject(nullptr);
903 if( bVertical
&& dynamic_cast<SdrTextObj
*>( pObj
) )
904 static_cast<SdrTextObj
*>(pObj
)->SetVerticalWriting( true );
906 SdrGrafObj
* pGraphicObj
= dynamic_cast<SdrGrafObj
*>( pObj
);
910 pGraphicObj
->SetGraphic(aEmpty
);
914 SdrOle2Obj
* pOleObj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
917 pOleObj
->ClearGraphic();
923 // now set an empty OutlinerParaObject at pObj without
924 // any content but with the style of the old OutlinerParaObjects
928 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
929 DBG_ASSERT( pDoc
, "no document?" );
933 SdOutliner
* pOutliner
= pDoc
->GetInternalOutliner();
934 DBG_ASSERT( pOutliner
, "no outliner?" );
935 if( pOutliner
== nullptr )
938 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
939 DBG_ASSERT( pPage
, "no page?" );
940 if( pPage
== nullptr )
943 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
944 pOutliner
->SetText( *pOutlinerParaObject
);
945 const bool bVertical
= pOutliner
->IsVertical();
948 pOutliner
->SetVertical( bVertical
);
949 pOutliner
->SetStyleSheetPool( static_cast<SfxStyleSheetPool
*>(pDoc
->GetStyleSheetPool()) );
950 pOutliner
->SetStyleSheet( 0, pPage
->GetTextStyleSheetForObject( pObj
) );
951 pOutliner
->Insert( pPage
->GetPresObjText( pPage
->GetPresObjKind(pObj
) ) );
952 pObj
->SetOutlinerParaObject( pOutliner
->CreateParaObject() );
958 pObj
->SetEmptyPresObj(bEmpty
);
961 bool SdXShape::IsMasterDepend() const throw()
963 SdrObject
* pObj
= mpShape
->GetSdrObject();
964 return pObj
&& pObj
->GetUserCall() != nullptr;
967 void SdXShape::SetMasterDepend( bool bDepend
) throw()
969 if( IsMasterDepend() == bDepend
)
972 SdrObject
* pObj
= mpShape
->GetSdrObject();
977 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
978 pObj
->SetUserCall( pPage
);
982 pObj
->SetUserCall( nullptr );
987 void SdXShape::SetStyleSheet( const uno::Any
& rAny
)
989 SdrObject
* pObj
= mpShape
->GetSdrObject();
990 if( pObj
== nullptr )
991 throw beans::UnknownPropertyException();
993 uno::Reference
< style::XStyle
> xStyle( rAny
, uno::UNO_QUERY
);
994 SfxStyleSheet
* pStyleSheet
= SfxUnoStyleSheet::getUnoStyleSheet( xStyle
);
996 const SfxStyleSheet
* pOldStyleSheet
= pObj
->GetStyleSheet();
997 if( pOldStyleSheet
== pStyleSheet
)
1000 if( pStyleSheet
== nullptr || (pStyleSheet
->GetFamily() != SfxStyleFamily::Para
&& pStyleSheet
->GetFamily() != SfxStyleFamily::Page
) )
1001 throw lang::IllegalArgumentException();
1003 pObj
->SetStyleSheet( pStyleSheet
, false );
1005 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : nullptr;
1008 ::sd::DrawDocShell
* pDocSh
= pDoc
->GetDocSh();
1009 ::sd::ViewShell
* pViewSh
= pDocSh
? pDocSh
->GetViewShell() : nullptr;
1012 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2
);
1016 uno::Any
SdXShape::GetStyleSheet() const
1018 SdrObject
* pObj
= mpShape
->GetSdrObject();
1019 if( pObj
== nullptr )
1020 throw beans::UnknownPropertyException();
1022 SfxStyleSheet
* pStyleSheet
= pObj
->GetStyleSheet();
1023 // it is possible for shapes inside a draw to have a presentation style
1024 // but we don't want this for the api
1025 if( (pStyleSheet
== nullptr) || ((pStyleSheet
->GetFamily() != SfxStyleFamily::Para
) && !mpModel
->IsImpressDocument()) )
1028 return Any( uno::Reference
< style::XStyle
>( dynamic_cast< SfxUnoStyleSheet
* >( pStyleSheet
) ) );
1031 class SdUnoEventsAccess
: public cppu::WeakImplHelper
< css::container::XNameReplace
, css::lang::XServiceInfo
>
1034 SdXShape
* const mpShape
;
1037 explicit SdUnoEventsAccess(SdXShape
* pShape
) throw();
1040 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
1043 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
1044 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
1045 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
1048 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
1049 virtual sal_Bool SAL_CALL
hasElements( ) override
;
1052 virtual OUString SAL_CALL
getImplementationName( ) override
;
1053 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
1054 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
1058 uno::Reference
< container::XNameReplace
> SAL_CALL
SdXShape::getEvents( )
1060 return new SdUnoEventsAccess( this );
1063 static const OUStringLiteral
gaStrOnClick( "OnClick" );
1064 static const OUStringLiteral
gaStrServiceName( "com.sun.star.documents.Events" );
1065 static const OUStringLiteral
gaStrEventType( "EventType" );
1066 static const OUStringLiteral
gaStrPresentation( "Presentation" );
1067 static const OUStringLiteral
gaStrLibrary("Library");
1068 static const OUStringLiteral
gaStrMacroName("MacroName");
1069 static const OUStringLiteral
gaStrClickAction( "ClickAction" );
1070 static const OUStringLiteral
gaStrBookmark( "Bookmark" );
1071 static const OUStringLiteral
gaStrEffect( "Effect" );
1072 static const OUStringLiteral
gaStrPlayFull( "PlayFull" );
1073 static const OUStringLiteral
gaStrVerb( "Verb" );
1074 static const OUStringLiteral
gaStrSoundURL( "SoundURL" );
1075 static const OUStringLiteral
gaStrSpeed( "Speed" );
1076 static const OUStringLiteral
gaStrStarBasic( "StarBasic" );
1077 static const OUStringLiteral
gaStrScript( "Script" );
1079 SdUnoEventsAccess::SdUnoEventsAccess( SdXShape
* pShape
) throw()
1084 enum class FoundFlags
{
1086 ClickAction
= 0x0001,
1098 template<> struct typed_flags
<FoundFlags
> : is_typed_flags
<FoundFlags
, 0x03ff> {};
1101 static void clearEventsInAnimationInfo( SdAnimationInfo
* pInfo
)
1103 pInfo
->SetBookmark( "" );
1104 pInfo
->mbSecondSoundOn
= false;
1105 pInfo
->mbSecondPlayFull
= false;
1106 pInfo
->meClickAction
= presentation::ClickAction_NONE
;
1107 pInfo
->meSecondEffect
= presentation::AnimationEffect_NONE
;
1108 pInfo
->meSecondSpeed
= presentation::AnimationSpeed_MEDIUM
;
1113 void SAL_CALL
SdUnoEventsAccess::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
1115 if( mpShape
== nullptr || aName
!= gaStrOnClick
)
1116 throw container::NoSuchElementException();
1118 uno::Sequence
< beans::PropertyValue
> aProperties
;
1119 if( !aElement
.hasValue() || aElement
.getValueType() != getElementType() || !(aElement
>>= aProperties
) )
1120 throw lang::IllegalArgumentException();
1122 FoundFlags nFound
= FoundFlags::NONE
;
1124 OUString aStrEventType
;
1125 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1126 presentation::AnimationEffect eEffect
= presentation::AnimationEffect_NONE
;
1127 presentation::AnimationSpeed eSpeed
= presentation::AnimationSpeed_MEDIUM
;
1128 OUString aStrSoundURL
;
1129 bool bPlayFull
= false;
1130 sal_Int32 nVerb
= 0;
1132 OUString aStrLibrary
;
1133 OUString aStrBookmark
;
1135 for( const beans::PropertyValue
& rProperty
: std::as_const(aProperties
) )
1137 if( !( nFound
& FoundFlags::EventType
) && rProperty
.Name
== gaStrEventType
)
1139 if( rProperty
.Value
>>= aStrEventType
)
1141 nFound
|= FoundFlags::EventType
;
1145 else if( !( nFound
& FoundFlags::ClickAction
) && rProperty
.Name
== gaStrClickAction
)
1147 if( rProperty
.Value
>>= eClickAction
)
1149 nFound
|= FoundFlags::ClickAction
;
1153 else if( !( nFound
& FoundFlags::Macro
) && ( rProperty
.Name
== gaStrMacroName
|| rProperty
.Name
== gaStrScript
) )
1155 if( rProperty
.Value
>>= aStrMacro
)
1157 nFound
|= FoundFlags::Macro
;
1161 else if( !( nFound
& FoundFlags::Library
) && rProperty
.Name
== gaStrLibrary
)
1163 if( rProperty
.Value
>>= aStrLibrary
)
1165 nFound
|= FoundFlags::Library
;
1169 else if( !( nFound
& FoundFlags::Effect
) && rProperty
.Name
== gaStrEffect
)
1171 if( rProperty
.Value
>>= eEffect
)
1173 nFound
|= FoundFlags::Effect
;
1177 else if( !( nFound
& FoundFlags::Bookmark
) && rProperty
.Name
== gaStrBookmark
)
1179 if( rProperty
.Value
>>= aStrBookmark
)
1181 nFound
|= FoundFlags::Bookmark
;
1185 else if( !( nFound
& FoundFlags::Speed
) && rProperty
.Name
== gaStrSpeed
)
1187 if( rProperty
.Value
>>= eSpeed
)
1189 nFound
|= FoundFlags::Speed
;
1193 else if( !( nFound
& FoundFlags::SoundUrl
) && rProperty
.Name
== gaStrSoundURL
)
1195 if( rProperty
.Value
>>= aStrSoundURL
)
1197 nFound
|= FoundFlags::SoundUrl
;
1201 else if( !( nFound
& FoundFlags::PlayFull
) && rProperty
.Name
== gaStrPlayFull
)
1203 if( rProperty
.Value
>>= bPlayFull
)
1205 nFound
|= FoundFlags::PlayFull
;
1209 else if( !( nFound
& FoundFlags::Verb
) && rProperty
.Name
== gaStrVerb
)
1211 if( rProperty
.Value
>>= nVerb
)
1213 nFound
|= FoundFlags::Verb
;
1218 throw lang::IllegalArgumentException();
1224 if( !( nFound
& FoundFlags::EventType
) )
1227 if( aStrEventType
== gaStrPresentation
)
1229 if( !( nFound
& FoundFlags::ClickAction
) )
1232 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo();
1233 if( presentation::ClickAction_NONE
== eClickAction
&& nullptr == pInfo
)
1239 if( nullptr == pInfo
)
1240 pInfo
= mpShape
->GetAnimationInfo( true );
1242 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1243 if( nullptr == pInfo
)
1246 clearEventsInAnimationInfo( pInfo
);
1247 pInfo
->meClickAction
= eClickAction
;
1249 switch( eClickAction
)
1251 case presentation::ClickAction_NONE
:
1252 case presentation::ClickAction_PREVPAGE
:
1253 case presentation::ClickAction_NEXTPAGE
:
1254 case presentation::ClickAction_FIRSTPAGE
:
1255 case presentation::ClickAction_LASTPAGE
:
1256 case presentation::ClickAction_INVISIBLE
:
1257 case presentation::ClickAction_STOPPRESENTATION
:
1263 case presentation::ClickAction_PROGRAM
:
1264 case presentation::ClickAction_BOOKMARK
:
1265 case presentation::ClickAction_DOCUMENT
:
1266 if( nFound
& FoundFlags::Bookmark
)
1268 if( eClickAction
== presentation::ClickAction_BOOKMARK
)
1270 aStrBookmark
= getUiNameFromPageApiNameImpl( aStrBookmark
);
1272 else if( eClickAction
== presentation::ClickAction_DOCUMENT
)
1274 sal_Int32 nPos
= aStrBookmark
.lastIndexOf( '#' );
1277 OUString
aURL( aStrBookmark
.copy( 0, nPos
+1 ) );
1278 aURL
+= getUiNameFromPageApiNameImpl( aStrBookmark
.copy( nPos
+1 ) );
1279 aStrBookmark
= aURL
;
1283 pInfo
->SetBookmark( aStrBookmark
);
1288 case presentation::ClickAction_MACRO
:
1289 if( nFound
& FoundFlags::Macro
)
1291 pInfo
->SetBookmark( aStrMacro
);
1296 case presentation::ClickAction_VERB
:
1297 if( nFound
& FoundFlags::Verb
)
1299 pInfo
->mnVerb
= static_cast<sal_uInt16
>(nVerb
);
1304 case presentation::ClickAction_VANISH
:
1305 if( !( nFound
& FoundFlags::Effect
) )
1308 pInfo
->meSecondEffect
= eEffect
;
1309 pInfo
->meSecondSpeed
= nFound
& FoundFlags::Speed
? eSpeed
: presentation::AnimationSpeed_MEDIUM
;
1315 case presentation::ClickAction_SOUND
:
1316 if( nFound
& FoundFlags::SoundUrl
)
1318 pInfo
->SetBookmark( aStrSoundURL
);
1319 if( eClickAction
!= presentation::ClickAction_SOUND
)
1320 pInfo
->mbSecondSoundOn
= !aStrSoundURL
.isEmpty();
1321 pInfo
->mbSecondPlayFull
= (nFound
& FoundFlags::PlayFull
) && bPlayFull
;
1332 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( true );
1334 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1335 if( nullptr == pInfo
)
1338 clearEventsInAnimationInfo( pInfo
);
1339 pInfo
->meClickAction
= presentation::ClickAction_MACRO
;
1341 if ( SfxApplication::IsXScriptURL( aStrMacro
) )
1343 pInfo
->SetBookmark( aStrMacro
);
1347 sal_Int32 nIdx
{ 0 };
1348 const OUString aLibName
= aStrMacro
.getToken(0, '.', nIdx
);
1349 const OUString aModulName
= aStrMacro
.getToken(0, '.', nIdx
);
1350 const OUString aMacroName
= aStrMacro
.getToken(0, '.', nIdx
);
1352 OUStringBuffer sBuffer
;
1353 sBuffer
.append( aMacroName
);
1354 sBuffer
.append( '.' );
1355 sBuffer
.append( aModulName
);
1356 sBuffer
.append( '.' );
1357 sBuffer
.append( aLibName
);
1358 sBuffer
.append( '.' );
1360 if ( aStrLibrary
== "StarOffice" )
1362 sBuffer
.append( "BASIC" );
1366 sBuffer
.append( aStrLibrary
);
1369 pInfo
->SetBookmark( sBuffer
.makeStringAndClear() );
1377 throw lang::IllegalArgumentException();
1381 uno::Any SAL_CALL
SdUnoEventsAccess::getByName( const OUString
& aName
)
1383 if( mpShape
== nullptr || aName
!= gaStrOnClick
)
1384 throw container::NoSuchElementException();
1386 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo();
1388 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1390 eClickAction
= pInfo
->meClickAction
;
1392 sal_Int32 nPropertyCount
= 2;
1393 switch( eClickAction
)
1395 case presentation::ClickAction_NONE
:
1396 case presentation::ClickAction_PREVPAGE
:
1397 case presentation::ClickAction_NEXTPAGE
:
1398 case presentation::ClickAction_FIRSTPAGE
:
1399 case presentation::ClickAction_LASTPAGE
:
1400 case presentation::ClickAction_INVISIBLE
:
1401 case presentation::ClickAction_STOPPRESENTATION
:
1403 case presentation::ClickAction_PROGRAM
:
1404 case presentation::ClickAction_VERB
:
1405 case presentation::ClickAction_BOOKMARK
:
1406 case presentation::ClickAction_DOCUMENT
:
1407 case presentation::ClickAction_MACRO
:
1408 if ( !SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1409 nPropertyCount
+= 1;
1412 case presentation::ClickAction_SOUND
:
1413 nPropertyCount
+= 2;
1416 case presentation::ClickAction_VANISH
:
1417 nPropertyCount
+= 4;
1423 uno::Sequence
< beans::PropertyValue
> aProperties( nPropertyCount
);
1424 beans::PropertyValue
* pProperties
= aProperties
.getArray();
1428 if( eClickAction
== presentation::ClickAction_MACRO
)
1430 if ( SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1432 // Scripting Framework URL
1433 aAny
<<= OUString(gaStrScript
);
1434 pProperties
->Name
= gaStrEventType
;
1435 pProperties
->Handle
= -1;
1436 pProperties
->Value
= aAny
;
1437 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1440 aAny
<<= pInfo
->GetBookmark();
1441 pProperties
->Name
= gaStrScript
;
1442 pProperties
->Handle
= -1;
1443 pProperties
->Value
= aAny
;
1444 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1449 // Old Basic macro URL
1450 aAny
<<= OUString(gaStrStarBasic
);
1451 pProperties
->Name
= gaStrEventType
;
1452 pProperties
->Handle
= -1;
1453 pProperties
->Value
= aAny
;
1454 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1457 OUString aMacro
= pInfo
->GetBookmark();
1459 // aMacro has got following format:
1460 // "Macroname.Modulname.Libname.Documentname" or
1461 // "Macroname.Modulname.Libname.Applicationname"
1462 sal_Int32 nIdx
{ 0 };
1463 const OUString aMacroName
= aMacro
.getToken(0, '.', nIdx
);
1464 const OUString aModulName
= aMacro
.getToken(0, '.', nIdx
);
1465 const OUString aLibName
= aMacro
.getToken(0, '.', nIdx
);
1467 OUString sBuffer
= aLibName
+
1474 pProperties
->Name
= gaStrMacroName
;
1475 pProperties
->Handle
= -1;
1476 pProperties
->Value
= aAny
;
1477 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1480 aAny
<<= OUString( "StarOffice" );
1481 pProperties
->Name
= gaStrLibrary
;
1482 pProperties
->Handle
= -1;
1483 pProperties
->Value
= aAny
;
1484 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1489 aAny
<<= OUString(gaStrPresentation
);
1490 pProperties
->Name
= gaStrEventType
;
1491 pProperties
->Handle
= -1;
1492 pProperties
->Value
= aAny
;
1493 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1496 aAny
<<= eClickAction
;
1497 pProperties
->Name
= gaStrClickAction
;
1498 pProperties
->Handle
= -1;
1499 pProperties
->Value
= aAny
;
1500 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1503 switch( eClickAction
)
1505 case presentation::ClickAction_NONE
:
1506 case presentation::ClickAction_PREVPAGE
:
1507 case presentation::ClickAction_NEXTPAGE
:
1508 case presentation::ClickAction_FIRSTPAGE
:
1509 case presentation::ClickAction_LASTPAGE
:
1510 case presentation::ClickAction_INVISIBLE
:
1511 case presentation::ClickAction_STOPPRESENTATION
:
1513 case presentation::ClickAction_BOOKMARK
:
1515 const OUString
aStrBookmark( getPageApiNameFromUiName( pInfo
->GetBookmark()) );
1516 pProperties
->Name
= gaStrBookmark
;
1517 pProperties
->Handle
= -1;
1518 pProperties
->Value
<<= aStrBookmark
;
1519 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1523 case presentation::ClickAction_DOCUMENT
:
1524 case presentation::ClickAction_PROGRAM
:
1526 OUString
aString( pInfo
->GetBookmark());
1527 sal_Int32 nPos
= aString
.lastIndexOf( '#' );
1530 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
1531 aURL
+= getPageApiNameFromUiName( aString
.copy( nPos
+1 ) );
1534 pProperties
->Name
= gaStrBookmark
;
1535 pProperties
->Handle
= -1;
1536 pProperties
->Value
<<= aString
;
1537 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1541 case presentation::ClickAction_VANISH
:
1542 aAny
<<= pInfo
->meSecondEffect
;
1543 pProperties
->Name
= gaStrEffect
;
1544 pProperties
->Handle
= -1;
1545 pProperties
->Value
= aAny
;
1546 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1549 aAny
<<= pInfo
->meSecondSpeed
;
1550 pProperties
->Name
= gaStrSpeed
;
1551 pProperties
->Handle
= -1;
1552 pProperties
->Value
= aAny
;
1553 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1558 case presentation::ClickAction_SOUND
:
1559 if( eClickAction
== presentation::ClickAction_SOUND
|| pInfo
->mbSecondSoundOn
)
1561 aAny
<<= pInfo
->GetBookmark();
1562 pProperties
->Name
= gaStrSoundURL
;
1563 pProperties
->Handle
= -1;
1564 pProperties
->Value
= aAny
;
1565 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1568 pProperties
->Name
= gaStrPlayFull
;
1569 pProperties
->Handle
= -1;
1570 pProperties
->Value
<<= pInfo
->mbSecondPlayFull
;
1571 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1575 case presentation::ClickAction_VERB
:
1576 aAny
<<= static_cast<sal_Int32
>(pInfo
->mnVerb
);
1577 pProperties
->Name
= gaStrVerb
;
1578 pProperties
->Handle
= -1;
1579 pProperties
->Value
= aAny
;
1580 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1587 aAny
<<= aProperties
;
1591 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getElementNames( )
1593 return { gaStrOnClick
};
1596 sal_Bool SAL_CALL
SdUnoEventsAccess::hasByName( const OUString
& aName
)
1598 return aName
== gaStrOnClick
;
1602 uno::Type SAL_CALL
SdUnoEventsAccess::getElementType( )
1604 return cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get();
1607 sal_Bool SAL_CALL
SdUnoEventsAccess::hasElements( )
1613 OUString SAL_CALL
SdUnoEventsAccess::getImplementationName( )
1615 return "SdUnoEventsAccess";
1618 sal_Bool SAL_CALL
SdUnoEventsAccess::supportsService( const OUString
& ServiceName
)
1620 return cppu::supportsService(this, ServiceName
);
1623 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getSupportedServiceNames( )
1625 return { gaStrServiceName
};
1628 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */