From ed5640d8b587fbcfed7dd7967f3de04b37a76f26 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:06:44 +0200 Subject: Adding upstream version 4:7.4.7. Signed-off-by: Daniel Baumann --- oox/source/ppt/animationspersist.cxx | 220 +++++ oox/source/ppt/animationtypes.cxx | 63 ++ oox/source/ppt/animationtypes.hxx | 35 + oox/source/ppt/animvariantcontext.cxx | 95 ++ oox/source/ppt/animvariantcontext.hxx | 50 ++ oox/source/ppt/backgroundproperties.cxx | 50 ++ oox/source/ppt/buildlistcontext.cxx | 84 ++ oox/source/ppt/buildlistcontext.hxx | 48 ++ oox/source/ppt/comments.cxx | 89 ++ oox/source/ppt/commonbehaviorcontext.cxx | 145 ++++ oox/source/ppt/commonbehaviorcontext.hxx | 65 ++ oox/source/ppt/commontimenodecontext.cxx | 666 ++++++++++++++ oox/source/ppt/commontimenodecontext.hxx | 48 ++ oox/source/ppt/conditioncontext.cxx | 182 ++++ oox/source/ppt/conditioncontext.hxx | 67 ++ oox/source/ppt/customshowlistcontext.cxx | 105 +++ oox/source/ppt/extdrawingfragmenthandler.cxx | 64 ++ oox/source/ppt/extdrawingfragmenthandler.hxx | 41 + oox/source/ppt/headerfootercontext.cxx | 58 ++ oox/source/ppt/headerfootercontext.hxx | 42 + oox/source/ppt/layoutfragmenthandler.cxx | 72 ++ oox/source/ppt/pptfilterhelpers.cxx | 422 +++++++++ oox/source/ppt/pptgraphicshapecontext.cxx | 189 ++++ oox/source/ppt/pptimport.cxx | 309 +++++++ oox/source/ppt/pptshape.cxx | 809 +++++++++++++++++ oox/source/ppt/pptshapecontext.cxx | 195 +++++ oox/source/ppt/pptshapegroupcontext.cxx | 158 ++++ oox/source/ppt/pptshapepropertiescontext.cxx | 56 ++ oox/source/ppt/presPropsfragmenthandler.cxx | 89 ++ oox/source/ppt/presentationfragmenthandler.cxx | 792 +++++++++++++++++ oox/source/ppt/slidefragmenthandler.cxx | 265 ++++++ oox/source/ppt/slidemastertextstylescontext.cxx | 79 ++ oox/source/ppt/slidepersist.cxx | 555 ++++++++++++ oox/source/ppt/slidetimingcontext.cxx | 70 ++ oox/source/ppt/slidetransition.cxx | 467 ++++++++++ oox/source/ppt/slidetransitioncontext.cxx | 200 +++++ oox/source/ppt/soundactioncontext.cxx | 109 +++ oox/source/ppt/timeanimvaluecontext.cxx | 84 ++ oox/source/ppt/timeanimvaluecontext.hxx | 51 ++ oox/source/ppt/timenode.cxx | 668 +++++++++++++++ oox/source/ppt/timenodelistcontext.cxx | 1048 +++++++++++++++++++++++ oox/source/ppt/timetargetelementcontext.cxx | 168 ++++ oox/source/ppt/timetargetelementcontext.hxx | 45 + 43 files changed, 9117 insertions(+) create mode 100644 oox/source/ppt/animationspersist.cxx create mode 100644 oox/source/ppt/animationtypes.cxx create mode 100644 oox/source/ppt/animationtypes.hxx create mode 100644 oox/source/ppt/animvariantcontext.cxx create mode 100644 oox/source/ppt/animvariantcontext.hxx create mode 100644 oox/source/ppt/backgroundproperties.cxx create mode 100644 oox/source/ppt/buildlistcontext.cxx create mode 100644 oox/source/ppt/buildlistcontext.hxx create mode 100644 oox/source/ppt/comments.cxx create mode 100644 oox/source/ppt/commonbehaviorcontext.cxx create mode 100644 oox/source/ppt/commonbehaviorcontext.hxx create mode 100644 oox/source/ppt/commontimenodecontext.cxx create mode 100644 oox/source/ppt/commontimenodecontext.hxx create mode 100644 oox/source/ppt/conditioncontext.cxx create mode 100644 oox/source/ppt/conditioncontext.hxx create mode 100644 oox/source/ppt/customshowlistcontext.cxx create mode 100644 oox/source/ppt/extdrawingfragmenthandler.cxx create mode 100644 oox/source/ppt/extdrawingfragmenthandler.hxx create mode 100644 oox/source/ppt/headerfootercontext.cxx create mode 100644 oox/source/ppt/headerfootercontext.hxx create mode 100644 oox/source/ppt/layoutfragmenthandler.cxx create mode 100644 oox/source/ppt/pptfilterhelpers.cxx create mode 100644 oox/source/ppt/pptgraphicshapecontext.cxx create mode 100644 oox/source/ppt/pptimport.cxx create mode 100644 oox/source/ppt/pptshape.cxx create mode 100644 oox/source/ppt/pptshapecontext.cxx create mode 100644 oox/source/ppt/pptshapegroupcontext.cxx create mode 100644 oox/source/ppt/pptshapepropertiescontext.cxx create mode 100644 oox/source/ppt/presPropsfragmenthandler.cxx create mode 100644 oox/source/ppt/presentationfragmenthandler.cxx create mode 100644 oox/source/ppt/slidefragmenthandler.cxx create mode 100644 oox/source/ppt/slidemastertextstylescontext.cxx create mode 100644 oox/source/ppt/slidepersist.cxx create mode 100644 oox/source/ppt/slidetimingcontext.cxx create mode 100644 oox/source/ppt/slidetransition.cxx create mode 100644 oox/source/ppt/slidetransitioncontext.cxx create mode 100644 oox/source/ppt/soundactioncontext.cxx create mode 100644 oox/source/ppt/timeanimvaluecontext.cxx create mode 100644 oox/source/ppt/timeanimvaluecontext.hxx create mode 100644 oox/source/ppt/timenode.cxx create mode 100644 oox/source/ppt/timenodelistcontext.cxx create mode 100644 oox/source/ppt/timetargetelementcontext.cxx create mode 100644 oox/source/ppt/timetargetelementcontext.hxx (limited to 'oox/source/ppt') diff --git a/oox/source/ppt/animationspersist.cxx b/oox/source/ppt/animationspersist.cxx new file mode 100644 index 000000000..450e3da00 --- /dev/null +++ b/oox/source/ppt/animationspersist.cxx @@ -0,0 +1,220 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::text; + +namespace oox +{ + +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.getArray()[nSize] = rNewValue; + } + else + { + aNewSeq = { rOldValue, rNewValue }; + } + return Any( aNewSeq ); + } +} + +} // namespace oox + +namespace oox::ppt { + + void ShapeTargetElement::convert( css::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... + SAL_INFO("oox.ppt", "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. + SAL_INFO("oox.ppt", "OOX: TODO what to do with more than one" ); + break; + } + rTarget <<= 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 + SAL_INFO("oox.ppt", "OOX: TODO inkTgt" ); + break; + case XML_sldTgt: + // TODO + SAL_INFO("oox.ppt", "OOX: TODO sldTgt" ); + break; + case XML_sndTgt: + aTarget <<= msValue; + break; + case XML_spTgt: + { + OUString sShapeName = msValue; + + // bnc#705982 - catch referenced diagram fallback shapes + if( maShapeTarget.mnType == XML_dgm ) + sShapeName = maShapeTarget.msSubShapeId; + + Any rTarget; + ::oox::drawingml::ShapePtr pShape = pSlide->getShape( sShapeName ); + SAL_WARN_IF( !pShape, "oox.ppt", "failed to locate Shape" ); + + if( !pShape && maShapeTarget.mnType == XML_dgm ) + { + pShape = pSlide->getShape( msValue ); + } + + if( pShape ) + { + Reference< XShape > xShape( pShape->getXShape() ); + SAL_WARN_IF( !xShape.is(), "oox.ppt", "fail to get XShape from shape" ); + if( xShape.is() ) + { + rTarget <<= xShape; + maShapeTarget.convert(rTarget, nSubType); + aTarget = rTarget; + } + } + break; + } + default: + break; + } + return aTarget; + } + + // Convert a time node condition to XAnimation.Begin or XAnimation.End + Any AnimationCondition::convert(const SlidePersistPtr & pSlide) const + { + Any aAny; + Event aEvent; + if(mpTarget && (maValue >>= aEvent)) + { + sal_Int16 nSubType; + aAny = mpTarget->convert( pSlide, nSubType ); + aEvent.Source = aAny; + aAny <<= aEvent; + } + else if (mnType == PPT_TOKEN(tn) && (maValue >>= aEvent)) + { + OUString sId; + aEvent.Source >>= sId; + css::uno::Reference xNode = pSlide->getAnimationNode(sId); + if (xNode.is()) + { + aEvent.Source <<= xNode; + } + else + aEvent.Source.clear(); + aAny <<= aEvent; + } + else + { + aAny = maValue; + } + return aAny; + } + + Any AnimationCondition::convertList(const SlidePersistPtr & pSlide, const AnimationConditionList & l) + { + Any aAny; + + if (l.size() == 1) + return l[0].convert(pSlide); + + for (auto const& elem : l) + { + aAny = addToSequence( aAny, elem.convert(pSlide) ); + } + return aAny; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animationtypes.cxx b/oox/source/ppt/animationtypes.cxx new file mode 100644 index 000000000..c6b49b3e8 --- /dev/null +++ b/oox/source/ppt/animationtypes.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "animationtypes.hxx" + +#include + +#include + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::xml::sax; + +namespace oox::ppt +{ +// ST_TLTime +Any GetTime(const OUString& val) +{ + Any aDuration; + if (val == "indefinite") + { + aDuration <<= Timing_INDEFINITE; + } + else + { + aDuration <<= val.toFloat() / 1000.0; + } + return aDuration; +} + +// ST_TLTimeAnimateValueTime +Any GetTimeAnimateValueTime(const OUString& val) +{ + Any aPercent; + if (val == "indefinite") + { + aPercent <<= Timing_INDEFINITE; + } + else + { + aPercent <<= val.toFloat() / 100000.0; + } + return aPercent; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animationtypes.hxx b/oox/source/ppt/animationtypes.hxx new file mode 100644 index 000000000..92652978f --- /dev/null +++ b/oox/source/ppt/animationtypes.hxx @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_ANIMATIONTYPES_HXX +#define INCLUDED_OOX_SOURCE_PPT_ANIMATIONTYPES_HXX + +#include + +namespace oox::ppt +{ +// ST_TLTime +css::uno::Any GetTime(const OUString& val); +// ST_TLTimeAnimateValueTime +css::uno::Any GetTimeAnimateValueTime(const OUString& val); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx new file mode 100644 index 000000000..5f2faf799 --- /dev/null +++ b/oox/source/ppt/animvariantcontext.cxx @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "animvariantcontext.hxx" + +#include +#include + +#include +#include +#include +#include +#include + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::ppt { + AnimVariantContext::AnimVariantContext( FragmentHandler2 const & rParent, sal_Int32 aElement, Any & aValue ) + : FragmentHandler2( rParent ) + , mnElement( aElement ) + , maValue( aValue ) + { + } + + AnimVariantContext::~AnimVariantContext( ) noexcept + { + } + + void AnimVariantContext::onEndElement() + { + if( isCurrentElement( mnElement ) && maColor.isUsed() ) + { + maValue <<= maColor.getColor( getFilter().getGraphicHelper() ); + } + } + + ContextHandlerRef AnimVariantContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) + { + switch( aElementToken ) + { + case PPT_TOKEN( boolVal ): + { + bool val = rAttribs.getBool( XML_val, false ); + maValue <<= val; + return this; + } + case PPT_TOKEN( clrVal ): + return new ::oox::drawingml::ColorContext( *this, maColor ); + // we'll defer setting the Any until the end. + case PPT_TOKEN( fltVal ): + { + double val = rAttribs.getDouble( XML_val, 0.0 ); + maValue <<= val; + return this; + } + case PPT_TOKEN( intVal ): + { + sal_Int32 val = rAttribs.getInteger( XML_val, 0 ); + maValue <<= val; + return this; + } + case PPT_TOKEN( strVal ): + { + OUString val = rAttribs.getString( XML_val, OUString() ); + maValue <<= val; + return this; + } + default: + break; + } + + return this; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animvariantcontext.hxx b/oox/source/ppt/animvariantcontext.hxx new file mode 100644 index 000000000..8830e0e6a --- /dev/null +++ b/oox/source/ppt/animvariantcontext.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_ANIMVARIANTCONTEXT_HXX +#define INCLUDED_OOX_SOURCE_PPT_ANIMVARIANTCONTEXT_HXX + +#include + +#include +#include + +namespace oox::ppt { + + /** context CT_TLAnimVariant */ + class AnimVariantContext + : public ::oox::core::FragmentHandler2 + { + public: + AnimVariantContext( ::oox::core::FragmentHandler2 const & rParent, ::sal_Int32 aElement, css::uno::Any & aValue ); + virtual ~AnimVariantContext( ) noexcept override; + virtual void onEndElement() override; + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; + + private: + ::sal_Int32 mnElement; + css::uno::Any& maValue; + ::oox::drawingml::Color maColor; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/backgroundproperties.cxx b/oox/source/ppt/backgroundproperties.cxx new file mode 100644 index 000000000..9fe256612 --- /dev/null +++ b/oox/source/ppt/backgroundproperties.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::ppt { + +BackgroundPropertiesContext::BackgroundPropertiesContext( FragmentHandler2 const & rParent, ::oox::drawingml::FillProperties& rFillProperties ) +: FragmentHandler2( rParent ) +, mrFillProperties( rFillProperties ) +{ +} + +::oox::core::ContextHandlerRef BackgroundPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case PPT_TOKEN( fill ): // a:CT_FillEffect + return this; + } + + return ::oox::drawingml::FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrFillProperties ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/buildlistcontext.cxx b/oox/source/ppt/buildlistcontext.cxx new file mode 100644 index 000000000..011d30346 --- /dev/null +++ b/oox/source/ppt/buildlistcontext.cxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "buildlistcontext.hxx" +#include +#include + +namespace oox::ppt { + + BuildListContext::BuildListContext( FragmentHandler2 const & rParent ) + : FragmentHandler2( rParent ) + , mbInBldGraphic( false ) + , mbBuildAsOne( false ) + { + } + + BuildListContext::~BuildListContext( ) + { + } + + void BuildListContext::onEndElement() + { + switch( getCurrentElement() ) + { + case PPT_TOKEN( bldGraphic ): + mbInBldGraphic = false; + break; + default: + break; + } + } + + ::oox::core::ContextHandlerRef BuildListContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/ ) + { + switch( aElementToken ) + { + case PPT_TOKEN( bldAsOne ): + if( mbInBldGraphic ) + { + mbBuildAsOne = true; + } + return this; + case PPT_TOKEN( bldSub ): + return this; + case PPT_TOKEN( bldGraphic ): + { + mbInBldGraphic = true; +// OUString sShapeId = rAttribs.getString( XML_spid, OUString() ); +// TODO +// bool uiExpand = rAttribs.getBool( XML_uiExpand, true ); + /* this is unsigned */ +// sal_uInt32 nGroupId = rAttribs.getUnsignedInteger( XML_grpId, 0 ); + return this; + } + case A_TOKEN( bldDgm ): + case A_TOKEN( bldOleChart ): + case A_TOKEN( bldP ): + return this; + default: + break; + } + + return this; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/buildlistcontext.hxx b/oox/source/ppt/buildlistcontext.hxx new file mode 100644 index 000000000..a95e464e9 --- /dev/null +++ b/oox/source/ppt/buildlistcontext.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_BUILDLISTCONTEXT_HXX +#define INCLUDED_OOX_SOURCE_PPT_BUILDLISTCONTEXT_HXX + +#include + +namespace oox::ppt { + + /** CT_BuildList */ + class BuildListContext + : public ::oox::core::FragmentHandler2 + { + public: + explicit BuildListContext( ::oox::core::FragmentHandler2 const & rParent ); + + virtual ~BuildListContext( ) override; + + virtual void onEndElement() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; + private: + bool mbInBldGraphic; + bool mbBuildAsOne; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/comments.cxx b/oox/source/ppt/comments.cxx new file mode 100644 index 000000000..c38397fca --- /dev/null +++ b/oox/source/ppt/comments.cxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include +#include +#include +#include + +namespace oox::ppt +{ +void CommentAuthorList::setValues(const CommentAuthorList& list) +{ + for (auto const& author : list.cmAuthorLst) + { + CommentAuthor temp; + // TODO JNA : why not doing push_back at the end instead of using back()? + cmAuthorLst.push_back(temp); + cmAuthorLst.back().clrIdx = author.clrIdx; + cmAuthorLst.back().id = author.id; + cmAuthorLst.back().initials = author.initials; + cmAuthorLst.back().lastIdx = author.lastIdx; + cmAuthorLst.back().name = author.name; + } +} + +//DateTime is saved as : 2013-01-10T15:53:26.000 +void Comment::setDateTime(const OUString& sDateTime) +{ + sal_Int32 nIdx{ 0 }; + aDateTime.Year = o3tl::toInt32(o3tl::getToken(sDateTime, 0, '-', nIdx)); + aDateTime.Month = o3tl::toUInt32(o3tl::getToken(sDateTime, 0, '-', nIdx)); + aDateTime.Day = o3tl::toUInt32(o3tl::getToken(sDateTime, 0, 'T', nIdx)); + aDateTime.Hours = o3tl::toUInt32(o3tl::getToken(sDateTime, 0, ':', nIdx)); + aDateTime.Minutes = o3tl::toUInt32(o3tl::getToken(sDateTime, 0, ':', nIdx)); + double seconds = rtl_math_uStringToDouble(sDateTime.getStr() + nIdx, + sDateTime.getStr() + sDateTime.getLength(), '.', 0, + nullptr, nullptr); + aDateTime.Seconds = floor(seconds); + seconds -= aDateTime.Seconds; + aDateTime.NanoSeconds = ::rtl::math::round(seconds * 1000000000); + const int secondsOverflow = (aDateTime.Seconds == 60) ? 61 : 60; + // normalise time part of aDateTime + if (aDateTime.NanoSeconds == 1000000000) + { + aDateTime.NanoSeconds = 0; + ++aDateTime.Seconds; + } + if (aDateTime.Seconds == secondsOverflow) + { + aDateTime.Seconds = 0; + ++aDateTime.Minutes; + } + if (aDateTime.Minutes == 60) + { + aDateTime.Minutes = 0; + ++aDateTime.Hours; + } + // if overflow goes into date, I give up +} + +OUString Comment::getAuthor(const CommentAuthorList& list) +{ + const sal_Int32 nId = authorId.toInt32(); + for (auto const& author : list.cmAuthorLst) + { + if (author.id.toInt32() == nId) + return author.name; + } + return "Anonymous"; +} + +const Comment& CommentList::getCommentAtIndex(int index) +{ + if (index < 0 || o3tl::make_unsigned(index) >= cmLst.size()) + throw css::lang::IllegalArgumentException(); + + return cmLst.at(index); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commonbehaviorcontext.cxx b/oox/source/ppt/commonbehaviorcontext.cxx new file mode 100644 index 000000000..4ba40925a --- /dev/null +++ b/oox/source/ppt/commonbehaviorcontext.cxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include + +#include +#include +#include + +#include "commonbehaviorcontext.hxx" +#include "commontimenodecontext.hxx" +#include "timetargetelementcontext.hxx" + +#include + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::ppt { + + CommonBehaviorContext::CommonBehaviorContext( FragmentHandler2 const & rParent, + const TimeNodePtr & pNode) + : FragmentHandler2(rParent) + , mbInAttrList( false ) + , mbIsInAttrName( false ) + , mpNode(pNode) + { + } + + CommonBehaviorContext::~CommonBehaviorContext( ) noexcept + { + } + + void CommonBehaviorContext::onEndElement() + { + switch( getCurrentElement() ) + { + case PPT_TOKEN( cBhvr ): + { + if( !maAttributes.empty() ) + { + OUStringBuffer sAttributes; + for (auto const& attribute : maAttributes) + { + if( !sAttributes.isEmpty() ) + { + sAttributes.append( ";" ); + } + sAttributes.append( attribute.name ); + } + OUString sTmp( sAttributes.makeStringAndClear() ); + mpNode->getNodeProperties()[ NP_ATTRIBUTENAME ] <<= sTmp; + } + break; + } + case PPT_TOKEN( attrNameLst ): + mbInAttrList = false; + break; + case PPT_TOKEN( attrName ): + if( mbIsInAttrName ) + { + const ImplAttributeNameConversion *attrConv = getAttributeConversionList(); + while( attrConv->mpMSName != nullptr ) + { + if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) ) + { + Attribute attr; + attr.name = OUString::intern( attrConv->mpAPIName, + strlen(attrConv->mpAPIName), + RTL_TEXTENCODING_ASCII_US ); + attr.type = attrConv->meAttribute; + maAttributes.push_back( attr ); + SAL_INFO("oox.ppt", "OOX: attrName is " << msCurrentAttribute << " -> " << attrConv->mpAPIName ); + break; + } + attrConv++; + } + mbIsInAttrName = false; + } + break; + default: + break; + } + } + + void CommonBehaviorContext::onCharacters( const OUString& aChars ) + { + if( mbIsInAttrName ) + { + msCurrentAttribute += aChars; + } + } + + ::oox::core::ContextHandlerRef CommonBehaviorContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) + { + switch ( aElementToken ) + { + case PPT_TOKEN( cTn ): + return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode ); + case PPT_TOKEN( tgtEl ): + return new TimeTargetElementContext( *this, mpNode->getTarget() ); + case PPT_TOKEN( attrNameLst ): + mbInAttrList = true; + return this; + case PPT_TOKEN( attrName ): + { + if( mbInAttrList ) + { + mbIsInAttrName = true; + msCurrentAttribute.clear(); + } + else + { + SAL_INFO("oox.ppt", "OOX: Attribute Name outside an Attribute List" ); + } + return this; + } + default: + break; + } + + return this; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commonbehaviorcontext.hxx b/oox/source/ppt/commonbehaviorcontext.hxx new file mode 100644 index 000000000..eb6bc28fc --- /dev/null +++ b/oox/source/ppt/commonbehaviorcontext.hxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_COMMONBEHAVIORCONTEXT_HXX +#define INCLUDED_OOX_SOURCE_PPT_COMMONBEHAVIORCONTEXT_HXX + +#include +#include +#include +#include +#include + +namespace oox::ppt { + + struct Attribute + { + OUString name; + AnimationAttributeEnum type; + }; + + /** CT_TLCommonBehaviorData */ + class CommonBehaviorContext + : public ::oox::core::FragmentHandler2 + { + public: + CommonBehaviorContext( ::oox::core::FragmentHandler2 const & rParent, + const TimeNodePtr & pNode ); + virtual ~CommonBehaviorContext( ) + noexcept override; + + virtual void onEndElement() override; + + virtual void onCharacters( const OUString& aChars ) override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; + + private: + bool mbInAttrList; + bool mbIsInAttrName; + std::vector< Attribute > maAttributes; + OUString msCurrentAttribute; + const TimeNodePtr& mpNode; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commontimenodecontext.cxx b/oox/source/ppt/commontimenodecontext.cxx new file mode 100644 index 000000000..e7d1cf1dc --- /dev/null +++ b/oox/source/ppt/commontimenodecontext.cxx @@ -0,0 +1,666 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "commontimenodecontext.hxx" +#include "conditioncontext.hxx" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#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; + + +namespace oox::ppt { + +const convert_subtype* convert_subtype::getList() +{ + static const convert_subtype aList[] = + { + // 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, nullptr } + }; + + return aList; +} + +const preset_mapping* preset_mapping::getList() +{ + + static const preset_mapping aList[] = + { + { css::presentation::EffectPresetClass::ENTRANCE, 1 ,"ooo-entrance-appear" }, + { css::presentation::EffectPresetClass::ENTRANCE, 2 ,"ooo-entrance-fly-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 3 ,"ooo-entrance-venetian-blinds" }, + { css::presentation::EffectPresetClass::ENTRANCE, 4 ,"ooo-entrance-box" }, + { css::presentation::EffectPresetClass::ENTRANCE, 5 ,"ooo-entrance-checkerboard" }, + { css::presentation::EffectPresetClass::ENTRANCE, 6 ,"ooo-entrance-circle" }, + { css::presentation::EffectPresetClass::ENTRANCE, 7 ,"ooo-entrance-fly-in-slow" }, + { css::presentation::EffectPresetClass::ENTRANCE, 8 ,"ooo-entrance-diamond" }, + { css::presentation::EffectPresetClass::ENTRANCE, 9 ,"ooo-entrance-dissolve-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 10 ,"ooo-entrance-fade-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 11 ,"ooo-entrance-flash-once" }, + { css::presentation::EffectPresetClass::ENTRANCE, 12 ,"ooo-entrance-peek-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 13 ,"ooo-entrance-plus" }, + { css::presentation::EffectPresetClass::ENTRANCE, 14 ,"ooo-entrance-random-bars" }, + { css::presentation::EffectPresetClass::ENTRANCE, 15 ,"ooo-entrance-spiral-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 16 ,"ooo-entrance-split" }, + { css::presentation::EffectPresetClass::ENTRANCE, 17 ,"ooo-entrance-stretchy" }, + { css::presentation::EffectPresetClass::ENTRANCE, 18 ,"ooo-entrance-diagonal-squares" }, + { css::presentation::EffectPresetClass::ENTRANCE, 19 ,"ooo-entrance-swivel" }, + { css::presentation::EffectPresetClass::ENTRANCE, 20 ,"ooo-entrance-wedge" }, + { css::presentation::EffectPresetClass::ENTRANCE, 21 ,"ooo-entrance-wheel" }, + { css::presentation::EffectPresetClass::ENTRANCE, 22 ,"ooo-entrance-wipe" }, + { css::presentation::EffectPresetClass::ENTRANCE, 23 ,"ooo-entrance-zoom" }, + { css::presentation::EffectPresetClass::ENTRANCE, 24 ,"ooo-entrance-random" }, + { css::presentation::EffectPresetClass::ENTRANCE, 25 ,"ooo-entrance-boomerang" }, + { css::presentation::EffectPresetClass::ENTRANCE, 26 ,"ooo-entrance-bounce" }, + { css::presentation::EffectPresetClass::ENTRANCE, 27 ,"ooo-entrance-colored-lettering" }, + { css::presentation::EffectPresetClass::ENTRANCE, 28 ,"ooo-entrance-movie-credits" }, + { css::presentation::EffectPresetClass::ENTRANCE, 29 ,"ooo-entrance-ease-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 30 ,"ooo-entrance-float" }, + { css::presentation::EffectPresetClass::ENTRANCE, 31 ,"ooo-entrance-turn-and-grow" }, + { css::presentation::EffectPresetClass::ENTRANCE, 34 ,"ooo-entrance-breaks" }, + { css::presentation::EffectPresetClass::ENTRANCE, 35 ,"ooo-entrance-pinwheel" }, + { css::presentation::EffectPresetClass::ENTRANCE, 37 ,"ooo-entrance-rise-up" }, + { css::presentation::EffectPresetClass::ENTRANCE, 38 ,"ooo-entrance-falling-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 39 ,"ooo-entrance-thread" }, + { css::presentation::EffectPresetClass::ENTRANCE, 40 ,"ooo-entrance-unfold" }, + { css::presentation::EffectPresetClass::ENTRANCE, 41 ,"ooo-entrance-whip" }, + { css::presentation::EffectPresetClass::ENTRANCE, 42 ,"ooo-entrance-ascend" }, + { css::presentation::EffectPresetClass::ENTRANCE, 43 ,"ooo-entrance-center-revolve" }, + { css::presentation::EffectPresetClass::ENTRANCE, 45 ,"ooo-entrance-fade-in-and-swivel" }, + { css::presentation::EffectPresetClass::ENTRANCE, 47 ,"ooo-entrance-descend" }, + { css::presentation::EffectPresetClass::ENTRANCE, 48 ,"ooo-entrance-sling" }, + { css::presentation::EffectPresetClass::ENTRANCE, 49 ,"ooo-entrance-spin-in" }, + { css::presentation::EffectPresetClass::ENTRANCE, 50 ,"ooo-entrance-compress" }, + { css::presentation::EffectPresetClass::ENTRANCE, 51 ,"ooo-entrance-magnify" }, + { css::presentation::EffectPresetClass::ENTRANCE, 52 ,"ooo-entrance-curve-up" }, + { css::presentation::EffectPresetClass::ENTRANCE, 53 ,"ooo-entrance-fade-in-and-zoom" }, + { css::presentation::EffectPresetClass::ENTRANCE, 54 ,"ooo-entrance-glide" }, + { css::presentation::EffectPresetClass::ENTRANCE, 55 ,"ooo-entrance-expand" }, + { css::presentation::EffectPresetClass::ENTRANCE, 56 ,"ooo-entrance-flip" }, + { css::presentation::EffectPresetClass::ENTRANCE, 58 ,"ooo-entrance-fold" }, + { css::presentation::EffectPresetClass::EMPHASIS, 1 ,"ooo-emphasis-fill-color" }, + { css::presentation::EffectPresetClass::EMPHASIS, 2 ,"ooo-emphasis-font" }, + { css::presentation::EffectPresetClass::EMPHASIS, 3 ,"ooo-emphasis-font-color" }, + { css::presentation::EffectPresetClass::EMPHASIS, 4 ,"ooo-emphasis-font-size" }, + { css::presentation::EffectPresetClass::EMPHASIS, 5 ,"ooo-emphasis-font-style" }, + { css::presentation::EffectPresetClass::EMPHASIS, 6 ,"ooo-emphasis-grow-and-shrink" }, + { css::presentation::EffectPresetClass::EMPHASIS, 7 ,"ooo-emphasis-line-color" }, + { css::presentation::EffectPresetClass::EMPHASIS, 8 ,"ooo-emphasis-spin" }, + { css::presentation::EffectPresetClass::EMPHASIS, 9 ,"ooo-emphasis-transparency" }, + { css::presentation::EffectPresetClass::EMPHASIS, 10 ,"ooo-emphasis-bold-flash" }, + { css::presentation::EffectPresetClass::EMPHASIS, 14 ,"ooo-emphasis-blast" }, + { css::presentation::EffectPresetClass::EMPHASIS, 15 ,"ooo-emphasis-bold-reveal" }, + { css::presentation::EffectPresetClass::EMPHASIS, 16 ,"ooo-emphasis-color-over-by-word" }, + { css::presentation::EffectPresetClass::EMPHASIS, 18 ,"ooo-emphasis-reveal-underline" }, + { css::presentation::EffectPresetClass::EMPHASIS, 19 ,"ooo-emphasis-color-blend" }, + { css::presentation::EffectPresetClass::EMPHASIS, 20 ,"ooo-emphasis-color-over-by-letter" }, + { css::presentation::EffectPresetClass::EMPHASIS, 21 ,"ooo-emphasis-complementary-color" }, + { css::presentation::EffectPresetClass::EMPHASIS, 22 ,"ooo-emphasis-complementary-color-2" }, + { css::presentation::EffectPresetClass::EMPHASIS, 23 ,"ooo-emphasis-contrasting-color" }, + { css::presentation::EffectPresetClass::EMPHASIS, 24 ,"ooo-emphasis-darken" }, + { css::presentation::EffectPresetClass::EMPHASIS, 25 ,"ooo-emphasis-desaturate" }, + { css::presentation::EffectPresetClass::EMPHASIS, 26 ,"ooo-emphasis-flash-bulb" }, + { css::presentation::EffectPresetClass::EMPHASIS, 27 ,"ooo-emphasis-flicker" }, + { css::presentation::EffectPresetClass::EMPHASIS, 28 ,"ooo-emphasis-grow-with-color" }, + { css::presentation::EffectPresetClass::EMPHASIS, 30 ,"ooo-emphasis-lighten" }, + { css::presentation::EffectPresetClass::EMPHASIS, 31 ,"ooo-emphasis-style-emphasis" }, + { css::presentation::EffectPresetClass::EMPHASIS, 32 ,"ooo-emphasis-teeter" }, + { css::presentation::EffectPresetClass::EMPHASIS, 33 ,"ooo-emphasis-vertical-highlight" }, + { css::presentation::EffectPresetClass::EMPHASIS, 34 ,"ooo-emphasis-wave" }, + { css::presentation::EffectPresetClass::EMPHASIS, 35 ,"ooo-emphasis-blink" }, + { css::presentation::EffectPresetClass::EMPHASIS, 36 ,"ooo-emphasis-shimmer" }, + { css::presentation::EffectPresetClass::EXIT, 1 ,"ooo-exit-disappear" }, + { css::presentation::EffectPresetClass::EXIT, 2 ,"ooo-exit-fly-out" }, + { css::presentation::EffectPresetClass::EXIT, 3 ,"ooo-exit-venetian-blinds" }, + { css::presentation::EffectPresetClass::EXIT, 4 ,"ooo-exit-box" }, + { css::presentation::EffectPresetClass::EXIT, 5 ,"ooo-exit-checkerboard" }, + { css::presentation::EffectPresetClass::EXIT, 6 ,"ooo-exit-circle" }, + { css::presentation::EffectPresetClass::EXIT, 7 ,"ooo-exit-crawl-out" }, + { css::presentation::EffectPresetClass::EXIT, 8 ,"ooo-exit-diamond" }, + { css::presentation::EffectPresetClass::EXIT, 9 ,"ooo-exit-dissolve" }, + { css::presentation::EffectPresetClass::EXIT, 10 ,"ooo-exit-fade-out" }, + { css::presentation::EffectPresetClass::EXIT, 11 ,"ooo-exit-flash-once" }, + { css::presentation::EffectPresetClass::EXIT, 12 ,"ooo-exit-peek-out" }, + { css::presentation::EffectPresetClass::EXIT, 13 ,"ooo-exit-plus" }, + { css::presentation::EffectPresetClass::EXIT, 14 ,"ooo-exit-random-bars" }, + { css::presentation::EffectPresetClass::EXIT, 15 ,"ooo-exit-spiral-out" }, + { css::presentation::EffectPresetClass::EXIT, 16 ,"ooo-exit-split" }, + { css::presentation::EffectPresetClass::EXIT, 17 ,"ooo-exit-collapse" }, + { css::presentation::EffectPresetClass::EXIT, 18 ,"ooo-exit-diagonal-squares" }, + { css::presentation::EffectPresetClass::EXIT, 19 ,"ooo-exit-swivel" }, + { css::presentation::EffectPresetClass::EXIT, 20 ,"ooo-exit-wedge" }, + { css::presentation::EffectPresetClass::EXIT, 21 ,"ooo-exit-wheel" }, + { css::presentation::EffectPresetClass::EXIT, 22 ,"ooo-exit-wipe" }, + { css::presentation::EffectPresetClass::EXIT, 23 ,"ooo-exit-zoom" }, + { css::presentation::EffectPresetClass::EXIT, 24 ,"ooo-exit-random" }, + { css::presentation::EffectPresetClass::EXIT, 25 ,"ooo-exit-boomerang" }, + { css::presentation::EffectPresetClass::EXIT, 26 ,"ooo-exit-bounce" }, + { css::presentation::EffectPresetClass::EXIT, 27 ,"ooo-exit-colored-lettering" }, + { css::presentation::EffectPresetClass::EXIT, 28 ,"ooo-exit-movie-credits" }, + { css::presentation::EffectPresetClass::EXIT, 29 ,"ooo-exit-ease-out" }, + { css::presentation::EffectPresetClass::EXIT, 30 ,"ooo-exit-float" }, + { css::presentation::EffectPresetClass::EXIT, 31 ,"ooo-exit-turn-and-grow" }, + { css::presentation::EffectPresetClass::EXIT, 34 ,"ooo-exit-breaks" }, + { css::presentation::EffectPresetClass::EXIT, 35 ,"ooo-exit-pinwheel" }, + { css::presentation::EffectPresetClass::EXIT, 37 ,"ooo-exit-sink-down" }, + { css::presentation::EffectPresetClass::EXIT, 38 ,"ooo-exit-swish" }, + { css::presentation::EffectPresetClass::EXIT, 39 ,"ooo-exit-thread" }, + { css::presentation::EffectPresetClass::EXIT, 40 ,"ooo-exit-unfold" }, + { css::presentation::EffectPresetClass::EXIT, 41 ,"ooo-exit-whip" }, + { css::presentation::EffectPresetClass::EXIT, 42 ,"ooo-exit-descend" }, + { css::presentation::EffectPresetClass::EXIT, 43 ,"ooo-exit-center-revolve" }, + { css::presentation::EffectPresetClass::EXIT, 45 ,"ooo-exit-fade-out-and-swivel" }, + { css::presentation::EffectPresetClass::EXIT, 47 ,"ooo-exit-ascend" }, + { css::presentation::EffectPresetClass::EXIT, 48 ,"ooo-exit-sling" }, + { css::presentation::EffectPresetClass::EXIT, 53 ,"ooo-exit-fade-out-and-zoom" }, + { css::presentation::EffectPresetClass::EXIT, 55 ,"ooo-exit-contract" }, + { css::presentation::EffectPresetClass::EXIT, 49 ,"ooo-exit-spin-out" }, + { css::presentation::EffectPresetClass::EXIT, 50 ,"ooo-exit-stretchy" }, + { css::presentation::EffectPresetClass::EXIT, 51 ,"ooo-exit-magnify" }, + { css::presentation::EffectPresetClass::EXIT, 52 ,"ooo-exit-curve-down" }, + { css::presentation::EffectPresetClass::EXIT, 54 ,"ooo-exit-glide" }, + { css::presentation::EffectPresetClass::EXIT, 56 ,"ooo-exit-flip" }, + { css::presentation::EffectPresetClass::EXIT, 58 ,"ooo-exit-fold" }, + + { css::presentation::EffectPresetClass::MOTIONPATH, 16 ,"ooo-motionpath-4-point-star" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 5 ,"ooo-motionpath-5-point-star" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 11 ,"ooo-motionpath-6-point-star" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 17 ,"ooo-motionpath-8-point-star" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 1 ,"ooo-motionpath-circle" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 6 ,"ooo-motionpath-crescent-moon" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 3 ,"ooo-motionpath-diamond" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 13 ,"ooo-motionpath-equal-triangle" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 12 ,"ooo-motionpath-oval" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 9 ,"ooo-motionpath-heart" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 4 ,"ooo-motionpath-hexagon" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 10 ,"ooo-motionpath-octagon" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 14 ,"ooo-motionpath-parallelogram" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 15 ,"ooo-motionpath-pentagon" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 2 ,"ooo-motionpath-right-triangle" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 7 ,"ooo-motionpath-square" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 18 ,"ooo-motionpath-teardrop" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 8 ,"ooo-motionpath-trapezoid" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 37 ,"ooo-motionpath-arc-down" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 51 ,"ooo-motionpath-arc-left" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 58 ,"ooo-motionpath-arc-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 44 ,"ooo-motionpath-arc-up" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 41 ,"ooo-motionpath-bounce-left" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 54 ,"ooo-motionpath-bounce-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 48 ,"ooo-motionpath-curvy-left" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 61 ,"ooo-motionpath-curvy-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 60 ,"ooo-motionpath-decaying-wave" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 49 ,"ooo-motionpath-diagonal-down-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 56 ,"ooo-motionpath-diagonal-up-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 42 ,"ooo-motionpath-down" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 52 ,"ooo-motionpath-funnel" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 53 ,"ooo-motionpath-spring" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 62 ,"ooo-motionpath-stairs-down" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 50 ,"ooo-motionpath-turn-down" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 36 ,"ooo-motionpath-turn-down-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 43 ,"ooo-motionpath-turn-up" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 57 ,"ooo-motionpath-turn-up-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 64 ,"ooo-motionpath-up" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 47 ,"ooo-motionpath-wave" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 38 ,"ooo-motionpath-zigzag" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 31 ,"ooo-motionpath-bean" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 25 ,"ooo-motionpath-buzz-saw" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 20 ,"ooo-motionpath-curved-square" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 21 ,"ooo-motionpath-curved-x" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 23 ,"ooo-motionpath-curvy-star" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 28 ,"ooo-motionpath-figure-8-four" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 26 ,"ooo-motionpath-horizontal-figure-8" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 34 ,"ooo-motionpath-inverted-square" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 33 ,"ooo-motionpath-inverted-triangle" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 24 ,"ooo-motionpath-loop-de-loop" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 29 ,"ooo-motionpath-neutron" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 27 ,"ooo-motionpath-peanut" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 32 ,"ooo-motionpath-clover" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 19 ,"ooo-motionpath-pointy-star" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 30 ,"ooo-motionpath-swoosh" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 22 ,"ooo-motionpath-vertical-figure-8" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 35 ,"ooo-motionpath-left" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 63 ,"ooo-motionpath-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 55 ,"ooo-motionpath-spiral-left" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 46 ,"ooo-motionpath-spiral-right" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 40 ,"ooo-motionpath-sine-wave" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 59 ,"ooo-motionpath-s-curve-1" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 39 ,"ooo-motionpath-s-curve-2" }, + { css::presentation::EffectPresetClass::MOTIONPATH, 45 ,"ooo-motionpath-heartbeat" }, + + { 0,0,nullptr } + }; + + return aList; +}; + +OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId, sal_Int32 nPresetSubType ) +{ + const char* pStr = nullptr; + + 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 == nullptr ) + { + const convert_subtype* p = convert_subtype::getList(); + + while( p->mpStrSubType ) + { + if( p->mnID == nPresetSubType ) + { + pStr = p->mpStrSubType; + break; + } + p++; + } + } + } + } + + if( pStr ) + return OUString::createFromAscii( pStr ); + else + return OUString::number( nPresetSubType ); +} + + CommonTimeNodeContext::CommonTimeNodeContext( + FragmentHandler2 const & rParent, + sal_Int32 aElement, + const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode ) + : TimeNodeContext( rParent, aElement, 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[ "after-effect" ] + <<= attribs.getBool( XML_afterEffect, false ); + } + aProps[ NP_AUTOREVERSE ] <<= 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 ] <<= 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[ "node-type" ] <<= nEnum; + } + + // ST_TLTimeNodePresetClassType + nInt = xAttribs->getOptionalValueToken( XML_presetClass, 0 ); + if( nInt != 0 ) + { + sal_Int16 nEffectPresetClass = 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[ "preset-class" ] <<= nEffectPresetClass; + if( attribs.hasAttribute( XML_presetID ) ) + { + sal_Int32 nPresetId = attribs.getInteger( XML_presetID, 0 ); + const preset_mapping* p = preset_mapping::getList(); + while( p->mpStrPresetId && ((p->mnPresetClass != nEffectPresetClass) || (p->mnPresetId != nPresetId )) ) + p++; + + aUserData[ "preset-id" ] + <<= OUString::createFromAscii( p->mpStrPresetId ); + sal_Int32 nPresetSubType = attribs.getInteger( XML_presetSubtype, 0 ); + if( nPresetSubType ) + { + aUserData[ "preset-sub-type" ] <<= 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 ] <<= nEnum; + } + // ST_Percentage TODO + xAttribs->getOptionalValue( XML_spd /*"10000" */ ); + // ST_TLTimeNodeSyncType TODO + xAttribs->getOptionalValue( XML_syncBehavior ); + // TODO (string) + xAttribs->getOptionalValue( XML_tmFilter ); + } + + CommonTimeNodeContext::~CommonTimeNodeContext( ) noexcept + { + } + + void CommonTimeNodeContext::onEndElement() + { + if( isCurrentElement( PPT_TOKEN( iterate ) ) ) + { + mbIterate = false; + } + } + + ::oox::core::ContextHandlerRef CommonTimeNodeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) + { + + switch ( aElementToken ) + { + case PPT_TOKEN( childTnLst ): + case PPT_TOKEN( subTnLst ): + return new TimeNodeListContext( *this, mpNode->getChildren() ); + + case PPT_TOKEN( stCondLst ): + return new CondListContext( *this, aElementToken, mpNode, mpNode->getStartCondition() ); + case PPT_TOKEN( endCondLst ): + return new CondListContext( *this, aElementToken, mpNode, mpNode->getEndCondition() ); + + case PPT_TOKEN( endSync ): + return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, mpNode->getEndSyncValue() ); + case PPT_TOKEN( iterate ): + { + sal_Int32 nVal = rAttribs.getToken( 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. + // TODO what to do with this + /*bool bBackwards =*/ rAttribs.getBool( XML_backwards, false ); + mbIterate = true; + return this; + } + case PPT_TOKEN( tmAbs ): + if( mbIterate ) + { + double fTime = rAttribs.getUnsigned( XML_val, 0 ) / 1000.0; // convert ms. to second. + mpNode->getNodeProperties()[NP_ITERATEINTERVAL] <<= fTime; + } + return this; + case PPT_TOKEN( tmPct ): + if( mbIterate ) + { + // TODO: should use duration to get iterate interval in second. + double fPercent = static_cast(rAttribs.getUnsigned( XML_val, 0 )) / 100000.0; + mpNode->getNodeProperties()[ NP_ITERATEINTERVAL ] <<= fPercent; + } + return this; + default: + break; + } + + return this; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commontimenodecontext.hxx b/oox/source/ppt/commontimenodecontext.hxx new file mode 100644 index 000000000..80ca74926 --- /dev/null +++ b/oox/source/ppt/commontimenodecontext.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_COMMONTIMENODECONTEXT_HXX +#define INCLUDED_OOX_SOURCE_PPT_COMMONTIMENODECONTEXT_HXX + +#include +#include + +namespace oox::ppt { + + /** CT_TLCommonTimeNodeData */ + class CommonTimeNodeContext + : public TimeNodeContext + { + public: + CommonTimeNodeContext( ::oox::core::FragmentHandler2 const & rParent, sal_Int32 aElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs, const TimeNodePtr & pNode); + virtual ~CommonTimeNodeContext( ) noexcept override; + + virtual void onEndElement() override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; + + private: + bool mbIterate; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/conditioncontext.cxx b/oox/source/ppt/conditioncontext.cxx new file mode 100644 index 000000000..650d7ef9c --- /dev/null +++ b/oox/source/ppt/conditioncontext.cxx @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "conditioncontext.hxx" + +#include +#include + +#include +#include +#include "animationtypes.hxx" +#include +#include + +#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::ppt { + + CondContext::CondContext( FragmentHandler2 const & rParent, const Reference< XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode, AnimationCondition & aValue ) + : TimeNodeContext( rParent, PPT_TOKEN( cond ), 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( ) noexcept + { + if( maCond.mnType == 0 || maCond.mnType == PPT_TOKEN(tn)) + { + maCond.maValue = (maEvent.Trigger == EventTrigger::NONE) ? maEvent.Offset : Any( maEvent ); + } + } + + ::oox::core::ContextHandlerRef CondContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) + { + switch( aElementToken ) + { + case PPT_TOKEN( rtn ): + { + // ST_TLTriggerRuntimeNode { first, last, all } + sal_Int32 aTok; + sal_Int16 nEnum; + aTok = rAttribs.getToken( 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 <<= nEnum; + return this; + } + case PPT_TOKEN( tn ): + { + maCond.mnType = aElementToken; + // Convert the node id string to XAnimationNode later + maEvent.Source <<= rAttribs.getString(XML_val, OUString()); + return this; + } + case PPT_TOKEN( tgtEl ): + // CT_TLTimeTargetElement + return new TimeTargetElementContext( *this, maCond.getTarget() ); + default: + break; + } + + return this; + + } + + /** CT_TLTimeConditionList */ + CondListContext::CondListContext( + FragmentHandler2 const & rParent, sal_Int32 aElement, + const TimeNodePtr & pNode, + AnimationConditionList & aCond ) + : TimeNodeContext( rParent, aElement, pNode ) + , maConditions( aCond ) + { + } + + CondListContext::~CondListContext( ) + noexcept + { + } + + ::oox::core::ContextHandlerRef CondListContext::onCreateContext( sal_Int32 aElement, const AttributeList& rAttribs ) + { + switch( aElement ) + { + case PPT_TOKEN( cond ): + // add a condition to the list + maConditions.emplace_back( ); + return new CondContext( *this, rAttribs.getFastAttributeList(), mpNode, maConditions.back() ); + default: + break; + } + return this; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/conditioncontext.hxx b/oox/source/ppt/conditioncontext.hxx new file mode 100644 index 000000000..fd8d4dd10 --- /dev/null +++ b/oox/source/ppt/conditioncontext.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_CONDITIONCONTEXT_HXX +#define INCLUDED_OOX_SOURCE_PPT_CONDITIONCONTEXT_HXX + +#include + +#include +#include +#include + +namespace oox::ppt { + + /** CT_TLTimeCondition */ + class CondContext + : public TimeNodeContext + { + public: + CondContext( ::oox::core::FragmentHandler2 const & rParent, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs, + const TimeNodePtr & pNode, AnimationCondition & aCond ); + virtual ~CondContext( ) noexcept override; + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; + + private: + css::animations::Event maEvent; + AnimationCondition & maCond; + }; + + /** CT_TLTimeConditionList */ + class CondListContext + : public TimeNodeContext + { + public: + CondListContext( ::oox::core::FragmentHandler2 const & rParent, + sal_Int32 aElement, + const TimeNodePtr & pNode, AnimationConditionList & aCondList ); + virtual ~CondListContext( ) noexcept override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; + + private: + AnimationConditionList & maConditions; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/customshowlistcontext.cxx b/oox/source/ppt/customshowlistcontext.cxx new file mode 100644 index 000000000..1e6befd63 --- /dev/null +++ b/oox/source/ppt/customshowlistcontext.cxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include +#include + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::ppt { + +namespace { + +class CustomShowContext : public ::oox::core::FragmentHandler2 +{ + std::vector< CustomShow >& mrCustomShowList; + +public: + CustomShowContext( ::oox::core::FragmentHandler2 const & rParent, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs, + std::vector< CustomShow >& rCustomShowList ); + + virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override; +}; + +} + +CustomShowContext::CustomShowContext( FragmentHandler2 const & rParent, + const Reference< XFastAttributeList >& rxAttribs, + std::vector< CustomShow >& rCustomShowList ) +: FragmentHandler2( rParent ) +, mrCustomShowList( rCustomShowList ) +{ + CustomShow aCustomShow; + aCustomShow.maCustomShowName = rxAttribs->getOptionalValue( XML_name ); + aCustomShow.mnId = rxAttribs->getOptionalValue( XML_id ); + mrCustomShowList.push_back(aCustomShow); +} + +::oox::core::ContextHandlerRef CustomShowContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case PPT_TOKEN( sld ) : + mrCustomShowList.back().maSldLst.push_back( + getRelations() + .getRelationFromRelId(rAttribs.getString(R_TOKEN(id), OUString())) + ->maTarget); + return this; + default: + break; + } + + return this; +} + +CustomShowListContext::CustomShowListContext( FragmentHandler2 const & rParent, + std::vector< CustomShow >& rCustomShowList ) +: FragmentHandler2( rParent ) +, mrCustomShowList( rCustomShowList ) +{ +} + +CustomShowListContext::~CustomShowListContext( ) +{ +} + +::oox::core::ContextHandlerRef CustomShowListContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case PPT_TOKEN( custShow ) : + { + return new CustomShowContext( *this, rAttribs.getFastAttributeList(), mrCustomShowList ); + } + default: + break; + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/extdrawingfragmenthandler.cxx b/oox/source/ppt/extdrawingfragmenthandler.cxx new file mode 100644 index 000000000..9aad170c1 --- /dev/null +++ b/oox/source/ppt/extdrawingfragmenthandler.cxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "extdrawingfragmenthandler.hxx" + +#include +#include +#include + +using namespace ::oox::core; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::uno; + +namespace oox::ppt { + +ExtDrawingFragmentHandler::ExtDrawingFragmentHandler( XmlFilterBase& rFilter, + const OUString& rFragmentPath, + const oox::ppt::SlidePersistPtr& rSlidePersistPtr, + const oox::ppt::ShapeLocation eShapeLocation, + oox::drawingml::ShapePtr const & pGroupShapePtr, + oox::drawingml::ShapePtr const & pShapePtr) + : FragmentHandler2( rFilter, rFragmentPath ), + mpSlidePersistPtr (rSlidePersistPtr ), + meShapeLocation( eShapeLocation ), + mpGroupShapePtr( pGroupShapePtr ), + mpShapePtr( pShapePtr ) +{ +} + +ExtDrawingFragmentHandler::~ExtDrawingFragmentHandler( ) noexcept +{ + // Empty DrawingML fallback, need to warn the user at the end. + if (mpShapePtr && mpShapePtr->getChildren().empty()) + getFilter().setMissingExtDrawing(); +} + +ContextHandlerRef +ExtDrawingFragmentHandler::onCreateContext( ::sal_Int32 aElement, + const AttributeList& ) +{ + switch( aElement ) + { + case DSP_TOKEN( drawing ): + break; + case DSP_TOKEN( spTree ): + return new PPTShapeGroupContext( + *this, mpSlidePersistPtr, meShapeLocation, mpGroupShapePtr, + mpShapePtr ); + default: + break; + } + + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/extdrawingfragmenthandler.hxx b/oox/source/ppt/extdrawingfragmenthandler.hxx new file mode 100644 index 000000000..22406f3d9 --- /dev/null +++ b/oox/source/ppt/extdrawingfragmenthandler.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_EXTDRAWINGFRAGMENTHANDLER_HXX +#define INCLUDED_OOX_SOURCE_PPT_EXTDRAWINGFRAGMENTHANDLER_HXX + +#include +#include + +namespace oox::ppt { + +class ExtDrawingFragmentHandler : public ::oox::core::FragmentHandler2 +{ +public: + ExtDrawingFragmentHandler( oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath, + const oox::ppt::SlidePersistPtr& rSlidePersistPtr, + const oox::ppt::ShapeLocation eShapeLocation, + oox::drawingml::ShapePtr const & pGroupShapePtr, + oox::drawingml::ShapePtr const & pShapePtr ); + virtual ~ExtDrawingFragmentHandler() noexcept override; + + virtual ::oox::core::ContextHandlerRef onCreateContext( ::sal_Int32 Element, const AttributeList& rAttribs ) override; + +private: + const oox::ppt::SlidePersistPtr mpSlidePersistPtr; + const oox::ppt::ShapeLocation meShapeLocation; + oox::drawingml::ShapePtr mpGroupShapePtr; + oox::drawingml::ShapePtr mpShapePtr; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/headerfootercontext.cxx b/oox/source/ppt/headerfootercontext.cxx new file mode 100644 index 000000000..2a51fdafd --- /dev/null +++ b/oox/source/ppt/headerfootercontext.cxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "headerfootercontext.hxx" +#include +#include + +using namespace ::oox::core; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +namespace oox::ppt { + + HeaderFooterContext::HeaderFooterContext( FragmentHandler2 const & rParent, + const AttributeList& rAttribs, HeaderFooter& rHeaderFooter ) + : FragmentHandler2( rParent ) + { + if ( rAttribs.hasAttribute( XML_sldNum ) ) + { + rHeaderFooter.mbSlideNumber = rAttribs.getBool( XML_sldNum, true ); + } + if ( rAttribs.hasAttribute( XML_hdr ) ) + { + rHeaderFooter.mbHeader = rAttribs.getBool( XML_hdr, true ); + } + if ( rAttribs.hasAttribute( XML_ftr ) ) + { + rHeaderFooter.mbFooter = rAttribs.getBool( XML_ftr, true ); + } + if ( rAttribs.hasAttribute( XML_dt ) ) + { + rHeaderFooter.mbDateTime = rAttribs.getBool( XML_dt, true ); + } + } + + HeaderFooterContext::~HeaderFooterContext( ) + { + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/headerfootercontext.hxx b/oox/source/ppt/headerfootercontext.hxx new file mode 100644 index 000000000..9b93fb5f1 --- /dev/null +++ b/oox/source/ppt/headerfootercontext.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_OOX_SOURCE_PPT_HEADERFOOTERCONTEXT_HXX +#define INCLUDED_OOX_SOURCE_PPT_HEADERFOOTERCONTEXT_HXX + +#include +#include + +namespace oox::ppt { + + /** CT_HeaderFooter */ + class HeaderFooterContext : public ::oox::core::FragmentHandler2 + { + public: + HeaderFooterContext( ::oox::core::FragmentHandler2 const & rParent, + const AttributeList& rAttribs, HeaderFooter& rHeaderFooter ); + + virtual ~HeaderFooterContext( ) override; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/layoutfragmenthandler.cxx b/oox/source/ppt/layoutfragmenthandler.cxx new file mode 100644 index 000000000..9d95b6ecc --- /dev/null +++ b/oox/source/ppt/layoutfragmenthandler.cxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "headerfootercontext.hxx" +#include +#include +#include +#include +#include + +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; + +namespace oox::ppt { + +// CT_SlideLayout + +LayoutFragmentHandler::LayoutFragmentHandler(XmlFilterBase& rFilter, const OUString& rFragmentPath, + const SlidePersistPtr& pMasterPersistPtr) + : SlideFragmentHandler(rFilter, rFragmentPath, pMasterPersistPtr, Layout) +{ +} + +LayoutFragmentHandler::~LayoutFragmentHandler() +{ + +} + +ContextHandlerRef LayoutFragmentHandler::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + case PPT_TOKEN( sldLayout ): // CT_SlideLayout + { + mpSlidePersistPtr->setLayoutValueToken( rAttribs.getToken( XML_type, 0 ) ); // CT_SlideLayoutType + + OptValue< bool > aShowMasterShapes = rAttribs.getBool( XML_showMasterSp ); + if( aShowMasterShapes.has() && !aShowMasterShapes.get() ) { + mpSlidePersistPtr->hideShapesAsMasterShapes(); + } + break; + } + case PPT_TOKEN( hf ): // CT_HeaderFooter + return new HeaderFooterContext( *this, rAttribs, mpSlidePersistPtr->getHeaderFooter() ); + default: + return SlideFragmentHandler::onCreateContext( aElementToken, rAttribs ); + } + return this; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptfilterhelpers.cxx b/oox/source/ppt/pptfilterhelpers.cxx new file mode 100644 index 000000000..054bf6260 --- /dev/null +++ b/oox/source/ppt/pptfilterhelpers.cxx @@ -0,0 +1,422 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + int lcl_gethex(int nChar) + { + if (nChar >= '0' && nChar <= '9') + return nChar - '0'; + else if (nChar >= 'a' && nChar <= 'f') + return nChar - 'a' + 10; + else if (nChar >= 'A' && nChar <= 'F') + return nChar - 'A' + 10; + else + return 0; + } +} + +namespace oox::ppt { + + const ImplAttributeNameConversion *getAttributeConversionList() + { + static const ImplAttributeNameConversion aList[] = + { + { AnimationAttributeEnum::PPT_X, "ppt_x", "X" }, + { AnimationAttributeEnum::PPT_Y, "ppt_y", "Y" }, + { AnimationAttributeEnum::PPT_W, "ppt_w", "Width" }, + { AnimationAttributeEnum::PPT_H, "ppt_h", "Height" }, + { AnimationAttributeEnum::PPT_C, "ppt_c", "DimColor" }, + { AnimationAttributeEnum::R, "r", "Rotate" }, + { AnimationAttributeEnum::XSHEAR, "xshear", "SkewX" }, + { AnimationAttributeEnum::FILLCOLOR, "fillcolor", "FillColor" }, + { AnimationAttributeEnum::FILLCOLOR, "fillColor", "FillColor" }, + { AnimationAttributeEnum::FILLTYPE, "fill.type", "FillStyle" }, + { AnimationAttributeEnum::FILLON, "fill.on", "FillOn" }, + { AnimationAttributeEnum::STROKECOLOR, "stroke.color", "LineColor" }, + { AnimationAttributeEnum::STROKEON, "stroke.on", "LineStyle" }, + { AnimationAttributeEnum::STYLECOLOR, "style.color", "CharColor" }, + { AnimationAttributeEnum::STYLEROTATION, "style.rotation", "Rotate" }, + { AnimationAttributeEnum::FONTWEIGHT, "style.fontWeight", "CharWeight" }, + { AnimationAttributeEnum::STYLEUNDERLINE, "style.textDecorationUnderline","CharUnderline" }, + { AnimationAttributeEnum::STYLEFONTFAMILY, "style.fontFamily", "CharFontName" }, + { AnimationAttributeEnum::STYLEFONTSIZE, "style.fontSize", "CharHeight" }, + { AnimationAttributeEnum::STYLEFONTSTYLE, "style.fontStyle", "CharPosture" }, + { AnimationAttributeEnum::STYLEVISIBILITY, "style.visibility", "Visibility" }, + { AnimationAttributeEnum::STYLEOPACITY, "style.opacity", "Opacity" }, + { AnimationAttributeEnum::UNKNOWN, nullptr, nullptr } + }; + + return aList; + } + + const transition* transition::getList() + { + static const transition aList[] = + { + { "wipe(up)", css::animations::TransitionType::BARWIPE, css::animations::TransitionSubType::TOPTOBOTTOM, true }, + { "wipe(right)", css::animations::TransitionType::BARWIPE, css::animations::TransitionSubType::LEFTTORIGHT, false }, + { "wipe(left)", css::animations::TransitionType::BARWIPE, css::animations::TransitionSubType::LEFTTORIGHT, true }, + { "wipe(down)", css::animations::TransitionType::BARWIPE, css::animations::TransitionSubType::TOPTOBOTTOM, false }, + { "wheel(1)", css::animations::TransitionType::PINWHEELWIPE, css::animations::TransitionSubType::ONEBLADE, true }, + { "wheel(2)", css::animations::TransitionType::PINWHEELWIPE, css::animations::TransitionSubType::TWOBLADEVERTICAL, true }, + { "wheel(3)", css::animations::TransitionType::PINWHEELWIPE, css::animations::TransitionSubType::THREEBLADE, true }, + { "wheel(4)", css::animations::TransitionType::PINWHEELWIPE, css::animations::TransitionSubType::FOURBLADE, true }, + { "wheel(8)", css::animations::TransitionType::PINWHEELWIPE, css::animations::TransitionSubType::EIGHTBLADE, true }, + { "strips(downLeft)", css::animations::TransitionType::WATERFALLWIPE, css::animations::TransitionSubType::HORIZONTALRIGHT, true }, + { "strips(upLeft)", css::animations::TransitionType::WATERFALLWIPE, css::animations::TransitionSubType::HORIZONTALLEFT, false }, + { "strips(downRight)", css::animations::TransitionType::WATERFALLWIPE, css::animations::TransitionSubType::HORIZONTALLEFT, true }, + { "strips(upRight)", css::animations::TransitionType::WATERFALLWIPE, css::animations::TransitionSubType::HORIZONTALRIGHT, false }, + { "barn(inVertical)", css::animations::TransitionType::BARNDOORWIPE, css::animations::TransitionSubType::VERTICAL, false }, + { "barn(outVertical)", css::animations::TransitionType::BARNDOORWIPE, css::animations::TransitionSubType::VERTICAL, true }, + { "barn(inHorizontal)", css::animations::TransitionType::BARNDOORWIPE, css::animations::TransitionSubType::HORIZONTAL, false }, + { "barn(outHorizontal)", css::animations::TransitionType::BARNDOORWIPE, css::animations::TransitionSubType::HORIZONTAL, true }, + { "randombar(vertical)", css::animations::TransitionType::RANDOMBARWIPE, css::animations::TransitionSubType::VERTICAL, true}, + { "randombar(horizontal)", css::animations::TransitionType::RANDOMBARWIPE, css::animations::TransitionSubType::HORIZONTAL, true }, + { "checkerboard(down)", css::animations::TransitionType::CHECKERBOARDWIPE, css::animations::TransitionSubType::DOWN, true}, + { "checkerboard(across)", css::animations::TransitionType::CHECKERBOARDWIPE, css::animations::TransitionSubType::ACROSS, true }, + { "plus(out)", css::animations::TransitionType::FOURBOXWIPE, css::animations::TransitionSubType::CORNERSIN, false }, + { "plus(in)", css::animations::TransitionType::FOURBOXWIPE, css::animations::TransitionSubType::CORNERSIN, true }, + { "diamond(out)", css::animations::TransitionType::IRISWIPE, css::animations::TransitionSubType::DIAMOND, true }, + { "diamond(in)", css::animations::TransitionType::IRISWIPE, css::animations::TransitionSubType::DIAMOND, false }, + { "circle(out)", css::animations::TransitionType::ELLIPSEWIPE, css::animations::TransitionSubType::HORIZONTAL, true }, + { "circle(in)", css::animations::TransitionType::ELLIPSEWIPE, css::animations::TransitionSubType::HORIZONTAL, false }, + { "box(out)", css::animations::TransitionType::IRISWIPE, css::animations::TransitionSubType::RECTANGLE, true }, + { "box(in)", css::animations::TransitionType::IRISWIPE, css::animations::TransitionSubType::RECTANGLE, false }, + { "wedge", css::animations::TransitionType::FANWIPE, css::animations::TransitionSubType::CENTERTOP, true }, + { "blinds(vertical)", css::animations::TransitionType::BLINDSWIPE, css::animations::TransitionSubType::VERTICAL, true }, + { "blinds(horizontal)", css::animations::TransitionType::BLINDSWIPE, css::animations::TransitionSubType::HORIZONTAL, true }, + { "fade", css::animations::TransitionType::FADE, css::animations::TransitionSubType::CROSSFADE, true }, + { "slide(fromTop)", css::animations::TransitionType::SLIDEWIPE, css::animations::TransitionSubType::FROMTOP, true }, + { "slide(fromRight)", css::animations::TransitionType::SLIDEWIPE, css::animations::TransitionSubType::FROMRIGHT, true }, + { "slide(fromLeft)", css::animations::TransitionType::SLIDEWIPE, css::animations::TransitionSubType::FROMLEFT, true }, + { "slide(fromBottom)", css::animations::TransitionType::SLIDEWIPE, css::animations::TransitionSubType::FROMBOTTOM, true }, + { "dissolve", css::animations::TransitionType::DISSOLVE, css::animations::TransitionSubType::DEFAULT, true }, + { "image", css::animations::TransitionType::DISSOLVE, css::animations::TransitionSubType::DEFAULT, true }, // TODO + { nullptr, 0, 0, false } + }; + + return aList; + } + + const transition* transition::find( std::u16string_view rName ) + { + const transition* p = transition::getList(); + + while( p->mpName ) + { + if( o3tl::equalsAscii( rName, p->mpName ) ) + return p; + + p++; + } + + return nullptr; + } + + bool convertMeasure(OUString& rString) + { + bool bRet = false; + + const char* pSource[] = { "ppt_x", "ppt_y", "ppt_w", "ppt_h", nullptr }; + const char* pDest[] = { "x", "y", "width", "height", nullptr }; + + /* here we want to substitute all occurrences of + * [#]ppt_[xyhw] with + * x,y,height and width respectively + */ + sal_Int32 nIndex = 0; + + const char** ps = pSource; + const 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[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; + } + + bool convertAnimationValue(AnimationAttributeEnum eAttribute, css::uno::Any& rValue) + { + using css::animations::ValuePair; + bool bRet = false; + switch (eAttribute) + { + case AnimationAttributeEnum::PPT_X: + case AnimationAttributeEnum::PPT_Y: + case AnimationAttributeEnum::PPT_W: + case AnimationAttributeEnum::PPT_H: + { + OUString aString; + + if (rValue.getValueType() == cppu::UnoType::get()) + { + ValuePair aValuePair; + if (rValue >>= aValuePair) + { + if (aValuePair.First >>= aString) + { + if (convertMeasure(aString)) + { + aValuePair.First <<= aString; + bRet = true; + } + } + + if (aValuePair.Second >>= aString) + { + if (convertMeasure(aString)) + { + aValuePair.Second <<= aString; + bRet = true; + } + } + } + } + else if (rValue.getValueType() == cppu::UnoType::get()) + { + if (rValue >>= aString) + { + bRet = convertMeasure(aString); + + if (bRet) + rValue <<= aString; + } + } + } + break; + + case AnimationAttributeEnum::XSHEAR: + case AnimationAttributeEnum::R: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString.toDouble(); + bRet = true; + } + } + break; + + case AnimationAttributeEnum::STYLEROTATION: + { + if (rValue.getValueType() == cppu::UnoType::get()) + { + OUString aString; + rValue >>= aString; + rValue <<= static_cast(aString.toDouble()); + bRet = true; + } + else if (rValue.getValueType() == cppu::UnoType::get()) + { + double fValue = 0.0; + rValue >>= fValue; + rValue <<= static_cast(fValue); + bRet = true; + } + } + break; + + case AnimationAttributeEnum::FILLCOLOR: + case AnimationAttributeEnum::STROKECOLOR: + case AnimationAttributeEnum::STYLECOLOR: + case AnimationAttributeEnum::PPT_C: + { + OUString aString; + if (rValue >>= aString) + { + if (aString.getLength() >= 7 && aString[0] == '#') + { + Color aColor; + aColor.SetRed(static_cast(lcl_gethex(aString[1]) * 16 + + lcl_gethex(aString[2]))); + aColor.SetGreen(static_cast(lcl_gethex(aString[3]) * 16 + + lcl_gethex(aString[4]))); + aColor.SetBlue(static_cast(lcl_gethex(aString[5]) * 16 + + lcl_gethex(aString[6]))); + rValue <<= aColor; + bRet = true; + } + else if (aString.startsWith("rgb(")) + { + aString = aString.copy(4, aString.getLength() - 5); + Color aColor; + sal_Int32 index = 0; + aColor.SetRed( + static_cast(o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)))); + aColor.SetGreen( + static_cast(o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)))); + aColor.SetRed( + static_cast(o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)))); + rValue <<= aColor; + bRet = true; + } + else if (aString.startsWith("hsl(")) + { + sal_Int32 index = 0; + sal_Int32 nA = o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)); + sal_Int32 nB = o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)); + sal_Int32 nC = o3tl::toInt32(o3tl::getToken(aString, 0, ',', index)); + css::uno::Sequence aHSL + { + nA * 360.0 / 255.0, + nB / 255.0, + nC / 255.0 + }; + rValue <<= aHSL; + bRet = true; + } + } + } + break; + case AnimationAttributeEnum::FILLON: + { + // Slideshow doesn't support FillOn, but we need to convert the value type + // so it can be written out again. + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString == "true"; + bRet = true; + } + } + break; + + case AnimationAttributeEnum::FILLTYPE: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString == "solid" ? css::drawing::FillStyle_SOLID + : css::drawing::FillStyle_NONE; + bRet = true; + } + } + break; + + case AnimationAttributeEnum::STROKEON: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString == "true" ? css::drawing::LineStyle_SOLID + : css::drawing::LineStyle_NONE; + bRet = true; + } + } + break; + + case AnimationAttributeEnum::FONTWEIGHT: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString == "bold" ? css::awt::FontWeight::BOLD + : css::awt::FontWeight::NORMAL; + bRet = true; + } + } + break; + + case AnimationAttributeEnum::STYLEFONTSTYLE: + { + OUString aString; + if (rValue >>= aString) + { + rValue + <<= aString == "italic" ? css::awt::FontSlant_ITALIC : css::awt::FontSlant_NONE; + bRet = true; + } + } + break; + + case AnimationAttributeEnum::STYLEUNDERLINE: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString == "true" ? css::awt::FontUnderline::SINGLE + : css::awt::FontUnderline::NONE; + bRet = true; + } + } + break; + + case AnimationAttributeEnum::STYLEOPACITY: + case AnimationAttributeEnum::STYLEFONTSIZE: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= static_cast(aString.toDouble()); + bRet = true; + } + } + break; + + case AnimationAttributeEnum::STYLEVISIBILITY: + { + OUString aString; + if (rValue >>= aString) + { + rValue <<= aString == "visible"; + bRet = true; + } + } + break; + default: + break; + } + + return bRet; + } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx b/oox/source/ppt/pptgraphicshapecontext.cxx new file mode 100644 index 000000000..254f44809 --- /dev/null +++ b/oox/source/ppt/pptgraphicshapecontext.cxx @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::text; + +namespace oox::ppt { + +// CT_Shape +PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler2Helper const & rParent, const SlidePersistPtr& rSlidePersistPtr, const oox::drawingml::ShapePtr& pMasterShapePtr, const oox::drawingml::ShapePtr& pShapePtr ) +: oox::drawingml::GraphicShapeContext( rParent, pMasterShapePtr, pShapePtr ) +, mpSlidePersistPtr( rSlidePersistPtr ) +{ +} + +ContextHandlerRef PPTGraphicShapeContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) +{ + switch( aElementToken ) + { + // nvSpPr CT_ShapeNonVisual begin +// case NMSP_PPT|XML_drElemPr: +// break; + case PPT_TOKEN(cNvPr): + mpShapePtr->setId( rAttribs.getString( XML_id ).get() ); + mpShapePtr->setName( rAttribs.getString( XML_name ).get() ); + break; + case PPT_TOKEN(ph): + { + sal_Int32 nSubType( rAttribs.getToken( XML_type, XML_obj ) ); + mpShapePtr->setSubType( nSubType ); + OUString sIdx( rAttribs.getString( XML_idx ).get() ); + bool bHasIdx = !sIdx.isEmpty(); + sal_Int32 nIdx = sIdx.toInt32(); + if( rAttribs.hasAttribute( XML_idx ) ) + mpShapePtr->setSubTypeIndex( nIdx ); + + if ( nSubType || bHasIdx ) + { + PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); + if ( pPPTShapePtr ) + { + oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation(); + oox::drawingml::ShapePtr pPlaceholder; + + if ( bHasIdx && eShapeLocation == Slide ) + { + // TODO: use id to shape map + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); + if ( pMasterPersist && rAttribs.hasAttribute( XML_idx ) ) + pPlaceholder = PPTShape::findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() ); + } + if ( !pPlaceholder && ( ( 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_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; + break; + default: + break; + } + if ( nFirstPlaceholder ) + { + if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree + pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, + pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren(), true ); + else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects + { + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); + if ( pMasterPersist ) + pPlaceholder = PPTShape::findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, + pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + } + } + } + if ( pPlaceholder ) + { + bool bUseText = true; + switch( pPlaceholder->getSubType() ) + { + case XML_title : + case XML_body : + case XML_ctrTitle : + case XML_subTitle : + case XML_dt : + case XML_sldNum : + case XML_ftr : + case XML_hdr : + case XML_obj : + case XML_chart : + case XML_tbl : + case XML_clipArt : + case XML_dgm : + case XML_media : + case XML_sldImg : + case XML_pic : + bUseText = false; + } + pPlaceholder->getShapeProperties().setAnyProperty( + PROP_URL, mpShapePtr->getShapeProperties().getProperty(PROP_URL)); + mpShapePtr->applyShapeReference( *pPlaceholder, bUseText ); + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); + if ( pPPTShape ) + pPPTShape->setReferenced( true ); + pPPTShapePtr->setPlaceholder( pPlaceholder ); + } + } + } + break; + } + // nvSpPr CT_ShapeNonVisual end + + case PPT_TOKEN(spPr): + return new PPTShapePropertiesContext( *this, *mpShapePtr ); + + case PPT_TOKEN(style): + return new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); + + case PPT_TOKEN(txBody): + { + oox::drawingml::TextBodyPtr xTextBody = std::make_shared(); + mpShapePtr->setTextBody( xTextBody ); + return new oox::drawingml::TextBodyContext( *this, *xTextBody ); + } + } + + return GraphicShapeContext::onCreateContext( aElementToken, rAttribs ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx new file mode 100644 index 000000000..55e094db6 --- /dev/null +++ b/oox/source/ppt/pptimport.cxx @@ -0,0 +1,309 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace oox::core; + +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::lang::XComponent; + +namespace oox::ppt { + +#if OSL_DEBUG_LEVEL > 0 +XmlFilterBase* PowerPointImport::mpDebugFilterBase = nullptr; +#endif + +PowerPointImport::PowerPointImport( const Reference< XComponentContext >& rxContext ) : + XmlFilterBase( rxContext ), +#if ENABLE_WASM_STRIP_CHART + // WASM_CHART change + mxChartConv( ) +#else + mxChartConv( std::make_shared<::oox::drawingml::chart::ChartConverter>() ) +#endif +{ +#if OSL_DEBUG_LEVEL > 0 + mpDebugFilterBase = this; +#endif +} + +PowerPointImport::~PowerPointImport() +{ +} + +bool PowerPointImport::importDocument() +{ + /* to activate the PPTX dumper, define the environment variable + OOO_PPTXDUMPER and insert the full path to the file + file:////source/dump/pptxdumper.ini. */ + OOX_DUMP_FILE( ::oox::dump::pptx::Dumper ); + + uno::Reference< document::XUndoManagerSupplier > xUndoManagerSupplier (getModel(), UNO_QUERY ); + uno::Reference< util::XLockable > xUndoManager; + bool bWasUnLocked = true; + if(xUndoManagerSupplier.is()) + { + xUndoManager = xUndoManagerSupplier->getUndoManager(); + if(xUndoManager.is()) + { + bWasUnLocked = !xUndoManager->isLocked(); + xUndoManager->lock(); + } + } + + importDocumentProperties(); + + OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( u"officeDocument" ); + FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) ); + maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( u"tableStyles" ); + const OUString sPresPropsPath + = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc(u"presProps"); + + bool bRet = importFragment(xPresentationFragmentHandler); + if (bRet && !sPresPropsPath.isEmpty()) + { + FragmentHandlerRef xPresPropsFragmentHandler( + new PresPropsFragmentHandler(*this, sPresPropsPath)); + importFragment(xPresPropsFragmentHandler); + } + + static bool bNoSmartartWarning = getenv("OOX_NO_SMARTART_WARNING"); + if (!bNoSmartartWarning && mbMissingExtDrawing) + { + // Construct a warning message. + INetURLObject aURL(getFileUrl()); + SfxErrorContext aContext(ERRCTX_SFX_OPENDOC, aURL.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset), nullptr, RID_ERRCTX); + OUString aWarning; + aContext.GetString(ERRCODE_NONE.MakeWarning(), aWarning); + aWarning += ":\n" + SvxResId(RID_SVXSTR_WARN_MISSING_SMARTART); + + // Show it. + std::unique_ptr xWarn(Application::CreateMessageDialog(nullptr, + VclMessageType::Warning, VclButtonsType::Ok, + aWarning)); + xWarn->run(); + } + + if(xUndoManager.is() && bWasUnLocked) + xUndoManager->unlock(); + + return bRet; + +} + +bool PowerPointImport::exportDocument() noexcept +{ + return false; +} + +::Color PowerPointImport::getSchemeColor( sal_Int32 nToken ) const +{ + ::Color nColor; + if ( mpActualSlidePersist ) + { + bool bColorMapped = 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 ) + pClrMapPtr->getColorMap( nToken ); + } + } + + ::oox::drawingml::ThemePtr pTheme = mpActualSlidePersist->getTheme(); + if( pTheme ) + { + pTheme->getClrScheme().getColor( nToken, nColor ); + } + else + { + SAL_WARN("oox", "OOX: PowerPointImport::mpThemePtr is NULL"); + } + } + return nColor; +} + +const ::oox::drawingml::Theme* PowerPointImport::getCurrentTheme() const +{ + return mpActualSlidePersist ? mpActualSlidePersist->getTheme().get() : nullptr; +} + +std::shared_ptr<::oox::drawingml::Theme> PowerPointImport::getCurrentThemePtr() const +{ + return mpActualSlidePersist ? mpActualSlidePersist->getTheme() : std::shared_ptr<::oox::drawingml::Theme>(); +} + +sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& rDescriptor ) +{ + if( XmlFilterBase::filter( rDescriptor ) ) + return true; + + if (isExportFilter()) + { + uno::Sequence aArguments(comphelper::InitAnyPropertySequence( + { + {"IsPPTM", uno::Any(exportVBA())}, + {"IsTemplate", uno::Any(isExportTemplate())}, + })); + + Reference aFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW); + Reference< XExporter > xExporter(aFactory->createInstanceWithArguments("com.sun.star.comp.Impress.oox.PowerPointExport", aArguments), UNO_QUERY); + + if (Reference xFilter{ xExporter, UNO_QUERY }) + { + Reference xUndoManager; + bool bWasUnLocked = true; + if (Reference xUMS{ getModel(), UNO_QUERY }) + { + xUndoManager = xUMS->getUndoManager(); + if (xUndoManager.is()) + { + bWasUnLocked = !xUndoManager->isLocked(); + xUndoManager->lock(); + } + } + comphelper::ScopeGuard aGuard([xUndoManager, bWasUnLocked] { + if (xUndoManager && bWasUnLocked) + xUndoManager->unlock(); + }); + + Reference< XComponent > xDocument = getModel(); + xExporter->setSourceDocument(xDocument); + if (xFilter->filter(rDescriptor)) + return true; + } + } + + return false; +} + +::oox::vml::Drawing* PowerPointImport::getVmlDrawing() +{ + return mpActualSlidePersist ? mpActualSlidePersist->getDrawing() : nullptr; +} + +oox::drawingml::table::TableStyleListPtr PowerPointImport::getTableStyles() +{ + if ( !mpTableStyleList && !maTableStyleListPath.isEmpty() ) + { + mpTableStyleList = std::make_shared( ); + importFragment( new oox::drawingml::table::TableStyleListFragmentHandler( + *this, maTableStyleListPath, *mpTableStyleList ) ); + } + return mpTableStyleList; +} + +::oox::drawingml::chart::ChartConverter* PowerPointImport::getChartConverter() +{ + return mxChartConv.get(); +} + +namespace { + +class PptGraphicHelper : public GraphicHelper +{ +public: + explicit PptGraphicHelper( const PowerPointImport& rFilter ); + virtual ::Color getSchemeColor( sal_Int32 nToken ) const override; + virtual sal_Int32 getDefaultChartAreaFillStyle() const override; +private: + const PowerPointImport& mrFilter; +}; + +PptGraphicHelper::PptGraphicHelper( const PowerPointImport& rFilter ) : + GraphicHelper( rFilter.getComponentContext(), rFilter.getTargetFrame(), rFilter.getStorage() ), + mrFilter( rFilter ) +{ +} + +::Color PptGraphicHelper::getSchemeColor( sal_Int32 nToken ) const +{ + return mrFilter.getSchemeColor( nToken ); +} + +sal_Int32 PptGraphicHelper::getDefaultChartAreaFillStyle() const +{ + return XML_noFill; +} + +} // namespace + +GraphicHelper* PowerPointImport::implCreateGraphicHelper() const +{ + return new PptGraphicHelper( *this ); +} + +::oox::ole::VbaProject* PowerPointImport::implCreateVbaProject() const +{ + return new ::oox::ole::VbaProject( getComponentContext(), getModel(), u"Impress" ); +} + +OUString PowerPointImport::getImplementationName() +{ + return "com.sun.star.comp.oox.ppt.PowerPointImport"; +} + +} + +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_comp_oox_ppt_PowerPointImport_get_implementation( + uno::XComponentContext* pCtx, uno::Sequence const& /*rSeq*/) +{ + return cppu::acquire(new oox::ppt::PowerPointImport(pCtx)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx new file mode 100644 index 000000000..2ec4a3fbe --- /dev/null +++ b/oox/source/ppt/pptshape.cxx @@ -0,0 +1,809 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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::text; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::presentation; + +namespace oox::ppt { + +PPTShape::PPTShape( const oox::ppt::ShapeLocation eShapeLocation, const char* pServiceName ) +: Shape( pServiceName ) +, meShapeLocation( eShapeLocation ) +, mbReferenced( false ) +, mbHasNoninheritedShapeProperties( false ) +{ +} + +PPTShape::~PPTShape() +{ +} + +static const char* lclDebugSubType( sal_Int32 nType ) +{ + switch (nType) { + case XML_ctrTitle : + return "ctrTitle"; + case XML_title : + return "title"; + case XML_subTitle : + return "subTitle"; + case XML_obj : + return "obj"; + case XML_body : + return "body"; + case XML_dt : + return "dt"; + case XML_hdr : + return "hdr"; + case XML_ftr : + return "frt"; + case XML_sldNum : + return "sldNum"; + case XML_sldImg : + return "sldImg"; + } + + return "unknown - please extend lclDebugSubType"; +} + +namespace +{ +bool ShapeHasNoVisualPropertiesOnImport(const oox::ppt::PPTShape& rPPTShape) +{ + return !rPPTShape.hasNonInheritedShapeProperties() + && !rPPTShape.hasShapeStyleRefs() + && !rPPTShape.getTextBody()->hasVisualRunProperties() + && !rPPTShape.getTextBody()->hasNoninheritedBodyProperties() + && !rPPTShape.getTextBody()->hasListStyleOnImport() + && !rPPTShape.getTextBody()->hasParagraphProperties(); +} +} + +oox::drawingml::TextListStylePtr PPTShape::getSubTypeTextListStyle( const SlidePersist& rSlidePersist, sal_Int32 nSubType ) +{ + oox::drawingml::TextListStylePtr pTextListStyle; + + SAL_INFO("oox.ppt", "subtype style: " << lclDebugSubType( nSubType ) ); + + switch( nSubType ) + { + case XML_ctrTitle : + case XML_title : + pTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); + break; + case XML_subTitle : + case XML_obj : + case XML_body : + if ( rSlidePersist.isNotesPage() ) + pTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle(); + else + pTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + break; + } + + return pTextListStyle; +} + +bool PPTShape::IsPlaceHolderCandidate(const SlidePersist& rSlidePersist) const +{ + if (meShapeLocation != Slide) + return false; + if (rSlidePersist.isNotesPage()) + return false; + auto pTextBody = getTextBody(); + if (!pTextBody) + return false; + auto rParagraphs = pTextBody->getParagraphs(); + if (rParagraphs.size() != 1) + return false; + if (rParagraphs.front()->getRuns().size() != 1) + return false; + // If the placeholder has a shape other than rectangle, + // we have to place it in the slide as a CustomShape. + if (!mpCustomShapePropertiesPtr->representsDefaultShape()) + return false; + return ShapeHasNoVisualPropertiesOnImport(*this); +} + +void PPTShape::addShape( + oox::core::XmlFilterBase& rFilterBase, + const SlidePersist& rSlidePersist, + const oox::drawingml::Theme* pTheme, + const Reference< XShapes >& rxShapes, + basegfx::B2DHomMatrix& aTransformation, + ::oox::drawingml::ShapeIdMap* pShapeMap ) +{ + SAL_INFO("oox.ppt","add shape id: " << msId << " location: " << ((meShapeLocation == Master) ? "master" : ((meShapeLocation == Slide) ? "slide" : ((meShapeLocation == Layout) ? "layout" : "other"))) << " subtype: " << mnSubType << " service: " << msServiceName); + // only placeholder from layout are being inserted + if ( mnSubType && ( meShapeLocation == Master ) ) + return; + + OUString sServiceName( msServiceName ); + if (sServiceName.isEmpty()) + return; + try + { + oox::drawingml::TextListStylePtr aMasterTextListStyle; + Reference xServiceFact(rFilterBase.getModel(), UNO_QUERY_THROW); + bool bClearText = false; + + if (sServiceName != "com.sun.star.drawing.GraphicObjectShape" && + sServiceName != "com.sun.star.drawing.OLE2Shape") + { + static const OUStringLiteral sOutlinerShapeService(u"com.sun.star.presentation.OutlinerShape"); + SAL_INFO("oox.ppt","has master: " << std::hex << rSlidePersist.getMasterPersist().get()); + switch (mnSubType) + { + case XML_ctrTitle : + case XML_title : + { + sServiceName = "com.sun.star.presentation.TitleTextShape"; + aMasterTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); + } + break; + case XML_subTitle : + { + if ((meShapeLocation == Master) || (meShapeLocation == Layout)) + sServiceName = OUString(); + else { + sServiceName = "com.sun.star.presentation.SubtitleShape"; + aMasterTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + } + } + break; + case XML_obj : + { + sServiceName = sOutlinerShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + } + break; + case XML_body : + { + if (rSlidePersist.isNotesPage()) + { + sServiceName = "com.sun.star.presentation.NotesShape"; + aMasterTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle(); + } + else + { + sServiceName = sOutlinerShapeService; + aMasterTextListStyle = rSlidePersist.getMasterPersist() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + } + } + break; + case XML_dt : + if (IsPlaceHolderCandidate(rSlidePersist)) + { + TextRunPtr& pTextRun = getTextBody()->getParagraphs().front()->getRuns().front(); + oox::drawingml::TextField* pTextField = dynamic_cast(pTextRun.get()); + if (pTextField) + { + OUString aType = pTextField->getType(); + if ( aType.startsWith("datetime") ) + { + SvxDateFormat eDateFormat = drawingml::TextField::getLODateFormat(aType); + SvxTimeFormat eTimeFormat = drawingml::TextField::getLOTimeFormat(aType); + Reference< XPropertySet > xPropertySet( rSlidePersist.getPage(), UNO_QUERY ); + + if( eDateFormat != SvxDateFormat::AppDefault + || eTimeFormat != SvxTimeFormat::AppDefault ) + { + // DateTimeFormat property looks for the date in 4 LSBs + // and looks for time format in the 4 bits after that + sal_Int32 nDateTimeFormat = static_cast(eDateFormat) | + static_cast(eTimeFormat) << 4; + xPropertySet->setPropertyValue( "IsDateTimeVisible", Any(true) ); + xPropertySet->setPropertyValue( "IsDateTimeFixed", Any(false) ); + xPropertySet->setPropertyValue( "DateTimeFormat", Any(nDateTimeFormat) ); + return; + } + } + } + } + sServiceName = "com.sun.star.presentation.DateTimeShape"; + bClearText = true; + break; + case XML_hdr : + sServiceName = "com.sun.star.presentation.HeaderShape"; + bClearText = true; + break; + case XML_ftr : + if (IsPlaceHolderCandidate(rSlidePersist)) + { + const OUString& rFooterText = getTextBody()->toString(); + + if( !rFooterText.isEmpty() ) + { + // if it is possible to get the footer as a property the LO way, + // get it and discard the shape + Reference< XPropertySet > xPropertySet( rSlidePersist.getPage(), UNO_QUERY ); + xPropertySet->setPropertyValue( "IsFooterVisible", Any( true ) ); + xPropertySet->setPropertyValue( "FooterText", Any(rFooterText) ); + return; + } + } + sServiceName = "com.sun.star.presentation.FooterShape"; + bClearText = true; + break; + case XML_sldNum : + if (IsPlaceHolderCandidate(rSlidePersist)) + { + TextRunPtr& pTextRun + = getTextBody()->getParagraphs().front()->getRuns().front(); + oox::drawingml::TextField* pTextField + = dynamic_cast(pTextRun.get()); + if (pTextField && pTextField->getType() == "slidenum") + { + // if it is possible to get the slidenum placeholder as a property + // do that and discard the shape + Reference xPropertySet(rSlidePersist.getPage(), + UNO_QUERY); + xPropertySet->setPropertyValue("IsPageNumberVisible", Any(true)); + return; + } + } + sServiceName = "com.sun.star.presentation.SlideNumberShape"; + bClearText = true; + break; + case XML_sldImg : + sServiceName = "com.sun.star.presentation.PageShape"; + break; + case XML_chart : + if (meShapeLocation == Layout) + sServiceName = sOutlinerShapeService; + else + sServiceName = "com.sun.star.presentation.ChartShape"; + break; + case XML_tbl : + if (meShapeLocation == Layout) + sServiceName = sOutlinerShapeService; + else + sServiceName = "com.sun.star.presentation.TableShape"; + break; + case XML_pic : + if (meShapeLocation == Layout) + sServiceName = sOutlinerShapeService; + else + sServiceName = "com.sun.star.presentation.GraphicObjectShape"; + break; + case XML_media : + if (meShapeLocation == Layout) + sServiceName = sOutlinerShapeService; + else + sServiceName = "com.sun.star.presentation.MediaShape"; + break; + default: + if (mnSubType && meShapeLocation == Layout) + sServiceName = sOutlinerShapeService; + break; + } + } + + // Since it is not possible to represent custom shaped placeholders in Impress + // Need to use service name css.drawing.CustomShape if they have a non default shape. + // This workaround has the drawback of them not really being processed as placeholders + // so it is only done for slide footers... + if ((mnSubType == XML_sldNum || mnSubType == XML_dt || mnSubType == XML_ftr) + && meShapeLocation == Slide && !mpCustomShapePropertiesPtr->representsDefaultShape()) + { + sServiceName = "com.sun.star.drawing.CustomShape"; + } + + SAL_INFO("oox.ppt","shape service: " << sServiceName); + + if (mnSubType && getSubTypeIndex().has() && meShapeLocation == Layout) + { + oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex().get(), rSlidePersist.getShapes()->getChildren(), true ); + if (!pPlaceholder) + pPlaceholder = PPTShape::findPlaceholder( mnSubType, 0, getSubTypeIndex(), rSlidePersist.getShapes()->getChildren(), true ); + + if (pPlaceholder) { + if (maSize.Width == 0 || maSize.Height == 0) { + awt::Size aSize = maSize; + if (maSize.Width == 0) + aSize.Width = pPlaceholder->getSize().Width; + if (maSize.Height == 0) + aSize.Height = pPlaceholder->getSize().Height; + setSize( aSize ); + if (maPosition.X == 0 || maPosition.Y == 0) { + awt::Point aPosition = maPosition; + if (maPosition.X == 0) + aPosition.X = pPlaceholder->getPosition().X; + if (maPosition.Y == 0) + aPosition.Y = pPlaceholder->getPosition().Y; + setPosition( aPosition ); + } + } + } + } + + // use placeholder index if possible + if (mnSubType && getSubTypeIndex().has() && rSlidePersist.getMasterPersist()) + { + oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex(getSubTypeIndex().get(), rSlidePersist.getMasterPersist()->getShapes()->getChildren()); + // TODO: Check if this is required for non-notes slides as well... + if (rSlidePersist.isNotesPage() && pPlaceholder && pPlaceholder->getSubType() != getSubType()) + pPlaceholder.reset(); + + if (pPlaceholder) { + SAL_INFO("oox.ppt","found placeholder with index: " << getSubTypeIndex().get() << " and type: " << lclDebugSubType( mnSubType )); + PPTShape* pPPTPlaceholder = dynamic_cast< PPTShape* >( pPlaceholder.get() ); + TextListStylePtr pNewTextListStyle = std::make_shared(); + + if (pPlaceholder->getTextBody()) { + + pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() ); + if (pPlaceholder->getMasterTextListStyle()) + pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() ); + + // SAL_INFO("oox.ppt","placeholder body style"); + // pPlaceholder->getTextBody()->getTextListStyle().dump(); + // SAL_INFO("oox.ppt","master text list style"); + // pPlaceholder->getMasterTextListStyle()->dump(); + + aMasterTextListStyle = pNewTextListStyle; + // SAL_INFO("oox.ppt","combined master text list style"); + // aMasterTextListStyle->dump(); + } + if (pPPTPlaceholder && pPPTPlaceholder->mpPlaceholder) { + SAL_INFO("oox.ppt","placeholder has parent placeholder: " << pPPTPlaceholder->mpPlaceholder->getId() << " type: " << lclDebugSubType( pPPTPlaceholder->mpPlaceholder->getSubType() ) << " index: " << pPPTPlaceholder->mpPlaceholder->getSubTypeIndex().get() ); + SAL_INFO("oox.ppt","has textbody " << (pPPTPlaceholder->mpPlaceholder->getTextBody() != nullptr) ); + TextListStylePtr pPlaceholderStyle = getSubTypeTextListStyle( rSlidePersist, pPPTPlaceholder->mpPlaceholder->getSubType() ); + if (pPPTPlaceholder->mpPlaceholder->getTextBody()) + pNewTextListStyle->apply( pPPTPlaceholder->mpPlaceholder->getTextBody()->getTextListStyle() ); + if (pPlaceholderStyle) { + pNewTextListStyle->apply( *pPlaceholderStyle ); + //pPlaceholderStyle->dump(); + } + } + } else if (!mpPlaceholder) { + aMasterTextListStyle.reset(); + } + SAL_INFO("oox.ppt","placeholder id: " << (pPlaceholder ? pPlaceholder->getId() : "not found")); + } + + if (!sServiceName.isEmpty()) + { + if (!aMasterTextListStyle) + { + bool isOther = !getTextBody() && sServiceName != "com.sun.star.drawing.GroupShape"; + TextListStylePtr aSlideStyle = isOther ? rSlidePersist.getOtherTextStyle() : rSlidePersist.getDefaultTextStyle(); + // Combine from MasterSlide details as well. + if (rSlidePersist.getMasterPersist()) + { + aMasterTextListStyle = isOther ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getMasterPersist()->getDefaultTextStyle(); + if (aSlideStyle) + aMasterTextListStyle->apply( *aSlideStyle ); + } + else + { + aMasterTextListStyle = aSlideStyle; + } + } + + if( aMasterTextListStyle && getTextBody() ) { + TextListStylePtr aCombinedTextListStyle = std::make_shared(); + + aCombinedTextListStyle->apply( *aMasterTextListStyle ); + + if( mpPlaceholder && mpPlaceholder->getTextBody() ) + aCombinedTextListStyle->apply( mpPlaceholder->getTextBody()->getTextListStyle() ); + aCombinedTextListStyle->apply( getTextBody()->getTextListStyle() ); + + setMasterTextListStyle( aCombinedTextListStyle ); + } else + setMasterTextListStyle( aMasterTextListStyle ); + + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, bClearText, bool(mpPlaceholder), aTransformation, getFillProperties() ) ); + // if exists and not duplicated, try to use the title text as slide name to help its re-use on UI + if (!rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && (mnSubType == XML_title || mnSubType == XML_ctrTitle)) + { + try + { + sal_Int32 nCount = 1; + OUString aTitleText; + Reference xText(xShape, UNO_QUERY_THROW); + aTitleText = xText->getString(); + Reference xDPS(rFilterBase.getModel(), uno::UNO_QUERY_THROW); + Reference xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW); + sal_uInt32 nMaxPages = xDrawPages->getCount(); + // just a magic value but we don't want to drop out slide names which are too long + if (aTitleText.getLength() > 63) + aTitleText = aTitleText.copy(0, 63); + bool bUseTitleAsSlideName = !aTitleText.isEmpty(); + // check duplicated title name + if (bUseTitleAsSlideName) + { + for (sal_uInt32 nPage = 0; nPage < nMaxPages; ++nPage) + { + Reference xDrawPage(xDrawPages->getByIndex(nPage), uno::UNO_QUERY); + Reference xNamed(xDrawPage, UNO_QUERY_THROW); + OUString sRest; + if (xNamed->getName().startsWith(aTitleText, &sRest) + && (sRest.isEmpty() + || (sRest.startsWith(" (") && sRest.endsWith(")") + && o3tl::toInt32(sRest.subView(2, sRest.getLength() - 3)) > 0))) + nCount++; + } + Reference xName(rSlidePersist.getPage(), UNO_QUERY_THROW); + xName->setName( + aTitleText + + (nCount == 1 ? OUString("") : " (" + OUString::number(nCount) + ")")); + } + } + catch (uno::Exception&) + { + + } + } + + // Apply text properties on placeholder text inside this placeholder shape + if (meShapeLocation == Slide && mpPlaceholder && getTextBody() && getTextBody()->isEmpty()) + { + Reference < XText > xText(mxShape, UNO_QUERY); + if (xText.is()) + { + TextCharacterProperties aCharStyleProperties; + getTextBody()->ApplyStyleEmpty(rFilterBase, xText, aCharStyleProperties, mpMasterTextListStyle); + } + } + if (pShapeMap) + { + // bnc#705982 - if optional model id reference is + // there, use that to obtain target shape + if (!msModelId.isEmpty()) + { + (*pShapeMap)[ msModelId ] = shared_from_this(); + } + else if (!msId.isEmpty()) + { + (*pShapeMap)[ msId ] = shared_from_this(); + } + } + + // we will be losing whatever information there is in the footer placeholder on master/layout slides + // since they should have the "