diff options
Diffstat (limited to 'oox/source/ppt')
41 files changed, 7694 insertions, 0 deletions
diff --git a/oox/source/ppt/animationspersist.cxx b/oox/source/ppt/animationspersist.cxx new file mode 100644 index 000000000000..fdee865251af --- /dev/null +++ b/oox/source/ppt/animationspersist.cxx @@ -0,0 +1,198 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/animationspersist.hxx" + +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/presentation/ParagraphTarget.hpp> +#include <com/sun/star/presentation/ShapeAnimationSubType.hpp> + +#include "oox/drawingml/shape.hxx" + +using rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::text; + +namespace oox { namespace ppt { + + void ShapeTargetElement::convert( ::com::sun::star::uno::Any & rTarget, sal_Int16 & rSubType ) const + { + switch(mnType) + { + case XML_subSp: + rSubType = ShapeAnimationSubType::AS_WHOLE; + break; + case XML_bg: + rSubType = ShapeAnimationSubType::ONLY_BACKGROUND; + break; + case XML_txEl: + { + ParagraphTarget aParaTarget; + Reference< XShape > xShape; + rTarget >>= xShape; + aParaTarget.Shape = xShape; + rSubType = ShapeAnimationSubType::ONLY_TEXT; + + Reference< XText > xText( xShape, UNO_QUERY ); + if( xText.is() ) + { + switch(mnRangeType) + { + case XML_charRg: + // TODO calculate the corresponding paragraph for the text range.... + OSL_TRACE( "OOX: TODO calculate the corresponding paragraph for the text range..." ); + break; + case XML_pRg: + aParaTarget.Paragraph = static_cast< sal_Int16 >( maRange.start ); + // TODO what to do with more than one. + OSL_TRACE( "OOX: TODO what to do with more than one" ); + break; + } + rTarget = makeAny( aParaTarget ); + } + break; + } + default: + break; + } + } + + + Any AnimTargetElement::convert(const SlidePersistPtr & pSlide, sal_Int16 & nSubType) const + { + Any aTarget; + // see sd/source/files/ppt/pptinanimations.cxx:3191 (in importTargetElementContainer()) + switch(mnType) + { + case XML_inkTgt: + // TODO + OSL_TRACE( "OOX: TODO inkTgt" ); + break; + case XML_sldTgt: + // TODO + OSL_TRACE( "OOX: TODO sldTgt" ); + break; + case XML_sndTgt: + aTarget = makeAny(msValue); + break; + case XML_spTgt: + { + Any rTarget; + ::oox::drawingml::ShapePtr pShape = pSlide->getShape(msValue); + OSL_ENSURE( pShape, "failed to locate Shape"); + if( pShape ) + { + Reference< XShape > xShape( pShape->getXShape() ); + OSL_ENSURE( xShape.is(), "fail to get XShape from shape" ); + if( xShape.is() ) + { + rTarget <<= xShape; + maShapeTarget.convert(rTarget, nSubType); + aTarget = rTarget; + } + } + break; + } + default: + break; + } + return aTarget; + } + + +// BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.cxx +/** this adds an any to another any. + if rNewValue is empty, rOldValue is returned. + if rOldValue is empty, rNewValue is returned. + if rOldValue contains a value, a sequence with rOldValue and rNewValue is returned. + if rOldValue contains a sequence, a new sequence with the old sequence and rNewValue is returned. +*/ + static Any addToSequence( const Any& rOldValue, const Any& rNewValue ) + { + if( !rNewValue.hasValue() ) + { + return rOldValue; + } + else if( !rOldValue.hasValue() ) + { + return rNewValue; + } + else + { + Sequence< Any > aNewSeq; + if( rOldValue >>= aNewSeq ) + { + sal_Int32 nSize = aNewSeq.getLength(); + aNewSeq.realloc(nSize+1); + aNewSeq[nSize] = rNewValue; + } + else + { + aNewSeq.realloc(2); + aNewSeq[0] = rOldValue; + aNewSeq[1] = rNewValue; + } + return makeAny( aNewSeq ); + } + } +// END + + Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const + { + Any aAny; + if( mpTarget ) + { + sal_Int16 nSubType; + aAny = mpTarget->convert( pSlide, nSubType ); + } + else + { + aAny = maValue; + } + return aAny; + } + + + Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l) + { + Any aAny; + for( AnimationConditionList::const_iterator iter = l.begin(); + iter != l.end(); iter++) + { + aAny = addToSequence( aAny, iter->convert(pSlide) ); + } + return aAny; + } + +} } + + diff --git a/oox/source/ppt/animationtypes.cxx b/oox/source/ppt/animationtypes.cxx new file mode 100644 index 000000000000..6346a8058c5d --- /dev/null +++ b/oox/source/ppt/animationtypes.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "animationtypes.hxx" + +#include <com/sun/star/animations/Timing.hpp> + +#include "oox/helper/attributelist.hxx" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +// ST_TLTime +Any GetTime( const ::rtl::OUString & val ) +{ + Any aDuration; + if( val.compareToAscii( "indefinite" ) == 0 ) + { + aDuration <<= Timing_INDEFINITE; + } + else + { + aDuration <<= val.toFloat() / 1000.0; + } + return aDuration; +} + + +// ST_TLTimeAnimateValueTime +Any GetTimeAnimateValueTime( const ::rtl::OUString & val ) +{ + Any aPercent; + if( val.compareToAscii( "indefinite" ) == 0 ) + { + aPercent <<= Timing_INDEFINITE; + } + else + { + aPercent <<= val.toFloat() / 100000.0; + } + return aPercent; +} + +} } diff --git a/oox/source/ppt/animationtypes.hxx b/oox/source/ppt/animationtypes.hxx new file mode 100644 index 000000000000..a2c57b53267f --- /dev/null +++ b/oox/source/ppt/animationtypes.hxx @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifndef OOX_POWERPOINT_ANIMATIONTYPES_HXX +#define OOX_POWERPOINT_ANIMATIONTYPES_HXX + + +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/xml/sax/XFastAttributeList.hpp> + + +namespace oox { namespace ppt { + +// ST_TLTime +::com::sun::star::uno::Any GetTime( const ::rtl::OUString & val ); +// ST_TLTimeAnimateValueTime +::com::sun::star::uno::Any GetTimeAnimateValueTime( const ::rtl::OUString & val ); + +} } + +#endif diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx new file mode 100644 index 000000000000..449c4ef73d11 --- /dev/null +++ b/oox/source/ppt/animvariantcontext.cxx @@ -0,0 +1,122 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "animvariantcontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include <osl/diagnose.h> + +#include <com/sun/star/uno/Any.hxx> +#include <rtl/ustring.hxx> + +#include "oox/helper/attributelist.hxx" +#include "oox/core/fragmenthandler.hxx" +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/colorchoicecontext.hxx" +#include "pptfilterhelpers.hxx" + +using ::rtl::OUString; +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + + AnimVariantContext::AnimVariantContext( ContextHandler& rParent, sal_Int32 aElement, Any & aValue ) + : ContextHandler( rParent ) + , mnElement( aElement ) + , maValue( aValue ) + { + } + + AnimVariantContext::~AnimVariantContext( ) throw( ) + { + } + + void SAL_CALL AnimVariantContext::endFastElement( sal_Int32 aElement ) + throw ( SAXException, RuntimeException) + { + if( ( aElement == mnElement ) && maColor.isUsed() ) + { + maValue = makeAny( maColor.getColor( getFilter().getGraphicHelper() ) ); + } + } + + + Reference< XFastContextHandler > + SAL_CALL AnimVariantContext::createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + AttributeList attribs(xAttribs); + + switch( aElementToken ) + { + case PPT_TOKEN( boolVal ): + { + bool val = attribs.getBool( XML_val, false ); + maValue = makeAny( val ); + break; + } + case PPT_TOKEN( clrVal ): + xRet.set( new ::oox::drawingml::ColorContext( *this, maColor ) ); + // we'll defer setting the Any until the end. + break; + case PPT_TOKEN( fltVal ): + { + double val = attribs.getDouble( XML_val, 0.0 ); + maValue = makeAny( val ); + break; + } + case PPT_TOKEN( intVal ): + { + sal_Int32 val = attribs.getInteger( XML_val, 0 ); + maValue = makeAny( val ); + break; + } + case PPT_TOKEN( strVal ): + { + OUString val = attribs.getString( XML_val, OUString() ); + convertMeasure( val ); // ignore success or failure if it fails, use as is + maValue = makeAny( val ); + break; + } + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + + +} } diff --git a/oox/source/ppt/animvariantcontext.hxx b/oox/source/ppt/animvariantcontext.hxx new file mode 100644 index 000000000000..48fff797744f --- /dev/null +++ b/oox/source/ppt/animvariantcontext.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifndef OOX_PPT_ANIMVARIANTCONTEXT +#define OOX_PPT_ANIMVERIANTCONTEXT + + +#include <com/sun/star/uno/Any.hxx> + +#include "oox/core/contexthandler.hxx" +#include "oox/drawingml/color.hxx" + +namespace oox { namespace ppt { + + /** context CT_TLAnimVariant */ + class AnimVariantContext + : public ::oox::core::ContextHandler + { + public: + AnimVariantContext( ::oox::core::ContextHandler& rParent, ::sal_Int32 aElement, ::com::sun::star::uno::Any & aValue ); + ~AnimVariantContext( ) throw( ); + virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: + ::sal_Int32 mnElement; + ::com::sun::star::uno::Any& maValue; + ::oox::drawingml::Color maColor; + }; + +} } + + +#endif diff --git a/oox/source/ppt/backgroundproperties.cxx b/oox/source/ppt/backgroundproperties.cxx new file mode 100644 index 000000000000..65664bdd3691 --- /dev/null +++ b/oox/source/ppt/backgroundproperties.cxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/backgroundproperties.hxx" +#include "oox/drawingml/fillpropertiesgroupcontext.hxx" +#include "oox/drawingml/drawingmltypes.hxx" + +using ::rtl::OUString; +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { +// --------------------------------------------------------------------- + +BackgroundPropertiesContext::BackgroundPropertiesContext( ContextHandler& rParent, ::oox::drawingml::FillProperties& rFillProperties ) throw() +: ContextHandler( rParent ) +, mrFillProperties( rFillProperties ) +{ +} + +Reference< XFastContextHandler > BackgroundPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( fill ): // a:CT_FillEffect + break; + } + + // FillPropertiesGroupContext + if( !xRet.is() ) + xRet = ::oox::drawingml::FillPropertiesContext::createFillContext( *this, aElementToken, xAttribs, mrFillProperties ); + + return xRet; +} + +} } diff --git a/oox/source/ppt/buildlistcontext.cxx b/oox/source/ppt/buildlistcontext.cxx new file mode 100644 index 000000000000..3352e202e057 --- /dev/null +++ b/oox/source/ppt/buildlistcontext.cxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "buildlistcontext.hxx" +#include <rtl/ustring.hxx> +#include "oox/helper/attributelist.hxx" + + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using ::rtl::OUString; + +namespace oox { namespace ppt { + + BuildListContext::BuildListContext( ContextHandler& rParent, + const Reference< XFastAttributeList >& /*xAttribs*/, + TimeNodePtrList & aTimeNodeList) + : ContextHandler( rParent ) + , maTimeNodeList( aTimeNodeList ) + , mbInBldGraphic( false ) + , mbBuildAsOne( false ) + { + } + + BuildListContext::~BuildListContext( ) + { + } + + void SAL_CALL BuildListContext::endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + { + switch( aElement ) + { + case PPT_TOKEN( bldGraphic ): + mbInBldGraphic = false; + break; + default: + break; + } + } + + Reference< XFastContextHandler > SAL_CALL BuildListContext::createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( bldAsOne ): + if( mbInBldGraphic ) + { + mbBuildAsOne = true; + } + break; + case PPT_TOKEN( bldSub ): + if( mbInBldGraphic ) + { + } + break; + case PPT_TOKEN( bldGraphic ): + { + mbInBldGraphic = true; + AttributeList attribs( xAttribs ); + OUString sShapeId = xAttribs->getOptionalValue( XML_spid ); +// TODO +// bool uiExpand = attribs.getBool( XML_uiExpand, true ); + /* this is unsigned */ +// sal_uInt32 nGroupId = attribs.getUnsignedInteger( XML_grpId, 0 ); + break; + } + case A_TOKEN( bldDgm ): + case A_TOKEN( bldOleChart ): + case A_TOKEN( bldP ): + + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set(this); + + return xRet; + } + + +} } diff --git a/oox/source/ppt/buildlistcontext.hxx b/oox/source/ppt/buildlistcontext.hxx new file mode 100644 index 000000000000..8b8d5c52b068 --- /dev/null +++ b/oox/source/ppt/buildlistcontext.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifndef OOX_PPT_BUILDLISTCONTEXT +#define OOX_PPT_BUILDLISTCONTEXT + +#include "oox/ppt/timenode.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace ppt { + + + /** CT_BuildList */ + class BuildListContext + : public ::oox::core::ContextHandler + { + public: + BuildListContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + TimeNodePtrList & aTimeNodeList); + + ~BuildListContext( ); + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + private: + TimeNodePtrList & maTimeNodeList; + bool mbInBldGraphic; + bool mbBuildAsOne; + }; + + + + +} } + +#endif diff --git a/oox/source/ppt/commonbehaviorcontext.cxx b/oox/source/ppt/commonbehaviorcontext.cxx new file mode 100644 index 000000000000..a4e3951228ae --- /dev/null +++ b/oox/source/ppt/commonbehaviorcontext.cxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include <osl/diagnose.h> +#include <rtl/ustrbuf.hxx> + +#include <com/sun/star/animations/XTimeContainer.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> +#include <com/sun/star/animations/XAnimate.hpp> + +#include "oox/core/fragmenthandler.hxx" + +#include "commonbehaviorcontext.hxx" +#include "commontimenodecontext.hxx" +#include "timetargetelementcontext.hxx" +#include "pptfilterhelpers.hxx" + +#include <string.h> + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::animations; + +namespace oox { namespace ppt { + + CommonBehaviorContext::CommonBehaviorContext( ContextHandler& rParent, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, PPT_TOKEN( cBhvr ), xAttribs, pNode ) + , mbInAttrList( false ) + , mbIsInAttrName( false ) + { + } + + + CommonBehaviorContext::~CommonBehaviorContext( ) throw( ) + { + } + + + + void SAL_CALL CommonBehaviorContext::endFastElement( sal_Int32 aElement ) + throw ( SAXException, RuntimeException) + { + switch( aElement ) + { + case PPT_TOKEN( cBhvr ): + { + if( !maAttributes.empty() ) + { + OUStringBuffer sAttributes; + std::list< Attribute >::const_iterator iter; + for(iter = maAttributes.begin(); iter != maAttributes.end(); iter++) + { + if( sAttributes.getLength() ) + { + sAttributes.appendAscii( ";" ); + } + sAttributes.append( iter->name ); + } + OUString sTmp( sAttributes.makeStringAndClear() ); + mpNode->getNodeProperties()[ NP_ATTRIBUTENAME ] = makeAny( sTmp ); + } + break; + } + case PPT_TOKEN( attrNameLst ): + mbInAttrList = false; + break; + case PPT_TOKEN( attrName ): + if( mbIsInAttrName ) + { + const ImplAttributeNameConversion *attrConv = gImplConversionList; + while( attrConv->mpMSName != NULL ) + { + if(msCurrentAttribute.compareToAscii( attrConv->mpMSName ) == 0 ) + { + Attribute attr; + attr.name = ::rtl::OUString::intern( attrConv->mpAPIName, + strlen(attrConv->mpAPIName), + RTL_TEXTENCODING_ASCII_US ); + attr.type = attrConv->meAttribute; + maAttributes.push_back( attr ); + OSL_TRACE( "OOX: attrName is %s -> %s", + OUSTRING_TO_CSTR( msCurrentAttribute ), + attrConv->mpAPIName ); + break; + } + attrConv++; + } + mbIsInAttrName = false; + } + break; + default: + break; + } + } + + + void CommonBehaviorContext::characters( const OUString& aChars ) + throw( SAXException, RuntimeException ) + { + if( mbIsInAttrName ) + { + msCurrentAttribute += aChars; + } + } + + + Reference< XFastContextHandler > SAL_CALL CommonBehaviorContext::createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cTn ): + xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( tgtEl ): + xRet.set( new TimeTargetElementContext( *this, mpNode->getTarget() ) ); + break; + case PPT_TOKEN( attrNameLst ): + mbInAttrList = true; + break; + case PPT_TOKEN( attrName ): + { + if( mbInAttrList ) + { + mbIsInAttrName = true; + msCurrentAttribute = OUString(); + } + else + { + OSL_TRACE( "OOX: Attribute Name outside an Attribute List" ); + } + break; + } + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + +} } diff --git a/oox/source/ppt/commonbehaviorcontext.hxx b/oox/source/ppt/commonbehaviorcontext.hxx new file mode 100644 index 000000000000..95e47342a76e --- /dev/null +++ b/oox/source/ppt/commonbehaviorcontext.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef OOX_PPT_COMMONBEHAVIORCONTEXT +#define OOX_PPT_COMMONBEHAVIORCONTEXT + +#include <rtl/ustring.hxx> +#include "oox/ppt/timenodelistcontext.hxx" +#include "oox/ppt/animationspersist.hxx" +#include "conditioncontext.hxx" +#include "pptfilterhelpers.hxx" + +namespace oox { namespace ppt { + + struct Attribute + { + ::rtl::OUString name; + MS_AttributeNames type; + }; + + + /** CT_TLCommonBehaviorData */ + class CommonBehaviorContext + : public TimeNodeContext + { + public: + CommonBehaviorContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ); + ~CommonBehaviorContext( ) + throw( ); + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + private: + bool mbInAttrList; + bool mbIsInAttrName; + std::list< Attribute > maAttributes; + ::rtl::OUString msCurrentAttribute; + }; + + +} } + + +#endif diff --git a/oox/source/ppt/commontimenodecontext.cxx b/oox/source/ppt/commontimenodecontext.cxx new file mode 100644 index 000000000000..1057deb70c5d --- /dev/null +++ b/oox/source/ppt/commontimenodecontext.cxx @@ -0,0 +1,708 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "commontimenodecontext.hxx" + +#include <algorithm> + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include <osl/diagnose.h> + +#include <com/sun/star/animations/XTimeContainer.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> +#include <com/sun/star/animations/AnimationFill.hpp> +#include <com/sun/star/animations/AnimationRestart.hpp> +#include <com/sun/star/presentation/TextAnimationType.hpp> +#include <com/sun/star/presentation/EffectPresetClass.hpp> +#include <com/sun/star/presentation/EffectNodeType.hpp> + +#include "oox/helper/attributelist.hxx" +#include "oox/core/fragmenthandler.hxx" +#include "oox/ppt/pptimport.hxx" +#include "oox/drawingml/drawingmltypes.hxx" + +#include "animationtypes.hxx" + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::xml::sax; + + +using ::rtl::OUString; +using ::com::sun::star::beans::NamedValue; + +namespace oox { namespace ppt { + +// BEGIN CUT&PASTE from sd/source/filter/ppt/pptanimations.hxx +struct convert_subtype +{ + sal_Int32 mnID; + const sal_Char* mpStrSubType; +}; +static const convert_subtype gConvertArray[] = +{ + // fly in + { 1, "from-top" }, + { 2, "from-right" }, + { 3, "from-top-right" }, + { 4, "from-bottom" }, + { 5, "horizontal" }, + { 6, "from-bottom-right" }, + { 8, "from-left" }, + { 9, "from-top-left" }, + { 10, "vertical" }, + { 12, "from-bottom-left" }, + { 16, "in" }, + { 21, "vertical-in" }, + { 26, "horizontal-in" }, + { 32, "out" }, + { 36, "out-from-screen-center" }, + { 37, "vertical-out" }, + { 42, "horizontal-out" }, + { 272, "in-slightly" }, + { 288, "out-slightly" }, + { 528, "in-from-screen-center" }, + { 0, 0 } +}; + + +struct preset_maping +{ + sal_Int32 mnPresetClass; + sal_Int32 mnPresetId; + const sal_Char* mpStrPresetId; +}; + +static const preset_maping gPresetMaping[] = +{ + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 1 ,"ooo-entrance-appear" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 2 ,"ooo-entrance-fly-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 3 ,"ooo-entrance-venetian-blinds" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 4 ,"ooo-entrance-box" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 5 ,"ooo-entrance-checkerboard" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 6 ,"ooo-entrance-circle" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 7 ,"ooo-entrance-fly-in-slow" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 8 ,"ooo-entrance-diamond" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 9 ,"ooo-entrance-dissolve-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 10 ,"ooo-entrance-fade-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 11 ,"ooo-entrance-flash-once" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 12 ,"ooo-entrance-peek-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 13 ,"ooo-entrance-plus" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 14 ,"ooo-entrance-random-bars" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 15 ,"ooo-entrance-spiral-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 16 ,"ooo-entrance-split" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 17 ,"ooo-entrance-stretchy" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 18 ,"ooo-entrance-diagonal-squares" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 19 ,"ooo-entrance-swivel" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 20 ,"ooo-entrance-wedge" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 21 ,"ooo-entrance-wheel" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 22 ,"ooo-entrance-wipe" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 23 ,"ooo-entrance-zoom" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 24 ,"ooo-entrance-random" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 25 ,"ooo-entrance-boomerang" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 26 ,"ooo-entrance-bounce" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 27 ,"ooo-entrance-colored-lettering" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 28 ,"ooo-entrance-movie-credits" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 29 ,"ooo-entrance-ease-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 30 ,"ooo-entrance-float" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 31 ,"ooo-entrance-turn-and-grow" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 34 ,"ooo-entrance-breaks" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 35 ,"ooo-entrance-pinwheel" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 37 ,"ooo-entrance-rise-up" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 38 ,"ooo-entrance-falling-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 39 ,"ooo-entrance-thread" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 40 ,"ooo-entrance-unfold" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 41 ,"ooo-entrance-whip" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 42 ,"ooo-entrance-ascend" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 43 ,"ooo-entrance-center-revolve" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 45 ,"ooo-entrance-fade-in-and-swivel" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 47 ,"ooo-entrance-descend" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 48 ,"ooo-entrance-sling" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 49 ,"ooo-entrance-spin-in" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 50 ,"ooo-entrance-compress" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 51 ,"ooo-entrance-magnify" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 52 ,"ooo-entrance-curve-up" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 53 ,"ooo-entrance-fade-in-and-zoom" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 54 ,"ooo-entrance-glide" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 55 ,"ooo-entrance-expand" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 56 ,"ooo-entrance-flip" }, + { ::com::sun::star::presentation::EffectPresetClass::ENTRANCE, 58 ,"ooo-entrance-fold" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 1 ,"ooo-emphasis-fill-color" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 2 ,"ooo-emphasis-font" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 3 ,"ooo-emphasis-font-color" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 4 ,"ooo-emphasis-font-size" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 5 ,"ooo-emphasis-font-style" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 6 ,"ooo-emphasis-grow-and-shrink" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 7 ,"ooo-emphasis-line-color" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 8 ,"ooo-emphasis-spin" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 9 ,"ooo-emphasis-transparency" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 10 ,"ooo-emphasis-bold-flash" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 14 ,"ooo-emphasis-blast" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 15 ,"ooo-emphasis-bold-reveal" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 16 ,"ooo-emphasis-color-over-by-word" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 18 ,"ooo-emphasis-reveal-underline" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 19 ,"ooo-emphasis-color-blend" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 20 ,"ooo-emphasis-color-over-by-letter" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 21 ,"ooo-emphasis-complementary-color" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 22 ,"ooo-emphasis-complementary-color-2" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 23 ,"ooo-emphasis-contrasting-color" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 24 ,"ooo-emphasis-darken" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 25 ,"ooo-emphasis-desaturate" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 26 ,"ooo-emphasis-flash-bulb" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 27 ,"ooo-emphasis-flicker" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 28 ,"ooo-emphasis-grow-with-color" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 30 ,"ooo-emphasis-lighten" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 31 ,"ooo-emphasis-style-emphasis" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 32 ,"ooo-emphasis-teeter" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 33 ,"ooo-emphasis-vertical-highlight" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 34 ,"ooo-emphasis-wave" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 35 ,"ooo-emphasis-blink" }, + { ::com::sun::star::presentation::EffectPresetClass::EMPHASIS, 36 ,"ooo-emphasis-shimmer" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 1 ,"ooo-exit-disappear" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 2 ,"ooo-exit-fly-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 3 ,"ooo-exit-venetian-blinds" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 4 ,"ooo-exit-box" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 5 ,"ooo-exit-checkerboard" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 6 ,"ooo-exit-circle" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 7 ,"ooo-exit-crawl-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 8 ,"ooo-exit-diamond" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 9 ,"ooo-exit-dissolve" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 10 ,"ooo-exit-fade-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 11 ,"ooo-exit-flash-once" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 12 ,"ooo-exit-peek-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 13 ,"ooo-exit-plus" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 14 ,"ooo-exit-random-bars" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 15 ,"ooo-exit-spiral-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 16 ,"ooo-exit-split" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 17 ,"ooo-exit-collapse" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 18 ,"ooo-exit-diagonal-squares" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 19 ,"ooo-exit-swivel" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 20 ,"ooo-exit-wedge" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 21 ,"ooo-exit-wheel" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 22 ,"ooo-exit-wipe" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 23 ,"ooo-exit-zoom" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 24 ,"ooo-exit-random" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 25 ,"ooo-exit-boomerang" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 26 ,"ooo-exit-bounce" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 27 ,"ooo-exit-colored-lettering" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 28 ,"ooo-exit-movie-credits" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 29 ,"ooo-exit-ease-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 30 ,"ooo-exit-float" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 31 ,"ooo-exit-turn-and-grow" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 34 ,"ooo-exit-breaks" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 35 ,"ooo-exit-pinwheel" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 37 ,"ooo-exit-sink-down" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 38 ,"ooo-exit-swish" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 39 ,"ooo-exit-thread" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 40 ,"ooo-exit-unfold" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 41 ,"ooo-exit-whip" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 42 ,"ooo-exit-descend" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 43 ,"ooo-exit-center-revolve" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 45 ,"ooo-exit-fade-out-and-swivel" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 47 ,"ooo-exit-ascend" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 48 ,"ooo-exit-sling" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 53 ,"ooo-exit-fade-out-and-zoom" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 55 ,"ooo-exit-contract" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 49 ,"ooo-exit-spin-out" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 50 ,"ooo-exit-stretchy" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 51 ,"ooo-exit-magnify" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 52 ,"ooo-exit-curve-down" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 54 ,"ooo-exit-glide" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 56 ,"ooo-exit-flip" }, + { ::com::sun::star::presentation::EffectPresetClass::EXIT, 58 ,"ooo-exit-fold" }, + + + + + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 16 ,"ooo-motionpath-4-point-star" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 5 ,"ooo-motionpath-5-point-star" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 11 ,"ooo-motionpath-6-point-star" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 17 ,"ooo-motionpath-8-point-star" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 1 ,"ooo-motionpath-circle" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 6 ,"ooo-motionpath-crescent-moon" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 3 ,"ooo-motionpath-diamond" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 13 ,"ooo-motionpath-equal-triangle" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 12 ,"ooo-motionpath-oval" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 9 ,"ooo-motionpath-heart" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 4 ,"ooo-motionpath-hexagon" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 10 ,"ooo-motionpath-octagon" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 14 ,"ooo-motionpath-parallelogram" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 15 ,"ooo-motionpath-pentagon" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 2 ,"ooo-motionpath-right-triangle" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 7 ,"ooo-motionpath-square" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 18 ,"ooo-motionpath-teardrop" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 8 ,"ooo-motionpath-trapezoid" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 37 ,"ooo-motionpath-arc-down" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 51 ,"ooo-motionpath-arc-left" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 58 ,"ooo-motionpath-arc-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 44 ,"ooo-motionpath-arc-up" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 41 ,"ooo-motionpath-bounce-left" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 54 ,"ooo-motionpath-bounce-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 48 ,"ooo-motionpath-curvy-left" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 61 ,"ooo-motionpath-curvy-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 60 ,"ooo-motionpath-decaying-wave" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 49 ,"ooo-motionpath-diagonal-down-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 56 ,"ooo-motionpath-diagonal-up-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 42 ,"ooo-motionpath-down" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 52 ,"ooo-motionpath-funnel" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 53 ,"ooo-motionpath-spring" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 62 ,"ooo-motionpath-stairs-down" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 50 ,"ooo-motionpath-turn-down" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 36 ,"ooo-motionpath-turn-down-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 43 ,"ooo-motionpath-turn-up" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 57 ,"ooo-motionpath-turn-up-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 64 ,"ooo-motionpath-up" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 47 ,"ooo-motionpath-wave" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 38 ,"ooo-motionpath-zigzag" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 31 ,"ooo-motionpath-bean" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 25 ,"ooo-motionpath-buzz-saw" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 20 ,"ooo-motionpath-curved-square" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 21 ,"ooo-motionpath-curved-x" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 23 ,"ooo-motionpath-curvy-star" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 28 ,"ooo-motionpath-figure-8-four" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 26 ,"ooo-motionpath-horizontal-figure-8" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 34 ,"ooo-motionpath-inverted-square" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 33 ,"ooo-motionpath-inverted-triangle" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 24 ,"ooo-motionpath-loop-de-loop" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 29 ,"ooo-motionpath-neutron" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 27 ,"ooo-motionpath-peanut" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 32 ,"ooo-motionpath-clover" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 19 ,"ooo-motionpath-pointy-star" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 30 ,"ooo-motionpath-swoosh" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 22 ,"ooo-motionpath-vertical-figure-8" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 35 ,"ooo-motionpath-left" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 63 ,"ooo-motionpath-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 55 ,"ooo-motionpath-spiral-left" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 46 ,"ooo-motionpath-spiral-right" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 40 ,"ooo-motionpath-sine-wave" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 59 ,"ooo-motionpath-s-curve-1" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 39 ,"ooo-motionpath-s-curve-2" }, + { ::com::sun::star::presentation::EffectPresetClass::MOTIONPATH, 45 ,"ooo-motionpath-heartbeat" }, + + + { 0,0,0 } +}; + +// from sd/source/filter/ppt/pptinanimations.cxx +static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId, sal_Int32 nPresetSubType ) +{ + const sal_Char* pStr = 0; + + if( (nPresetClass == EffectPresetClass::ENTRANCE) || (nPresetClass == EffectPresetClass::EXIT) ) + { + // skip wheel effect + if( nPresetId != 21 ) + { + if( nPresetId == 5 ) + { + // checkerboard + switch( nPresetSubType ) + { + case 5: pStr = "downward"; break; + case 10: pStr = "across"; break; + } + } + else if( nPresetId == 17 ) + { + // stretch + if( nPresetSubType == 10 ) + pStr = "across"; + } + else if( nPresetId == 18 ) + { + // strips + switch( nPresetSubType ) + { + case 3: pStr = "right-to-top"; break; + case 6: pStr = "right-to-bottom"; break; + case 9: pStr = "left-to-top"; break; + case 12: pStr = "left-to-bottom"; break; + } + } + + if( pStr == 0 ) + { + const convert_subtype* p = gConvertArray; + + while( p->mpStrSubType ) + { + if( p->mnID == nPresetSubType ) + { + pStr = p->mpStrSubType; + break; + } + p++; + } + } + } + } + + if( pStr ) + return OUString::createFromAscii( pStr ); + else + return OUString::valueOf( nPresetSubType ); +} + +// END + + CommonTimeNodeContext::CommonTimeNodeContext( + ContextHandler& rParent, + sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + , mbIterate( false ) + { + AttributeList attribs( xAttribs ); + sal_Int32 nInt; // some temporary int value for float conversions + + NodePropertyMap & aProps = pNode->getNodeProperties(); + TimeNode::UserDataMap & aUserData = pNode->getUserData(); + + if( attribs.hasAttribute( XML_accel ) ) + { + double dPercent = ::oox::drawingml::GetPositiveFixedPercentage( xAttribs->getOptionalValue( XML_accel ) ); + aProps[ NP_ACCELERATION ] <<= dPercent; + } + + if( attribs.hasAttribute( XML_afterEffect ) ) + { + aUserData[ CREATE_OUSTRING( "after-effect" ) ] + = makeAny( attribs.getBool( XML_afterEffect, false ) ); + } + aProps[ NP_AUTOREVERSE ] = makeAny( attribs.getBool( XML_autoRev, false ) ); + + // TODO + if( attribs.hasAttribute( XML_bldLvl ) ) + { + attribs.getInteger( XML_bldLvl, 0 ); + } + if( attribs.hasAttribute( XML_decel ) ) + { + double dPercent = ::oox::drawingml::GetPositiveFixedPercentage( xAttribs->getOptionalValue( XML_decel ) ); + aProps[ NP_DECELERATE ] <<= dPercent; + } + // TODO + if( attribs.hasAttribute( XML_display ) ) + { + aProps[ NP_DISPLAY ] <<= attribs.getBool( XML_display, true ); + } + if( attribs.hasAttribute( XML_dur ) ) + { + aProps[ NP_DURATION ] = GetTime( xAttribs->getOptionalValue( XML_dur) ); + } + // TODO + if( attribs.hasAttribute( XML_evtFilter ) ) + { + xAttribs->getOptionalValue( XML_evtFilter ); + } + // ST_TLTimeNodeFillType + if( attribs.hasAttribute( XML_fill ) ) + { + nInt = xAttribs->getOptionalValueToken( XML_fill, 0 ); + if( nInt != 0 ) + { + sal_Int16 nEnum; + switch( nInt ) + { + case XML_remove: + nEnum = AnimationFill::REMOVE; + break; + case XML_freeze: + nEnum = AnimationFill::FREEZE; + break; + case XML_hold: + nEnum = AnimationFill::HOLD; + break; + case XML_transition: + nEnum = AnimationFill::TRANSITION; + break; + default: + nEnum = AnimationFill::DEFAULT; + break; + } + aProps[ NP_FILL ] <<= (sal_Int16)nEnum; + } + } + if( attribs.hasAttribute( XML_grpId ) ) + { + attribs.getUnsigned( XML_grpId, 0 ); + } + // ST_TLTimeNodeID + if( attribs.hasAttribute( XML_id ) ) + { + sal_uInt32 nId = attribs.getUnsigned( XML_id, 0 ); + pNode->setId( nId ); + } + // ST_TLTimeNodeMasterRelation + nInt = xAttribs->getOptionalValueToken( XML_masterRel, 0 ); + if( nInt ) + { + // TODO + switch(nInt) + { + case XML_sameClick: + case XML_lastClick: + case XML_nextClick: + break; + } + } + + // TODO + if( attribs.hasAttribute( XML_nodePh ) ) + { + attribs.getBool( XML_nodePh, false ); + } + // ST_TLTimeNodeType + nInt = xAttribs->getOptionalValueToken( XML_nodeType, 0 ); + if( nInt != 0 ) + { + sal_Int16 nEnum; + switch( nInt ) + { + case XML_clickEffect: + case XML_clickPar: + nEnum = EffectNodeType::ON_CLICK; + break; + case XML_withEffect: + case XML_withGroup: + nEnum = EffectNodeType::WITH_PREVIOUS; + break; + case XML_mainSeq: + nEnum = EffectNodeType::MAIN_SEQUENCE; + break; + case XML_interactiveSeq: + nEnum = EffectNodeType::INTERACTIVE_SEQUENCE; + break; + case XML_afterGroup: + case XML_afterEffect: + nEnum = EffectNodeType::AFTER_PREVIOUS; + break; + case XML_tmRoot: + nEnum = EffectNodeType::TIMING_ROOT; + break; + default: + nEnum = EffectNodeType::DEFAULT; + break; + } + aUserData[ CREATE_OUSTRING( "node-type" ) ] <<= nEnum; + } + + // ST_TLTimeNodePresetClassType + nInt = xAttribs->getOptionalValueToken( XML_presetClass, 0 ); + sal_Int16 nEffectPresetClass = 0; + sal_Int32 nPresetId = 0; + sal_Int32 nPresetSubType = 0; + if( nInt != 0 ) + { + // TODO put that in a function + switch( nInt ) + { + case XML_entr: + nEffectPresetClass = EffectPresetClass::ENTRANCE; + break; + case XML_exit: + nEffectPresetClass = EffectPresetClass::EXIT; + break; + case XML_emph: + nEffectPresetClass = EffectPresetClass::EMPHASIS; + break; + case XML_path: + nEffectPresetClass = EffectPresetClass::MOTIONPATH; + break; + case XML_verb: + // TODO check that the value below is correct + nEffectPresetClass = EffectPresetClass::OLEACTION; + break; + case XML_mediacall: + nEffectPresetClass = EffectPresetClass::MEDIACALL; + break; + default: + nEffectPresetClass = 0; + break; + } + aUserData[ CREATE_OUSTRING( "preset-class" ) ] = makeAny( nEffectPresetClass ); + if( attribs.hasAttribute( XML_presetID ) ) + { + nPresetId = attribs.getInteger( XML_presetID, 0 ); + const preset_maping* p = gPresetMaping; + while( p->mpStrPresetId && ((p->mnPresetClass != nEffectPresetClass) || (p->mnPresetId != nPresetId )) ) + p++; + + aUserData[ CREATE_OUSTRING( "preset-id" ) ] + = makeAny( OUString::createFromAscii( p->mpStrPresetId ) ); + nPresetSubType = attribs.getInteger( XML_presetSubtype, 0 ); + if( nPresetSubType ) + { + aUserData[ CREATE_OUSTRING( "preset-sub-type" ) ] + = makeAny( getConvertedSubType( nEffectPresetClass, nPresetId, nPresetSubType ) ); + } + } + } + if( attribs.hasAttribute( XML_repeatCount ) ) + { + aProps[ NP_REPEATCOUNT ] = GetTime( xAttribs->getOptionalValue( XML_repeatCount ) ); + } + /* see pptinanimation */ +// aProps[ NP_REPEATCOUNT ] <<= (fCount < ((float)3.40282346638528860e+38)) ? makeAny( (double)fCount ) : makeAny( Timing_INDEFINITE ); + if( attribs.hasAttribute( XML_repeatDur ) ) + { + aProps[ NP_REPEATDURATION ] = GetTime( xAttribs->getOptionalValue( XML_repeatDur ) ); + } + // TODO repeatDur is otherwise the same as dur. What shall we do? -- Hub + + // ST_TLTimeNodeRestartType + nInt = xAttribs->getOptionalValueToken( XML_restart, 0 ); + if( nInt != 0 ) + { + // TODO put that in a function + sal_Int16 nEnum; + switch( nInt ) + { + case XML_always: + nEnum = AnimationRestart::ALWAYS; + break; + case XML_whenNotActive: + nEnum = AnimationRestart::WHEN_NOT_ACTIVE; + break; + case XML_never: + nEnum = AnimationRestart::NEVER; + break; + default: + nEnum = AnimationRestart::DEFAULT; + break; + } + aProps[ NP_RESTART ] <<= (sal_Int16)nEnum; + } + // ST_Percentage TODO + xAttribs->getOptionalValue( XML_spd /*"10000" */ ); + // ST_TLTimeNodeSyncType TODO + xAttribs->getOptionalValue( XML_syncBehavior ); + // TODO (string) + xAttribs->getOptionalValue( XML_tmFilter ); + } + + + CommonTimeNodeContext::~CommonTimeNodeContext( ) throw ( ) + { + } + + + void SAL_CALL CommonTimeNodeContext::endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + { + if( aElement == ( PPT_TOKEN( iterate ) ) ) + { + mbIterate = false; + } + } + + + Reference< XFastContextHandler > SAL_CALL CommonTimeNodeContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( childTnLst ): + case PPT_TOKEN( subTnLst ): + xRet.set( new TimeNodeListContext( *this, mpNode->getChildren() ) ); + break; + + case PPT_TOKEN( stCondLst ): + xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, mpNode->getStartCondition() ) ); + break; + case PPT_TOKEN( endCondLst ): + xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, mpNode->getEndCondition() ) ); + break; + + case PPT_TOKEN( endSync ): + xRet.set( new CondContext( *this, xAttribs, mpNode, mpNode->getEndSyncValue() ) ); + break; + case PPT_TOKEN( iterate ): + { + sal_Int32 nVal = xAttribs->getOptionalValueToken( XML_type, XML_el ); + if( nVal != 0 ) + { + // TODO put that in a function + sal_Int16 nEnum; + switch( nVal ) + { + case XML_el: + nEnum = TextAnimationType::BY_PARAGRAPH; + break; + case XML_lt: + nEnum = TextAnimationType::BY_LETTER; + break; + case XML_wd: + nEnum = TextAnimationType::BY_WORD; + break; + default: + // default is BY_WORD. See Ppt97Animation::GetTextAnimationType() + // in sd/source/filter/ppt/ppt97animations.cxx:297 + nEnum = TextAnimationType::BY_WORD; + break; + } + mpNode->getNodeProperties()[ NP_ITERATETYPE ] <<= nEnum; + } + // in case of exception we ignore the whole tag. + AttributeList attribs( xAttribs ); + // TODO what to do with this + /*bool bBackwards =*/ attribs.getBool( XML_backwards, false ); + mbIterate = true; + break; + } + case PPT_TOKEN( tmAbs ): + if( mbIterate ) + { + AttributeList attribs( xAttribs ); + double fTime = attribs.getUnsigned( XML_val, 0 ); + // time in ms. property is in % TODO + mpNode->getNodeProperties()[ NP_ITERATEINTERVAL ] <<= fTime; + } + break; + case PPT_TOKEN( tmPct ): + if( mbIterate ) + { + AttributeList attribs( xAttribs ); + double fPercent = (double)attribs.getUnsigned( XML_val, 0 ) / 100000.0; + mpNode->getNodeProperties()[ NP_ITERATEINTERVAL ] <<= fPercent; + } + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + +} } diff --git a/oox/source/ppt/commontimenodecontext.hxx b/oox/source/ppt/commontimenodecontext.hxx new file mode 100644 index 000000000000..e8c55fa2d944 --- /dev/null +++ b/oox/source/ppt/commontimenodecontext.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef OOX_PPT_COMMONTIMENODECONTEXT +#define OOX_PPT_COMMONTIMENODECONTEXT + + +#include <com/sun/star/animations/XIterateContainer.hpp> +#include "oox/ppt/timenode.hxx" +#include "oox/ppt/timenodelistcontext.hxx" +#include "conditioncontext.hxx" + + +namespace oox { namespace ppt { + + /** CT_TLCommonTimeNodeData */ + class CommonTimeNodeContext + : public TimeNodeContext + { + public: + CommonTimeNodeContext( ::oox::core::ContextHandler& rParent, sal_Int32 aElement, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode); + ~CommonTimeNodeContext( ) throw( ); + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: + bool mbIterate; + ::com::sun::star::uno::Reference< ::com::sun::star::animations::XIterateContainer > mxIter; + }; + + +} } + + +#endif diff --git a/oox/source/ppt/conditioncontext.cxx b/oox/source/ppt/conditioncontext.cxx new file mode 100644 index 000000000000..5b622b6ef602 --- /dev/null +++ b/oox/source/ppt/conditioncontext.cxx @@ -0,0 +1,212 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "conditioncontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include <osl/diagnose.h> + +#include <com/sun/star/animations/XTimeContainer.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> +#include <com/sun/star/animations/AnimationEndSync.hpp> +#include <com/sun/star/animations/EventTrigger.hpp> + +#include "oox/helper/attributelist.hxx" +#include "oox/core/contexthandler.hxx" +#include "oox/ppt/animationspersist.hxx" +#include "animationtypes.hxx" + +#include "timetargetelementcontext.hxx" + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::animations; + +namespace oox { namespace ppt { + + CondContext::CondContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode, AnimationCondition & aValue ) + : TimeNodeContext( rParent, PPT_TOKEN( cond ), xAttribs, pNode ) + , maCond( aValue ) + { + maEvent.Trigger = EventTrigger::NONE; + maEvent.Repeat = 0; + + AttributeList attribs( xAttribs ); + if( attribs.hasAttribute( XML_evt ) ) + { + sal_Int32 nEvent = xAttribs->getOptionalValueToken( XML_evt, 0 ); + switch( nEvent ) + { + case XML_onBegin: + maEvent.Trigger = EventTrigger::ON_BEGIN; + break; + case XML_onEnd: + maEvent.Trigger = EventTrigger::ON_END; + break; + case XML_begin: + maEvent.Trigger = EventTrigger::BEGIN_EVENT; + break; + case XML_end: + maEvent.Trigger = EventTrigger::END_EVENT; + break; + case XML_onClick: + maEvent.Trigger = EventTrigger::ON_CLICK; + break; + case XML_onDblClick: + maEvent.Trigger = EventTrigger::ON_DBL_CLICK; + break; + case XML_onMouseOver: + maEvent.Trigger = EventTrigger::ON_MOUSE_ENTER; + break; + case XML_onMouseOut: + maEvent.Trigger = EventTrigger::ON_MOUSE_LEAVE; + break; + case XML_onNext: + maEvent.Trigger = EventTrigger::ON_NEXT; + break; + case XML_onPrev: + maEvent.Trigger = EventTrigger::ON_PREV; + break; + case XML_onStopAudio: + maEvent.Trigger = EventTrigger::ON_STOP_AUDIO; + break; + default: + break; + } + } + if( attribs.hasAttribute( XML_delay ) || ( maEvent.Trigger == EventTrigger::NONE ) ) + { + maEvent.Offset = GetTime( xAttribs->getOptionalValue( XML_delay ) ); + } + } + + CondContext::~CondContext( ) throw( ) + { + if( maCond.mnType == 0 ) + { + maCond.maValue = (maEvent.Trigger == EventTrigger::NONE) ? maEvent.Offset : makeAny( maEvent ); + } + } + + Reference< XFastContextHandler > SAL_CALL CondContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( rtn ): + { + // ST_TLTriggerRuntimeNode { first, last, all } + sal_Int32 aTok; + sal_Int16 nEnum; + aTok = xAttribs->getOptionalValueToken( XML_val, XML_first ); + switch( aTok ) + { + case XML_first: + nEnum = AnimationEndSync::FIRST; + break; + case XML_last: + nEnum = AnimationEndSync::LAST; + break; + case XML_all: + nEnum = AnimationEndSync::ALL; + break; + default: + break; + } + maCond.mnType = aElementToken; + maCond.maValue = makeAny( nEnum ); + break; + } + case PPT_TOKEN( tn ): + { + maCond.mnType = aElementToken; + AttributeList attribs( xAttribs ); + sal_uInt32 nId = attribs.getUnsigned( XML_val, 0 ); + maCond.maValue = makeAny( nId ); + break; + } + case PPT_TOKEN( tgtEl ): + // CT_TLTimeTargetElement + xRet.set( new TimeTargetElementContext( *this, maCond.getTarget() ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + + } + + + + /** CT_TLTimeConditionList */ + CondListContext::CondListContext( + ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode, + AnimationConditionList & aCond ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + , maConditions( aCond ) + { + } + + CondListContext::~CondListContext( ) + throw( ) + { + } + + Reference< XFastContextHandler > CondListContext::createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch( aElement ) + { + case PPT_TOKEN( cond ): + // add a condition to the list + maConditions.push_back( AnimationCondition() ); + xRet.set( new CondContext( *this, xAttribs, mpNode, maConditions.back() ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + +} } + diff --git a/oox/source/ppt/conditioncontext.hxx b/oox/source/ppt/conditioncontext.hxx new file mode 100644 index 000000000000..b89e587a9571 --- /dev/null +++ b/oox/source/ppt/conditioncontext.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef OOX_PPT_CONDITIONCONTEXT +#define OOX_PPT_CONDITIONCONTEXT + +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/animations/Event.hpp> + +#include "oox/core/fragmenthandler.hxx" +#include "oox/ppt/timenode.hxx" +#include "oox/ppt/timenodelistcontext.hxx" +#include "oox/ppt/animationspersist.hxx" + +namespace oox { namespace ppt { + + + /** CT_TLTimeCondition */ + class CondContext + : public TimeNodeContext + { + public: + CondContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode, AnimationCondition & aCond ); + ~CondContext( ) throw( ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: +// ::com::sun::star::uno::Any & maCond; + ::com::sun::star::animations::Event maEvent; +// AnimTargetElementPtr mpTarget; + AnimationCondition & maCond; + }; + + + + /** CT_TLTimeConditionList */ + class CondListContext + : public TimeNodeContext + { + public: + CondListContext( ::oox::core::ContextHandler& rParent, + sal_Int32 aElement, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode, AnimationConditionList & aCondList ); + ~CondListContext( ) throw( ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: + AnimationConditionList & maConditions; + }; + + +} } + + +#endif diff --git a/oox/source/ppt/customshowlistcontext.cxx b/oox/source/ppt/customshowlistcontext.cxx new file mode 100644 index 000000000000..f66ccb0f6084 --- /dev/null +++ b/oox/source/ppt/customshowlistcontext.cxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "customshowlistcontext.hxx" + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +class CustomShowContext : public ::oox::core::ContextHandler +{ + CustomShow mrCustomShow; + +public: + CustomShowContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + CustomShow& rCustomShow ); + ~CustomShowContext( ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) + throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); +}; + +CustomShowContext::CustomShowContext( ContextHandler& rParent, + const Reference< XFastAttributeList >& rxAttribs, + CustomShow& rCustomShow ) +: ContextHandler( rParent ) +, mrCustomShow( rCustomShow ) +{ + mrCustomShow.maName = rxAttribs->getOptionalValue( XML_name ); + mrCustomShow.mnId = rxAttribs->getOptionalValue( XML_id ); +} + +CustomShowContext::~CustomShowContext( ) +{ +} + +Reference< XFastContextHandler > SAL_CALL CustomShowContext::createFastChildContext( sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) +{ + Reference< XFastContextHandler > xRet; + switch( aElementToken ) + { + case PPT_TOKEN( sld ) : + mrCustomShow.maSldLst.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); + default: + break; + } + if( !xRet.is() ) + xRet.set( this ); + + return xRet; +} + +//--------------------------------------------------------------------------- + +CustomShowListContext::CustomShowListContext( ContextHandler& rParent, + std::vector< CustomShow >& rCustomShowList ) +: ContextHandler( rParent ) +, mrCustomShowList( rCustomShowList ) +{ +} + +CustomShowListContext::~CustomShowListContext( ) +{ +} + +Reference< XFastContextHandler > SAL_CALL CustomShowListContext::createFastChildContext( sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) +{ + Reference< XFastContextHandler > xRet; + switch( aElementToken ) + { + case PPT_TOKEN( custShow ) : + { + CustomShow aCustomShow; + mrCustomShowList.push_back( aCustomShow ); + xRet = new CustomShowContext( *this, xAttribs, mrCustomShowList.back() ); + } + default: + break; + } + if( !xRet.is() ) + xRet.set( this ); + + return xRet; +} + + +} } diff --git a/oox/source/ppt/customshowlistcontext.hxx b/oox/source/ppt/customshowlistcontext.hxx new file mode 100644 index 000000000000..a423b18f2f5d --- /dev/null +++ b/oox/source/ppt/customshowlistcontext.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifndef OOX_POWERPOINT_CUSTOMSHOWLISTCONTEXT_HXX +#define OOX_POWERPOINT_CUSTOMSHOWLISTCONTEXT_HXX + +#include "oox/core/contexthandler.hxx" +#include <vector> + +namespace oox { namespace ppt { + + + struct CustomShow + { + ::rtl::OUString maName; + ::rtl::OUString mnId; + std::vector< rtl::OUString >maSldLst; + }; + + /** CT_ */ + class CustomShowListContext : public ::oox::core::ContextHandler + { + std::vector< CustomShow >& mrCustomShowList; + + public: + CustomShowListContext( ::oox::core::ContextHandler& rParent, + std::vector< CustomShow >& rCustomShowList ); + + ~CustomShowListContext( ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) + throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + }; + +} } + +#endif diff --git a/oox/source/ppt/headerfootercontext.cxx b/oox/source/ppt/headerfootercontext.cxx new file mode 100644 index 000000000000..2089b019c58c --- /dev/null +++ b/oox/source/ppt/headerfootercontext.cxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "headerfootercontext.hxx" +#include "oox/helper/attributelist.hxx" + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + + HeaderFooterContext::HeaderFooterContext( ContextHandler& rParent, + const Reference< XFastAttributeList >& xAttribs, HeaderFooter& rHeaderFooter ) + : ContextHandler( rParent ) + { + AttributeList aAttribs( xAttribs ); + if ( xAttribs->hasAttribute( XML_sldNum ) ) + { + rHeaderFooter.mbSlideNumber = aAttribs.getBool( XML_sldNum, sal_True ); + } + if ( xAttribs->hasAttribute( XML_hdr ) ) + { + rHeaderFooter.mbHeader = aAttribs.getBool( XML_hdr, sal_True ); + } + if ( xAttribs->hasAttribute( XML_ftr ) ) + { + rHeaderFooter.mbFooter = aAttribs.getBool( XML_ftr, sal_True ); + } + if ( xAttribs->hasAttribute( XML_dt ) ) + { + rHeaderFooter.mbDateTime = aAttribs.getBool( XML_dt, sal_True ); + } + } + + HeaderFooterContext::~HeaderFooterContext( ) + { + } + +} } diff --git a/oox/source/ppt/headerfootercontext.hxx b/oox/source/ppt/headerfootercontext.hxx new file mode 100644 index 000000000000..52e5bb9ab55e --- /dev/null +++ b/oox/source/ppt/headerfootercontext.hxx @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifndef OOX_PPT_HEADERFOOTERCONTEXT +#define OOX_PPT_HEADERFOOTERCONTEXT + +#include "oox/ppt/headerfooter.hxx" +#include "oox/core/contexthandler.hxx" + +namespace oox { namespace ppt { + + /** CT_HeaderFooter */ + class HeaderFooterContext : public ::oox::core::ContextHandler + { + public: + HeaderFooterContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, HeaderFooter& rHeaderFooter ); + + ~HeaderFooterContext( ); + }; + +} } + +#endif diff --git a/oox/source/ppt/layoutfragmenthandler.cxx b/oox/source/ppt/layoutfragmenthandler.cxx new file mode 100644 index 000000000000..152beb280bd7 --- /dev/null +++ b/oox/source/ppt/layoutfragmenthandler.cxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" + +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "headerfootercontext.hxx" +#include "oox/ppt/layoutfragmenthandler.hxx" +#include "oox/drawingml/shapegroupcontext.hxx" + +using rtl::OUString; +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::container; + +namespace oox { namespace ppt { + +// CT_SlideLayout + +LayoutFragmentHandler::LayoutFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, SlidePersistPtr pMasterPersistPtr ) + throw() +: SlideFragmentHandler( rFilter, rFragmentPath, pMasterPersistPtr, Layout ) +{ +} + +LayoutFragmentHandler::~LayoutFragmentHandler() + throw() +{ + +} + +Reference< XFastContextHandler > LayoutFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) + throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet = getFastContextHandler(); + switch( aElementToken ) + { + case PPT_TOKEN( sldLayout ): // CT_SlideLayout + mpSlidePersistPtr->setLayoutValueToken( xAttribs->getOptionalValueToken( XML_type, 0 ) ); // CT_SlideLayoutType + break; + case PPT_TOKEN( hf ): // CT_HeaderFooter + xRet.set( new HeaderFooterContext( *this, xAttribs, mpSlidePersistPtr->getHeaderFooter() ) ); + break; + default: + xRet.set( SlideFragmentHandler::createFastChildContext( aElementToken, xAttribs ) ); + } + return xRet; +} + +void SAL_CALL LayoutFragmentHandler::endDocument() + throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ +} + +} } + diff --git a/oox/source/ppt/makefile.mk b/oox/source/ppt/makefile.mk new file mode 100644 index 000000000000..8d902ed51337 --- /dev/null +++ b/oox/source/ppt/makefile.mk @@ -0,0 +1,76 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=oox +TARGET=ppt +AUTOSEG=true + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES = \ + $(SLO)$/animationspersist.obj \ + $(SLO)$/animationtypes.obj \ + $(SLO)$/animvariantcontext.obj \ + $(SLO)$/backgroundproperties.obj\ + $(SLO)$/buildlistcontext.obj \ + $(SLO)$/commonbehaviorcontext.obj \ + $(SLO)$/commontimenodecontext.obj \ + $(SLO)$/conditioncontext.obj \ + $(SLO)$/customshowlistcontext.obj \ + $(SLO)$/headerfootercontext.obj \ + $(SLO)$/layoutfragmenthandler.obj\ + $(SLO)$/pptfilterhelpers.obj\ + $(SLO)$/pptimport.obj\ + $(SLO)$/pptshape.obj \ + $(SLO)$/pptshapecontext.obj \ + $(SLO)$/pptshapegroupcontext.obj \ + $(SLO)$/pptshapepropertiescontext.obj \ + $(SLO)$/presentationfragmenthandler.obj\ + $(SLO)$/slidefragmenthandler.obj\ + $(SLO)$/slidemastertextstylescontext.obj \ + $(SLO)$/slidepersist.obj\ + $(SLO)$/slidetimingcontext.obj\ + $(SLO)$/slidetransition.obj\ + $(SLO)$/slidetransitioncontext.obj\ + $(SLO)$/soundactioncontext.obj \ + $(SLO)$/timeanimvaluecontext.obj \ + $(SLO)$/timenode.obj\ + $(SLO)$/timenodelistcontext.obj \ + $(SLO)$/timetargetelementcontext.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk diff --git a/oox/source/ppt/pptfilterhelpers.cxx b/oox/source/ppt/pptfilterhelpers.cxx new file mode 100644 index 000000000000..40040e985a4c --- /dev/null +++ b/oox/source/ppt/pptfilterhelpers.cxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include <com/sun/star/animations/TransitionType.hpp> +#include <com/sun/star/animations/TransitionSubType.hpp> + +#include "pptfilterhelpers.hxx" + + +using rtl::OUString; + +#include "pptfilterhelpers.hxx" + +namespace oox { namespace ppt { + + // BEGIN CUT&PASTE from sd pptanimations.hxx + + + static const transition gTransitions[] = + { + { "wipe(up)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM, sal_True }, + { "wipe(right)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT, sal_False }, + { "wipe(left)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::LEFTTORIGHT, sal_True }, + { "wipe(down)", ::com::sun::star::animations::TransitionType::BARWIPE, ::com::sun::star::animations::TransitionSubType::TOPTOBOTTOM, sal_False }, + { "wheel(1)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::ONEBLADE, sal_True }, + { "wheel(2)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::TWOBLADEVERTICAL, sal_True }, + { "wheel(3)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::THREEBLADE, sal_True }, + { "wheel(4)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::FOURBLADE, sal_True }, + { "wheel(8)", ::com::sun::star::animations::TransitionType::PINWHEELWIPE, ::com::sun::star::animations::TransitionSubType::EIGHTBLADE, sal_True }, + { "strips(downLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT, sal_True }, + { "strips(upLeft)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT, sal_False }, + { "strips(downRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALLEFT, sal_True }, + { "strips(upRight)", ::com::sun::star::animations::TransitionType::WATERFALLWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTALRIGHT, sal_False }, + { "barn(inVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_False }, + { "barn(outVertical)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True }, + { "barn(inHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_False }, + { "barn(outHorizontal)", ::com::sun::star::animations::TransitionType::BARNDOORWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True }, + { "randombar(vertical)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True}, + { "randombar(horizontal)", ::com::sun::star::animations::TransitionType::RANDOMBARWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True }, + { "checkerboard(down)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE, ::com::sun::star::animations::TransitionSubType::DOWN, sal_True}, + { "checkerboard(across)", ::com::sun::star::animations::TransitionType::CHECKERBOARDWIPE, ::com::sun::star::animations::TransitionSubType::ACROSS, sal_True }, + { "plus(out)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE, ::com::sun::star::animations::TransitionSubType::CORNERSIN, sal_False }, + { "plus(in)", ::com::sun::star::animations::TransitionType::FOURBOXWIPE, ::com::sun::star::animations::TransitionSubType::CORNERSIN, sal_True }, + { "diamond(out)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::DIAMOND, sal_True }, + { "diamond(in)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::DIAMOND, sal_False }, + { "circle(out)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True }, + { "circle(in)", ::com::sun::star::animations::TransitionType::ELLIPSEWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_False }, + { "box(out)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::RECTANGLE, sal_True }, + { "box(in)", ::com::sun::star::animations::TransitionType::IRISWIPE, ::com::sun::star::animations::TransitionSubType::RECTANGLE, sal_False }, + { "wedge", ::com::sun::star::animations::TransitionType::FANWIPE, ::com::sun::star::animations::TransitionSubType::CENTERTOP, sal_True }, + { "blinds(vertical)", ::com::sun::star::animations::TransitionType::BLINDSWIPE, ::com::sun::star::animations::TransitionSubType::VERTICAL, sal_True }, + { "blinds(horizontal)", ::com::sun::star::animations::TransitionType::BLINDSWIPE, ::com::sun::star::animations::TransitionSubType::HORIZONTAL, sal_True }, + { "fade", ::com::sun::star::animations::TransitionType::FADE, ::com::sun::star::animations::TransitionSubType::CROSSFADE, sal_True }, + { "slide(fromTop)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMTOP, sal_True }, + { "slide(fromRight)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMRIGHT, sal_True }, + { "slide(fromLeft)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMLEFT, sal_True }, + { "slide(fromBottom)", ::com::sun::star::animations::TransitionType::SLIDEWIPE, ::com::sun::star::animations::TransitionSubType::FROMBOTTOM, sal_True }, + { "dissolve", ::com::sun::star::animations::TransitionType::DISSOLVE, ::com::sun::star::animations::TransitionSubType::DEFAULT, sal_True }, + { "image", ::com::sun::star::animations::TransitionType::DISSOLVE, ::com::sun::star::animations::TransitionSubType::DEFAULT, sal_True }, // TODO + { NULL, 0, 0, sal_False } + }; + + const transition* transition::find( const OUString& rName ) + { + const transition* p = gTransitions; + + while( p->mpName ) + { + if( rName.compareToAscii( p->mpName ) == 0 ) + return p; + + p++; + } + + return NULL; + } + + + bool convertMeasure( OUString& rString ) + { + bool bRet = false; + + const sal_Char* pSource[] = { "ppt_x", "ppt_y", "ppt_w", "ppt_h", NULL }; + const sal_Char* pDest[] = { "x", "y", "width", "height", NULL }; + sal_Int32 nIndex = 0; + + const sal_Char** ps = pSource; + const sal_Char** pd = pDest; + + while( *ps ) + { + const OUString aSearch( OUString::createFromAscii( *ps ) ); + while( (nIndex = rString.indexOf( aSearch, nIndex )) != -1 ) + { + sal_Int32 nLength = aSearch.getLength(); + if( nIndex && (rString.getStr()[nIndex-1] == '#' ) ) + { + nIndex--; + nLength++; + } + + const OUString aNew( OUString::createFromAscii( *pd ) ); + rString = rString.replaceAt( nIndex, nLength, aNew ); + nIndex += aNew.getLength(); + bRet = true; + } + ps++; + pd++; + } + + return bRet; + } + + +} } diff --git a/oox/source/ppt/pptfilterhelpers.hxx b/oox/source/ppt/pptfilterhelpers.hxx new file mode 100644 index 000000000000..c36c66df5ae7 --- /dev/null +++ b/oox/source/ppt/pptfilterhelpers.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#ifndef OOX_PPT_PPTFILTERHELPERS +#define OOX_PPT_PPTFILTERHELPERS + +#include <rtl/ustring.hxx> + +namespace oox { namespace ppt { + + +//BEGIN CUT&PASTE from sd pptanimations.hxx + // conversion of MS to OOo attributes. + enum MS_AttributeNames + { + MS_PPT_X, MS_PPT_Y, MS_PPT_W, MS_PPT_H, MS_PPT_C, MS_R, MS_XSHEAR, MS_FILLCOLOR, MS_FILLTYPE, + MS_STROKECOLOR, MS_STROKEON, MS_STYLECOLOR, MS_STYLEROTATION, MS_FONTWEIGHT, + MS_STYLEUNDERLINE, MS_STYLEFONTFAMILY, MS_STYLEFONTSIZE, MS_STYLEFONTSTYLE, + MS_STYLEVISIBILITY, MS_STYLEOPACITY, MS_UNKNOWN + }; + + struct ImplAttributeNameConversion + { + MS_AttributeNames meAttribute; + const char* mpMSName; + const char* mpAPIName; + }; + + static const ImplAttributeNameConversion gImplConversionList[] = + { + { MS_PPT_X, "ppt_x", "X" }, + { MS_PPT_Y, "ppt_y", "Y" }, + { MS_PPT_W, "ppt_w", "Width" }, + { MS_PPT_H, "ppt_h", "Height" }, + { MS_PPT_C, "ppt_c", "DimColor" }, + { MS_R, "r", "Rotate" }, + { MS_XSHEAR, "xshear", "SkewX" }, + { MS_FILLCOLOR, "fillColor", "FillColor" }, + { MS_FILLCOLOR, "fillcolor", "FillColor" }, + { MS_FILLTYPE, "fill.type", "FillStyle" }, + { MS_STROKECOLOR, "stroke.color", "LineColor" }, + { MS_STROKEON, "stroke.on", "LineStyle" }, + { MS_STYLECOLOR, "style.color", "CharColor" }, + { MS_STYLEROTATION, "style.rotation", "Rotate" }, + { MS_FONTWEIGHT, "style.fontWeight", "CharWeight" }, + { MS_STYLEUNDERLINE, "style.textDecorationUnderline","CharUnderline" }, + { MS_STYLEFONTFAMILY, "style.fontFamily", "CharFontName" }, + { MS_STYLEFONTSIZE, "style.fontSize", "CharHeight" }, + { MS_STYLEFONTSTYLE, "style.fontStyle", "CharPosture" }, + { MS_STYLEVISIBILITY, "style.visibility", "Visibility" }, + { MS_STYLEOPACITY, "style.opacity", "Opacity" }, + { MS_UNKNOWN, NULL, NULL } + }; + //END CUT&PASTE + + + // BEGIN CUT&PASTE from sd pptanimations.hxx + struct transition + { + const sal_Char* mpName; + sal_Int16 mnType; + sal_Int16 mnSubType; + sal_Bool mbDirection; // true: default geometric direction + + static const transition* find( const rtl::OUString& rName ); + static const sal_Char* find( const sal_Int16 mnType, const sal_Int16 mnSubType, const sal_Bool bDirection ); + }; + // END CUT&PASTE + + + // BEGIN CUT&PASTE from sd pptinanimation.cxx + bool convertMeasure( ::rtl::OUString& rString ); + // END CUT&PASTE from sd pptinanimation.cxx + + +} } + + +#endif diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx new file mode 100644 index 000000000000..625e4e662e3c --- /dev/null +++ b/oox/source/ppt/pptimport.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/pptimport.hxx" +#include "oox/drawingml/chart/chartconverter.hxx" +#include "oox/dump/pptxdumper.hxx" +#include "oox/drawingml/table/tablestylelistfragmenthandler.hxx" +#include "oox/helper/graphichelper.hxx" +#include "oox/ole/vbaproject.hxx" + +using ::rtl::OUString; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace oox::core; + +namespace oox { namespace ppt { + +OUString SAL_CALL PowerPointImport_getImplementationName() throw() +{ + return CREATE_OUSTRING( "com.sun.star.comp.oox.ppt.PowerPointImport" ); +} + +uno::Sequence< OUString > SAL_CALL PowerPointImport_getSupportedServiceNames() throw() +{ + Sequence< OUString > aSeq( 2 ); + aSeq[ 0 ] = CREATE_OUSTRING( "com.sun.star.document.ImportFilter" ); + aSeq[ 1 ] = CREATE_OUSTRING( "com.sun.star.document.ExportFilter" ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL PowerPointImport_createInstance( const Reference< XComponentContext >& rxContext ) throw( Exception ) +{ + return static_cast< ::cppu::OWeakObject* >( new PowerPointImport( rxContext ) ); +} + +PowerPointImport::PowerPointImport( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) : + XmlFilterBase( rxContext ), + mxChartConv( new ::oox::drawingml::chart::ChartConverter ) +{ +} + +PowerPointImport::~PowerPointImport() +{ +} + +bool PowerPointImport::importDocument() throw() +{ + /* to activate the PPTX dumper, define the environment variable + OOO_PPTXDUMPER and insert the full path to the file + file:///<path-to-oox-module>/source/dump/pptxdumper.ini. */ + OOX_DUMP_FILE( ::oox::dump::pptx::Dumper ); + + OUString aFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "officeDocument" ) ); + FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) ); + maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "tableStyles" ) ); + return importFragment( xPresentationFragmentHandler ); + + +} + +bool PowerPointImport::exportDocument() throw() +{ + return false; +} + +sal_Int32 PowerPointImport::getSchemeColor( sal_Int32 nToken ) const +{ + sal_Int32 nColor = 0; + if ( mpActualSlidePersist ) + { + sal_Bool bColorMapped = sal_False; + oox::drawingml::ClrMapPtr pClrMapPtr( mpActualSlidePersist->getClrMap() ); + if ( pClrMapPtr ) + bColorMapped = pClrMapPtr->getColorMap( nToken ); + + if ( !bColorMapped ) // try masterpage mapping + { + SlidePersistPtr pMasterPersist = mpActualSlidePersist->getMasterPersist(); + if ( pMasterPersist ) + { + pClrMapPtr = pMasterPersist->getClrMap(); + if ( pClrMapPtr ) + bColorMapped = pClrMapPtr->getColorMap( nToken ); + } + } + oox::drawingml::ClrSchemePtr pClrSchemePtr( mpActualSlidePersist->getClrScheme() ); + if ( pClrSchemePtr ) + pClrSchemePtr->getColor( nToken, nColor ); + else + { + ::oox::drawingml::ThemePtr pTheme = mpActualSlidePersist->getTheme(); + if( pTheme ) + { + pTheme->getClrScheme().getColor( nToken, nColor ); + } + else + { + OSL_TRACE("OOX: PowerPointImport::mpThemePtr is NULL"); + } + } + } + return nColor; +} + +const ::oox::drawingml::Theme* PowerPointImport::getCurrentTheme() const +{ + return mpActualSlidePersist ? mpActualSlidePersist->getTheme().get() : 0; +} + +::oox::vml::Drawing* PowerPointImport::getVmlDrawing() +{ + return mpActualSlidePersist ? mpActualSlidePersist->getDrawing() : 0; +} + +const oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles() +{ + if ( !mpTableStyleList && maTableStyleListPath.getLength() ) + { + mpTableStyleList = oox::drawingml::table::TableStyleListPtr( new oox::drawingml::table::TableStyleList() ); + importFragment( new oox::drawingml::table::TableStyleListFragmentHandler( + *this, maTableStyleListPath, *mpTableStyleList ) ); + } + return mpTableStyleList;; +} + +::oox::drawingml::chart::ChartConverter& PowerPointImport::getChartConverter() +{ + return *mxChartConv; +} + +namespace { + +class PptGraphicHelper : public GraphicHelper +{ +public: + explicit PptGraphicHelper( const PowerPointImport& rFilter ); + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; +private: + const PowerPointImport& mrFilter; +}; + +PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : + GraphicHelper( rFilter.getComponentContext(), rFilter.getTargetFrame(), rFilter.getStorage() ), + mrFilter( rFilter ) +{ +} + +sal_Int32 PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const +{ + return mrFilter.getSchemeColor( nToken ); +} + +} // namespace + +GraphicHelper* PowerPointImport::implCreateGraphicHelper() const +{ + return new PptGraphicHelper( *this ); +} + +::oox::ole::VbaProject* PowerPointImport::implCreateVbaProject() const +{ + return new ::oox::ole::VbaProject( getComponentContext(), getModel(), CREATE_OUSTRING( "Impress" ) ); +} + +OUString PowerPointImport::implGetImplementationName() const +{ + return PowerPointImport_getImplementationName(); +} + +}} diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx new file mode 100644 index 000000000000..7437b378b324 --- /dev/null +++ b/oox/source/ppt/pptshape.cxx @@ -0,0 +1,279 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/pptshape.hxx" +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/textbody.hxx" + +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/drawing/HomogenMatrix3.hpp> +#include <com/sun/star/text/XText.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include "oox/ppt/slidepersist.hxx" + +using rtl::OUString; +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star; +using namespace ::com::sun::star::awt; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::drawing; + +namespace oox { namespace ppt { + +PPTShape::PPTShape( const oox::ppt::ShapeLocation eShapeLocation, const sal_Char* pServiceName ) +: Shape( pServiceName ) +, meShapeLocation( eShapeLocation ) +, mbReferenced( sal_False ) +{ +} + +PPTShape::~PPTShape() +{ +} + +void PPTShape::addShape( + oox::core::XmlFilterBase& rFilterBase, + const SlidePersist& rSlidePersist, + const oox::drawingml::Theme* pTheme, + const Reference< XShapes >& rxShapes, + const awt::Rectangle* pShapeRect, + ::oox::drawingml::ShapeIdMap* pShapeMap ) +{ + // only placeholder from layout are being inserted + if ( mnSubType && ( meShapeLocation == Master ) ) + return; + try + { + rtl::OUString sServiceName( msServiceName ); + if( sServiceName.getLength() ) + { + oox::drawingml::TextListStylePtr aMasterTextListStyle; + Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW ); + sal_Bool bClearText = sal_False; + + if ( sServiceName != OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) + { + switch( mnSubType ) + { + case XML_ctrTitle : + case XML_title : + { + const rtl::OUString sTitleShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.TitleTextShape" ) ); + sServiceName = sTitleShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); + } + break; + case XML_subTitle : + { + if ( ( meShapeLocation == Master ) || ( meShapeLocation == Layout ) ) + sServiceName = rtl::OUString(); + else { + const rtl::OUString sTitleShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.SubtitleShape" ) ); + sServiceName = sTitleShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); + } + } + break; + case XML_obj : + { + const rtl::OUString sOutlinerShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.OutlinerShape" ) ); + sServiceName = sOutlinerShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + } + break; + case XML_body : + { + const rtl::OUString sNotesShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.NotesShape" ) ); + const rtl::OUString sOutlinerShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.OutlinerShape" ) ); + if ( rSlidePersist.isNotesPage() ) + { + sServiceName = sNotesShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle(); + } + else + { + sServiceName = sOutlinerShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + } + } + break; + case XML_dt : + { + const rtl::OUString sDateTimeShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.DateTimeShape" ) ); + sServiceName = sDateTimeShapeService; + bClearText = sal_True; + } + break; + case XML_hdr : + { + const rtl::OUString sHeaderShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.HeaderShape" ) ); + sServiceName = sHeaderShapeService; + bClearText = sal_True; + } + break; + case XML_ftr : + { + const rtl::OUString sFooterShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.FooterShape" ) ); + sServiceName = sFooterShapeService; + bClearText = sal_True; + } + break; + case XML_sldNum : + { + const rtl::OUString sSlideNumberShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.SlideNumberShape" ) ); + sServiceName = sSlideNumberShapeService; + bClearText = sal_True; + } + break; + case XML_sldImg : + { + const rtl::OUString sPageShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PageShape" ) ); + sServiceName = sPageShapeService; + } + break; + + default: + break; + } + } + +/* + // use placeholder index if possible + if( mnSubType && getSubTypeIndex() && rSlidePersist.getMasterPersist().get() ) { + oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() ); + if( pPlaceholder.get() && pPlaceholder->getTextBody() ) { + TextListStylePtr pNewTextListStyle ( new TextListStyle() ); + + pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() ); + if( pPlaceholder->getMasterTextListStyle().get() ) + pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() ); + + aMasterTextListStyle = pNewTextListStyle; + } + } +*/ + if ( sServiceName.getLength() ) + { + if ( !aMasterTextListStyle.get() ) + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getOtherTextStyle(); + setMasterTextListStyle( aMasterTextListStyle ); + + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText ) ); + if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) ) + { + try + { + rtl::OUString aTitleText; + Reference< XTextRange > xText( xShape, UNO_QUERY_THROW ); + aTitleText = xText->getString(); + if ( aTitleText.getLength() && ( aTitleText.getLength() < 64 ) ) // just a magic value, but we don't want to set slide names which are too long + { + Reference< container::XNamed > xName( rSlidePersist.getPage(), UNO_QUERY_THROW ); + xName->setName( aTitleText ); + } + } + catch( uno::Exception& ) + { + + } + } + if( pShapeMap && msId.getLength() ) + { + (*pShapeMap)[ msId ] = shared_from_this(); + } + + // if this is a group shape, we have to add also each child shape + Reference< XShapes > xShapes( xShape, UNO_QUERY ); + if ( xShapes.is() ) + addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap ); + } + } + } + catch( const Exception& ) + { + } +} + +void PPTShape::applyShapeReference( const oox::drawingml::Shape& rReferencedShape ) +{ + Shape::applyShapeReference( rReferencedShape ); +} + +oox::drawingml::ShapePtr PPTShape::findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); + while( aRevIter != rShapes.rend() ) + { + if ( (*aRevIter)->getSubType() == nMasterPlaceholder ) + { + aShapePtr = *aRevIter; + break; + } + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); + aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren ); + if ( aShapePtr.get() ) + break; + aRevIter++; + } + return aShapePtr; +} + +oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); + while( aRevIter != rShapes.rend() ) + { + if ( (*aRevIter)->getSubTypeIndex() == nIdx ) + { + aShapePtr = *aRevIter; + break; + } + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); + aShapePtr = findPlaceholderByIndex( nIdx, rChildren ); + if ( aShapePtr.get() ) + break; + aRevIter++; + } + return aShapePtr; +} + +// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder +oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes ); + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes ); +} + +} } diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx new file mode 100644 index 000000000000..7df41ac3d714 --- /dev/null +++ b/oox/source/ppt/pptshapecontext.cxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/xml/sax/FastToken.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "oox/helper/attributelist.hxx" +#include "oox/ppt/pptshape.hxx" +#include "oox/ppt/pptshapecontext.hxx" +#include "oox/ppt/pptshapepropertiescontext.hxx" +#include "oox/ppt/slidepersist.hxx" +#include "oox/drawingml/shapestylecontext.hxx" +#include "oox/drawingml/fillpropertiesgroupcontext.hxx" +#include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/customshapegeometry.hxx" +#include "oox/drawingml/textbodycontext.hxx" + +using rtl::OUString; +using namespace oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +// CT_Shape +PPTShapeContext::PPTShapeContext( ContextHandler& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr ) +: oox::drawingml::ShapeContext( rParent, pMasterShapePtr, pShapePtr ) +, mpSlidePersistPtr( pSlidePersistPtr ) +{ +} + +oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); + while( aRevIter != rShapes.rend() ) + { + if ( (*aRevIter)->getSubType() == nMasterPlaceholder ) + { + if ( ( nSubTypeIndex == -1 ) || ( nSubTypeIndex == (*aRevIter)->getSubTypeIndex() ) ) + { + aShapePtr = *aRevIter; + break; + } + } + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); + aShapePtr = findPlaceholder( nMasterPlaceholder, nSubTypeIndex, rChildren ); + if ( aShapePtr.get() ) + break; + aRevIter++; + } + return aShapePtr; +} + +// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder +oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, + sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, nSubTypeIndex, rShapes ); + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, nSubTypeIndex, rShapes ); +} + +Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + // nvSpPr CT_ShapeNonVisual begin + // case PPT_TOKEN( drElemPr ): + // break; + case PPT_TOKEN( cNvPr ): + { + AttributeList aAttribs( xAttribs ); + mpShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); + mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); + mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + break; + } + case PPT_TOKEN( ph ): + { + sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); + mpShapePtr->setSubType( nSubType ); + mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + if ( nSubType ) + { + PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); + if ( pPPTShapePtr ) + { + oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation(); + if ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) + { + // inheriting properties from placeholder objects by cloning shape + sal_Int32 nFirstPlaceholder = 0; + sal_Int32 nSecondPlaceholder = 0; + switch( nSubType ) + { + case XML_ctrTitle : // slide/layout + nFirstPlaceholder = XML_ctrTitle; + nSecondPlaceholder = XML_title; + break; + + case XML_subTitle : // slide/layout + nFirstPlaceholder = XML_subTitle; + nSecondPlaceholder = XML_title; + break; + + case XML_obj : // slide/layout + nFirstPlaceholder = XML_obj; + nSecondPlaceholder = XML_body; + break; + + case XML_dt : // slide/layout/master/notes/notesmaster/handoutmaster + case XML_sldNum : // slide/layout/master/notes/notesmaster/handoutmaster + case XML_ftr : // slide/layout/master/notes/notesmaster/handoutmaster + case XML_hdr : // notes/notesmaster/handoutmaster + case XML_body : // slide/layout/master/notes/notesmaster + case XML_title : // slide/layout/master/ + case XML_chart : // slide/layout + case XML_tbl : // slide/layout + case XML_clipArt : // slide/layout + case XML_dgm : // slide/layout + case XML_media : // slide/layout + case XML_sldImg : // notes/notesmaster + case XML_pic : // slide/layout + nFirstPlaceholder = nSubType; + default: + break; + } + if ( nFirstPlaceholder ) + { + oox::drawingml::ShapePtr pPlaceholder; + if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, -1, mpSlidePersistPtr->getShapes()->getChildren() ); + else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects + { + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); + if ( pMasterPersist.get() ) + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, + pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + } + if ( pPlaceholder.get() ) + { + mpShapePtr->applyShapeReference( *pPlaceholder.get() ); + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); + if ( pPPTShape ) + pPPTShape->setReferenced( sal_True ); + } + } + } + } + + } + break; + } + + // nvSpPr CT_ShapeNonVisual end + + case PPT_TOKEN( spPr ): + xRet = new PPTShapePropertiesContext( *this, *mpShapePtr ); + break; + + case PPT_TOKEN( style ): + xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); + break; + + case PPT_TOKEN( txBody ): + { + oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody ); + xTextBody->getTextProperties().maPropertyMap[ PROP_FontIndependentLineSpacing ] <<= static_cast< sal_Bool >( sal_True ); + mpShapePtr->setTextBody( xTextBody ); + xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody ); + break; + } + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; +} + + +} } diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx new file mode 100644 index 000000000000..0ba36ee99417 --- /dev/null +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/xml/sax/FastToken.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "oox/helper/attributelist.hxx" +#include "oox/ppt/pptshape.hxx" +#include "oox/ppt/pptshapecontext.hxx" +#include "oox/ppt/pptshapegroupcontext.hxx" +#include "oox/drawingml/graphicshapecontext.hxx" +#include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/customshapegeometry.hxx" +#include "oox/drawingml/textbodycontext.hxx" +#include "oox/drawingml/connectorshapecontext.hxx" + +using rtl::OUString; +using namespace oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +PPTShapeGroupContext::PPTShapeGroupContext( + ContextHandler& rParent, + const oox::ppt::SlidePersistPtr pSlidePersistPtr, + const ShapeLocation eShapeLocation, + oox::drawingml::ShapePtr pMasterShapePtr, + oox::drawingml::ShapePtr pGroupShapePtr ) +: ShapeGroupContext( rParent, pMasterShapePtr, pGroupShapePtr ) +, mpSlidePersistPtr( pSlidePersistPtr ) +, meShapeLocation( eShapeLocation ) +{ +} + +Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( cNvPr ): + { + AttributeList aAttribs( xAttribs ); + mpGroupShapePtr->setHidden( aAttribs.getBool( XML_hidden, false ) ); + mpGroupShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); + mpGroupShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + break; + } + case PPT_TOKEN( ph ): + mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); + mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + break; + // nvSpPr CT_ShapeNonVisual end + + case PPT_TOKEN( grpSpPr ): + xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr ); + break; + case PPT_TOKEN( spPr ): + xRet = new oox::drawingml::ShapePropertiesContext( *this, *mpGroupShapePtr ); + break; +/* + case PPT_TOKEN( style ): + xRet = new ShapeStyleContext( getParser() ); + break; +*/ + case PPT_TOKEN( cxnSp ): // connector shape + xRet.set( new oox::drawingml::ConnectorShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.ConnectorShape" ) ) ) ); + break; + case PPT_TOKEN( grpSp ): // group shape + xRet.set( new PPTShapeGroupContext( *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) ); + break; + case PPT_TOKEN( sp ): // Shape + xRet.set( new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) ) ) ); + break; + case PPT_TOKEN( pic ): // CT_Picture + xRet.set( new oox::drawingml::GraphicShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) ); + break; + case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame + xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) ), true ) ); + break; + + } + if( !xRet.is() ) + xRet.set( this ); + + + return xRet; +} + +} } diff --git a/oox/source/ppt/pptshapepropertiescontext.cxx b/oox/source/ppt/pptshapepropertiescontext.cxx new file mode 100644 index 000000000000..bddd74f4837a --- /dev/null +++ b/oox/source/ppt/pptshapepropertiescontext.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/xml/sax/FastToken.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "oox/ppt/pptshape.hxx" +#include "oox/ppt/pptshapepropertiescontext.hxx" +#include "oox/ppt/slidepersist.hxx" +#include "oox/drawingml/shapestylecontext.hxx" +#include "oox/drawingml/fillpropertiesgroupcontext.hxx" +#include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/customshapegeometry.hxx" +#include "oox/drawingml/textbodycontext.hxx" + +using rtl::OUString; +using namespace oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +// CT_Shape +PPTShapePropertiesContext::PPTShapePropertiesContext( ContextHandler& rParent, ::oox::drawingml::Shape& rShape ) +: ShapePropertiesContext( rParent, rShape ) +{ +} + +Reference< XFastContextHandler > PPTShapePropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) + throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case A_TOKEN( xfrm ): + { + mrShape.getShapeProperties()[ PROP_IsPlaceholderDependent ] <<= sal_False; + + xRet = ShapePropertiesContext::createFastChildContext( aElementToken, xAttribs ); + } + break; + + default: + xRet = ShapePropertiesContext::createFastChildContext( aElementToken, xAttribs ); + break; + } + return xRet; +} + +} } diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx new file mode 100644 index 000000000000..6976c965ad83 --- /dev/null +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -0,0 +1,390 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" + +#include <com/sun/star/drawing/XMasterPagesSupplier.hpp> +#include <com/sun/star/drawing/XDrawPages.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/drawing/XMasterPageTarget.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/presentation/XPresentationPage.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> + +#include "oox/drawingml/theme.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/themefragmenthandler.hxx" +#include "oox/drawingml/textliststylecontext.hxx" +#include "oox/ppt/pptshape.hxx" +#include "oox/ppt/presentationfragmenthandler.hxx" +#include "oox/ppt/slidefragmenthandler.hxx" +#include "oox/ppt/layoutfragmenthandler.hxx" +#include "oox/ppt/pptimport.hxx" + +using rtl::OUString; +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw() +: FragmentHandler( rFilter, rFragmentPath ) +, mpTextListStyle( new TextListStyle ) +{ + TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() ); + TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() ); + while( aParagraphDefaultIter != rParagraphDefaulsVector.end() ) + { + // ppt is having zero bottom margin per default, whereas OOo is 0,5cm, + // so this attribute needs to be set always + (*aParagraphDefaultIter++)->getParaBottomMargin() = TextSpacing( 0 ); + } +} + +PresentationFragmentHandler::~PresentationFragmentHandler() throw() +{ + +} +void PresentationFragmentHandler::startDocument() throw (SAXException, RuntimeException) +{ +} + +void ResolveTextFields( XmlFilterBase& rFilter ) +{ + const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack(); + if ( rTextFields.size() ) + { + Reference< frame::XModel > xModel( rFilter.getModel() ); + oox::core::TextFieldStack::const_iterator aIter( rTextFields.begin() ); + while( aIter != rTextFields.end() ) + { + const OUString sURL = CREATE_OUSTRING( "URL" ); + Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW ); + Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW ); + + const oox::core::TextField& rTextField( *aIter++ ); + Reference< XPropertySet > xPropSet( rTextField.xTextField, UNO_QUERY ); + Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + if ( xPropSetInfo->hasPropertyByName( sURL ) ) + { + rtl::OUString aURL; + if ( xPropSet->getPropertyValue( sURL ) >>= aURL ) + { + const OUString sSlide = CREATE_OUSTRING( "#Slide " ); + const OUString sNotes = CREATE_OUSTRING( "#Notes " ); + sal_Bool bNotes = sal_False; + sal_Int32 nPageNumber = 0; + if ( aURL.match( sSlide ) ) + nPageNumber = aURL.copy( sSlide.getLength() ).toInt32(); + else if ( aURL.match( sNotes ) ) + { + nPageNumber = aURL.copy( sNotes.getLength() ).toInt32(); + bNotes = sal_True; + } + if ( nPageNumber ) + { + try + { + Reference< XDrawPage > xDrawPage; + xDrawPages->getByIndex( nPageNumber - 1 ) >>= xDrawPage; + if ( bNotes ) + { + Reference< ::com::sun::star::presentation::XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW ); + xDrawPage = xPresentationPage->getNotesPage(); + } + Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW ); + aURL = CREATE_OUSTRING( "#" ).concat( xNamed->getName() ); + xPropSet->setPropertyValue( sURL, Any( aURL ) ); + Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY); + Reference< text::XTextRange > xTextRange( rTextField.xTextCursor, UNO_QUERY ); + rTextField.xText->insertTextContent( xTextRange, xContent, sal_True ); + } + catch( uno::Exception& ) + { + } + } + } + } + } + } +} + +void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeException) +{ + // todo: localized progress bar text + const Reference< task::XStatusIndicator >& rxStatusIndicator( getFilter().getStatusIndicator() ); + if ( rxStatusIndicator.is() ) + rxStatusIndicator->start( rtl::OUString(), 10000 ); + + try + { + PowerPointImport& rFilter = dynamic_cast< PowerPointImport& >( getFilter() ); + + Reference< frame::XModel > xModel( rFilter.getModel() ); + Reference< drawing::XDrawPage > xSlide; + sal_uInt32 nSlide; + + // importing slide pages and its corresponding notes page + Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW ); + Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_QUERY_THROW ); + + for( nSlide = 0; nSlide < maSlidesVector.size(); nSlide++ ) + { + if ( rxStatusIndicator.is() ) + rxStatusIndicator->setValue( ( nSlide * 10000 ) / maSlidesVector.size() ); + + if( nSlide == 0 ) + xDrawPages->getByIndex( 0 ) >>= xSlide; + else + xSlide = xDrawPages->insertNewByIndex( nSlide ); + + OUString aSlideFragmentPath = getFragmentPathFromRelId( maSlidesVector[ nSlide ] ); + if( aSlideFragmentPath.getLength() > 0 ) + { + SlidePersistPtr pMasterPersistPtr; + SlidePersistPtr pSlidePersistPtr( new SlidePersist( rFilter, sal_False, sal_False, xSlide, + ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) ); + + FragmentHandlerRef xSlideFragmentHandler( new SlideFragmentHandler( rFilter, aSlideFragmentPath, pSlidePersistPtr, Slide ) ); + + // importing the corresponding masterpage/layout + OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideLayout" ) ); + if ( aLayoutFragmentPath.getLength() > 0 ) + { + // importing layout + RelationsRef xLayoutRelations = rFilter.importRelations( aLayoutFragmentPath ); + OUString aMasterFragmentPath = xLayoutRelations->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideMaster" ) ); + if( aMasterFragmentPath.getLength() ) + { + // check if the corresponding masterpage+layout has already been imported + std::vector< SlidePersistPtr >& rMasterPages( rFilter.getMasterPages() ); + std::vector< SlidePersistPtr >::iterator aIter( rMasterPages.begin() ); + while( aIter != rMasterPages.end() ) + { + if ( ( (*aIter)->getPath() == aMasterFragmentPath ) && ( (*aIter)->getLayoutPath() == aLayoutFragmentPath ) ) + { + pMasterPersistPtr = *aIter; + break; + } + aIter++; + } + if ( aIter == rMasterPages.end() ) + { // masterpersist not found, we have to load it + Reference< drawing::XDrawPage > xMasterPage; + Reference< drawing::XMasterPagesSupplier > xMPS( xModel, uno::UNO_QUERY_THROW ); + Reference< drawing::XDrawPages > xMasterPages( xMPS->getMasterPages(), uno::UNO_QUERY_THROW ); + + if( !(rFilter.getMasterPages().size() )) + xMasterPages->getByIndex( 0 ) >>= xMasterPage; + else + xMasterPage = xMasterPages->insertNewByIndex( xMasterPages->getCount() ); + + pMasterPersistPtr = SlidePersistPtr( new SlidePersist( rFilter, sal_True, sal_False, xMasterPage, + ShapePtr( new PPTShape( Master, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) ); + pMasterPersistPtr->setLayoutPath( aLayoutFragmentPath ); + rFilter.getMasterPages().push_back( pMasterPersistPtr ); + rFilter.setActualSlidePersist( pMasterPersistPtr ); + FragmentHandlerRef xMasterFragmentHandler( new SlideFragmentHandler( rFilter, aMasterFragmentPath, pMasterPersistPtr, Master ) ); + + // set the correct theme + OUString aThemeFragmentPath = xMasterFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "theme" ) ); + if( aThemeFragmentPath.getLength() > 0 ) + { + std::map< OUString, oox::drawingml::ThemePtr >& rThemes( rFilter.getThemes() ); + std::map< OUString, oox::drawingml::ThemePtr >::iterator aIter2( rThemes.find( aThemeFragmentPath ) ); + if( aIter2 == rThemes.end() ) + { + oox::drawingml::ThemePtr pThemePtr( new oox::drawingml::Theme() ); + pMasterPersistPtr->setTheme( pThemePtr ); + rFilter.importFragment( new ThemeFragmentHandler( rFilter, aThemeFragmentPath, *pThemePtr ) ); + rThemes[ aThemeFragmentPath ] = pThemePtr; + } + else + { + pMasterPersistPtr->setTheme( (*aIter2).second ); + } + } + importSlide( xMasterFragmentHandler, pMasterPersistPtr ); + rFilter.importFragment( new LayoutFragmentHandler( rFilter, aLayoutFragmentPath, pMasterPersistPtr ) ); + pMasterPersistPtr->createBackground( rFilter ); + pMasterPersistPtr->createXShapes( rFilter ); + } + } + } + + // importing slide page + pSlidePersistPtr->setMasterPersist( pMasterPersistPtr ); + pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() ); + Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY ); + if( xMasterPageTarget.is() ) + xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() ); + rFilter.getDrawPages().push_back( pSlidePersistPtr ); + rFilter.setActualSlidePersist( pSlidePersistPtr ); + importSlide( xSlideFragmentHandler, pSlidePersistPtr ); + pSlidePersistPtr->createBackground( rFilter ); + pSlidePersistPtr->createXShapes( rFilter ); + + // now importing the notes page + OUString aNotesFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "notesSlide" ) ); + if( aNotesFragmentPath.getLength() > 0 ) + { + Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY ); + if ( xPresentationPage.is() ) + { + Reference< XDrawPage > xNotesPage( xPresentationPage->getNotesPage() ); + if ( xNotesPage.is() ) + { + SlidePersistPtr pNotesPersistPtr( new SlidePersist( rFilter, sal_False, sal_True, xNotesPage, + ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) ); + FragmentHandlerRef xNotesFragmentHandler( new SlideFragmentHandler( getFilter(), aNotesFragmentPath, pNotesPersistPtr, Slide ) ); + rFilter.getNotesPages().push_back( pNotesPersistPtr ); + rFilter.setActualSlidePersist( pNotesPersistPtr ); + importSlide( xNotesFragmentHandler, pNotesPersistPtr ); + pNotesPersistPtr->createBackground( rFilter ); + pNotesPersistPtr->createXShapes( rFilter ); + } + } + } + } + } + ResolveTextFields( rFilter ); + } + catch( uno::Exception& ) + { + OSL_ENSURE( false, + (rtl::OString("oox::ppt::PresentationFragmentHandler::EndDocument(), " + "exception caught: ") + + rtl::OUStringToOString( + comphelper::anyToString( cppu::getCaughtException() ), + RTL_TEXTENCODING_UTF8 )).getStr() ); + + } + + // todo error handling; + if ( rxStatusIndicator.is() ) + rxStatusIndicator->end(); +} + +// CT_Presentation +Reference< XFastContextHandler > PresentationFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + switch( aElementToken ) + { + case PPT_TOKEN( presentation ): + case PPT_TOKEN( sldMasterIdLst ): + case PPT_TOKEN( notesMasterIdLst ): + case PPT_TOKEN( sldIdLst ): + break; + case PPT_TOKEN( sldMasterId ): + maSlideMasterVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); + break; + case PPT_TOKEN( sldId ): + maSlidesVector.push_back( xAttribs->getOptionalValue( R_TOKEN( id ) ) ); + break; + case PPT_TOKEN( notesMasterId ): + maNotesMasterVector.push_back( xAttribs->getOptionalValue(R_TOKEN( id ) ) ); + break; + case PPT_TOKEN( sldSz ): + maSlideSize = GetSize2D( xAttribs ); + break; + case PPT_TOKEN( notesSz ): + maNotesSize = GetSize2D( xAttribs ); + break; + case PPT_TOKEN( custShowLst ): + xRet.set( new CustomShowListContext( *this, maCustomShowList ) ); + break; + case PPT_TOKEN( defaultTextStyle ): + xRet.set( new TextListStyleContext( *this, *mpTextListStyle ) ); + break; + } + if ( !xRet.is() ) + xRet = getFastContextHandler(); + return xRet; +} + +bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlideFragmentHandler, + const SlidePersistPtr pSlidePersistPtr ) +{ + Reference< drawing::XDrawPage > xSlide( pSlidePersistPtr->getPage() ); + SlidePersistPtr pMasterPersistPtr( pSlidePersistPtr->getMasterPersist() ); + if ( pMasterPersistPtr.get() ) + { + const OUString sLayout = CREATE_OUSTRING( "Layout" ); + uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW ); + xSet->setPropertyValue( sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) ); + } + while( xSlide->getCount() ) + { + Reference< drawing::XShape > xShape; + xSlide->getByIndex(0) >>= xShape; + xSlide->remove( xShape ); + } + + Reference< XPropertySet > xPropertySet( xSlide, UNO_QUERY ); + if ( xPropertySet.is() ) + { + static const OUString sWidth = CREATE_OUSTRING( "Width" ); + static const OUString sHeight = CREATE_OUSTRING( "Height" ); + awt::Size& rPageSize( pSlidePersistPtr->isNotesPage() ? maNotesSize : maSlideSize ); + xPropertySet->setPropertyValue( sWidth, Any( rPageSize.Width ) ); + xPropertySet->setPropertyValue( sHeight, Any( rPageSize.Height ) ); + + oox::ppt::HeaderFooter aHeaderFooter( pSlidePersistPtr->getHeaderFooter() ); + if ( !pSlidePersistPtr->isMasterPage() ) + aHeaderFooter.mbSlideNumber = aHeaderFooter.mbHeader = aHeaderFooter.mbFooter = aHeaderFooter.mbDateTime = sal_False; + try + { + static const OUString sIsHeaderVisible = CREATE_OUSTRING( "IsHeaderVisible" ); + static const OUString sIsFooterVisible = CREATE_OUSTRING( "IsFooterVisible" ); + static const OUString sIsDateTimeVisible = CREATE_OUSTRING( "IsDateTimeVisible" ); + static const OUString sIsPageNumberVisible = CREATE_OUSTRING( "IsPageNumberVisible" ); + + if ( pSlidePersistPtr->isNotesPage() ) + xPropertySet->setPropertyValue( sIsHeaderVisible, Any( aHeaderFooter.mbHeader ) ); + xPropertySet->setPropertyValue( sIsFooterVisible, Any( aHeaderFooter.mbFooter ) ); + xPropertySet->setPropertyValue( sIsDateTimeVisible, Any( aHeaderFooter.mbDateTime ) ); + xPropertySet->setPropertyValue( sIsPageNumberVisible, Any( aHeaderFooter.mbSlideNumber ) ); + } + catch( uno::Exception& ) + { + } + } + pSlidePersistPtr->setPath( rxSlideFragmentHandler->getFragmentPath() ); + return getFilter().importFragment( rxSlideFragmentHandler ); +} + +} } + diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx new file mode 100644 index 000000000000..1d25abe5c941 --- /dev/null +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" + +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "oox/helper/propertyset.hxx" +#include "oox/core/xmlfilterbase.hxx" +#include "headerfootercontext.hxx" +#include "oox/ppt/backgroundproperties.hxx" +#include "oox/ppt/slidefragmenthandler.hxx" +#include "oox/ppt/slidetimingcontext.hxx" +#include "oox/ppt/slidetransitioncontext.hxx" +#include "oox/ppt/slidemastertextstylescontext.hxx" +#include "oox/ppt/pptshapegroupcontext.hxx" +#include "oox/ppt/pptshape.hxx" +#include "oox/vml/vmldrawing.hxx" +#include "oox/vml/vmldrawingfragment.hxx" +#include "oox/drawingml/clrschemecontext.hxx" + + +using rtl::OUString; +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::container; + +namespace oox { namespace ppt { + +SlideFragmentHandler::SlideFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath, SlidePersistPtr pPersistPtr, const ShapeLocation eShapeLocation ) throw() +: FragmentHandler( rFilter, rFragmentPath ) +, mpSlidePersistPtr( pPersistPtr ) +, meShapeLocation( eShapeLocation ) +{ + OUString aVMLDrawingFragmentPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "vmlDrawing" ) ); + if( aVMLDrawingFragmentPath.getLength() > 0 ) + getFilter().importFragment( new oox::vml::DrawingFragment( + getFilter(), aVMLDrawingFragmentPath, *pPersistPtr->getDrawing() ) ); +} + +SlideFragmentHandler::~SlideFragmentHandler() throw() +{ + // convert and insert all VML shapes (mostly form controls) + mpSlidePersistPtr->getDrawing()->convertAndInsert(); +} + +Reference< XFastContextHandler > SlideFragmentHandler::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + AttributeList aAttribs( xAttribs ); + + switch( aElementToken ) + { + case PPT_TOKEN( sldMaster ): // CT_SlideMaster + case PPT_TOKEN( handoutMaster ): // CT_HandoutMaster + case PPT_TOKEN( sld ): // CT_CommonSlideData + { + AttributeList attribs( xAttribs ); + + Reference< XDrawPage > xSlide( mpSlidePersistPtr->getPage() ); + PropertyMap aPropMap; + PropertySet aSlideProp( xSlide ); + + aPropMap[ PROP_Visible ] = Any( attribs.getBool( XML_show, sal_True ) ); + aSlideProp.setProperties( aPropMap ); + + break; + } + case PPT_TOKEN( notes ): // CT_NotesSlide + case PPT_TOKEN( notesMaster ): // CT_NotesMaster + break; + case PPT_TOKEN( cSld ): // CT_CommonSlideData + maSlideName = xAttribs->getOptionalValue(XML_name); + break; + + case PPT_TOKEN( spTree ): // CT_GroupShape + { + xRet.set( new PPTShapeGroupContext( + *this, mpSlidePersistPtr, meShapeLocation, mpSlidePersistPtr->getShapes(), + oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GroupShape" ) ) ) ); + } + break; + + case PPT_TOKEN( controls ): + xRet = getFastContextHandler(); + break; + case PPT_TOKEN( control ): + { + ::oox::vml::ControlInfo aInfo; + aInfo.setShapeId( aAttribs.getInteger( XML_spid, 0 ) ); + aInfo.maFragmentPath = getFragmentPathFromRelId( aAttribs.getString( R_TOKEN( id ), OUString() ) ); + aInfo.maName = aAttribs.getXString( XML_name, OUString() ); + mpSlidePersistPtr->getDrawing()->registerControl( aInfo ); + } + return xRet; + + case PPT_TOKEN( timing ): // CT_SlideTiming + xRet.set( new SlideTimingContext( *this, mpSlidePersistPtr->getTimeNodeList() ) ); + break; + case PPT_TOKEN( transition ): // CT_SlideTransition + xRet.set( new SlideTransitionContext( *this, xAttribs, maSlideProperties ) ); + break; + case PPT_TOKEN( hf ): + xRet.set( new HeaderFooterContext( *this, xAttribs, mpSlidePersistPtr->getHeaderFooter() ) ); + break; + + // BackgroundGroup + case PPT_TOKEN( bgPr ): // CT_BackgroundProperties + { + FillPropertiesPtr pFillPropertiesPtr( new FillProperties ); + xRet.set( new BackgroundPropertiesContext( *this, *pFillPropertiesPtr ) ); + mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); + } + break; + + case PPT_TOKEN( bgRef ): // a:CT_StyleMatrixReference + { + FillPropertiesPtr pFillPropertiesPtr( new FillProperties( + *mpSlidePersistPtr->getTheme()->getFillStyle( xAttribs->getOptionalValue( XML_idx ).toInt32() ) ) ); + xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColorRef() ) ); + mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); + } + break; + + case PPT_TOKEN( clrMap ): // CT_ColorMapping + { + oox::drawingml::ClrMapPtr pClrMapPtr( new oox::drawingml::ClrMap() ); + xRet.set( new oox::drawingml::clrMapContext( *this, xAttribs, *pClrMapPtr ) ); + mpSlidePersistPtr->setClrMap( pClrMapPtr ); + } + break; + case PPT_TOKEN( clrMapOvr ): // CT_ColorMappingOverride + case PPT_TOKEN( sldLayoutIdLst ): // CT_SlideLayoutIdList + break; + case PPT_TOKEN( txStyles ): // CT_SlideMasterTextStyles + xRet.set( new SlideMasterTextStylesContext( *this, mpSlidePersistPtr ) ); + break; + case PPT_TOKEN( custDataLst ): // CT_CustomerDataList + case PPT_TOKEN( tagLst ): // CT_TagList + break; + } + + if( !xRet.is() ) + xRet = getFastContextHandler(); + + return xRet; +} + +void SAL_CALL SlideFragmentHandler::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + try + { + Reference< XDrawPage > xSlide( mpSlidePersistPtr->getPage() ); + PropertySet aSlideProp( xSlide ); + aSlideProp.setProperties( maSlideProperties ); + if ( maSlideName.getLength() ) + { + Reference< XNamed > xNamed( xSlide, UNO_QUERY ); + if( xNamed.is() ) + xNamed->setName( maSlideName ); + } + } + catch( uno::Exception& ) + { + OSL_ENSURE( false, + (rtl::OString("oox::ppt::SlideFragmentHandler::EndElement(), " + "exception caught: ") + + rtl::OUStringToOString( + comphelper::anyToString( cppu::getCaughtException() ), + RTL_TEXTENCODING_UTF8 )).getStr() ); + } +} + +} } + diff --git a/oox/source/ppt/slidemastertextstylescontext.cxx b/oox/source/ppt/slidemastertextstylescontext.cxx new file mode 100644 index 000000000000..d4c777102a0a --- /dev/null +++ b/oox/source/ppt/slidemastertextstylescontext.cxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/drawingml/textliststyle.hxx" +#include "oox/drawingml/textliststylecontext.hxx" +#include "oox/ppt/slidemastertextstylescontext.hxx" + +using rtl::OUString; +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +SlideMasterTextStylesContext::SlideMasterTextStylesContext( ContextHandler& rParent, SlidePersistPtr pSlidePersistPtr ) +: ContextHandler( rParent ) +, mpSlidePersistPtr( pSlidePersistPtr ) +{ +} + +SlideMasterTextStylesContext::~SlideMasterTextStylesContext() +{ +} + +Reference< XFastContextHandler > SlideMasterTextStylesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /* xAttribs */ ) throw (SAXException, RuntimeException) +{ + oox::drawingml::TextListStylePtr aTextListStylePtr; + Reference< XFastContextHandler > xRet; + switch( aElementToken ) + { + case PPT_TOKEN( titleStyle ): + { + aTextListStylePtr = mpSlidePersistPtr->getTitleTextStyle(); + break; + } + case PPT_TOKEN( bodyStyle ): + { + aTextListStylePtr = mpSlidePersistPtr->getBodyTextStyle(); + break; + } + case PPT_TOKEN( notesStyle ): + { + aTextListStylePtr = mpSlidePersistPtr->getNotesTextStyle(); + break; + } + case PPT_TOKEN( otherStyle ): + { + aTextListStylePtr = mpSlidePersistPtr->getOtherTextStyle(); + break; + } + } + if ( aTextListStylePtr ) // sj: the master list style is the last instance of from where properties + { // are obtained. i got some documents without having the textsize set at + for ( int i = 0; i < 9; i++ ) // any point, the master reference application is using 18pt then + aTextListStylePtr->getListStyle()[ i ]->getTextCharacterProperties().moHeight = 1800; + xRet.set( new oox::drawingml::TextListStyleContext( *this, *aTextListStylePtr ) ); + } + if( !xRet.is() ) + xRet.set( this ); + + return xRet; +} + +} } diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx new file mode 100644 index 000000000000..7f8fba345bd6 --- /dev/null +++ b/oox/source/ppt/slidepersist.cxx @@ -0,0 +1,317 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/helper/propertyset.hxx" +#include "oox/ppt/timenode.hxx" +#include "oox/ppt/pptshape.hxx" +#include "oox/ppt/slidepersist.hxx" +#include "oox/drawingml/fillproperties.hxx" +#include "oox/vml/vmldrawing.hxx" +#include "oox/core/xmlfilterbase.hxx" + +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/animations/XAnimationNodeSupplier.hpp> + +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::animations; + +namespace oox { namespace ppt { + +SlidePersist::SlidePersist( XmlFilterBase& rFilter, sal_Bool bMaster, sal_Bool bNotes, + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxPage, + oox::drawingml::ShapePtr pShapesPtr, const drawingml::TextListStylePtr & pDefaultTextStyle ) +: mpDrawingPtr( new oox::vml::Drawing( rFilter, rxPage, oox::vml::VMLDRAWING_POWERPOINT ) ) +, mxPage( rxPage ) +, maShapesPtr( pShapesPtr ) +, mnLayoutValueToken( 0 ) +, mbMaster( bMaster ) +, mbNotes ( bNotes ) +, maDefaultTextStylePtr( pDefaultTextStyle ) +, maTitleTextStylePtr( new oox::drawingml::TextListStyle ) +, maBodyTextStylePtr( new oox::drawingml::TextListStyle ) +, maNotesTextStylePtr( new oox::drawingml::TextListStyle ) +, maOtherTextStylePtr( new oox::drawingml::TextListStyle ) +{ + if ( pDefaultTextStyle ) + { + /* + maTitleTextStylePtr->apply( *pDefaultTextStyle.get() ); + maBodyTextStylePtr->apply( *pDefaultTextStyle.get() ); + maNotesTextStylePtr->apply( *pDefaultTextStyle.get() ); + */ + maOtherTextStylePtr->apply( *pDefaultTextStyle.get() ); + } +} + +SlidePersist::~SlidePersist() +{ + +} + +sal_Int16 SlidePersist::getLayoutFromValueToken() +{ + sal_Int16 nLayout = 20; // 20 == blanc (so many magic numbers :-( the description at com.sun.star.presentation.DrawPage.Layout does not help) + switch( mnLayoutValueToken ) + { + case XML_blank: nLayout = 20; break; + case XML_chart: nLayout = 2; break; + case XML_chartAndTx: nLayout = 7; break; + case XML_clipArtAndTx: nLayout = 9; break; + case XML_clipArtAndVertTx: nLayout = 24; break; + case XML_fourObj: nLayout = 18; break; + case XML_obj: nLayout = 11; break; + case XML_objAndTx: nLayout = 13; break; + case XML_objOverTx: nLayout = 14; break; + case XML_tbl: nLayout = 8; break; + case XML_title: nLayout = 0; break; + case XML_titleOnly: nLayout = 19; break; + case XML_twoObj: + case XML_twoColTx: nLayout = 3; break; + case XML_twoObjAndTx: nLayout = 15; break; + case XML_twoObjOverTx: nLayout = 16; break; + case XML_tx: nLayout = 1; break; + case XML_txAndChart: nLayout = 4; break; + case XML_txAndClipArt: nLayout = 6; break; + case XML_txAndMedia: nLayout = 6; break; + case XML_txAndObj: nLayout = 10; break; + case XML_txAndTwoObj: nLayout = 12; break; + case XML_txOverObj: nLayout = 17; break; + case XML_vertTitleAndTx: nLayout = 22; break; + case XML_vertTitleAndTxOverChart: nLayout = 21; break; + case XML_vertTx: nLayout = 23; break; + + case XML_twoTxTwoObj: + case XML_twoObjAndObj: + case XML_objTx: + case XML_picTx: + case XML_secHead: + case XML_objOnly: + case XML_objAndTwoObj: + case XML_mediaAndTx: + case XML_dgm: + case XML_cust: + default: + nLayout = 20; + } + return nLayout; +} + +void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) +{ + applyTextStyles( rFilterBase ); + + Reference< XShapes > xShapes( getPage(), UNO_QUERY ); + + std::vector< oox::drawingml::ShapePtr >& rShapes( maShapesPtr->getChildren() ); + std::vector< oox::drawingml::ShapePtr >::iterator aShapesIter( rShapes.begin() ); + while( aShapesIter != rShapes.end() ) + { + std::vector< oox::drawingml::ShapePtr >& rChildren( (*aShapesIter++)->getChildren() ); + std::vector< oox::drawingml::ShapePtr >::iterator aChildIter( rChildren.begin() ); + while( aChildIter != rChildren.end() ) + { + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( (*aChildIter).get() ); + if ( pPPTShape ) + pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, 0, &getShapeMap() ); + else + (*aChildIter)->addShape( rFilterBase, getTheme().get(), xShapes, 0, &getShapeMap() ); + aChildIter++; + } + } + + Reference< XAnimationNodeSupplier > xNodeSupplier( getPage(), UNO_QUERY); + if( xNodeSupplier.is() ) + { + Reference< XAnimationNode > xNode( xNodeSupplier->getAnimationNode() ); + if( xNode.is() && !maTimeNodeList.empty() ) + { + SlidePersistPtr pSlidePtr( shared_from_this() ); + TimeNodePtr pNode(maTimeNodeList.front()); + OSL_ENSURE( pNode, "pNode" ); + + pNode->setNode( rFilterBase, xNode, pSlidePtr ); + } + } +} + +void SlidePersist::createBackground( const XmlFilterBase& rFilterBase ) +{ + if ( mpBackgroundPropertiesPtr ) + { + try + { + sal_Int32 nPhClr = API_RGB_TRANSPARENT; + if ( maBackgroundColorRef.isUsed() ) + nPhClr = maBackgroundColorRef.getColor( rFilterBase.getGraphicHelper() ); + + PropertyMap aPropMap; + static const rtl::OUString sBackground( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ); + uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xPropertySet( aPropMap.makePropertySet() ); + PropertySet aPropSet( xPropertySet ); + mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), + rFilterBase.getGraphicHelper(), oox::drawingml::FillProperties::DEFAULT_IDS, 0, nPhClr ); + xPagePropSet->setPropertyValue( sBackground, Any( xPropertySet ) ); + } + catch( Exception ) + { + } + } +} + +void setTextStyle( Reference< beans::XPropertySet >& rxPropSet, const XmlFilterBase& rFilter, + oox::drawingml::TextListStylePtr& pTextListStylePtr, int nLevel ) +{ + ::oox::drawingml::TextParagraphPropertiesPtr pTextParagraphPropertiesPtr( pTextListStylePtr->getListStyle()[ nLevel ] ); + if( pTextParagraphPropertiesPtr == NULL ) + { + // no properties. return + return; + } + + PropertyMap& rTextParagraphPropertyMap( pTextParagraphPropertiesPtr->getTextParagraphPropertyMap() ); + + PropertySet aPropSet( rxPropSet ); + aPropSet.setProperties( rTextParagraphPropertyMap ); + pTextParagraphPropertiesPtr->getTextCharacterProperties().pushToPropSet( aPropSet, rFilter ); +} + +void SlidePersist::applyTextStyles( const XmlFilterBase& rFilterBase ) +{ + if ( mbMaster ) + { + try + { + Reference< style::XStyleFamiliesSupplier > aXStyleFamiliesSupplier( rFilterBase.getModel(), UNO_QUERY_THROW ); + Reference< container::XNameAccess > aXNameAccess( aXStyleFamiliesSupplier->getStyleFamilies() ); + Reference< container::XNamed > aXNamed( mxPage, UNO_QUERY_THROW ); + + if ( aXNameAccess.is() && aXNamed.is() ) + { + oox::drawingml::TextListStylePtr pTextListStylePtr; + rtl::OUString aStyle; + rtl::OUString aFamily; + + const rtl::OUString sOutline( RTL_CONSTASCII_USTRINGPARAM( "outline1" ) ); + const rtl::OUString sTitle( RTL_CONSTASCII_USTRINGPARAM( "title" ) ); + const rtl::OUString sStandard( RTL_CONSTASCII_USTRINGPARAM( "standard" ) ); + const rtl::OUString sSubtitle( RTL_CONSTASCII_USTRINGPARAM( "subtitle" ) ); + + for( int i = 0; i < 4; i++ ) // todo: aggregation of bodystyle (subtitle) + { + switch( i ) + { + case 0 : // title style + { + pTextListStylePtr = maTitleTextStylePtr; + aStyle = sTitle; + aFamily= aXNamed->getName(); + break; + } + case 1 : // body style + { + pTextListStylePtr = maBodyTextStylePtr; + aStyle = sOutline; + aFamily= aXNamed->getName(); + break; + } + case 3 : // notes style + { + pTextListStylePtr = maNotesTextStylePtr; + aStyle = sTitle; + aFamily= aXNamed->getName(); + break; + } + case 4 : // standard style + { + pTextListStylePtr = maOtherTextStylePtr; + aStyle = sStandard; + aFamily = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ); + break; + } + case 5 : // subtitle + { + pTextListStylePtr = maBodyTextStylePtr; + aStyle = sSubtitle; + aFamily = aXNamed->getName(); + break; + } + } + Reference< container::XNameAccess > xFamilies; + if ( aXNameAccess->hasByName( aFamily ) ) + { + if( aXNameAccess->getByName( aFamily ) >>= xFamilies ) + { + if ( xFamilies->hasByName( aStyle ) ) + { + Reference< style::XStyle > aXStyle; + if ( xFamilies->getByName( aStyle ) >>= aXStyle ) + { + Reference< beans::XPropertySet > xPropSet( aXStyle, UNO_QUERY_THROW ); + setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, 0 ); + setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, 0 ); + if ( i == 1 /* BodyStyle */ ) + { + for ( int nLevel = 1; nLevel < 5; nLevel++ ) + { + { + sal_Char pOutline[ 9 ] = "outline1"; + pOutline[ 7 ] = static_cast< sal_Char >( '0' + nLevel ); + rtl::OUString sOutlineStyle( rtl::OUString::createFromAscii( pOutline ) ); + if ( xFamilies->hasByName( sOutlineStyle ) ) + { + xFamilies->getByName( sOutlineStyle ) >>= aXStyle; + if( aXStyle.is() ) + xPropSet = Reference< beans::XPropertySet >( aXStyle, UNO_QUERY_THROW ); + } + } + setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, nLevel ); + setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, nLevel ); + } + } + } + } + } + } + } + } + } + catch( Exception& ) + { + } + } +} + +} } + diff --git a/oox/source/ppt/slidetimingcontext.cxx b/oox/source/ppt/slidetimingcontext.cxx new file mode 100644 index 000000000000..4357e14ea08e --- /dev/null +++ b/oox/source/ppt/slidetimingcontext.cxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/slidetimingcontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" + +#include "oox/ppt/backgroundproperties.hxx" +#include "oox/ppt/slidefragmenthandler.hxx" +#include "oox/drawingml/shapegroupcontext.hxx" +#include "oox/helper/attributelist.hxx" +#include "oox/ppt/timenodelistcontext.hxx" +#include "buildlistcontext.hxx" + +using rtl::OUString; +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::container; + +namespace oox { namespace ppt { + +SlideTimingContext::SlideTimingContext( ContextHandler& rParent, TimeNodePtrList & aTimeNodeList ) throw() + : ContextHandler( rParent ) + , maTimeNodeList( aTimeNodeList ) +{ +} + +SlideTimingContext::~SlideTimingContext() throw() +{ + +} + +void SlideTimingContext::endFastElement( sal_Int32 /*aElement*/ ) throw ( SAXException, RuntimeException) +{ +} + + +Reference< XFastContextHandler > SlideTimingContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( bldLst ): + xRet.set( new BuildListContext( *this, xAttribs, maTimeNodeList ) ); + break; + case PPT_TOKEN( extLst ): + return xRet; + case PPT_TOKEN( tnLst ): + // timing nodes + { + xRet.set( new TimeNodeListContext( *this, maTimeNodeList ) ); + } + break; + + default: + break; + } + + if( !xRet.is() ) + xRet.set(this); + + return xRet; +} + +void SAL_CALL SlideTimingContext::endDocument( ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException) +{ + +} + +} } + diff --git a/oox/source/ppt/slidetransition.cxx b/oox/source/ppt/slidetransition.cxx new file mode 100644 index 000000000000..a380a4d945e1 --- /dev/null +++ b/oox/source/ppt/slidetransition.cxx @@ -0,0 +1,418 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/slidetransition.hxx" + +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/presentation/AnimationSpeed.hpp> +#include <com/sun/star/animations/TransitionType.hpp> +#include <com/sun/star/animations/TransitionSubType.hpp> + +#include "oox/helper/helper.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/token/namespaces.hxx" +#include "oox/token/tokens.hxx" +#include "pptfilterhelpers.hxx" + +using rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::presentation; + +namespace oox { namespace ppt { + + + SlideTransition::SlideTransition() + : mnTransitionType( 0 ) + , mnTransitionSubType( 0 ) + , mbTransitionDirectionNormal( true ) + , mnAnimationSpeed( AnimationSpeed_FAST ) + , mnFadeColor( 0 ) + , mbMode( true ) + { + + } + + + SlideTransition::SlideTransition(const OUString & sFilterName) + : mnTransitionType( 0 ) + , mnTransitionSubType( 0 ) + , mbTransitionDirectionNormal( true ) + , mnAnimationSpeed( AnimationSpeed_FAST ) + , mnFadeColor( 0 ) + , mbMode( true ) + { + const transition *p = transition::find( sFilterName ); + if( p ) + { + mnTransitionType = p->mnType; + mnTransitionSubType = p->mnSubType; + mbTransitionDirectionNormal = p->mbDirection; + } + } + + + void SlideTransition::setSlideProperties( PropertyMap & aProps ) + { + try + { + aProps[ PROP_TransitionType ] <<= mnTransitionType; + aProps[ PROP_TransitionSubtype ] <<= mnTransitionSubType; + aProps[ PROP_TransitionDirection ] <<= mbTransitionDirectionNormal; + aProps[ PROP_Speed ] <<= mnAnimationSpeed; + aProps[ PROP_TransitionFadeColor ] <<= mnFadeColor; + } + catch( Exception& ) + { + // should not happen + OSL_ENSURE( false, "exception raised" ); + } + } + + void SlideTransition::setTransitionFilterProperties( const Reference< XTransitionFilter > & xFilter ) + { + try + { + xFilter->setTransition( mnTransitionType ); + xFilter->setSubtype( mnTransitionSubType ); + xFilter->setDirection( mbTransitionDirectionNormal ); + xFilter->setFadeColor( mnFadeColor ); + xFilter->setMode( mbMode ); + } + catch( Exception& ) + { + // should not happen + OSL_ENSURE( false, "exception raised" ); + } + } + + + void SlideTransition::setOoxTransitionSpeed( sal_Int32 nToken) + { + switch( nToken ) + { + /* In case you want to use time values in second, + * the speed values are located in the PPT97 importer + * sd/source/filter/ppt/ppt97animations.cxx:664 + * (void Ppt97Animation::UpdateCacheData() const) + */ + case XML_fast: + mnAnimationSpeed = AnimationSpeed_FAST; + break; + case XML_med: + mnAnimationSpeed = AnimationSpeed_MEDIUM; + break; + case XML_slow: + mnAnimationSpeed = AnimationSpeed_SLOW; + break; + default: + // should not happen. just ignore + break; + } + } + + + + sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType ) + { + sal_Int16 nOdpDirection; + nOdpDirection = ooxToOdpBorderDirections( nOoxType ); + if( nOdpDirection == 0 ) + { + nOdpDirection = ooxToOdpCornerDirections( nOoxType ); + } + return nOdpDirection; + } + + + sal_Int16 SlideTransition::ooxToOdpBorderDirections( ::sal_Int32 nOoxType ) + { + sal_Int16 nOdpDirection; + switch( nOoxType ) + { + case XML_d: + nOdpDirection = TransitionSubType::FROMTOP; + break; + case XML_l: + nOdpDirection = TransitionSubType::FROMLEFT; + break; + case XML_r: + nOdpDirection = TransitionSubType::FROMRIGHT; + break; + case XML_u: + nOdpDirection = TransitionSubType::FROMBOTTOM; + break; + default: + nOdpDirection= 0; + break; + } + return nOdpDirection; + } + + sal_Int16 SlideTransition::ooxToOdpSideDirections( ::sal_Int32 nOoxType ) + { + sal_Int16 nOdpDirection; + switch( nOoxType ) + { + case XML_d: + case XML_u: + nOdpDirection = TransitionSubType::TOPTOBOTTOM; + break; + case XML_l: + case XML_r: + nOdpDirection = TransitionSubType::LEFTTORIGHT; + break; + default: + nOdpDirection= 0; + break; + } + return nOdpDirection; + } + + sal_Bool SlideTransition::ooxToOdpSideDirectionsDirectionNormal( ::sal_Int32 nOoxType ) + { + sal_Bool nOdpDirection = true; + switch( nOoxType ) + { + case XML_u: + case XML_l: + nOdpDirection = false; + break; + } + return nOdpDirection; + } + + sal_Int16 SlideTransition::ooxToOdpCornerDirections( ::sal_Int32 nOoxType ) + { + sal_Int16 nOdpDirection; + switch( nOoxType ) + { + case XML_lu: + nOdpDirection = TransitionSubType::FROMBOTTOMRIGHT; + break; + case XML_ru: + nOdpDirection = TransitionSubType::FROMBOTTOMLEFT; + break; + case XML_ld: + nOdpDirection = TransitionSubType::FROMTOPRIGHT; + break; + case XML_rd: + nOdpDirection = TransitionSubType::FROMTOPLEFT; + break; + default: + nOdpDirection = 0; + break; + } + return nOdpDirection; + } + + + sal_Int16 SlideTransition::ooxToOdpDirection( ::sal_Int32 nOoxType ) + { + sal_Int16 nOdpDir; + switch( nOoxType ) + { + case XML_vert: + nOdpDir = TransitionSubType::VERTICAL; + break; + case XML_horz: + nOdpDir = TransitionSubType::HORIZONTAL; + break; + default: + nOdpDir = 0; + break; + } + return nOdpDir; + } + + void SlideTransition::setOoxTransitionType( ::sal_Int32 OoxType, ::sal_Int32 param1, ::sal_Int32 param2 ) + { + switch( OoxType ) + { + case PPT_TOKEN( blinds ): + mnTransitionType = TransitionType::BLINDSWIPE; + mnTransitionSubType = ooxToOdpDirection( param1 ); + break; + case PPT_TOKEN( checker ): + mnTransitionType = TransitionType::CHECKERBOARDWIPE; + switch ( param1 ) + { + case XML_vert: + mnTransitionSubType = TransitionSubType::DOWN; + break; + case XML_horz: + mnTransitionSubType = TransitionSubType::ACROSS; + break; + default: + break; + } + break; + case PPT_TOKEN( comb ): + mnTransitionType = TransitionType::PUSHWIPE; + switch( param1 ) + { + case XML_vert: + mnTransitionSubType = TransitionSubType::COMBVERTICAL; + break; + case XML_horz: + mnTransitionSubType = TransitionSubType::COMBHORIZONTAL; + break; + default: + break; + } + break; + case PPT_TOKEN( cover ): + mnTransitionType = TransitionType::SLIDEWIPE; + mnTransitionSubType = ooxToOdpEightDirections( param1 ); + break; + case PPT_TOKEN( pull ): // uncover + mnTransitionType = TransitionType::SLIDEWIPE; + mnTransitionSubType = ooxToOdpEightDirections( param1 ); + mbTransitionDirectionNormal = false; + break; + case PPT_TOKEN( cut ): + // The binfilter seems to ignore this transition. + // Fade to black instead if thrBlk is true. + if( param1 ) + { + mnTransitionType = TransitionType::FADE; + mnTransitionSubType = TransitionSubType::FADEOVERCOLOR; + } + OSL_TRACE( "OOX: cut transition fallback." ); + break; + case PPT_TOKEN( fade ): + mnTransitionType = TransitionType::FADE; + if( param1 ) + { + mnTransitionSubType = TransitionSubType::FADEOVERCOLOR; + } + else + { + mnTransitionSubType = TransitionSubType::CROSSFADE; + } + break; + case PPT_TOKEN( push ): + mnTransitionType = TransitionType::PUSHWIPE; + mnTransitionSubType = ooxToOdpBorderDirections( param1 ); + break; + case PPT_TOKEN( wipe ): + mnTransitionType = TransitionType::BARWIPE; + mnTransitionSubType = ooxToOdpSideDirections( param1 ); + mbTransitionDirectionNormal = ooxToOdpSideDirectionsDirectionNormal( param1 ); + break; + case PPT_TOKEN( split ): + mnTransitionType = TransitionType::BARNDOORWIPE; + mnTransitionSubType = ooxToOdpDirection( param1 ); + if( param2 == XML_in ) + { + // reverse + mbTransitionDirectionNormal = false; + } + break; + case PPT_TOKEN( wheel ): + mnTransitionType = TransitionType::PINWHEELWIPE; + switch( param1 ) + { + case 1: + mnTransitionSubType = TransitionSubType::ONEBLADE; + break; + case 2: + mnTransitionSubType = TransitionSubType::TWOBLADEVERTICAL; + break; + case 3: + mnTransitionSubType = TransitionSubType::THREEBLADE; + break; + case 4: + mnTransitionSubType = TransitionSubType::FOURBLADE; + break; + case 8: + mnTransitionSubType = TransitionSubType::EIGHTBLADE; + break; + default: + OSL_TRACE( "OOX: strange number of blades for thw wheel-wipe %d", param1 ); + if( param1 > 8 ) + { + mnTransitionSubType = TransitionSubType::EIGHTBLADE; + } + else if( param1 > 4 ) + { + mnTransitionSubType = TransitionSubType::FOURBLADE; + } + else if( param1 == 0) + { + mnTransitionSubType = TransitionSubType::ONEBLADE; + } + break; + } + break; + case PPT_TOKEN( randomBar ): + mnTransitionType = TransitionType::RANDOMBARWIPE; + mnTransitionSubType = ooxToOdpDirection( param1 ); + break; + case PPT_TOKEN( circle ): + mnTransitionType = TransitionType::ELLIPSEWIPE; + mnTransitionSubType = TransitionSubType::CIRCLE; + break; + case PPT_TOKEN( diamond ): + mnTransitionType = TransitionType::IRISWIPE; + mnTransitionSubType = TransitionSubType::DIAMOND; + break; + case PPT_TOKEN( dissolve ): + mnTransitionType = TransitionType::DISSOLVE; + mnTransitionSubType = TransitionSubType::DEFAULT; + break; + case PPT_TOKEN( newsflash ): + // this is what the PPT binary filter does.... not sure I agree. + mnTransitionType = TransitionType::FOURBOXWIPE; + mnTransitionSubType = TransitionSubType::CORNERSOUT; + break; + case PPT_TOKEN( plus ): + mnTransitionType = TransitionType::FOURBOXWIPE; + mnTransitionSubType = TransitionSubType::CORNERSOUT; + break; + case PPT_TOKEN( random ): + mnTransitionType = TransitionType::RANDOM; + mnTransitionSubType = TransitionSubType::DEFAULT; + break; + case PPT_TOKEN( wedge ): + mnTransitionType = TransitionType::FANWIPE; + mnTransitionSubType = TransitionSubType::CENTERTOP; + break; + case PPT_TOKEN( zoom ): + mnTransitionType = TransitionType::ZOOM; + mnTransitionSubType = TransitionSubType::DEFAULT; + break; + default: + mnTransitionType = 0; + break; + } + } + + +} } diff --git a/oox/source/ppt/slidetransitioncontext.cxx b/oox/source/ppt/slidetransitioncontext.cxx new file mode 100644 index 000000000000..4c5ae7dcc65f --- /dev/null +++ b/oox/source/ppt/slidetransitioncontext.cxx @@ -0,0 +1,200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/slidetransitioncontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" + +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include <oox/ppt/backgroundproperties.hxx> +#include "oox/ppt/slidefragmenthandler.hxx" +#include "oox/ppt/soundactioncontext.hxx" +#include "oox/drawingml/shapegroupcontext.hxx" +#include "oox/helper/attributelist.hxx" + +using rtl::OUString; +using namespace ::com::sun::star; +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::container; + +namespace oox { namespace ppt { + + +SlideTransitionContext::SlideTransitionContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, PropertyMap & aProperties ) throw() +: ContextHandler( rParent ) +, maSlideProperties( aProperties ) +, mbHasTransition( sal_False ) +{ + AttributeList attribs(xAttribs); + + // ST_TransitionSpeed + maTransition.setOoxTransitionSpeed( xAttribs->getOptionalValueToken( XML_spd, XML_fast ) ); + + // TODO + attribs.getBool( XML_advClick, true ); + + // careful. if missing, no auto advance... 0 looks like a valid value + // for auto advance + if(attribs.hasAttribute( XML_advTm )) + { + // TODO + xAttribs->getOptionalValue( XML_advTm ); + } +} + +SlideTransitionContext::~SlideTransitionContext() throw() +{ + +} + +Reference< XFastContextHandler > SlideTransitionContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( blinds ): + case PPT_TOKEN( checker ): + case PPT_TOKEN( comb ): + case PPT_TOKEN( randomBar ): + if (!mbHasTransition) + { + mbHasTransition = true; + maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_horz ), 0); + // ST_Direction { XML_horz, XML_vert } + } + break; + case PPT_TOKEN( cover ): + case PPT_TOKEN( pull ): + if (!mbHasTransition) + { + mbHasTransition = true; + maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 ); + // ST_TransitionEightDirectionType { ST_TransitionSideDirectionType { + // XML_d, XML_d, XML_r, XML_u }, + // ST_TransitionCornerDirectionType { + // XML_ld, XML_lu, XML_rd, XML_ru } + } + break; + case PPT_TOKEN( cut ): + case PPT_TOKEN( fade ): + if (!mbHasTransition) + { + mbHasTransition = true; + AttributeList attribs(xAttribs); + // CT_OptionalBlackTransition xdb:bool + maTransition.setOoxTransitionType( aElementToken, attribs.getBool( XML_thruBlk, false ), 0); + } + break; + case PPT_TOKEN( push ): + case PPT_TOKEN( wipe ): + if (!mbHasTransition) + { + mbHasTransition = true; + maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_l ), 0 ); + // ST_TransitionSideDirectionType { XML_d, XML_l, XML_r, XML_u } + } + break; + case PPT_TOKEN( split ): + if (!mbHasTransition) + { + mbHasTransition = true; + maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_orient, XML_horz ), xAttribs->getOptionalValueToken( XML_dir, XML_out ) ); + // ST_Direction { XML_horz, XML_vert } + // ST_TransitionInOutDirectionType { XML_out, XML_in } + } + break; + case PPT_TOKEN( zoom ): + if (!mbHasTransition) + { + mbHasTransition = true; + maTransition.setOoxTransitionType( aElementToken, xAttribs->getOptionalValueToken( XML_dir, XML_out ), 0 ); + // ST_TransitionInOutDirectionType { XML_out, XML_in } + } + break; + case PPT_TOKEN( wheel ): + if (!mbHasTransition) + { + mbHasTransition = true; + AttributeList attribs(xAttribs); + maTransition.setOoxTransitionType( aElementToken, attribs.getUnsigned( XML_spokes, 4 ), 0 ); + // unsignedInt + } + break; + case PPT_TOKEN( circle ): + case PPT_TOKEN( diamond ): + case PPT_TOKEN( dissolve ): + case PPT_TOKEN( newsflash ): + case PPT_TOKEN( plus ): + case PPT_TOKEN( random ): + case PPT_TOKEN( wedge ): + // CT_Empty + if (!mbHasTransition) + { + mbHasTransition = true; + maTransition.setOoxTransitionType( aElementToken, 0, 0 ); + } + break; + + + case PPT_TOKEN( sndAc ): // CT_TransitionSoundAction + //"Sound" + xRet.set( new SoundActionContext ( *this, maSlideProperties ) ); + break; + case PPT_TOKEN( extLst ): // CT_OfficeArtExtensionList + return xRet; + default: + break; + } + + if( !xRet.is() ) + xRet.set(this); + + return xRet; +} + +void SlideTransitionContext::endFastElement( sal_Int32 aElement ) throw (::com::sun::star::xml::sax::SAXException, RuntimeException) +{ + if( aElement == (PPT_TOKEN( transition )) ) + { + if( mbHasTransition ) + { + maTransition.setSlideProperties( maSlideProperties ); + mbHasTransition = false; + } + } +} + + +} } + diff --git a/oox/source/ppt/soundactioncontext.cxx b/oox/source/ppt/soundactioncontext.cxx new file mode 100644 index 000000000000..e9b955a73e15 --- /dev/null +++ b/oox/source/ppt/soundactioncontext.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/soundactioncontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" + +#include "oox/helper/attributelist.hxx" +#include "oox/helper/propertymap.hxx" +#include "oox/drawingml/embeddedwavaudiofile.hxx" + +using rtl::OUString; +using namespace ::oox::core; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::uno; + + +namespace oox { namespace ppt { + + + SoundActionContext::SoundActionContext( ContextHandler& rParent, PropertyMap & aProperties ) throw() + : ContextHandler( rParent ) + , maSlideProperties( aProperties ) + , mbHasStartSound( false ) + , mbLoopSound( false ) + , mbStopSound( false ) + { + } + + + SoundActionContext::~SoundActionContext() throw() + { + } + + + void SoundActionContext::endFastElement( sal_Int32 aElement ) throw (SAXException, RuntimeException) + { + if ( aElement == PPT_TOKEN( sndAc ) ) + { + if( mbHasStartSound ) + { + OUString url; + // TODO this is very wrong + if ( msSndName.getLength() != 0 ) + { + // try the builtIn version + url = msSndName; + } +#if 0 // OOo does not support embedded data yet + else if ( msEmbedded.getLength() != 0 ) + { + RelationsRef xRel = getHandler()->getRelations(); + url = xRel->getRelationById( msEmbedded )->msTarget; + } + else if ( msLink.getLength() != 0 ) + { + url = msLink; + } +#endif + if ( url.getLength() != 0 ) + { + maSlideProperties[ PROP_Sound ] <<= url; + maSlideProperties[ PROP_SoundOn ] <<= sal_True; + } + } +// else if( mbStopSound ) +// { +// maSlideProperties[ CREATE_OUSTRING( "" ) ] = Any( sal_True ); +// } + } + } + + + Reference< XFastContextHandler > SoundActionContext::createFastChildContext( ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) + { + Reference< XFastContextHandler > xRet; + AttributeList attribs(xAttribs); + + switch( aElement ) + { + case PPT_TOKEN( snd ): + if( mbHasStartSound ) + { + drawingml::EmbeddedWAVAudioFile aAudio; + drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio); + + msSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed ); + } + break; + case PPT_TOKEN( endSnd ): + // CT_Empty + mbStopSound = true; + break; + case PPT_TOKEN( stSnd ): + mbHasStartSound = true; + mbLoopSound = attribs.getBool( XML_loop, false ); + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + + +} } diff --git a/oox/source/ppt/timeanimvaluecontext.cxx b/oox/source/ppt/timeanimvaluecontext.cxx new file mode 100644 index 000000000000..185897f2e101 --- /dev/null +++ b/oox/source/ppt/timeanimvaluecontext.cxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "timeanimvaluecontext.hxx" + +#include "animvariantcontext.hxx" + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + + TimeAnimValueListContext::TimeAnimValueListContext( ContextHandler& rParent, + const Reference< XFastAttributeList >& /*xAttribs*/, + TimeAnimationValueList & aTavList ) + : ContextHandler( rParent ) + , maTavList( aTavList ) + , mbInValue( false ) + { + } + + + TimeAnimValueListContext::~TimeAnimValueListContext( ) + { + } + + + void SAL_CALL TimeAnimValueListContext::endFastElement( sal_Int32 aElement ) + throw ( SAXException, RuntimeException) + { + if( aElement == PPT_TOKEN( tav ) ) + { + mbInValue = false; + } + } + + + Reference< XFastContextHandler > SAL_CALL TimeAnimValueListContext::createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( tav ): + { + mbInValue = true; + TimeAnimationValue val; + val.msFormula = xAttribs->getOptionalValue( XML_fmla ); + val.msTime = xAttribs->getOptionalValue( XML_tm ); + maTavList.push_back( val ); + break; + } + case PPT_TOKEN( val ): + if( mbInValue ) + { + // CT_TLAnimVariant + xRet.set( new AnimVariantContext( *this, aElementToken, maTavList.back().maValue ) ); + } + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + +} } diff --git a/oox/source/ppt/timeanimvaluecontext.hxx b/oox/source/ppt/timeanimvaluecontext.hxx new file mode 100644 index 000000000000..0c6391e4c175 --- /dev/null +++ b/oox/source/ppt/timeanimvaluecontext.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + + +#ifndef OOX_PPT_TIMEANIMVALUELISTCONTEXT +#define OOX_PPT_TIMEANIMVALUELISTCONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/ppt/animationspersist.hxx" + +namespace oox { namespace ppt { + + /** CT_TLTimeAnimateValueList */ + class TimeAnimValueListContext + : public ::oox::core::ContextHandler + { + public: + TimeAnimValueListContext( ::oox::core::ContextHandler& rParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs, + TimeAnimationValueList & aTavList ); + + ~TimeAnimValueListContext( ); + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + + private: + TimeAnimationValueList & maTavList; + bool mbInValue; + }; + + + + +} } + +#endif diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx new file mode 100644 index 000000000000..6887bcfdf3a3 --- /dev/null +++ b/oox/source/ppt/timenode.cxx @@ -0,0 +1,630 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/timenode.hxx" + +#include <boost/bind.hpp> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/animations/XAnimateColor.hpp> +#include <com/sun/star/animations/XAnimateMotion.hpp> +#include <com/sun/star/animations/XAnimateTransform.hpp> +#include <com/sun/star/animations/XCommand.hpp> +#include <com/sun/star/animations/XIterateContainer.hpp> +#include <com/sun/star/animations/XAnimationNodeSupplier.hpp> +#include <com/sun/star/animations/XTimeContainer.hpp> +#include <com/sun/star/animations/AnimationNodeType.hpp> +#include <com/sun/star/animations/Event.hpp> +#include <com/sun/star/animations/EventTrigger.hpp> +#include <com/sun/star/presentation/EffectNodeType.hpp> + +#include "oox/helper/helper.hxx" +#include "oox/core/xmlfilterbase.hxx" + +using ::rtl::OUString; +using namespace ::oox::core; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::presentation; + +namespace oox { namespace ppt { + + OUString TimeNode::getServiceName( sal_Int16 nNodeType ) + { + OUString sServiceName; + switch( nNodeType ) + { + case AnimationNodeType::PAR: +// sServiceName = CREATE_OUSTRING("com.sun.star.animations.IterateContainer"); + sServiceName = CREATE_OUSTRING("com.sun.star.animations.ParallelTimeContainer"); + break; + case AnimationNodeType::SEQ: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.SequenceTimeContainer"); + break; + case AnimationNodeType::ANIMATE: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.Animate"); + break; + case AnimationNodeType::ANIMATECOLOR: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateColor"); + break; + case AnimationNodeType::TRANSITIONFILTER: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.TransitionFilter"); + break; + case AnimationNodeType::ANIMATEMOTION: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateMotion"); + break; + case AnimationNodeType::ANIMATETRANSFORM: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateTransform"); + break; + case AnimationNodeType::COMMAND: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.Command"); + break; + case AnimationNodeType::SET: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.AnimateSet"); + break; + case AnimationNodeType::AUDIO: + sServiceName = CREATE_OUSTRING("com.sun.star.animations.Audio"); + break; + default: + OSL_TRACE( "OOX: uhandled type %x", nNodeType ); + break; + } + return sServiceName; + } + + + + TimeNode::TimeNode( sal_Int16 nNodeType ) + : mnNodeType( nNodeType ) + , mbHasEndSyncValue( false ) + { + } + + + TimeNode::~TimeNode() + { + } + +// BEGIN CUT&PASTE from sd/source/filter/ppt/pptinanimations.hxx +// -------------------------------------------------------------------- + static void fixMainSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) + { + try + { + bool bFirst = true; + Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW ); + Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW ); + while( xE->hasMoreElements() ) + { + // click node + Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY ); + + Event aEvent; + aEvent.Trigger = EventTrigger::ON_NEXT; + aEvent.Repeat = 0; + xClickNode->setBegin( makeAny( aEvent ) ); + + if( bFirst ) + { + bFirst = false; + Reference< XEnumerationAccess > xEA2( xClickNode, UNO_QUERY_THROW ); + Reference< XEnumeration > xE2( xEA2->createEnumeration(), UNO_QUERY_THROW ); + if( xE2->hasMoreElements() ) + { + // with node + xE2->nextElement() >>= xEA2; + if( xEA2.is() ) + xE2.query( xEA2->createEnumeration() ); + else + xE2.clear(); + + if( xE2.is() && xE2->hasMoreElements() ) + { + Reference< XAnimationNode > xEffectNode( xE2->nextElement(), UNO_QUERY_THROW ); + const Sequence< NamedValue > aUserData( xEffectNode->getUserData() ); + const NamedValue* p = aUserData.getConstArray(); + sal_Int32 nLength = aUserData.getLength(); + while( nLength-- ) + { + if( p->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "node-type" ) ) ) + { + sal_Int16 nNodeType = 0; + p->Value >>= nNodeType; + if( nNodeType != ::com::sun::star::presentation::EffectNodeType::ON_CLICK ) + { + // first effect does not start on click, so correct + // first click nodes begin to 0s + xClickNode->setBegin( makeAny( (double)0.0 ) ); + break; + } + } + p++; + } + } + } + } + } + } + catch( Exception& e ) + { + (void)e; + OSL_TRACE("fixMainSequenceTiming(), exception caught!" ); + } + } + +// -------------------------------------------------------------------- + + static void fixInteractiveSequenceTiming( const ::com::sun::star::uno::Reference< ::com::sun::star::animations::XAnimationNode >& xNode ) + { + try + { + Any aBegin( xNode->getBegin() ); + Any aEmpty; + xNode->setBegin( aEmpty ); + + Reference< XEnumerationAccess > xEA( xNode, UNO_QUERY_THROW ); + Reference< XEnumeration > xE( xEA->createEnumeration(), UNO_QUERY_THROW ); + while( xE->hasMoreElements() ) + { + // click node + Reference< XAnimationNode > xClickNode( xE->nextElement(), UNO_QUERY ); + xClickNode->setBegin( aBegin ); + } + } + catch( Exception& e ) + { + (void)e; + OSL_TRACE("fixInteractiveSequenceTiming(), exception caught!" ); + } + } + +// END CUT&PASTE + + void TimeNode::addNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& rxNode, const SlidePersistPtr & pSlide ) + { + try { + OUString sServiceName = getServiceName( mnNodeType ); + Reference< XAnimationNode > xNode = createAndInsert( rFilter, sServiceName, rxNode ); + setNode( rFilter, xNode, pSlide ); + } + catch( const Exception& e ) + { + OSL_TRACE( "OOX: exception raised in TimeNode::addNode() - %s", + OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } + + void TimeNode::setNode( const XmlFilterBase& rFilter, const Reference< XAnimationNode >& xNode, const SlidePersistPtr & pSlide ) + { + OSL_ENSURE( xNode.is(), "null node passed" ); + + try { + if( msId.getLength() ) + { + pSlide->getAnimNodesMap()[ msId ] = xNode; + } + + if( mpTarget ) + { + sal_Int16 nSubType; + maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubType ); + if( mpTarget->mnType == XML_spTgt ) + { + maNodeProperties[ NP_SUBITEM ] <<= nSubType; + } + } + + if( !maStCondList.empty() ) + { + Any aAny = AnimationCondition::convertList( pSlide, maStCondList ); + if( aAny.hasValue() ) + { + xNode->setBegin( aAny ); + } + + } + if( !maEndCondList.empty() ) + { + Any aAny = AnimationCondition::convertList( pSlide, maEndCondList ); + if( aAny.hasValue() ) + { + xNode->setEnd( aAny ); + } + } +#if 0 // FIXME even the binary filter has this disabled. + if( !maNextCondList.empty() ) + { + Any aAny = AnimationCondition::convertList( pSlide, maNextCondList ); + if( aAny.hasValue() ) + { + xNode->setNext( aAny ); + } + } + if( !maPrevCondList.empty() ) + { + Any aAny = AnimationCondition::convertList( pSlide, maPrevCondList ); + if( aAny.hasValue() ) + { + xNode->setPrev( aAny ); + } + } +#endif + if( mbHasEndSyncValue ) + { + Any aValue = maEndSyncValue.convert( pSlide ); + xNode->setEndSync(aValue); + } + + if( !maUserData.empty() ) + { + Sequence< NamedValue > aUserDataSeq( static_cast< sal_Int32 >( maUserData.size() ) ); + NamedValue* pValues = aUserDataSeq.getArray(); + for( UserDataMap::const_iterator aIt = maUserData.begin(), aEnd = maUserData.end(); aIt != aEnd; ++aIt, ++pValues ) + { + pValues->Name = aIt->first; + pValues->Value = aIt->second; + } + maNodeProperties[ NP_USERDATA ] <<= aUserDataSeq; + } + + Reference< XAnimate > xAnimate( xNode, UNO_QUERY ); + Reference< XAnimateColor > xAnimateColor( xNode, UNO_QUERY ); + Reference< XAnimateMotion > xAnimateMotion( xNode, UNO_QUERY ); + Reference< XAnimateTransform > xAnimateTransform( xNode, UNO_QUERY ); + Reference< XCommand > xCommand( xNode, UNO_QUERY ); + Reference< XIterateContainer > xIterateContainer( xNode, UNO_QUERY ); + sal_Int16 nInt16 = 0; + sal_Bool bBool = sal_False; + double fDouble = 0; + OUString sString; + Sequence< NamedValue > aSeq; + + for( int i = 0; i < _NP_SIZE; i++) + { + Any & aValue( maNodeProperties[ i ] ); + if( aValue.hasValue() ) + { + switch( i ) + { + case NP_TO: + if( xAnimate.is() ) + xAnimate->setTo( aValue ); + break; + case NP_FROM: + if( xAnimate.is() ) + xAnimate->setFrom( aValue ); + break; + case NP_BY: + if( xAnimate.is() ) + xAnimate->setBy( aValue ); + break; + case NP_TARGET: + if( xAnimate.is() ) + xAnimate->setTarget( aValue ); + break; + case NP_SUBITEM: + if( xAnimate.is() ) + { + if( aValue >>= nInt16 ) + xAnimate->setSubItem( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_ATTRIBUTENAME: + if( xAnimate.is() ) + { + if( aValue >>= sString ) + xAnimate->setAttributeName( sString ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_CALCMODE: + if( xAnimate.is() ) + { + if( aValue >>= nInt16 ) + xAnimate->setCalcMode( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_KEYTIMES: + if( xAnimate.is() ) + { + Sequence<double> aKeyTimes; + if( aValue >>= aKeyTimes ) + xAnimate->setKeyTimes(aKeyTimes); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_VALUES: + if( xAnimate.is() ) + { + Sequence<Any> aValues; + if( aValue >>= aValues ) + xAnimate->setValues(aValues); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_FORMULA: + if( xAnimate.is() ) + { + if( aValue >>= sString ) + xAnimate->setFormula(sString); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_COLORINTERPOLATION: + if( xAnimateColor.is() ) + { + if( aValue >>= nInt16 ) + xAnimateColor->setColorInterpolation( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_DIRECTION: + if( xAnimateColor.is() ) + { + if( aValue >>= bBool ) + xAnimateColor->setDirection( bBool ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_PATH: + if( xAnimateMotion.is() ) + xAnimateMotion->setPath( aValue ); + break; + case NP_TRANSFORMTYPE: + if( xAnimateTransform.is() ) + { + if( aValue >>= nInt16 ) + xAnimateTransform->setTransformType( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_USERDATA: + if( aValue >>= aSeq ) + xNode->setUserData( aSeq ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + break; + case NP_ACCELERATION: + if( aValue >>= fDouble ) + xNode->setAcceleration( fDouble ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + break; + case NP_DECELERATE: + if( aValue >>= fDouble ) + xNode->setDecelerate( fDouble ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + break; + case NP_AUTOREVERSE: + if( aValue >>= bBool ) + xNode->setAutoReverse( bBool ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + break; + case NP_DURATION: + xNode->setDuration( aValue ); + break; + case NP_FILL: + if( aValue >>= nInt16 ) + xNode->setFill( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + break; + case NP_REPEATCOUNT: + xNode->setRepeatCount( aValue ); + break; + case NP_REPEATDURATION: + xNode->setRepeatDuration( aValue ); + break; + case NP_RESTART: + if( aValue >>= nInt16 ) + xNode->setRestart( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + break; + case NP_COMMAND: + if( xCommand.is() ) + { + if( aValue >>= nInt16 ) + xCommand->setCommand( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_PARAMETER: + if( xCommand.is() ) + xCommand->setParameter( aValue ); + break; + case NP_ITERATETYPE: + if( xIterateContainer.is() ) + { + if( aValue >>= nInt16 ) + xIterateContainer->setIterateType( nInt16 ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + case NP_ITERATEINTERVAL: + if( xIterateContainer.is() ) + { + if( aValue >>= fDouble ) + xIterateContainer->setIterateInterval( fDouble ); + else + { + OSL_TRACE( "any >>= failed %d", __LINE__ ); + } + } + break; + default: + OSL_TRACE( "ERR-OOX: unknown prop index %d", i ); + break; + } + } + } + + if( mnNodeType == AnimationNodeType::TRANSITIONFILTER ) + { + + Reference< XTransitionFilter > xFilter( xNode, UNO_QUERY ); + maTransitionFilter.setTransitionFilterProperties( xFilter ); + } + + std::for_each( maChildren.begin(), maChildren.end(), + boost::bind(&TimeNode::addNode, _1, boost::cref(rFilter), boost::ref(xNode), + boost::ref(pSlide) ) ); + + switch( mnNodeType ) + { + case AnimationNodeType::SEQ: + { + sal_Int16 nEnum = 0; + if( maUserData[ CREATE_OUSTRING( "node-type" ) ] >>= nEnum ) + { + if( nEnum == EffectNodeType::MAIN_SEQUENCE ) + { + fixMainSequenceTiming( xNode ); + } + else if( nEnum == EffectNodeType::INTERACTIVE_SEQUENCE ) + { + fixInteractiveSequenceTiming( xNode ); + } + } + break; + } + case AnimationNodeType::PAR: + // some other cut&paste... from AnimationImporter::importAnimationContainer() + break; + } + } + catch( const Exception& e ) + { + OSL_TRACE( "OOX: exception raised in TimeNode::setNode() - %s", + OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } + + + Reference< XAnimationNode > TimeNode::createAndInsert( + const XmlFilterBase& rFilter, + const OUString& rServiceName, + const Reference< XAnimationNode >& rxNode ) + { + try { + Reference< XAnimationNode > xNode ( rFilter.getServiceFactory()->createInstance( rServiceName ), UNO_QUERY_THROW ); + Reference< XTimeContainer > xParentContainer( rxNode, UNO_QUERY_THROW ); + + xParentContainer->appendChild( xNode ); + return xNode; + } + catch( const Exception& e ) + { + OSL_TRACE( "OOX: exception raised in TimeNode::createAndInsert() trying to create a service %s = %s", + OUStringToOString( rServiceName, RTL_TEXTENCODING_ASCII_US ).getStr(), + OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + + return Reference< XAnimationNode >(); + } + + + void TimeNode::setId( sal_Int32 nId ) + { + msId = OUString::valueOf(nId); + } + + void TimeNode::setTo( const Any & aTo ) + { + maNodeProperties[ NP_TO ] = aTo; + } + + + void TimeNode::setFrom( const Any & aFrom ) + { + maNodeProperties[ NP_FROM ] = aFrom; + } + + void TimeNode::setBy( const Any & aBy ) + { + maNodeProperties[ NP_BY ] = aBy; + } + + +} } diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx new file mode 100644 index 000000000000..6a82dc29c1de --- /dev/null +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -0,0 +1,1163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "oox/ppt/timenodelistcontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include <osl/diagnose.h> +#include <rtl/math.hxx> + +#include <com/sun/star/animations/XTimeContainer.hpp> +#include <com/sun/star/animations/XAnimationNode.hpp> +#include <com/sun/star/animations/XAnimateColor.hpp> +#include <com/sun/star/animations/XAnimateSet.hpp> +#include <com/sun/star/animations/XAnimateTransform.hpp> +#include <com/sun/star/animations/AnimationTransformType.hpp> +#include <com/sun/star/animations/AnimationCalcMode.hpp> +#include <com/sun/star/animations/AnimationColorSpace.hpp> +#include <com/sun/star/animations/AnimationNodeType.hpp> +#include <com/sun/star/animations/XCommand.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/presentation/EffectCommands.hpp> +#include <com/sun/star/beans/NamedValue.hpp> + +#include "oox/helper/attributelist.hxx" +#include "oox/core/xmlfilterbase.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/colorchoicecontext.hxx" +#include "oox/ppt/slidetransition.hxx" + +#include "animvariantcontext.hxx" +#include "commonbehaviorcontext.hxx" +#include "conditioncontext.hxx" +#include "commontimenodecontext.hxx" +#include "timeanimvaluecontext.hxx" +#include "animationtypes.hxx" + +using namespace ::oox::core; +using namespace ::oox::drawingml; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::awt; +using ::com::sun::star::beans::NamedValue; + +using ::rtl::OUString; + +namespace oox { namespace ppt { + + struct AnimColor + { + AnimColor(sal_Int16 cs, sal_Int32 o, sal_Int32 t, sal_Int32 th ) + : colorSpace( cs ), one( o ), two( t ), three( th ) + { + } + + sal_Int32 get() + { + sal_Int32 nColor; + + switch( colorSpace ) + { + case AnimationColorSpace::HSL: + nColor = ( ( ( one * 128 ) / 360 ) & 0xff ) << 16 + | ( ( ( two * 128 ) / 1000 ) & 0xff ) << 8 + | ( ( ( three * 128 ) / 1000 ) & 0xff ); + break; + case AnimationColorSpace::RGB: + nColor = ( ( ( one * 128 ) / 1000 ) & 0xff ) << 16 + | ( ( ( two * 128 ) / 1000 ) & 0xff ) << 8 + | ( ( ( three * 128 ) / 1000 ) & 0xff ); + break; + default: + nColor = 0; + break; + } + return nColor; + } + + sal_Int16 colorSpace; + sal_Int32 one; + sal_Int32 two; + sal_Int32 three; + }; + + + /** CT_TLMediaNodeAudio + CT_TLMediaNodeVideo */ + class MediaNodeContext + : public TimeNodeContext + { + public: + MediaNodeContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + , mbIsNarration( false ) + , mbFullScrn( false ) + { + AttributeList attribs( xAttribs ); + + switch( aElement ) + { + case PPT_TOKEN( audio ): + mbIsNarration = attribs.getBool( XML_isNarration, false ); + break; + case PPT_TOKEN( video ): + mbFullScrn = attribs.getBool( XML_fullScrn, false ); + break; + default: + break; + } + } + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) + throw ( SAXException, RuntimeException) + { + if( aElement == PPT_TOKEN( audio ) ) + { + // TODO deal with mbIsNarration + } + else if( aElement == PPT_TOKEN( video ) ) + { + // TODO deal with mbFullScrn + } + } + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + private: + bool mbIsNarration; + bool mbFullScrn; + }; + + + /** CT_TLSetBehavior + */ + class SetTimeNodeContext + : public TimeNodeContext + { + public: + SetTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + { + + } + + ~SetTimeNodeContext() throw () + { + if( maTo.hasValue() ) + { + // TODO + // HACK !!! discard and refactor + OUString aString; + if( maTo >>= aString ) + { + OSL_TRACE( "Magic conversion %s", OUSTRING_TO_CSTR( aString ) ); + maTo = makeAny( aString.equalsAscii( "visible" ) ? sal_True : sal_False ); + if( !maTo.has<sal_Bool>() ) + OSL_TRACE( "conversion failed" ); + } + mpNode->setTo( maTo ); + } + + } + + virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) + throw ( SAXException, RuntimeException) + { + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( to ): + // CT_TLAnimVariant + xRet.set( new AnimVariantContext( *this, aElementToken, maTo ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + private: + Any maTo; + }; + + /** CT_TLCommandBehavior + */ + class CmdTimeNodeContext + : public TimeNodeContext + { + public: + CmdTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + , maType(0) + { + switch ( aElement ) + { + case PPT_TOKEN( cmd ): + msCommand = xAttribs->getOptionalValue( XML_cmd ); + maType = xAttribs->getOptionalValueToken( XML_type, 0 ); + break; + default: + break; + } + } + + ~CmdTimeNodeContext() throw () + { + } + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) + throw ( SAXException, RuntimeException) + { + if( aElement == PPT_TOKEN( cmd ) ) + { + try { + // see sd/source/filter/ppt/pptinanimations.cxx + // in AnimationImporter::importCommandContainer() + // REFACTOR? + // a good chunk of this code has been copied verbatim *sigh* + sal_Int16 nCommand = EffectCommands::CUSTOM; + NamedValue aParamValue; + + switch( maType ) + { + case XML_verb: + aParamValue.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("Verb")); + // TODO make sure msCommand has what we want + aParamValue.Value <<= msCommand.toInt32(); + nCommand = EffectCommands::VERB; + break; + case XML_evt: + case XML_call: + if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "onstopaudio" ) ) ) + { + nCommand = EffectCommands::STOPAUDIO; + } + else if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("play") ) ) + { + nCommand = EffectCommands::PLAY; + } + else if( msCommand.compareToAscii( RTL_CONSTASCII_STRINGPARAM("playFrom") ) == 0 ) + { + const OUString aMediaTime( msCommand.copy( 9, msCommand.getLength() - 10 ) ); + rtl_math_ConversionStatus eStatus; + double fMediaTime = ::rtl::math::stringToDouble( aMediaTime, (sal_Unicode)('.'), (sal_Unicode)(','), &eStatus, NULL ); + if( eStatus == rtl_math_ConversionStatus_Ok ) + { + aParamValue.Name = CREATE_OUSTRING("MediaTime"); + aParamValue.Value <<= fMediaTime; + } + nCommand = EffectCommands::PLAY; + } + else if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("togglePause") ) ) + { + nCommand = EffectCommands::TOGGLEPAUSE; + } + else if( msCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("stop") ) ) + { + nCommand = EffectCommands::STOP; + } + break; + } + mpNode->getNodeProperties()[ NP_COMMAND ] = makeAny((sal_Int16)nCommand); + if( nCommand == EffectCommands::CUSTOM ) + { + OSL_TRACE("OOX: CmdTimeNodeContext::endFastElement(), unknown command!"); + aParamValue.Name = CREATE_OUSTRING("UserDefined"); + aParamValue.Value <<= msCommand; + } + if( aParamValue.Value.hasValue() ) + { + Sequence< NamedValue > aParamSeq( &aParamValue, 1 ); + mpNode->getNodeProperties()[ NP_PARAMETER ] = makeAny( aParamSeq ); + } + } + catch( RuntimeException& ) + { + OSL_TRACE( "OOX: Exception in CmdTimeNodeContext::endFastElement()" ); + } + } + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + private: + OUString msCommand; + sal_Int32 maType; + }; + + + /** CT_TLTimeNodeSequence + */ + class SequenceTimeNodeContext + : public TimeNodeContext + { + public: + SequenceTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + , mnNextAc(0) + , mnPrevAc(0) + { + AttributeList attribs(xAttribs); + mbConcurrent = attribs.getBool( XML_concurrent, false ); + // ST_TLNextActionType { none, seek } + mnNextAc = xAttribs->getOptionalValueToken( XML_nextAc, 0 ); + // ST_TLPreviousActionType { none, skipTimed } + mnPrevAc = xAttribs->getOptionalValueToken( XML_prevAc, 0 ); + } + + ~SequenceTimeNodeContext() throw() + { + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cTn ): + xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( nextCondLst ): + xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, + mpNode->getNextCondition() ) ); + break; + case PPT_TOKEN( prevCondLst ): + xRet.set( new CondListContext( *this, aElementToken, xAttribs, mpNode, + mpNode->getPrevCondition() ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + private: + bool mbConcurrent; + sal_Int32 mnNextAc, mnPrevAc; + }; + + + /** CT_TLTimeNodeParallel + * CT_TLTimeNodeExclusive + */ + class ParallelExclTimeNodeContext + : public TimeNodeContext + { + public: + ParallelExclTimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + { + } + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cTn ): + xRet.set( new CommonTimeNodeContext( *this, aElementToken, xAttribs, mpNode ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + protected: + + }; + + + /** CT_TLAnimateColorBehavior */ + class AnimColorContext + : public TimeNodeContext + { + public: + AnimColorContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) throw() + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + // ST_TLAnimateColorSpace ( XML_rgb, XML_hsl } + , mnColorSpace( xAttribs->getOptionalValueToken( XML_clrSpc, 0 ) ) + // ST_TLAnimateColorDirection { XML_cw, XML_ccw } + , mnDir( xAttribs->getOptionalValueToken( XML_dir, 0 ) ) + , mbHasByColor( false ) + , m_byColor( AnimationColorSpace::RGB, 0, 0, 0) + { + } + ~AnimColorContext() throw() + { + } + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + { + //xParentNode + if( aElement == mnElement ) + { + NodePropertyMap & pProps(mpNode->getNodeProperties()); + pProps[ NP_DIRECTION ] = makeAny( mnDir == XML_cw ); + pProps[ NP_COLORINTERPOLATION ] = makeAny( mnColorSpace == XML_hsl ? AnimationColorSpace::HSL : AnimationColorSpace::RGB ); + const GraphicHelper& rGraphicHelper = getFilter().getGraphicHelper(); + if( maToClr.isUsed() ) + mpNode->setTo( Any( maToClr.getColor( rGraphicHelper ) ) ); + if( maFromClr.isUsed() ) + mpNode->setFrom( Any( maFromClr.getColor( rGraphicHelper ) ) ); + if( mbHasByColor ) + mpNode->setBy( Any ( m_byColor.get() ) ); + } + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( hsl ): + // CT_TLByHslColorTransform + { + if( mbHasByColor ) + { + m_byColor.colorSpace = AnimationColorSpace::HSL; + m_byColor.one = xAttribs->getOptionalValue( XML_h ).toInt32( ); + m_byColor.two = xAttribs->getOptionalValue( XML_s ).toInt32( ); + m_byColor.three = xAttribs->getOptionalValue( XML_l ).toInt32( ); + } + xRet.set(this); + break; + } + case PPT_TOKEN( rgb ): + { + if( mbHasByColor ) + { + // CT_TLByRgbColorTransform + m_byColor.colorSpace = AnimationColorSpace::RGB; + m_byColor.one = xAttribs->getOptionalValue( XML_r ).toInt32(); + m_byColor.two = xAttribs->getOptionalValue( XML_g ).toInt32(); + m_byColor.three = xAttribs->getOptionalValue( XML_b ).toInt32(); + } + xRet.set(this); + break; + } + case PPT_TOKEN( by ): + // CT_TLByAnimateColorTransform + mbHasByColor = true; + xRet.set(this); + break; + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( to ): + // CT_Color + xRet.set( new ColorContext( *this, maToClr ) ); + break; + case PPT_TOKEN( from ): + // CT_Color + xRet.set( new ColorContext( *this, maFromClr ) ); + break; + + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + + private: + sal_Int32 mnColorSpace; + sal_Int32 mnDir; + bool mbHasByColor; + AnimColor m_byColor; + oox::drawingml::Color maToClr; + oox::drawingml::Color maFromClr; + }; + + + /** CT_TLAnimateBehavior */ + class AnimContext + : public TimeNodeContext + { + public: + AnimContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) throw() + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + { + NodePropertyMap & aProps( pNode->getNodeProperties() ); + sal_Int32 nCalcMode = xAttribs->getOptionalValueToken( XML_calcmode, 0 ); + if(nCalcMode) + { + sal_Int16 nEnum = 0; + switch(nCalcMode) + { + case XML_discrete: + nEnum = AnimationCalcMode::DISCRETE; + break; + case XML_lin: + nEnum = AnimationCalcMode::LINEAR; + break; + case XML_fmla: + default: + // TODO what value is good ? + nEnum = AnimationCalcMode::DISCRETE; + break; + } + aProps[ NP_CALCMODE ] = makeAny(nEnum); + } + OUString aStr; + aStr = xAttribs->getOptionalValue( XML_from ); + if( aStr.getLength() ) + { + pNode->setFrom( makeAny( aStr ) ); + } + aStr = xAttribs->getOptionalValue( XML_by ); + if( aStr.getLength() ) + { + pNode->setBy( makeAny( aStr ) ); + } + aStr = xAttribs->getOptionalValue( XML_to ); + if( aStr.getLength() ) + { + pNode->setTo( makeAny( aStr ) ); + } + mnValueType = xAttribs->getOptionalValueToken( XML_valueType, 0 ); + } + + + ~AnimContext() throw () + { + ::std::list< TimeAnimationValue >::iterator iter, end; + int nKeyTimes = maTavList.size(); + if( nKeyTimes > 0) + { + int i; + Sequence< double > aKeyTimes( nKeyTimes ); + Sequence< Any > aValues( nKeyTimes ); + + NodePropertyMap & aProps( mpNode->getNodeProperties() ); + end = maTavList.end(); + for(iter = maTavList.begin(), i=0; iter != end; iter++,i++) + { + // TODO what to do if it is Timing_INFINITE ? + Any aTime = GetTimeAnimateValueTime( iter->msTime ); + aTime >>= aKeyTimes[i]; + aValues[i] = iter->maValue; + + OUString aTest; + iter->maValue >>= aTest; + if( aTest.getLength() != 0 ) + { + aValues[i] = iter->maValue; + } + else + { + aProps[ NP_FORMULA ] <<= iter->msFormula; + } + } + aProps[ NP_VALUES ] <<= aValues; + aProps[ NP_KEYTIMES ] <<= aKeyTimes; + } + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( tavLst ): + xRet.set( new TimeAnimValueListContext ( *this, xAttribs, maTavList ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + private: + sal_Int32 mnValueType; + TimeAnimationValueList maTavList; + }; + + + /** CT_TLAnimateScaleBehavior */ + class AnimScaleContext + : public TimeNodeContext + { + public: + AnimScaleContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) throw() + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + , mbZoomContents( false ) + { + AttributeList attribs( xAttribs ); + // TODO what to do with mbZoomContents + mbZoomContents = attribs.getBool( XML_zoomContents, false ); + pNode->getNodeProperties()[ NP_TRANSFORMTYPE ] + = makeAny((sal_Int16)AnimationTransformType::SCALE); + } + + ~AnimScaleContext( ) throw( ) + { + } + + virtual void SAL_CALL endFastElement( sal_Int32 aElement ) throw ( SAXException, RuntimeException) + { + if( aElement == mnElement ) + { + if( maTo.hasValue() ) + { + mpNode->setTo( maTo ); + } + if( maBy.hasValue() ) + { + mpNode->setBy( maBy ); + } + if( maFrom.hasValue() ) + { + mpNode->setFrom( maFrom ); + } + } + } + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( to ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + maTo <<= p.X; + maTo <<= p.Y; + break; + } + case PPT_TOKEN( from ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + maFrom <<= p.X; + maFrom <<= p.Y; + break; + } + case PPT_TOKEN( by ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + maBy <<= p.X; + maBy <<= p.Y; + break; + } + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + private: + Any maBy; + Any maFrom; + Any maTo; + bool mbZoomContents; + }; + + + /** CT_TLAnimateRotationBehavior */ + class AnimRotContext + : public TimeNodeContext + { + public: + AnimRotContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) throw() + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + { + AttributeList attribs( xAttribs ); + + pNode->getNodeProperties()[ NP_TRANSFORMTYPE ] + = makeAny((sal_Int16)AnimationTransformType::ROTATE); + // TODO make sure the units are OK + if(attribs.hasAttribute( XML_by ) ) + { + sal_Int32 nBy = attribs.getInteger( XML_by, 0 ); + pNode->setBy( makeAny( nBy ) ); + } + if(attribs.hasAttribute( XML_from ) ) + { + sal_Int32 nFrom = attribs.getInteger( XML_from, 0 ); + pNode->setFrom( makeAny( nFrom ) ); + } + if(attribs.hasAttribute( XML_to ) ) + { + sal_Int32 nTo = attribs.getInteger( XML_to, 0 ); + pNode->setTo( makeAny( nTo ) ); + } + } + + ~AnimRotContext( ) throw( ) + { + } + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + }; + + + + /** CT_TLAnimateMotionBehavior */ + class AnimMotionContext + : public TimeNodeContext + { + public: + AnimMotionContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) throw() + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + { + pNode->getNodeProperties()[ NP_TRANSFORMTYPE ] + = makeAny((sal_Int16)AnimationTransformType::TRANSLATE); + + AttributeList attribs( xAttribs ); + // ST_TLAnimateMotionBehaviorOrigin { parent, layour } + sal_Int32 nOrigin = xAttribs->getOptionalValueToken( XML_origin, 0 ); + if( nOrigin != 0 ) + { + switch(nOrigin) + { + case XML_layout: + case XML_parent: + break; + } + // TODO + } + + OUString aStr = xAttribs->getOptionalValue( XML_path ); + aStr = aStr.replace( 'E', ' ' ); + aStr = aStr.trim(); + pNode->getNodeProperties()[ NP_PATH ] = makeAny(aStr); + + // ST_TLAnimateMotionPathEditMode{ fixed, relative } + mnPathEditMode = xAttribs->getOptionalValueToken( XML_pathEditMode, 0 ); + msPtsTypes = xAttribs->getOptionalValue( XML_ptsTypes ); + mnAngle = attribs.getInteger( XML_rAng, 0 ); + // TODO make sure the units are right. Likely not. + } + + ~AnimMotionContext( ) throw() + { + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( to ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + Any rAny; + rAny <<= p.X; + rAny <<= p.Y; + mpNode->setTo( rAny ); + break; + } + case PPT_TOKEN( from ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + Any rAny; + rAny <<= p.X; + rAny <<= p.Y; + mpNode->setFrom( rAny ); + break; + } + case PPT_TOKEN( by ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + Any rAny; + rAny <<= p.X; + rAny <<= p.Y; + mpNode->setBy( rAny ); + break; + } + case PPT_TOKEN( rCtr ): + { + // CT_TLPoint + Point p = GetPointPercent( xAttribs ); + // TODO push + break; + } + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + private: + OUString msPtsTypes; + sal_Int32 mnPathEditMode; + sal_Int32 mnAngle; + }; + + + /** CT_TLAnimateEffectBehavior */ + class AnimEffectContext + : public TimeNodeContext + { + public: + AnimEffectContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) throw() + : TimeNodeContext( rParent, aElement, xAttribs, pNode ) + { + sal_Int32 nDir = xAttribs->getOptionalValueToken( XML_transition, 0 ); + OUString sFilter = xAttribs->getOptionalValue( XML_filter ); + // TODO +// OUString sPrList = xAttribs->getOptionalValue( XML_prLst ); + + if( sFilter.getLength() ) + { + SlideTransition aFilter( sFilter ); + aFilter.setMode( nDir == XML_out ? false : true ); + pNode->setTransitionFilter( aFilter ); + } + } + + + ~AnimEffectContext( ) throw() + { + } + + + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch ( aElementToken ) + { + case PPT_TOKEN( cBhvr ): + xRet.set( new CommonBehaviorContext ( *this, xAttribs, mpNode ) ); + break; + case PPT_TOKEN( progress ): + xRet.set( new AnimVariantContext( *this, aElementToken, maProgress ) ); + // TODO handle it. + break; + default: + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + private: + Any maProgress; + OUString msFilter; + OUString msPrList; + }; + + + + TimeNodeContext * TimeNodeContext::makeContext( + ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + { + TimeNodeContext *pCtx = NULL; + switch( aElement ) + { + case PPT_TOKEN( animClr ): + pCtx = new AnimColorContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( par ): + pCtx = new ParallelExclTimeNodeContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( seq ): + pCtx = new SequenceTimeNodeContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( excl ): + pCtx = new ParallelExclTimeNodeContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( anim ): + pCtx = new AnimContext ( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( animEffect ): + pCtx = new AnimEffectContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( animMotion ): + pCtx = new AnimMotionContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( animRot ): + pCtx = new AnimRotContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( animScale ): + pCtx = new AnimScaleContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( cmd ): + pCtx = new CmdTimeNodeContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( set ): + pCtx = new SetTimeNodeContext( rParent, aElement, xAttribs, pNode ); + break; + case PPT_TOKEN( audio ): + case PPT_TOKEN( video ): + pCtx = new MediaNodeContext( rParent, aElement, xAttribs, pNode ); + break; + default: + break; + } + return pCtx; + } + + + TimeNodeContext::TimeNodeContext( ContextHandler& rParent, sal_Int32 aElement, + const Reference< XFastAttributeList >& /*xAttribs*/, + const TimeNodePtr & pNode ) throw() + : ContextHandler( rParent ) + , mnElement( aElement ) + , mpNode( pNode ) + { + } + + + TimeNodeContext::~TimeNodeContext( ) throw() + { + + } + + + TimeNodeListContext::TimeNodeListContext( ContextHandler& rParent, TimeNodePtrList & aList ) + throw() + : ContextHandler( rParent ) + , maList( aList ) + { + } + + + TimeNodeListContext::~TimeNodeListContext( ) throw() + { + } + + + Reference< XFastContextHandler > SAL_CALL TimeNodeListContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) + { + Reference< XFastContextHandler > xRet; + + sal_Int16 nNodeType; + + switch( aElementToken ) + { + case PPT_TOKEN( par ): + nNodeType = AnimationNodeType::PAR; + break; + case PPT_TOKEN( seq ): + nNodeType = AnimationNodeType::SEQ; + break; + case PPT_TOKEN( excl ): + // TODO pick the right type. We choose parallel for now as + // there does not seem to be an "Exclusive" + nNodeType = AnimationNodeType::PAR; + break; + case PPT_TOKEN( anim ): + nNodeType = AnimationNodeType::ANIMATE; + break; + case PPT_TOKEN( animClr ): + nNodeType = AnimationNodeType::ANIMATECOLOR; + break; + case PPT_TOKEN( animEffect ): + nNodeType = AnimationNodeType::TRANSITIONFILTER; + break; + case PPT_TOKEN( animMotion ): + nNodeType = AnimationNodeType::ANIMATEMOTION; + break; + case PPT_TOKEN( animRot ): + case PPT_TOKEN( animScale ): + nNodeType = AnimationNodeType::ANIMATETRANSFORM; + break; + case PPT_TOKEN( cmd ): + nNodeType = AnimationNodeType::COMMAND; + break; + case PPT_TOKEN( set ): + nNodeType = AnimationNodeType::SET; + break; + case PPT_TOKEN( audio ): + nNodeType = AnimationNodeType::AUDIO; + break; + case PPT_TOKEN( video ): + nNodeType = AnimationNodeType::AUDIO; + OSL_TRACE( "OOX: video requested, gave Audio instead" ); + break; + + default: + nNodeType = AnimationNodeType::CUSTOM; + OSL_TRACE( "OOX: uhandled token %x", aElementToken ); + break; + } + + TimeNodePtr pNode(new TimeNode(nNodeType)); + maList.push_back( pNode ); + ContextHandler * pContext = TimeNodeContext::makeContext( *this, aElementToken, xAttribs, pNode ); + xRet.set( pContext ? pContext : this ); + + return xRet; + } + + +} } diff --git a/oox/source/ppt/timetargetelementcontext.cxx b/oox/source/ppt/timetargetelementcontext.cxx new file mode 100644 index 000000000000..81320bef5e89 --- /dev/null +++ b/oox/source/ppt/timetargetelementcontext.cxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "timetargetelementcontext.hxx" + +#include "comphelper/anytostring.hxx" +#include "cppuhelper/exc_hlp.hxx" +#include <osl/diagnose.h> + +#include <com/sun/star/uno/Any.hxx> + +#include "oox/helper/attributelist.hxx" +#include "oox/drawingml/embeddedwavaudiofile.hxx" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::oox::core; + +using ::rtl::OUString; + +namespace oox { namespace ppt { + + + + // CT_TLShapeTargetElement + class ShapeTargetElementContext + : public ContextHandler + { + public: + ShapeTargetElementContext( ContextHandler& rParent, ShapeTargetElement & aValue ) + : ContextHandler( rParent ) + , bTargetSet(false) + , maShapeTarget(aValue) + { + } + virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, + const Reference< XFastAttributeList >& xAttribs ) + throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( bg ): + bTargetSet = true; + maShapeTarget.mnType = XML_bg; + break; + case PPT_TOKEN( txEl ): + bTargetSet = true; + maShapeTarget.mnType = XML_txEl; + break; + case PPT_TOKEN( subSp ): + bTargetSet = true; + maShapeTarget.mnType = XML_subSp; + maShapeTarget.msSubShapeId = xAttribs->getOptionalValue( XML_spid ); + break; + case PPT_TOKEN( graphicEl ): + case PPT_TOKEN( oleChartEl ): + bTargetSet = true; + // TODO + break; + case PPT_TOKEN( charRg ): + case PPT_TOKEN( pRg ): + if( bTargetSet && maShapeTarget.mnType == XML_txEl ) + { + maShapeTarget.mnRangeType = getBaseToken( aElementToken ); + maShapeTarget.maRange = drawingml::GetIndexRange( xAttribs ); + } + break; + default: + break; + } + if( !xRet.is() ) + xRet.set( this ); + return xRet; + } + + private: + bool bTargetSet; + ShapeTargetElement & maShapeTarget; + }; + + + + TimeTargetElementContext::TimeTargetElementContext( ContextHandler& rParent, const AnimTargetElementPtr & pValue ) + : ContextHandler( rParent ), + mpTarget( pValue ) + { + OSL_ENSURE( mpTarget, "no valid target passed" ); + } + + + TimeTargetElementContext::~TimeTargetElementContext( ) throw( ) + { + } + + void SAL_CALL TimeTargetElementContext::endFastElement( sal_Int32 /*aElement*/ ) throw ( SAXException, RuntimeException) + { + } + + Reference< XFastContextHandler > SAL_CALL TimeTargetElementContext::createFastChildContext( ::sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw ( SAXException, RuntimeException ) + { + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + case PPT_TOKEN( inkTgt ): + { + mpTarget->mnType = XML_inkTgt; + OUString aId = xAttribs->getOptionalValue( XML_spid ); + if( aId.getLength() ) + { + mpTarget->msValue = aId; + } + break; + } + case PPT_TOKEN( sldTgt ): + mpTarget->mnType = XML_sldTgt; + break; + case PPT_TOKEN( sndTgt ): + { + mpTarget->mnType = XML_sndTgt; + drawingml::EmbeddedWAVAudioFile aAudio; + drawingml::getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio); + + OUString sSndName = ( aAudio.mbBuiltIn ? aAudio.msName : aAudio.msEmbed ); + mpTarget->msValue = sSndName; + break; + } + case PPT_TOKEN( spTgt ): + { + mpTarget->mnType = XML_spTgt; + OUString aId = xAttribs->getOptionalValue( XML_spid ); + mpTarget->msValue = aId; + xRet.set( new ShapeTargetElementContext( *this, mpTarget->maShapeTarget ) ); + break; + } + default: + OSL_TRACE( "OOX: unhandled tag %ld in TL_TimeTargetElement.", getBaseToken( aElementToken ) ); + break; + } + + if( !xRet.is() ) + xRet.set( this ); + + return xRet; + } + + +} } diff --git a/oox/source/ppt/timetargetelementcontext.hxx b/oox/source/ppt/timetargetelementcontext.hxx new file mode 100644 index 000000000000..05295e4298ea --- /dev/null +++ b/oox/source/ppt/timetargetelementcontext.hxx @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_PPT_TIMETARGETELEMENTCONTEXT +#define OOX_PPT_TIMETARGETELEMENTCONTEXT + +#include "oox/core/contexthandler.hxx" +#include "oox/ppt/animationspersist.hxx" + +namespace oox { namespace ppt { + + /** context CT_TLTimeTargetElement */ + class TimeTargetElementContext + : public ::oox::core::ContextHandler + { + public: + TimeTargetElementContext( ::oox::core::ContextHandler& rParent, const AnimTargetElementPtr & aValue ); + ~TimeTargetElementContext( ) throw( ); + virtual void SAL_CALL endFastElement( sal_Int32 /*aElement*/ ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttribs ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: + AnimTargetElementPtr mpTarget; + }; + +} } + + +#endif |