20 #include <com/sun/star/document/XEventsSupplier.hpp>
21 #include <com/sun/star/container/XNameReplace.hpp>
22 #include <com/sun/star/presentation/AnimationSpeed.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <osl/diagnose.h>
38 using namespace ::
std;
39 using namespace ::
cppu;
60 {
XML_STOP, ClickAction_STOPPRESENTATION },
73 , meClickAction(ClickAction_NONE), meEffect(
EK_none)
74 , meDirection(
ED_none), mnStartScale(100), meSpeed(AnimationSpeed_MEDIUM)
75 , mnVerb(0), mbPlayFull(
false)
88 SdXMLEventContext(
SvXMLImport& rImport, sal_Int32 nElement,
const Reference< XFastAttributeList>& xAttrList,
const Reference< XShape >& rxShape );
92 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
100 XMLEventSoundContext(
SvXMLImport& rImport,
const Reference< XFastAttributeList >& xAttrList, SdXMLEventContext* pParent );
105 XMLEventSoundContext::XMLEventSoundContext(
SvXMLImport& rImp,
const Reference< XFastAttributeList >& xAttrList, SdXMLEventContext* pParent )
110 switch( aIter.getToken() )
124 SdXMLEventContext::SdXMLEventContext(
SvXMLImport& rImp,
126 const Reference< XFastAttributeList >& xAttrList,
const Reference< XShape >& rxShape )
148 switch( aIter.getToken() )
163 maData.mnStartScale =
static_cast<sal_Int16
>(nScale);
174 sEventName = aIter.toString();
175 sal_uInt16 nScriptPrefix =
176 GetImport().GetNamespaceMap().GetKeyByAttrValueQName(sEventName, &sEventName);
183 OUString aScriptLanguage;
184 maData.msLanguage = aIter.toString();
186 GetKeyByAttrValueQName(
maData.msLanguage, &aScriptLanguage);
188 maData.msLanguage = aScriptLanguage;
198 maData.msMacroName = aIter.toString();
202 const OUString &rTmp =
213 maData.mbValid = !sEventName.isEmpty();
216 css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLEventContext::createFastChildContext(
218 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
221 return new XMLEventSoundContext( GetImport(), xAttrList,
this );
227 void SdXMLEventContext::endFastElement(sal_Int32 )
229 GetImport().GetShapeImport()->addShapeEvents(maData);
239 Reference< XEventsSupplier > xEventsSupplier(
mxShape, UNO_QUERY );
240 if( !xEventsSupplier.is() )
243 Reference< XNameReplace > xEvents( xEventsSupplier->getEvents() );
244 SAL_WARN_IF( !xEvents.is(),
"xmloff",
"XEventsSupplier::getEvents() returned NULL" );
248 OUString sAPIEventName;
251 sAPIEventName =
"OnClick";
256 sal_Int32 nPropertyCount = 2;
259 case ClickAction_NONE:
260 case ClickAction_PREVPAGE:
261 case ClickAction_NEXTPAGE:
262 case ClickAction_FIRSTPAGE:
263 case ClickAction_LASTPAGE:
264 case ClickAction_INVISIBLE:
265 case ClickAction_STOPPRESENTATION:
267 case ClickAction_PROGRAM:
268 case ClickAction_VERB:
269 case ClickAction_BOOKMARK:
270 case ClickAction_DOCUMENT:
273 case ClickAction_MACRO:
274 if (
msLanguage.equalsIgnoreAsciiCase(
"starbasic") )
278 case ClickAction_SOUND:
282 case ClickAction_VANISH:
289 aProperties.realloc( nPropertyCount );
290 beans::PropertyValue* pProperties = aProperties.getArray();
294 if (
msLanguage.equalsIgnoreAsciiCase(
"starbasic") )
299 if(
msMacroName.getLength() > rApp.getLength()+1 &&
303 sLibrary =
"StarOffice";
306 else if(
msMacroName.getLength() > rDoc.getLength()+1 &&
314 pProperties->Name =
"EventType";
315 pProperties->Handle = -1;
316 pProperties->Value <<= OUString(
"StarBasic" );
317 pProperties->State = beans::PropertyState_DIRECT_VALUE;
320 pProperties->Name =
"MacroName";
321 pProperties->Handle = -1;
323 pProperties->State = beans::PropertyState_DIRECT_VALUE;
326 pProperties->Name =
"Library";
327 pProperties->Handle = -1;
328 pProperties->Value <<= sLibrary;
329 pProperties->State = beans::PropertyState_DIRECT_VALUE;
333 pProperties->Name =
"EventType";
334 pProperties->Handle = -1;
335 pProperties->Value <<= OUString(
"Script" );
336 pProperties->State = beans::PropertyState_DIRECT_VALUE;
339 pProperties->Name =
"Script";
340 pProperties->Handle = -1;
342 pProperties->State = beans::PropertyState_DIRECT_VALUE;
347 pProperties->Name =
"EventType";
348 pProperties->Handle = -1;
349 pProperties->Value <<= OUString(
"Presentation" );
350 pProperties->State = beans::PropertyState_DIRECT_VALUE;
361 pProperties->Name =
"ClickAction";
362 pProperties->Handle = -1;
364 pProperties->State = beans::PropertyState_DIRECT_VALUE;
369 case ClickAction_NONE:
370 case ClickAction_PREVPAGE:
371 case ClickAction_NEXTPAGE:
372 case ClickAction_FIRSTPAGE:
373 case ClickAction_LASTPAGE:
374 case ClickAction_INVISIBLE:
375 case ClickAction_STOPPRESENTATION:
378 case ClickAction_BOOKMARK:
383 case ClickAction_DOCUMENT:
384 case ClickAction_PROGRAM:
385 pProperties->Name =
"Bookmark";
386 pProperties->Handle = -1;
388 pProperties->State = beans::PropertyState_DIRECT_VALUE;
391 case ClickAction_VANISH:
392 pProperties->Name =
"Effect";
393 pProperties->Handle = -1;
395 pProperties->State = beans::PropertyState_DIRECT_VALUE;
398 pProperties->Name =
"Speed";
399 pProperties->Handle = -1;
400 pProperties->Value <<=
meSpeed;
401 pProperties->State = beans::PropertyState_DIRECT_VALUE;
406 case ClickAction_SOUND:
407 pProperties->Name =
"SoundURL";
408 pProperties->Handle = -1;
410 pProperties->State = beans::PropertyState_DIRECT_VALUE;
413 pProperties->Name =
"PlayFull";
414 pProperties->Handle = -1;
416 pProperties->State = beans::PropertyState_DIRECT_VALUE;
419 case ClickAction_VERB:
420 pProperties->Name =
"Verb";
421 pProperties->Handle = -1;
422 pProperties->Value <<=
mnVerb;
423 pProperties->State = beans::PropertyState_DIRECT_VALUE;
425 case ClickAction_MACRO:
426 OSL_FAIL(
"xmloff::SdXMLEventContext::EndElement(), ClickAction_MACRO must be handled in different if case");
432 xEvents->replaceByName( sAPIEventName,
uno::Any( aProperties ) );
449 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
css::uno::Reference< css::drawing::XShape > mxShape
css::uno::Reference< css::drawing::XShape > mxShape
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
SdXMLEventContextData(const css::uno::Reference< css::drawing::XShape > &rxShape)
SvXMLImport & GetImport()
constexpr sal_uInt16 XML_NAMESPACE_OOO
SvXMLNamespaceMap & GetNamespaceMap()
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
const SvXMLEnumMapEntry< XMLEffectDirection > aXML_AnimationDirection_EnumMap[]
const SvXMLEnumMapEntry< XMLEffect > aXML_AnimationEffect_EnumMap[]
constexpr sal_uInt16 XML_NAMESPACE_DOM
std::vector< sal_Int8 > maData
static bool translateToInternal(std::u16string_view rTheExtURIRef, OUString &rTheIntURIRef, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
uno::Reference< drawing::XShape > const mxShape
PropertiesInfo aProperties
constexpr OUStringLiteral sLibrary
#define XMLOFF_WARN_UNKNOWN(area, rIter)
css::presentation::AnimationSpeed meSpeed
virtual ~SdXMLEventsContext() override
SvXMLEnumMapEntry< ClickAction > const aXML_EventActions_EnumMap[]
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
This class deliberately does not support XWeak, to improve performance when loading large documents...
Map an XMLTokenEnum to an enum value.
SdXMLEventsContext(SvXMLImport &rImport, const css::uno::Reference< css::drawing::XShape > &rxShape)
const SvXMLEnumMapEntry< AnimationSpeed > aXML_AnimationSpeed_EnumMap[]
OUString GetAbsoluteReference(const OUString &rValue) const
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Handling of tokens in XML:
XMLEffectDirection meDirection
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
#define XML_ELEMENT(prefix, name)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
AnimationEffect ImplSdXMLgetEffect(XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool)
css::presentation::ClickAction meClickAction
OUString toString(OptionInfo const *info)
bool m_bDetectedRangeSegmentation false