22 #include <string_view>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/presentation/AnimationEffect.hpp>
27 #include <com/sun/star/presentation/AnimationSpeed.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/drawing/XShape.hpp>
30 #include <com/sun/star/xml/sax/XAttributeList.hpp>
44 using namespace ::
std;
45 using namespace ::
cppu;
126 case ED_from_left:
return AnimationEffect_FADE_FROM_LEFT;
127 case ED_from_top:
return AnimationEffect_FADE_FROM_TOP;
135 case ED_to_center:
return AnimationEffect_FADE_TO_CENTER;
142 default:
return AnimationEffect_FADE_FROM_LEFT;
145 if( nStartScale == 200 )
147 return AnimationEffect_ZOOM_OUT_SMALL;
149 else if( nStartScale == 50 )
151 return AnimationEffect_ZOOM_IN_SMALL;
153 else if( nStartScale < 100 )
157 case ED_from_left:
return AnimationEffect_ZOOM_IN_FROM_LEFT;
158 case ED_from_top:
return AnimationEffect_ZOOM_IN_FROM_TOP;
159 case ED_from_right:
return AnimationEffect_ZOOM_IN_FROM_RIGHT;
167 case ED_to_left:
return AnimationEffect_MOVE_TO_LEFT;
168 case ED_to_top:
return AnimationEffect_MOVE_TO_TOP;
169 case ED_to_right:
return AnimationEffect_MOVE_TO_RIGHT;
170 case ED_to_bottom:
return AnimationEffect_MOVE_TO_BOTTOM;
175 default:
return AnimationEffect_ZOOM_IN;
178 else if( nStartScale > 100 )
182 case ED_from_left:
return AnimationEffect_ZOOM_OUT_FROM_LEFT;
183 case ED_from_top:
return AnimationEffect_ZOOM_OUT_FROM_TOP;
184 case ED_from_right:
return AnimationEffect_ZOOM_OUT_FROM_RIGHT;
192 default:
return AnimationEffect_ZOOM_OUT;
199 case ED_from_left:
return AnimationEffect_MOVE_FROM_LEFT;
200 case ED_from_top:
return AnimationEffect_MOVE_FROM_TOP;
207 case ED_path:
return AnimationEffect_PATH;
208 case ED_to_top:
return AnimationEffect_MOVE_TO_TOP;
209 case ED_to_right:
return AnimationEffect_MOVE_TO_RIGHT;
210 case ED_to_bottom:
return AnimationEffect_MOVE_TO_BOTTOM;
219 return AnimationEffect_MOVE_FROM_LEFT;
222 return AnimationEffect_VERTICAL_STRIPES;
224 return AnimationEffect_HORIZONTAL_STRIPES;
227 return AnimationEffect_OPEN_VERTICAL;
229 return AnimationEffect_OPEN_HORIZONTAL;
232 return AnimationEffect_CLOSE_VERTICAL;
234 return AnimationEffect_CLOSE_HORIZONTAL;
236 return AnimationEffect_DISSOLVE;
240 case ED_from_left:
return AnimationEffect_WAVYLINE_FROM_LEFT;
241 case ED_from_top:
return AnimationEffect_WAVYLINE_FROM_TOP;
242 case ED_from_right:
return AnimationEffect_WAVYLINE_FROM_RIGHT;
244 default:
return AnimationEffect_WAVYLINE_FROM_LEFT;
247 return AnimationEffect_RANDOM;
250 return AnimationEffect_VERTICAL_LINES;
252 return AnimationEffect_HORIZONTAL_LINES;
256 case ED_from_left:
return AnimationEffect_LASER_FROM_LEFT;
257 case ED_from_top:
return AnimationEffect_LASER_FROM_TOP;
264 default:
return AnimationEffect_LASER_FROM_LEFT;
267 return AnimationEffect_APPEAR;
269 return AnimationEffect_HIDE;
273 case ED_from_left:
return AnimationEffect_MOVE_SHORT_FROM_LEFT;
274 case ED_from_top:
return AnimationEffect_MOVE_SHORT_FROM_TOP;
275 case ED_from_right:
return AnimationEffect_MOVE_SHORT_FROM_RIGHT;
276 case ED_from_bottom:
return AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
281 case ED_to_left:
return AnimationEffect_MOVE_SHORT_TO_LEFT;
283 case ED_to_top:
return AnimationEffect_MOVE_SHORT_TO_TOP;
285 case ED_to_right:
return AnimationEffect_MOVE_SHORT_TO_RIGHT;
287 case ED_to_bottom:
return AnimationEffect_MOVE_SHORT_TO_BOTTOM;
289 default:
return AnimationEffect_MOVE_SHORT_FROM_LEFT;
293 return AnimationEffect_VERTICAL_CHECKERBOARD;
295 return AnimationEffect_HORIZONTAL_CHECKERBOARD;
298 return AnimationEffect_VERTICAL_ROTATE;
300 return AnimationEffect_HORIZONTAL_ROTATE;
304 case ED_from_left:
return AnimationEffect_STRETCH_FROM_LEFT;
305 case ED_from_top:
return AnimationEffect_STRETCH_FROM_TOP;
306 case ED_from_right:
return AnimationEffect_STRETCH_FROM_RIGHT;
312 case ED_vertical:
return AnimationEffect_VERTICAL_STRETCH;
313 case ED_horizontal:
return AnimationEffect_HORIZONTAL_STRETCH;
317 return AnimationEffect_STRETCH_FROM_LEFT;
319 return AnimationEffect_NONE;
325 constexpr OUStringLiteral gsDimColor =
u"DimColor";
326 constexpr OUStringLiteral gsDimHide =
u"DimHide";
327 constexpr OUStringLiteral gsDimPrev =
u"DimPrevious";
328 constexpr OUStringLiteral
gsEffect =
u"Effect";
329 constexpr OUStringLiteral
gsPlayFull =
u"PlayFull";
330 constexpr OUStringLiteral gsSound =
u"Sound";
331 constexpr OUStringLiteral gsSoundOn =
u"SoundOn";
332 constexpr OUStringLiteral
gsSpeed =
u"Speed";
333 constexpr OUStringLiteral gsTextEffect =
u"TextEffect";
334 constexpr OUStringLiteral gsPresShapeService =
u"com.sun.star.presentation.Shape";
335 constexpr OUStringLiteral gsAnimPath =
u"AnimationPath";
336 constexpr OUStringLiteral gsIsAnimation =
u"IsAnimation";
360 sal_Int16 mnStartScale;
362 AnimationSpeed meSpeed;
363 sal_Int32 maDimColor;
366 OUString maPathShapeId;
372 const Reference< XFastAttributeList >& xAttrList,
375 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
378 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
385 XMLAnimationsSoundContext(
SvXMLImport& rImport, sal_Int32 nElement,
const Reference< XFastAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent );
390 XMLAnimationsSoundContext::XMLAnimationsSoundContext(
SvXMLImport& rImport, sal_Int32 nElement,
const Reference< XFastAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent )
398 switch( aIter.getToken() )
401 pParent->maSoundURL = rImport.GetAbsoluteReference(aIter.
toString());
412 XMLAnimationsEffectContext::XMLAnimationsEffectContext(
SvXMLImport& rImport,
414 const Reference< XFastAttributeList >& xAttrList,
417 mxAnimationsContext( &rAnimationsContext ),
418 meKind( XMLE_SHOW ), mbTextEffect( false ),
420 meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( false )
452 switch( aIter.getToken() )
458 ::
sax::Converter::convertColor(maDimColor, aIter.
toString());
462 SvXMLUnitConverter::convertEnum( meEffect, aIter.toView(), aXML_AnimationEffect_EnumMap );
465 SvXMLUnitConverter::convertEnum( meDirection, aIter.toView(), aXML_AnimationDirection_EnumMap );
471 mnStartScale =
static_cast<sal_Int16
>(nScale);
475 SvXMLUnitConverter::convertEnum( meSpeed, aIter.toView(), aXML_AnimationSpeed_EnumMap );
486 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLAnimationsEffectContext::createFastChildContext(
488 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
490 return new XMLAnimationsSoundContext( GetImport(), nElement, xAttrList,
this );
493 void XMLAnimationsEffectContext::endFastElement(sal_Int32 )
499 if( !maShapeId.isEmpty() )
502 if( mxAnimationsContext->maLastShapeId != maShapeId )
504 xSet.set( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ), UNO_QUERY );
509 Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY );
510 if( !xServiceInfo.is() || !xServiceInfo->supportsService( gsPresShapeService ) )
514 mxAnimationsContext->maLastShapeId = maShapeId;
515 mxAnimationsContext->mxLastShape = xSet;
520 xSet = mxAnimationsContext->mxLastShape;
525 if( meKind == XMLE_DIM )
527 xSet->setPropertyValue( gsDimPrev,
Any(
true) );
529 xSet->setPropertyValue( gsDimColor,
Any(maDimColor) );
531 else if( meKind == XMLE_PLAY )
533 xSet->setPropertyValue( gsIsAnimation,
Any(
true) );
541 if( meKind == XMLE_HIDE && !mbTextEffect && meEffect ==
EK_none )
543 xSet->setPropertyValue( gsDimHide,
Any(
true) );
547 const AnimationEffect eEffect =
ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW );
550 xSet->setPropertyValue( gsTextEffect,
makeAny( eEffect ) );
555 if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() )
557 Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY );
559 xSet->setPropertyValue( gsAnimPath,
makeAny( xPath ) );
564 if( !maSoundURL.isEmpty() )
568 xSet->setPropertyValue( gsSound,
Any(maSoundURL) );
570 xSet->setPropertyValue( gsSoundOn,
Any(
true) );
574 OSL_FAIL(
"XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!");
579 catch (
const Exception&)
582 "exception caught while importing animation information!");
593 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
595 return new XMLAnimationsEffectContext(
GetImport(), nElement, xAttrList, *
this );
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
SvXMLImport & GetImport()
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[]
XMLAnimationsContext(SvXMLImport &rImport)
constexpr OUStringLiteral gsSpeed(u"Speed")
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr OUStringLiteral gsPlayFull(u"PlayFull")
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
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.
const SvXMLEnumMapEntry< AnimationSpeed > aXML_AnimationSpeed_EnumMap[]
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:
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)
constexpr sal_Int32 TOKEN_MASK
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
AnimationEffect ImplSdXMLgetEffect(XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool)
OUString toString(OptionInfo const *info)
constexpr OUStringLiteral gsEffect(u"Effect")
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)