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/text/XText.hpp>
29 #include <com/sun/star/beans/PropertyState.hpp>
30 #include <com/sun/star/beans/PropertyValues.hpp>
31 #include <rtl/ustrbuf.hxx>
32 #include <svl/itemprop.hxx>
33 #include <svl/style.hxx>
34 #include <svx/svdpool.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <sfx2/app.hxx>
37 #include <svtools/unoimap.hxx>
38 #include <svtools/unoevent.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <sfx2/event.hxx>
41 #include <sfx2/sfxsids.hrc>
42 #include <comphelper/extract.hxx>
43 #include <cppuhelper/implbase.hxx>
44 #include <cppuhelper/supportsservice.hxx>
45 #include <svx/unoprov.hxx>
46 #include <svx/unoshape.hxx>
47 #include <svx/svditer.hxx>
48 #include <svx/svdotext.hxx>
49 #include <svx/unoapi.hxx>
50 #include <svx/svdopath.hxx>
51 #include <svx/svdoole2.hxx>
52 #include <svx/svdograf.hxx>
53 #include <filter/msfilter/msdffimp.hxx>
54 #include <svl/instrm.hxx>
55 #include <editeng/outlobj.hxx>
56 #include <CustomAnimationPreset.hxx>
57 #include <Outliner.hxx>
58 #include <comphelper/serviceinfohelper.hxx>
59 #include <svx/svdogrp.hxx>
60 #include <o3tl/typed_flags_set.hxx>
61 #include <vcl/svapp.hxx>
62 #include <tools/debug.hxx>
64 #include <anminfo.hxx>
66 #include <unoprnms.hxx>
67 #include <unomodel.hxx>
68 #include <drawdoc.hxx>
71 #include <ViewShell.hxx>
72 #include <unokywds.hxx>
73 #include <unopage.hxx>
74 #include <DrawDocShell.hxx>
76 #include "unolayer.hxx"
77 #include <imapinfo.hxx>
78 #include <EffectMigration.hxx>
81 using namespace ::com::sun::star
;
82 using namespace ::com::sun::star::presentation
;
83 using namespace ::com::sun::star::animations
;
85 using ::com::sun::star::uno::makeAny
;
86 using ::com::sun::star::uno::Any
;
87 using ::com::sun::star::drawing::XShape
;
91 #define WID_TEXTEFFECT 3
92 #define WID_BOOKMARK 4
93 #define WID_CLICKACTION 5
94 #define WID_PLAYFULL 6
95 #define WID_SOUNDFILE 7
97 #define WID_BLUESCREEN 9
99 #define WID_DIMCOLOR 11
100 #define WID_DIMHIDE 12
101 #define WID_DIMPREV 13
102 #define WID_PRESORDER 14
104 #define WID_ANIMPATH 16
105 #define WID_IMAGEMAP 17
106 #define WID_ISANIMATION 18
107 #define WID_THAT_NEED_ANIMINFO 19
109 #define WID_ISEMPTYPRESOBJ 20
110 #define WID_ISPRESOBJ 21
111 #define WID_MASTERDEPEND 22
113 #define WID_NAVORDER 23
114 #define WID_PLACEHOLDERTEXT 24
115 #define WID_LEGACYFRAGMENT 25
117 #define IMPRESS_MAP_ENTRIES \
118 { OUString(UNO_NAME_OBJ_LEGACYFRAGMENT),WID_LEGACYFRAGMENT, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
119 { OUString(UNO_NAME_OBJ_ANIMATIONPATH), WID_ANIMPATH, cppu::UnoType<drawing::XShape>::get(), 0, 0},\
120 { OUString(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
121 { OUString(UNO_NAME_OBJ_DIMCOLOR), WID_DIMCOLOR, cppu::UnoType<sal_Int32>::get(), 0, 0},\
122 { OUString(UNO_NAME_OBJ_DIMHIDE), WID_DIMHIDE, cppu::UnoType<bool>::get(), 0, 0},\
123 { OUString(UNO_NAME_OBJ_DIMPREV), WID_DIMPREV, cppu::UnoType<bool>::get(), 0, 0},\
124 { OUString(UNO_NAME_OBJ_EFFECT), WID_EFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
125 { OUString(UNO_NAME_OBJ_ISEMPTYPRESOBJ),WID_ISEMPTYPRESOBJ, cppu::UnoType<bool>::get(), 0, 0},\
126 { OUString(UNO_NAME_OBJ_ISPRESOBJ), WID_ISPRESOBJ, cppu::UnoType<bool>::get(), css::beans::PropertyAttribute::READONLY, 0},\
127 { OUString(UNO_NAME_OBJ_MASTERDEPENDENT),WID_MASTERDEPEND, cppu::UnoType<bool>::get(), 0, 0},\
128 { OUString(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(), 0, 0},\
129 { OUString(UNO_NAME_OBJ_PLAYFULL), WID_PLAYFULL, cppu::UnoType<bool>::get(), 0, 0},\
130 { OUString(UNO_NAME_OBJ_PRESORDER), WID_PRESORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
131 { OUString(UNO_NAME_OBJ_STYLE), WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
132 { OUString(UNO_NAME_OBJ_SOUNDFILE), WID_SOUNDFILE, cppu::UnoType<OUString>::get(), 0, 0},\
133 { OUString(UNO_NAME_OBJ_SOUNDON), WID_SOUNDON, cppu::UnoType<bool>::get(), 0, 0},\
134 { OUString(UNO_NAME_OBJ_SPEED), WID_SPEED, cppu::UnoType<presentation::AnimationSpeed>::get(), 0, 0},\
135 { OUString(UNO_NAME_OBJ_TEXTEFFECT), WID_TEXTEFFECT, cppu::UnoType<presentation::AnimationEffect>::get(), 0, 0},\
136 { OUString(UNO_NAME_OBJ_BLUESCREEN), WID_BLUESCREEN, cppu::UnoType<sal_Int32>::get(), 0, 0},\
137 { OUString(UNO_NAME_OBJ_VERB), WID_VERB, cppu::UnoType<sal_Int32>::get(), 0, 0},\
138 { OUString("IsAnimation"), WID_ISANIMATION, cppu::UnoType<bool>::get(), 0, 0},\
139 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
140 { OUString("PlaceholderText"), WID_PLACEHOLDERTEXT, cppu::UnoType<OUString>::get(), 0, 0},\
141 { OUString(), 0, css::uno::Type(), 0, 0 }
143 static const SfxItemPropertyMapEntry
* lcl_GetImpress_SdXShapePropertyGraphicMap_Impl()
146 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertyGraphicMap_Impl
[] =
148 { OUString("ImageMap"), WID_IMAGEMAP
, cppu::UnoType
<container::XIndexContainer
>::get(), 0, 0 },
151 return aImpress_SdXShapePropertyGraphicMap_Impl
;
154 static const SfxItemPropertyMapEntry
* lcl_GetImpress_SdXShapePropertySimpleMap_Impl()
157 static const SfxItemPropertyMapEntry aImpress_SdXShapePropertySimpleMap_Impl
[] =
161 return aImpress_SdXShapePropertySimpleMap_Impl
;
164 #define DRAW_MAP_ENTRIES\
165 { OUString(UNO_NAME_OBJ_BOOKMARK), WID_BOOKMARK, cppu::UnoType<OUString>::get(), 0, 0},\
166 { OUString(UNO_NAME_OBJ_CLICKACTION), WID_CLICKACTION, cppu::UnoType<presentation::ClickAction>::get(),0, 0},\
167 { OUString(UNO_NAME_OBJ_STYLE), WID_STYLE, cppu::UnoType<style::XStyle>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0},\
168 { OUString("NavigationOrder"), WID_NAVORDER, cppu::UnoType<sal_Int32>::get(), 0, 0},\
169 { OUString(), 0, css::uno::Type(), 0, 0 }
171 static const SfxItemPropertyMapEntry
* lcl_GetDraw_SdXShapePropertySimpleMap_Impl()
173 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyMap_Impl
[] =
177 return aDraw_SdXShapePropertyMap_Impl
;
179 static const SfxItemPropertyMapEntry
* lcl_GetDraw_SdXShapePropertyGraphicMap_Impl()
181 static const SfxItemPropertyMapEntry aDraw_SdXShapePropertyGraphicMap_Impl
[] =
183 { OUString("ImageMap"), WID_IMAGEMAP
, cppu::UnoType
<container::XIndexContainer
>::get(), 0, 0 },
186 return aDraw_SdXShapePropertyGraphicMap_Impl
;
188 static const SfxItemPropertyMapEntry
* lcl_ImplGetShapePropertyMap( bool bImpress
, bool bGraphicObj
)
190 const SfxItemPropertyMapEntry
* pRet
= nullptr;
194 pRet
= lcl_GetImpress_SdXShapePropertyGraphicMap_Impl();
196 pRet
= lcl_GetImpress_SdXShapePropertySimpleMap_Impl();
201 pRet
= lcl_GetDraw_SdXShapePropertyGraphicMap_Impl();
203 pRet
= lcl_GetDraw_SdXShapePropertySimpleMap_Impl();
208 static const SvxItemPropertySet
* lcl_ImplGetShapePropertySet( bool bImpress
, bool bGraphicObj
)
210 const SvxItemPropertySet
* pRet
= nullptr;
215 static SvxItemPropertySet
aImpress_SdXShapePropertyGraphicSet_Impl( lcl_GetImpress_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
216 pRet
= &aImpress_SdXShapePropertyGraphicSet_Impl
;
220 static SvxItemPropertySet
aImpress_SdXShapePropertySet_Impl(lcl_GetImpress_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
221 pRet
= &aImpress_SdXShapePropertySet_Impl
;
228 static SvxItemPropertySet
aDraw_SdXShapePropertyGraphicSet_Impl(lcl_GetDraw_SdXShapePropertyGraphicMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
229 pRet
= &aDraw_SdXShapePropertyGraphicSet_Impl
;
233 static SvxItemPropertySet
aDraw_SdXShapePropertySet_Impl( lcl_GetDraw_SdXShapePropertySimpleMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool());
234 pRet
= &aDraw_SdXShapePropertySet_Impl
;
239 static const SfxItemPropertyMapEntry
* lcl_GetEmpty_SdXShapePropertyMap_Impl()
241 static const SfxItemPropertyMapEntry aEmpty_SdXShapePropertyMap_Impl
[] =
243 { OUString(), 0, css::uno::Type(), 0, 0 }
245 return aEmpty_SdXShapePropertyMap_Impl
;
248 static const SvxItemPropertySet
* lcl_GetEmpty_SdXShapePropertySet_Impl()
250 static SvxItemPropertySet
aEmptyPropSet( lcl_GetEmpty_SdXShapePropertyMap_Impl(), SdrObject::GetGlobalDrawObjectItemPool() );
251 return &aEmptyPropSet
;
253 const SvEventDescription
* ImplGetSupportedMacroItems()
255 static const SvEventDescription aMacroDescriptionsImpl
[] =
257 { SvMacroItemId::OnMouseOver
, "OnMouseOver" },
258 { SvMacroItemId::OnMouseOut
, "OnMouseOut" },
259 { SvMacroItemId::NONE
, nullptr }
262 return aMacroDescriptionsImpl
;
265 SdXShape::SdXShape(SvxShape
* pShape
, SdXImpressDocument
* pModel
)
268 lcl_ImplGetShapePropertySet(pModel
->IsImpressDocument(), pShape
->getShapeKind() == OBJ_GRAF
)
269 : lcl_GetEmpty_SdXShapePropertySet_Impl() ),
271 lcl_ImplGetShapePropertyMap(pModel
->IsImpressDocument(), pShape
->getShapeKind() == OBJ_GRAF
)
272 : lcl_GetEmpty_SdXShapePropertyMap_Impl() ),
276 pShape
->setMaster( this );
279 SdXShape::~SdXShape() throw()
283 void SdXShape::dispose()
285 mpShape
->setMaster( nullptr );
289 uno::Any SAL_CALL
SdXShape::queryInterface( const uno::Type
& rType
)
291 return mpShape
->queryInterface( rType
);
294 void SAL_CALL
SdXShape::acquire() throw()
299 void SAL_CALL
SdXShape::release() throw()
304 bool SdXShape::queryAggregation( const css::uno::Type
& rType
, css::uno::Any
& aAny
)
306 if( mpModel
&& mpModel
->IsImpressDocument() )
308 if( rType
== cppu::UnoType
<document::XEventsSupplier
>::get())
310 aAny
<<= uno::Reference
< document::XEventsSupplier
>(this);
318 uno::Sequence
< uno::Type
> SAL_CALL
SdXShape::getTypes()
320 if( mpModel
&& !mpModel
->IsImpressDocument() )
322 return mpShape
->_getTypes();
326 sal_uInt32 nObjId
= mpShape
->getShapeKind();
327 uno::Sequence
< uno::Type
> aTypes
;
328 SdTypesCache
& gImplTypesCache
= SD_MOD()->gImplTypesCache
;
329 SdTypesCache::iterator
aIter( gImplTypesCache
.find( nObjId
) );
330 if( aIter
== gImplTypesCache
.end() )
332 aTypes
= mpShape
->_getTypes();
333 sal_uInt32 nCount
= aTypes
.getLength();
334 aTypes
.realloc( nCount
+1 );
335 aTypes
[nCount
] = cppu::UnoType
<lang::XTypeProvider
>::get();
337 gImplTypesCache
.insert(std::make_pair(nObjId
, aTypes
));
341 // use the already computed implementation id
342 aTypes
= (*aIter
).second
;
349 beans::PropertyState SAL_CALL
SdXShape::getPropertyState( const OUString
& PropertyName
)
351 SolarMutexGuard aGuard
;
353 if( mpPropSet
->getPropertyMapEntry(PropertyName
) )
355 return beans::PropertyState_DIRECT_VALUE
;
359 SdrObject
* pObj
= mpShape
->GetSdrObject();
360 if( pObj
== nullptr || ( pObj
->getSdrPageFromSdrObject()->IsMasterPage() && pObj
->IsEmptyPresObj() ) )
361 return beans::PropertyState_DEFAULT_VALUE
;
363 return mpShape
->_getPropertyState( PropertyName
);
367 void SAL_CALL
SdXShape::setPropertyToDefault( const OUString
& PropertyName
)
369 SolarMutexGuard aGuard
;
371 if( mpPropSet
->getPropertyMapEntry(PropertyName
) )
377 mpShape
->_setPropertyToDefault(PropertyName
);
381 uno::Any SAL_CALL
SdXShape::getPropertyDefault( const OUString
& aPropertyName
)
383 SolarMutexGuard aGuard
;
385 if( mpPropSet
->getPropertyMapEntry(aPropertyName
) )
387 return getPropertyValue( aPropertyName
);
391 uno::Any
aRet( mpShape
->_getPropertyDefault(aPropertyName
) );
397 css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
SdXShape::getPropertySetInfo()
399 SfxItemPropertyMapEntry
const * nObjId
= mpShape
->getPropertyMapEntries();
400 css::uno::Reference
<css::beans::XPropertySetInfo
> pInfo
;
402 SdExtPropertySetInfoCache
& rCache
= (mpModel
&& mpModel
->IsImpressDocument()) ?
403 SD_MOD()->gImplImpressPropertySetInfoCache
: SD_MOD()->gImplDrawPropertySetInfoCache
;
405 SdExtPropertySetInfoCache::iterator
aIter( rCache
.find( nObjId
) );
406 if( aIter
== rCache
.end() )
408 uno::Reference
< beans::XPropertySetInfo
> xInfo( mpShape
->_getPropertySetInfo() );
409 pInfo
= new SfxExtItemPropertySetInfo( mpMap
, xInfo
->getProperties() );
411 rCache
.insert(std::make_pair(nObjId
, pInfo
));
415 // use the already computed implementation id
416 pInfo
= (*aIter
).second
;
422 void SAL_CALL
SdXShape::setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
)
424 SolarMutexGuard aGuard
;
426 const SfxItemPropertySimpleEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(aPropertyName
);
430 SdrObject
* pObj
= mpShape
->GetSdrObject();
433 SdAnimationInfo
* pInfo
= GetAnimationInfo(pEntry
->nWID
<= WID_THAT_NEED_ANIMINFO
);
439 sal_Int32 nNavOrder
= 0;
440 if(!(aValue
>>= nNavOrder
))
441 throw lang::IllegalArgumentException();
443 SdrObjList
* pObjList
= pObj
->getParentSdrObjListFromSdrObject();
445 pObjList
->SetObjectNavigationPosition( *pObj
, (nNavOrder
< 0) ? SAL_MAX_UINT32
: static_cast< sal_uInt32
>( nNavOrder
) );
451 AnimationEffect eEffect
;
452 if(!(aValue
>>= eEffect
))
453 throw lang::IllegalArgumentException();
455 EffectMigration::SetAnimationEffect( mpShape
, eEffect
);
460 AnimationEffect eEffect
;
461 if(!(aValue
>>= eEffect
))
462 throw lang::IllegalArgumentException();
464 EffectMigration::SetTextAnimationEffect( mpShape
, eEffect
);
469 AnimationSpeed eSpeed
;
470 if(!(aValue
>>=eSpeed
))
471 throw lang::IllegalArgumentException();
473 EffectMigration::SetAnimationSpeed( mpShape
, eSpeed
);
476 case WID_ISANIMATION
:
478 bool bIsAnimation(false);
480 if(!(aValue
>>= bIsAnimation
))
482 throw lang::IllegalArgumentException();
487 SdrObjGroup
* pGroup
= dynamic_cast< SdrObjGroup
* >(pObj
);
488 SdPage
* pPage
= pGroup
? dynamic_cast< SdPage
* >(pGroup
->getSdrPageFromSdrObject()) : nullptr;
492 // #i42894# Animated Group object, migrate that effect
493 EffectMigration::CreateAnimatedGroup(*pGroup
, *pPage
);
495 // #i42894# unfortunately when doing this all group members have to
496 // be moved to the page as direct members, else the currently
497 // available forms of animation do not work. If it succeeds,
498 // the group is empty and can be removed and deleted
499 if(!pGroup
->GetSubList()->GetObjCount())
501 pPage
->NbcRemoveObject(pGroup
->GetOrdNum());
503 // always use SdrObject::Free(...) for SdrObjects (!)
504 SdrObject
* pTemp(pGroup
);
505 SdrObject::Free(pTemp
);
509 //pInfo->mbIsMovie = bIsAnimation;
515 if(!(aValue
>>= aString
))
516 throw lang::IllegalArgumentException();
518 pInfo
->SetBookmark( SdDrawPage::getUiNameFromPageApiName( aString
) );
521 case WID_CLICKACTION
:
522 ::cppu::any2enum
< presentation::ClickAction
>( pInfo
->meClickAction
, aValue
);
525 // TODO: WID_PLAYFULL:
529 if(!(aValue
>>= aString
))
530 throw lang::IllegalArgumentException();
531 pInfo
->maSoundFile
= aString
;
532 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
538 if( !(aValue
>>= pInfo
->mbSoundOn
) )
539 throw lang::IllegalArgumentException();
540 EffectMigration::UpdateSoundEffect( mpShape
, pInfo
);
546 if(!(aValue
>>= nVerb
))
547 throw lang::IllegalArgumentException();
549 pInfo
->mnVerb
= static_cast<sal_uInt16
>(nVerb
);
554 sal_Int32 nColor
= 0;
556 if( !(aValue
>>= nColor
) )
557 throw lang::IllegalArgumentException();
559 EffectMigration::SetDimColor( mpShape
, nColor
);
564 bool bDimHide
= false;
565 if( !(aValue
>>= bDimHide
) )
566 throw lang::IllegalArgumentException();
568 EffectMigration::SetDimHide( mpShape
, bDimHide
);
573 bool bDimPrevious
= false;
574 if( !(aValue
>>= bDimPrevious
) )
575 throw lang::IllegalArgumentException();
577 EffectMigration::SetDimPrevious( mpShape
, bDimPrevious
);
582 sal_Int32 nNewPos
= 0;
583 if( !(aValue
>>= nNewPos
) )
584 throw lang::IllegalArgumentException();
586 EffectMigration::SetPresentationOrder( mpShape
, nNewPos
);
590 SetStyleSheet( aValue
);
592 case WID_ISEMPTYPRESOBJ
:
593 SetEmptyPresObj( ::cppu::any2bool(aValue
) );
595 case WID_MASTERDEPEND
:
596 SetMasterDepend( ::cppu::any2bool(aValue
) );
599 case WID_LEGACYFRAGMENT
:
601 uno::Reference
< io::XInputStream
> xInputStream
;
602 aValue
>>= xInputStream
;
603 if( xInputStream
.is() )
605 SvInputStream
aStream( xInputStream
);
606 SdrObject
* pObject
= mpShape
->GetSdrObject();
607 SvxMSDffManager::ReadObjText( aStream
, pObject
);
614 uno::Reference
< drawing::XShape
> xShape( aValue
, uno::UNO_QUERY
);
615 SdrPathObj
* pObj2
= xShape
.is() ? dynamic_cast< SdrPathObj
* >( GetSdrObjectFromXShape( xShape
) ) : nullptr;
617 if( pObj2
== nullptr )
618 throw lang::IllegalArgumentException();
620 EffectMigration::SetAnimationPath( mpShape
, pObj2
);
625 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
629 uno::Reference
< uno::XInterface
> xImageMap
;
630 aValue
>>= xImageMap
;
632 if( !xImageMap
.is() || !SvUnoImageMap_fillImageMap( xImageMap
, aImageMap
) )
633 throw lang::IllegalArgumentException();
635 SdIMapInfo
* pIMapInfo
= SdDrawDocument::GetIMapInfo(pObj
);
638 // replace existing image map
639 pIMapInfo
->SetImageMap( aImageMap
);
643 // insert new user data with image map
644 pObj
->AppendUserData(std::unique_ptr
<SdrObjUserData
>(new SdIMapInfo(aImageMap
) ));
654 mpShape
->_setPropertyValue(aPropertyName
, aValue
);
658 mpModel
->SetModified();
661 css::uno::Any SAL_CALL
SdXShape::getPropertyValue( const OUString
& PropertyName
)
663 SolarMutexGuard aGuard
;
667 const SfxItemPropertySimpleEntry
* pEntry
= mpPropSet
->getPropertyMapEntry(PropertyName
);
669 if( pEntry
&& mpShape
->GetSdrObject() )
671 SdAnimationInfo
* pInfo
= GetAnimationInfo();
677 const sal_uInt32 nNavOrder
= mpShape
->GetSdrObject()->GetNavigationPosition();
678 aRet
<<= nNavOrder
== SAL_MAX_UINT32
? static_cast<sal_Int32
>(-1) : static_cast< sal_Int32
>(nNavOrder
);
682 aRet
<<= EffectMigration::GetAnimationEffect( mpShape
);
685 aRet
<<= EffectMigration::GetTextAnimationEffect( mpShape
);
688 aRet
<<= IsPresObj();
690 case WID_ISEMPTYPRESOBJ
:
691 aRet
<<= IsEmptyPresObj();
693 case WID_MASTERDEPEND
:
694 aRet
<<= IsMasterDepend();
697 aRet
<<= EffectMigration::GetAnimationSpeed( mpShape
);
699 case WID_ISANIMATION
:
700 aRet
<<= (pInfo
&& pInfo
->mbIsMovie
);
702 case WID_PLACEHOLDERTEXT
:
703 aRet
<<= GetPlaceholderText();
708 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : nullptr;
711 // is the bookmark a page?
713 if(pDoc
->GetPageByName( pInfo
->GetBookmark(), bIsMasterPage
) != SDRPAGE_NOTFOUND
)
715 aString
= SdDrawPage::getPageApiNameFromUiName( pInfo
->GetBookmark() );
719 aString
= pInfo
->GetBookmark() ;
720 sal_Int32 nPos
= aString
.lastIndexOf( '#' );
723 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
724 OUString
aName( aString
.copy( nPos
+1 ) );
725 if(pDoc
->GetPageByName( aName
, bIsMasterPage
) != SDRPAGE_NOTFOUND
)
727 aURL
+= SdDrawPage::getPageApiNameFromUiName( aName
);
737 case WID_CLICKACTION
:
738 aRet
<<= ( pInfo
?pInfo
->meClickAction
:presentation::ClickAction_NONE
);
741 aRet
<<= ( pInfo
&& pInfo
->mbPlayFull
);
744 aRet
<<= EffectMigration::GetSoundFile( mpShape
);
747 aRet
<<= EffectMigration::GetSoundOn( mpShape
);
750 aRet
<<= pInfo
? pInfo
->maBlueScreen
: Color(0x00ffffff);
753 aRet
<<= static_cast<sal_Int32
>( pInfo
?pInfo
->mnVerb
:0 );
756 aRet
<<= EffectMigration::GetDimColor( mpShape
);
759 aRet
<<= EffectMigration::GetDimHide( mpShape
);
762 aRet
<<= EffectMigration::GetDimPrevious( mpShape
);
765 aRet
<<= EffectMigration::GetPresentationOrder( mpShape
);
768 aRet
= GetStyleSheet();
772 uno::Reference
< uno::XInterface
> xImageMap
;
774 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
778 SdIMapInfo
* pIMapInfo
= SdDrawDocument::GetIMapInfo(mpShape
->GetSdrObject());
781 const ImageMap
& rIMap
= pIMapInfo
->GetImageMap();
782 xImageMap
= SvUnoImageMap_createInstance( rIMap
, ImplGetSupportedMacroItems() );
786 xImageMap
= SvUnoImageMap_createInstance();
790 aRet
<<= uno::Reference
< container::XIndexContainer
>::query( xImageMap
);
797 aRet
= mpShape
->_getPropertyValue(PropertyName
);
804 SdAnimationInfo
* SdXShape::GetAnimationInfo( bool bCreate
) const
806 SdAnimationInfo
* pInfo
= nullptr;
808 SdrObject
* pObj
= mpShape
->GetSdrObject();
810 pInfo
= SdDrawDocument::GetShapeUserData(*pObj
, bCreate
);
815 uno::Sequence
< OUString
> SAL_CALL
SdXShape::getSupportedServiceNames()
817 uno::Sequence
< OUString
> aSeq( mpShape
->_getSupportedServiceNames() );
819 comphelper::ServiceInfoHelper::addToSequence( aSeq
, {"com.sun.star.presentation.Shape",
820 "com.sun.star.document.LinkTarget"} );
822 SdrObject
* pObj
= mpShape
->GetSdrObject();
823 if(pObj
&& pObj
->GetObjInventor() == SdrInventor::Default
)
825 sal_uInt32 nInventor
= pObj
->GetObjIdentifier();
829 comphelper::ServiceInfoHelper::addToSequence( aSeq
, {"com.sun.star.presentation.TitleTextShape"} );
831 case OBJ_OUTLINETEXT
:
832 comphelper::ServiceInfoHelper::addToSequence( aSeq
, {"com.sun.star.presentation.OutlinerShape"} );
839 /** checks if this is a presentation object
841 bool SdXShape::IsPresObj() const
843 SdrObject
* pObj
= mpShape
->GetSdrObject();
846 SdPage
* pPage
= dynamic_cast<SdPage
* >(pObj
->getSdrPageFromSdrObject());
848 return pPage
->GetPresObjKind(pObj
) != PRESOBJ_NONE
;
853 /** checks if this presentation object is empty
855 bool SdXShape::IsEmptyPresObj() const
857 SdrObject
* pObj
= mpShape
->GetSdrObject();
858 if( (pObj
!= nullptr) && pObj
->IsEmptyPresObj() )
860 // check if the object is in edit, than its temporarily not empty
861 SdrTextObj
* pTextObj
= dynamic_cast< SdrTextObj
* >( pObj
);
862 if( pTextObj
== nullptr )
865 const std::unique_ptr
<OutlinerParaObject
> pParaObj(pTextObj
->GetEditOutlinerParaObject());
872 OUString
SdXShape::GetPlaceholderText() const
874 // only possible if this actually *is* a presentation object
878 SdrObject
* pObj
= mpShape
->GetSdrObject();
879 if( pObj
== nullptr )
882 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
883 DBG_ASSERT( pPage
, "no page?" );
884 if( pPage
== nullptr )
887 return pPage
->GetPresObjText( pPage
->GetPresObjKind(pObj
) );
890 /** sets/reset the empty status of a presentation object
892 void SdXShape::SetEmptyPresObj(bool bEmpty
)
894 // only possible if this actually *is* a presentation object
898 SdrObject
* pObj
= mpShape
->GetSdrObject();
899 if( pObj
== nullptr )
902 if( pObj
->IsEmptyPresObj() == bEmpty
)
907 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
908 const bool bVertical
= pOutlinerParaObject
&& pOutlinerParaObject
->IsVertical();
910 // really delete SdrOutlinerObj at pObj
911 pObj
->NbcSetOutlinerParaObject(nullptr);
912 if( bVertical
&& dynamic_cast<SdrTextObj
*>( pObj
) )
913 static_cast<SdrTextObj
*>(pObj
)->SetVerticalWriting( true );
915 SdrGrafObj
* pGraphicObj
= dynamic_cast<SdrGrafObj
*>( pObj
);
919 pGraphicObj
->SetGraphic(aEmpty
);
923 SdrOle2Obj
* pOleObj
= dynamic_cast< SdrOle2Obj
* >( pObj
);
926 pOleObj
->ClearGraphic();
932 // now set an empty OutlinerParaObject at pObj without
933 // any content but with the style of the old OutlinerParaObjects
937 SdDrawDocument
* pDoc
= mpModel
?mpModel
->GetDoc():nullptr;
938 DBG_ASSERT( pDoc
, "no document?" );
942 SdOutliner
* pOutliner
= pDoc
->GetInternalOutliner();
943 DBG_ASSERT( pOutliner
, "no outliner?" );
944 if( pOutliner
== nullptr )
947 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
948 DBG_ASSERT( pPage
, "no page?" );
949 if( pPage
== nullptr )
952 OutlinerParaObject
* pOutlinerParaObject
= pObj
->GetOutlinerParaObject();
953 pOutliner
->SetText( *pOutlinerParaObject
);
954 const bool bVertical
= pOutliner
->IsVertical();
957 pOutliner
->SetVertical( bVertical
);
958 pOutliner
->SetStyleSheetPool( static_cast<SfxStyleSheetPool
*>(pDoc
->GetStyleSheetPool()) );
959 pOutliner
->SetStyleSheet( 0, pPage
->GetTextStyleSheetForObject( pObj
) );
960 pOutliner
->Insert( pPage
->GetPresObjText( pPage
->GetPresObjKind(pObj
) ) );
961 pObj
->SetOutlinerParaObject( pOutliner
->CreateParaObject() );
967 pObj
->SetEmptyPresObj(bEmpty
);
970 bool SdXShape::IsMasterDepend() const throw()
972 SdrObject
* pObj
= mpShape
->GetSdrObject();
973 return pObj
&& pObj
->GetUserCall() != nullptr;
976 void SdXShape::SetMasterDepend( bool bDepend
) throw()
978 if( IsMasterDepend() == bDepend
)
981 SdrObject
* pObj
= mpShape
->GetSdrObject();
986 SdPage
* pPage
= dynamic_cast< SdPage
* >(pObj
->getSdrPageFromSdrObject());
987 pObj
->SetUserCall( pPage
);
991 pObj
->SetUserCall( nullptr );
996 void SdXShape::SetStyleSheet( const uno::Any
& rAny
)
998 SdrObject
* pObj
= mpShape
->GetSdrObject();
999 if( pObj
== nullptr )
1000 throw beans::UnknownPropertyException();
1002 uno::Reference
< style::XStyle
> xStyle( rAny
, uno::UNO_QUERY
);
1003 SfxStyleSheet
* pStyleSheet
= SfxUnoStyleSheet::getUnoStyleSheet( xStyle
);
1005 const SfxStyleSheet
* pOldStyleSheet
= pObj
->GetStyleSheet();
1006 if( pOldStyleSheet
== pStyleSheet
)
1009 if( pStyleSheet
== nullptr || (pStyleSheet
->GetFamily() != SfxStyleFamily::Para
&& pStyleSheet
->GetFamily() != SfxStyleFamily::Page
) )
1010 throw lang::IllegalArgumentException();
1012 pObj
->SetStyleSheet( pStyleSheet
, false );
1014 SdDrawDocument
* pDoc
= mpModel
? mpModel
->GetDoc() : nullptr;
1017 ::sd::DrawDocShell
* pDocSh
= pDoc
->GetDocSh();
1018 ::sd::ViewShell
* pViewSh
= pDocSh
? pDocSh
->GetViewShell() : nullptr;
1021 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_FAMILY2
);
1025 uno::Any
SdXShape::GetStyleSheet() const
1027 SdrObject
* pObj
= mpShape
->GetSdrObject();
1028 if( pObj
== nullptr )
1029 throw beans::UnknownPropertyException();
1031 SfxStyleSheet
* pStyleSheet
= pObj
->GetStyleSheet();
1032 // it is possible for shapes inside a draw to have a presentation style
1033 // but we don't want this for the api
1034 if( (pStyleSheet
== nullptr) || ((pStyleSheet
->GetFamily() != SfxStyleFamily::Para
) && !mpModel
->IsImpressDocument()) )
1037 return Any( uno::Reference
< style::XStyle
>( dynamic_cast< SfxUnoStyleSheet
* >( pStyleSheet
) ) );
1040 class SdUnoEventsAccess
: public cppu::WeakImplHelper
< css::container::XNameReplace
, css::lang::XServiceInfo
>
1043 SdXShape
* const mpShape
;
1046 explicit SdUnoEventsAccess(SdXShape
* pShape
) throw();
1049 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
1052 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
1053 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
1054 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
1057 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
1058 virtual sal_Bool SAL_CALL
hasElements( ) override
;
1061 virtual OUString SAL_CALL
getImplementationName( ) override
;
1062 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
1063 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
1067 uno::Reference
< container::XNameReplace
> SAL_CALL
SdXShape::getEvents( )
1069 return new SdUnoEventsAccess( this );
1072 static const OUStringLiteral
gaStrOnClick( "OnClick" );
1073 static const OUStringLiteral
gaStrServiceName( "com.sun.star.documents.Events" );
1074 static const OUStringLiteral
gaStrEventType( "EventType" );
1075 static const OUStringLiteral
gaStrPresentation( "Presentation" );
1076 static const OUStringLiteral
gaStrLibrary("Library");
1077 static const OUStringLiteral
gaStrMacroName("MacroName");
1078 static const OUStringLiteral
gaStrClickAction( "ClickAction" );
1079 static const OUStringLiteral
gaStrBookmark( "Bookmark" );
1080 static const OUStringLiteral
gaStrEffect( "Effect" );
1081 static const OUStringLiteral
gaStrPlayFull( "PlayFull" );
1082 static const OUStringLiteral
gaStrVerb( "Verb" );
1083 static const OUStringLiteral
gaStrSoundURL( "SoundURL" );
1084 static const OUStringLiteral
gaStrSpeed( "Speed" );
1085 static const OUStringLiteral
gaStrStarBasic( "StarBasic" );
1086 static const OUStringLiteral
gaStrScript( "Script" );
1088 SdUnoEventsAccess::SdUnoEventsAccess( SdXShape
* pShape
) throw()
1093 enum class FoundFlags
{
1095 ClickAction
= 0x0001,
1107 template<> struct typed_flags
<FoundFlags
> : is_typed_flags
<FoundFlags
, 0x03ff> {};
1110 static void clearEventsInAnimationInfo( SdAnimationInfo
* pInfo
)
1112 pInfo
->SetBookmark( "" );
1113 pInfo
->mbSecondSoundOn
= false;
1114 pInfo
->mbSecondPlayFull
= false;
1115 pInfo
->meClickAction
= presentation::ClickAction_NONE
;
1116 pInfo
->meSecondEffect
= presentation::AnimationEffect_NONE
;
1117 pInfo
->meSecondSpeed
= presentation::AnimationSpeed_MEDIUM
;
1122 void SAL_CALL
SdUnoEventsAccess::replaceByName( const OUString
& aName
, const uno::Any
& aElement
)
1124 if( mpShape
== nullptr || aName
!= gaStrOnClick
)
1125 throw container::NoSuchElementException();
1127 uno::Sequence
< beans::PropertyValue
> aProperties
;
1128 if( !aElement
.hasValue() || aElement
.getValueType() != getElementType() || !(aElement
>>= aProperties
) )
1129 throw lang::IllegalArgumentException();
1131 FoundFlags nFound
= FoundFlags::NONE
;
1132 const beans::PropertyValue
* pProperties
= aProperties
.getConstArray();
1134 OUString aStrEventType
;
1135 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1136 presentation::AnimationEffect eEffect
= presentation::AnimationEffect_NONE
;
1137 presentation::AnimationSpeed eSpeed
= presentation::AnimationSpeed_MEDIUM
;
1138 OUString aStrSoundURL
;
1139 bool bPlayFull
= false;
1140 sal_Int32 nVerb
= 0;
1142 OUString aStrLibrary
;
1143 OUString aStrBookmark
;
1145 const sal_Int32 nCount
= aProperties
.getLength();
1147 for( nIndex
= 0; nIndex
< nCount
; nIndex
++, pProperties
++ )
1149 if( !( nFound
& FoundFlags::EventType
) && pProperties
->Name
== gaStrEventType
)
1151 if( pProperties
->Value
>>= aStrEventType
)
1153 nFound
|= FoundFlags::EventType
;
1157 else if( !( nFound
& FoundFlags::ClickAction
) && pProperties
->Name
== gaStrClickAction
)
1159 if( pProperties
->Value
>>= eClickAction
)
1161 nFound
|= FoundFlags::ClickAction
;
1165 else if( !( nFound
& FoundFlags::Macro
) && ( pProperties
->Name
== gaStrMacroName
|| pProperties
->Name
== gaStrScript
) )
1167 if( pProperties
->Value
>>= aStrMacro
)
1169 nFound
|= FoundFlags::Macro
;
1173 else if( !( nFound
& FoundFlags::Library
) && pProperties
->Name
== gaStrLibrary
)
1175 if( pProperties
->Value
>>= aStrLibrary
)
1177 nFound
|= FoundFlags::Library
;
1181 else if( !( nFound
& FoundFlags::Effect
) && pProperties
->Name
== gaStrEffect
)
1183 if( pProperties
->Value
>>= eEffect
)
1185 nFound
|= FoundFlags::Effect
;
1189 else if( !( nFound
& FoundFlags::Bookmark
) && pProperties
->Name
== gaStrBookmark
)
1191 if( pProperties
->Value
>>= aStrBookmark
)
1193 nFound
|= FoundFlags::Bookmark
;
1197 else if( !( nFound
& FoundFlags::Speed
) && pProperties
->Name
== gaStrSpeed
)
1199 if( pProperties
->Value
>>= eSpeed
)
1201 nFound
|= FoundFlags::Speed
;
1205 else if( !( nFound
& FoundFlags::SoundUrl
) && pProperties
->Name
== gaStrSoundURL
)
1207 if( pProperties
->Value
>>= aStrSoundURL
)
1209 nFound
|= FoundFlags::SoundUrl
;
1213 else if( !( nFound
& FoundFlags::PlayFull
) && pProperties
->Name
== gaStrPlayFull
)
1215 if( pProperties
->Value
>>= bPlayFull
)
1217 nFound
|= FoundFlags::PlayFull
;
1221 else if( !( nFound
& FoundFlags::Verb
) && pProperties
->Name
== gaStrVerb
)
1223 if( pProperties
->Value
>>= nVerb
)
1225 nFound
|= FoundFlags::Verb
;
1230 throw lang::IllegalArgumentException();
1236 if( !( nFound
& FoundFlags::EventType
) )
1239 if( aStrEventType
== gaStrPresentation
)
1241 if( !( nFound
& FoundFlags::ClickAction
) )
1244 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo();
1245 if( presentation::ClickAction_NONE
== eClickAction
&& nullptr == pInfo
)
1251 if( nullptr == pInfo
)
1252 pInfo
= mpShape
->GetAnimationInfo( true );
1254 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1255 if( nullptr == pInfo
)
1258 clearEventsInAnimationInfo( pInfo
);
1259 pInfo
->meClickAction
= eClickAction
;
1261 switch( eClickAction
)
1263 case presentation::ClickAction_NONE
:
1264 case presentation::ClickAction_PREVPAGE
:
1265 case presentation::ClickAction_NEXTPAGE
:
1266 case presentation::ClickAction_FIRSTPAGE
:
1267 case presentation::ClickAction_LASTPAGE
:
1268 case presentation::ClickAction_INVISIBLE
:
1269 case presentation::ClickAction_STOPPRESENTATION
:
1275 case presentation::ClickAction_PROGRAM
:
1276 case presentation::ClickAction_BOOKMARK
:
1277 case presentation::ClickAction_DOCUMENT
:
1278 if( nFound
& FoundFlags::Bookmark
)
1280 if( eClickAction
== presentation::ClickAction_BOOKMARK
)
1282 aStrBookmark
= getUiNameFromPageApiNameImpl( aStrBookmark
);
1284 else if( eClickAction
== presentation::ClickAction_DOCUMENT
)
1286 sal_Int32 nPos
= aStrBookmark
.lastIndexOf( '#' );
1289 OUString
aURL( aStrBookmark
.copy( 0, nPos
+1 ) );
1290 aURL
+= getUiNameFromPageApiNameImpl( aStrBookmark
.copy( nPos
+1 ) );
1291 aStrBookmark
= aURL
;
1295 pInfo
->SetBookmark( aStrBookmark
);
1300 case presentation::ClickAction_MACRO
:
1301 if( nFound
& FoundFlags::Macro
)
1303 pInfo
->SetBookmark( aStrMacro
);
1308 case presentation::ClickAction_VERB
:
1309 if( nFound
& FoundFlags::Verb
)
1311 pInfo
->mnVerb
= static_cast<sal_uInt16
>(nVerb
);
1316 case presentation::ClickAction_VANISH
:
1317 if( !( nFound
& FoundFlags::Effect
) )
1320 pInfo
->meSecondEffect
= eEffect
;
1321 pInfo
->meSecondSpeed
= nFound
& FoundFlags::Speed
? eSpeed
: presentation::AnimationSpeed_MEDIUM
;
1327 case presentation::ClickAction_SOUND
:
1328 if( nFound
& FoundFlags::SoundUrl
)
1330 pInfo
->SetBookmark( aStrSoundURL
);
1331 if( eClickAction
!= presentation::ClickAction_SOUND
)
1332 pInfo
->mbSecondSoundOn
= !aStrSoundURL
.isEmpty();
1333 pInfo
->mbSecondPlayFull
= (nFound
& FoundFlags::PlayFull
) && bPlayFull
;
1344 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo( true );
1346 DBG_ASSERT( pInfo
, "shape animation info could not be created!" );
1347 if( nullptr == pInfo
)
1350 clearEventsInAnimationInfo( pInfo
);
1351 pInfo
->meClickAction
= presentation::ClickAction_MACRO
;
1353 if ( SfxApplication::IsXScriptURL( aStrMacro
) )
1355 pInfo
->SetBookmark( aStrMacro
);
1359 sal_Int32 nIdx
{ 0 };
1360 const OUString aLibName
= aStrMacro
.getToken(0, '.', nIdx
);
1361 const OUString aModulName
= aStrMacro
.getToken(0, '.', nIdx
);
1362 const OUString aMacroName
= aStrMacro
.getToken(0, '.', nIdx
);
1364 OUStringBuffer sBuffer
;
1365 sBuffer
.append( aMacroName
);
1366 sBuffer
.append( '.' );
1367 sBuffer
.append( aModulName
);
1368 sBuffer
.append( '.' );
1369 sBuffer
.append( aLibName
);
1370 sBuffer
.append( '.' );
1372 if ( aStrLibrary
== "StarOffice" )
1374 sBuffer
.append( "BASIC" );
1378 sBuffer
.append( aStrLibrary
);
1381 pInfo
->SetBookmark( sBuffer
.makeStringAndClear() );
1389 throw lang::IllegalArgumentException();
1393 uno::Any SAL_CALL
SdUnoEventsAccess::getByName( const OUString
& aName
)
1395 if( mpShape
== nullptr || aName
!= gaStrOnClick
)
1396 throw container::NoSuchElementException();
1398 SdAnimationInfo
* pInfo
= mpShape
->GetAnimationInfo();
1400 presentation::ClickAction eClickAction
= presentation::ClickAction_NONE
;
1402 eClickAction
= pInfo
->meClickAction
;
1404 sal_Int32 nPropertyCount
= 2;
1405 switch( eClickAction
)
1407 case presentation::ClickAction_NONE
:
1408 case presentation::ClickAction_PREVPAGE
:
1409 case presentation::ClickAction_NEXTPAGE
:
1410 case presentation::ClickAction_FIRSTPAGE
:
1411 case presentation::ClickAction_LASTPAGE
:
1412 case presentation::ClickAction_INVISIBLE
:
1413 case presentation::ClickAction_STOPPRESENTATION
:
1415 case presentation::ClickAction_PROGRAM
:
1416 case presentation::ClickAction_VERB
:
1417 case presentation::ClickAction_BOOKMARK
:
1418 case presentation::ClickAction_DOCUMENT
:
1419 case presentation::ClickAction_MACRO
:
1420 if ( !SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1421 nPropertyCount
+= 1;
1424 case presentation::ClickAction_SOUND
:
1425 nPropertyCount
+= 2;
1428 case presentation::ClickAction_VANISH
:
1429 nPropertyCount
+= 4;
1435 uno::Sequence
< beans::PropertyValue
> aProperties( nPropertyCount
);
1436 beans::PropertyValue
* pProperties
= aProperties
.getArray();
1440 if( eClickAction
== presentation::ClickAction_MACRO
)
1442 if ( SfxApplication::IsXScriptURL( pInfo
->GetBookmark() ) )
1444 // Scripting Framework URL
1445 aAny
<<= OUString(gaStrScript
);
1446 pProperties
->Name
= gaStrEventType
;
1447 pProperties
->Handle
= -1;
1448 pProperties
->Value
= aAny
;
1449 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1452 aAny
<<= pInfo
->GetBookmark();
1453 pProperties
->Name
= gaStrScript
;
1454 pProperties
->Handle
= -1;
1455 pProperties
->Value
= aAny
;
1456 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1461 // Old Basic macro URL
1462 aAny
<<= OUString(gaStrStarBasic
);
1463 pProperties
->Name
= gaStrEventType
;
1464 pProperties
->Handle
= -1;
1465 pProperties
->Value
= aAny
;
1466 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1469 OUString aMacro
= pInfo
->GetBookmark();
1471 // aMacro has got following format:
1472 // "Macroname.Modulname.Libname.Documentname" or
1473 // "Macroname.Modulname.Libname.Applicationname"
1474 sal_Int32 nIdx
{ 0 };
1475 const OUString aMacroName
= aMacro
.getToken(0, '.', nIdx
);
1476 const OUString aModulName
= aMacro
.getToken(0, '.', nIdx
);
1477 const OUString aLibName
= aMacro
.getToken(0, '.', nIdx
);
1479 OUStringBuffer sBuffer
;
1480 sBuffer
.append( aLibName
);
1481 sBuffer
.append( '.' );
1482 sBuffer
.append( aModulName
);
1483 sBuffer
.append( '.' );
1484 sBuffer
.append( aMacroName
);
1486 aAny
<<= sBuffer
.makeStringAndClear();
1487 pProperties
->Name
= gaStrMacroName
;
1488 pProperties
->Handle
= -1;
1489 pProperties
->Value
= aAny
;
1490 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1493 aAny
<<= OUString( "StarOffice" );
1494 pProperties
->Name
= gaStrLibrary
;
1495 pProperties
->Handle
= -1;
1496 pProperties
->Value
= aAny
;
1497 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1502 aAny
<<= OUString(gaStrPresentation
);
1503 pProperties
->Name
= gaStrEventType
;
1504 pProperties
->Handle
= -1;
1505 pProperties
->Value
= aAny
;
1506 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1509 aAny
<<= eClickAction
;
1510 pProperties
->Name
= gaStrClickAction
;
1511 pProperties
->Handle
= -1;
1512 pProperties
->Value
= aAny
;
1513 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1516 switch( eClickAction
)
1518 case presentation::ClickAction_NONE
:
1519 case presentation::ClickAction_PREVPAGE
:
1520 case presentation::ClickAction_NEXTPAGE
:
1521 case presentation::ClickAction_FIRSTPAGE
:
1522 case presentation::ClickAction_LASTPAGE
:
1523 case presentation::ClickAction_INVISIBLE
:
1524 case presentation::ClickAction_STOPPRESENTATION
:
1526 case presentation::ClickAction_BOOKMARK
:
1528 const OUString
aStrBookmark( getPageApiNameFromUiName( pInfo
->GetBookmark()) );
1529 pProperties
->Name
= gaStrBookmark
;
1530 pProperties
->Handle
= -1;
1531 pProperties
->Value
<<= aStrBookmark
;
1532 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1536 case presentation::ClickAction_DOCUMENT
:
1537 case presentation::ClickAction_PROGRAM
:
1539 OUString
aString( pInfo
->GetBookmark());
1540 sal_Int32 nPos
= aString
.lastIndexOf( '#' );
1543 OUString
aURL( aString
.copy( 0, nPos
+1 ) );
1544 aURL
+= getPageApiNameFromUiName( aString
.copy( nPos
+1 ) );
1547 pProperties
->Name
= gaStrBookmark
;
1548 pProperties
->Handle
= -1;
1549 pProperties
->Value
<<= aString
;
1550 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1554 case presentation::ClickAction_VANISH
:
1555 aAny
<<= pInfo
->meSecondEffect
;
1556 pProperties
->Name
= gaStrEffect
;
1557 pProperties
->Handle
= -1;
1558 pProperties
->Value
= aAny
;
1559 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1562 aAny
<<= pInfo
->meSecondSpeed
;
1563 pProperties
->Name
= gaStrSpeed
;
1564 pProperties
->Handle
= -1;
1565 pProperties
->Value
= aAny
;
1566 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1571 case presentation::ClickAction_SOUND
:
1572 if( eClickAction
== presentation::ClickAction_SOUND
|| pInfo
->mbSecondSoundOn
)
1574 aAny
<<= pInfo
->GetBookmark();
1575 pProperties
->Name
= gaStrSoundURL
;
1576 pProperties
->Handle
= -1;
1577 pProperties
->Value
= aAny
;
1578 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1581 pProperties
->Name
= gaStrPlayFull
;
1582 pProperties
->Handle
= -1;
1583 pProperties
->Value
<<= pInfo
->mbSecondPlayFull
;
1584 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1588 case presentation::ClickAction_VERB
:
1589 aAny
<<= static_cast<sal_Int32
>(pInfo
->mnVerb
);
1590 pProperties
->Name
= gaStrVerb
;
1591 pProperties
->Handle
= -1;
1592 pProperties
->Value
= aAny
;
1593 pProperties
->State
= beans::PropertyState_DIRECT_VALUE
;
1600 aAny
<<= aProperties
;
1604 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getElementNames( )
1606 return { gaStrOnClick
};
1609 sal_Bool SAL_CALL
SdUnoEventsAccess::hasByName( const OUString
& aName
)
1611 return aName
== gaStrOnClick
;
1615 uno::Type SAL_CALL
SdUnoEventsAccess::getElementType( )
1617 return cppu::UnoType
<uno::Sequence
< beans::PropertyValue
>>::get();
1620 sal_Bool SAL_CALL
SdUnoEventsAccess::hasElements( )
1626 OUString SAL_CALL
SdUnoEventsAccess::getImplementationName( )
1628 return OUString( "SdUnoEventsAccess" );
1631 sal_Bool SAL_CALL
SdUnoEventsAccess::supportsService( const OUString
& ServiceName
)
1633 return cppu::supportsService(this, ServiceName
);
1636 uno::Sequence
< OUString
> SAL_CALL
SdUnoEventsAccess::getSupportedServiceNames( )
1638 return { gaStrServiceName
};
1641 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */