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>
37 using namespace ::
std;
38 using namespace ::
cppu;
59 {
XML_STOP, ClickAction_STOPPRESENTATION },
72 , meClickAction(ClickAction_NONE), meEffect(
EK_none)
73 , meDirection(
ED_none), mnStartScale(100), meSpeed(AnimationSpeed_MEDIUM)
74 , mnVerb(0), mbPlayFull(false)
87 SdXMLEventContext(
SvXMLImport& rImport, sal_Int32 nElement,
const Reference< XFastAttributeList>& xAttrList,
const Reference< XShape >& rxShape );
91 const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
99 XMLEventSoundContext(
SvXMLImport& rImport,
const Reference< XFastAttributeList >& xAttrList, SdXMLEventContext* pParent );
104 XMLEventSoundContext::XMLEventSoundContext(
SvXMLImport& rImp,
const Reference< XFastAttributeList >& xAttrList, SdXMLEventContext* pParent )
109 switch( aIter.getToken() )
123 SdXMLEventContext::SdXMLEventContext(
SvXMLImport& rImp,
125 const Reference< XFastAttributeList >& xAttrList,
const Reference< XShape >& rxShape )
147 switch( aIter.getToken() )
162 maData.mnStartScale =
static_cast<sal_Int16
>(nScale);
173 sEventName = aIter.toString();
174 sal_uInt16 nScriptPrefix =
175 GetImport().GetNamespaceMap().GetKeyByAttrValueQName(sEventName, &sEventName);
182 OUString aScriptLanguage;
183 maData.msLanguage = aIter.toString();
185 GetKeyByAttrValueQName(
maData.msLanguage, &aScriptLanguage);
187 maData.msLanguage = aScriptLanguage;
197 maData.msMacroName = aIter.toString();
201 const OUString &rTmp =
212 maData.mbValid = !sEventName.isEmpty();
215 css::uno::Reference< css::xml::sax::XFastContextHandler > SdXMLEventContext::createFastChildContext(
217 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
220 return new XMLEventSoundContext( GetImport(), xAttrList,
this );
226 void SdXMLEventContext::endFastElement(sal_Int32 )
228 GetImport().GetShapeImport()->addShapeEvents(maData);
238 Reference< XEventsSupplier > xEventsSupplier(
mxShape, UNO_QUERY );
239 if( !xEventsSupplier.is() )
242 Reference< XNameReplace > xEvents( xEventsSupplier->getEvents() );
243 SAL_WARN_IF( !xEvents.is(),
"xmloff",
"XEventsSupplier::getEvents() returned NULL" );
247 OUString sAPIEventName;
250 sAPIEventName =
"OnClick";
255 sal_Int32 nPropertyCount = 2;
258 case ClickAction_NONE:
259 case ClickAction_PREVPAGE:
260 case ClickAction_NEXTPAGE:
261 case ClickAction_FIRSTPAGE:
262 case ClickAction_LASTPAGE:
263 case ClickAction_INVISIBLE:
264 case ClickAction_STOPPRESENTATION:
266 case ClickAction_PROGRAM:
267 case ClickAction_VERB:
268 case ClickAction_BOOKMARK:
269 case ClickAction_DOCUMENT:
272 case ClickAction_MACRO:
273 if (
msLanguage.equalsIgnoreAsciiCase(
"starbasic") )
277 case ClickAction_SOUND:
281 case ClickAction_VANISH:
288 aProperties.realloc( nPropertyCount );
289 beans::PropertyValue* pProperties = aProperties.getArray();
293 if (
msLanguage.equalsIgnoreAsciiCase(
"starbasic") )
298 if(
msMacroName.getLength() > rApp.getLength()+1 &&
302 sLibrary =
"StarOffice";
305 else if(
msMacroName.getLength() > rDoc.getLength()+1 &&
313 pProperties->Name =
"EventType";
314 pProperties->Handle = -1;
315 pProperties->Value <<= OUString(
"StarBasic" );
316 pProperties->State = beans::PropertyState_DIRECT_VALUE;
319 pProperties->Name =
"MacroName";
320 pProperties->Handle = -1;
322 pProperties->State = beans::PropertyState_DIRECT_VALUE;
325 pProperties->Name =
"Library";
326 pProperties->Handle = -1;
327 pProperties->Value <<= sLibrary;
328 pProperties->State = beans::PropertyState_DIRECT_VALUE;
332 pProperties->Name =
"EventType";
333 pProperties->Handle = -1;
334 pProperties->Value <<= OUString(
"Script" );
335 pProperties->State = beans::PropertyState_DIRECT_VALUE;
338 pProperties->Name =
"Script";
339 pProperties->Handle = -1;
341 pProperties->State = beans::PropertyState_DIRECT_VALUE;
346 pProperties->Name =
"EventType";
347 pProperties->Handle = -1;
348 pProperties->Value <<= OUString(
"Presentation" );
349 pProperties->State = beans::PropertyState_DIRECT_VALUE;
360 pProperties->Name =
"ClickAction";
361 pProperties->Handle = -1;
363 pProperties->State = beans::PropertyState_DIRECT_VALUE;
368 case ClickAction_NONE:
369 case ClickAction_PREVPAGE:
370 case ClickAction_NEXTPAGE:
371 case ClickAction_FIRSTPAGE:
372 case ClickAction_LASTPAGE:
373 case ClickAction_INVISIBLE:
374 case ClickAction_STOPPRESENTATION:
377 case ClickAction_BOOKMARK:
382 case ClickAction_DOCUMENT:
383 case ClickAction_PROGRAM:
384 pProperties->Name =
"Bookmark";
385 pProperties->Handle = -1;
387 pProperties->State = beans::PropertyState_DIRECT_VALUE;
390 case ClickAction_VANISH:
391 pProperties->Name =
"Effect";
392 pProperties->Handle = -1;
394 pProperties->State = beans::PropertyState_DIRECT_VALUE;
397 pProperties->Name =
"Speed";
398 pProperties->Handle = -1;
399 pProperties->Value <<=
meSpeed;
400 pProperties->State = beans::PropertyState_DIRECT_VALUE;
405 case ClickAction_SOUND:
406 pProperties->Name =
"SoundURL";
407 pProperties->Handle = -1;
409 pProperties->State = beans::PropertyState_DIRECT_VALUE;
412 pProperties->Name =
"PlayFull";
413 pProperties->Handle = -1;
415 pProperties->State = beans::PropertyState_DIRECT_VALUE;
418 case ClickAction_VERB:
419 pProperties->Name =
"Verb";
420 pProperties->Handle = -1;
421 pProperties->Value <<=
mnVerb;
422 pProperties->State = beans::PropertyState_DIRECT_VALUE;
424 case ClickAction_MACRO:
425 OSL_FAIL(
"xmloff::SdXMLEventContext::EndElement(), ClickAction_MACRO must be handled in different if case");
431 xEvents->replaceByName( sAPIEventName,
uno::Any( aProperties ) );
448 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
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[]
static bool translateToInternal(OUString const &rTheExtURIRef, OUString &rTheIntURIRef, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
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)