Files
libreoffice/xmloff/source/draw/animimp.cxx

673 lines
26 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by: Armin Le Grand. #118558# Correcting OLE attributes of LO3.4 at load time by loading as OOo3.3, details see task. http://svn.apache.org/viewvc?view=revision&revision=1195906 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles http://svn.apache.org/viewvc?view=revision&revision=1293316 #119337# Solves the wrong get/setPropertyValue calls in SvxShapeText (and thus in SvxOle2Shape) http://svn.apache.org/viewvc?view=revision&revision=1344156 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117717#: remove wrong assertion http://svn.apache.org/viewvc?view=revision&revision=1172349 Patch contributed by Herbert Duerr goodbye Registration and License dialogs, don't let the door hit you http://svn.apache.org/viewvc?view=revision&revision=1172613 help gcc 4.6.0 on 32bit ubuntu 11.10" http://svn.apache.org/viewvc?view=revision&revision=1245357 Do not add targets for junit tests when junit is disabled. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1241508 Revert "sb140: #i117082# avoid unncessary static class data members commit 21d97438e2944861e26e4984195f959a0cce1e41. remove obsolete FreeBSD visibility special case. retain consolidated BSD bridge code, remove OS/2 pieces.
2012-11-12 17:21:24 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-12-19 15:23:48 +00:00
#include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
2000-12-19 15:23:48 +00:00
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/presentation/AnimationEffect.hpp>
#include <com/sun/star/presentation/AnimationSpeed.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <sax/tools/converter.hxx>
2001-02-01 15:29:47 +00:00
#include <list>
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlimp.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmluconv.hxx>
#include <xmloff/nmspmap.hxx>
2000-12-19 15:23:48 +00:00
#include "anim.hxx"
#include "animimp.hxx"
using namespace ::std;
using namespace ::cppu;
using namespace ::com::sun::star;
using namespace ::com::sun::star::xml;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::presentation;
using namespace ::xmloff::token;
2000-12-19 15:23:48 +00:00
SvXMLEnumMapEntry aXML_AnimationEffect_EnumMap[] =
{
{ XML_NONE, EK_none },
{ XML_FADE, EK_fade },
{ XML_MOVE, EK_move },
{ XML_STRIPES, EK_stripes },
{ XML_OPEN, EK_open },
{ XML_CLOSE, EK_close },
{ XML_DISSOLVE, EK_dissolve },
{ XML_WAVYLINE, EK_wavyline },
{ XML_RANDOM, EK_random },
{ XML_LINES, EK_lines },
{ XML_LASER, EK_laser },
{ XML_APPEAR, EK_appear },
{ XML_HIDE, EK_hide },
{ XML_MOVE_SHORT, EK_move_short },
{ XML_CHECKERBOARD, EK_checkerboard },
{ XML_ROTATE, EK_rotate },
{ XML_STRETCH, EK_stretch },
{ XML_TOKEN_INVALID, 0 }
};
SvXMLEnumMapEntry aXML_AnimationDirection_EnumMap[] =
{
{ XML_NONE, ED_none },
{ XML_FROM_LEFT, ED_from_left },
{ XML_FROM_TOP, ED_from_top },
{ XML_FROM_RIGHT, ED_from_right },
{ XML_FROM_BOTTOM, ED_from_bottom },
{ XML_FROM_CENTER, ED_from_center },
{ XML_FROM_UPPER_LEFT, ED_from_upperleft },
{ XML_FROM_UPPER_RIGHT, ED_from_upperright },
{ XML_FROM_LOWER_LEFT, ED_from_lowerleft },
{ XML_FROM_LOWER_RIGHT, ED_from_lowerright },
{ XML_TO_LEFT, ED_to_left },
{ XML_TO_TOP, ED_to_top },
{ XML_TO_RIGHT, ED_to_right },
{ XML_TO_BOTTOM, ED_to_bottom },
{ XML_TO_UPPER_LEFT, ED_to_upperleft },
{ XML_TO_UPPER_RIGHT, ED_to_upperright },
{ XML_TO_LOWER_RIGHT, ED_to_lowerright },
{ XML_TO_LOWER_LEFT, ED_to_lowerleft },
{ XML_PATH, ED_path },
{ XML_SPIRAL_INWARD_LEFT, ED_spiral_inward_left },
{ XML_SPIRAL_INWARD_RIGHT,ED_spiral_inward_right },
{ XML_SPIRAL_OUTWARD_LEFT, ED_spiral_outward_left },
{ XML_SPIRAL_OUTWARD_RIGHT, ED_spiral_outward_right },
{ XML_VERTICAL, ED_vertical },
{ XML_HORIZONTAL, ED_horizontal },
{ XML_TO_CENTER, ED_to_center },
{ XML_CLOCKWISE, ED_clockwise },
{ XML_COUNTER_CLOCKWISE,ED_cclockwise },
{ XML_TOKEN_INVALID, 0 }
};
SvXMLEnumMapEntry aXML_AnimationSpeed_EnumMap[] =
{
{ XML_SLOW, AnimationSpeed_SLOW },
{ XML_MEDIUM, AnimationSpeed_MEDIUM },
{ XML_FAST, AnimationSpeed_FAST },
{ XML_TOKEN_INVALID, 0 }
};
AnimationEffect ImplSdXMLgetEffect( XMLEffect eKind, XMLEffectDirection eDirection, sal_Int16 nStartScale, bool /*bIn*/ )
2000-12-19 15:23:48 +00:00
{
2001-02-07 15:26:36 +00:00
switch( eKind )
2000-12-19 15:23:48 +00:00
{
2001-02-07 15:26:36 +00:00
case EK_fade:
switch( eDirection )
2000-12-19 15:23:48 +00:00
{
2001-02-07 15:26:36 +00:00
case ED_from_left: return AnimationEffect_FADE_FROM_LEFT;
case ED_from_top: return AnimationEffect_FADE_FROM_TOP;
case ED_from_right: return AnimationEffect_FADE_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_FADE_FROM_BOTTOM;
case ED_from_center: return AnimationEffect_FADE_FROM_CENTER;
case ED_from_upperleft: return AnimationEffect_FADE_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_FADE_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_FADE_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_FADE_FROM_LOWERRIGHT;
case ED_to_center: return AnimationEffect_FADE_TO_CENTER;
case ED_clockwise: return AnimationEffect_CLOCKWISE;
case ED_cclockwise: return AnimationEffect_COUNTERCLOCKWISE;
case ED_spiral_inward_left: return AnimationEffect_SPIRALIN_LEFT;
case ED_spiral_inward_right:return AnimationEffect_SPIRALIN_RIGHT;
case ED_spiral_outward_left:return AnimationEffect_SPIRALOUT_LEFT;
case ED_spiral_outward_right:return AnimationEffect_SPIRALOUT_RIGHT;
default: return AnimationEffect_FADE_FROM_LEFT;
2000-12-19 15:23:48 +00:00
}
2001-02-07 15:26:36 +00:00
case EK_move:
if( nStartScale == 200 )
{
return AnimationEffect_ZOOM_OUT_SMALL;
}
else if( nStartScale == 50 )
{
return AnimationEffect_ZOOM_IN_SMALL;
}
else if( nStartScale < 100 )
2000-12-19 15:23:48 +00:00
{
switch( eDirection )
{
2001-02-07 15:26:36 +00:00
case ED_from_left: return AnimationEffect_ZOOM_IN_FROM_LEFT;
case ED_from_top: return AnimationEffect_ZOOM_IN_FROM_TOP;
case ED_from_right: return AnimationEffect_ZOOM_IN_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_ZOOM_IN_FROM_BOTTOM;
case ED_from_upperleft: return AnimationEffect_ZOOM_IN_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_ZOOM_IN_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_ZOOM_IN_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_ZOOM_IN_FROM_LOWERRIGHT;
case ED_from_center: return AnimationEffect_ZOOM_IN_FROM_CENTER;
case ED_spiral_inward_left: return AnimationEffect_ZOOM_IN_SPIRAL;
2000-12-19 15:23:48 +00:00
case ED_to_left: return AnimationEffect_MOVE_TO_LEFT;
case ED_to_top: return AnimationEffect_MOVE_TO_TOP;
case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT;
case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM;
case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT;
case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT;
case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT;
case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT;
default: return AnimationEffect_ZOOM_IN;
2000-12-19 15:23:48 +00:00
}
2001-02-07 15:26:36 +00:00
}
else if( nStartScale > 100 )
{
switch( eDirection )
{
case ED_from_left: return AnimationEffect_ZOOM_OUT_FROM_LEFT;
case ED_from_top: return AnimationEffect_ZOOM_OUT_FROM_TOP;
case ED_from_right: return AnimationEffect_ZOOM_OUT_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_ZOOM_OUT_FROM_BOTTOM;
case ED_from_upperleft: return AnimationEffect_ZOOM_OUT_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_ZOOM_OUT_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_ZOOM_OUT_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_ZOOM_OUT_FROM_LOWERRIGHT;
case ED_from_center: return AnimationEffect_ZOOM_OUT_FROM_CENTER;
case ED_spiral_inward_left: return AnimationEffect_ZOOM_OUT_SPIRAL;
default: return AnimationEffect_ZOOM_OUT;
2001-02-07 15:26:36 +00:00
}
}
else
{
2000-12-19 15:23:48 +00:00
switch( eDirection )
{
2001-02-07 15:26:36 +00:00
case ED_from_left: return AnimationEffect_MOVE_FROM_LEFT;
case ED_from_top: return AnimationEffect_MOVE_FROM_TOP;
case ED_from_right: return AnimationEffect_MOVE_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_MOVE_FROM_BOTTOM;
case ED_from_upperleft: return AnimationEffect_MOVE_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_MOVE_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_MOVE_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_MOVE_FROM_LOWERRIGHT;
case ED_path: return AnimationEffect_PATH;
2001-05-23 07:56:35 +00:00
case ED_to_top: return AnimationEffect_MOVE_TO_TOP;
case ED_to_right: return AnimationEffect_MOVE_TO_RIGHT;
case ED_to_bottom: return AnimationEffect_MOVE_TO_BOTTOM;
case ED_to_upperleft: return AnimationEffect_MOVE_TO_UPPERLEFT;
case ED_to_upperright: return AnimationEffect_MOVE_TO_UPPERRIGHT;
case ED_to_lowerright: return AnimationEffect_MOVE_TO_LOWERRIGHT;
case ED_to_lowerleft: return AnimationEffect_MOVE_TO_LOWERLEFT;
default:
break;
2000-12-19 15:23:48 +00:00
}
}
2001-02-07 15:26:36 +00:00
return AnimationEffect_MOVE_FROM_LEFT;
case EK_stripes:
if( eDirection == ED_vertical )
return AnimationEffect_VERTICAL_STRIPES;
else
return AnimationEffect_HORIZONTAL_STRIPES;
case EK_open:
if( eDirection == ED_vertical )
return AnimationEffect_OPEN_VERTICAL;
else
return AnimationEffect_OPEN_HORIZONTAL;
case EK_close:
if( eDirection == ED_vertical )
return AnimationEffect_CLOSE_VERTICAL;
else
return AnimationEffect_CLOSE_HORIZONTAL;
case EK_dissolve:
return AnimationEffect_DISSOLVE;
case EK_wavyline:
switch( eDirection )
{
case ED_from_left: return AnimationEffect_WAVYLINE_FROM_LEFT;
case ED_from_top: return AnimationEffect_WAVYLINE_FROM_TOP;
case ED_from_right: return AnimationEffect_WAVYLINE_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_WAVYLINE_FROM_BOTTOM;
default: return AnimationEffect_WAVYLINE_FROM_LEFT;
2001-02-07 15:26:36 +00:00
}
case EK_random:
return AnimationEffect_RANDOM;
case EK_lines:
if( eDirection == ED_vertical )
return AnimationEffect_VERTICAL_LINES;
else
return AnimationEffect_HORIZONTAL_LINES;
case EK_laser:
switch( eDirection )
{
case ED_from_left: return AnimationEffect_LASER_FROM_LEFT;
case ED_from_top: return AnimationEffect_LASER_FROM_TOP;
case ED_from_right: return AnimationEffect_LASER_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_LASER_FROM_BOTTOM;
case ED_from_upperleft: return AnimationEffect_LASER_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_LASER_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_LASER_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_LASER_FROM_LOWERRIGHT;
default: return AnimationEffect_LASER_FROM_LEFT;
2001-02-07 15:26:36 +00:00
}
case EK_appear:
return AnimationEffect_APPEAR;
case EK_hide:
return AnimationEffect_HIDE;
case EK_move_short:
switch( eDirection )
{
case ED_from_left: return AnimationEffect_MOVE_SHORT_FROM_LEFT;
case ED_from_top: return AnimationEffect_MOVE_SHORT_FROM_TOP;
case ED_from_right: return AnimationEffect_MOVE_SHORT_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_MOVE_SHORT_FROM_BOTTOM;
case ED_from_upperleft: return AnimationEffect_MOVE_SHORT_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_MOVE_SHORT_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_MOVE_SHORT_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_MOVE_SHORT_FROM_LOWERRIGHT;
2001-02-07 15:26:36 +00:00
case ED_to_left: return AnimationEffect_MOVE_SHORT_TO_LEFT;
case ED_to_upperleft: return AnimationEffect_MOVE_SHORT_TO_UPPERLEFT;
case ED_to_top: return AnimationEffect_MOVE_SHORT_TO_TOP;
case ED_to_upperright: return AnimationEffect_MOVE_SHORT_TO_UPPERRIGHT;
case ED_to_right: return AnimationEffect_MOVE_SHORT_TO_RIGHT;
case ED_to_lowerright: return AnimationEffect_MOVE_SHORT_TO_LOWERRIGHT;
case ED_to_bottom: return AnimationEffect_MOVE_SHORT_TO_BOTTOM;
case ED_to_lowerleft: return AnimationEffect_MOVE_SHORT_TO_LOWERLEFT;
default: return AnimationEffect_MOVE_SHORT_FROM_LEFT;
2001-02-07 15:26:36 +00:00
}
case EK_checkerboard:
if( eDirection == ED_vertical )
return AnimationEffect_VERTICAL_CHECKERBOARD;
else
return AnimationEffect_HORIZONTAL_CHECKERBOARD;
case EK_rotate:
if( eDirection == ED_vertical )
return AnimationEffect_VERTICAL_ROTATE;
else
return AnimationEffect_HORIZONTAL_ROTATE;
case EK_stretch:
switch( eDirection )
{
case ED_from_left: return AnimationEffect_STRETCH_FROM_LEFT;
case ED_from_top: return AnimationEffect_STRETCH_FROM_TOP;
case ED_from_right: return AnimationEffect_STRETCH_FROM_RIGHT;
case ED_from_bottom: return AnimationEffect_STRETCH_FROM_BOTTOM;
case ED_from_upperleft: return AnimationEffect_STRETCH_FROM_UPPERLEFT;
case ED_from_upperright: return AnimationEffect_STRETCH_FROM_UPPERRIGHT;
case ED_from_lowerleft: return AnimationEffect_STRETCH_FROM_LOWERLEFT;
case ED_from_lowerright: return AnimationEffect_STRETCH_FROM_LOWERRIGHT;
case ED_vertical: return AnimationEffect_VERTICAL_STRETCH;
case ED_horizontal: return AnimationEffect_HORIZONTAL_STRETCH;
default:
break;
2001-02-07 15:26:36 +00:00
}
return AnimationEffect_STRETCH_FROM_LEFT;
default:
return AnimationEffect_NONE;
2000-12-19 15:23:48 +00:00
}
}
class AnimImpImpl
{
public:
Reference< XPropertySet > mxLastShape;
OUString maLastShapeId;
2000-12-19 15:23:48 +00:00
OUString msDimColor;
OUString msDimHide;
OUString msDimPrev;
OUString msEffect;
OUString msPlayFull;
OUString msPresOrder;
OUString msSound;
OUString msSoundOn;
OUString msSpeed;
OUString msTextEffect;
OUString msPresShapeService;
OUString msAnimPath;
OUString msIsAnimation;
2000-12-19 15:23:48 +00:00
AnimImpImpl()
: msDimColor( "DimColor" ),
msDimHide( "DimHide" ),
msDimPrev( "DimPrevious" ),
msEffect( "Effect" ),
msPlayFull( "PlayFull" ),
msPresOrder( "PresentationOrder" ),
msSound( "Sound" ),
msSoundOn( "SoundOn" ),
msSpeed( "Speed" ),
msTextEffect( "TextEffect" ),
msPresShapeService( "com.sun.star.presentation.Shape" ),
msAnimPath( "AnimationPath" ),
msIsAnimation( "IsAnimation" )
2000-12-19 15:23:48 +00:00
{}
};
enum XMLActionKind
{
XMLE_SHOW,
XMLE_HIDE,
XMLE_DIM,
XMLE_PLAY
2000-12-19 15:23:48 +00:00
};
class XMLAnimationsEffectContext : public SvXMLImportContext
{
public:
AnimImpImpl* mpImpl;
XMLActionKind meKind;
bool mbTextEffect;
OUString maShapeId;
2000-12-19 15:23:48 +00:00
XMLEffect meEffect;
XMLEffectDirection meDirection;
sal_Int16 mnStartScale;
AnimationSpeed meSpeed;
sal_Int32 maDimColor;
2000-12-19 15:23:48 +00:00
OUString maSoundURL;
bool mbPlayFull;
OUString maPathShapeId;
2000-12-19 15:23:48 +00:00
public:
TYPEINFO_OVERRIDE();
2000-12-19 15:23:48 +00:00
XMLAnimationsEffectContext( SvXMLImport& rImport,
sal_uInt16 nPrfx,
const OUString& rLocalName,
const Reference< XAttributeList >& xAttrList,
AnimImpImpl* pImpl);
virtual ~XMLAnimationsEffectContext();
virtual void EndElement() SAL_OVERRIDE;
2000-12-19 15:23:48 +00:00
virtual SvXMLImportContext * CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
const Reference< XAttributeList >& xAttrList ) SAL_OVERRIDE;
2000-12-19 15:23:48 +00:00
};
class XMLAnimationsSoundContext : public SvXMLImportContext
{
XMLAnimationsEffectContext* mpParent;
public:
TYPEINFO_OVERRIDE();
2000-12-19 15:23:48 +00:00
XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent );
virtual ~XMLAnimationsSoundContext();
};
TYPEINIT1( XMLAnimationsSoundContext, SvXMLImportContext );
XMLAnimationsSoundContext::XMLAnimationsSoundContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, XMLAnimationsEffectContext* pParent )
: SvXMLImportContext( rImport, nPrfx, rLocalName ), mpParent( pParent )
{
if( mpParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND ) )
2000-12-19 15:23:48 +00:00
{
const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 i=0; i < nAttrCount; i++)
{
OUString sAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
OUString sValue = xAttrList->getValueByIndex( i );
switch( nPrefix )
{
case XML_NAMESPACE_XLINK:
if( IsXMLToken( aLocalName, XML_HREF ) )
2000-12-19 15:23:48 +00:00
{
2001-06-27 13:02:50 +00:00
mpParent->maSoundURL = rImport.GetAbsoluteReference(sValue);
2000-12-19 15:23:48 +00:00
}
break;
case XML_NAMESPACE_PRESENTATION:
if( IsXMLToken( aLocalName, XML_PLAY_FULL ) )
2000-12-19 15:23:48 +00:00
{
mpParent->mbPlayFull = IsXMLToken( sValue, XML_TRUE );
2000-12-19 15:23:48 +00:00
}
}
}
}
}
XMLAnimationsSoundContext::~XMLAnimationsSoundContext()
{
}
TYPEINIT1( XMLAnimationsEffectContext, SvXMLImportContext );
XMLAnimationsEffectContext::XMLAnimationsEffectContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, AnimImpImpl* pImpl )
: SvXMLImportContext(rImport, nPrfx, rLocalName),
mpImpl( pImpl ),
meKind( XMLE_SHOW ), mbTextEffect( false ),
2000-12-19 15:23:48 +00:00
meEffect( EK_none ), meDirection( ED_none ), mnStartScale( 100 ),
meSpeed( AnimationSpeed_MEDIUM ), maDimColor(0), mbPlayFull( false )
2000-12-19 15:23:48 +00:00
{
if( IsXMLToken( rLocalName, XML_SHOW_SHAPE ) )
2000-12-19 15:23:48 +00:00
{
meKind = XMLE_SHOW;
}
else if( IsXMLToken( rLocalName, XML_SHOW_TEXT ) )
2000-12-19 15:23:48 +00:00
{
meKind = XMLE_SHOW;
mbTextEffect = true;
2000-12-19 15:23:48 +00:00
}
else if( IsXMLToken( rLocalName, XML_HIDE_SHAPE ) )
2000-12-19 15:23:48 +00:00
{
meKind = XMLE_HIDE;
}
else if( IsXMLToken( rLocalName, XML_HIDE_TEXT ) )
2000-12-19 15:23:48 +00:00
{
meKind = XMLE_HIDE;
mbTextEffect = true;
2000-12-19 15:23:48 +00:00
}
else if( IsXMLToken( rLocalName, XML_DIM ) )
2000-12-19 15:23:48 +00:00
{
meKind = XMLE_DIM;
}
else if( IsXMLToken( rLocalName, XML_PLAY ) )
{
meKind = XMLE_PLAY;
}
2000-12-19 15:23:48 +00:00
else
{
// unknown action, overread
return;
}
// read attributes
const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 i=0; i < nAttrCount; i++)
{
OUString sAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
OUString sValue = xAttrList->getValueByIndex( i );
switch( nPrefix )
{
case XML_NAMESPACE_DRAW:
if( IsXMLToken( aLocalName, XML_SHAPE_ID ) )
2000-12-19 15:23:48 +00:00
{
maShapeId = sValue;
2000-12-19 15:23:48 +00:00
}
else if( IsXMLToken( aLocalName, XML_COLOR ) )
2000-12-19 15:23:48 +00:00
{
::sax::Converter::convertColor(maDimColor, sValue);
2000-12-19 15:23:48 +00:00
}
break;
case XML_NAMESPACE_PRESENTATION:
if( IsXMLToken( aLocalName, XML_EFFECT ) )
2000-12-19 15:23:48 +00:00
{
sal_uInt16 eEnum;
2000-12-19 15:23:48 +00:00
if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationEffect_EnumMap ) )
meEffect = (XMLEffect)eEnum;
}
else if( IsXMLToken(aLocalName, XML_DIRECTION ) )
2000-12-19 15:23:48 +00:00
{
sal_uInt16 eEnum;
2000-12-19 15:23:48 +00:00
if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationDirection_EnumMap ) )
meDirection = (XMLEffectDirection)eEnum;
}
else if( IsXMLToken( aLocalName, XML_START_SCALE ) )
2000-12-19 15:23:48 +00:00
{
sal_Int32 nScale;
if (::sax::Converter::convertPercent( nScale, sValue ))
2000-12-19 15:23:48 +00:00
mnStartScale = (sal_Int16)nScale;
}
else if( IsXMLToken( aLocalName, XML_SPEED ) )
2000-12-19 15:23:48 +00:00
{
sal_uInt16 eEnum;
2000-12-19 15:23:48 +00:00
if( SvXMLUnitConverter::convertEnum( eEnum, sValue, aXML_AnimationSpeed_EnumMap ) )
meSpeed = (AnimationSpeed)eEnum;
}
else if( IsXMLToken( aLocalName, XML_PATH_ID ) )
2000-12-19 15:23:48 +00:00
{
maPathShapeId = sValue;
2000-12-19 15:23:48 +00:00
}
break;
}
}
}
XMLAnimationsEffectContext::~XMLAnimationsEffectContext()
{
}
SvXMLImportContext * XMLAnimationsEffectContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList>& xAttrList )
2000-12-19 15:23:48 +00:00
{
return new XMLAnimationsSoundContext( GetImport(), nPrefix, rLocalName, xAttrList, this );
}
void XMLAnimationsEffectContext::EndElement()
{
// set effect on shape
try
{
rtl::Reference< XMLShapeImportHelper > xShapeImport( GetImport().GetShapeImport() );
2000-12-19 15:23:48 +00:00
Any aAny;
if( !maShapeId.isEmpty() )
2000-12-19 15:23:48 +00:00
{
Reference< XPropertySet > xSet;
if( mpImpl->maLastShapeId != maShapeId )
2000-12-19 15:23:48 +00:00
{
xSet = Reference< XPropertySet >::query( GetImport().getInterfaceToIdentifierMapper().getReference( maShapeId ) );
2000-12-19 15:23:48 +00:00
if( xSet.is() )
{
// check for presentation shape service
{
Reference< XServiceInfo > xServiceInfo( xSet, UNO_QUERY );
if( !xServiceInfo.is() || !xServiceInfo->supportsService( mpImpl->msPresShapeService ) )
return;
}
mpImpl->maLastShapeId = maShapeId;
2000-12-19 15:23:48 +00:00
mpImpl->mxLastShape = xSet;
}
}
else
{
xSet = mpImpl->mxLastShape;
}
if( xSet.is() )
{
if( meKind == XMLE_DIM )
{
aAny <<= true;
2000-12-19 15:23:48 +00:00
xSet->setPropertyValue( mpImpl->msDimPrev, aAny );
aAny <<= maDimColor;
2000-12-19 15:23:48 +00:00
xSet->setPropertyValue( mpImpl->msDimColor, aAny );
}
else if( meKind == XMLE_PLAY )
{
aAny <<= true;
xSet->setPropertyValue( mpImpl->msIsAnimation, aAny );
// #i42894# speed is not supported for the old group animation fallback, so no need to set it
// aAny <<= meSpeed;
// xSet->setPropertyValue( mpImpl->msSpeed, aAny );
}
2000-12-19 15:23:48 +00:00
else
{
if( meKind == XMLE_HIDE && !mbTextEffect && meEffect == EK_none )
{
aAny <<= true;
2000-12-19 15:23:48 +00:00
xSet->setPropertyValue( mpImpl->msDimHide, aAny );
}
else
{
2001-02-07 15:26:36 +00:00
const AnimationEffect eEffect = ImplSdXMLgetEffect( meEffect, meDirection, mnStartScale, meKind == XMLE_SHOW );
2000-12-19 15:23:48 +00:00
xSet->setPropertyValue( mbTextEffect ? mpImpl->msTextEffect : mpImpl->msEffect, makeAny( eEffect ) );
xSet->setPropertyValue( mpImpl->msSpeed, makeAny( meSpeed ) );
2000-12-19 15:23:48 +00:00
if( eEffect == AnimationEffect_PATH && !maPathShapeId.isEmpty() )
2000-12-19 15:23:48 +00:00
{
Reference< XShape > xPath( GetImport().getInterfaceToIdentifierMapper().getReference( maPathShapeId ), UNO_QUERY );
2000-12-19 15:23:48 +00:00
if( xPath.is() )
xSet->setPropertyValue( mpImpl->msAnimPath, makeAny( xPath ) );
2000-12-19 15:23:48 +00:00
}
}
}
}
if( !maSoundURL.isEmpty() )
2000-12-19 15:23:48 +00:00
{
if( xSet.is() )
{
aAny <<= maSoundURL;
xSet->setPropertyValue( mpImpl->msSound, aAny );
2000-12-19 15:23:48 +00:00
aAny <<= mbPlayFull;
xSet->setPropertyValue( mpImpl->msPlayFull, aAny );
2000-12-19 15:23:48 +00:00
aAny <<= true;
xSet->setPropertyValue( mpImpl->msSoundOn, aAny );
}
else
{
2011-03-01 19:07:44 +01:00
OSL_FAIL("XMLAnimationsEffectContext::EndElement - Sound URL without a XPropertySet!");
}
2000-12-19 15:23:48 +00:00
}
}
}
2012-02-13 13:26:31 +00:00
catch (const Exception&)
2000-12-19 15:23:48 +00:00
{
2012-02-13 13:26:31 +00:00
OSL_FAIL( "exception caught while importing animation information!" );
2000-12-19 15:23:48 +00:00
}
}
TYPEINIT1( XMLAnimationsContext, SvXMLImportContext );
XMLAnimationsContext::XMLAnimationsContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& )
2000-12-19 15:23:48 +00:00
: SvXMLImportContext(rImport, nPrfx, rLocalName)
{
mpImpl = new AnimImpImpl();
}
XMLAnimationsContext::~XMLAnimationsContext()
{
delete mpImpl;
}
SvXMLImportContext * XMLAnimationsContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
2000-12-19 15:23:48 +00:00
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
{
return new XMLAnimationsEffectContext( GetImport(), nPrefix, rLocalName, xAttrList, mpImpl );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */