From 21470d1711b99bc88036318bab22f3e21ecb4a8d Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 1 Nov 2022 18:30:48 +0300 Subject: [PATCH 01/22] Animation reformation was started --- .../Converter/Animation/animationparser.cpp | 47 + .../Converter/Animation/animationparser.h | 11 + .../Converter/Animation/intermediate_anim.cpp | 6 + .../Converter/Animation/intermediate_anim.h | 31 + .../PPTFormatLib/Converter/timing.cpp | 18 + .../PPTFormatLib/Converter/timing.h | 27 + .../PPTFormatLib/Linux/PPTFormatLib.pro | 10 +- .../PPTFormatLib/PPTXWriter/Animation.cpp | 2501 ----------------- .../PPTFormatLib/PPTXWriter/Animation.h | 272 -- .../PPTFormatLib/PPTXWriter/Converter.cpp | 44 +- .../PPTFormatLib/PPTXWriter/Converter.h | 2 +- 11 files changed, 157 insertions(+), 2812 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.h create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/timing.h delete mode 100644 ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp delete mode 100644 ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp new file mode 100644 index 0000000000..bdfd87ed8e --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp @@ -0,0 +1,47 @@ +#include "animationparser.h" +#include "../../Records/Drawing/ShapeContainer.h" + +using namespace PPT::Intermediate; + +static CRecordPP10SlideBinaryTagExtension* getPP10SlideBinaryTagExtension(CRecordSlide *pSlide); +static std::list getListOfRawAnimIC(CRecordSlide *pSlide); + + +SlideAnimation ParseSlideAnimation(CRecordSlide *pSlide) +{ + SlideAnimation slideAnim; + auto listOfOldAnim = getListOfRawAnimIC(pSlide); + auto pAnimExt = getPP10SlideBinaryTagExtension(pSlide); + + return slideAnim; +} + +CRecordPP10SlideBinaryTagExtension* getPP10SlideBinaryTagExtension(CRecordSlide *pSlide) +{ + CRecordSlideProgTagsContainer* progTag = pSlide->m_pSlideProgTagsContainer; + return progTag ? progTag->getPP10SlideBinaryTagExtension() : nullptr; +} + +std::list getListOfRawAnimIC(CRecordSlide *pSlide) +{ + std::vector arrShapeCont; + pSlide->GetRecordsByType(&arrShapeCont, true); + + std::list listOfRawAnimIC; + for (auto* pShapeCont : arrShapeCont) + { + std::vector shape; + pShapeCont->GetRecordsByType(&shape, true); + std::vector anim; + pShapeCont->GetRecordsByType(&anim, true); + Animation animIC; + if (!anim.empty() && !shape.empty()) + { + animIC.shapeId = shape[0]->m_nID; + animIC.pAnimIC = anim[0]; + listOfRawAnimIC.push_back(animIC); + } + } + + return listOfRawAnimIC; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.h new file mode 100644 index 0000000000..efb490449b --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.h @@ -0,0 +1,11 @@ +#pragma once + +#include "intermediate_anim.h" +#include "../../Records/SlideContainer.h" + + +namespace PPT { +namespace Intermediate { +SlideAnimation ParseSlideAnimation(CRecordSlide* pSlide); +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp new file mode 100644 index 0000000000..643371eb27 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp @@ -0,0 +1,6 @@ +#include "intermediate_anim.h" + +aic_animation::aic_animation() +{ + +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h new file mode 100644 index 0000000000..4c8b9f2ba5 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h @@ -0,0 +1,31 @@ +#pragma once + +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" + +#include "../Records/SlideProgTagsContainer.h" +#include "../PPTXWriter/ImageManager.h" +#include "../Records/Animations/AnimationInfoContainer.h" +#include + + +namespace PPT { +namespace Intermediate { +struct Animation +{ + _INT32 shapeId = -1; + CRecordAnimationInfoContainer* pAnimIC = nullptr; // old animation records + CRecordExtTimeNodeContainer* pETNCIC = nullptr; // new animation records +}; + +// todo not correct (for example: triggers)!!! +using ParallelTimeNodes = std::list; +using SequenceTimeNodes = std::list; + +struct SlideAnimation +{ + SequenceTimeNodes sequences; + CRecordBuildListContainer* pBLC = nullptr; + std::unordered_set<_INT32> realShapesIds; +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp new file mode 100644 index 0000000000..e1ab480f33 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -0,0 +1,18 @@ +#include "timing.h" + +#include "Animation/intermediate_anim.h" +#include "Animation/ppt10ext_animation.h" + + +using namespace PPT::Converter; + +Timing::Timing(const PPT::Intermediate::SlideAnimation& slideAnim, const CExMedia* pExMedia, const CRelsGenerator* pRels) : + slideAnim(slideAnim), pExMedia(pExMedia), pRels(pRels) +{ + +} + +PPTX::Logic::Timing Timing::Convert() +{ + return std::move(timing); +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h new file mode 100644 index 0000000000..b489b352b6 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h @@ -0,0 +1,27 @@ +#pragma once + +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" +#include "../PPTXWriter/ImageManager.h" +#include "Animation/intermediate_anim.h" + + +namespace PPT { +namespace Converter { +class Timing +{ +public: + Timing(const PPT::Intermediate::SlideAnimation& slideAnim, const CExMedia* pExMedia, const CRelsGenerator* pRels); + PPTX::Logic::Timing Convert(); + + bool HasAnimation() const; + +private: + const PPT::Intermediate::SlideAnimation& slideAnim; + const CExMedia* pExMedia; + const CRelsGenerator* pRels; + + bool isPPT10Broken = true; + PPTX::Logic::Timing timing; +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index bb6761d448..2a09385e87 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -27,12 +27,15 @@ DEFINES += UNICODE \ #DISABLE_FILE_DOWNLOADER HEADERS += \ + ../Converter/Animation/animation.h \ + ../Converter/Animation/animationparser.h \ + ../Converter/Animation/intermediate_anim.h \ + ../Converter/timing.h \ ../Converter/transition.h \ ../Enums/RecordType.h \ ../Enums/_includer.h \ ../Enums/enums.h \ ../PPTFormatLib.h \ - ../PPTXWriter/Animation.h \ ../PPTXWriter/BulletsConverter.h \ ../PPTXWriter/TableWriter.h \ ../PPTXWriter/TxBodyConverter.h \ @@ -275,6 +278,7 @@ SOURCES += \ core_debug { SOURCES += \ + ../Converter/Animation/animation.cpp \ ../Enums/RecordType.cpp \ ../PPTFormatLib.cpp \ ../Reader/ReadStructures.cpp \ @@ -285,7 +289,6 @@ SOURCES += \ ../Reader/SlidePersist.cpp \ ../PPTXWriter/Converter.cpp \ ../PPTXWriter/ShapeWriter.cpp \ - ../PPTXWriter/Animation.cpp \ ../PPTXWriter/TableWriter.cpp \ ../PPTXWriter/TxBodyConverter.cpp \ ../Records/Drawing/ArtBlip.cpp \ @@ -298,6 +301,9 @@ SOURCES += \ ../../../ASCOfficePPTXFile/Editor/Drawing/Elements.cpp \ ../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \ ../../../Common/3dParty/pole/pole.cpp \ + ../Converter/Animation/animationparser.cpp \ + ../Converter/Animation/intermediate_anim.cpp \ + ../Converter/timing.cpp \ ../Converter/transition.cpp \ ../PPTXWriter/BulletsConverter.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp deleted file mode 100644 index 75a7d2b172..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.cpp +++ /dev/null @@ -1,2501 +0,0 @@ -/* - *(c) Copyright Ascensio System SIA 2010-2019 - * - *This program is a free software product. You can redistribute it and/or - *modify it under the terms of the GNU Affero General Public License (AGPL) - *version 3 as published by the Free Software Foundation. In accordance with - *Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - *that Ascensio System SIA expressly excludes the warranty of non-infringement - *of any third-party rights. - * - *This program is distributed WITHOUT ANY WARRANTY; without even the implied - *warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - *details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - *You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - *street, Riga, Latvia, EU, LV-1050. - * - *The interactive user interfaces in modified source and object code versions - *of the Program must display Appropriate Legal Notices, as required under - *Section 5 of the GNU AGPL version 3. - * - *Pursuant to Section 7(b) of the License you must retain the original Product - *logo when distributing the program. Pursuant to Section 7(e) we decline to - *grant you any rights under trademark law for use of our trademarks. - * - *All the Product's GUI elements, including illustrations and icon sets, as - *well as technical writing content are licensed under the terms of the - *Creative Commons Attribution-ShareAlike 4.0 International. See the License - *terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -#include "Animation.h" - -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h" - -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldLst.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldDgm.h" - -#include "../Records/Animations/BuildListContainer.h" -#include "../Records/Animations/ChartBuildContainer.h" -#include "../Records/Animations/DiagramBuildContainer.h" - -#include "../Records/SoundContainer.h" -//#include - -using namespace PPT_FORMAT; - -void Animation::Convert(PPTX::Logic::Timing &oTiming) -{ - if (m_pPPT10) - { - m_isPPT10Broken = false; - // It must be first to write some reference from ExtTimeNodeContainer - if (m_pPPT10->m_haveBuildList && !m_pPPT10->m_pBuildListContainer->n_arrRgChildRec.empty()) - { - oTiming.bldLst = new PPTX::Logic::BldLst(); - FillBldLst(m_pPPT10->m_pBuildListContainer, *(oTiming.bldLst)); - m_pBldLst = oTiming.bldLst.GetPointer(); - } - - if (m_pPPT10->m_haveExtTime) - { - oTiming.tnLst = new PPTX::Logic::TnLst(); - FillTnLst(m_pPPT10->m_pExtTimeNodeContainer, *(oTiming.tnLst)); - } - } - if (!m_arrOldAnim.empty() && m_isPPT10Broken) - { - oTiming = PPTX::Logic::Timing(); - InitTimingTags(oTiming); - } - - return; -} - -void Animation::FillAnim( - CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, - PPTX::Logic::Anim &oAnim) -{ - if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bCalcModePropertyUsed) - { - std::wstring calcmode; - switch (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_nCalcMode) { - case 0: calcmode = L"discrete"; break; - case 1: calcmode = L"lin"; break; - case 2: calcmode = L"fmla"; break; - } - oAnim.calcmode = new PPTX::Limit::TLCalcMode; - oAnim.calcmode = calcmode; - } - - if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bValueTypePropertyUsed) - { - std::wstring valueType; - switch (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_ValueType) { - case TL_TABVT_Color: valueType = L"Color"; break; - case TL_TABVT_Number: valueType = L"Number"; break; - case TL_TABVT_String: valueType = L"String"; break; - } - if (!valueType.empty()) - { - oAnim.valueType = new PPTX::Limit::TLValueType; - oAnim.valueType = valueType; - } - } - - // By - if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bByPropertyUsed) - { - oAnim.by = pTimeAnimateBehavior->m_oVarBy.m_Value; - } - // To - if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bToPropertyUsed) - { - oAnim.to = pTimeAnimateBehavior->m_oVarTo.m_Value; - } - //From - if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bFromPropertyUsed) - { - oAnim.from = pTimeAnimateBehavior->m_oVarFrom.m_Value; - } - - //// Writing childs - - if (!pTimeAnimateBehavior->m_oAnimateValueList.m_arrEntry.empty()) - oAnim.tavLst = new PPTX::Logic::TavLst; - for (auto &animValue : pTimeAnimateBehavior->m_oAnimateValueList.m_arrEntry) - { - PPTX::Logic::Tav tav; - tav.val = new PPTX::Logic::AnimVariant; - - tav.val->node_name = L"val"; - - if (animValue->m_pVarValue.is_init()) - switch (animValue->m_pVarValue->m_Type) { - case TL_TVT_String: - { - tav.val->strVal = dynamic_cast - (animValue->m_pVarValue.get()).m_Value; - break; - } - case TL_TVT_Bool: - { - tav.val->boolVal = dynamic_cast - (animValue->m_pVarValue.get()).m_Value; - break; - } - case TL_TVT_Int: - { - tav.val->intVal = dynamic_cast - (animValue->m_pVarValue.get()).m_Value; - break; - } - case TL_TVT_Float: - { - tav.val->fltVal = dynamic_cast - (animValue->m_pVarValue.get()).m_Value; - break; - } - } - - auto tavTime = animValue->m_oTimeAnimationValueAtom.m_nTime; - if (tavTime <= 1000 && tavTime >= 0) // todo check - tav.tm = std::to_wstring((/*1000 - */tavTime) * 100); - - if (!animValue->m_VarFormula.m_Value.empty()) - { - tav.fmla = animValue->m_VarFormula.m_Value; - } - - oAnim.tavLst->list.push_back(tav); - } - FillCBhvr(&(pTimeAnimateBehavior->m_oBehavior), oAnim.cBhvr); -} - -void Animation::FillAnimClr( - CRecordTimeColorBehaviorContainer *pColor, - CRecordTimePropertyList4TimeNodeContainer *pProp, - PPTX::Logic::AnimClr &oAnimClr) -{ - auto &clrAtom = pColor->m_oColorBehaviorAtom; - - FillCBhvr(&(pColor->m_oBehavior), oAnimClr.cBhvr); - FillCTn(pProp, oAnimClr.cBhvr.cTn); - - // Write Attributes - if (pColor->m_oBehavior.m_havePropertyList){ - for (auto pRec : pColor->m_oBehavior.m_pPropertyList->m_arRecords) - { - if (pRec->m_oHeader.RecInstance == TL_TBPID_ColorColorModel) - { - auto oTimeColorModel = dynamic_cast(pRec); - oAnimClr.clrSpc = new PPTX::Limit::TLColorSpace; - std::wstring clrSpc; - if (!clrAtom.m_fColorSpacePropertyUsed) clrSpc = L"rgb"; - else clrSpc = oTimeColorModel->m_Value ? L"hsl" : L"rgb"; - oAnimClr.clrSpc = clrSpc; - } - else if (pRec->m_oHeader.RecInstance == TL_TBPID_ColorDirection) - { - auto oTimeColorDirection = dynamic_cast(pRec); - oAnimClr.dir = new PPTX::Limit::TLColorDirection; - std::wstring dir; - if (!clrAtom.m_fDirectionPropertyUsed) dir = L"cw"; - else dir = oTimeColorDirection->m_Value ? L"ccw" : L"cw"; - oAnimClr.dir = dir; - } - } - } - - if (clrAtom.m_fByPropertyUsed) - { - if (clrAtom.m_sColorBy.model == 0) // RGB == 0 - { - oAnimClr.byR = clrAtom.m_sColorBy.component0; - oAnimClr.byG = clrAtom.m_sColorBy.component1; - oAnimClr.byB = clrAtom.m_sColorBy.component2; - } - else if (clrAtom.m_sColorBy.model == 1) // HSL == 1 - { - oAnimClr.byH = clrAtom.m_sColorBy.component0; - oAnimClr.byS = clrAtom.m_sColorBy.component1; - oAnimClr.byL = clrAtom.m_sColorBy.component2; - } - } - - if (clrAtom.m_fFromPropertyUsed) - { - oAnimClr.from = *new PPTX::Logic::UniColor; - if (clrAtom.m_sColorFrom.model == 0) - { - auto pSrgb = new PPTX::Logic::SrgbClr; - pSrgb->red = clrAtom.m_sColorFrom.component0; - pSrgb->green = clrAtom.m_sColorFrom.component1; - pSrgb->blue = clrAtom.m_sColorFrom.component2; - oAnimClr.from.Color = pSrgb; - } - else - { - auto pScheme = new PPTX::Logic::SchemeClr; - std::wstring strVal; - UINT index = clrAtom.m_sColorFrom.component0; - if (index >= 4 && index < 10) - { - strVal = L"accent" + std::to_wstring(index - 3); - } - pScheme->val = strVal; - oAnimClr.from.Color = pScheme; - } - } - - if (clrAtom.m_fToPropertyUsed) - { - oAnimClr.to = *new PPTX::Logic::UniColor; - if (clrAtom.m_sColorTo.model == 0) - { - auto pSrgb = new PPTX::Logic::SrgbClr; - pSrgb->red = clrAtom.m_sColorTo.component0; - pSrgb->green = clrAtom.m_sColorTo.component1; - pSrgb->blue = clrAtom.m_sColorTo.component2; - oAnimClr.to.Color = pSrgb; - } - else - { - auto pScheme = new PPTX::Logic::SchemeClr; - std::wstring strVal; - UINT index = clrAtom.m_sColorTo.component0; - if (index >= 4 && index < 10) - { - strVal = L"accent" + std::to_wstring(index - 3); - } - pScheme->val = strVal; - oAnimClr.to.Color = pScheme; - } - } -} - -void Animation::FillAnimEffect( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimEffect &oAnim) -{ - auto *bhvr = pETNC->m_pTimeEffectBehavior; - oAnim.filter = bhvr->m_oVarType.m_Value; - - if (bhvr->m_effectBehaviorAtom.m_bProgressPropertyUsed) - { - if (!oAnim.progress.is_init()) - oAnim.progress = new PPTX::Logic::AnimVariant; - oAnim.progress->fltVal = bhvr->m_oVarProgress.m_Value; - } - - if (bhvr->m_effectBehaviorAtom.m_bRuntimeContextObsolete) - { - if (!oAnim.progress.is_init()) - oAnim.progress = new PPTX::Logic::AnimVariant; - oAnim.progress->strVal = bhvr->m_oVarRuntimeContext.m_Value; - } - - if (bhvr->m_effectBehaviorAtom.m_bTransitionPropertyUsed) - { - oAnim.transition = bhvr->m_effectBehaviorAtom.m_nEffectTransition ? - L"out" : L"in"; - } - - FillCBhvr(pETNC, oAnim.cBhvr); - -} - -void Animation::FillAnimMotion( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimMotion &oAnim) -{ - if (!pETNC || !pETNC->m_pTimeMotionBehavior) return; - - auto pMotion = pETNC->m_pTimeMotionBehavior; - auto oAtom = pMotion->m_oMotionBehaviorAtom; - - FillCBhvr(pETNC, oAnim.cBhvr); - - if (oAtom.m_bFromPropertyUsed) - { - oAnim.fromX = oAtom.m_nXFROM; - oAnim.fromY = oAtom.m_nYFROM; - } - if (oAtom.m_bToPropertyUsed) - { - oAnim.toX = oAtom.m_nXTO; - oAnim.toY = oAtom.m_nYTO; - } - if (oAtom.m_bByPropertyUsed) - { - oAnim.byX = oAtom.m_nXBY; - oAnim.byY = oAtom.m_nYBY; - } - - if (oAtom.m_bOriginPropertyUsed) - { - oAnim.origin = new PPTX::Limit::TLOrigin; - oAnim.origin->set(oAtom.m_nBehaviorOrigin == 2 ? - L"layout" : L"parent"); - } - - if (!pMotion->m_pVarPath->m_Value.empty()) - oAnim.path = pMotion->m_pVarPath->m_Value; - -// oAnim.ptsTypes - - - oAnim.pathEditMode = new PPTX::Limit::TLPathEditMode; - oAnim.pathEditMode->set(oAtom.m_bEditRotationPropertyUsed ? L"fixed" : L"relative"); -} - -void Animation::FillAnimRot( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimRot &oAnim) -{ - if (!pETNC || !pETNC->m_pTimeRotationBehavior) return; - - auto pRot = pETNC->m_pTimeRotationBehavior; - auto oAtom = pRot->m_oRotationBehaviorAtom; - - FillCBhvr(pETNC, oAnim.cBhvr); - - const auto mult = 60000; - - if (oAtom.m_fByPropertyUsed) - oAnim.by = oAtom.m_By *mult; - if (oAtom.m_fToPropertyUsed) - oAnim.to = oAtom.m_To *mult; - if (oAtom.m_fFromPropertyUsed) - oAnim.from = oAtom.m_From *mult; - -} - -void Animation::FillAnimScale( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimScale &oAnim) -{ - if (!pETNC || !pETNC->m_pTimeScaleBehavior) return; - - auto pScale = pETNC->m_pTimeScaleBehavior; - auto oAtom = pScale->m_oScaleBehaviorAtom; - - FillCBhvr(pETNC, oAnim.cBhvr); - - const auto mult = 1000; - if (oAtom.m_fByPropertyUsed) - { - oAnim.byX = oAtom.m_XBy *mult; - oAnim.byY = oAtom.m_YBy *mult; - } - if (oAtom.m_fToPropertyUsed) - { - oAnim.toX = oAtom.m_XTo *mult; - oAnim.toY = oAtom.m_YTo *mult; - } - if (oAtom.m_fFromPropertyUsed) - { - oAnim.fromX = oAtom.m_XFrom *mult; - oAnim.fromY = oAtom.m_YFrom *mult; - } - - if (oAtom.m_fZoomContentsUsed) - oAnim.zoomContents = oAtom.m_fZoomContents; -} - -// TODO refactoring -void Animation::FillAudio(CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Audio &oAudio) -{ - auto* pCVEC = pETNC->m_pClientVisualElement; - if (pCVEC->m_bVisualShapeAtom && m_pRels) - { - CExFilesInfo* pInfo1 = m_pExMedia->LockAudioFromCollection(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); - if (pInfo1) - { - bool bExternal(false); - oAudio.cMediaNode.tgtEl.embed = - new OOX::RId(m_pRels->WriteAudio(pInfo1->m_strFilePath, bExternal)); - oAudio.cMediaNode.tgtEl.name = XmlUtils::EncodeXmlString(pInfo1->m_name); - } else if (pCVEC->m_oVisualShapeAtom.m_RefType == TL_ET_ShapeType) - { - oAudio.cMediaNode.tgtEl.spTgt = new PPTX::Logic::SpTgt; - oAudio.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); -// oAudio.isNarration = true; -// oAudio.cMediaNode.showWhenStopped = false; - } else - return; - FillCTn(pETNC, oAudio.cMediaNode.cTn); - } -} - -void Animation::FillAudio(CRecordClientVisualElementContainer *pCVEC, - PPTX::Logic::Audio &oAudio) -{ - if (pCVEC->m_bVisualShapeAtom) - { - CExFilesInfo* pInfo1 = m_pExMedia->LockAudioFromCollection(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); - if (pInfo1 && m_pRels) - { - bool bExternal(false); - oAudio.cMediaNode.tgtEl.embed = - new OOX::RId(m_pRels->WriteAudio(pInfo1->m_strFilePath, bExternal)); - oAudio.cMediaNode.tgtEl.name = XmlUtils::EncodeXmlString(pInfo1->m_name); - } - } -} - -void Animation::FillVideo( - CRecordExtTimeNodeContainer* pETNC, - PPTX::Logic::Video& oVideo) -{ - auto video = pETNC->m_pClientVisualElement->m_oVisualShapeAtom; - - FillCTn(pETNC, oVideo.cMediaNode.cTn); - - if (pETNC->m_pTimePropertyList->m_arrElements.size() >= 5) - { - try { - oVideo.cMediaNode.vol = (int)(static_cast - (pETNC->m_pTimePropertyList->m_arrElements[1])-> - m_Value * 100000); - oVideo.cMediaNode.mute = static_cast - (pETNC->m_pTimePropertyList->m_arrElements[2])-> - m_Value; - oVideo.fullScrn = static_cast - (pETNC->m_pTimePropertyList->m_arrElements[3])-> - m_Value; - oVideo.cMediaNode.showWhenStopped = static_cast - (pETNC->m_pTimePropertyList->m_arrElements[4])-> - m_Value; - } catch (...) { - - } - } - - - oVideo.cMediaNode.tgtEl.spTgt = PPTX::Logic::SpTgt(); - oVideo.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(video.m_nObjectIdRef); - - -} - -void Animation::FillBldLst( - PPT_FORMAT::CRecordBuildListContainer *pBLC, - PPTX::Logic::BldLst &oBL) -{ - if (!pBLC) - return; - // Write p - for (unsigned i = 0; i < pBLC->n_arrRgChildRec.size(); i++) - { - PPTX::Logic::BuildNodeBase oBuildNodeBase; - switch ( pBLC->n_arrRgChildRec[i]->m_oHeader.RecType ) { - case RT_ParaBuild: - { - CRecordParaBuildContainer *pRec = - (CRecordParaBuildContainer*)pBLC->n_arrRgChildRec[i]; - PPTX::Logic::BldP *pBldP = new PPTX::Logic::BldP(); - FillBldP(pRec, *pBldP); - - oBuildNodeBase.m_node = pBldP; - break; - } - case RT_ChartBuild: - { - CRecordChartBuildContainer *pRec = - (CRecordChartBuildContainer*)pBLC->n_arrRgChildRec[i]; - PPTX::Logic::BldOleChart *pBldC = new PPTX::Logic::BldOleChart(); - - pBldC->spid = std::to_wstring(pRec->m_oBuildAtom.m_nShapeIdRef); - pBldC->grpId = (int)pRec->m_oBuildAtom.m_nBuildId; - pBldC->uiExpand = pRec->m_oBuildAtom.m_fExpanded; - - pBldC->animBg = pRec->m_oChartBuildAtom.m_fAnimBackground; - - std::vector ST_TLOleChartBuildType = - { - L"allAtOnce", - L"series", - L"category", - L"seriesEl", - L"categoryEl" - }; - pBldC->bld = ST_TLOleChartBuildType[pRec->m_oChartBuildAtom.m_ChartBuild % 5]; - - oBuildNodeBase.m_node = pBldC; - break; - } - - case RT_DiagramBuild: - { - CRecordDiagramBuildContainer *pRec = - (CRecordDiagramBuildContainer*)pBLC->n_arrRgChildRec[i]; - PPTX::Logic::BldDgm *pBldD = new PPTX::Logic::BldDgm(); - - pBldD->spid = std::to_wstring(pRec->m_oBuildAtom.m_nShapeIdRef); - pBldD->grpId = (int)pRec->m_oBuildAtom.m_nBuildId; - pBldD->uiExpand = pRec->m_oBuildAtom.m_fExpanded; - - std::vector ST_TLDiagramBuildType = - { - L"whole", - L"depthByNode", - L"depthByBranch", - L"breadthByNode", - L"breadthByLvl", - L"cw", - L"cwIn", - L"cwOut", - L"ccw", - L"ccwIn", - L"ccwOut", - L"inByRing", - L"outByRing", - L"up", - L"down", - L"allAtOnce", - L"cust" - }; - pBldD->bld = ST_TLDiagramBuildType[pRec->m_oDiagramBuildAtom.m_oDiagramBuild % 17]; - - oBuildNodeBase.m_node = pBldD; - break; - } - default: - break; - } - oBL.list.push_back(oBuildNodeBase); - - } - - - return; -} - -void Animation::FillBldP(PPT_FORMAT::CRecordParaBuildContainer *pPBC, - PPTX::Logic::BldP &oBP) -{ - - oBP.spid = std::to_wstring(pPBC->m_oBuildAtom.m_nShapeIdRef); - oBP.grpId = (int)pPBC->m_oBuildAtom.m_nBuildId; - oBP.uiExpand = pPBC->m_oBuildAtom.m_fExpanded; - - oBP.advAuto = std::to_wstring(pPBC->m_oParaBuildAtom.m_nDelayTime); - oBP.animBg = pPBC->m_oParaBuildAtom.m_fAnimBackground; - oBP.rev = pPBC->m_oParaBuildAtom.m_fReverse; - oBP.autoUpdateAnimBg = pPBC->m_oParaBuildAtom.m_fAutomatic; - - std::vector ST_TLParaBuildType = - { - L"allAtOnce", - L"p", - L"cust", - L"whole" - }; - oBP.build = ST_TLParaBuildType[pPBC->m_oParaBuildAtom.m_nParaBuild % 4]; -} - -void Animation::FillCBhvr( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::CBhvr &oBhvr) -{ - CRecordTimeBehaviorContainer *bhvr = nullptr; - if (pETNC->m_haveSetBehavior) bhvr = &(pETNC->m_pTimeSetBehavior->m_oBehavior); - else if (pETNC->m_haveEffectBehavior) bhvr = &(pETNC->m_pTimeEffectBehavior->m_oBehavior); - else if (pETNC->m_haveAnimateBehavior) bhvr = &(pETNC->m_pTimeAnimateBehavior->m_oBehavior); - else if (pETNC->m_haveColorBehavior) bhvr = &(pETNC->m_pTimeColorBehavior->m_oBehavior); - else if (pETNC->m_haveMotionBehavior) bhvr = &(pETNC->m_pTimeMotionBehavior->m_oTimeBehavior); - else if (pETNC->m_haveRotationBehavior) bhvr = &(pETNC->m_pTimeRotationBehavior->m_oBehavior); - else if (pETNC->m_haveScaleBehavior) bhvr = &(pETNC->m_pTimeScaleBehavior->m_oBehavior); - else bhvr = &(pETNC->m_pTimeCommandBehavior->m_oBevavior); - - FillCBhvr(bhvr, oBhvr); - - FillCTn(pETNC, oBhvr.cTn); - -} - - -void Animation::FillCBhvr( - CRecordTimeBehaviorContainer *pBhvr, - PPTX::Logic::CBhvr &oBhvr) -{ - //// Atom //// - - // additive - if (pBhvr->m_oBehaviorAtom.m_bAdditivePropertyUsed) { - oBhvr.additive = new PPTX::Limit::TLAdditive; - oBhvr.additive = pBhvr->m_oBehaviorAtom.m_nBehaviorAdditive ? - L"repl" : L"base"; - } - - // accumulate - MUST be 0 - // xfrmType - MUST be 0 - - if (pBhvr->m_haveStringList) - { - if (!pBhvr->m_pStringList->m_arrRgChildRec.empty()) - { - oBhvr.attrNameLst = new PPTX::Logic::AttrNameLst(); - } - for (const auto &oldAttr : pBhvr->m_pStringList->m_arrRgChildRec) - { - PPTX::Logic::AttrName addAttr; - addAttr.text = oldAttr.m_Value; - oBhvr.attrNameLst->list.push_back(addAttr); - - } - } - - if (pBhvr->m_oClientVisualElement.m_bVisualShapeAtom) - { - UINT spid = pBhvr-> - m_oClientVisualElement. - m_oVisualShapeAtom.m_nObjectIdRef; - - if (isSpidReal(spid) == false) - { - m_isPPT10Broken = true; - } - - oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt(); - oBhvr.tgtEl.spTgt->spid = - std::to_wstring(spid); - if (m_currentBldP) - { - m_currentBldP->spid = - oBhvr.tgtEl.spTgt->spid; - } - if (pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData2 != 0xFFFFFFFF && - pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData1 != 0xFFFFFFFF) - { - oBhvr.tgtEl.spTgt->txEl = new PPTX::Logic::TxEl; - oBhvr.tgtEl.spTgt->txEl->charRg = false; - oBhvr.tgtEl.spTgt->txEl->st = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData1; - oBhvr.tgtEl.spTgt->txEl->end = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData2; - } - } - - - if (pBhvr->m_pPropertyList == nullptr) - return; - - for (const auto prop : pBhvr->m_pPropertyList->m_arRecords) - { - if (prop == nullptr) - continue; - - switch (prop->m_oHeader.RecInstance) - { - case TL_TBPID_RuntimeContext: - break; - case TL_TBPID_MotionPathEditRelative: - break; - case TL_TBPID_ColorColorModel: - break; - case TL_TBPID_ColorDirection: - break; - case TL_TBPID_Override: - { - auto override_ = new PPTX::Limit::TLOverride; - override_->set(L"childStyle"); - oBhvr.override_= override_; - break; - } - case TL_TBPID_PathEditRotationAngle: - break; - case TL_TBPID_PathEditRotationX: - break; - case TL_TBPID_PathEditRotationY: - break; - case TL_TBPID_PointsTypes: - break; - case TL_TBPID_UnknownPropertyList: - default: - break; - } - } -} -void Animation::FillCBhvr( - PPTX::Logic::CBhvr &oBhvr, int dur, - UINT spid, std::wstring attrname, int delay) -{ - oBhvr.cTn.id = m_cTnId++; - oBhvr.cTn.fill = L"hold"; - oBhvr.cTn.dur = std::to_wstring(dur); - if (delay > -1) - { - oBhvr.cTn.stCondLst = new PPTX::Logic::CondLst; - oBhvr.cTn.stCondLst->node_name = L"stCondLst"; - PPTX::Logic::Cond cond; - cond.delay = std::to_wstring(delay); - oBhvr.cTn.stCondLst->list.push_back(cond); - } - - oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt; - oBhvr.tgtEl.spTgt->spid = std::to_wstring(spid); - - if (!attrname.empty()) - { - oBhvr.attrNameLst = new PPTX::Logic::AttrNameLst; - PPTX::Logic::AttrName attrName; - attrName.text = attrname; - oBhvr.attrNameLst->list.push_back(attrName); - } - - -} -void Animation::FillCmd( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Cmd &oCmd) -{ - if (!pETNC || !pETNC->m_pTimeCommandBehavior) return; - - auto pCommand = pETNC->m_pTimeCommandBehavior; - auto oAtom = pCommand->m_oCommandBehaviorAtom; - - FillCBhvr(pETNC, oCmd.cBhvr); - - if (oAtom.m_fTypePropertyUsed) - { - oCmd.type = new PPTX::Limit::TLCommandType; - std::wstring type; - switch (oAtom.m_eCommandBehaviorType) - { - case TL_TCBT_Eventv: type = L"evt"; break; - case TL_TCBT_Call: type = L"call"; break; - case TL_TCBT_OleVerb: type = L"verb"; break; - } - oCmd.type->set(type); - } - if (oAtom.m_fCommandPropertyUsed) - { - oCmd.cmd = pCommand->m_oVarCommand.m_Value; - } -} - -void Animation::FillCond( - PPT_FORMAT::CRecordTimeConditionContainer *oldCond, - PPTX::Logic::Cond &cond) -{ - if (oldCond->m_oTimeConditionAtom.m_nTimeDelay != -1) - cond.delay = std::to_wstring(oldCond->m_oTimeConditionAtom.m_nTimeDelay); - else - cond.delay = L"indefinite"; - -// if (oldCond->m_oTimeConditionAtom.m_TriggerObject == TL_TOT_RuntimeNodeRef || -// oldCond->m_oTimeConditionAtom.m_TriggerObject == TL_TOT_TimeNode) -// { -// cond.tn = oldCond->m_oTimeConditionAtom.m_nID; -// } - if (oldCond->m_oTimeConditionAtom.m_TriggerObject == TL_TOT_RuntimeNodeRef) - { - cond.rtn = new PPTX::Limit::TLRuntimeTrigger; - cond.rtn->SetBYTECode(0); - } - - std::wstring str; - - switch (oldCond->m_oTimeConditionAtom.m_nTriggerEvent) - { - case 1: str = L"onBegin"; break; - case 3: str = L"begin"; break; - case 4: str = L"end"; break; - case 5: str = L"onClick"; break; - case 7: str = L"onMouseOver"; break; - case 9: str = L"onNext"; break; - case 10: str = L"onPrev"; break; - case 11: str = L"onStopAudio"; break; - default: str.clear(); - } - - if (!str.empty()) cond.evt = str; - - if (oldCond->m_oVisualElement.m_bVisualShapeAtom) - { - cond.tgtEl = new PPTX::Logic::TgtEl; - cond.tgtEl->spTgt = new PPTX::Logic::SpTgt; - cond.tgtEl->spTgt->spid = std::to_wstring( - oldCond->m_oVisualElement.m_oVisualShapeAtom.m_nObjectIdRef); - } else if (oldCond->m_oVisualElement.m_bVisualPageAtom) - { - cond.tgtEl = new PPTX::Logic::TgtEl; - } -} - - -// Not called -void Animation::FillCTn( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::CTn &oCTn) -{ - oCTn.id = m_cTnId++; - m_cTnDeep++; - - // Reading TimeNodeAtom - const auto &oTimeNodeAtom = pETNC->m_oTimeNodeAtom; - - // Write restart - if (oTimeNodeAtom.m_fRestartProperty) - oCTn.restart = PPTX::Limit::TLRestart(oTimeNodeAtom.m_dwRestart) ; - - - // Write fill - if (oTimeNodeAtom.m_fFillProperty) - oCTn.fill = PPTX::Limit::TLNodeFillType(oTimeNodeAtom.m_dwFill); - - // Write dur - if (oTimeNodeAtom.m_fDurationProperty) - { - if (oTimeNodeAtom.m_nDuration == -1) - oCTn.dur = L"indefinite"; - else - oCTn.dur = std::to_wstring(oTimeNodeAtom.m_nDuration); - } - - - //// Write Children //// - - //Write cTn attr - if (pETNC->m_haveTimePropertyList && !pETNC->m_pTimePropertyList->m_bEmtyNode) - { - FillCTn(pETNC->m_pTimePropertyList, oCTn); - } - - if (!pETNC->m_haveSequenceAtom) - { - // Write stCondLst - if (pETNC->m_arrRgBeginTimeCondition.empty() == false) - { - oCTn.stCondLst = new PPTX::Logic::CondLst; - oCTn.stCondLst->node_name = L"stCondLst"; - } - for (auto *oldCond : pETNC->m_arrRgBeginTimeCondition) { - PPTX::Logic::Cond cond; - cond.node_name = L"cond"; - FillCond(oldCond, cond); - oCTn.stCondLst->list.push_back(cond); - } - - - // Write endCondLst - if (pETNC->m_arrRgEndTimeCondition.empty() == false) - { - oCTn.endCondLst = new PPTX::Logic::CondLst; - oCTn.endCondLst->node_name = L"endCondLst"; - FillCondLst(pETNC->m_arrRgEndTimeCondition, oCTn.endCondLst.get2()); - } - } - - - // Write childTnLst - if (pETNC->m_arrRgExtTimeNodeChildren.empty() == false) - { - oCTn.childTnLst = new PPTX::Logic::ChildTnLst; - } - for (auto *oldChild : pETNC->m_arrRgExtTimeNodeChildren) { - PPTX::Logic::TimeNodeBase child; - FillTnChild(oldChild, child); - oCTn.childTnLst->list.push_back(child); - } - - - // Write iterate - if (pETNC->m_haveIterateDataAtom) - { - auto *iter = pETNC->m_pTimeIterateDataAtom; - oCTn.iterate = new PPTX::Logic::Iterate; - - std::wstring type[] = {L"el", L"wd", L"lt"}; - if (iter->m_fIterateTypePropertyUsed) - oCTn.iterate->type = type[iter->m_nIterateType % 3]; - - if (iter->m_fIterateDirectionPropertyUsed) - oCTn.iterate->backwards = (bool)iter->m_nIterateDirection; - - int intervalType = iter->m_fIterateIntervalTypePropertyUsed ? - iter->m_nIterateIntervalType : 0; - uint iterateInterval = iter->m_fIterateIntervalPropertyUsed ? - iter->m_nIterateInterval : 0; - - if (intervalType) - oCTn.iterate->tmPct = iterateInterval > 1000 ? 10000 : iterateInterval * 10; - else - oCTn.iterate->tmAbs = std::to_wstring(iterateInterval); - } - - - // Write endSync - if (pETNC->m_haveTimeEndSyncTime) - { - auto *sync = pETNC->m_pTimeEndSyncTimeCondition; - oCTn.endSync = new PPTX::Logic::Cond; - oCTn.endSync->node_name = L"endSync"; - FillCond(sync, *(oCTn.endSync)); - } - - - // Write subTnLst - if (pETNC->m_arrRgSubEffect.empty() == false) - { - // if ( - // pETNC->m_arrRgSubEffect[0]->m_oTimeNodeAtom.m_fGroupingTypeProperty && - // m_pBldLst && - // m_pPPT10->m_haveBuildList - // ) - // { - // oCTn.grpId = 0; - // auto bldP = new PPTX::Logic::BldP; - // bldP->grpId = 0; - // m_currentBldP = bldP; - // } - - auto sub = new PPTX::Logic::TnLst; - sub->node_name = L"subTnLst"; - FillSubTnLst(pETNC->m_arrRgSubEffect, *sub); - oCTn.subTnLst = sub; - - if (m_currentBldP) - { - PPTX::Logic::BuildNodeBase oBuildNodeBase; - oBuildNodeBase.m_node = m_currentBldP; - m_pBldLst->list.push_back(oBuildNodeBase); - m_currentBldP = nullptr; - } - - for (auto timeModAtom : pETNC->m_arrRgTimeModifierAtom) - { - switch (timeModAtom->m_nType) - { - case 0: - { - oCTn.repeatCount = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 1: - { - // Check 1000 - oCTn.repeatDur = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 2: - { - // Check 1000 - oCTn.spd = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 3: - { - // Check 1000 - oCTn.accel = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 4: - { - // Check 1000 - oCTn.decel = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 5: - { - // Check 1000 - oCTn.autoRev = (bool)timeModAtom->m_Value; - break; - } - - } - } - - } - - // Write stCondLst - if (pETNC->m_arrRgBeginTimeCondition.empty() == false) - { - oCTn.stCondLst = new PPTX::Logic::CondLst; - oCTn.stCondLst->node_name = L"stCondLst"; - FillStCondLst(pETNC->m_arrRgBeginTimeCondition, oCTn.stCondLst.get2()); - } - - if (oCTn.nodeType.IsInit() == false && (m_cTnDeep == 3 || m_cTnDeep == 4)) - { - oCTn.nodeType = new PPTX::Limit::TLNodeType(); - oCTn.nodeType->set( m_cTnDeep == 3 ? L"clickPar" : L"withGroup"); - } - m_cTnDeep--; -} - -void Animation::FillStCondLst(const std::vector &timeCondCont, - PPTX::Logic::CondLst &stCondLst) -{ - for (const auto& pCond : timeCondCont) - { - int target = -1; - if (pCond->m_oVisualElement.m_bVisualShapeAtom) - target = pCond->m_oVisualElement.m_oVisualShapeAtom.m_nObjectIdRef; - - PPTX::Logic::Cond cond; - FillCond(pCond, cond); - - stCondLst.list.push_back(cond); - } -} - -void Animation::FillPar( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Par &oPar) -{ - FillCTn(pETNC, oPar.cTn); -} - -void Animation::FillSeq( - PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Seq& oSec) -{ - if (pETNC->m_haveSequenceAtom) - { - if (pETNC->m_pTimeSequenceDataAtom->m_fConcurrencyPropertyUsed) - oSec.concurrent = (bool)pETNC->m_pTimeSequenceDataAtom->m_nConcurrency; - if (pETNC->m_pTimeSequenceDataAtom->m_fNextActionPropertyUsed) - oSec.nextAc = pETNC->m_pTimeSequenceDataAtom->m_nNextAction ? L"seek" : L"none"; - if (pETNC->m_pTimeSequenceDataAtom->m_fPreviousActionPropertyUsed) - oSec.prevAc = pETNC->m_pTimeSequenceDataAtom->m_nPreviousAction ? L"skipTimed" : L"none"; - } - FillCTn(pETNC, oSec.cTn); - - // Fill cond lists - if (!pETNC->m_arrRgEndTimeCondition.empty()) - { - oSec.prevCondLst = new PPTX::Logic::CondLst(); - oSec.prevCondLst->node_name = L"prevCondLst"; - } - for (auto oldCond : pETNC->m_arrRgEndTimeCondition) - { - PPTX::Logic::Cond cond; - cond.node_name = L"cond"; - FillCond(oldCond, cond); - if (m_cTnDeep == 1) - FillEmptyTargetCond(cond); - oSec.prevCondLst->list.push_back(cond); - } - - if (!pETNC->m_arrRgNextTimeCondition.empty()) - { - oSec.nextCondLst = new PPTX::Logic::CondLst(); - oSec.nextCondLst->node_name = L"nextCondLst"; - } - for (auto oldCond : pETNC->m_arrRgNextTimeCondition) - { - PPTX::Logic::Cond cond; - cond.node_name = L"cond"; - FillCond(oldCond, cond); - if (m_cTnDeep == 1) - FillEmptyTargetCond(cond); - oSec.nextCondLst->list.push_back(cond); - } - -} - -void Animation::FillSet( - PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Set& oSet) -{ - if (!pETNC->m_haveSetBehavior) return; - - // TODO - FillCBhvr(pETNC, oSet.cBhvr); - oSet.to = new PPTX::Logic::AnimVariant(); - oSet.to->node_name = L"to"; - oSet.to->strVal = pETNC->m_pTimeSetBehavior->m_oVarTo.m_Value; - -} - -void Animation::FillTnChild( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::TimeNodeBase &oChild) -{ - if (pETNC->m_haveSequenceAtom) - { - auto seq = new PPTX::Logic::Seq; - FillSeq(pETNC, *seq); - oChild.m_node = seq; - } - else if (pETNC->m_haveSetBehavior) - { - auto set = new PPTX::Logic::Set; - FillSet(pETNC, *set); - oChild.m_node = set; - } - else if (pETNC->m_haveAnimateBehavior) - { - auto anim = new PPTX::Logic::Anim; - FillAnim(pETNC->m_pTimeAnimateBehavior, *anim); - FillCTn(pETNC, anim->cBhvr.cTn); - oChild.m_node = anim; - } - else if (pETNC->m_haveColorBehavior) - { - auto animClr = new PPTX::Logic::AnimClr; - FillAnimClr(pETNC->m_pTimeColorBehavior, pETNC->m_pTimePropertyList, *animClr); - oChild.m_node = animClr; - } - else if (pETNC->m_haveEffectBehavior) - { - auto animEffect = new PPTX::Logic::AnimEffect; - FillAnimEffect(pETNC, *animEffect); - oChild.m_node = animEffect; - } - else if (pETNC->m_haveMotionBehavior) - { - auto motion = new PPTX::Logic::AnimMotion; - FillAnimMotion(pETNC, *motion); - oChild.m_node = motion; - } - else if (pETNC->m_haveRotationBehavior) - { - auto rot = new PPTX::Logic::AnimRot; - FillAnimRot(pETNC, *rot); - oChild.m_node = rot; - } - else if (pETNC->m_haveScaleBehavior) - { - auto scale = new PPTX::Logic::AnimScale; - FillAnimScale(pETNC, *scale); - oChild.m_node = scale; - } - else if (pETNC->m_haveCommandBehavior) - { - auto cmd = new PPTX::Logic::Cmd; - FillCmd(pETNC, *cmd); - oChild.m_node = cmd; - } - else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) - { - auto par = new PPTX::Logic::Par; - FillPar(pETNC, *par); - oChild.m_node = par; - } - else if (pETNC->m_haveClientVisualElement) - { - if (pETNC->m_pClientVisualElement->m_bVisualPageAtom) - { - - } - if (pETNC->m_pClientVisualElement->m_bVisualShapeAtom) - { - if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Video) - { - auto video = new PPTX::Logic::Video; - FillVideo(pETNC, *video); - oChild.m_node = video; - } - - if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Audio) - { - auto audio = new PPTX::Logic::Audio; - FillAudio(pETNC, *audio); - oChild.m_node = audio; - } - } - } -} - -void Animation::FillTnLst( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::TnLst &oTnLst) -{ - if (!pETNC) - return; - - PPTX::Logic::TimeNodeBase oChildTimeNodeBase; - FillTnChild(pETNC, oChildTimeNodeBase); - oTnLst.list.push_back(oChildTimeNodeBase); -} - -void Animation::FillSubTnLst ( - std::vector &vecSEC, - PPTX::Logic::TnLst &oSubTnLst) -{ - for (auto pSEC : vecSEC) - { - if (pSEC->m_haveClientVisualElement) - { - PPTX::Logic::TimeNodeBase TNB; - auto audio = new PPTX::Logic::Audio; - - FillAudio(pSEC->m_pClientVisualElement, *audio); - TNB.m_node = audio; - oSubTnLst.list.push_back(TNB); - - // Write endCondLst - if (pSEC->m_arrRgEndTimeCondition.empty() == false) - { - audio->cMediaNode.cTn.endCondLst = new PPTX::Logic::CondLst; - audio->cMediaNode.cTn.endCondLst->node_name = L"endCondLst"; - } - FillCondLst(pSEC->m_arrRgEndTimeCondition, - audio->cMediaNode.cTn.endCondLst.get2()); - - // Write stCondLst - if (pSEC->m_arrRgBeginTimeCondition.empty() == false) - { - audio->cMediaNode.cTn.stCondLst = new PPTX::Logic::CondLst; - audio->cMediaNode.cTn.stCondLst->node_name = L"stCondLst"; - } - FillCondLst(pSEC->m_arrRgBeginTimeCondition, - audio->cMediaNode.cTn.stCondLst.get2()); - FillCTn(pSEC->m_pTimePropertyList, audio->cMediaNode.cTn); - } - - if (pSEC->m_haveColorBehavior) - { - PPTX::Logic::TimeNodeBase TNB; - auto color = new PPTX::Logic::AnimClr; - - FillAnimClr(pSEC->m_pTimeColorBehavior, pSEC->m_pTimePropertyList, *color); - TNB.m_node = color; - oSubTnLst.list.push_back(TNB); - } - } -} - -void Animation::FillCondLst( - std::vector& oCondVec, - PPTX::Logic::CondLst &oCondLst) -{ - for (auto *oldCond : oCondVec) { - PPTX::Logic::Cond cond; - cond.node_name = L"cond"; - FillCond(oldCond, cond); - oCondLst.list.push_back(cond); - } -} - -void Animation::FillEmptyTargetCond(PPTX::Logic::Cond &cond) -{ - cond.tgtEl = new PPTX::Logic::TgtEl; - // p:sldTgt will be pasted by default -} - -void Animation::FillCTn( - CRecordTimePropertyList4TimeNodeContainer *pProp, - PPTX::Logic::CTn &oCTn) -{ - if (pProp && !pProp->m_bEmtyNode) - { - for (auto *pRec : pProp->m_arrElements) - { - TimePropertyID4TimeNode VariableType = ( TimePropertyID4TimeNode ) pRec->m_oHeader.RecInstance; - - switch ( VariableType ) - { - case TL_TPID_Display: - { - oCTn.display = !(bool)dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_MasterPos: - { - oCTn.masterRel = new PPTX::Limit::TLMasterRelation; - oCTn.masterRel = dynamic_cast(pRec)->m_Value ? - L"nextClick" : L"sameClick"; - break; - } - case TL_TPID_SubType: break; - case TL_TPID_EffectID: - { - oCTn.presetID = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EffectDir: - { - oCTn.presetSubtype = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EffectType: - { - // Write presetClass - std::wstring presetClass; - switch (dynamic_cast(pRec)->m_Value) { - case 0: break; - case 1: presetClass = L"entr"; break; - case 2: presetClass = L"exit"; break; - case 3: presetClass = L"emph"; break; - case 4: presetClass = L"path"; break; - case 5: presetClass = L"verb"; break; - case 6: presetClass = L"mediacall"; break; - } - if (!presetClass.empty()) - { - oCTn.presetClass = new PPTX::Limit::TLPresetClass; - oCTn.presetClass = presetClass; - } - break; - } - case TL_TPID_AfterEffect: - { - oCTn.afterEffect = (bool)dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_SlideCount: break; - case TL_TPID_TimeFilter: - { - oCTn.tmFilter = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EventFilter: - { - oCTn.evtFilter = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_HideWhenStopped: break; - case TL_TPID_GroupID: - { - oCTn.grpId = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EffectNodeType: - { - // Write nodeType - std::wstring nodeType; - switch (dynamic_cast(pRec)->m_Value) - { - case 1: nodeType = L"clickEffect"; break; - case 2: nodeType = L"withEffect"; break; - case 3: nodeType = L"afterEffect"; break; - case 4: nodeType = L"mainSeq"; break; - case 5: nodeType = L"interactiveSeq"; break; - case 6: nodeType = L"clickPar"; break; - case 7: nodeType = L"withGroup"; break; - case 8: nodeType = L"afterGroup"; break; - case 9: nodeType = L"tmRoot"; break; - } - if (!nodeType.empty()) - { - oCTn.nodeType = new PPTX::Limit::TLNodeType; - oCTn.nodeType = nodeType; - } - - break; - } - case TL_TPID_PlaceholderNode: - { - oCTn.nodePh = (bool)dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_MediaVolume: break; - case TL_TPID_MediaMute: break; - case TL_TPID_ZoomToFullScreen: break; - default : - break; - } - } - } -} - -void Animation::InitTimingTags(PPTX::Logic::Timing &oTiming) -{ - // p:bldLst - oTiming.bldLst = new PPTX::Logic::BldLst(); - for (auto oldAnim : m_arrOldAnim) - { - PPTX::Logic::BuildNodeBase oBuildNodeBase; - PPTX::Logic::BldP *pBldP = new PPTX::Logic::BldP(); - pBldP->spid = std::to_wstring(oldAnim.shapeId); - pBldP->grpId = false; - pBldP->animBg = (bool)(oldAnim.anim->m_AnimationAtom.m_fAnimateBg != 0); - - oBuildNodeBase.m_node = pBldP; - oTiming.bldLst->list.push_back(oBuildNodeBase); - } - - // p:tnLst - oTiming.tnLst = new PPTX::Logic::TnLst(); - - auto par1 = new PPTX::Logic::Par; - par1->cTn.id = m_cTnId++; - par1->cTn.dur = L"indefinite"; - par1->cTn.restart = L"never"; - par1->cTn.nodeType = L"tmRoot"; - - auto seq2 = new PPTX::Logic::Seq; - seq2->cTn.id = m_cTnId++; - seq2->cTn.dur = L"indefinite"; - seq2->cTn.nodeType = L"mainSeq"; - seq2->concurrent = L"1"; - seq2->nextAc = L"seek"; - seq2->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - - std::list > arrClickPar; - SplitAnim(arrClickPar); - - for (auto& clickPar : arrClickPar) - { - PPTX::Logic::TimeNodeBase child; - FillClickPar(clickPar, child); - seq2->cTn.childTnLst->list.push_back(child); - } - - PPTX::Logic::Cond cond; - cond.tgtEl = new PPTX::Logic::TgtEl; - if (m_arrOldAnim[0].anim->m_AnimationAtom.m_fAutomatic) - cond.delay = L"0"; - - seq2->nextCondLst = new PPTX::Logic::CondLst; - seq2->nextCondLst->node_name = L"nextCondLst"; - cond.evt = L"onNext"; - cond.delay = L"0"; - seq2->nextCondLst->list.push_back(cond); - - seq2->prevCondLst = new PPTX::Logic::CondLst; - seq2->prevCondLst->node_name = L"prevCondLst"; - cond.evt = L"onPrev"; - cond.delay = L"0"; - seq2->prevCondLst->list.push_back(cond); - - // push back - PPTX::Logic::TimeNodeBase timeNodeBase; - timeNodeBase.m_node = seq2; - par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - par1->cTn.childTnLst->list.push_back(timeNodeBase); - timeNodeBase.m_node = par1; - - oTiming.tnLst->list.push_back(timeNodeBase); - -} - -void Animation::SplitAnim(std::list >& arrClickPar) -{ - std::sort(m_arrOldAnim.begin(), m_arrOldAnim.end(), [] ( - const SOldAnimation& a1, - const SOldAnimation& a2) - { - return a1.anim->m_AnimationAtom.m_OrderID < - a2.anim->m_AnimationAtom.m_OrderID; - }); - - for (auto& oldAnim : m_arrOldAnim) - { - if (isSpidReal(oldAnim.shapeId) == false) - continue; - - if (arrClickPar.empty()) - { - std::list clickPar; - clickPar.push_back(&oldAnim); - arrClickPar.push_back(clickPar); - } else if (oldAnim.anim->m_AnimationAtom.m_fAutomatic) - { - arrClickPar.back().push_back(&oldAnim); - } else - { - std::list clickPar; - clickPar.push_back(&oldAnim); - arrClickPar.push_back(clickPar); - } - } - -} - -void Animation::FillClickPar(std::list& clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase) -{ - auto animAtom = clickPar.front()->anim->m_AnimationAtom; - - auto par1 = new PPTX::Logic::Par; - FillCTnParams(par1->cTn, L"clickPar", L"indefinite"); - - PPTX::Logic::Cond cond; - if (animAtom.m_OrderID == 1 && - animAtom.m_fAutomatic) - { - cond.evt = L"onBegin"; - cond.delay = L"0"; - cond.tn = 2; - par1->cTn.stCondLst->list.push_back(cond); - } - - // p:childTnLst - PPTX::Logic::TimeNodeBase childTimeNode; - _UINT32 groupDelay = 0; - FillGroup(clickPar.front(), childTimeNode, groupDelay, L"withGroup"); - par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - par1->cTn.childTnLst->list.push_back(childTimeNode); - clickPar.pop_front(); - - while (!clickPar.empty()) - { - PPTX::Logic::TimeNodeBase childTimeNode; - FillGroup(clickPar.front(), childTimeNode, groupDelay, L"afterGroup"); - par1->cTn.childTnLst->list.push_back(childTimeNode); - clickPar.pop_front(); - } - - oTimeNodeBase.m_node = par1; -} - -void Animation::FillGroup (SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType) -{ - auto anim = pOldAnim->anim->m_AnimationAtom; - auto par = new PPTX::Logic::Par; - - FillCTnParams(par->cTn, nodeType, std::to_wstring(groupDelay)); - PPTX::Logic::TimeNodeBase childTimeNode; - if (anim.m_fAutomatic) - { - FillAfterEffect(pOldAnim, childTimeNode, groupDelay); - } else - { - FillClickEffect(pOldAnim, childTimeNode, groupDelay); - } - - par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - par->cTn.childTnLst->list.push_back(childTimeNode); - - oTimeNodeBase.m_node = par; -} - -void Animation::FillClickEffect(SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay) -{ - auto par = new PPTX::Logic::Par; - - FillCTnParams(par->cTn, L"clickEffect", L"0", L"hold", pOldAnim); - groupDelay += 500; // Effect time // TODO for anim - - oTimeNodeBase.m_node = par; -} - -void Animation::FillAfterEffect(SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay) -{ - auto anim = pOldAnim->anim->m_AnimationAtom; - auto par = new PPTX::Logic::Par; - - groupDelay += anim.m_DelayTime; - auto delay = std::to_wstring(anim.m_DelayTime); - groupDelay += pOldAnim->getAnimDur(); // Effect time - - FillCTnParams(par->cTn, L"afterEffect", delay, L"hold", pOldAnim); -// par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed - - oTimeNodeBase.m_node = par; -} - -void Animation::FillCBhvr (PPTX::Logic::CBhvr &oCBhvr, SOldAnimation* pOldAnim, int delay) -{ - // auto anim = pOldAnim->anim->m_AnimationAtom; - FillCBhvr(oCBhvr, 1, pOldAnim->shapeId, L"style.visibility", delay); -} - -void Animation::FillCTnParams (PPTX::Logic::CTn &oCTN, std::wstring nodeType, std::wstring condDelay, - std::wstring fill, SOldAnimation* pOldAnim) -{ - oCTN.id = m_cTnId++; - oCTN.fill = fill; - oCTN.nodeType = nodeType; - - if (pOldAnim) - { - FillCTnAnimation(oCTN, pOldAnim); - } - - // p:stCondLst - oCTN.stCondLst = new PPTX::Logic::CondLst; - oCTN.stCondLst->node_name = L"stCondLst"; - PPTX::Logic::Cond cond; - cond.delay = condDelay; - oCTN.stCondLst->list.push_back(cond); -} - -void Animation::FillCBhvrForAnim (PPTX::Logic::Anim& oAnim, SOldAnimation* pOldAnim, int dur, std::wstring attrname) -{ - FillCBhvr(oAnim.cBhvr, dur, pOldAnim->shapeId, attrname, -1); - - oAnim.cBhvr.additive = new PPTX::Limit::TLAdditive; - oAnim.cBhvr.additive->set(L"base"); - - oAnim.calcmode = new PPTX::Limit::TLCalcMode; - oAnim.calcmode->set(L"lin"); - oAnim.valueType = new PPTX::Limit::TLValueType; - oAnim.valueType->set(L"num"); -} - -void Animation::FillAnim (PPTX::Logic::Anim& oAnim, SOldAnimation* pOldAnim, int dur, std::wstring attrname, - SValue val1, SValue val2, std::wstring fmla) -{ - FillCBhvrForAnim(oAnim, pOldAnim, dur, attrname); - - oAnim.tavLst = new PPTX::Logic::TavLst; - PPTX::Logic::Tav tav; - - tav.tm = L"0"; - if (fmla.size()) - { - tav.fmla = fmla; - } - auto val = new PPTX::Logic::AnimVariant; - val->node_name = L"val"; - if (val1.type == SValue::str) - val->strVal = val1.strVal; - else if (val1.type == SValue::dbl) - val->fltVal = val1.dblVal; - - tav.val = val; - oAnim.tavLst->list.push_back(tav); - tav.fmla.reset(); - - tav.tm = L"100000"; - val = new PPTX::Logic::AnimVariant; - val->node_name = L"val"; - if (val2.type == SValue::str) - val->strVal = val2.strVal; - else if (val2.type == SValue::dbl) - val->fltVal = val2.dblVal; - - tav.val = val; - oAnim.tavLst->list.push_back(tav); - -} - -void Animation::FillAnimEffect (PPTX::Logic::AnimEffect& oAnimEffect, SOldAnimation* pOldAnim, std::wstring filter, std::wstring transition) -{ - oAnimEffect.transition = new PPTX::Limit::TLTransition(); - oAnimEffect.transition->set(transition); - oAnimEffect.filter = filter; - - oAnimEffect.cBhvr.cTn.id = m_cTnId++; - oAnimEffect.cBhvr.cTn.dur = std::to_wstring(pOldAnim->getAnimDur()); - oAnimEffect.cBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt; - oAnimEffect.cBhvr.tgtEl.spTgt->spid = std::to_wstring(pOldAnim->shapeId); -} - - -void Animation::FillSetAndAnim (SOldAnimation* pOldAnim, - PPTX::Logic::ChildTnLst& oParent) -{ - // bool isAppear = pOldAnim->anim->m_AnimationAtom.m_AnimEffect == 0; - // PPTX::Logic::TimeNodeBase childTimeNode; - // auto set = new PPTX::Logic::Set; - // if (isAppear) - // FillCBhvr(set->cBhvr, pOldAnim); - // else - // { - // FillCBhvr(set->cBhvr, pOldAnim, 0); - // } - // set->to = new PPTX::Logic::AnimVariant; - // set->to->node_name = L"to"; - // set->to->strVal = L"visible"; - - // childTimeNode.m_node = set; - // oParent.list.push_back(childTimeNode); - - // if (!isAppear) - // { - // auto anim = new PPTX::Logic::Anim; - // FillAnim(*anim, pOldAnim, 500, L"ppt_x", L"0-#ppt_w/2", L"#ppt_x"); - // childTimeNode.m_node = anim; - // oParent.list.push_back(childTimeNode); - - // anim = new PPTX::Logic::Anim; - // FillAnim(*anim, pOldAnim, 500, L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); - // childTimeNode.m_node = anim; - // oParent.list.push_back(childTimeNode); - // } -} - -void Animation::FillCTnAnimation (PPTX::Logic::CTn &oCTN, SOldAnimation *pOldAnim) -{ - oCTN.presetClass = L"entr"; - oCTN.grpId = 0; - oCTN.childTnLst = new PPTX::Logic::ChildTnLst; - oCTN.presetSubtype = 0; - int presetSub = -1; - - const UINT effect = pOldAnim->anim->m_AnimationAtom.m_AnimEffect; - const UINT direct = pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection; - - // Todo 4, 7. 0x11 - 0x1B - switch (effect) - { - case 0x00: - { - oCTN.presetID = 1; - ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); - break; - } - case 0x01: - { - oCTN.presetID = 24; - ConvertRandomEffect(oCTN.childTnLst.get2(), pOldAnim); - break; - } - case 0x02: - { - oCTN.presetID = 3; - ConvertBlinds(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - case 0x03: - { - oCTN.presetID = 5; - ConvertCheckerboard(oCTN.childTnLst.get2(), pOldAnim); - break; - } - case 0x05: - { - oCTN.presetID = 9; - ConvertDissolveIn(oCTN.childTnLst.get2(), pOldAnim); - break; - } - case 0x06: - { - oCTN.presetID = 10; - ConvertFade(oCTN.childTnLst.get2(), pOldAnim); - break; - } - case 0x08: - { - oCTN.presetID = 14; - ConvertRandomBars(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - case 0x09: - { - oCTN.presetID = 18; - ConvertStrips(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - case 0x0A: - { - oCTN.presetID = 22; - ConvertWipe(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - case 0x0B: - { - oCTN.presetID = 4; - ConvertShape(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - case 0x0C: - { - if (direct >= 0 && direct <= 7) - { - oCTN.presetID = 2; - ConvertFlyIn(oCTN.childTnLst.get2(), pOldAnim, presetSub); - } else if (direct >= 8 && direct <= 11) - { - oCTN.presetID = 12; - ConvertPeekIn(oCTN.childTnLst.get2(), pOldAnim, presetSub); - } else if (direct >= 12 && direct <= 15) - { - oCTN.presetID = 7; - ConvertCrawlIn(oCTN.childTnLst.get2(), pOldAnim, presetSub); - } else if (direct >= 16 && direct <= 21) - { - oCTN.presetID = 23; - ConvertBasicZoom(oCTN.childTnLst.get2(), pOldAnim, presetSub); - } else if (direct >= 22 && direct <= 26) - { - oCTN.presetID = 17; - ConvertStretch(oCTN.childTnLst.get2(), pOldAnim, presetSub); - } else if (direct == 27) - { - oCTN.presetID = 19; - ConvertBasicSwivel(oCTN.childTnLst.get2(), pOldAnim, presetSub); - } else if (direct == 28) - { - oCTN.presetID = 15; - ConvertSpiralIn(oCTN.childTnLst.get2(), pOldAnim); - } - break; - } - case 0x0D: - { - oCTN.presetID = 16; - ConvertSplit(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - case 0x0E: - { - oCTN.presetID = 11; - ConvertFlashOnce(oCTN.childTnLst.get2(), pOldAnim, presetSub); - break; - } - default: - oCTN.presetID = 1; - ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); - std::wcout << "Error: Unknown old animation id: " << std::to_wstring(effect) << L"\n"; - - } - - if (presetSub != -1) - { - oCTN.presetSubtype = presetSub; - } - -} - -// This methods fill ChildTnLst with anim nodes -void Animation::ConvertAppear(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim) -{ - PushSet(oParent, pOldAnim, 499); -} - -void Animation::ConvertFlyIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 0: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - - presetSub = 8; - break; - } - case 1: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"#ppt_x", L"#ppt_x", - L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); - - presetSub = 1; - break; - } - case 2: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - - presetSub = 2; - break; - } - case 3: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"#ppt_x", L"#ppt_x", - L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); - - presetSub = 4; - break; - } - case 4: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", - L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); - - presetSub = 9; - break; - } - case 5: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", - L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); - - presetSub = 3; - break; - } - case 6: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", - L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); - - presetSub = 12; - break; - } - case 7: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", - L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); - - presetSub = 6; - break; - } - } -} - -void Animation::ConvertBlinds(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int &presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 0: - { - PushAnimEffect(oParent, pOldAnim, L"blinds(vertical)", L"in"); - - presetSub = 5; - break; - } - case 1: - { - PushAnimEffect(oParent, pOldAnim, L"blinds(horizontal)", L"in"); - - presetSub = 10; - break; - } - } -} - -void Animation::ConvertShape(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 0: - { - PushAnimEffect(oParent, pOldAnim, L"box(out)", L"in"); - - presetSub = 32; - break; - } - case 1: - { - PushAnimEffect(oParent, pOldAnim, L"box(in)", L"in"); - - presetSub = 16; - break; - } - } -} - -void Animation::ConvertCheckerboard(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim) -{ - PushSet(oParent, pOldAnim); - PushAnimEffect(oParent, pOldAnim, L"checkerboard(across)", L"in"); -} - -void Animation::ConvertCrawlIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 15: - { - PushAnim(oParent, pOldAnim, 5000, - L"ppt_x", L"#ppt_x", L"#ppt_x", - L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); - - presetSub = 4; - break; - } - case 12: - { - PushAnim(oParent, pOldAnim, 5000, - L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - - presetSub = 8; - break; - } - case 14: - { - PushAnim(oParent, pOldAnim, 5000, - L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - - presetSub = 2; - break; - } - case 13: - { - PushAnim(oParent, pOldAnim, 5000, - L"ppt_x", L"#ppt_x", L"#ppt_x", - L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); - - presetSub = 1; - break; - } - } -} - -void Animation::ConvertDissolveIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim) -{ - PushSet(oParent, pOldAnim); - PushAnimEffect(oParent, pOldAnim, L"dissolve", L"in"); -} - -void Animation::ConvertFade(PPTX::Logic::ChildTnLst &oParent, SOldAnimation *pOldAnim) -{ - PushSet(oParent, pOldAnim); - PushAnimEffect(oParent, pOldAnim, L"fade", L"in"); -} - -void Animation::ConvertFlashOnce(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - presetSub = 0; - - // correct cTn params - auto set = dynamic_cast(oParent.list.front().m_node.GetPointer()); - if (!set) return; - set->cBhvr.cTn.dur = std::to_wstring(pOldAnim->getAnimDur()); - set->cBhvr.cTn.fill.reset(); -} - -void Animation::ConvertPeekIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 8: - { - PushAnim(oParent, pOldAnim, L"ppt_x", L"#ppt_x-#ppt_w*1.125000", L"#ppt_x"); - PushAnimEffect(oParent, pOldAnim, L"wipe(right)", L"in"); - - presetSub = 8; - break; - } - case 9: - { - PushAnim(oParent, pOldAnim, L"ppt_y", L"#ppt_y+#ppt_h*1.125000", L"#ppt_y"); - PushAnimEffect(oParent, pOldAnim, L"wipe(up)", L"in"); - - presetSub = 4; - break; - } - case 10: - { - PushAnim(oParent, pOldAnim, L"ppt_x", L"#ppt_x+#ppt_w*1.125000", L"#ppt_x"); - PushAnimEffect(oParent, pOldAnim, L"wipe(left)", L"in"); - - presetSub = 2; - break; - } - case 11: - { - PushAnim(oParent, pOldAnim, L"ppt_y", L"#ppt_y-#ppt_h*1.125000", L"#ppt_y"); - PushAnimEffect(oParent, pOldAnim, L"wipe(down)", L"in"); - - presetSub = 1; - break; - } - } -} - -void Animation::ConvertRandomBars(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 0: - { - PushAnimEffect(oParent, pOldAnim, L"randombar(horizontal)", L"in"); - - presetSub = 10; - break; - } - case 1: - { - PushAnimEffect(oParent, pOldAnim, L"randombar(vertical)", L"in"); - - presetSub = 5; - break; - } - } -} - -void Animation::ConvertSpiralIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim) -{ - PushSet(oParent, pOldAnim); -// TODO - PushAnim(oParent, pOldAnim, 1000, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", double(0), L"#ppt_h"); - PushAnim(oParent, pOldAnim, 1000, - L"ppt_x", double(0), double(1), - L"ppt_y", double(0), double(1), - L"#ppt_x+(cos(-2*pi*(1-$))*-#ppt_x-sin(-2*pi*(1-$))*(1-#ppt_y))*(1-$)", - L"#ppt_y+(sin(-2*pi*(1-$))*-#ppt_x+cos(-2*pi*(1-$))*(1-#ppt_y))*(1-$)"); - - // remove additive from - for (auto& child : oParent.list) - { - auto anim = dynamic_cast(child.m_node.GetPointer()); - if (!anim) continue; - anim->cBhvr.additive.reset(); - } - -} - -void Animation::ConvertSplit(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 0: - { - PushAnimEffect(oParent, pOldAnim, L"barn(outHorizontal)", L"in"); - - presetSub = 42; - break; - } - case 1: - { - PushAnimEffect(oParent, pOldAnim, L"barn(inHorizontal)", L"in"); - - presetSub = 26; - break; - } - case 2: - { - PushAnimEffect(oParent, pOldAnim, L"barn(outVertical)", L"in"); - - presetSub = 37; - break; - } - case 3: - { - PushAnimEffect(oParent, pOldAnim, L"barn(inVertical)", L"in"); - - presetSub = 21; - break; - } - } -} - -void Animation::ConvertStretch(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 22: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", L"#ppt_h", L"#ppt_h"); - - presetSub = 10; - break; - } - case 26: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"#ppt_x", L"#ppt_x", - L"ppt_y", L"#ppt_y+#ppt_h/2", L"#ppt_y"); - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", L"#ppt_w", L"#ppt_w", - L"ppt_h", double(0), L"#ppt_h"); - - presetSub = 4; - break; - } - case 23: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"##ppt_x-#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", L"#ppt_h", L"#ppt_h"); - - presetSub = 8; - break; - } - case 25: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"#ppt_x-#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", L"#ppt_h", L"#ppt_h"); - - presetSub = 2; - break; - } - case 24: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", L"#ppt_x+#ppt_w/2", L"#ppt_x", - L"ppt_y", L"#ppt_y", L"#ppt_y"); - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", L"#ppt_h", L"#ppt_h"); - - presetSub = 1; - break; - } - } -} - -void Animation::ConvertStrips(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 6: - { - PushAnimEffect(oParent, pOldAnim, L"strips(downLeft)", L"in"); - - presetSub = 12; - break; - } - case 4: - { - PushAnimEffect(oParent, pOldAnim, L"strips(upLeft)", L"in"); - - presetSub = 9; - break; - } - case 7: - { - PushAnimEffect(oParent, pOldAnim, L"strips(downRight)", L"in"); - - presetSub = 6; - break; - } - case 5: - { - PushAnimEffect(oParent, pOldAnim, L"strips(upRight)", L"in"); - - presetSub = 3; - break; - } - } -} - -void Animation::ConvertBasicSwivel(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - presetSub = 10; - - PushAnim(oParent, pOldAnim, 5000, - L"ppt_w", double(0), double(1), - L"ppt_h", L"#ppt_h", L"#ppt_h", - L"#ppt_w*sin(2.5*pi*$)"); -} - -void Animation::ConvertWipe(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 3: - { - PushAnimEffect(oParent, pOldAnim, L"wipe(up)", L"in"); - - presetSub = 1; - break; - } - case 0: - { - PushAnimEffect(oParent, pOldAnim, L"wipe(left)", L"in"); - - presetSub = 2; - break; - } - case 2: - { - PushAnimEffect(oParent, pOldAnim, L"wipe(right)", L"in"); - - presetSub = 8; - break; - } - case 1: - { - PushAnimEffect(oParent, pOldAnim, L"wipe(down)", L"in"); - - presetSub = 4; - break; - } - } -} - -void Animation::ConvertBasicZoom(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub) -{ - PushSet(oParent, pOldAnim); - - switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) - { - case 16: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", double(0), L"#ppt_h"); - - presetSub = 16; - break; - } - case 20: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", double(0), L"#ppt_w", - L"ppt_h", double(0), L"#ppt_h"); - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", double(0.5), L"#ppt_x", - L"ppt_y", double(0.5), L"#ppt_y"); - - presetSub = 528; - break; - } - case 17: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", L"2/3*#ppt_w", L"#ppt_w", - L"ppt_h", L"2/3*#ppt_h", L"#ppt_h"); - - presetSub = 272; - break; - } - case 18: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", L"#ppt_w", L"#ppt_w", - L"ppt_h", L"4*#ppt_h", L"#ppt_h"); - - presetSub = 32; - break; - } - case 21: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", L"(6*min(max(#ppt_w*#ppt_h,.3),1)-7.4)/-.7*#ppt_w", L"#ppt_w", - L"ppt_h", L"(6*min(max(#ppt_w*#ppt_h,.3),1)-7.4)/-.7*#ppt_h", L"#ppt_h"); - PushAnim(oParent, pOldAnim, 500, - L"ppt_x", double(0.5), L"#ppt_x", - L"ppt_y", L"1+(6*min(max(#ppt_w*#ppt_h,.3),1)-7.4)/-.7*#ppt_h/2", L"#ppt_y"); - - presetSub = 36; - break; - } - case 19: - { - PushAnim(oParent, pOldAnim, 500, - L"ppt_w", L"4/3*#ppt_w", L"#ppt_w", - L"ppt_h", L"4/3*#ppt_h", L"#ppt_h"); - - presetSub = 288; - break; - } - } -} - -void Animation::ConvertRandomEffect(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim) -{ - PushSet(oParent, pOldAnim, 499); - - PPTX::Logic::TimeNodeBase childTimeNode; - - auto anim = new PPTX::Logic::Anim; - anim->to = L""; - anim->calcmode = new PPTX::Limit::TLCalcMode; - anim->calcmode->set(L"lin"); - anim->valueType = new PPTX::Limit::TLValueType; - anim->valueType->set(L"num"); - - FillCBhvr(anim->cBhvr, 1, pOldAnim->shapeId, L"", -1); - childTimeNode.m_node = anim; - oParent.list.push_back(childTimeNode); -} - -void Animation::PushAnim(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int dur, - std::wstring attrname1, SValue val1, SValue val2, - std::wstring attrname2, SValue val3, SValue val4, std::wstring fmla1, std::wstring fmla2) -{ - PushAnim(oParent, pOldAnim, attrname1, val1, val2, fmla1); - PushAnim(oParent, pOldAnim, attrname2, val3, val4, fmla2); -} - -void Animation::PushAnim(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, - std::wstring attrname1, SValue val1, SValue val2,std::wstring fmla1) -{ - PPTX::Logic::TimeNodeBase childTimeNode; - - auto anim = new PPTX::Logic::Anim; - FillAnim(*anim, pOldAnim, pOldAnim->getAnimDur(), attrname1, val1, val2, fmla1); - childTimeNode.m_node = anim; - oParent.list.push_back(childTimeNode); -} - -void Animation::PushAnimEffect(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, std::wstring filter, std::wstring transition) -{ - PPTX::Logic::TimeNodeBase childTimeNode; - - auto animEffect = new PPTX::Logic::AnimEffect; - FillAnimEffect(*animEffect, pOldAnim, filter, transition); - childTimeNode.m_node = animEffect; - oParent.list.push_back(childTimeNode); -} - -void Animation::PushSet(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int dur) -{ - PPTX::Logic::TimeNodeBase childTimeNode; - auto set = new PPTX::Logic::Set; - - FillCBhvr(set->cBhvr, pOldAnim, dur); - set->to = new PPTX::Logic::AnimVariant; - set->to->node_name = L"to"; - set->to->strVal = L"visible"; - - childTimeNode.m_node = set; - oParent.list.push_back(childTimeNode); -} - -bool Animation::isSpidReal(const UINT spid) -{ - if (m_realShapesId.find(spid) == m_realShapesId.end()) - return false; - else - return true; - -// if (m_arrOldAnim.empty()) -// return true; - -// for (const auto& oldAnim : m_arrOldAnim) -// if (oldAnim.shapeId == spid) -// return true; - -// return false; -} - - -unsigned SOldAnimation::getAnimDur()const -{ - unsigned dur = 500; - if (!anim) - return 0; - - const UINT effect = anim->m_AnimationAtom.m_AnimEffect; - const UINT direct = anim->m_AnimationAtom.m_AnimEffectDirection; - - if (effect == 12 && ((direct >= 12 && direct <= 15) || direct == 27)) // Crawl In, Basic Swivel - dur = 5000; - else if (effect == 12 && direct == 28) - dur = 1000; - else if (effect == 14) - { - switch (direct) - { - case 0: dur = 75; break; - case 1: dur = 500; break; - case 2: dur = 1000; break; - } - } - - return dur; -} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h deleted file mode 100644 index ae9331eae8..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Animation.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - *(c) Copyright Ascensio System SIA 2010-2019 - * - *This program is a free software product. You can redistribute it and/or - *modify it under the terms of the GNU Affero General Public License (AGPL) - *version 3 as published by the Free Software Foundation. In accordance with - *Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - *that Ascensio System SIA expressly excludes the warranty of non-infringement - *of any third-party rights. - * - *This program is distributed WITHOUT ANY WARRANTY; without even the implied - *warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - *details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - *You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - *street, Riga, Latvia, EU, LV-1050. - * - *The interactive user interfaces in modified source and object code versions - *of the Program must display Appropriate Legal Notices, as required under - *Section 5 of the GNU AGPL version 3. - * - *Pursuant to Section 7(b) of the License you must retain the original Product - *logo when distributing the program. Pursuant to Section 7(e) we decline to - *grant you any rights under trademark law for use of our trademarks. - * - *All the Product's GUI elements, including illustrations and icon sets, as - *well as technical writing content are licensed under the terms of the - *Creative Commons Attribution-ShareAlike 4.0 International. See the License - *terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ -#pragma once - -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimClr.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimMotion.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimRot.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimScale.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimVariant.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Audio.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CBhvr.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/ChildTnLst.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cmd.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CondLst.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Set.h" -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Video.h" - -#include "../Records/SlideProgTagsContainer.h" -#include "ImageManager.h" -#include "../Records/Animations/AnimationInfoContainer.h" -#include - -namespace PPT_FORMAT -{ -struct SOldAnimation -{ - UINT shapeId; - CRecordAnimationInfoContainer* anim; - - // There will be additional records for animation here; - unsigned getAnimDur()const; -}; - -// struct for the params in class PPTX::Logic::Val -struct SValue -{ - enum - { - str, - dbl - }; - SValue(const std::wstring& str) : strVal(str), type(SValue::str) {} - SValue(const wchar_t* str) : strVal(str), type(SValue::str) {} - SValue(const double& dbl) : dblVal(dbl), type(SValue::dbl) {} - - std::wstring strVal; - double dblVal; - const int type; -}; - -// Extenstion for CRecordExtTimeNodeContainer -class Animation -{ -public: - Animation(CRecordPP10SlideBinaryTagExtension *pPPT10Ext, const std::vector &oldAnim, - CExMedia* pExMedia, CRelsGenerator* pRels, const std::unordered_set& realShapesId) : - m_pPPT10(pPPT10Ext), - m_arrOldAnim(oldAnim), - m_pExMedia(pExMedia), - m_pRels(pRels), - m_cTnId(1), - m_pBldLst(nullptr), - m_currentBldP(nullptr), - m_realShapesId(realShapesId) - { - - } - - - // Call it and only it to convert animation - void Convert(PPTX::Logic::Timing &oTiming); - -private: - void FillTnLst( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::TnLst &oTnLst); - void FillCTn( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::CTn &oCTn); - void FillStCondLst(const std::vector& timeCondCont, - PPTX::Logic::CondLst& stCondLst); - void FillTnChild( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::TimeNodeBase &oChild); - void FillAnim( - CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, - PPTX::Logic::Anim &oAnim); - void FillAnimClr( - CRecordTimeColorBehaviorContainer *pColor, - CRecordTimePropertyList4TimeNodeContainer *pProp, - PPTX::Logic::AnimClr &oAnimClr); - void FillAnimEffect( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimEffect &oAnim); - void FillAnimMotion( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimMotion &oAnim); - void FillAnimRot( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimRot &oAnim); - void FillAnimScale( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::AnimScale &oAnim); - void FillAudio(CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Audio &oAudio); - void FillAudio(CRecordClientVisualElementContainer *pCVEC, - PPTX::Logic::Audio &oAudio); - void FillCmd( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Cmd &oCmd); - void FillVideo( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Video &oVideo); - void FillPar( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Par &oPar); - void FillSeq( - PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Seq &oSec); - void FillCBhvr( - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::CBhvr &oBhvr); - void FillCBhvr( - CRecordTimeBehaviorContainer *pBhvr, - PPTX::Logic::CBhvr &oBhvr); - void FillCBhvr(PPTX::Logic::CBhvr &oBhvr, - int dur, UINT spid, std::wstring attrname, int delay); - void FillCond(PPT_FORMAT::CRecordTimeConditionContainer *oldCond, - PPTX::Logic::Cond &cond); - void FillBldLst( - PPT_FORMAT::CRecordBuildListContainer *pBLC, - PPTX::Logic::BldLst &oBL); - void FillBldP( - PPT_FORMAT::CRecordParaBuildContainer *pPBC, - PPTX::Logic::BldP &oBP); - void FillSet( - PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Set& oSet); - void FillSet( - PPT_FORMAT::CRecordTimeSetBehaviorContainer *pTSBC, - PPTX::Logic::Set& oSet); - void FillSubTnLst ( - std::vector &vecSEC, - PPTX::Logic::TnLst &oSubTnLst); - void FillCondLst( - std::vector& oCondVec, - PPTX::Logic::CondLst &oCondLst); - void FillEmptyTargetCond(PPTX::Logic::Cond &cond); - void FillCTn( - CRecordTimePropertyList4TimeNodeContainer *pProp, - PPTX::Logic::CTn &oCTn); -// void SubEffectToETNC( -// const CRecordSubEffectContainer *pSub, -// CRecordExtTimeNodeContainer *pETNC); - - // For old animation. - void InitTimingTags(PPTX::Logic::Timing &oTiming); // Initialize non-exist (in 95-97 format) struct - void FillOldAnim(SOldAnimation& oldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); - void SplitAnim(std::list >& arrClickPar); - - // erase first oldAnim and fill new timeNodeBase. After filling call next method with same list - void FillClickPar (std::list& clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); - void FillGroup (SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); - void FillAfterEffect(SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); - void FillClickEffect(SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); - void FillCBhvr (PPTX::Logic::CBhvr &oCBhvr, SOldAnimation* pOldAnim, int delay = 499); - - void FillCTnParams (PPTX::Logic::CTn &oCTN, std::wstring nodeType, std::wstring condDelay = L"0", - std::wstring fill = L"hold", SOldAnimation *pOldAnim = NULL); - void FillCTnAnimation (PPTX::Logic::CTn &oCTN, SOldAnimation *pOldAnim); - - void FillAnim (PPTX::Logic::Anim& oAnim, SOldAnimation* pOldAnim, int dur, std::wstring attrname, - SValue val1, SValue val2, std::wstring fmla = L""); - void FillAnimEffect (PPTX::Logic::AnimEffect& oAnimEffect, SOldAnimation* pOldAnim, std::wstring filter, std::wstring transition = L"in"); - - void FillCBhvrForAnim (PPTX::Logic::Anim& oAnim, SOldAnimation* pOldAnim, int dur, std::wstring attrname); - void FillSetAndAnim (SOldAnimation* pOldAnim, PPTX::Logic::ChildTnLst& oParent); - - // This methods fill ChildTnLst with anim nodes - void ConvertAppear(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim); - void ConvertFlyIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertBlinds(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertShape(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertCheckerboard(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim); - void ConvertCrawlIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertDissolveIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim); - void ConvertFade(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim); - void ConvertFlashOnce(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertPeekIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertRandomBars(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertSpiralIn(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim); - void ConvertSplit(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertStretch(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertStrips(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertBasicSwivel(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertWipe(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertBasicZoom(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim, int& presetSub); - void ConvertRandomEffect(PPTX::Logic::ChildTnLst& oParent, SOldAnimation* pOldAnim); - - void PushAnim(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int dur, - std::wstring attrname1, SValue val1, SValue val2, - std::wstring attrname2, SValue val3, SValue val4, - std::wstring fmla1 = L"", std::wstring fmla2 = L""); - void PushAnim(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, - std::wstring attrname1, SValue val1, SValue val2,std::wstring fmla1 = L""); - - void PushAnimEffect(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, std::wstring filter, std::wstring transition = L"in"); - void PushSet(PPTX::Logic::ChildTnLst& oParent, SOldAnimation *pOldAnim, int dur = 0); - - // To fix broken spids by using old animation struct - bool isSpidReal(const UINT spid); - -public: - // Not delete any pointers - CRecordPP10SlideBinaryTagExtension *m_pPPT10; // For new animation - std::vector m_arrOldAnim; // this one can dublicate new animation - -public: - inline void setNextRId(int nextRId) - { - m_nextRID = nextRId; - } - -private: - CExMedia *m_pExMedia; - CRelsGenerator *m_pRels; - unsigned m_cTnId; - int m_cTnDeep = 0; - PPTX::Logic::BldLst *m_pBldLst; // Do not delete - PPTX::Logic::BldP *m_currentBldP; - const std::unordered_set m_realShapesId; - - int m_nextRID; // it needs for audio maybe video for compisation id number; - bool m_isPPT10Broken = true; -}; - -} diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 93a9ca3651..b2e412dc68 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -47,7 +47,8 @@ #include "StylesWriter.h" #include "Converter.h" -#include "Animation.h" +#include "../Converter/timing.h" +#include "../Converter/Animation/animationparser.h" #include "../Converter/transition.h" #include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" @@ -1562,7 +1563,7 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) WriteTransition(oWriter, pSlide->m_oSlideShow); // TODO write new method and class for timing - WriteTiming(oWriter, oRels, realShapesId, nIndexSlide); + WriteTiming(oWriter, oRels, nIndexSlide); oWriter.WriteString(std::wstring(L"")); @@ -1858,42 +1859,13 @@ void CPPTXWriter::WriteLayoutAfterTheme(CThemePtr pTheme, const int nIndexTheme, } -void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, const std::unordered_set& realShapesId, int nIndexSlide) +void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide) { - PPTX::Logic::Timing oTiming; - auto slide_iter = m_pUserInfo->m_mapSlides.find(m_pUserInfo->m_arrSlidesOrder[nIndexSlide]); - // This part for new animation - CRecordSlideProgTagsContainer* progTag = slide_iter->second->m_pSlideProgTagsContainer; - CRecordPP10SlideBinaryTagExtension* pPP10SlideBinaryTag = progTag ? progTag->getPP10SlideBinaryTagExtension() : NULL; - // This part for old animation - std::vector arrShapeCont; - slide_iter->second->GetRecordsByType(&arrShapeCont, true); - std::vector arrOldAnim; - for (auto ShapeCont : arrShapeCont) - { - SOldAnimation oldAnim; - std::vector shape; - ShapeCont->GetRecordsByType(&shape, true); - std::vector anim; - ShapeCont->GetRecordsByType(&anim, true); - if (!anim.empty() && !shape.empty()) - { - oldAnim.shapeId = shape[0]->m_nID; - oldAnim.anim = anim[0]; - arrOldAnim.push_back(oldAnim); - } - } - - if (/*!pPP10SlideBinaryTag && */arrOldAnim.empty()) // todo check condition - return; - - Animation animation(pPP10SlideBinaryTag, arrOldAnim, &(m_pUserInfo->m_oExMedia), &oRels, realShapesId); - - animation.Convert(oTiming); - oWriter.WriteString(oTiming.toXML()); - //oWriter.WriteString(std::wstring(L"")); - + auto intermediateSlideAnimation = PPT::Intermediate::ParseSlideAnimation(slide_iter->second); + PPT::Converter::Timing animConverter(intermediateSlideAnimation, &(m_pUserInfo->m_oExMedia), &oRels); + auto timing = animConverter.Convert(); + oWriter.WriteString(timing.toXML()); } std::vector PPT_FORMAT::CPPTXWriter::GrepPaths(const std::vector &paths, const std::wstring &strRegEx) diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h index 6997e12cf3..c933d7328b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h @@ -89,7 +89,7 @@ namespace PPT_FORMAT // void WriteRelsMaster (std::wstring path, int type, ) void WriteSlide (int nIndexSlide); void WriteNotes (int nIndexNotes); - void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, const std::unordered_set &realShapesId, int nIndexSlide); + void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide); void WriteTransition (CStringWriter& oWriter, CSlideShowInfo& oSSInfo); void WriteColorScheme (CStringWriter& oWriter, const std::wstring & name, const std::vector & colors, bool extra = false); From e1168478cd5c2903a210566df359d671b61b7e30 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 2 Nov 2022 19:12:00 +0300 Subject: [PATCH 02/22] Animation reformation. Add header of old animation parser --- .../Converter/Animation/AnimationParser.cpp | 84 +++++++++++++++++++ .../{animationparser.h => AnimationParser.h} | 0 .../Animation/OldAnimationParser.cpp | 13 +++ .../Converter/Animation/OldAnimationParser.h | 19 +++++ .../Converter/Animation/TimeNode.h | 29 +++++++ .../Converter/Animation/animationparser.cpp | 47 ----------- .../Converter/Animation/intermediate_anim.cpp | 6 -- .../Converter/Animation/intermediate_anim.h | 16 +++- .../PPTFormatLib/Converter/timing.cpp | 1 - .../PPTFormatLib/Linux/PPTFormatLib.pro | 8 +- .../PPTFormatLib/PPTXWriter/Converter.cpp | 2 +- 11 files changed, 163 insertions(+), 62 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp rename ASCOfficePPTFile/PPTFormatLib/Converter/Animation/{animationparser.h => AnimationParser.h} (100%) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h delete mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp delete mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp new file mode 100644 index 0000000000..c59a80f931 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp @@ -0,0 +1,84 @@ +#include "AnimationParser.h" +#include "../../Records/Drawing/ShapeContainer.h" +#include "OldAnimationParser.h" + +namespace PPT { +namespace Intermediate { + +class AnimationParser +{ +public: + AnimationParser(CRecordSlide *pSlide) : + pSlide(pSlide) + { + InitListOfRawAnimIC(); + InitPP10SlideBinaryTagExtension(); + } + SlideAnimation Parse() + { + if(HasAnySlideAnimation() == false) + return {}; + + InitAnimationTree(); + return std::move(slideAnim); + } + +private: + void InitPP10SlideBinaryTagExtension() + { + CRecordSlideProgTagsContainer* progTag = pSlide->m_pSlideProgTagsContainer; + pAnimExt = progTag ? progTag->getPP10SlideBinaryTagExtension() : nullptr; + } + void InitListOfRawAnimIC() + { + std::vector arrShapeCont; + pSlide->GetRecordsByType(&arrShapeCont, true); + + for (auto* pShapeCont : arrShapeCont) + { + std::vector shape; + pShapeCont->GetRecordsByType(&shape, true); + std::vector anim; + pShapeCont->GetRecordsByType(&anim, true); + Animation animIC; + if (!anim.empty() && !shape.empty()) + { + animIC.shapeId = shape[0]->m_nID; + animIC.pAnimIC = anim[0]; + listOfOldAnim.push_back(animIC); + } + } + } + bool HasAnySlideAnimation() const + { + return listOfOldAnim.size() || pAnimExt; + } + void InitAnimationTree() + { + InitOldAnimationTree(); + if (pAnimExt == nullptr) + return; + // todo modern animation + } + void InitOldAnimationTree() + { + OldAnimationParser parser(slideAnim, listOfOldAnim); + // todo parser + parser.Parse(); + }; + +private: + CRecordSlide* pSlide; + SlideAnimation slideAnim; + std::list listOfOldAnim; + CRecordPP10SlideBinaryTagExtension* pAnimExt = nullptr; +}; + +SlideAnimation ParseSlideAnimation(CRecordSlide *pSlide) +{ + AnimationParser parser(pSlide); + auto slideAnim= parser.Parse(); + return slideAnim; +} +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.h similarity index 100% rename from ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.h rename to ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp new file mode 100644 index 0000000000..781efab4a9 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp @@ -0,0 +1,13 @@ +#include "OldAnimationParser.h" + + +PPT::Intermediate::OldAnimationParser::OldAnimationParser(SlideAnimation& slideAnim, std::list &rawOldAnimation) : + slideAnim(slideAnim), + lstAnimations(rawOldAnimation) +{} + +void PPT::Intermediate::OldAnimationParser::Parse() +{ + if (lstAnimations.empty()) + return; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h new file mode 100644 index 0000000000..1be5e42443 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h @@ -0,0 +1,19 @@ +#pragma once + +#include "TimeNode.h" +#include "intermediate_anim.h" + +namespace PPT { +namespace Intermediate { +class OldAnimationParser +{ +public: + OldAnimationParser(SlideAnimation& slideAnim, std::list& rawOldAnimation); + void Parse(); // todo change signature + +private: + SlideAnimation& slideAnim; + const std::list& lstAnimations; +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h new file mode 100644 index 0000000000..f028e3db32 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +namespace PPT { +namespace Intermediate { +class Animation; +struct TimeNode +{ + long cTnId = -1; + std::shared_ptr anim; + std::vector> childNodes; + +protected: + TimeNode(); +}; + +struct ParNode : TimeNode +{ + +}; + +struct SeqNode : TimeNode +{ + +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp deleted file mode 100644 index bdfd87ed8e..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/animationparser.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "animationparser.h" -#include "../../Records/Drawing/ShapeContainer.h" - -using namespace PPT::Intermediate; - -static CRecordPP10SlideBinaryTagExtension* getPP10SlideBinaryTagExtension(CRecordSlide *pSlide); -static std::list getListOfRawAnimIC(CRecordSlide *pSlide); - - -SlideAnimation ParseSlideAnimation(CRecordSlide *pSlide) -{ - SlideAnimation slideAnim; - auto listOfOldAnim = getListOfRawAnimIC(pSlide); - auto pAnimExt = getPP10SlideBinaryTagExtension(pSlide); - - return slideAnim; -} - -CRecordPP10SlideBinaryTagExtension* getPP10SlideBinaryTagExtension(CRecordSlide *pSlide) -{ - CRecordSlideProgTagsContainer* progTag = pSlide->m_pSlideProgTagsContainer; - return progTag ? progTag->getPP10SlideBinaryTagExtension() : nullptr; -} - -std::list getListOfRawAnimIC(CRecordSlide *pSlide) -{ - std::vector arrShapeCont; - pSlide->GetRecordsByType(&arrShapeCont, true); - - std::list listOfRawAnimIC; - for (auto* pShapeCont : arrShapeCont) - { - std::vector shape; - pShapeCont->GetRecordsByType(&shape, true); - std::vector anim; - pShapeCont->GetRecordsByType(&anim, true); - Animation animIC; - if (!anim.empty() && !shape.empty()) - { - animIC.shapeId = shape[0]->m_nID; - animIC.pAnimIC = anim[0]; - listOfRawAnimIC.push_back(animIC); - } - } - - return listOfRawAnimIC; -} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp deleted file mode 100644 index 643371eb27..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "intermediate_anim.h" - -aic_animation::aic_animation() -{ - -} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h index 4c8b9f2ba5..0b03368c21 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h @@ -6,6 +6,7 @@ #include "../PPTXWriter/ImageManager.h" #include "../Records/Animations/AnimationInfoContainer.h" #include +#include "TimeNode.h" namespace PPT { @@ -17,13 +18,20 @@ struct Animation CRecordExtTimeNodeContainer* pETNCIC = nullptr; // new animation records }; -// todo not correct (for example: triggers)!!! -using ParallelTimeNodes = std::list; -using SequenceTimeNodes = std::list; + +struct SimpleBuildNode +{ + _INT32 spid = -1; + bool grpId = false; + bool animBg = false; +}; +using SimpleBuildList = std::vector; + struct SlideAnimation { - SequenceTimeNodes sequences; + std::unique_ptr rootNode; + SimpleBuildList oldBuildList; CRecordBuildListContainer* pBLC = nullptr; std::unordered_set<_INT32> realShapesIds; }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index e1ab480f33..3e6ed42741 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -1,7 +1,6 @@ #include "timing.h" #include "Animation/intermediate_anim.h" -#include "Animation/ppt10ext_animation.h" using namespace PPT::Converter; diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 2a09385e87..7db1cb7b6c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -27,8 +27,10 @@ DEFINES += UNICODE \ #DISABLE_FILE_DOWNLOADER HEADERS += \ + ../Converter/Animation/AnimationParser.h \ + ../Converter/Animation/OldAnimationParser.h \ + ../Converter/Animation/TimeNode.h \ ../Converter/Animation/animation.h \ - ../Converter/Animation/animationparser.h \ ../Converter/Animation/intermediate_anim.h \ ../Converter/timing.h \ ../Converter/transition.h \ @@ -301,8 +303,8 @@ SOURCES += \ ../../../ASCOfficePPTXFile/Editor/Drawing/Elements.cpp \ ../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \ ../../../Common/3dParty/pole/pole.cpp \ - ../Converter/Animation/animationparser.cpp \ - ../Converter/Animation/intermediate_anim.cpp \ + ../Converter/Animation/AnimationParser.cpp \ + ../Converter/Animation/OldAnimationParser.cpp \ ../Converter/timing.cpp \ ../Converter/transition.cpp \ ../PPTXWriter/BulletsConverter.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index b2e412dc68..a69b510501 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -48,7 +48,7 @@ #include "Converter.h" #include "../Converter/timing.h" -#include "../Converter/Animation/animationparser.h" +#include "../Converter/Animation/AnimationParser.h" #include "../Converter/transition.h" #include "../../../ASCOfficeXlsFile2/source/Common/simple_xml_writer.h" From 80f2dce1b3dd73980d15f83850bb9c39ceefdc74 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 3 Nov 2022 18:40:06 +0300 Subject: [PATCH 03/22] Animation reformation. Add head logic to Converter::Animation_1995 --- .../Converter/Animation/AnimationParser.cpp | 91 +++------- .../Converter/Animation/Animation_1995.cpp | 164 ++++++++++++++++++ .../Converter/Animation/Animation_1995.h | 55 ++++++ .../Animation/OldAnimationParser.cpp | 13 -- .../Converter/Animation/OldAnimationParser.h | 19 -- .../Converter/Animation/TimeNode.h | 29 ---- .../Converter/Animation/intermediate_anim.h | 25 +-- .../PPTFormatLib/Converter/timing.cpp | 16 +- .../PPTFormatLib/Converter/timing.h | 11 +- .../PPTFormatLib/Linux/PPTFormatLib.pro | 5 +- .../PPTFormatLib/PPTXWriter/Converter.cpp | 5 +- 11 files changed, 273 insertions(+), 160 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h delete mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp delete mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h delete mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp index c59a80f931..b7566056a4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp @@ -1,83 +1,46 @@ #include "AnimationParser.h" #include "../../Records/Drawing/ShapeContainer.h" -#include "OldAnimationParser.h" +#include "Animation_1995.h" namespace PPT { namespace Intermediate { -class AnimationParser + +CRecordPP10SlideBinaryTagExtension* getPP10SlideBinaryTagExtension(CRecordSlide *pSlide) { -public: - AnimationParser(CRecordSlide *pSlide) : - pSlide(pSlide) - { - InitListOfRawAnimIC(); - InitPP10SlideBinaryTagExtension(); - } - SlideAnimation Parse() - { - if(HasAnySlideAnimation() == false) - return {}; + CRecordSlideProgTagsContainer* progTag = pSlide->m_pSlideProgTagsContainer; + return progTag ? progTag->getPP10SlideBinaryTagExtension() : nullptr; +} - InitAnimationTree(); - return std::move(slideAnim); - } +std::vector getOldSlideAnimation(CRecordSlide *pSlide) +{ + std::vector arrShapeCont; + pSlide->GetRecordsByType(&arrShapeCont, true); -private: - void InitPP10SlideBinaryTagExtension() + std::vector listOfRawAnimIC; + for (auto* pShapeCont : arrShapeCont) { - CRecordSlideProgTagsContainer* progTag = pSlide->m_pSlideProgTagsContainer; - pAnimExt = progTag ? progTag->getPP10SlideBinaryTagExtension() : nullptr; - } - void InitListOfRawAnimIC() - { - std::vector arrShapeCont; - pSlide->GetRecordsByType(&arrShapeCont, true); - - for (auto* pShapeCont : arrShapeCont) + std::vector shape; + pShapeCont->GetRecordsByType(&shape, true); + std::vector anim; + pShapeCont->GetRecordsByType(&anim, true); + SOldAnimation animIC; + if (!anim.empty() && !shape.empty()) { - std::vector shape; - pShapeCont->GetRecordsByType(&shape, true); - std::vector anim; - pShapeCont->GetRecordsByType(&anim, true); - Animation animIC; - if (!anim.empty() && !shape.empty()) - { - animIC.shapeId = shape[0]->m_nID; - animIC.pAnimIC = anim[0]; - listOfOldAnim.push_back(animIC); - } + animIC.shapeId = shape[0]->m_nID; + animIC.anim = anim[0]; + listOfRawAnimIC.push_back(animIC); } } - bool HasAnySlideAnimation() const - { - return listOfOldAnim.size() || pAnimExt; - } - void InitAnimationTree() - { - InitOldAnimationTree(); - if (pAnimExt == nullptr) - return; - // todo modern animation - } - void InitOldAnimationTree() - { - OldAnimationParser parser(slideAnim, listOfOldAnim); - // todo parser - parser.Parse(); - }; - -private: - CRecordSlide* pSlide; - SlideAnimation slideAnim; - std::list listOfOldAnim; - CRecordPP10SlideBinaryTagExtension* pAnimExt = nullptr; -}; + return listOfRawAnimIC; +} SlideAnimation ParseSlideAnimation(CRecordSlide *pSlide) { - AnimationParser parser(pSlide); - auto slideAnim= parser.Parse(); + SlideAnimation slideAnim; + slideAnim.arrAnim_1995 = getOldSlideAnimation(pSlide); + slideAnim.pAnim_2010 = getPP10SlideBinaryTagExtension(pSlide); + return slideAnim; } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp new file mode 100644 index 0000000000..39497b52bc --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp @@ -0,0 +1,164 @@ +#include "Animation_1995.h" +#include "../../Records/Animations/BuildListContainer.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h" +#include "../../Records/Animations/BuildListContainer.h" + + +namespace PPT { +namespace Converter { + +Animation_1995::Animation_1995(std::vector &vecAIC) : + arrOldAnim(vecAIC) +{} + +void Animation_1995::ConvertToTiming(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels) +{ + if (InitAndCheckVars(timimg, pExMedia, pRels) == false) + return; + ConvertBldLst(); + ConvertTnLst(); +} + +bool Animation_1995::InitAndCheckVars(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRelsGenerator *pRels) +{ + this->pExMedia = pExMedia; + this->pRels = pRels; + this->pTiming = &timimg; + + return pExMedia && pRels && pTiming && !arrOldAnim.empty(); +} + +void Animation_1995::ConvertBldLst() +{ + pTiming->bldLst = new PPTX::Logic::BldLst(); + for (auto oldAnim : arrOldAnim) + { + PPTX::Logic::BuildNodeBase oBuildNodeBase; + PPTX::Logic::BldP *pBldP = new PPTX::Logic::BldP(); + pBldP->spid = std::to_wstring(oldAnim.shapeId); + pBldP->grpId = false; + pBldP->animBg = (bool)(oldAnim.anim->m_AnimationAtom.m_fAnimateBg != 0); + + oBuildNodeBase.m_node = pBldP; + pTiming->bldLst->list.push_back(oBuildNodeBase); + } +} + +void Animation_1995::ConvertTnLst() +{ + pTiming->tnLst = new PPTX::Logic::TnLst(); + SplitRawAnim(); + auto mainSeq = ConvertMainSeqAnimation(); + InsertMainSeqToTnLst(mainSeq); +} + +PPTX::Logic::Seq *Animation_1995::ConvertMainSeqAnimation() +{ + auto seq2 = InitMainSeq(); + for (auto& clickPar : splitedAnim) + { + PPTX::Logic::TimeNodeBase child; + FillClickPar(clickPar, child); /// TODO next + seq2->cTn.childTnLst->list.push_back(child); + } + return seq2; +} + +void Animation_1995::InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq) +{ + PPTX::Logic::TimeNodeBase timeNodeBase; + timeNodeBase.m_node = mainSeq; + auto par1 = InitRootNode(); + par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + par1->cTn.childTnLst->list.push_back(timeNodeBase); + timeNodeBase.m_node = par1; + + pTiming->tnLst->list.push_back(timeNodeBase); +} + +PPTX::Logic::Par* Animation_1995::InitRootNode() +{ + auto par1 = new PPTX::Logic::Par; + par1->cTn.id = 1; + par1->cTn.dur = L"indefinite"; + par1->cTn.restart = L"never"; + par1->cTn.nodeType = L"tmRoot"; + + return par1; +} + +PPTX::Logic::Seq *Animation_1995::InitMainSeq() +{ + auto seq2 = new PPTX::Logic::Seq; + seq2->cTn.id = 2; + seq2->cTn.dur = L"indefinite"; + seq2->cTn.nodeType = L"mainSeq"; + seq2->concurrent = L"1"; + seq2->nextAc = L"seek"; + seq2->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + + PPTX::Logic::Cond cond; + cond.tgtEl = new PPTX::Logic::TgtEl; + if (arrOldAnim.front().anim->m_AnimationAtom.m_fAutomatic) + cond.delay = L"0"; + + seq2->nextCondLst = new PPTX::Logic::CondLst; + seq2->nextCondLst->node_name = L"nextCondLst"; + cond.evt = L"onNext"; + cond.delay = L"0"; + seq2->nextCondLst->list.push_back(cond); + + seq2->prevCondLst = new PPTX::Logic::CondLst; + seq2->prevCondLst->node_name = L"prevCondLst"; + cond.evt = L"onPrev"; + cond.delay = L"0"; + seq2->prevCondLst->list.push_back(cond); + + return seq2; +} + +void Animation_1995::SplitRawAnim() +{ + splitedAnim.clear(); + SortAnim(); + + for (auto& oldAnim : arrOldAnim) + { + if (splitedAnim.empty()) + { + std::list clickPar; + clickPar.push_back(oldAnim); + splitedAnim.push_back(clickPar); + } else if (oldAnim.anim->m_AnimationAtom.m_fAutomatic) + { + splitedAnim.back().push_back(oldAnim); + } else + { + std::list clickPar; + clickPar.push_back(oldAnim); + splitedAnim.push_back(clickPar); + } + } +} + +void Animation_1995::SortAnim() +{ + std::sort(arrOldAnim.begin(), arrOldAnim.end(), + [] + ( + const Intermediate::SOldAnimation& a1, + const Intermediate::SOldAnimation& a2 + ) + { + return + a1.anim->m_AnimationAtom.m_OrderID + < + a2.anim->m_AnimationAtom.m_OrderID; + } + ); +} + +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h new file mode 100644 index 0000000000..da651a2ead --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h @@ -0,0 +1,55 @@ +#pragma once + +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimClr.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimMotion.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimRot.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimScale.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimVariant.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Audio.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CBhvr.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/ChildTnLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cmd.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CondLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Set.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Video.h" +#include "../../Records/Animations/AnimationInfoContainer.h" +#include "intermediate_anim.h" + + +namespace PPT { +namespace Converter { +class Animation_1995 +{ +public: + Animation_1995(std::vector& vecAIC); + void ConvertToTiming(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + +private: + bool InitAndCheckVars(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + void ConvertBldLst(); + void ConvertTnLst(); + PPTX::Logic::Seq *ConvertMainSeqAnimation(); + void InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq); + PPTX::Logic::Par *InitRootNode(); + PPTX::Logic::Seq *InitMainSeq(); + void SplitRawAnim(); + void SortAnim(); + void FillClickPar(std::list& clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + +private: + std::vector& arrOldAnim; + std::list > splitedAnim; + + PPTX::Logic::Timing* pTiming = nullptr; + CExMedia* pExMedia; + CRelsGenerator* pRels; + _INT32 cTnId = 3; +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp deleted file mode 100644 index 781efab4a9..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "OldAnimationParser.h" - - -PPT::Intermediate::OldAnimationParser::OldAnimationParser(SlideAnimation& slideAnim, std::list &rawOldAnimation) : - slideAnim(slideAnim), - lstAnimations(rawOldAnimation) -{} - -void PPT::Intermediate::OldAnimationParser::Parse() -{ - if (lstAnimations.empty()) - return; -} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h deleted file mode 100644 index 1be5e42443..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/OldAnimationParser.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "TimeNode.h" -#include "intermediate_anim.h" - -namespace PPT { -namespace Intermediate { -class OldAnimationParser -{ -public: - OldAnimationParser(SlideAnimation& slideAnim, std::list& rawOldAnimation); - void Parse(); // todo change signature - -private: - SlideAnimation& slideAnim; - const std::list& lstAnimations; -}; -} -} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h deleted file mode 100644 index f028e3db32..0000000000 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimeNode.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include - -namespace PPT { -namespace Intermediate { -class Animation; -struct TimeNode -{ - long cTnId = -1; - std::shared_ptr anim; - std::vector> childNodes; - -protected: - TimeNode(); -}; - -struct ParNode : TimeNode -{ - -}; - -struct SeqNode : TimeNode -{ - -}; -} -} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h index 0b03368c21..ae6b900f13 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h @@ -6,33 +6,22 @@ #include "../PPTXWriter/ImageManager.h" #include "../Records/Animations/AnimationInfoContainer.h" #include -#include "TimeNode.h" namespace PPT { namespace Intermediate { -struct Animation +struct SOldAnimation { - _INT32 shapeId = -1; - CRecordAnimationInfoContainer* pAnimIC = nullptr; // old animation records - CRecordExtTimeNodeContainer* pETNCIC = nullptr; // new animation records + _INT32 shapeId; + CRecordAnimationInfoContainer* anim; + + _UINT32 getAnimDur() const; }; - -struct SimpleBuildNode -{ - _INT32 spid = -1; - bool grpId = false; - bool animBg = false; -}; -using SimpleBuildList = std::vector; - - struct SlideAnimation { - std::unique_ptr rootNode; - SimpleBuildList oldBuildList; - CRecordBuildListContainer* pBLC = nullptr; + CRecordPP10SlideBinaryTagExtension* pAnim_2010 = nullptr; + std::vector arrAnim_1995; std::unordered_set<_INT32> realShapesIds; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index 3e6ed42741..8032f9ad51 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -1,17 +1,21 @@ #include "timing.h" #include "Animation/intermediate_anim.h" +#include "Animation/Animation_1995.h" using namespace PPT::Converter; -Timing::Timing(const PPT::Intermediate::SlideAnimation& slideAnim, const CExMedia* pExMedia, const CRelsGenerator* pRels) : - slideAnim(slideAnim), pExMedia(pExMedia), pRels(pRels) -{ +Timing::Timing(const Intermediate::SlideAnimation& slideAnim) : + slideAnim(slideAnim) +{} -} - -PPTX::Logic::Timing Timing::Convert() +PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) { +// this->pExMedia = pExMedia; +// this->pRels = pRels; + + Animation_1995(slideAnim.arrAnim_1995). + ConvertToTiming(timing, pExMedia, pRels); return std::move(timing); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h index b489b352b6..345e770f8f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h @@ -10,17 +10,16 @@ namespace Converter { class Timing { public: - Timing(const PPT::Intermediate::SlideAnimation& slideAnim, const CExMedia* pExMedia, const CRelsGenerator* pRels); - PPTX::Logic::Timing Convert(); + Timing(const Intermediate::SlideAnimation& slideAnim); + PPTX::Logic::Timing Convert(CExMedia* pExMedia, CRelsGenerator *pRels); bool HasAnimation() const; private: - const PPT::Intermediate::SlideAnimation& slideAnim; - const CExMedia* pExMedia; - const CRelsGenerator* pRels; + const Intermediate::SlideAnimation& slideAnim; +// CExMedia* pExMedia; +// CRelsGenerator* pRels; - bool isPPT10Broken = true; PPTX::Logic::Timing timing; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 7db1cb7b6c..fccc525588 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -28,8 +28,7 @@ DEFINES += UNICODE \ HEADERS += \ ../Converter/Animation/AnimationParser.h \ - ../Converter/Animation/OldAnimationParser.h \ - ../Converter/Animation/TimeNode.h \ + ../Converter/Animation/Animation_1995.h \ ../Converter/Animation/animation.h \ ../Converter/Animation/intermediate_anim.h \ ../Converter/timing.h \ @@ -304,7 +303,7 @@ SOURCES += \ ../../../ASCOfficePPTXFile/Editor/Drawing/TextAttributesEx.cpp \ ../../../Common/3dParty/pole/pole.cpp \ ../Converter/Animation/AnimationParser.cpp \ - ../Converter/Animation/OldAnimationParser.cpp \ + ../Converter/Animation/Animation_1995.cpp \ ../Converter/timing.cpp \ ../Converter/transition.cpp \ ../PPTXWriter/BulletsConverter.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index a69b510501..062b2f0ea7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -1863,8 +1863,9 @@ void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator { auto slide_iter = m_pUserInfo->m_mapSlides.find(m_pUserInfo->m_arrSlidesOrder[nIndexSlide]); auto intermediateSlideAnimation = PPT::Intermediate::ParseSlideAnimation(slide_iter->second); - PPT::Converter::Timing animConverter(intermediateSlideAnimation, &(m_pUserInfo->m_oExMedia), &oRels); - auto timing = animConverter.Convert(); + auto timing = + PPT::Converter::Timing(intermediateSlideAnimation). + Convert(&(m_pUserInfo->m_oExMedia), &oRels); oWriter.WriteString(timing.toXML()); } From acb46e412db4322f29e29ebcaad04f8ac71782d9 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 7 Nov 2022 22:07:08 +0300 Subject: [PATCH 04/22] Add reformated converter Timiming_1995 with Animation_1995 --- .../Converter/Animation/AnimationParser.cpp | 2 +- .../Converter/Animation/Animation_1995.cpp | 977 +++++++++++++++--- .../Converter/Animation/Animation_1995.h | 82 +- .../Converter/Animation/Timing_1995.cpp | 270 +++++ .../Converter/Animation/Timing_1995.h | 49 + .../Converter/Animation/intermediate_anim.h | 19 +- .../PPTFormatLib/Converter/timing.cpp | 6 +- .../PPTFormatLib/Linux/PPTFormatLib.pro | 4 +- 8 files changed, 1223 insertions(+), 186 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp index b7566056a4..0d53022351 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/AnimationParser.cpp @@ -1,6 +1,6 @@ #include "AnimationParser.h" #include "../../Records/Drawing/ShapeContainer.h" -#include "Animation_1995.h" +#include "Timing_1995.h" namespace PPT { namespace Intermediate { diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp index 39497b52bc..1b3783b721 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp @@ -1,164 +1,863 @@ #include "Animation_1995.h" -#include "../../Records/Animations/BuildListContainer.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldLst.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h" -#include "../../Records/Animations/BuildListContainer.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimClr.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimMotion.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimRot.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimScale.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimVariant.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Audio.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CBhvr.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/ChildTnLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cmd.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CondLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Set.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Video.h" +#include "../../Records/Animations/AnimationInfoContainer.h" +using namespace PPT::Converter; -namespace PPT { -namespace Converter { - -Animation_1995::Animation_1995(std::vector &vecAIC) : - arrOldAnim(vecAIC) +Animation_1995::Animation_1995(_INT32 &cTnId) : + cTnId(cTnId) {} -void Animation_1995::ConvertToTiming(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels) +void Animation_1995::FillCTnAnimation(PPTX::Logic::CTn &oCTN, Intermediate::SOldAnimation *pOldAnim) { - if (InitAndCheckVars(timimg, pExMedia, pRels) == false) - return; - ConvertBldLst(); - ConvertTnLst(); -} + oCTN.presetClass = L"entr"; + oCTN.grpId = 0; + oCTN.childTnLst = new PPTX::Logic::ChildTnLst; + oCTN.presetSubtype = 0; + int presetSub = -1; -bool Animation_1995::InitAndCheckVars(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRelsGenerator *pRels) -{ - this->pExMedia = pExMedia; - this->pRels = pRels; - this->pTiming = &timimg; + const UINT effect = pOldAnim->anim->m_AnimationAtom.m_AnimEffect; + const UINT direct = pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection; - return pExMedia && pRels && pTiming && !arrOldAnim.empty(); -} - -void Animation_1995::ConvertBldLst() -{ - pTiming->bldLst = new PPTX::Logic::BldLst(); - for (auto oldAnim : arrOldAnim) + // Todo 4, 7. 0x11 - 0x1B + switch (effect) { - PPTX::Logic::BuildNodeBase oBuildNodeBase; - PPTX::Logic::BldP *pBldP = new PPTX::Logic::BldP(); - pBldP->spid = std::to_wstring(oldAnim.shapeId); - pBldP->grpId = false; - pBldP->animBg = (bool)(oldAnim.anim->m_AnimationAtom.m_fAnimateBg != 0); - - oBuildNodeBase.m_node = pBldP; - pTiming->bldLst->list.push_back(oBuildNodeBase); + case 0x00: + { + oCTN.presetID = 1; + ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); + break; } -} - -void Animation_1995::ConvertTnLst() -{ - pTiming->tnLst = new PPTX::Logic::TnLst(); - SplitRawAnim(); - auto mainSeq = ConvertMainSeqAnimation(); - InsertMainSeqToTnLst(mainSeq); -} - -PPTX::Logic::Seq *Animation_1995::ConvertMainSeqAnimation() -{ - auto seq2 = InitMainSeq(); - for (auto& clickPar : splitedAnim) + case 0x01: { - PPTX::Logic::TimeNodeBase child; - FillClickPar(clickPar, child); /// TODO next - seq2->cTn.childTnLst->list.push_back(child); + oCTN.presetID = 24; + ConvertRandomEffect(oCTN.childTnLst.get2(), pOldAnim); + break; } - return seq2; -} - -void Animation_1995::InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq) -{ - PPTX::Logic::TimeNodeBase timeNodeBase; - timeNodeBase.m_node = mainSeq; - auto par1 = InitRootNode(); - par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - par1->cTn.childTnLst->list.push_back(timeNodeBase); - timeNodeBase.m_node = par1; - - pTiming->tnLst->list.push_back(timeNodeBase); -} - -PPTX::Logic::Par* Animation_1995::InitRootNode() -{ - auto par1 = new PPTX::Logic::Par; - par1->cTn.id = 1; - par1->cTn.dur = L"indefinite"; - par1->cTn.restart = L"never"; - par1->cTn.nodeType = L"tmRoot"; - - return par1; -} - -PPTX::Logic::Seq *Animation_1995::InitMainSeq() -{ - auto seq2 = new PPTX::Logic::Seq; - seq2->cTn.id = 2; - seq2->cTn.dur = L"indefinite"; - seq2->cTn.nodeType = L"mainSeq"; - seq2->concurrent = L"1"; - seq2->nextAc = L"seek"; - seq2->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - - PPTX::Logic::Cond cond; - cond.tgtEl = new PPTX::Logic::TgtEl; - if (arrOldAnim.front().anim->m_AnimationAtom.m_fAutomatic) - cond.delay = L"0"; - - seq2->nextCondLst = new PPTX::Logic::CondLst; - seq2->nextCondLst->node_name = L"nextCondLst"; - cond.evt = L"onNext"; - cond.delay = L"0"; - seq2->nextCondLst->list.push_back(cond); - - seq2->prevCondLst = new PPTX::Logic::CondLst; - seq2->prevCondLst->node_name = L"prevCondLst"; - cond.evt = L"onPrev"; - cond.delay = L"0"; - seq2->prevCondLst->list.push_back(cond); - - return seq2; -} - -void Animation_1995::SplitRawAnim() -{ - splitedAnim.clear(); - SortAnim(); - - for (auto& oldAnim : arrOldAnim) + case 0x02: { - if (splitedAnim.empty()) + oCTN.presetID = 3; + ConvertBlinds(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + case 0x03: + { + oCTN.presetID = 5; + ConvertCheckerboard(oCTN.childTnLst.get2(), pOldAnim); + break; + } + case 0x05: + { + oCTN.presetID = 9; + ConvertDissolveIn(oCTN.childTnLst.get2(), pOldAnim); + break; + } + case 0x06: + { + oCTN.presetID = 10; + ConvertFade(oCTN.childTnLst.get2(), pOldAnim); + break; + } + case 0x08: + { + oCTN.presetID = 14; + ConvertRandomBars(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + case 0x09: + { + oCTN.presetID = 18; + ConvertStrips(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + case 0x0A: + { + oCTN.presetID = 22; + ConvertWipe(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + case 0x0B: + { + oCTN.presetID = 4; + ConvertShape(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + case 0x0C: + { + if (direct >= 0 && direct <= 7) { - std::list clickPar; - clickPar.push_back(oldAnim); - splitedAnim.push_back(clickPar); - } else if (oldAnim.anim->m_AnimationAtom.m_fAutomatic) + oCTN.presetID = 2; + ConvertFlyIn(oCTN.childTnLst.get2(), pOldAnim, presetSub); + } else if (direct >= 8 && direct <= 11) { - splitedAnim.back().push_back(oldAnim); - } else + oCTN.presetID = 12; + ConvertPeekIn(oCTN.childTnLst.get2(), pOldAnim, presetSub); + } else if (direct >= 12 && direct <= 15) { - std::list clickPar; - clickPar.push_back(oldAnim); - splitedAnim.push_back(clickPar); + oCTN.presetID = 7; + ConvertCrawlIn(oCTN.childTnLst.get2(), pOldAnim, presetSub); + } else if (direct >= 16 && direct <= 21) + { + oCTN.presetID = 23; + ConvertBasicZoom(oCTN.childTnLst.get2(), pOldAnim, presetSub); + } else if (direct >= 22 && direct <= 26) + { + oCTN.presetID = 17; + ConvertStretch(oCTN.childTnLst.get2(), pOldAnim, presetSub); + } else if (direct == 27) + { + oCTN.presetID = 19; + ConvertBasicSwivel(oCTN.childTnLst.get2(), pOldAnim, presetSub); + } else if (direct == 28) + { + oCTN.presetID = 15; + ConvertSpiralIn(oCTN.childTnLst.get2(), pOldAnim); } + break; } -} - -void Animation_1995::SortAnim() -{ - std::sort(arrOldAnim.begin(), arrOldAnim.end(), - [] - ( - const Intermediate::SOldAnimation& a1, - const Intermediate::SOldAnimation& a2 - ) + case 0x0D: { - return - a1.anim->m_AnimationAtom.m_OrderID - < - a2.anim->m_AnimationAtom.m_OrderID; + oCTN.presetID = 16; + ConvertSplit(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + case 0x0E: + { + oCTN.presetID = 11; + ConvertFlashOnce(oCTN.childTnLst.get2(), pOldAnim, presetSub); + break; + } + default: + oCTN.presetID = 1; + ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); + std::wcout << "Error: Unknown old animation id: " << std::to_wstring(effect) << L"\n"; + + } + + if (presetSub != -1) + { + oCTN.presetSubtype = presetSub; } - ); } + + +void Animation_1995::FillCBhvrForAnim (PPTX::Logic::Anim& oAnim, Intermediate::SOldAnimation* pOldAnim, int dur, std::wstring attrname) +{ + FillCBhvr(oAnim.cBhvr, dur, pOldAnim->shapeId, attrname, -1); + + oAnim.cBhvr.additive = new PPTX::Limit::TLAdditive; + oAnim.cBhvr.additive->set(L"base"); + + oAnim.calcmode = new PPTX::Limit::TLCalcMode; + oAnim.calcmode->set(L"lin"); + oAnim.valueType = new PPTX::Limit::TLValueType; + oAnim.valueType->set(L"num"); } + +void Animation_1995::FillCBhvr(PPTX::Logic::CBhvr &oBhvr, int dur, UINT spid, std::wstring attrname, int delay) +{ + oBhvr.cTn.id = cTnId++; + oBhvr.cTn.fill = L"hold"; + oBhvr.cTn.dur = std::to_wstring(dur); + if (delay > -1) + { + oBhvr.cTn.stCondLst = new PPTX::Logic::CondLst; + oBhvr.cTn.stCondLst->node_name = L"stCondLst"; + PPTX::Logic::Cond cond; + cond.delay = std::to_wstring(delay); + oBhvr.cTn.stCondLst->list.push_back(cond); + } + + oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt; + oBhvr.tgtEl.spTgt->spid = std::to_wstring(spid); + + if (!attrname.empty()) + { + oBhvr.attrNameLst = new PPTX::Logic::AttrNameLst; + PPTX::Logic::AttrName attrName; + attrName.text = attrname; + oBhvr.attrNameLst->list.push_back(attrName); + } +} + +void Animation_1995::FillCBhvr(PPTX::Logic::CBhvr &oCBhvr, Intermediate::SOldAnimation *pOldAnim, int delay) +{ + FillCBhvr(oCBhvr, 1, pOldAnim->shapeId, L"style.visibility", delay); +} + +void Animation_1995::FillAnim (PPTX::Logic::Anim& oAnim, Intermediate::SOldAnimation* pOldAnim, int dur, std::wstring attrname, + Intermediate::SValue val1, Intermediate::SValue val2, std::wstring fmla) +{ + FillCBhvrForAnim(oAnim, pOldAnim, dur, attrname); + + oAnim.tavLst = new PPTX::Logic::TavLst; + PPTX::Logic::Tav tav; + + tav.tm = L"0"; + if (fmla.size()) + { + tav.fmla = fmla; + } + auto val = new PPTX::Logic::AnimVariant; + val->node_name = L"val"; + if (val1.type == Intermediate::SValue::str) + val->strVal = val1.strVal; + else if (val1.type == Intermediate::SValue::dbl) + val->fltVal = val1.dblVal; + + tav.val = val; + oAnim.tavLst->list.push_back(tav); + tav.fmla.reset(); + + tav.tm = L"100000"; + val = new PPTX::Logic::AnimVariant; + val->node_name = L"val"; + if (val2.type == Intermediate::SValue::str) + val->strVal = val2.strVal; + else if (val2.type == Intermediate::SValue::dbl) + val->fltVal = val2.dblVal; + + tav.val = val; + oAnim.tavLst->list.push_back(tav); + +} + +void Animation_1995::FillAnimEffect (PPTX::Logic::AnimEffect& oAnimEffect, Intermediate::SOldAnimation* pOldAnim, std::wstring filter, std::wstring transition) +{ + oAnimEffect.transition = new PPTX::Limit::TLTransition(); + oAnimEffect.transition->set(transition); + oAnimEffect.filter = filter; + + oAnimEffect.cBhvr.cTn.id = cTnId++; + oAnimEffect.cBhvr.cTn.dur = std::to_wstring(pOldAnim->getAnimDur()); + oAnimEffect.cBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt; + oAnimEffect.cBhvr.tgtEl.spTgt->spid = std::to_wstring(pOldAnim->shapeId); +} + +// This methods fill ChildTnLst with anim nodes +void Animation_1995::ConvertAppear(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim) +{ + PushSet(oParent, pOldAnim, 499); +} + +void Animation_1995::ConvertFlyIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 0: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + + presetSub = 8; + break; + } + case 1: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"#ppt_x", L"#ppt_x", + L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); + + presetSub = 1; + break; + } + case 2: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + + presetSub = 2; + break; + } + case 3: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"#ppt_x", L"#ppt_x", + L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); + + presetSub = 4; + break; + } + case 4: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", + L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); + + presetSub = 9; + break; + } + case 5: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", + L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); + + presetSub = 3; + break; + } + case 6: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", + L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); + + presetSub = 12; + break; + } + case 7: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", + L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); + + presetSub = 6; + break; + } + } +} + +void Animation_1995::ConvertBlinds(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int &presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 0: + { + PushAnimEffect(oParent, pOldAnim, L"blinds(vertical)", L"in"); + + presetSub = 5; + break; + } + case 1: + { + PushAnimEffect(oParent, pOldAnim, L"blinds(horizontal)", L"in"); + + presetSub = 10; + break; + } + } +} + +void Animation_1995::ConvertShape(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 0: + { + PushAnimEffect(oParent, pOldAnim, L"box(out)", L"in"); + + presetSub = 32; + break; + } + case 1: + { + PushAnimEffect(oParent, pOldAnim, L"box(in)", L"in"); + + presetSub = 16; + break; + } + } +} + +void Animation_1995::ConvertCheckerboard(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim) +{ + PushSet(oParent, pOldAnim); + PushAnimEffect(oParent, pOldAnim, L"checkerboard(across)", L"in"); +} + +void Animation_1995::ConvertCrawlIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 15: + { + PushAnim(oParent, pOldAnim, 5000, + L"ppt_x", L"#ppt_x", L"#ppt_x", + L"ppt_y", L"1+#ppt_h/2", L"#ppt_y"); + + presetSub = 4; + break; + } + case 12: + { + PushAnim(oParent, pOldAnim, 5000, + L"ppt_x", L"0-#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + + presetSub = 8; + break; + } + case 14: + { + PushAnim(oParent, pOldAnim, 5000, + L"ppt_x", L"1+#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + + presetSub = 2; + break; + } + case 13: + { + PushAnim(oParent, pOldAnim, 5000, + L"ppt_x", L"#ppt_x", L"#ppt_x", + L"ppt_y", L"0-#ppt_h/2", L"#ppt_y"); + + presetSub = 1; + break; + } + } +} + +void Animation_1995::ConvertDissolveIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim) +{ + PushSet(oParent, pOldAnim); + PushAnimEffect(oParent, pOldAnim, L"dissolve", L"in"); +} + +void Animation_1995::ConvertFade(PPTX::Logic::ChildTnLst &oParent, Intermediate::SOldAnimation *pOldAnim) +{ + PushSet(oParent, pOldAnim); + PushAnimEffect(oParent, pOldAnim, L"fade", L"in"); +} + +void Animation_1995::ConvertFlashOnce(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + presetSub = 0; + + // correct cTn params + auto set = dynamic_cast(oParent.list.front().m_node.GetPointer()); + if (!set) return; + set->cBhvr.cTn.dur = std::to_wstring(pOldAnim->getAnimDur()); + set->cBhvr.cTn.fill.reset(); +} + +void Animation_1995::ConvertPeekIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 8: + { + PushAnim(oParent, pOldAnim, L"ppt_x", L"#ppt_x-#ppt_w*1.125000", L"#ppt_x"); + PushAnimEffect(oParent, pOldAnim, L"wipe(right)", L"in"); + + presetSub = 8; + break; + } + case 9: + { + PushAnim(oParent, pOldAnim, L"ppt_y", L"#ppt_y+#ppt_h*1.125000", L"#ppt_y"); + PushAnimEffect(oParent, pOldAnim, L"wipe(up)", L"in"); + + presetSub = 4; + break; + } + case 10: + { + PushAnim(oParent, pOldAnim, L"ppt_x", L"#ppt_x+#ppt_w*1.125000", L"#ppt_x"); + PushAnimEffect(oParent, pOldAnim, L"wipe(left)", L"in"); + + presetSub = 2; + break; + } + case 11: + { + PushAnim(oParent, pOldAnim, L"ppt_y", L"#ppt_y-#ppt_h*1.125000", L"#ppt_y"); + PushAnimEffect(oParent, pOldAnim, L"wipe(down)", L"in"); + + presetSub = 1; + break; + } + } +} + +void Animation_1995::ConvertRandomBars(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 0: + { + PushAnimEffect(oParent, pOldAnim, L"randombar(horizontal)", L"in"); + + presetSub = 10; + break; + } + case 1: + { + PushAnimEffect(oParent, pOldAnim, L"randombar(vertical)", L"in"); + + presetSub = 5; + break; + } + } +} + +void Animation_1995::ConvertSpiralIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim) +{ + PushSet(oParent, pOldAnim); + // TODO + PushAnim(oParent, pOldAnim, 1000, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", double(0), L"#ppt_h"); + PushAnim(oParent, pOldAnim, 1000, + L"ppt_x", double(0), double(1), + L"ppt_y", double(0), double(1), + L"#ppt_x+(cos(-2*pi*(1-$))*-#ppt_x-sin(-2*pi*(1-$))*(1-#ppt_y))*(1-$)", + L"#ppt_y+(sin(-2*pi*(1-$))*-#ppt_x+cos(-2*pi*(1-$))*(1-#ppt_y))*(1-$)"); + + // remove additive from + for (auto& child : oParent.list) + { + auto anim = dynamic_cast(child.m_node.GetPointer()); + if (!anim) continue; + anim->cBhvr.additive.reset(); + } + +} + +void Animation_1995::ConvertSplit(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 0: + { + PushAnimEffect(oParent, pOldAnim, L"barn(outHorizontal)", L"in"); + + presetSub = 42; + break; + } + case 1: + { + PushAnimEffect(oParent, pOldAnim, L"barn(inHorizontal)", L"in"); + + presetSub = 26; + break; + } + case 2: + { + PushAnimEffect(oParent, pOldAnim, L"barn(outVertical)", L"in"); + + presetSub = 37; + break; + } + case 3: + { + PushAnimEffect(oParent, pOldAnim, L"barn(inVertical)", L"in"); + + presetSub = 21; + break; + } + } +} + +void Animation_1995::ConvertStretch(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 22: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", L"#ppt_h", L"#ppt_h"); + + presetSub = 10; + break; + } + case 26: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"#ppt_x", L"#ppt_x", + L"ppt_y", L"#ppt_y+#ppt_h/2", L"#ppt_y"); + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", L"#ppt_w", L"#ppt_w", + L"ppt_h", double(0), L"#ppt_h"); + + presetSub = 4; + break; + } + case 23: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"##ppt_x-#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", L"#ppt_h", L"#ppt_h"); + + presetSub = 8; + break; + } + case 25: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"#ppt_x-#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", L"#ppt_h", L"#ppt_h"); + + presetSub = 2; + break; + } + case 24: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", L"#ppt_x+#ppt_w/2", L"#ppt_x", + L"ppt_y", L"#ppt_y", L"#ppt_y"); + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", L"#ppt_h", L"#ppt_h"); + + presetSub = 1; + break; + } + } +} + +void Animation_1995::ConvertStrips(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 6: + { + PushAnimEffect(oParent, pOldAnim, L"strips(downLeft)", L"in"); + + presetSub = 12; + break; + } + case 4: + { + PushAnimEffect(oParent, pOldAnim, L"strips(upLeft)", L"in"); + + presetSub = 9; + break; + } + case 7: + { + PushAnimEffect(oParent, pOldAnim, L"strips(downRight)", L"in"); + + presetSub = 6; + break; + } + case 5: + { + PushAnimEffect(oParent, pOldAnim, L"strips(upRight)", L"in"); + + presetSub = 3; + break; + } + } +} + +void Animation_1995::ConvertBasicSwivel(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + presetSub = 10; + + PushAnim(oParent, pOldAnim, 5000, + L"ppt_w", double(0), double(1), + L"ppt_h", L"#ppt_h", L"#ppt_h", + L"#ppt_w*sin(2.5*pi*$)"); +} + +void Animation_1995::ConvertWipe(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 3: + { + PushAnimEffect(oParent, pOldAnim, L"wipe(up)", L"in"); + + presetSub = 1; + break; + } + case 0: + { + PushAnimEffect(oParent, pOldAnim, L"wipe(left)", L"in"); + + presetSub = 2; + break; + } + case 2: + { + PushAnimEffect(oParent, pOldAnim, L"wipe(right)", L"in"); + + presetSub = 8; + break; + } + case 1: + { + PushAnimEffect(oParent, pOldAnim, L"wipe(down)", L"in"); + + presetSub = 4; + break; + } + } +} + +void Animation_1995::ConvertBasicZoom(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub) +{ + PushSet(oParent, pOldAnim); + + switch (pOldAnim->anim->m_AnimationAtom.m_AnimEffectDirection) + { + case 16: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", double(0), L"#ppt_h"); + + presetSub = 16; + break; + } + case 20: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", double(0), L"#ppt_w", + L"ppt_h", double(0), L"#ppt_h"); + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", double(0.5), L"#ppt_x", + L"ppt_y", double(0.5), L"#ppt_y"); + + presetSub = 528; + break; + } + case 17: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", L"2/3*#ppt_w", L"#ppt_w", + L"ppt_h", L"2/3*#ppt_h", L"#ppt_h"); + + presetSub = 272; + break; + } + case 18: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", L"#ppt_w", L"#ppt_w", + L"ppt_h", L"4*#ppt_h", L"#ppt_h"); + + presetSub = 32; + break; + } + case 21: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", L"(6*min(max(#ppt_w*#ppt_h,.3),1)-7.4)/-.7*#ppt_w", L"#ppt_w", + L"ppt_h", L"(6*min(max(#ppt_w*#ppt_h,.3),1)-7.4)/-.7*#ppt_h", L"#ppt_h"); + PushAnim(oParent, pOldAnim, 500, + L"ppt_x", double(0.5), L"#ppt_x", + L"ppt_y", L"1+(6*min(max(#ppt_w*#ppt_h,.3),1)-7.4)/-.7*#ppt_h/2", L"#ppt_y"); + + presetSub = 36; + break; + } + case 19: + { + PushAnim(oParent, pOldAnim, 500, + L"ppt_w", L"4/3*#ppt_w", L"#ppt_w", + L"ppt_h", L"4/3*#ppt_h", L"#ppt_h"); + + presetSub = 288; + break; + } + } +} + +void Animation_1995::ConvertRandomEffect(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim) +{ + PushSet(oParent, pOldAnim, 499); + + PPTX::Logic::TimeNodeBase childTimeNode; + + auto anim = new PPTX::Logic::Anim; + anim->to = L""; + anim->calcmode = new PPTX::Limit::TLCalcMode; + anim->calcmode->set(L"lin"); + anim->valueType = new PPTX::Limit::TLValueType; + anim->valueType->set(L"num"); + + FillCBhvr(anim->cBhvr, 1, pOldAnim->shapeId, L"", -1); + childTimeNode.m_node = anim; + oParent.list.push_back(childTimeNode); +} + +void Animation_1995::PushAnim(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int dur, + std::wstring attrname1, Intermediate::SValue val1, Intermediate::SValue val2, + std::wstring attrname2, Intermediate::SValue val3, Intermediate::SValue val4, std::wstring fmla1, std::wstring fmla2) +{ + PushAnim(oParent, pOldAnim, attrname1, val1, val2, fmla1); + PushAnim(oParent, pOldAnim, attrname2, val3, val4, fmla2); +} + +void Animation_1995::PushAnim(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, + std::wstring attrname1, Intermediate::SValue val1, Intermediate::SValue val2,std::wstring fmla1) +{ + PPTX::Logic::TimeNodeBase childTimeNode; + + auto anim = new PPTX::Logic::Anim; + FillAnim(*anim, pOldAnim, pOldAnim->getAnimDur(), attrname1, val1, val2, fmla1); + childTimeNode.m_node = anim; + oParent.list.push_back(childTimeNode); +} + +void Animation_1995::PushAnimEffect(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, std::wstring filter, std::wstring transition) +{ + PPTX::Logic::TimeNodeBase childTimeNode; + + auto animEffect = new PPTX::Logic::AnimEffect; + FillAnimEffect(*animEffect, pOldAnim, filter, transition); + childTimeNode.m_node = animEffect; + oParent.list.push_back(childTimeNode); +} + +void Animation_1995::PushSet(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int dur) +{ + PPTX::Logic::TimeNodeBase childTimeNode; + auto set = new PPTX::Logic::Set; + + FillCBhvr(set->cBhvr, pOldAnim, dur); + set->to = new PPTX::Logic::AnimVariant; + set->to->node_name = L"to"; + set->to->strVal = L"visible"; + + childTimeNode.m_node = set; + oParent.list.push_back(childTimeNode); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h index da651a2ead..b2d3d1e870 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.h @@ -1,25 +1,9 @@ #pragma once -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimClr.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimMotion.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimRot.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimScale.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimVariant.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Audio.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CBhvr.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/ChildTnLst.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cmd.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CondLst.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Set.h" -#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Video.h" -#include "../../Records/Animations/AnimationInfoContainer.h" #include "intermediate_anim.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/ChildTnLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h" namespace PPT { @@ -27,29 +11,51 @@ namespace Converter { class Animation_1995 { public: - Animation_1995(std::vector& vecAIC); - void ConvertToTiming(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + Animation_1995(_INT32& cTnId); + void FillCTnAnimation(PPTX::Logic::CTn &oCTN, Intermediate::SOldAnimation *pOldAnim); private: - bool InitAndCheckVars(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); - void ConvertBldLst(); - void ConvertTnLst(); - PPTX::Logic::Seq *ConvertMainSeqAnimation(); - void InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq); - PPTX::Logic::Par *InitRootNode(); - PPTX::Logic::Seq *InitMainSeq(); - void SplitRawAnim(); - void SortAnim(); - void FillClickPar(std::list& clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillAnim (PPTX::Logic::Anim& oAnim, Intermediate::SOldAnimation* pOldAnim, int dur, std::wstring attrname, + Intermediate::SValue val1, Intermediate::SValue val2, std::wstring fmla = L""); + void FillAnimEffect (PPTX::Logic::AnimEffect& oAnimEffect, Intermediate::SOldAnimation* pOldAnim, std::wstring filter, std::wstring transition = L"in"); + + void FillCBhvrForAnim (PPTX::Logic::Anim& oAnim, Intermediate::SOldAnimation* pOldAnim, int dur, std::wstring attrname); + void FillCBhvr(PPTX::Logic::CBhvr &oBhvr, int dur, UINT spid, std::wstring attrname, int delay=499); + void FillCBhvr(PPTX::Logic::CBhvr &oCBhvr, Intermediate::SOldAnimation* pOldAnim, int delay = 499); + + // This methods fill ChildTnLst with anim nodes + void ConvertAppear(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim); + void ConvertFlyIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertBlinds(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertShape(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertCheckerboard(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim); + void ConvertCrawlIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertDissolveIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim); + void ConvertFade(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim); + void ConvertFlashOnce(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertPeekIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertRandomBars(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertSpiralIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim); + void ConvertSplit(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertStretch(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertStrips(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertBasicSwivel(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertWipe(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertBasicZoom(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim, int& presetSub); + void ConvertRandomEffect(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim); + + void PushAnim(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int dur, + std::wstring attrname1, Intermediate::SValue val1, Intermediate::SValue val2, + std::wstring attrname2, Intermediate::SValue val3, Intermediate::SValue val4, + std::wstring fmla1 = L"", std::wstring fmla2 = L""); + void PushAnim(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, + std::wstring attrname1, Intermediate::SValue val1, Intermediate::SValue val2,std::wstring fmla1 = L""); + + void PushAnimEffect(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, std::wstring filter, std::wstring transition = L"in"); + void PushSet(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int dur = 0); private: - std::vector& arrOldAnim; - std::list > splitedAnim; - - PPTX::Logic::Timing* pTiming = nullptr; - CExMedia* pExMedia; - CRelsGenerator* pRels; - _INT32 cTnId = 3; + _INT32 & cTnId; }; } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp new file mode 100644 index 0000000000..6187988a98 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp @@ -0,0 +1,270 @@ +#include "Timing_1995.h" +#include "Animation_1995.h" +#include "../../Records/Animations/BuildListContainer.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldLst.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h" +#include "../../Records/Animations/BuildListContainer.h" + + +namespace PPT { +namespace Converter { + +Timing_1995::Timing_1995(const std::vector &vecAIC) : + arrOldAnim(vecAIC), + animConverter(new Animation_1995(cTnId)) +{} + +void Timing_1995::Convert(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels) +{ + if (InitAndCheckVars(timimg, pExMedia, pRels) == false) + return; + ConvertBldLst(); + ConvertTnLst(); +} + +Timing_1995::~Timing_1995() +{ + delete animConverter; +} + +bool Timing_1995::InitAndCheckVars(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRelsGenerator *pRels) +{ + this->pExMedia = pExMedia; + this->pRels = pRels; + this->pTiming = &timimg; + + return pExMedia && pRels && pTiming && !arrOldAnim.empty(); +} + +void Timing_1995::ConvertBldLst() +{ + pTiming->bldLst = new PPTX::Logic::BldLst(); + for (auto oldAnim : arrOldAnim) + { + PPTX::Logic::BuildNodeBase oBuildNodeBase; + PPTX::Logic::BldP *pBldP = new PPTX::Logic::BldP(); + pBldP->spid = std::to_wstring(oldAnim.shapeId); + pBldP->grpId = false; + pBldP->animBg = (bool)(oldAnim.anim->m_AnimationAtom.m_fAnimateBg != 0); + + oBuildNodeBase.m_node = pBldP; + pTiming->bldLst->list.push_back(oBuildNodeBase); + } +} + +void Timing_1995::ConvertTnLst() +{ + pTiming->tnLst = new PPTX::Logic::TnLst(); + SplitRawAnim(); + auto mainSeq = ConvertMainSeqAnimation(); + InsertMainSeqToTnLst(mainSeq); +} + +PPTX::Logic::Seq *Timing_1995::ConvertMainSeqAnimation() +{ + auto seq2 = InitMainSeq(); + for (auto& clickPar : splitedAnim) + { + PPTX::Logic::TimeNodeBase child; + FillClickPar(clickPar, child); /// TODO next + seq2->cTn.childTnLst->list.push_back(child); + } + return seq2; +} + +void Timing_1995::InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq) +{ + PPTX::Logic::TimeNodeBase timeNodeBase; + timeNodeBase.m_node = mainSeq; + auto par1 = InitRootNode(); + par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + par1->cTn.childTnLst->list.push_back(timeNodeBase); + timeNodeBase.m_node = par1; + + pTiming->tnLst->list.push_back(timeNodeBase); +} + +PPTX::Logic::Par* Timing_1995::InitRootNode() +{ + auto par1 = new PPTX::Logic::Par; + par1->cTn.id = 1; + par1->cTn.dur = L"indefinite"; + par1->cTn.restart = L"never"; + par1->cTn.nodeType = L"tmRoot"; + + return par1; +} + +PPTX::Logic::Seq *Timing_1995::InitMainSeq() +{ + auto seq2 = new PPTX::Logic::Seq; + seq2->cTn.id = 2; + seq2->cTn.dur = L"indefinite"; + seq2->cTn.nodeType = L"mainSeq"; + seq2->concurrent = L"1"; + seq2->nextAc = L"seek"; + seq2->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + + PPTX::Logic::Cond cond; + cond.tgtEl = new PPTX::Logic::TgtEl; + if (arrOldAnim.front().anim->m_AnimationAtom.m_fAutomatic) + cond.delay = L"0"; + + seq2->nextCondLst = new PPTX::Logic::CondLst; + seq2->nextCondLst->node_name = L"nextCondLst"; + cond.evt = L"onNext"; + cond.delay = L"0"; + seq2->nextCondLst->list.push_back(cond); + + seq2->prevCondLst = new PPTX::Logic::CondLst; + seq2->prevCondLst->node_name = L"prevCondLst"; + cond.evt = L"onPrev"; + cond.delay = L"0"; + seq2->prevCondLst->list.push_back(cond); + + return seq2; +} + +void Timing_1995::SplitRawAnim() +{ + splitedAnim.clear(); + SortAnim(); + + for (auto& oldAnim : arrOldAnim) + { + if (splitedAnim.empty()) + { + std::list clickPar; + clickPar.push_back(&oldAnim); + splitedAnim.push_back(clickPar); + } else if (oldAnim.anim->m_AnimationAtom.m_fAutomatic) + { + splitedAnim.back().push_back(&oldAnim); + } else + { + std::list clickPar; + clickPar.push_back(&oldAnim); + splitedAnim.push_back(clickPar); + } + } +} + +void Timing_1995::SortAnim() +{ + std::sort(arrOldAnim.begin(), arrOldAnim.end(), + [] + ( + const Intermediate::SOldAnimation& a1, + const Intermediate::SOldAnimation& a2 + ) + { + return + a1.anim->m_AnimationAtom.m_OrderID + < + a2.anim->m_AnimationAtom.m_OrderID; + } + ); +} + +void Timing_1995::FillClickPar(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase) +{ + const auto& animAtom = clickPar.front()->anim->m_AnimationAtom; + + auto par1 = new PPTX::Logic::Par; + FillCTnParams(par1->cTn, L"clickPar", L"indefinite"); + + PPTX::Logic::Cond cond; + if (animAtom.m_OrderID == 1 && + animAtom.m_fAutomatic) + { + cond.evt = L"onBegin"; + cond.delay = L"0"; + cond.tn = 2; + par1->cTn.stCondLst->list.push_back(cond); + } + + // p:childTnLst + PPTX::Logic::TimeNodeBase childTimeNode; + _UINT32 groupDelay = 0; + FillGroup(clickPar.front(), childTimeNode, groupDelay, L"withGroup"); + par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + par1->cTn.childTnLst->list.push_back(childTimeNode); + clickPar.pop_front(); + + while (!clickPar.empty()) + { + PPTX::Logic::TimeNodeBase childTimeNode; + FillGroup(clickPar.front(), childTimeNode, groupDelay, L"afterGroup"); + par1->cTn.childTnLst->list.push_back(childTimeNode); + clickPar.pop_front(); + } + + oTimeNodeBase.m_node = par1; +} + +void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay, std::wstring fill, Intermediate::SOldAnimation* pOldAnim) +{ + cTn.id = cTnId++; + cTn.fill = fill; + cTn.nodeType = nodeType; + + if (pOldAnim) + animConverter->FillCTnAnimation(cTn, pOldAnim); + + // p:stCondLst + cTn.stCondLst = new PPTX::Logic::CondLst; + cTn.stCondLst->node_name = L"stCondLst"; + PPTX::Logic::Cond cond; + cond.delay = condDelay; + cTn.stCondLst->list.push_back(cond); +} + +void Timing_1995::FillGroup(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay, std::wstring nodeType) +{ + const auto& anim = pOldAnim->anim->m_AnimationAtom; + auto par = new PPTX::Logic::Par; + + FillCTnParams(par->cTn, nodeType, std::to_wstring(groupDelay)); + PPTX::Logic::TimeNodeBase childTimeNode; + if (anim.m_fAutomatic) + { + FillAfterEffect(pOldAnim, childTimeNode, groupDelay); + } else + { + FillClickEffect(pOldAnim, childTimeNode, groupDelay); + } + + par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + par->cTn.childTnLst->list.push_back(childTimeNode); + + oTimeNodeBase.m_node = par; +} + +void Timing_1995::FillClickEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) +{ + auto par = new PPTX::Logic::Par; + + FillCTnParams(par->cTn, L"clickEffect", L"0", L"hold", pOldAnim); + groupDelay += 500; // Effect time // TODO for anim + + oTimeNodeBase.m_node = par; +} + +void Timing_1995::FillAfterEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) +{ + const auto& anim = pOldAnim->anim->m_AnimationAtom; + auto par = new PPTX::Logic::Par; + + groupDelay += anim.m_DelayTime; + auto delay = std::to_wstring(anim.m_DelayTime); + groupDelay += pOldAnim->getAnimDur(); // Effect time + + FillCTnParams(par->cTn, L"afterEffect", delay, L"hold", pOldAnim); + // par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed + + oTimeNodeBase.m_node = par; +} + +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h new file mode 100644 index 0000000000..f88d674c79 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h @@ -0,0 +1,49 @@ +#pragma once + +#include "../../PPTXWriter/ImageManager.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h" +#include "intermediate_anim.h" + + +namespace PPT { +namespace Converter { +class Animation_1995; + +class Timing_1995 +{ +public: + Timing_1995(const std::vector& vecAIC); + void Convert(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + ~Timing_1995(); + +private: + bool InitAndCheckVars(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + void ConvertBldLst(); + void ConvertTnLst(); + PPTX::Logic::Seq *ConvertMainSeqAnimation(); + void InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq); + PPTX::Logic::Par *InitRootNode(); + PPTX::Logic::Seq *InitMainSeq(); + void SplitRawAnim(); + void SortAnim(); + + void FillClickPar(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay=L"", std::wstring fill=L"hold", Intermediate::SOldAnimation* pOldAnim = nullptr); + void FillGroup(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); + void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); + void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); + +private: + std::vector arrOldAnim; + std::list > splitedAnim; + Animation_1995* animConverter; + + PPTX::Logic::Timing* pTiming = nullptr; + CExMedia* pExMedia; + CRelsGenerator* pRels; + _INT32 cTnId = 3; +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h index ae6b900f13..24a7230c3f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h @@ -1,9 +1,6 @@ #pragma once -#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" - #include "../Records/SlideProgTagsContainer.h" -#include "../PPTXWriter/ImageManager.h" #include "../Records/Animations/AnimationInfoContainer.h" #include @@ -24,5 +21,21 @@ struct SlideAnimation std::vector arrAnim_1995; std::unordered_set<_INT32> realShapesIds; }; + +struct SValue +{ + enum + { + str, + dbl + }; + SValue(const std::wstring& str) : strVal(str), type(SValue::str) {} + SValue(const wchar_t* str) : strVal(str), type(SValue::str) {} + SValue(const double& dbl) : dblVal(dbl), type(SValue::dbl) {} + + std::wstring strVal; + double dblVal; + const int type; +}; } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index 8032f9ad51..dcacbd61ab 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -1,7 +1,7 @@ #include "timing.h" #include "Animation/intermediate_anim.h" -#include "Animation/Animation_1995.h" +#include "Animation/Timing_1995.h" using namespace PPT::Converter; @@ -15,7 +15,7 @@ PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) // this->pExMedia = pExMedia; // this->pRels = pRels; - Animation_1995(slideAnim.arrAnim_1995). - ConvertToTiming(timing, pExMedia, pRels); + Timing_1995(slideAnim.arrAnim_1995). + Convert(timing, pExMedia, pRels); return std::move(timing); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index fccc525588..e14a5f5543 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -29,7 +29,7 @@ DEFINES += UNICODE \ HEADERS += \ ../Converter/Animation/AnimationParser.h \ ../Converter/Animation/Animation_1995.h \ - ../Converter/Animation/animation.h \ + ../Converter/Animation/Timing_1995.h \ ../Converter/Animation/intermediate_anim.h \ ../Converter/timing.h \ ../Converter/transition.h \ @@ -279,7 +279,6 @@ SOURCES += \ core_debug { SOURCES += \ - ../Converter/Animation/animation.cpp \ ../Enums/RecordType.cpp \ ../PPTFormatLib.cpp \ ../Reader/ReadStructures.cpp \ @@ -304,6 +303,7 @@ SOURCES += \ ../../../Common/3dParty/pole/pole.cpp \ ../Converter/Animation/AnimationParser.cpp \ ../Converter/Animation/Animation_1995.cpp \ + ../Converter/Animation/Timing_1995.cpp \ ../Converter/timing.cpp \ ../Converter/transition.cpp \ ../PPTXWriter/BulletsConverter.cpp From 70e07e3ce1464cdb8e58b6fd18d1aed4c0d2ab73 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 8 Nov 2022 19:56:20 +0300 Subject: [PATCH 05/22] fix part of 1995 animation bug --- .../Converter/Animation/Animation_1995.cpp | 12 +++- .../Converter/Animation/Timing_1995.cpp | 58 +++++++++++++------ .../Converter/Animation/Timing_1995.h | 3 +- .../Converter/Animation/intermediate_anim.cpp | 29 ++++++++++ .../PPTFormatLib/Linux/PPTFormatLib.pro | 1 + 5 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp index 1b3783b721..31a25e52a9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp @@ -38,8 +38,16 @@ void Animation_1995::FillCTnAnimation(PPTX::Logic::CTn &oCTN, Intermediate::SOld { case 0x00: { - oCTN.presetID = 1; - ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); + if (direct == 1) + { + oCTN.presetID = 1; + ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); + } + else + { + oCTN.presetID = 10; + ConvertFade(oCTN.childTnLst.get2(), pOldAnim); + } break; } case 0x01: diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp index 6187988a98..73b45952ed 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp @@ -187,17 +187,15 @@ void Timing_1995::FillClickPar(std::list &clickPar // p:childTnLst PPTX::Logic::TimeNodeBase childTimeNode; _UINT32 groupDelay = 0; - FillGroup(clickPar.front(), childTimeNode, groupDelay, L"withGroup"); + FillGroup(clickPar, childTimeNode, groupDelay, L"withGroup"); par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; par1->cTn.childTnLst->list.push_back(childTimeNode); - clickPar.pop_front(); while (!clickPar.empty()) { PPTX::Logic::TimeNodeBase childTimeNode; - FillGroup(clickPar.front(), childTimeNode, groupDelay, L"afterGroup"); + FillGroup(clickPar, childTimeNode, groupDelay, L"afterGroup"); par1->cTn.childTnLst->list.push_back(childTimeNode); - clickPar.pop_front(); } oTimeNodeBase.m_node = par1; @@ -220,23 +218,31 @@ void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, st cTn.stCondLst->list.push_back(cond); } -void Timing_1995::FillGroup(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay, std::wstring nodeType) +void Timing_1995::FillGroup(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay, std::wstring nodeType) { - const auto& anim = pOldAnim->anim->m_AnimationAtom; auto par = new PPTX::Logic::Par; - - FillCTnParams(par->cTn, nodeType, std::to_wstring(groupDelay)); - PPTX::Logic::TimeNodeBase childTimeNode; - if (anim.m_fAutomatic) - { - FillAfterEffect(pOldAnim, childTimeNode, groupDelay); - } else - { - FillClickEffect(pOldAnim, childTimeNode, groupDelay); - } - par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - par->cTn.childTnLst->list.push_back(childTimeNode); + while (clickPar.empty() == false) + { + auto* pOldAnim = clickPar.front(); + const auto& anim = pOldAnim->anim->m_AnimationAtom; + clickPar.pop_front(); + + FillCTnParams(par->cTn, nodeType, std::to_wstring(groupDelay)); + PPTX::Logic::TimeNodeBase childTimeNode; + if (anim.m_fAutomatic && !clickPar.empty() && clickPar.front()->anim->m_AnimationAtom.m_fSynchronous) // todo need to connect parallel animatios + { + FillWithEffect(pOldAnim, childTimeNode, groupDelay); + } else if (anim.m_fAutomatic) + { + FillAfterEffect(pOldAnim, childTimeNode, groupDelay); + } else + { + FillClickEffect(pOldAnim, childTimeNode, groupDelay); + } + + par->cTn.childTnLst->list.push_back(childTimeNode); + } oTimeNodeBase.m_node = par; } @@ -266,5 +272,21 @@ void Timing_1995::FillAfterEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::L oTimeNodeBase.m_node = par; } +void Timing_1995::FillWithEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) +{ + const auto& anim = pOldAnim->anim->m_AnimationAtom; + auto par = new PPTX::Logic::Par; + + groupDelay += anim.m_DelayTime; + auto delay = std::to_wstring(anim.m_DelayTime); + groupDelay += pOldAnim->getAnimDur(); // Effect time + + FillCTnParams(par->cTn, L"withEffect", delay, L"hold", pOldAnim); + // par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed + + oTimeNodeBase.m_node = par; + +} + } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h index f88d674c79..bc5c999f5c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h @@ -31,9 +31,10 @@ private: void FillClickPar(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); void FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay=L"", std::wstring fill=L"hold", Intermediate::SOldAnimation* pOldAnim = nullptr); - void FillGroup(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); + void FillGroup(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); + void FillWithEffect (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); private: std::vector arrOldAnim; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp new file mode 100644 index 0000000000..c745ae5007 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp @@ -0,0 +1,29 @@ +#include "intermediate_anim.h" + + + +_UINT32 PPT::Intermediate::SOldAnimation::getAnimDur() const +{ + _UINT32 dur = 500; + if (!anim) + return 0; + + const UINT effect = anim->m_AnimationAtom.m_AnimEffect; + const UINT direct = anim->m_AnimationAtom.m_AnimEffectDirection; + + if (effect == 12 && ((direct >= 12 && direct <= 15) || direct == 27)) // Crawl In, Basic Swivel + dur = 5000; + else if (effect == 12 && direct == 28) + dur = 1000; + else if (effect == 14) + { + switch (direct) + { + case 0: dur = 75; break; + case 1: dur = 500; break; + case 2: dur = 1000; break; + } + } + + return dur; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index e14a5f5543..31bf7ebfad 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -304,6 +304,7 @@ SOURCES += \ ../Converter/Animation/AnimationParser.cpp \ ../Converter/Animation/Animation_1995.cpp \ ../Converter/Animation/Timing_1995.cpp \ + ../Converter/Animation/intermediate_anim.cpp \ ../Converter/timing.cpp \ ../Converter/transition.cpp \ ../PPTXWriter/BulletsConverter.cpp From 12960e474e577b42b0df94377b83078076012d52 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 9 Nov 2022 16:33:03 +0300 Subject: [PATCH 06/22] add some lost source files --- .../Converter/Animation/intermediate_anim.cpp | 5 ++- .../Converter/Animation/intermediate_anim.h | 33 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp index c745ae5007..852c3dbf4b 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp @@ -1,15 +1,14 @@ #include "intermediate_anim.h" - _UINT32 PPT::Intermediate::SOldAnimation::getAnimDur() const { _UINT32 dur = 500; if (!anim) return 0; - const UINT effect = anim->m_AnimationAtom.m_AnimEffect; - const UINT direct = anim->m_AnimationAtom.m_AnimEffectDirection; + const BYTE effect = anim->m_AnimationAtom.m_AnimEffect; + const BYTE direct = anim->m_AnimationAtom.m_AnimEffectDirection; if (effect == 12 && ((direct >= 12 && direct <= 15) || direct == 27)) // Crawl In, Basic Swivel dur = 5000; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h index 24a7230c3f..79fd2229f9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.h @@ -1,27 +1,15 @@ #pragma once +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" + #include "../Records/SlideProgTagsContainer.h" +#include "../PPTXWriter/ImageManager.h" #include "../Records/Animations/AnimationInfoContainer.h" #include namespace PPT { namespace Intermediate { -struct SOldAnimation -{ - _INT32 shapeId; - CRecordAnimationInfoContainer* anim; - - _UINT32 getAnimDur() const; -}; - -struct SlideAnimation -{ - CRecordPP10SlideBinaryTagExtension* pAnim_2010 = nullptr; - std::vector arrAnim_1995; - std::unordered_set<_INT32> realShapesIds; -}; - struct SValue { enum @@ -37,5 +25,20 @@ struct SValue double dblVal; const int type; }; + +struct SOldAnimation +{ + _INT32 shapeId; + CRecordAnimationInfoContainer* anim; + + _UINT32 getAnimDur() const; +}; + +struct SlideAnimation +{ + CRecordPP10SlideBinaryTagExtension* pAnim_2010 = nullptr; + std::vector arrAnim_1995; + std::unordered_set<_INT32> realShapesIds; +}; } } From 057c2174577f31f98e6c09b3f5dedebf29992980 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 9 Nov 2022 19:06:35 +0300 Subject: [PATCH 07/22] trying to fix pld animation --- .../Converter/Animation/Timing_1995.cpp | 50 ++++++++++--------- .../Converter/Animation/Timing_1995.h | 4 +- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp index 73b45952ed..58cb47da24 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp @@ -67,7 +67,7 @@ PPTX::Logic::Seq *Timing_1995::ConvertMainSeqAnimation() for (auto& clickPar : splitedAnim) { PPTX::Logic::TimeNodeBase child; - FillClickPar(clickPar, child); /// TODO next + FillClickGroup(clickPar, child); /// TODO next seq2->cTn.childTnLst->list.push_back(child); } return seq2; @@ -167,13 +167,14 @@ void Timing_1995::SortAnim() ); } -void Timing_1995::FillClickPar(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase) +void Timing_1995::FillClickGroup(std::list &clickGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { - const auto& animAtom = clickPar.front()->anim->m_AnimationAtom; + const auto& animAtom = clickGroup.front()->anim->m_AnimationAtom; - auto par1 = new PPTX::Logic::Par; - FillCTnParams(par1->cTn, L"clickPar", L"indefinite"); + auto par3 = new PPTX::Logic::Par; + FillCTnParams(par3->cTn, L"", L"indefinite", L"hold"); + //todo refactoring: move to fill FirstAutomaticGroup PPTX::Logic::Cond cond; if (animAtom.m_OrderID == 1 && animAtom.m_fAutomatic) @@ -181,31 +182,30 @@ void Timing_1995::FillClickPar(std::list &clickPar cond.evt = L"onBegin"; cond.delay = L"0"; cond.tn = 2; - par1->cTn.stCondLst->list.push_back(cond); + par3->cTn.stCondLst->list.push_back(cond); } // p:childTnLst - PPTX::Logic::TimeNodeBase childTimeNode; + par3->cTn.childTnLst = new PPTX::Logic::ChildTnLst; _UINT32 groupDelay = 0; - FillGroup(clickPar, childTimeNode, groupDelay, L"withGroup"); - par1->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - par1->cTn.childTnLst->list.push_back(childTimeNode); - while (!clickPar.empty()) + while (!clickGroup.empty()) { PPTX::Logic::TimeNodeBase childTimeNode; - FillGroup(clickPar, childTimeNode, groupDelay, L"afterGroup"); - par1->cTn.childTnLst->list.push_back(childTimeNode); + ConvertParallelGroupAnimation(clickGroup, childTimeNode, groupDelay, L"afterGroup"); + par3->cTn.childTnLst->list.push_back(childTimeNode); } - oTimeNodeBase.m_node = par1; + oTimeNodeBase.m_node = par3; } void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay, std::wstring fill, Intermediate::SOldAnimation* pOldAnim) { cTn.id = cTnId++; - cTn.fill = fill; - cTn.nodeType = nodeType; + if (!fill.empty()) + cTn.fill = fill; + if (!nodeType.empty()) + cTn.nodeType = nodeType; if (pOldAnim) animConverter->FillCTnAnimation(cTn, pOldAnim); @@ -218,19 +218,20 @@ void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, st cTn.stCondLst->list.push_back(cond); } -void Timing_1995::FillGroup(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay, std::wstring nodeType) +void Timing_1995::ConvertParallelGroupAnimation(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay, std::wstring nodeType) { - auto par = new PPTX::Logic::Par; - par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; + // par4 - 4 level - all 1995 animation level + auto par4 = new PPTX::Logic::Par; + par4->cTn.childTnLst = new PPTX::Logic::ChildTnLst; while (clickPar.empty() == false) { auto* pOldAnim = clickPar.front(); const auto& anim = pOldAnim->anim->m_AnimationAtom; clickPar.pop_front(); - FillCTnParams(par->cTn, nodeType, std::to_wstring(groupDelay)); + FillCTnParams(par4->cTn, nodeType, std::to_wstring(groupDelay)); PPTX::Logic::TimeNodeBase childTimeNode; - if (anim.m_fAutomatic && !clickPar.empty() && clickPar.front()->anim->m_AnimationAtom.m_fSynchronous) // todo need to connect parallel animatios + if (anim.m_fAutomatic && anim.m_fSynchronous) // todo need to connect parallel animatios { FillWithEffect(pOldAnim, childTimeNode, groupDelay); } else if (anim.m_fAutomatic) @@ -241,10 +242,13 @@ void Timing_1995::FillGroup(std::list &clickPar, P FillClickEffect(pOldAnim, childTimeNode, groupDelay); } - par->cTn.childTnLst->list.push_back(childTimeNode); + if (!clickPar.empty() && clickPar.front()->anim->m_AnimationAtom.m_fSynchronous) + break; + + par4->cTn.childTnLst->list.push_back(childTimeNode); } - oTimeNodeBase.m_node = par; + oTimeNodeBase.m_node = par4; } void Timing_1995::FillClickEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h index bc5c999f5c..2df5d57ab6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h @@ -29,9 +29,9 @@ private: void SplitRawAnim(); void SortAnim(); - void FillClickPar(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillClickGroup(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); void FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay=L"", std::wstring fill=L"hold", Intermediate::SOldAnimation* pOldAnim = nullptr); - void FillGroup(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); + void ConvertParallelGroupAnimation(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); void FillWithEffect (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); From e2aad28114c0d733ca63a9c877115171a70a613d Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 10 Nov 2022 15:16:23 +0300 Subject: [PATCH 08/22] fix old animation struct --- .../Converter/Animation/Timing_1995.cpp | 73 +++++++++++++------ .../Converter/Animation/Timing_1995.h | 11 ++- 2 files changed, 57 insertions(+), 27 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp index 58cb47da24..d6fa60c769 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp @@ -5,6 +5,7 @@ #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h" #include "../../Records/Animations/BuildListContainer.h" +#include namespace PPT { @@ -167,9 +168,10 @@ void Timing_1995::SortAnim() ); } -void Timing_1995::FillClickGroup(std::list &clickGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase) +void Timing_1995::FillClickGroup(LstAnim &clickGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { const auto& animAtom = clickGroup.front()->anim->m_AnimationAtom; + auto parGroups = SplitClickGroupByParrallelShow(clickGroup); auto par3 = new PPTX::Logic::Par; FillCTnParams(par3->cTn, L"", L"indefinite", L"hold"); @@ -189,16 +191,33 @@ void Timing_1995::FillClickGroup(std::list &clickG par3->cTn.childTnLst = new PPTX::Logic::ChildTnLst; _UINT32 groupDelay = 0; - while (!clickGroup.empty()) + for (auto& group : parGroups) { PPTX::Logic::TimeNodeBase childTimeNode; - ConvertParallelGroupAnimation(clickGroup, childTimeNode, groupDelay, L"afterGroup"); + ConvertParallelGroupAnimation(group, childTimeNode, groupDelay); par3->cTn.childTnLst->list.push_back(childTimeNode); } oTimeNodeBase.m_node = par3; } +LstLstAnim Timing_1995::SplitClickGroupByParrallelShow(LstAnim &clickGroup) +{ + LstLstAnim lstParallelGroups; + bool needNewGroup = true; + for (auto* anim : clickGroup) + { + auto& animAtom = anim->anim->m_AnimationAtom; + if (needNewGroup) + lstParallelGroups.push_back({anim}); + else + lstParallelGroups.back().push_back(anim); + + needNewGroup = animAtom.m_fSynchronous; + } + return lstParallelGroups; +} + void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay, std::wstring fill, Intermediate::SOldAnimation* pOldAnim) { cTn.id = cTnId++; @@ -218,39 +237,45 @@ void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, st cTn.stCondLst->list.push_back(cond); } -void Timing_1995::ConvertParallelGroupAnimation(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay, std::wstring nodeType) +void Timing_1995::ConvertParallelGroupAnimation(LstAnim &parGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) { // par4 - 4 level - all 1995 animation level auto par4 = new PPTX::Logic::Par; par4->cTn.childTnLst = new PPTX::Logic::ChildTnLst; - while (clickPar.empty() == false) + + FillCTnParams(par4->cTn, L"", std::to_wstring(groupDelay)); + PPTX::Logic::TimeNodeBase childTimeNode; + auto* pOldAnimation = parGroup.front(); + if (pOldAnimation->anim->m_AnimationAtom.m_fAutomatic) + FillAfterEffect(pOldAnimation, childTimeNode, groupDelay); + else + FillClickEffect(pOldAnimation, childTimeNode, groupDelay); + parGroup.pop_front(); + par4->cTn.childTnLst->list.push_back(childTimeNode); + + while (!parGroup.empty()) { - auto* pOldAnim = clickPar.front(); - const auto& anim = pOldAnim->anim->m_AnimationAtom; - clickPar.pop_front(); - - FillCTnParams(par4->cTn, nodeType, std::to_wstring(groupDelay)); PPTX::Logic::TimeNodeBase childTimeNode; - if (anim.m_fAutomatic && anim.m_fSynchronous) // todo need to connect parallel animatios - { - FillWithEffect(pOldAnim, childTimeNode, groupDelay); - } else if (anim.m_fAutomatic) - { - FillAfterEffect(pOldAnim, childTimeNode, groupDelay); - } else - { - FillClickEffect(pOldAnim, childTimeNode, groupDelay); - } - - if (!clickPar.empty() && clickPar.front()->anim->m_AnimationAtom.m_fSynchronous) - break; - + auto* pOldAnimation = parGroup.front(); + FillWithEffect(pOldAnimation, childTimeNode, groupDelay); + parGroup.pop_front(); par4->cTn.childTnLst->list.push_back(childTimeNode); } oTimeNodeBase.m_node = par4; } +_INT32 Timing_1995::GetParallelGroupDuration(LstAnim &parGroup) +{ + auto iterSlowestAnim = std::max(parGroup.begin(), parGroup.end(), + [] (Intermediate::SOldAnimation const* a1, Intermediate::SOldAnimation const* a2) + { + return a1->getAnimDur() < a2->getAnimDur(); + }); + + return (*iterSlowestAnim)->getAnimDur();; +} + void Timing_1995::FillClickEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) { auto par = new PPTX::Logic::Par; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h index 2df5d57ab6..f3050dceb6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h @@ -11,6 +11,9 @@ namespace PPT { namespace Converter { class Animation_1995; +using LstAnim = std::list; +using LstLstAnim = std::list; + class Timing_1995 { public: @@ -29,16 +32,18 @@ private: void SplitRawAnim(); void SortAnim(); - void FillClickGroup(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillClickGroup(LstAnim &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + static LstLstAnim SplitClickGroupByParrallelShow(LstAnim &clickGroup); void FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay=L"", std::wstring fill=L"hold", Intermediate::SOldAnimation* pOldAnim = nullptr); - void ConvertParallelGroupAnimation(std::list &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay, std::wstring nodeType); + void ConvertParallelGroupAnimation(LstAnim& parGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); + static _INT32 GetParallelGroupDuration(LstAnim &parGroup); void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); void FillWithEffect (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); private: std::vector arrOldAnim; - std::list > splitedAnim; + LstLstAnim splitedAnim; Animation_1995* animConverter; PPTX::Logic::Timing* pTiming = nullptr; From 88bab0600cb847da38208e5f426dfbedc5f6ca14 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 10 Nov 2022 16:37:43 +0300 Subject: [PATCH 09/22] fix old animation: groupDelay --- .../Converter/Animation/Timing_1995.cpp | 21 ++++++++----------- .../Converter/Animation/Timing_1995.h | 6 +++--- .../Converter/Animation/intermediate_anim.cpp | 3 ++- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp index d6fa60c769..423be4562d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp @@ -244,12 +244,14 @@ void Timing_1995::ConvertParallelGroupAnimation(LstAnim &parGroup, PPTX::Logic:: par4->cTn.childTnLst = new PPTX::Logic::ChildTnLst; FillCTnParams(par4->cTn, L"", std::to_wstring(groupDelay)); + groupDelay += GetParallelGroupDuration(parGroup); + PPTX::Logic::TimeNodeBase childTimeNode; auto* pOldAnimation = parGroup.front(); if (pOldAnimation->anim->m_AnimationAtom.m_fAutomatic) - FillAfterEffect(pOldAnimation, childTimeNode, groupDelay); + FillAfterEffect(pOldAnimation, childTimeNode); else - FillClickEffect(pOldAnimation, childTimeNode, groupDelay); + FillClickEffect(pOldAnimation, childTimeNode); parGroup.pop_front(); par4->cTn.childTnLst->list.push_back(childTimeNode); @@ -257,7 +259,7 @@ void Timing_1995::ConvertParallelGroupAnimation(LstAnim &parGroup, PPTX::Logic:: { PPTX::Logic::TimeNodeBase childTimeNode; auto* pOldAnimation = parGroup.front(); - FillWithEffect(pOldAnimation, childTimeNode, groupDelay); + FillWithEffect(pOldAnimation, childTimeNode); parGroup.pop_front(); par4->cTn.childTnLst->list.push_back(childTimeNode); } @@ -267,7 +269,7 @@ void Timing_1995::ConvertParallelGroupAnimation(LstAnim &parGroup, PPTX::Logic:: _INT32 Timing_1995::GetParallelGroupDuration(LstAnim &parGroup) { - auto iterSlowestAnim = std::max(parGroup.begin(), parGroup.end(), + auto iterSlowestAnim = std::max_element(parGroup.begin(), parGroup.end(), [] (Intermediate::SOldAnimation const* a1, Intermediate::SOldAnimation const* a2) { return a1->getAnimDur() < a2->getAnimDur(); @@ -276,24 +278,21 @@ _INT32 Timing_1995::GetParallelGroupDuration(LstAnim &parGroup) return (*iterSlowestAnim)->getAnimDur();; } -void Timing_1995::FillClickEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) +void Timing_1995::FillClickEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { auto par = new PPTX::Logic::Par; FillCTnParams(par->cTn, L"clickEffect", L"0", L"hold", pOldAnim); - groupDelay += 500; // Effect time // TODO for anim oTimeNodeBase.m_node = par; } -void Timing_1995::FillAfterEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) +void Timing_1995::FillAfterEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { const auto& anim = pOldAnim->anim->m_AnimationAtom; auto par = new PPTX::Logic::Par; - groupDelay += anim.m_DelayTime; auto delay = std::to_wstring(anim.m_DelayTime); - groupDelay += pOldAnim->getAnimDur(); // Effect time FillCTnParams(par->cTn, L"afterEffect", delay, L"hold", pOldAnim); // par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed @@ -301,14 +300,12 @@ void Timing_1995::FillAfterEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::L oTimeNodeBase.m_node = par; } -void Timing_1995::FillWithEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32 &groupDelay) +void Timing_1995::FillWithEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { const auto& anim = pOldAnim->anim->m_AnimationAtom; auto par = new PPTX::Logic::Par; - groupDelay += anim.m_DelayTime; auto delay = std::to_wstring(anim.m_DelayTime); - groupDelay += pOldAnim->getAnimDur(); // Effect time FillCTnParams(par->cTn, L"withEffect", delay, L"hold", pOldAnim); // par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h index f3050dceb6..a398388cc7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h @@ -37,9 +37,9 @@ private: void FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay=L"", std::wstring fill=L"hold", Intermediate::SOldAnimation* pOldAnim = nullptr); void ConvertParallelGroupAnimation(LstAnim& parGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); static _INT32 GetParallelGroupDuration(LstAnim &parGroup); - void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); - void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); - void FillWithEffect (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); + void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillWithEffect (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); private: std::vector arrOldAnim; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp index 852c3dbf4b..1304b74340 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/intermediate_anim.cpp @@ -22,7 +22,8 @@ _UINT32 PPT::Intermediate::SOldAnimation::getAnimDur() const case 1: dur = 500; break; case 2: dur = 1000; break; } - } + } else if (effect == 19 || effect == 26) + dur = 2000; return dur; } From a989422bcae877f99d2e2279e556f92dee5c0b47 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 10 Nov 2022 19:50:02 +0300 Subject: [PATCH 10/22] refactoring: Timing_1995 --- .../Converter/Animation/Animation_1995.cpp | 6 +- .../Converter/Animation/Timing_1995.cpp | 172 +++++++++--------- .../Converter/Animation/Timing_1995.h | 9 +- 3 files changed, 92 insertions(+), 95 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp index 31a25e52a9..dd4b332cb0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Animation_1995.cpp @@ -38,7 +38,7 @@ void Animation_1995::FillCTnAnimation(PPTX::Logic::CTn &oCTN, Intermediate::SOld { case 0x00: { - if (direct == 1) + if (direct != 1) { oCTN.presetID = 1; ConvertAppear(oCTN.childTnLst.get2(), pOldAnim); @@ -260,7 +260,7 @@ void Animation_1995::FillAnimEffect (PPTX::Logic::AnimEffect& oAnimEffect, Inter // This methods fill ChildTnLst with anim nodes void Animation_1995::ConvertAppear(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim) { - PushSet(oParent, pOldAnim, 499); + PushSet(oParent, pOldAnim, 0); } void Animation_1995::ConvertFlyIn(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation *pOldAnim, int& presetSub) @@ -811,7 +811,7 @@ void Animation_1995::ConvertBasicZoom(PPTX::Logic::ChildTnLst& oParent, Intermed void Animation_1995::ConvertRandomEffect(PPTX::Logic::ChildTnLst& oParent, Intermediate::SOldAnimation* pOldAnim) { - PushSet(oParent, pOldAnim, 499); + PushSet(oParent, pOldAnim, 0); PPTX::Logic::TimeNodeBase childTimeNode; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp index 423be4562d..ef2b3a9f29 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.cpp @@ -57,18 +57,45 @@ void Timing_1995::ConvertBldLst() void Timing_1995::ConvertTnLst() { pTiming->tnLst = new PPTX::Logic::TnLst(); - SplitRawAnim(); - auto mainSeq = ConvertMainSeqAnimation(); + auto clickGroupsAnim = SplitRawAnim(); + auto mainSeq = ConvertMainSeqAnimation(clickGroupsAnim); InsertMainSeqToTnLst(mainSeq); } -PPTX::Logic::Seq *Timing_1995::ConvertMainSeqAnimation() +LstLstAnim Timing_1995::SplitRawAnim() +{ + SortAnim(); + + LstLstAnim splitedAnim; + + for (auto& oldAnim : arrOldAnim) + { + if (splitedAnim.empty()) + { + std::list clickPar; + clickPar.push_back(&oldAnim); + splitedAnim.push_back(clickPar); + } else if (oldAnim.anim->m_AnimationAtom.m_fAutomatic) + { + splitedAnim.back().push_back(&oldAnim); + } else + { + std::list clickPar; + clickPar.push_back(&oldAnim); + splitedAnim.push_back(clickPar); + } + } + + return splitedAnim; +} + +PPTX::Logic::Seq *Timing_1995::ConvertMainSeqAnimation(LstLstAnim &splitedAnim) { auto seq2 = InitMainSeq(); - for (auto& clickPar : splitedAnim) + for (auto& clickGroup : splitedAnim) { PPTX::Logic::TimeNodeBase child; - FillClickGroup(clickPar, child); /// TODO next + FillClickGroup(clickGroup, child); seq2->cTn.childTnLst->list.push_back(child); } return seq2; @@ -127,41 +154,12 @@ PPTX::Logic::Seq *Timing_1995::InitMainSeq() return seq2; } -void Timing_1995::SplitRawAnim() -{ - splitedAnim.clear(); - SortAnim(); - - for (auto& oldAnim : arrOldAnim) - { - if (splitedAnim.empty()) - { - std::list clickPar; - clickPar.push_back(&oldAnim); - splitedAnim.push_back(clickPar); - } else if (oldAnim.anim->m_AnimationAtom.m_fAutomatic) - { - splitedAnim.back().push_back(&oldAnim); - } else - { - std::list clickPar; - clickPar.push_back(&oldAnim); - splitedAnim.push_back(clickPar); - } - } -} - void Timing_1995::SortAnim() { std::sort(arrOldAnim.begin(), arrOldAnim.end(), - [] - ( - const Intermediate::SOldAnimation& a1, - const Intermediate::SOldAnimation& a2 - ) + [] (const Intermediate::SOldAnimation& a1, const Intermediate::SOldAnimation& a2) { - return - a1.anim->m_AnimationAtom.m_OrderID + return a1.anim->m_AnimationAtom.m_OrderID < a2.anim->m_AnimationAtom.m_OrderID; } @@ -176,18 +174,8 @@ void Timing_1995::FillClickGroup(LstAnim &clickGroup, PPTX::Logic::TimeNodeBase auto par3 = new PPTX::Logic::Par; FillCTnParams(par3->cTn, L"", L"indefinite", L"hold"); - //todo refactoring: move to fill FirstAutomaticGroup - PPTX::Logic::Cond cond; - if (animAtom.m_OrderID == 1 && - animAtom.m_fAutomatic) - { - cond.evt = L"onBegin"; - cond.delay = L"0"; - cond.tn = 2; - par3->cTn.stCondLst->list.push_back(cond); - } + FillFirstAutomaticGroup(par3->cTn, animAtom); - // p:childTnLst par3->cTn.childTnLst = new PPTX::Logic::ChildTnLst; _UINT32 groupDelay = 0; @@ -218,6 +206,19 @@ LstLstAnim Timing_1995::SplitClickGroupByParrallelShow(LstAnim &clickGroup) return lstParallelGroups; } +void Timing_1995::FillFirstAutomaticGroup(PPTX::Logic::CTn &cTn, const CRecordAnimationInfoAtom &animAtom) const +{ + PPTX::Logic::Cond cond; + if (animAtom.m_OrderID == arrOldAnim[0].anim->m_AnimationAtom.m_OrderID && + animAtom.m_fAutomatic) + { + cond.evt = L"onBegin"; + cond.delay = L"0"; + cond.tn = 2; + cTn.stCondLst->list.push_back(cond); + } +} + void Timing_1995::FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay, std::wstring fill, Intermediate::SOldAnimation* pOldAnim) { cTn.id = cTnId++; @@ -246,23 +247,8 @@ void Timing_1995::ConvertParallelGroupAnimation(LstAnim &parGroup, PPTX::Logic:: FillCTnParams(par4->cTn, L"", std::to_wstring(groupDelay)); groupDelay += GetParallelGroupDuration(parGroup); - PPTX::Logic::TimeNodeBase childTimeNode; - auto* pOldAnimation = parGroup.front(); - if (pOldAnimation->anim->m_AnimationAtom.m_fAutomatic) - FillAfterEffect(pOldAnimation, childTimeNode); - else - FillClickEffect(pOldAnimation, childTimeNode); - parGroup.pop_front(); - par4->cTn.childTnLst->list.push_back(childTimeNode); - - while (!parGroup.empty()) - { - PPTX::Logic::TimeNodeBase childTimeNode; - auto* pOldAnimation = parGroup.front(); - FillWithEffect(pOldAnimation, childTimeNode); - parGroup.pop_front(); - par4->cTn.childTnLst->list.push_back(childTimeNode); - } + ConvertHeadEfectInParallelShow(parGroup, par4->cTn); + ConvertWithEfectsInParallelShow(parGroup, par4->cTn); oTimeNodeBase.m_node = par4; } @@ -270,48 +256,56 @@ void Timing_1995::ConvertParallelGroupAnimation(LstAnim &parGroup, PPTX::Logic:: _INT32 Timing_1995::GetParallelGroupDuration(LstAnim &parGroup) { auto iterSlowestAnim = std::max_element(parGroup.begin(), parGroup.end(), - [] (Intermediate::SOldAnimation const* a1, Intermediate::SOldAnimation const* a2) - { + [] (Intermediate::SOldAnimation const* a1, Intermediate::SOldAnimation const* a2) + { return a1->getAnimDur() < a2->getAnimDur(); - }); +}); return (*iterSlowestAnim)->getAnimDur();; } +void Timing_1995::ConvertHeadEfectInParallelShow(const LstAnim& group, PPTX::Logic::CTn &cTn) +{ + PPTX::Logic::TimeNodeBase childTimeNode; + auto* pOldAnimation = group.front(); + + if (pOldAnimation->anim->m_AnimationAtom.m_fAutomatic) + FillAfterEffect(pOldAnimation, childTimeNode); + else + FillClickEffect(pOldAnimation, childTimeNode); + cTn.childTnLst->list.push_back(childTimeNode); +} + +void Timing_1995::ConvertWithEfectsInParallelShow(const LstAnim& group, PPTX::Logic::CTn &cTn) +{ + for (auto itAnim = ++group.begin(); itAnim != group.end(); itAnim++) + { + PPTX::Logic::TimeNodeBase childTimeNode; + FillWithEffect(*itAnim, childTimeNode); + cTn.childTnLst->list.push_back(childTimeNode); + } +} + void Timing_1995::FillClickEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { - auto par = new PPTX::Logic::Par; - - FillCTnParams(par->cTn, L"clickEffect", L"0", L"hold", pOldAnim); - - oTimeNodeBase.m_node = par; + FillEffectType(pOldAnim, oTimeNodeBase, L"clickEffect"); } void Timing_1995::FillAfterEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { - const auto& anim = pOldAnim->anim->m_AnimationAtom; - auto par = new PPTX::Logic::Par; - - auto delay = std::to_wstring(anim.m_DelayTime); - - FillCTnParams(par->cTn, L"afterEffect", delay, L"hold", pOldAnim); - // par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed - - oTimeNodeBase.m_node = par; + FillEffectType(pOldAnim, oTimeNodeBase, L"afterEffect"); } void Timing_1995::FillWithEffect(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase) { - const auto& anim = pOldAnim->anim->m_AnimationAtom; + FillEffectType(pOldAnim, oTimeNodeBase, L"withEffect"); +} + +void Timing_1995::FillEffectType(Intermediate::SOldAnimation *pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, std::wstring nodeType) +{ auto par = new PPTX::Logic::Par; - - auto delay = std::to_wstring(anim.m_DelayTime); - - FillCTnParams(par->cTn, L"withEffect", delay, L"hold", pOldAnim); - // par->cTn.childTnLst = new PPTX::Logic::ChildTnLst; bug #52374, was fixed - + FillCTnParams(par->cTn, nodeType, L"0", L"hold", pOldAnim); oTimeNodeBase.m_node = par; - } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h index a398388cc7..2702837932 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_1995.h @@ -25,25 +25,28 @@ private: bool InitAndCheckVars(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); void ConvertBldLst(); void ConvertTnLst(); - PPTX::Logic::Seq *ConvertMainSeqAnimation(); + PPTX::Logic::Seq *ConvertMainSeqAnimation(LstLstAnim& splitedAnim); + LstLstAnim SplitRawAnim(); void InsertMainSeqToTnLst(PPTX::Logic::Seq *mainSeq); PPTX::Logic::Par *InitRootNode(); PPTX::Logic::Seq *InitMainSeq(); - void SplitRawAnim(); void SortAnim(); void FillClickGroup(LstAnim &clickPar, PPTX::Logic::TimeNodeBase &oTimeNodeBase); static LstLstAnim SplitClickGroupByParrallelShow(LstAnim &clickGroup); + void FillFirstAutomaticGroup(PPTX::Logic::CTn &cTn, const CRecordAnimationInfoAtom& animAtom) const; void FillCTnParams(PPTX::Logic::CTn &cTn, std::wstring nodeType, std::wstring condDelay=L"", std::wstring fill=L"hold", Intermediate::SOldAnimation* pOldAnim = nullptr); void ConvertParallelGroupAnimation(LstAnim& parGroup, PPTX::Logic::TimeNodeBase &oTimeNodeBase, _UINT32& groupDelay); static _INT32 GetParallelGroupDuration(LstAnim &parGroup); + void ConvertHeadEfectInParallelShow(const LstAnim& group, PPTX::Logic::CTn &cTn); + void ConvertWithEfectsInParallelShow(const LstAnim& group, PPTX::Logic::CTn &cTn); void FillClickEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); void FillAfterEffect(Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); void FillWithEffect (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase); + void FillEffectType (Intermediate::SOldAnimation* pOldAnim, PPTX::Logic::TimeNodeBase &oTimeNodeBase, std::wstring nodeType); private: std::vector arrOldAnim; - LstLstAnim splitedAnim; Animation_1995* animConverter; PPTX::Logic::Timing* pTiming = nullptr; From 9b5c153e648723b9cab6aa7580b31b81f5ef8511 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 14 Nov 2022 15:56:32 +0300 Subject: [PATCH 11/22] add class Timing_2010 and tag p:BldLst --- .../Converter/Animation/Timing_2010.cpp | 142 ++++++++++++++++++ .../Converter/Animation/Timing_2010.h | 43 ++++++ .../PPTFormatLib/Converter/timing.cpp | 5 +- .../PPTFormatLib/Converter/timing.h | 4 +- .../PPTFormatLib/Converter/transition.cpp | 2 +- .../PPTFormatLib/Linux/PPTFormatLib.pro | 3 + .../PPTFormatLib/PPTXWriter/Converter.cpp | 8 +- .../PPTFormatLib/PPTXWriter/Converter.h | 2 +- .../PPTFormatLib/Reader/Records.cpp | 2 +- .../Records/Animations/BuildListContainer.h | 43 +----- .../Animations/BuildListSubContainer.h | 67 +++++++++ .../Records/Animations/ChartBuildContainer.h | 22 +-- .../Animations/DiagramBuildContainer.h | 20 +-- .../Records/Animations/ParaBuildContainer.h | 50 +++--- 14 files changed, 302 insertions(+), 111 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h create mode 100644 ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListSubContainer.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp new file mode 100644 index 0000000000..4c58f06f0f --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -0,0 +1,142 @@ +#include "Timing_2010.h" + + +namespace PPT { +namespace Converter { + +Timing_2010::Timing_2010(CRecordPP10SlideBinaryTagExtension *pAnim_2010, const std::unordered_set &shapesID) : + pTagExtAnim(pAnim_2010), + slideShapes(shapesID) +{} + +void Timing_2010::Convert(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRelsGenerator *pRels) +{ + ConvertBldLst(timimg.bldLst.get2(), pTagExtAnim->m_pBuildListContainer); +} + +void Timing_2010::ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC) +{ + if (pBLC == nullptr) + return; + + for (IRecord* pDBC : pBLC->m_arRecords) + { + PPTX::Logic::BuildNodeBase oBuildNodeBase; + auto* pSub = dynamic_cast(pDBC); + if (pSub == nullptr) + continue; + if (slideShapes.count(pSub->buildAtom.m_nShapeIdRef) == false) + continue; + + FillBuildNodeBase(pSub, oBuildNodeBase); + } +} + +void Timing_2010::FillBuildNodeBase(CRecordBuildListSubContainer *pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase) +{ + switch (pSub->m_oHeader.RecType) + { + case RT_ParaBuild: + { + auto pBldP = new PPTX::Logic::BldP(); + FillBldP(dynamic_cast(pSub), *pBldP); + + oBuildNodeBase.m_node = pBldP; + break; + } + case RT_ChartBuild: + { + auto pBldOleChart = new PPTX::Logic::BldOleChart(); + FillBldOleChart(dynamic_cast(pSub), *pBldOleChart); + + oBuildNodeBase.m_node = pBldOleChart; + break; + } + case RT_DiagramBuild: + { + auto pBldDgm = new PPTX::Logic::BldDgm(); + FillBldDgm(dynamic_cast(pSub), *pBldDgm); + + oBuildNodeBase.m_node = pBldDgm; + break; + } + default: + break; + } + +} + +void Timing_2010::FillBldP(CRecordParaBuildContainer* pPBC, PPTX::Logic::BldP &oBP) +{ + oBP.spid = std::to_wstring(pPBC->buildAtom.m_nShapeIdRef); + oBP.grpId = (int)pPBC->buildAtom.m_nBuildId; + oBP.uiExpand = pPBC->buildAtom.m_fExpanded; + + oBP.advAuto = std::to_wstring(pPBC->m_oParaBuildAtom.m_nDelayTime); + oBP.animBg = pPBC->m_oParaBuildAtom.m_fAnimBackground; + oBP.rev = pPBC->m_oParaBuildAtom.m_fReverse; + oBP.autoUpdateAnimBg = pPBC->m_oParaBuildAtom.m_fAutomatic; + + std::vector ST_TLParaBuildType = + { + L"allAtOnce", + L"p", + L"cust", + L"whole" + }; + oBP.build = ST_TLParaBuildType[pPBC->m_oParaBuildAtom.m_nParaBuild % 4]; +} + +void Timing_2010::FillBldOleChart(CRecordChartBuildContainer *pCBC, PPTX::Logic::BldOleChart &oBP) +{ + oBP.spid = std::to_wstring(pCBC->buildAtom.m_nShapeIdRef); + oBP.grpId = (int)pCBC->buildAtom.m_nBuildId; + oBP.uiExpand = pCBC->buildAtom.m_fExpanded; + + oBP.animBg = pCBC->m_oChartBuildAtom.m_fAnimBackground; + + std::vector ST_TLOleChartBuildType = + { + L"allAtOnce", + L"series", + L"category", + L"seriesEl", + L"categoryEl" + }; + oBP.bld = ST_TLOleChartBuildType[pCBC->m_oChartBuildAtom.m_ChartBuild % 5]; +} + +void Timing_2010::FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP) +{ + oBP.spid = std::to_wstring(pDBC->buildAtom.m_nShapeIdRef); + oBP.grpId = (int)pDBC->buildAtom.m_nBuildId; + oBP.uiExpand = pDBC->buildAtom.m_fExpanded; + + std::vector ST_TLDiagramBuildType = + { + L"whole", + L"depthByNode", + L"depthByBranch", + L"breadthByNode", + L"breadthByLvl", + L"cw", + L"cwIn", + L"cwOut", + L"ccw", + L"ccwIn", + L"ccwOut", + L"inByRing", + L"outByRing", + L"up", + L"down", + L"allAtOnce", + L"cust" + }; + oBP.bld = ST_TLDiagramBuildType[pDBC->m_oDiagramBuildAtom.m_oDiagramBuild % 17]; +} + + + + +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h new file mode 100644 index 0000000000..f866f5d22e --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -0,0 +1,43 @@ +#pragma once + +#include "../../PPTXWriter/ImageManager.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h" + +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldDgm.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldOleChart.h" + +#include "../../Records/Animations/ParaBuildContainer.h" +#include "../../Records/Animations/ChartBuildContainer.h" +#include "../../Records/Animations/DiagramBuildContainer.h" + +#include "intermediate_anim.h" +//#include + + +namespace PPT { +namespace Converter { +class Animation_2010; + +class Timing_2010 +{ +public: + Timing_2010(CRecordPP10SlideBinaryTagExtension* pAnim_2010, const std::unordered_set& shapesID); + void Convert(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + +private: + void ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC); + void FillBuildNodeBase(CRecordBuildListSubContainer* pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase); + void FillBldP(CRecordParaBuildContainer *pPBC, PPTX::Logic::BldP &oBP); + void FillBldOleChart(CRecordChartBuildContainer* pCBC, PPTX::Logic::BldOleChart &oBP); + void FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP); + +private: + CRecordPP10SlideBinaryTagExtension* pTagExtAnim = nullptr; + const std::unordered_set slideShapes; +}; + +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index dcacbd61ab..6f310122f6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -6,8 +6,9 @@ using namespace PPT::Converter; -Timing::Timing(const Intermediate::SlideAnimation& slideAnim) : - slideAnim(slideAnim) +Timing::Timing(const Intermediate::SlideAnimation& slideAnim, const std::unordered_set &shapesID) : + slideAnim(slideAnim), + shapesID(shapesID) {} PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h index 345e770f8f..dcf4de2724 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h @@ -10,7 +10,7 @@ namespace Converter { class Timing { public: - Timing(const Intermediate::SlideAnimation& slideAnim); + Timing(const Intermediate::SlideAnimation& slideAnim, const std::unordered_set& shapesID); PPTX::Logic::Timing Convert(CExMedia* pExMedia, CRelsGenerator *pRels); bool HasAnimation() const; @@ -19,7 +19,7 @@ private: const Intermediate::SlideAnimation& slideAnim; // CExMedia* pExMedia; // CRelsGenerator* pRels; - + const std::unordered_set shapesID; PPTX::Logic::Timing timing; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/transition.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/transition.cpp index a6a405db21..03f862f728 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/transition.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/transition.cpp @@ -36,7 +36,7 @@ PPTX::Logic::Transition Transition::Convert() void Transition::ConvertClick() { - if (slideShowInfo.m_bAdvClick == false) + if (slideShowInfo.m_bManulClick == false) newTransition.advClick = false; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 31bf7ebfad..bf4f8d1834 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -30,6 +30,7 @@ HEADERS += \ ../Converter/Animation/AnimationParser.h \ ../Converter/Animation/Animation_1995.h \ ../Converter/Animation/Timing_1995.h \ + ../Converter/Animation/Timing_2010.h \ ../Converter/Animation/intermediate_anim.h \ ../Converter/timing.h \ ../Converter/transition.h \ @@ -56,6 +57,7 @@ HEADERS += \ ../Records/Animations/AnimationInfoContainer.h \ ../Records/Animations/BuildAtom.h \ ../Records/Animations/BuildListContainer.h \ + ../Records/Animations/BuildListSubContainer.h \ ../Records/Animations/ChartBuildAtom.h \ ../Records/Animations/ChartBuildContainer.h \ ../Records/Animations/ClientVisualElementContainer.h \ @@ -304,6 +306,7 @@ SOURCES += \ ../Converter/Animation/AnimationParser.cpp \ ../Converter/Animation/Animation_1995.cpp \ ../Converter/Animation/Timing_1995.cpp \ + ../Converter/Animation/Timing_2010.cpp \ ../Converter/Animation/intermediate_anim.cpp \ ../Converter/timing.cpp \ ../Converter/transition.cpp \ diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 062b2f0ea7..50c63c4dd0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -1533,7 +1533,7 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) CGroupElement *pGroupElement = !pSlide->m_arElements.empty() ? dynamic_cast(pSlide->m_arElements[0].get()) : NULL; size_t start_index = 0; - std::unordered_set realShapesId; + std::unordered_set realShapesId; // todo Wrap in context when code is restructured if (pGroupElement) { @@ -1563,7 +1563,7 @@ void PPT_FORMAT::CPPTXWriter::WriteSlide(int nIndexSlide) WriteTransition(oWriter, pSlide->m_oSlideShow); // TODO write new method and class for timing - WriteTiming(oWriter, oRels, nIndexSlide); + WriteTiming(oWriter, oRels, nIndexSlide, realShapesId); oWriter.WriteString(std::wstring(L"")); @@ -1859,12 +1859,12 @@ void CPPTXWriter::WriteLayoutAfterTheme(CThemePtr pTheme, const int nIndexTheme, } -void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide) +void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide, const std::unordered_set& sharesID) { auto slide_iter = m_pUserInfo->m_mapSlides.find(m_pUserInfo->m_arrSlidesOrder[nIndexSlide]); auto intermediateSlideAnimation = PPT::Intermediate::ParseSlideAnimation(slide_iter->second); auto timing = - PPT::Converter::Timing(intermediateSlideAnimation). + PPT::Converter::Timing(intermediateSlideAnimation, sharesID). Convert(&(m_pUserInfo->m_oExMedia), &oRels); oWriter.WriteString(timing.toXML()); } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h index c933d7328b..c54c507553 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h @@ -89,7 +89,7 @@ namespace PPT_FORMAT // void WriteRelsMaster (std::wstring path, int type, ) void WriteSlide (int nIndexSlide); void WriteNotes (int nIndexNotes); - void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide); + void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide, const std::unordered_set& sharesID); void WriteTransition (CStringWriter& oWriter, CSlideShowInfo& oSSInfo); void WriteColorScheme (CStringWriter& oWriter, const std::wstring & name, const std::vector & colors, bool extra = false); diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp index 8c5dcbb4c8..ce3b211669 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/Records.cpp @@ -454,7 +454,7 @@ IRecord* CreateByType(SRecordHeader oHeader) CREATE_BY_TYPE(RT_HashCodeAtom, CRecordHashCode10Atom) CREATE_BY_TYPE(RT_BuildList, CRecordBuildListContainer) CREATE_BY_TYPE(RT_ParaBuild, CRecordParaBuildContainer) - CREATE_BY_TYPE(RT_ChartBuild, CRecordChartBuildContainer) + CREATE_BY_TYPE(RT_ChartBuild, CRecordDiagramBuildAtom) CREATE_BY_TYPE(RT_DiagramBuild, CRecordDiagramBuildContainer) CREATE_BY_TYPE(RT_ParaBuildAtom, CRecordParaBuildAtom) CREATE_BY_TYPE(RT_LevelInfoAtom, CRecordLevelInfoAtom) diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListContainer.h index 416b981342..94ea6e4c0d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListContainer.h @@ -34,51 +34,12 @@ #include "../Reader/Records.h" #include "ParaBuildContainer.h" +#include "BuildListSubContainer.h" namespace PPT_FORMAT { -class CRecordBuildListContainer : public CUnknownRecord +class CRecordBuildListContainer : public CRecordsContainer { -public: - - CRecordBuildListContainer () - { - - } - - virtual ~CRecordBuildListContainer() - { - for ( size_t i = 0; i < n_arrRgChildRec.size(); ++i ) - RELEASEOBJECT (n_arrRgChildRec[i]); - } - - virtual void ReadFromStream ( SRecordHeader & oHeader, POLE::Stream* pStream ) - { - m_oHeader = oHeader; - - LONG lPos(0); StreamUtils::StreamPosition(lPos, pStream); - - _UINT32 lCurLen(0); - SRecordHeader ReadHeader; - - while (lCurLen < m_oHeader.RecLen) { - if ( ReadHeader.ReadFromStream(pStream) == false ) - { - break; - } - - lCurLen += 8 + ReadHeader.RecLen; - - IRecord* pBuildListSubContainer = CreateByType(ReadHeader); - pBuildListSubContainer->ReadFromStream(ReadHeader, pStream); - - n_arrRgChildRec.push_back(pBuildListSubContainer); - } - - StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); - } -public: - std::vector n_arrRgChildRec; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListSubContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListSubContainer.h new file mode 100644 index 0000000000..c82f6daede --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/BuildListSubContainer.h @@ -0,0 +1,67 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +#pragma once + + +#include "../Reader/Records.h" +#include "BuildAtom.h" +#include "ChartBuildAtom.h" + +namespace PPT_FORMAT +{ +class CRecordBuildListSubContainer : public CUnknownRecord +{ +public: + CRecordBuildListSubContainer() + { + + } + + ~CRecordBuildListSubContainer() + { + + } + + virtual void ReadFromStream(SRecordHeader &header, POLE::Stream *pStream) override + { + m_oHeader = header; + + SRecordHeader buildAtomHeader; + if (buildAtomHeader.ReadFromStream(pStream)) + buildAtom.ReadFromStream ( buildAtomHeader, pStream ); + + } + +public: + CRecordBuildAtom buildAtom; +}; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ChartBuildContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ChartBuildContainer.h index fc35e01342..c75d27df9a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ChartBuildContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ChartBuildContainer.h @@ -32,13 +32,11 @@ #pragma once -#include "../Reader/Records.h" -#include "BuildAtom.h" -#include "ChartBuildAtom.h" +#include "BuildListSubContainer.h" namespace PPT_FORMAT { -class CRecordChartBuildContainer : public CUnknownRecord +class CRecordChartBuildContainer : public CRecordBuildListSubContainer { public: CRecordChartBuildContainer() @@ -51,22 +49,16 @@ public: } - void ReadFromStream(SRecordHeader &thisHeader, POLE::Stream *pStream) override + void ReadFromStream(SRecordHeader &header, POLE::Stream *pStream) override { - m_oHeader = thisHeader; - - - SRecordHeader oHeader; - if (oHeader.ReadFromStream(pStream)) - m_oBuildAtom.ReadFromStream ( oHeader, pStream ); - - if (oHeader.ReadFromStream(pStream)) - m_oChartBuildAtom.ReadFromStream ( oHeader, pStream ); + CRecordBuildListSubContainer::ReadFromStream(header, pStream); + SRecordHeader childHeader; + if (childHeader.ReadFromStream(pStream)) + m_oChartBuildAtom.ReadFromStream ( childHeader, pStream ); } public: - CRecordBuildAtom m_oBuildAtom; CRecordChartBuildAtom m_oChartBuildAtom; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/DiagramBuildContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/DiagramBuildContainer.h index b416123fb4..7333b02535 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/DiagramBuildContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/DiagramBuildContainer.h @@ -32,14 +32,13 @@ #pragma once -#include "../Reader/Records.h" -#include "BuildAtom.h" +#include "BuildListSubContainer.h" #include "DiagramBuildAtom.h" namespace PPT_FORMAT { -class CRecordDiagramBuildContainer : public CUnknownRecord +class CRecordDiagramBuildContainer : public CRecordBuildListSubContainer { public: CRecordDiagramBuildContainer() @@ -52,22 +51,17 @@ public: } - void ReadFromStream(SRecordHeader &thisHeader, POLE::Stream *pStream) override + void ReadFromStream(SRecordHeader &header, POLE::Stream *pStream) override { - m_oHeader = thisHeader; + CRecordBuildListSubContainer::ReadFromStream(header, pStream); + SRecordHeader diagramBuildAtomHeader; - SRecordHeader oHeader; - if (oHeader.ReadFromStream(pStream)) - m_oBuildAtom.ReadFromStream ( oHeader, pStream ); - - if (oHeader.ReadFromStream(pStream)) - m_oDiagramBuildAtom.ReadFromStream ( oHeader, pStream ); - + if (diagramBuildAtomHeader.ReadFromStream(pStream)) + m_oDiagramBuildAtom.ReadFromStream (diagramBuildAtomHeader, pStream); } public: - CRecordBuildAtom m_oBuildAtom; CRecordDiagramBuildAtom m_oDiagramBuildAtom; }; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h index a6c2da476c..d7248eb288 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h @@ -32,14 +32,13 @@ #pragma once -#include "../Reader/Records.h" +#include "BuildListSubContainer.h" #include "ParaBuildLevel.h" -#include "BuildAtom.h" #include "ParaBuildAtom.h" namespace PPT_FORMAT { -class CRecordParaBuildContainer : public CUnknownRecord +class CRecordParaBuildContainer : public CRecordBuildListSubContainer { public: @@ -50,49 +49,38 @@ public: virtual ~CRecordParaBuildContainer() { - for ( size_t i = 0; i < m_arrRgParaBuildLevel.size(); ++i ) - RELEASEOBJECT (m_arrRgParaBuildLevel[i]); } - virtual void ReadFromStream ( SRecordHeader & thisHeader, POLE::Stream* pStream ) + virtual void ReadFromStream ( SRecordHeader & header, POLE::Stream* pStream ) override { - m_oHeader = thisHeader; + CRecordBuildListSubContainer::ReadFromStream(header, pStream); LONG lPos(0); StreamUtils::StreamPosition(lPos, pStream); - UINT lCurLen = 0; - SRecordHeader oHeader; -// UINT res = 0; + UINT lCurLen = buildAtom.m_oHeader.RecLen + 8; - if (oHeader.ReadFromStream(pStream)){ - m_oBuildAtom.ReadFromStream ( oHeader, pStream ); - lCurLen += oHeader.RecLen + 8; - } - if (oHeader.ReadFromStream(pStream)) + SRecordHeader paraBuildAtomHeader; + if (paraBuildAtomHeader.ReadFromStream(pStream)) { - m_oParaBuildAtom.ReadFromStream ( oHeader, pStream ); - lCurLen += oHeader.RecLen + 8; + m_oParaBuildAtom.ReadFromStream ( paraBuildAtomHeader, pStream ); + lCurLen += paraBuildAtomHeader.RecLen + 8; } - // TODO may not work + while (lCurLen < m_oHeader.RecLen ) + { + CRecordParaBuildLevel buildLevel; + buildLevel.ReadFromStream(pStream); + rgParaBuildLevel.push_back(buildLevel); - SRecordHeader ReadHeader; - - while ( lCurLen < m_oHeader.RecLen ) { - CRecordParaBuildLevel* pLevel = new CRecordParaBuildLevel(); - pLevel->ReadFromStream(pStream); - - m_arrRgParaBuildLevel.push_back(pLevel); - - lCurLen += pLevel->getRecordLen(); + lCurLen += buildLevel.getRecordLen(); } + StreamUtils::StreamSeek(lPos + m_oHeader.RecLen, pStream); } -public: - CRecordBuildAtom m_oBuildAtom; - CRecordParaBuildAtom m_oParaBuildAtom; - std::vector m_arrRgParaBuildLevel; +public: + CRecordParaBuildAtom m_oParaBuildAtom; + std::vector rgParaBuildLevel; }; } From ed07e856e4890ec644ebc1476739c891b543a31d Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 14 Nov 2022 18:34:00 +0300 Subject: [PATCH 12/22] start Timing_2010 mainSeq convertation --- .../Converter/Animation/Timing_2010.cpp | 346 +++++++++++++++++- .../Converter/Animation/Timing_2010.h | 10 + 2 files changed, 355 insertions(+), 1 deletion(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index 4c58f06f0f..db5bb9c30f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -63,7 +63,6 @@ void Timing_2010::FillBuildNodeBase(CRecordBuildListSubContainer *pSub, PPTX::Lo default: break; } - } void Timing_2010::FillBldP(CRecordParaBuildContainer* pPBC, PPTX::Logic::BldP &oBP) @@ -135,6 +134,351 @@ void Timing_2010::FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::Bl oBP.bld = ST_TLDiagramBuildType[pDBC->m_oDiagramBuildAtom.m_oDiagramBuild % 17]; } +void Timing_2010::ConvertTnLst(PPTX::Logic::TnLst &tnLst, CRecordExtTimeNodeContainer *pETNC) +{ + if (tnLst.list.empty()) + tnLst.list.push_back(PPTX::Logic::TimeNodeBase()); + + FillTnChild(pETNC, tnLst.list.front()); +} + +void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild) +{ + if (pETNC->m_haveSequenceAtom) + { + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Seq; + + FillSeq(pETNC, oChild.m_node.as()); + } + else if (pETNC->m_haveSetBehavior) + { + auto set = new PPTX::Logic::Set; + FillSet(pETNC, *set); + oChild.m_node = set; + } + else if (pETNC->m_haveAnimateBehavior) + { + auto anim = new PPTX::Logic::Anim; + FillAnim(pETNC->m_pTimeAnimateBehavior, *anim); + FillCTn(pETNC, anim->cBhvr.cTn); + oChild.m_node = anim; + } + else if (pETNC->m_haveColorBehavior) + { + auto animClr = new PPTX::Logic::AnimClr; + FillAnimClr(pETNC->m_pTimeColorBehavior, pETNC->m_pTimePropertyList, *animClr); + oChild.m_node = animClr; + } + else if (pETNC->m_haveEffectBehavior) + { + auto animEffect = new PPTX::Logic::AnimEffect; + FillAnimEffect(pETNC, *animEffect); + oChild.m_node = animEffect; + } + else if (pETNC->m_haveMotionBehavior) + { + auto motion = new PPTX::Logic::AnimMotion; + FillAnimMotion(pETNC, *motion); + oChild.m_node = motion; + } + else if (pETNC->m_haveRotationBehavior) + { + auto rot = new PPTX::Logic::AnimRot; + FillAnimRot(pETNC, *rot); + oChild.m_node = rot; + } + else if (pETNC->m_haveScaleBehavior) + { + auto scale = new PPTX::Logic::AnimScale; + FillAnimScale(pETNC, *scale); + oChild.m_node = scale; + } + else if (pETNC->m_haveCommandBehavior) + { + auto cmd = new PPTX::Logic::Cmd; + FillCmd(pETNC, *cmd); + oChild.m_node = cmd; + } + else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) + { + auto par = new PPTX::Logic::Par; + FillPar(pETNC, *par); + oChild.m_node = par; + } + else if (pETNC->m_haveClientVisualElement) + { + if (pETNC->m_pClientVisualElement->m_bVisualPageAtom) + { + + } + if (pETNC->m_pClientVisualElement->m_bVisualShapeAtom) + { + if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Video) + { + auto video = new PPTX::Logic::Video; + FillVideo(pETNC, *video); + oChild.m_node = video; + } + + if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Audio) + { + auto audio = new PPTX::Logic::Audio; + FillAudio(pETNC, *audio); + oChild.m_node = audio; + } + } + } +} + +void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq &oSec) +{ + if (pETNC->m_haveSequenceAtom) + { + if (pETNC->m_pTimeSequenceDataAtom->m_fConcurrencyPropertyUsed) + oSec.concurrent = (bool)pETNC->m_pTimeSequenceDataAtom->m_nConcurrency; + if (pETNC->m_pTimeSequenceDataAtom->m_fNextActionPropertyUsed) + oSec.nextAc = pETNC->m_pTimeSequenceDataAtom->m_nNextAction ? L"seek" : L"none"; + if (pETNC->m_pTimeSequenceDataAtom->m_fPreviousActionPropertyUsed) + oSec.prevAc = pETNC->m_pTimeSequenceDataAtom->m_nPreviousAction ? L"skipTimed" : L"none"; + } + FillCTn(pETNC, oSec.cTn); + + // Fill cond lists + if (!pETNC->m_arrRgEndTimeCondition.empty()) + { + oSec.prevCondLst = new PPTX::Logic::CondLst(); + oSec.prevCondLst->node_name = L"prevCondLst"; + } + for (auto oldCond : pETNC->m_arrRgEndTimeCondition) + { + PPTX::Logic::Cond cond; + cond.node_name = L"cond"; + FillCond(oldCond, cond); + if (m_cTnDeep == 1) + FillEmptyTargetCond(cond); + oSec.prevCondLst->list.push_back(cond); + } + + if (!pETNC->m_arrRgNextTimeCondition.empty()) + { + oSec.nextCondLst = new PPTX::Logic::CondLst(); + oSec.nextCondLst->node_name = L"nextCondLst"; + } + for (auto oldCond : pETNC->m_arrRgNextTimeCondition) + { + PPTX::Logic::Cond cond; + cond.node_name = L"cond"; + FillCond(oldCond, cond); + if (m_cTnDeep == 1) + FillEmptyTargetCond(cond); + oSec.nextCondLst->list.push_back(cond); + } +} + +void Timing_2010::FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ + oCTn.id = m_cTnId++; + m_cTnDeep++; + + // Reading TimeNodeAtom + const auto &oTimeNodeAtom = pETNC->m_oTimeNodeAtom; + + // Write restart + if (oTimeNodeAtom.m_fRestartProperty) + oCTn.restart = PPTX::Limit::TLRestart(oTimeNodeAtom.m_dwRestart) ; + + + // Write fill + if (oTimeNodeAtom.m_fFillProperty) + oCTn.fill = PPTX::Limit::TLNodeFillType(oTimeNodeAtom.m_dwFill); + + // Write dur + if (oTimeNodeAtom.m_fDurationProperty) + { + if (oTimeNodeAtom.m_nDuration == -1) + oCTn.dur = L"indefinite"; + else + oCTn.dur = std::to_wstring(oTimeNodeAtom.m_nDuration); + } + + + //// Write Children //// + + //Write cTn attr + if (pETNC->m_haveTimePropertyList && !pETNC->m_pTimePropertyList->m_bEmtyNode) + { + FillCTn(pETNC->m_pTimePropertyList, oCTn); + } + + if (!pETNC->m_haveSequenceAtom) + { + // Write stCondLst + if (pETNC->m_arrRgBeginTimeCondition.empty() == false) + { + oCTn.stCondLst = new PPTX::Logic::CondLst; + oCTn.stCondLst->node_name = L"stCondLst"; + } + for (auto *oldCond : pETNC->m_arrRgBeginTimeCondition) { + PPTX::Logic::Cond cond; + cond.node_name = L"cond"; + FillCond(oldCond, cond); + oCTn.stCondLst->list.push_back(cond); + } + + + // Write endCondLst + if (pETNC->m_arrRgEndTimeCondition.empty() == false) + { + oCTn.endCondLst = new PPTX::Logic::CondLst; + oCTn.endCondLst->node_name = L"endCondLst"; + FillCondLst(pETNC->m_arrRgEndTimeCondition, oCTn.endCondLst.get2()); + } + } + + + // Write childTnLst + if (pETNC->m_arrRgExtTimeNodeChildren.empty() == false) + { + oCTn.childTnLst = new PPTX::Logic::ChildTnLst; + } + for (auto *oldChild : pETNC->m_arrRgExtTimeNodeChildren) { + PPTX::Logic::TimeNodeBase child; + FillTnChild(oldChild, child); + oCTn.childTnLst->list.push_back(child); + } + + + // Write iterate + if (pETNC->m_haveIterateDataAtom) + { + auto *iter = pETNC->m_pTimeIterateDataAtom; + oCTn.iterate = new PPTX::Logic::Iterate; + + std::wstring type[] = {L"el", L"wd", L"lt"}; + if (iter->m_fIterateTypePropertyUsed) + oCTn.iterate->type = type[iter->m_nIterateType % 3]; + + if (iter->m_fIterateDirectionPropertyUsed) + oCTn.iterate->backwards = (bool)iter->m_nIterateDirection; + + int intervalType = iter->m_fIterateIntervalTypePropertyUsed ? + iter->m_nIterateIntervalType : 0; + uint iterateInterval = iter->m_fIterateIntervalPropertyUsed ? + iter->m_nIterateInterval : 0; + + if (intervalType) + oCTn.iterate->tmPct = iterateInterval > 1000 ? 10000 : iterateInterval * 10; + else + oCTn.iterate->tmAbs = std::to_wstring(iterateInterval); + } + + + // Write endSync + if (pETNC->m_haveTimeEndSyncTime) + { + auto *sync = pETNC->m_pTimeEndSyncTimeCondition; + oCTn.endSync = new PPTX::Logic::Cond; + oCTn.endSync->node_name = L"endSync"; + FillCond(sync, *(oCTn.endSync)); + } + + + // Write subTnLst + if (pETNC->m_arrRgSubEffect.empty() == false) + { + // if ( + // pETNC->m_arrRgSubEffect[0]->m_oTimeNodeAtom.m_fGroupingTypeProperty && + // m_pBldLst && + // m_pPPT10->m_haveBuildList + // ) + // { + // oCTn.grpId = 0; + // auto bldP = new PPTX::Logic::BldP; + // bldP->grpId = 0; + // m_currentBldP = bldP; + // } + + auto sub = new PPTX::Logic::TnLst; + sub->node_name = L"subTnLst"; + FillSubTnLst(pETNC->m_arrRgSubEffect, *sub); + oCTn.subTnLst = sub; + + if (m_currentBldP) + { + PPTX::Logic::BuildNodeBase oBuildNodeBase; + oBuildNodeBase.m_node = m_currentBldP; + m_pBldLst->list.push_back(oBuildNodeBase); + m_currentBldP = nullptr; + } + + for (auto timeModAtom : pETNC->m_arrRgTimeModifierAtom) + { + switch (timeModAtom->m_nType) + { + case 0: + { + oCTn.repeatCount = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 1: + { + // Check 1000 + oCTn.repeatDur = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 2: + { + // Check 1000 + oCTn.spd = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 3: + { + // Check 1000 + oCTn.accel = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 4: + { + // Check 1000 + oCTn.decel = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 5: + { + // Check 1000 + oCTn.autoRev = (bool)timeModAtom->m_Value; + break; + } + + } + } + + } + + // Write stCondLst + if (pETNC->m_arrRgBeginTimeCondition.empty() == false) + { + oCTn.stCondLst = new PPTX::Logic::CondLst; + oCTn.stCondLst->node_name = L"stCondLst"; + FillStCondLst(pETNC->m_arrRgBeginTimeCondition, oCTn.stCondLst.get2()); + } + + if (oCTn.nodeType.IsInit() == false && (m_cTnDeep == 3 || m_cTnDeep == 4)) + { + oCTn.nodeType = new PPTX::Limit::TLNodeType(); + oCTn.nodeType->set( m_cTnDeep == 3 ? L"clickPar" : L"withGroup"); + } + m_cTnDeep--; +} + + diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index f866f5d22e..77e3dbfcf7 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -34,9 +34,19 @@ private: void FillBldOleChart(CRecordChartBuildContainer* pCBC, PPTX::Logic::BldOleChart &oBP); void FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP); + void ConvertTnLst(PPTX::Logic::TnLst& tnLst, CRecordExtTimeNodeContainer* pETNC); + void FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild); + void FillSeq(PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq& oSec); + + void FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + private: CRecordPP10SlideBinaryTagExtension* pTagExtAnim = nullptr; const std::unordered_set slideShapes; + bool isMainSeq = false; + + int m_cTnId = 0; + int m_cTnDeep = 0; }; } From 503f916d54b4a3cca77931fde7cd9b45c2517b77 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 15 Nov 2022 18:54:08 +0300 Subject: [PATCH 13/22] Added raw code base for class Timing_2010 --- .../Converter/Animation/Timing_2010.cpp | 836 ++++++++++++++++++ .../Converter/Animation/Timing_2010.h | 69 +- 2 files changed, 904 insertions(+), 1 deletion(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index db5bb9c30f..5ff0d849eb 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -1,4 +1,6 @@ #include "Timing_2010.h" +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h" +#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h" namespace PPT { @@ -11,6 +13,8 @@ Timing_2010::Timing_2010(CRecordPP10SlideBinaryTagExtension *pAnim_2010, const s void Timing_2010::Convert(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRelsGenerator *pRels) { + m_pExMedia = pExMedia; + m_pRels = pRels; ConvertBldLst(timimg.bldLst.get2(), pTagExtAnim->m_pBuildListContainer); } @@ -276,6 +280,269 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & } } +void Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) +{ + FillCTn(pETNC, oPar.cTn); +} + +void Timing_2010::FillCBhvr(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CBhvr &oBhvr) +{ + CRecordTimeBehaviorContainer *bhvr = nullptr; + if (pETNC->m_haveSetBehavior) + bhvr = &(pETNC->m_pTimeSetBehavior->m_oBehavior); + else if (pETNC->m_haveEffectBehavior) + bhvr = &(pETNC->m_pTimeEffectBehavior->m_oBehavior); + else if (pETNC->m_haveAnimateBehavior) + bhvr = &(pETNC->m_pTimeAnimateBehavior->m_oBehavior); + else if (pETNC->m_haveColorBehavior) + bhvr = &(pETNC->m_pTimeColorBehavior->m_oBehavior); + else if (pETNC->m_haveMotionBehavior) + bhvr = &(pETNC->m_pTimeMotionBehavior->m_oTimeBehavior); + else if (pETNC->m_haveRotationBehavior) + bhvr = &(pETNC->m_pTimeRotationBehavior->m_oBehavior); + else if (pETNC->m_haveScaleBehavior) + bhvr = &(pETNC->m_pTimeScaleBehavior->m_oBehavior); + else + bhvr = &(pETNC->m_pTimeCommandBehavior->m_oBevavior); + + FillCBhvr(bhvr, oBhvr); + FillCTn(pETNC, oBhvr.cTn); +} + +void Timing_2010::FillCBhvr(CRecordTimeBehaviorContainer *pBhvr, PPTX::Logic::CBhvr &oBhvr) +{ + //// Atom //// + + // additive + if (pBhvr->m_oBehaviorAtom.m_bAdditivePropertyUsed) { + oBhvr.additive = new PPTX::Limit::TLAdditive; + oBhvr.additive = pBhvr->m_oBehaviorAtom.m_nBehaviorAdditive ? + L"repl" : L"base"; + } + + // accumulate - MUST be 0 + // xfrmType - MUST be 0 + + if (pBhvr->m_haveStringList) + { + if (!pBhvr->m_pStringList->m_arrRgChildRec.empty()) + { + oBhvr.attrNameLst = new PPTX::Logic::AttrNameLst(); + } + for (const auto &oldAttr : pBhvr->m_pStringList->m_arrRgChildRec) + { + PPTX::Logic::AttrName addAttr; + addAttr.text = oldAttr.m_Value; + oBhvr.attrNameLst->list.push_back(addAttr); + + } + } + + if (pBhvr->m_oClientVisualElement.m_bVisualShapeAtom) + { + UINT spid = pBhvr-> + m_oClientVisualElement. + m_oVisualShapeAtom.m_nObjectIdRef; + + // if (isSpidReal(spid) == false) + // { + // m_isPPT10Broken = true; /// TODO Here. Check with 1995 anim + // } + + oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt(); + oBhvr.tgtEl.spTgt->spid = + std::to_wstring(spid); + if (m_currentBldP) + { + m_currentBldP->spid = + oBhvr.tgtEl.spTgt->spid; + } + if (pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData2 != 0xFFFFFFFF && + pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData1 != 0xFFFFFFFF) + { + oBhvr.tgtEl.spTgt->txEl = new PPTX::Logic::TxEl; + oBhvr.tgtEl.spTgt->txEl->charRg = false; + oBhvr.tgtEl.spTgt->txEl->st = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData1; + oBhvr.tgtEl.spTgt->txEl->end = pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nData2; + } + } + + + if (pBhvr->m_pPropertyList == nullptr) + return; + + for (const auto prop : pBhvr->m_pPropertyList->m_arRecords) + { + if (prop == nullptr) + continue; + + switch (prop->m_oHeader.RecInstance) + { + case TL_TBPID_RuntimeContext: + break; + case TL_TBPID_MotionPathEditRelative: + break; + case TL_TBPID_ColorColorModel: + break; + case TL_TBPID_ColorDirection: + break; + case TL_TBPID_Override: + { + auto override_ = new PPTX::Limit::TLOverride; + override_->set(L"childStyle"); + oBhvr.override_= override_; + break; + } + case TL_TBPID_PathEditRotationAngle: + break; + case TL_TBPID_PathEditRotationX: + break; + case TL_TBPID_PathEditRotationY: + break; + case TL_TBPID_PointsTypes: + break; + case TL_TBPID_UnknownPropertyList: + default: + break; + } + } +} + +void Timing_2010::FillCBhvr(PPTX::Logic::CBhvr &oBhvr, int dur, UINT spid, std::wstring attrname, int delay) +{ + oBhvr.cTn.id = m_cTnId++; + oBhvr.cTn.fill = L"hold"; + oBhvr.cTn.dur = std::to_wstring(dur); + if (delay > -1) + { + oBhvr.cTn.stCondLst = new PPTX::Logic::CondLst; + oBhvr.cTn.stCondLst->node_name = L"stCondLst"; + PPTX::Logic::Cond cond; + cond.delay = std::to_wstring(delay); + oBhvr.cTn.stCondLst->list.push_back(cond); + } + + oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt; + oBhvr.tgtEl.spTgt->spid = std::to_wstring(spid); + + if (!attrname.empty()) + { + oBhvr.attrNameLst = new PPTX::Logic::AttrNameLst; + PPTX::Logic::AttrName attrName; + attrName.text = attrname; + oBhvr.attrNameLst->list.push_back(attrName); + } +} + +void Timing_2010::FillSet(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Set &oSet) +{ + if (!pETNC->m_haveSetBehavior) + return; + + FillCBhvr(pETNC, oSet.cBhvr); + oSet.to = new PPTX::Logic::AnimVariant(); + oSet.to->node_name = L"to"; + oSet.to->strVal = pETNC->m_pTimeSetBehavior->m_oVarTo.m_Value; +} + +void Timing_2010::FillAnim(CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, PPTX::Logic::Anim &oAnim) +{ + if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bCalcModePropertyUsed) + { + std::wstring calcmode; + switch (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_nCalcMode) { + case 0: calcmode = L"discrete"; break; + case 1: calcmode = L"lin"; break; + case 2: calcmode = L"fmla"; break; + } + oAnim.calcmode = new PPTX::Limit::TLCalcMode; + oAnim.calcmode = calcmode; + } + + if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bValueTypePropertyUsed) + { + std::wstring valueType; + switch (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_ValueType) { + case TL_TABVT_Color: valueType = L"Color"; break; + case TL_TABVT_Number: valueType = L"Number"; break; + case TL_TABVT_String: valueType = L"String"; break; + } + if (!valueType.empty()) + { + oAnim.valueType = new PPTX::Limit::TLValueType; + oAnim.valueType = valueType; + } + } + + // By + if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bByPropertyUsed) + { + oAnim.by = pTimeAnimateBehavior->m_oVarBy.m_Value; + } + // To + if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bToPropertyUsed) + { + oAnim.to = pTimeAnimateBehavior->m_oVarTo.m_Value; + } + //From + if (pTimeAnimateBehavior->m_oAnimateBehaviorAtom.m_bFromPropertyUsed) + { + oAnim.from = pTimeAnimateBehavior->m_oVarFrom.m_Value; + } + + //// Writing childs + + if (!pTimeAnimateBehavior->m_oAnimateValueList.m_arrEntry.empty()) + oAnim.tavLst = new PPTX::Logic::TavLst; + for (auto &animValue : pTimeAnimateBehavior->m_oAnimateValueList.m_arrEntry) + { + PPTX::Logic::Tav tav; + tav.val = new PPTX::Logic::AnimVariant; + + tav.val->node_name = L"val"; + + if (animValue->m_pVarValue.is_init()) + switch (animValue->m_pVarValue->m_Type) { + case TL_TVT_String: + { + tav.val->strVal = dynamic_cast + (animValue->m_pVarValue.get()).m_Value; + break; + } + case TL_TVT_Bool: + { + tav.val->boolVal = dynamic_cast + (animValue->m_pVarValue.get()).m_Value; + break; + } + case TL_TVT_Int: + { + tav.val->intVal = dynamic_cast + (animValue->m_pVarValue.get()).m_Value; + break; + } + case TL_TVT_Float: + { + tav.val->fltVal = dynamic_cast + (animValue->m_pVarValue.get()).m_Value; + break; + } + } + + auto tavTime = animValue->m_oTimeAnimationValueAtom.m_nTime; + if (tavTime <= 1000 && tavTime >= 0) // todo check + tav.tm = std::to_wstring((/*1000 - */tavTime) * 100); + + if (!animValue->m_VarFormula.m_Value.empty()) + { + tav.fmla = animValue->m_VarFormula.m_Value; + } + + oAnim.tavLst->list.push_back(tav); + } + FillCBhvr(&(pTimeAnimateBehavior->m_oBehavior), oAnim.cBhvr); +} + void Timing_2010::FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) { oCTn.id = m_cTnId++; @@ -478,7 +745,576 @@ void Timing_2010::FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn & m_cTnDeep--; } +void Timing_2010::FillCond(CRecordTimeConditionContainer *oldCond, PPTX::Logic::Cond &cond) +{ + if (oldCond->m_oTimeConditionAtom.m_nTimeDelay != -1) + cond.delay = std::to_wstring(oldCond->m_oTimeConditionAtom.m_nTimeDelay); + else + cond.delay = L"indefinite"; + // if (oldCond->m_oTimeConditionAtom.m_TriggerObject == TL_TOT_RuntimeNodeRef || + // oldCond->m_oTimeConditionAtom.m_TriggerObject == TL_TOT_TimeNode) + // { + // cond.tn = oldCond->m_oTimeConditionAtom.m_nID; + // } + + if (oldCond->m_oTimeConditionAtom.m_TriggerObject == TL_TOT_RuntimeNodeRef) + { + cond.rtn = new PPTX::Limit::TLRuntimeTrigger; + cond.rtn->SetBYTECode(0); + } + + std::wstring str; + + switch (oldCond->m_oTimeConditionAtom.m_nTriggerEvent) + { + case 1: str = L"onBegin"; break; + case 3: str = L"begin"; break; + case 4: str = L"end"; break; + case 5: str = L"onClick"; break; + case 7: str = L"onMouseOver"; break; + case 9: str = L"onNext"; break; + case 10: str = L"onPrev"; break; + case 11: str = L"onStopAudio"; break; + default: str.clear(); + } + + if (!str.empty()) cond.evt = str; + + if (oldCond->m_oVisualElement.m_bVisualShapeAtom) + { + cond.tgtEl = new PPTX::Logic::TgtEl; + cond.tgtEl->spTgt = new PPTX::Logic::SpTgt; + cond.tgtEl->spTgt->spid = std::to_wstring( + oldCond->m_oVisualElement.m_oVisualShapeAtom.m_nObjectIdRef); + } else if (oldCond->m_oVisualElement.m_bVisualPageAtom) + { + cond.tgtEl = new PPTX::Logic::TgtEl; + } +} + +void Timing_2010::FillStCondLst(const std::vector &timeCondCont, PPTX::Logic::CondLst &stCondLst) +{ + for (const auto& pCond : timeCondCont) + { + int target = -1; + if (pCond->m_oVisualElement.m_bVisualShapeAtom) + target = pCond->m_oVisualElement.m_oVisualShapeAtom.m_nObjectIdRef; + + PPTX::Logic::Cond cond; + FillCond(pCond, cond); + + stCondLst.list.push_back(cond); + } +} + +void Timing_2010::FillSubTnLst(std::vector &vecSEC, PPTX::Logic::TnLst &oSubTnLst) +{ + for (auto pSEC : vecSEC) + { + if (pSEC->m_haveClientVisualElement) + { + PPTX::Logic::TimeNodeBase TNB; + auto audio = new PPTX::Logic::Audio; + + FillAudio(pSEC->m_pClientVisualElement, *audio); + TNB.m_node = audio; + oSubTnLst.list.push_back(TNB); + + // Write endCondLst + if (pSEC->m_arrRgEndTimeCondition.empty() == false) + { + audio->cMediaNode.cTn.endCondLst = new PPTX::Logic::CondLst; + audio->cMediaNode.cTn.endCondLst->node_name = L"endCondLst"; + } + FillCondLst(pSEC->m_arrRgEndTimeCondition, + audio->cMediaNode.cTn.endCondLst.get2()); + + // Write stCondLst + if (pSEC->m_arrRgBeginTimeCondition.empty() == false) + { + audio->cMediaNode.cTn.stCondLst = new PPTX::Logic::CondLst; + audio->cMediaNode.cTn.stCondLst->node_name = L"stCondLst"; + } + FillCondLst(pSEC->m_arrRgBeginTimeCondition, + audio->cMediaNode.cTn.stCondLst.get2()); + FillCTn(pSEC->m_pTimePropertyList, audio->cMediaNode.cTn); + } + + if (pSEC->m_haveColorBehavior) + { + PPTX::Logic::TimeNodeBase TNB; + auto color = new PPTX::Logic::AnimClr; + + FillAnimClr(pSEC->m_pTimeColorBehavior, pSEC->m_pTimePropertyList, *color); + TNB.m_node = color; + oSubTnLst.list.push_back(TNB); + } + } +} + +void Timing_2010::FillAudio(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Audio &oAudio) +{ + auto* pCVEC = pETNC->m_pClientVisualElement; + if (pCVEC->m_bVisualShapeAtom && m_pRels) + { + CExFilesInfo* pInfo1 = m_pExMedia->LockAudioFromCollection(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); + if (pInfo1) + { + bool bExternal(false); + oAudio.cMediaNode.tgtEl.embed = + new OOX::RId(m_pRels->WriteAudio(pInfo1->m_strFilePath, bExternal)); + oAudio.cMediaNode.tgtEl.name = XmlUtils::EncodeXmlString(pInfo1->m_name); + } else if (pCVEC->m_oVisualShapeAtom.m_RefType == TL_ET_ShapeType) + { + oAudio.cMediaNode.tgtEl.spTgt = new PPTX::Logic::SpTgt; + oAudio.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); + // oAudio.isNarration = true; + // oAudio.cMediaNode.showWhenStopped = false; + } else + return; + FillCTn(pETNC, oAudio.cMediaNode.cTn); + } +} + +void Timing_2010::FillAudio(CRecordClientVisualElementContainer *pCVEC, PPTX::Logic::Audio &oAudio) +{ + if (pCVEC->m_bVisualShapeAtom) + { + CExFilesInfo* pInfo1 = m_pExMedia->LockAudioFromCollection(pCVEC->m_oVisualShapeAtom.m_nObjectIdRef); + if (pInfo1 && m_pRels) + { + bool bExternal(false); + oAudio.cMediaNode.tgtEl.embed = + new OOX::RId(m_pRels->WriteAudio(pInfo1->m_strFilePath, bExternal)); + oAudio.cMediaNode.tgtEl.name = XmlUtils::EncodeXmlString(pInfo1->m_name); + } + } +} + +void Timing_2010::FillCmd(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Cmd &oCmd) +{ + if (!pETNC || !pETNC->m_pTimeCommandBehavior) + return; + + auto pCommand = pETNC->m_pTimeCommandBehavior; + auto oAtom = pCommand->m_oCommandBehaviorAtom; + + FillCBhvr(pETNC, oCmd.cBhvr); + + if (oAtom.m_fTypePropertyUsed) + { + oCmd.type = new PPTX::Limit::TLCommandType; + std::wstring type; + switch (oAtom.m_eCommandBehaviorType) + { + case TL_TCBT_Eventv: type = L"evt"; break; + case TL_TCBT_Call: type = L"call"; break; + case TL_TCBT_OleVerb: type = L"verb"; break; + } + oCmd.type->set(type); + } + if (oAtom.m_fCommandPropertyUsed) + { + oCmd.cmd = pCommand->m_oVarCommand.m_Value; + } +} + +void Timing_2010::FillCondLst(std::vector &oCondVec, PPTX::Logic::CondLst &oCondLst) +{ + for (auto *oldCond : oCondVec) { + PPTX::Logic::Cond cond; + cond.node_name = L"cond"; + FillCond(oldCond, cond); + oCondLst.list.push_back(cond); + } +} + +void Timing_2010::FillEmptyTargetCond(PPTX::Logic::Cond &cond) +{ + cond.tgtEl = new PPTX::Logic::TgtEl; +} + +void Timing_2010::FillCTn(CRecordTimePropertyList4TimeNodeContainer *pProp, PPTX::Logic::CTn &oCTn) +{ + if (pProp && !pProp->m_bEmtyNode) + { + for (auto *pRec : pProp->m_arrElements) + { + TimePropertyID4TimeNode VariableType = ( TimePropertyID4TimeNode ) pRec->m_oHeader.RecInstance; + + switch ( VariableType ) + { + case TL_TPID_Display: + { + oCTn.display = !(bool)dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_MasterPos: + { + oCTn.masterRel = new PPTX::Limit::TLMasterRelation; + oCTn.masterRel = dynamic_cast(pRec)->m_Value ? + L"nextClick" : L"sameClick"; + break; + } + case TL_TPID_SubType: break; + case TL_TPID_EffectID: + { + oCTn.presetID = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EffectDir: + { + oCTn.presetSubtype = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EffectType: + { + // Write presetClass + std::wstring presetClass; + switch (dynamic_cast(pRec)->m_Value) { + case 0: break; + case 1: presetClass = L"entr"; break; + case 2: presetClass = L"exit"; break; + case 3: presetClass = L"emph"; break; + case 4: presetClass = L"path"; break; + case 5: presetClass = L"verb"; break; + case 6: presetClass = L"mediacall"; break; + } + if (!presetClass.empty()) + { + oCTn.presetClass = new PPTX::Limit::TLPresetClass; + oCTn.presetClass = presetClass; + } + break; + } + case TL_TPID_AfterEffect: + { + oCTn.afterEffect = (bool)dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_SlideCount: break; + case TL_TPID_TimeFilter: + { + oCTn.tmFilter = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EventFilter: + { + oCTn.evtFilter = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_HideWhenStopped: break; + case TL_TPID_GroupID: + { + oCTn.grpId = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EffectNodeType: + { + // Write nodeType + std::wstring nodeType; + switch (dynamic_cast(pRec)->m_Value) + { + case 1: nodeType = L"clickEffect"; break; + case 2: nodeType = L"withEffect"; break; + case 3: nodeType = L"afterEffect"; break; + case 4: nodeType = L"mainSeq"; break; + case 5: nodeType = L"interactiveSeq"; break; + case 6: nodeType = L"clickPar"; break; + case 7: nodeType = L"withGroup"; break; + case 8: nodeType = L"afterGroup"; break; + case 9: nodeType = L"tmRoot"; break; + } + if (!nodeType.empty()) + { + oCTn.nodeType = new PPTX::Limit::TLNodeType; + oCTn.nodeType = nodeType; + } + + break; + } + case TL_TPID_PlaceholderNode: + { + oCTn.nodePh = (bool)dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_MediaVolume: break; + case TL_TPID_MediaMute: break; + case TL_TPID_ZoomToFullScreen: break; + default : + break; + } + } + } +} + +void Timing_2010::FillAnimClr( + CRecordTimeColorBehaviorContainer *pColor, + CRecordTimePropertyList4TimeNodeContainer *pProp, + PPTX::Logic::AnimClr &oAnimClr) +{ + auto &clrAtom = pColor->m_oColorBehaviorAtom; + + FillCBhvr(&(pColor->m_oBehavior), oAnimClr.cBhvr); + FillCTn(pProp, oAnimClr.cBhvr.cTn); + + // Write Attributes + if (pColor->m_oBehavior.m_havePropertyList){ + for (auto pRec : pColor->m_oBehavior.m_pPropertyList->m_arRecords) + { + if (pRec->m_oHeader.RecInstance == TL_TBPID_ColorColorModel) + { + auto oTimeColorModel = dynamic_cast(pRec); + oAnimClr.clrSpc = new PPTX::Limit::TLColorSpace; + std::wstring clrSpc; + if (!clrAtom.m_fColorSpacePropertyUsed) clrSpc = L"rgb"; + else clrSpc = oTimeColorModel->m_Value ? L"hsl" : L"rgb"; + oAnimClr.clrSpc = clrSpc; + } + else if (pRec->m_oHeader.RecInstance == TL_TBPID_ColorDirection) + { + auto oTimeColorDirection = dynamic_cast(pRec); + oAnimClr.dir = new PPTX::Limit::TLColorDirection; + std::wstring dir; + if (!clrAtom.m_fDirectionPropertyUsed) dir = L"cw"; + else dir = oTimeColorDirection->m_Value ? L"ccw" : L"cw"; + oAnimClr.dir = dir; + } + } + } + + if (clrAtom.m_fByPropertyUsed) + { + if (clrAtom.m_sColorBy.model == 0) // RGB == 0 + { + oAnimClr.byR = clrAtom.m_sColorBy.component0; + oAnimClr.byG = clrAtom.m_sColorBy.component1; + oAnimClr.byB = clrAtom.m_sColorBy.component2; + } + else if (clrAtom.m_sColorBy.model == 1) // HSL == 1 + { + oAnimClr.byH = clrAtom.m_sColorBy.component0; + oAnimClr.byS = clrAtom.m_sColorBy.component1; + oAnimClr.byL = clrAtom.m_sColorBy.component2; + } + } + + if (clrAtom.m_fFromPropertyUsed) + { + oAnimClr.from = *new PPTX::Logic::UniColor; + if (clrAtom.m_sColorFrom.model == 0) + { + auto pSrgb = new PPTX::Logic::SrgbClr; + pSrgb->red = clrAtom.m_sColorFrom.component0; + pSrgb->green = clrAtom.m_sColorFrom.component1; + pSrgb->blue = clrAtom.m_sColorFrom.component2; + oAnimClr.from.Color = pSrgb; + } + else + { + auto pScheme = new PPTX::Logic::SchemeClr; + std::wstring strVal; + UINT index = clrAtom.m_sColorFrom.component0; + if (index >= 4 && index < 10) + { + strVal = L"accent" + std::to_wstring(index - 3); + } + pScheme->val = strVal; + oAnimClr.from.Color = pScheme; + } + } + + if (clrAtom.m_fToPropertyUsed) + { + oAnimClr.to = *new PPTX::Logic::UniColor; + if (clrAtom.m_sColorTo.model == 0) + { + auto pSrgb = new PPTX::Logic::SrgbClr; + pSrgb->red = clrAtom.m_sColorTo.component0; + pSrgb->green = clrAtom.m_sColorTo.component1; + pSrgb->blue = clrAtom.m_sColorTo.component2; + oAnimClr.to.Color = pSrgb; + } + else + { + auto pScheme = new PPTX::Logic::SchemeClr; + std::wstring strVal; + UINT index = clrAtom.m_sColorTo.component0; + if (index >= 4 && index < 10) + { + strVal = L"accent" + std::to_wstring(index - 3); + } + pScheme->val = strVal; + oAnimClr.to.Color = pScheme; + } + } +} + +void Timing_2010::FillAnimEffect( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimEffect &oAnim) +{ + auto *bhvr = pETNC->m_pTimeEffectBehavior; + oAnim.filter = bhvr->m_oVarType.m_Value; + + if (bhvr->m_effectBehaviorAtom.m_bProgressPropertyUsed) + { + if (!oAnim.progress.is_init()) + oAnim.progress = new PPTX::Logic::AnimVariant; + oAnim.progress->fltVal = bhvr->m_oVarProgress.m_Value; + } + + if (bhvr->m_effectBehaviorAtom.m_bRuntimeContextObsolete) + { + if (!oAnim.progress.is_init()) + oAnim.progress = new PPTX::Logic::AnimVariant; + oAnim.progress->strVal = bhvr->m_oVarRuntimeContext.m_Value; + } + + if (bhvr->m_effectBehaviorAtom.m_bTransitionPropertyUsed) + { + oAnim.transition = bhvr->m_effectBehaviorAtom.m_nEffectTransition ? + L"out" : L"in"; + } + + FillCBhvr(pETNC, oAnim.cBhvr); + +} + +void Timing_2010::FillAnimMotion( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimMotion &oAnim) +{ + if (!pETNC || !pETNC->m_pTimeMotionBehavior) + return; + + auto pMotion = pETNC->m_pTimeMotionBehavior; + auto oAtom = pMotion->m_oMotionBehaviorAtom; + + FillCBhvr(pETNC, oAnim.cBhvr); + + if (oAtom.m_bFromPropertyUsed) + { + oAnim.fromX = oAtom.m_nXFROM; + oAnim.fromY = oAtom.m_nYFROM; + } + if (oAtom.m_bToPropertyUsed) + { + oAnim.toX = oAtom.m_nXTO; + oAnim.toY = oAtom.m_nYTO; + } + if (oAtom.m_bByPropertyUsed) + { + oAnim.byX = oAtom.m_nXBY; + oAnim.byY = oAtom.m_nYBY; + } + + if (oAtom.m_bOriginPropertyUsed) + { + oAnim.origin = new PPTX::Limit::TLOrigin; + oAnim.origin->set(oAtom.m_nBehaviorOrigin == 2 ? + L"layout" : L"parent"); + } + + if (!pMotion->m_pVarPath->m_Value.empty()) + oAnim.path = pMotion->m_pVarPath->m_Value; + + // oAnim.ptsTypes + + + oAnim.pathEditMode = new PPTX::Limit::TLPathEditMode; + oAnim.pathEditMode->set(oAtom.m_bEditRotationPropertyUsed ? L"fixed" : L"relative"); +} + +void Timing_2010::FillAnimRot( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimRot &oAnim) +{ + if (!pETNC || !pETNC->m_pTimeRotationBehavior) return; + + auto pRot = pETNC->m_pTimeRotationBehavior; + auto oAtom = pRot->m_oRotationBehaviorAtom; + + FillCBhvr(pETNC, oAnim.cBhvr); + + const auto mult = 60000; + + if (oAtom.m_fByPropertyUsed) + oAnim.by = oAtom.m_By *mult; + if (oAtom.m_fToPropertyUsed) + oAnim.to = oAtom.m_To *mult; + if (oAtom.m_fFromPropertyUsed) + oAnim.from = oAtom.m_From *mult; + +} + +void Timing_2010::FillAnimScale( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimScale &oAnim) +{ + if (!pETNC || !pETNC->m_pTimeScaleBehavior) return; + + auto pScale = pETNC->m_pTimeScaleBehavior; + auto oAtom = pScale->m_oScaleBehaviorAtom; + + FillCBhvr(pETNC, oAnim.cBhvr); + + const auto mult = 1000; + if (oAtom.m_fByPropertyUsed) + { + oAnim.byX = oAtom.m_XBy *mult; + oAnim.byY = oAtom.m_YBy *mult; + } + if (oAtom.m_fToPropertyUsed) + { + oAnim.toX = oAtom.m_XTo *mult; + oAnim.toY = oAtom.m_YTo *mult; + } + if (oAtom.m_fFromPropertyUsed) + { + oAnim.fromX = oAtom.m_XFrom *mult; + oAnim.fromY = oAtom.m_YFrom *mult; + } + + if (oAtom.m_fZoomContentsUsed) + oAnim.zoomContents = oAtom.m_fZoomContents; +} + + + +void Timing_2010::FillVideo( + CRecordExtTimeNodeContainer* pETNC, + PPTX::Logic::Video& oVideo) +{ + auto video = pETNC->m_pClientVisualElement->m_oVisualShapeAtom; + + FillCTn(pETNC, oVideo.cMediaNode.cTn); + + if (pETNC->m_pTimePropertyList->m_arrElements.size() >= 5) + { + try { + oVideo.cMediaNode.vol = (int)(static_cast + (pETNC->m_pTimePropertyList->m_arrElements[1])-> + m_Value * 100000); + oVideo.cMediaNode.mute = static_cast + (pETNC->m_pTimePropertyList->m_arrElements[2])-> + m_Value; + oVideo.fullScrn = static_cast + (pETNC->m_pTimePropertyList->m_arrElements[3])-> + m_Value; + oVideo.cMediaNode.showWhenStopped = static_cast + (pETNC->m_pTimePropertyList->m_arrElements[4])-> + m_Value; + } catch (...) { + + } + } + + + oVideo.cMediaNode.tgtEl.spTgt = PPTX::Logic::SpTgt(); + oVideo.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(video.m_nObjectIdRef); +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index 77e3dbfcf7..e6f330d98c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -4,6 +4,16 @@ #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Timing.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Par.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Seq.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Audio.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimClr.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimEffect.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimMotion.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimRot.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/AnimScale.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Cmd.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Video.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Anim.h" +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/Set.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldP.h" #include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/BldDgm.h" @@ -13,7 +23,7 @@ #include "../../Records/Animations/ChartBuildContainer.h" #include "../../Records/Animations/DiagramBuildContainer.h" -#include "intermediate_anim.h" +#include "intermediate_anim.h" // it using //#include @@ -37,14 +47,71 @@ private: void ConvertTnLst(PPTX::Logic::TnLst& tnLst, CRecordExtTimeNodeContainer* pETNC); void FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild); void FillSeq(PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq& oSec); + void FillPar( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Par &oPar); + void FillCBhvr( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::CBhvr &oBhvr); + void FillCBhvr( + CRecordTimeBehaviorContainer *pBhvr, + PPTX::Logic::CBhvr &oBhvr); + void FillCBhvr( + PPTX::Logic::CBhvr &oBhvr, int dur, + UINT spid, std::wstring attrname, int delay); + void FillSet( + PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Set& oSet); + void FillAnim( + CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, + PPTX::Logic::Anim &oAnim); void FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void FillCond(PPT_FORMAT::CRecordTimeConditionContainer *oldCond, PPTX::Logic::Cond &cond); + void FillStCondLst(const std::vector& timeCondCont, PPTX::Logic::CondLst& stCondLst); + void FillSubTnLst (std::vector &vecSEC, PPTX::Logic::TnLst &oSubTnLst); + void FillCondLst(std::vector& oCondVec, PPTX::Logic::CondLst &oCondLst); + void FillEmptyTargetCond(PPTX::Logic::Cond &cond); + void FillCTn(CRecordTimePropertyList4TimeNodeContainer *pProp, PPTX::Logic::CTn &oCTn); + + + void FillAnimClr( + CRecordTimeColorBehaviorContainer *pColor, + CRecordTimePropertyList4TimeNodeContainer *pProp, + PPTX::Logic::AnimClr &oAnimClr); + void FillAnimEffect( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimEffect &oAnim); + void FillAnimMotion( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimMotion &oAnim); + void FillAnimRot( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimRot &oAnim); + void FillAnimScale( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::AnimScale &oAnim); + void FillAudio(CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Audio &oAudio); + void FillAudio(CRecordClientVisualElementContainer *pCVEC, + PPTX::Logic::Audio &oAudio); + void FillCmd( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Cmd &oCmd); + void FillVideo( + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Video &oVideo); private: CRecordPP10SlideBinaryTagExtension* pTagExtAnim = nullptr; const std::unordered_set slideShapes; + CExMedia *m_pExMedia = nullptr; + CRelsGenerator *m_pRels = nullptr; bool isMainSeq = false; + PPTX::Logic::BldLst *m_pBldLst = nullptr; // Do not delete + PPTX::Logic::BldP *m_currentBldP = nullptr; + int m_cTnId = 0; int m_cTnDeep = 0; }; From 13c6b18c3fbc9d5588d756bcf7e77cdb48f344e7 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 16 Nov 2022 13:13:05 +0300 Subject: [PATCH 14/22] Include Timing_2010.Convert(), no anim correction --- .../Converter/Animation/Timing_2010.cpp | 86 +++++++++++-------- .../PPTFormatLib/Converter/timing.cpp | 4 + 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index 5ff0d849eb..ccbb7ce18c 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -15,7 +15,9 @@ void Timing_2010::Convert(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRels { m_pExMedia = pExMedia; m_pRels = pRels; + ConvertBldLst(timimg.bldLst.get2(), pTagExtAnim->m_pBuildListContainer); + ConvertTnLst(timimg.tnLst.get2(), pTagExtAnim->m_pExtTimeNodeContainer); } void Timing_2010::ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC) @@ -157,58 +159,68 @@ void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T } else if (pETNC->m_haveSetBehavior) { - auto set = new PPTX::Logic::Set; - FillSet(pETNC, *set); - oChild.m_node = set; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Set; + + FillSet(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveAnimateBehavior) { - auto anim = new PPTX::Logic::Anim; - FillAnim(pETNC->m_pTimeAnimateBehavior, *anim); - FillCTn(pETNC, anim->cBhvr.cTn); - oChild.m_node = anim; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Anim; + auto& anim = oChild.m_node.as(); + + FillAnim(pETNC->m_pTimeAnimateBehavior, anim); + FillCTn(pETNC, anim.cBhvr.cTn); } else if (pETNC->m_haveColorBehavior) { - auto animClr = new PPTX::Logic::AnimClr; - FillAnimClr(pETNC->m_pTimeColorBehavior, pETNC->m_pTimePropertyList, *animClr); - oChild.m_node = animClr; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::AnimClr; + + FillAnimClr(pETNC->m_pTimeColorBehavior, pETNC->m_pTimePropertyList, oChild.m_node.as()); } else if (pETNC->m_haveEffectBehavior) { - auto animEffect = new PPTX::Logic::AnimEffect; - FillAnimEffect(pETNC, *animEffect); - oChild.m_node = animEffect; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::AnimEffect; + + FillAnimEffect(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveMotionBehavior) { - auto motion = new PPTX::Logic::AnimMotion; - FillAnimMotion(pETNC, *motion); - oChild.m_node = motion; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::AnimMotion; + + FillAnimMotion(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveRotationBehavior) { - auto rot = new PPTX::Logic::AnimRot; - FillAnimRot(pETNC, *rot); - oChild.m_node = rot; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::AnimRot; + + FillAnimRot(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveScaleBehavior) { - auto scale = new PPTX::Logic::AnimScale; - FillAnimScale(pETNC, *scale); - oChild.m_node = scale; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::AnimScale; + + FillAnimScale(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveCommandBehavior) { - auto cmd = new PPTX::Logic::Cmd; - FillCmd(pETNC, *cmd); - oChild.m_node = cmd; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Cmd; + + FillCmd(pETNC, oChild.m_node.as()); } else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) { - auto par = new PPTX::Logic::Par; - FillPar(pETNC, *par); - oChild.m_node = par; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Par; + + FillPar(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveClientVisualElement) { @@ -220,16 +232,18 @@ void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T { if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Video) { - auto video = new PPTX::Logic::Video; - FillVideo(pETNC, *video); - oChild.m_node = video; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Video; + + FillVideo(pETNC, oChild.m_node.as()); } if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Audio) { - auto audio = new PPTX::Logic::Audio; - FillAudio(pETNC, *audio); - oChild.m_node = audio; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Audio; + + FillAudio(pETNC, oChild.m_node.as()); } } } @@ -577,6 +591,9 @@ void Timing_2010::FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn & { FillCTn(pETNC->m_pTimePropertyList, oCTn); } + if (m_cTnDeep == 2) + isMainSeq = oCTn.nodeType.get_value_or(L"") == L"mainSeq"; + if (!pETNC->m_haveSequenceAtom) { @@ -742,6 +759,7 @@ void Timing_2010::FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn & oCTn.nodeType = new PPTX::Limit::TLNodeType(); oCTn.nodeType->set( m_cTnDeep == 3 ? L"clickPar" : L"withGroup"); } + m_cTnDeep--; } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index 6f310122f6..8ac74b71ec 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -2,6 +2,7 @@ #include "Animation/intermediate_anim.h" #include "Animation/Timing_1995.h" +#include "Animation/Timing_2010.h" using namespace PPT::Converter; @@ -18,5 +19,8 @@ PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) Timing_1995(slideAnim.arrAnim_1995). Convert(timing, pExMedia, pRels); + Timing_2010(slideAnim.pAnim_2010, shapesID). + Convert(timing, pExMedia, pRels); + return std::move(timing); } From cc7644bc36f19faf2b7c5053418157fbec68553f Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Wed, 16 Nov 2022 18:56:01 +0300 Subject: [PATCH 15/22] Timing_2010 restructed to control converter of animation --- .../Converter/Animation/Timing_2010.cpp | 614 +++++++++--------- .../Converter/Animation/Timing_2010.h | 29 +- 2 files changed, 342 insertions(+), 301 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index ccbb7ce18c..7e22f042d0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -145,7 +145,7 @@ void Timing_2010::ConvertTnLst(PPTX::Logic::TnLst &tnLst, CRecordExtTimeNodeCont if (tnLst.list.empty()) tnLst.list.push_back(PPTX::Logic::TimeNodeBase()); - FillTnChild(pETNC, tnLst.list.front()); + FillTnChild(pETNC, tnLst.list.back()); } void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild) @@ -171,7 +171,7 @@ void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T auto& anim = oChild.m_node.as(); FillAnim(pETNC->m_pTimeAnimateBehavior, anim); - FillCTn(pETNC, anim.cBhvr.cTn); + FillCTnRecursive(pETNC, anim.cBhvr.cTn); } else if (pETNC->m_haveColorBehavior) { @@ -260,7 +260,7 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & if (pETNC->m_pTimeSequenceDataAtom->m_fPreviousActionPropertyUsed) oSec.prevAc = pETNC->m_pTimeSequenceDataAtom->m_nPreviousAction ? L"skipTimed" : L"none"; } - FillCTn(pETNC, oSec.cTn); + FillCTnRecursive(pETNC, oSec.cTn); // Fill cond lists if (!pETNC->m_arrRgEndTimeCondition.empty()) @@ -273,7 +273,7 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & PPTX::Logic::Cond cond; cond.node_name = L"cond"; FillCond(oldCond, cond); - if (m_cTnDeep == 1) + if (cTNLevel == TimeNodeLevel::root) FillEmptyTargetCond(cond); oSec.prevCondLst->list.push_back(cond); } @@ -288,7 +288,7 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & PPTX::Logic::Cond cond; cond.node_name = L"cond"; FillCond(oldCond, cond); - if (m_cTnDeep == 1) + if (cTNLevel == TimeNodeLevel::root) FillEmptyTargetCond(cond); oSec.nextCondLst->list.push_back(cond); } @@ -296,7 +296,7 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & void Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) { - FillCTn(pETNC, oPar.cTn); + FillCTnRecursive(pETNC, oPar.cTn); } void Timing_2010::FillCBhvr(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CBhvr &oBhvr) @@ -320,7 +320,7 @@ void Timing_2010::FillCBhvr(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CBh bhvr = &(pETNC->m_pTimeCommandBehavior->m_oBevavior); FillCBhvr(bhvr, oBhvr); - FillCTn(pETNC, oBhvr.cTn); + FillCTnRecursive(pETNC, oBhvr.cTn); } void Timing_2010::FillCBhvr(CRecordTimeBehaviorContainer *pBhvr, PPTX::Logic::CBhvr &oBhvr) @@ -424,7 +424,7 @@ void Timing_2010::FillCBhvr(CRecordTimeBehaviorContainer *pBhvr, PPTX::Logic::CB void Timing_2010::FillCBhvr(PPTX::Logic::CBhvr &oBhvr, int dur, UINT spid, std::wstring attrname, int delay) { - oBhvr.cTn.id = m_cTnId++; + oBhvr.cTn.id = cTnId++; oBhvr.cTn.fill = L"hold"; oBhvr.cTn.dur = std::to_wstring(dur); if (delay > -1) @@ -557,210 +557,158 @@ void Timing_2010::FillAnim(CRecordTimeAnimateBehaviorContainer *pTimeAnimateBeha FillCBhvr(&(pTimeAnimateBehavior->m_oBehavior), oAnim.cBhvr); } -void Timing_2010::FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +void Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) { - oCTn.id = m_cTnId++; - m_cTnDeep++; + cTNLevel++; - // Reading TimeNodeAtom - const auto &oTimeNodeAtom = pETNC->m_oTimeNodeAtom; + FillCTnHeadArgs(pETNC, oCTn); - // Write restart - if (oTimeNodeAtom.m_fRestartProperty) - oCTn.restart = PPTX::Limit::TLRestart(oTimeNodeAtom.m_dwRestart) ; + ConvertChildTnLst(pETNC, oCTn); + ConvertCTnIterate(pETNC, oCTn); + ConvertCTnEndSync(pETNC, oCTn); + ConvertCTnIterate(pETNC, oCTn); + ConvertCTnStCondLst(pETNC, oCTn); + cTNLevel--; +} - // Write fill - if (oTimeNodeAtom.m_fFillProperty) - oCTn.fill = PPTX::Limit::TLNodeFillType(oTimeNodeAtom.m_dwFill); - - // Write dur - if (oTimeNodeAtom.m_fDurationProperty) - { - if (oTimeNodeAtom.m_nDuration == -1) - oCTn.dur = L"indefinite"; - else - oCTn.dur = std::to_wstring(oTimeNodeAtom.m_nDuration); - } - - - //// Write Children //// - - //Write cTn attr - if (pETNC->m_haveTimePropertyList && !pETNC->m_pTimePropertyList->m_bEmtyNode) - { - FillCTn(pETNC->m_pTimePropertyList, oCTn); - } - if (m_cTnDeep == 2) - isMainSeq = oCTn.nodeType.get_value_or(L"") == L"mainSeq"; - - - if (!pETNC->m_haveSequenceAtom) - { - // Write stCondLst - if (pETNC->m_arrRgBeginTimeCondition.empty() == false) - { - oCTn.stCondLst = new PPTX::Logic::CondLst; - oCTn.stCondLst->node_name = L"stCondLst"; - } - for (auto *oldCond : pETNC->m_arrRgBeginTimeCondition) { - PPTX::Logic::Cond cond; - cond.node_name = L"cond"; - FillCond(oldCond, cond); - oCTn.stCondLst->list.push_back(cond); - } - - - // Write endCondLst - if (pETNC->m_arrRgEndTimeCondition.empty() == false) - { - oCTn.endCondLst = new PPTX::Logic::CondLst; - oCTn.endCondLst->node_name = L"endCondLst"; - FillCondLst(pETNC->m_arrRgEndTimeCondition, oCTn.endCondLst.get2()); - } - } - - - // Write childTnLst +void Timing_2010::ConvertChildTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ if (pETNC->m_arrRgExtTimeNodeChildren.empty() == false) - { oCTn.childTnLst = new PPTX::Logic::ChildTnLst; - } - for (auto *oldChild : pETNC->m_arrRgExtTimeNodeChildren) { + + for (auto *oldChild : pETNC->m_arrRgExtTimeNodeChildren) + { PPTX::Logic::TimeNodeBase child; FillTnChild(oldChild, child); oCTn.childTnLst->list.push_back(child); } +} +void Timing_2010::ConvertCTnIterate(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ + if (!pETNC->m_haveIterateDataAtom) + return; - // Write iterate - if (pETNC->m_haveIterateDataAtom) + auto *iter = pETNC->m_pTimeIterateDataAtom; + oCTn.iterate = new PPTX::Logic::Iterate; + + std::wstring type[] = {L"el", L"wd", L"lt"}; + if (iter->m_fIterateTypePropertyUsed) + oCTn.iterate->type = type[iter->m_nIterateType % 3]; + + if (iter->m_fIterateDirectionPropertyUsed) + oCTn.iterate->backwards = (bool)iter->m_nIterateDirection; + + int intervalType = iter->m_fIterateIntervalTypePropertyUsed ? + iter->m_nIterateIntervalType : 0; + uint iterateInterval = iter->m_fIterateIntervalPropertyUsed ? + iter->m_nIterateInterval : 0; + + if (intervalType) + oCTn.iterate->tmPct = iterateInterval > 1000 ? 10000 : iterateInterval * 10; + else + oCTn.iterate->tmAbs = std::to_wstring(iterateInterval); +} + +void Timing_2010::ConvertCTnEndSync(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ + if (!pETNC->m_haveTimeEndSyncTime) + return; + + auto *sync = pETNC->m_pTimeEndSyncTimeCondition; + oCTn.endSync = new PPTX::Logic::Cond; + oCTn.endSync->node_name = L"endSync"; + FillCond(sync, *(oCTn.endSync)); +} + +void Timing_2010::ConvertCTnSubTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ + if (pETNC->m_arrRgSubEffect.empty()) + return; + + // if ( + // pETNC->m_arrRgSubEffect[0]->m_oTimeNodeAtom.m_fGroupingTypeProperty && + // m_pBldLst && + // m_pPPT10->m_haveBuildList + // ) + // { + // oCTn.grpId = 0; + // auto bldP = new PPTX::Logic::BldP; + // bldP->grpId = 0; + // m_currentBldP = bldP; + // } + + auto sub = new PPTX::Logic::TnLst; + sub->node_name = L"subTnLst"; + FillSubTnLst(pETNC->m_arrRgSubEffect, *sub); + oCTn.subTnLst = sub; + + if (m_currentBldP) { - auto *iter = pETNC->m_pTimeIterateDataAtom; - oCTn.iterate = new PPTX::Logic::Iterate; - - std::wstring type[] = {L"el", L"wd", L"lt"}; - if (iter->m_fIterateTypePropertyUsed) - oCTn.iterate->type = type[iter->m_nIterateType % 3]; - - if (iter->m_fIterateDirectionPropertyUsed) - oCTn.iterate->backwards = (bool)iter->m_nIterateDirection; - - int intervalType = iter->m_fIterateIntervalTypePropertyUsed ? - iter->m_nIterateIntervalType : 0; - uint iterateInterval = iter->m_fIterateIntervalPropertyUsed ? - iter->m_nIterateInterval : 0; - - if (intervalType) - oCTn.iterate->tmPct = iterateInterval > 1000 ? 10000 : iterateInterval * 10; - else - oCTn.iterate->tmAbs = std::to_wstring(iterateInterval); + PPTX::Logic::BuildNodeBase oBuildNodeBase; + oBuildNodeBase.m_node = m_currentBldP; + m_pBldLst->list.push_back(oBuildNodeBase); + m_currentBldP = nullptr; } - - // Write endSync - if (pETNC->m_haveTimeEndSyncTime) + for (auto timeModAtom : pETNC->m_arrRgTimeModifierAtom) { - auto *sync = pETNC->m_pTimeEndSyncTimeCondition; - oCTn.endSync = new PPTX::Logic::Cond; - oCTn.endSync->node_name = L"endSync"; - FillCond(sync, *(oCTn.endSync)); - } - - - // Write subTnLst - if (pETNC->m_arrRgSubEffect.empty() == false) - { - // if ( - // pETNC->m_arrRgSubEffect[0]->m_oTimeNodeAtom.m_fGroupingTypeProperty && - // m_pBldLst && - // m_pPPT10->m_haveBuildList - // ) - // { - // oCTn.grpId = 0; - // auto bldP = new PPTX::Logic::BldP; - // bldP->grpId = 0; - // m_currentBldP = bldP; - // } - - auto sub = new PPTX::Logic::TnLst; - sub->node_name = L"subTnLst"; - FillSubTnLst(pETNC->m_arrRgSubEffect, *sub); - oCTn.subTnLst = sub; - - if (m_currentBldP) + switch (timeModAtom->m_nType) { - PPTX::Logic::BuildNodeBase oBuildNodeBase; - oBuildNodeBase.m_node = m_currentBldP; - m_pBldLst->list.push_back(oBuildNodeBase); - m_currentBldP = nullptr; + case 0: + { + oCTn.repeatCount = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 1: + { + // Check 1000 + oCTn.repeatDur = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 2: + { + // Check 1000 + oCTn.spd = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 3: + { + // Check 1000 + oCTn.accel = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 4: + { + // Check 1000 + oCTn.decel = std::to_wstring((int) + timeModAtom->m_Value * 1000); + break; + } + case 5: + { + // Check 1000 + oCTn.autoRev = (bool)timeModAtom->m_Value; + break; } - for (auto timeModAtom : pETNC->m_arrRgTimeModifierAtom) - { - switch (timeModAtom->m_nType) - { - case 0: - { - oCTn.repeatCount = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 1: - { - // Check 1000 - oCTn.repeatDur = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 2: - { - // Check 1000 - oCTn.spd = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 3: - { - // Check 1000 - oCTn.accel = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 4: - { - // Check 1000 - oCTn.decel = std::to_wstring((int) - timeModAtom->m_Value * 1000); - break; - } - case 5: - { - // Check 1000 - oCTn.autoRev = (bool)timeModAtom->m_Value; - break; - } - - } } - } +} - // Write stCondLst - if (pETNC->m_arrRgBeginTimeCondition.empty() == false) - { - oCTn.stCondLst = new PPTX::Logic::CondLst; - oCTn.stCondLst->node_name = L"stCondLst"; - FillStCondLst(pETNC->m_arrRgBeginTimeCondition, oCTn.stCondLst.get2()); - } +void Timing_2010::ConvertCTnStCondLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ + if (pETNC->m_arrRgBeginTimeCondition.empty()) + return; - if (oCTn.nodeType.IsInit() == false && (m_cTnDeep == 3 || m_cTnDeep == 4)) - { - oCTn.nodeType = new PPTX::Limit::TLNodeType(); - oCTn.nodeType->set( m_cTnDeep == 3 ? L"clickPar" : L"withGroup"); - } - - m_cTnDeep--; + oCTn.stCondLst = new PPTX::Logic::CondLst; + oCTn.stCondLst->node_name = L"stCondLst"; + FillStCondLst(pETNC->m_arrRgBeginTimeCondition, oCTn.stCondLst.get2()); } void Timing_2010::FillCond(CRecordTimeConditionContainer *oldCond, PPTX::Logic::Cond &cond) @@ -856,7 +804,7 @@ void Timing_2010::FillSubTnLst(std::vector &vecSEC, } FillCondLst(pSEC->m_arrRgBeginTimeCondition, audio->cMediaNode.cTn.stCondLst.get2()); - FillCTn(pSEC->m_pTimePropertyList, audio->cMediaNode.cTn); + FillCTnProps(pSEC->m_pTimePropertyList, audio->cMediaNode.cTn); } if (pSEC->m_haveColorBehavior) @@ -891,7 +839,7 @@ void Timing_2010::FillAudio(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Aud // oAudio.cMediaNode.showWhenStopped = false; } else return; - FillCTn(pETNC, oAudio.cMediaNode.cTn); + FillCTnRecursive(pETNC, oAudio.cMediaNode.cTn); } } @@ -953,116 +901,182 @@ void Timing_2010::FillEmptyTargetCond(PPTX::Logic::Cond &cond) cond.tgtEl = new PPTX::Logic::TgtEl; } -void Timing_2010::FillCTn(CRecordTimePropertyList4TimeNodeContainer *pProp, PPTX::Logic::CTn &oCTn) +void Timing_2010::FillCTnProps(CRecordTimePropertyList4TimeNodeContainer *pProp, PPTX::Logic::CTn &oCTn) { - if (pProp && !pProp->m_bEmtyNode) + if (pProp == nullptr || pProp->m_bEmtyNode) + return; + for (auto *pRec : pProp->m_arrElements) { - for (auto *pRec : pProp->m_arrElements) + TimePropertyID4TimeNode VariableType = ( TimePropertyID4TimeNode ) pRec->m_oHeader.RecInstance; + + switch ( VariableType ) { - TimePropertyID4TimeNode VariableType = ( TimePropertyID4TimeNode ) pRec->m_oHeader.RecInstance; + case TL_TPID_Display: + { + oCTn.display = !(bool)dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_MasterPos: + { + oCTn.masterRel = new PPTX::Limit::TLMasterRelation; + oCTn.masterRel = dynamic_cast(pRec)->m_Value ? + L"nextClick" : L"sameClick"; + break; + } + case TL_TPID_SubType: break; + case TL_TPID_EffectID: + { + oCTn.presetID = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EffectDir: + { + oCTn.presetSubtype = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EffectType: + { + // Write presetClass + std::wstring presetClass; + switch (dynamic_cast(pRec)->m_Value) { + case 0: break; + case 1: presetClass = L"entr"; break; + case 2: presetClass = L"exit"; break; + case 3: presetClass = L"emph"; break; + case 4: presetClass = L"path"; break; + case 5: presetClass = L"verb"; break; + case 6: presetClass = L"mediacall"; break; + } + if (!presetClass.empty()) + { + oCTn.presetClass = new PPTX::Limit::TLPresetClass; + oCTn.presetClass = presetClass; + } + break; + } + case TL_TPID_AfterEffect: + { + oCTn.afterEffect = (bool)dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_SlideCount: break; + case TL_TPID_TimeFilter: + { + oCTn.tmFilter = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EventFilter: + { + oCTn.evtFilter = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_HideWhenStopped: + break; + case TL_TPID_GroupID: + { + oCTn.grpId = dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_EffectNodeType: + { + // Write nodeType + std::wstring nodeType; + switch (dynamic_cast(pRec)->m_Value) + { + case 1: nodeType = L"clickEffect"; break; + case 2: nodeType = L"withEffect"; break; + case 3: nodeType = L"afterEffect"; break; + case 4: nodeType = L"mainSeq"; break; + case 5: nodeType = L"interactiveSeq"; break; + case 6: nodeType = L"clickPar"; break; + case 7: nodeType = L"withGroup"; break; + case 8: nodeType = L"afterGroup"; break; + case 9: nodeType = L"tmRoot"; break; + } + if (!nodeType.empty()) + { + oCTn.nodeType = new PPTX::Limit::TLNodeType; + oCTn.nodeType = nodeType; + } - switch ( VariableType ) - { - case TL_TPID_Display: - { - oCTn.display = !(bool)dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_MasterPos: - { - oCTn.masterRel = new PPTX::Limit::TLMasterRelation; - oCTn.masterRel = dynamic_cast(pRec)->m_Value ? - L"nextClick" : L"sameClick"; - break; - } - case TL_TPID_SubType: break; - case TL_TPID_EffectID: - { - oCTn.presetID = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EffectDir: - { - oCTn.presetSubtype = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EffectType: - { - // Write presetClass - std::wstring presetClass; - switch (dynamic_cast(pRec)->m_Value) { - case 0: break; - case 1: presetClass = L"entr"; break; - case 2: presetClass = L"exit"; break; - case 3: presetClass = L"emph"; break; - case 4: presetClass = L"path"; break; - case 5: presetClass = L"verb"; break; - case 6: presetClass = L"mediacall"; break; - } - if (!presetClass.empty()) - { - oCTn.presetClass = new PPTX::Limit::TLPresetClass; - oCTn.presetClass = presetClass; - } - break; - } - case TL_TPID_AfterEffect: - { - oCTn.afterEffect = (bool)dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_SlideCount: break; - case TL_TPID_TimeFilter: - { - oCTn.tmFilter = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EventFilter: - { - oCTn.evtFilter = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_HideWhenStopped: break; - case TL_TPID_GroupID: - { - oCTn.grpId = dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_EffectNodeType: - { - // Write nodeType - std::wstring nodeType; - switch (dynamic_cast(pRec)->m_Value) - { - case 1: nodeType = L"clickEffect"; break; - case 2: nodeType = L"withEffect"; break; - case 3: nodeType = L"afterEffect"; break; - case 4: nodeType = L"mainSeq"; break; - case 5: nodeType = L"interactiveSeq"; break; - case 6: nodeType = L"clickPar"; break; - case 7: nodeType = L"withGroup"; break; - case 8: nodeType = L"afterGroup"; break; - case 9: nodeType = L"tmRoot"; break; - } - if (!nodeType.empty()) - { - oCTn.nodeType = new PPTX::Limit::TLNodeType; - oCTn.nodeType = nodeType; - } + break; + } + case TL_TPID_PlaceholderNode: + { + oCTn.nodePh = (bool)dynamic_cast(pRec)->m_Value; + break; + } + case TL_TPID_MediaVolume: + break; + case TL_TPID_MediaMute: + break; + case TL_TPID_ZoomToFullScreen: + break; + default : + break; + } + } +} - break; - } - case TL_TPID_PlaceholderNode: - { - oCTn.nodePh = (bool)dynamic_cast(pRec)->m_Value; - break; - } - case TL_TPID_MediaVolume: break; - case TL_TPID_MediaMute: break; - case TL_TPID_ZoomToFullScreen: break; - default : - break; - } +void Timing_2010::FillCTnHeadArgs(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +{ + oCTn.id = cTnId++; + + // Reading TimeNodeAtom + const auto &oTimeNodeAtom = pETNC->m_oTimeNodeAtom; + + // Write restart + if (oTimeNodeAtom.m_fRestartProperty) + oCTn.restart = PPTX::Limit::TLRestart(oTimeNodeAtom.m_dwRestart) ; + + + // Write fill + if (oTimeNodeAtom.m_fFillProperty) + oCTn.fill = PPTX::Limit::TLNodeFillType(oTimeNodeAtom.m_dwFill); + + // Write dur + if (oTimeNodeAtom.m_fDurationProperty) + { + if (oTimeNodeAtom.m_nDuration == -1) + oCTn.dur = L"indefinite"; + else + oCTn.dur = std::to_wstring(oTimeNodeAtom.m_nDuration); + } + + if (pETNC->m_haveTimePropertyList && !pETNC->m_pTimePropertyList->m_bEmtyNode) + FillCTnProps(pETNC->m_pTimePropertyList, oCTn); + + if (cTNLevel == TimeNodeLevel::mainSeqOrTrigger) + isMainSeq = oCTn.nodeType.get_value_or(L"") == L"mainSeq"; + + if (oCTn.nodeType.IsInit() == false && (cTNLevel == TimeNodeLevel::eventOrClickGroup || cTNLevel == TimeNodeLevel::parallelShow)) + { + oCTn.nodeType = new PPTX::Limit::TLNodeType(); + oCTn.nodeType->set( cTNLevel == TimeNodeLevel::parallelShow ? L"clickPar" : L"withGroup"); + } + + if (!pETNC->m_haveSequenceAtom) + { + // Write stCondLst + if (pETNC->m_arrRgBeginTimeCondition.empty() == false) + { + oCTn.stCondLst = new PPTX::Logic::CondLst; + oCTn.stCondLst->node_name = L"stCondLst"; + } + for (auto *oldCond : pETNC->m_arrRgBeginTimeCondition) { + PPTX::Logic::Cond cond; + cond.node_name = L"cond"; + FillCond(oldCond, cond); + oCTn.stCondLst->list.push_back(cond); + } + + + // Write endCondLst + if (pETNC->m_arrRgEndTimeCondition.empty() == false) + { + oCTn.endCondLst = new PPTX::Logic::CondLst; + oCTn.endCondLst->node_name = L"endCondLst"; + FillCondLst(pETNC->m_arrRgEndTimeCondition, oCTn.endCondLst.get2()); } } } @@ -1075,7 +1089,7 @@ void Timing_2010::FillAnimClr( auto &clrAtom = pColor->m_oColorBehaviorAtom; FillCBhvr(&(pColor->m_oBehavior), oAnimClr.cBhvr); - FillCTn(pProp, oAnimClr.cBhvr.cTn); + FillCTnProps(pProp, oAnimClr.cBhvr.cTn); // Write Attributes if (pColor->m_oBehavior.m_havePropertyList){ @@ -1307,7 +1321,7 @@ void Timing_2010::FillVideo( { auto video = pETNC->m_pClientVisualElement->m_oVisualShapeAtom; - FillCTn(pETNC, oVideo.cMediaNode.cTn); + FillCTnRecursive(pETNC, oVideo.cMediaNode.cTn); if (pETNC->m_pTimePropertyList->m_arrElements.size() >= 5) { @@ -1334,6 +1348,12 @@ void Timing_2010::FillVideo( oVideo.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(video.m_nObjectIdRef); } +void Timing_2010::FillAnimationPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) +{ + + +} + } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index e6f330d98c..1fdedd1450 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -37,6 +37,18 @@ public: Timing_2010(CRecordPP10SlideBinaryTagExtension* pAnim_2010, const std::unordered_set& shapesID); void Convert(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); +public: + enum TimeNodeLevel { + zero, + root = 1, + mainSeqOrTrigger = 2, + eventOrClickGroup = 3, + parallelShow = 4, + oneAnim = 5, + animEffectDescription = 6 + }; + + private: void ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC); void FillBuildNodeBase(CRecordBuildListSubContainer* pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase); @@ -66,13 +78,19 @@ private: CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, PPTX::Logic::Anim &oAnim); - void FillCTn(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void ConvertChildTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void ConvertCTnIterate(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void ConvertCTnEndSync(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void ConvertCTnSubTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void ConvertCTnStCondLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); void FillCond(PPT_FORMAT::CRecordTimeConditionContainer *oldCond, PPTX::Logic::Cond &cond); void FillStCondLst(const std::vector& timeCondCont, PPTX::Logic::CondLst& stCondLst); void FillSubTnLst (std::vector &vecSEC, PPTX::Logic::TnLst &oSubTnLst); void FillCondLst(std::vector& oCondVec, PPTX::Logic::CondLst &oCondLst); void FillEmptyTargetCond(PPTX::Logic::Cond &cond); - void FillCTn(CRecordTimePropertyList4TimeNodeContainer *pProp, PPTX::Logic::CTn &oCTn); + void FillCTnProps(CRecordTimePropertyList4TimeNodeContainer *pProp, PPTX::Logic::CTn &oCTn); + void FillCTnHeadArgs(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); void FillAnimClr( @@ -101,6 +119,9 @@ private: void FillVideo( CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Video &oVideo); + void FillAnimationPar( // TODO next + CRecordExtTimeNodeContainer *pETNC, + PPTX::Logic::Par &oPar); private: CRecordPP10SlideBinaryTagExtension* pTagExtAnim = nullptr; @@ -112,8 +133,8 @@ private: PPTX::Logic::BldLst *m_pBldLst = nullptr; // Do not delete PPTX::Logic::BldP *m_currentBldP = nullptr; - int m_cTnId = 0; - int m_cTnDeep = 0; + int cTnId = 0; + int cTNLevel = TimeNodeLevel::zero; }; } From 101b79ea490912b7d9af3d935192bae3fcb3de69 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Fri, 18 Nov 2022 16:39:18 +0300 Subject: [PATCH 16/22] add animation rejection --- .../Converter/Animation/TimingUtils.cpp | 56 +++++++++++++++++++ .../Converter/Animation/TimingUtils.h | 32 +++++++++++ .../Converter/Animation/Timing_2010.cpp | 56 +++++++++++++++---- .../Converter/Animation/Timing_2010.h | 10 ++-- .../PPTFormatLib/Linux/PPTFormatLib.pro | 3 + .../PPTFormatLib/Reader/ExtXmlUtils.hpp | 46 +++++++++++++++ 6 files changed, 187 insertions(+), 16 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h create mode 100644 ASCOfficePPTFile/PPTFormatLib/Reader/ExtXmlUtils.hpp diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp new file mode 100644 index 0000000000..7de7ccfca7 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp @@ -0,0 +1,56 @@ +#include "TimingUtils.h" +#include "../../Reader/ExtXmlUtils.hpp" +#include "../../Enums/enums.h" + + +PPT::Intermediate::ShapeAnim PPT::Intermediate::ParseExisting5Level_CTn(const PPTX::Logic::CTn &oCTn) +{ + ShapeAnim spAn; + spAn.presetID = oCTn.presetID.get_value_or(-1); + std::wstring xml = oCTn.toXML(); + auto arrSpids = XmlUtils::FindAttrValuesInt(xml, L"spid"); + if (arrSpids.size()) + spAn.spid = arrSpids[0]; + + return spAn; +} + +PPT::Intermediate::ShapeAnim PPT::Intermediate::ParseExisting5Level_ETNC(const CRecordExtTimeNodeContainer *pETNC) +{ + if (pETNC == nullptr) + return {}; + + ShapeAnim spAn; + for (const auto& child : pETNC->m_arrRgExtTimeNodeChildren) + { + if (child->m_haveSetBehavior && + child->m_pTimeSetBehavior && + child->m_pTimeSetBehavior->m_oBehavior.m_oClientVisualElement.m_bVisualShapeAtom && + child->m_pTimeSetBehavior->m_oBehavior.m_oClientVisualElement.m_oVisualShapeAtom.m_RefType == TL_ET_ShapeType) + { + spAn.spid = child->m_pTimeSetBehavior->m_oBehavior.m_oClientVisualElement.m_oVisualShapeAtom.m_nObjectIdRef; + break; + } + } + + if (pETNC->m_haveTimePropertyList && pETNC->m_pTimePropertyList != nullptr) + { + for (const auto prop : pETNC->m_pTimePropertyList->m_arrElements) + { + if (prop->m_oHeader.RecInstance == TL_TPID_EffectID) + { + spAn.presetID = dynamic_cast(prop)->m_Value; + break; + } + } + } + return spAn; +} + +bool PPT::Intermediate::operator==(const ShapeAnim &s1, const ShapeAnim &s2) +{ + if (s1.IsValid() == false) + return false; + + return s1.spid == s2.spid && (s1.presetID == s2.presetID || s1.presetID == 1 || s2.presetID == 1); /// 1 - Appear +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h new file mode 100644 index 0000000000..4faa34c914 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h @@ -0,0 +1,32 @@ +#pragma once + +#include "../../../../ASCOfficePPTXFile/PPTXFormat/Logic/Timing/CTn.h" +#include "../../Records/Animations/ExtTimeNodeContainer.h" + +namespace PPT { +namespace Intermediate { +struct ShapeAnim +{ + _INT32 spid = -1; + _INT32 presetID = -1; // where 1 is any animation or simpless: appear + + inline bool IsValid()const + {return spid > 0 && presetID > 0;} +}; + +bool operator==(const ShapeAnim &s1, const ShapeAnim &s2); + +// look at enum TimeNodeLevel +ShapeAnim ParseExisting3Level_CTn(const PPTX::Logic::CTn &oCTn); +ShapeAnim ParseExisting3Level_ETNC(const CRecordExtTimeNodeContainer *pETNC); + +ShapeAnim ParseExisting4Level_CTn(const PPTX::Logic::CTn &oCTn); +ShapeAnim ParseExisting4Level_ETNC(const CRecordExtTimeNodeContainer *pETNC); + +ShapeAnim ParseExisting5Level_CTn(const PPTX::Logic::CTn &oCTn); +ShapeAnim ParseExisting5Level_ETNC(const CRecordExtTimeNodeContainer *pETNC); + + + +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index 7e22f042d0..d2475fe2f4 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -1,6 +1,7 @@ #include "Timing_2010.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h" +#include "TimingUtils.h" namespace PPT { @@ -148,7 +149,7 @@ void Timing_2010::ConvertTnLst(PPTX::Logic::TnLst &tnLst, CRecordExtTimeNodeCont FillTnChild(pETNC, tnLst.list.back()); } -void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild) +bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild) { if (pETNC->m_haveSequenceAtom) { @@ -217,10 +218,14 @@ void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T } else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Par; + auto pPar = oChild.m_node.smart_dynamic_cast(); + if (!pPar.IsInit()) + pPar = new PPTX::Logic::Par; - FillPar(pETNC, oChild.m_node.as()); + if(FillPar(pETNC, *pPar)) + oChild.m_node = pPar.smart_dynamic_cast(); + else + return false; } else if (pETNC->m_haveClientVisualElement) { @@ -247,6 +252,8 @@ void Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T } } } + + return true; } void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq &oSec) @@ -294,9 +301,9 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & } } -void Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) +bool Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) { - FillCTnRecursive(pETNC, oPar.cTn); + return FillCTnRecursive(pETNC, oPar.cTn); } void Timing_2010::FillCBhvr(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CBhvr &oBhvr) @@ -557,8 +564,12 @@ void Timing_2010::FillAnim(CRecordTimeAnimateBehaviorContainer *pTimeAnimateBeha FillCBhvr(&(pTimeAnimateBehavior->m_oBehavior), oAnim.cBhvr); } -void Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +bool Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) { + if (cTNLevel+1 == TimeNodeLevel::oneAnim && + !CheckAnimation5Level(pETNC, oCTn)) + return false; + cTNLevel++; FillCTnHeadArgs(pETNC, oCTn); @@ -570,18 +581,39 @@ void Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Log ConvertCTnStCondLst(pETNC, oCTn); cTNLevel--; + return true; +} + +bool Timing_2010::CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) const +{ + auto anim_2010 = Intermediate::ParseExisting5Level_ETNC(pETNC); + if (IsSlideSpId(anim_2010.spid) == false) + return false; + if (isMainSeq == false) + return true; + + auto anim_pptx = Intermediate::ParseExisting5Level_CTn(oCTn); + return anim_pptx == anim_2010; +} + +bool Timing_2010::IsSlideSpId(_INT32 spid) const +{ + return slideShapes.find(spid) != slideShapes.end(); } void Timing_2010::ConvertChildTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) { - if (pETNC->m_arrRgExtTimeNodeChildren.empty() == false) + if (oCTn.childTnLst.IsInit() == false) oCTn.childTnLst = new PPTX::Logic::ChildTnLst; - for (auto *oldChild : pETNC->m_arrRgExtTimeNodeChildren) + for (size_t i = 0; i < pETNC->m_arrRgExtTimeNodeChildren.size(); i++) { - PPTX::Logic::TimeNodeBase child; - FillTnChild(oldChild, child); - oCTn.childTnLst->list.push_back(child); + auto *pETNC_child = pETNC->m_arrRgExtTimeNodeChildren[i]; + if (oCTn.childTnLst->list.size() == i) + oCTn.childTnLst->list.push_back(PPTX::Logic::TimeNodeBase()); + + auto& pptx_child = oCTn.childTnLst->list[i]; + FillTnChild(pETNC_child, pptx_child); } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index 1fdedd1450..f5a227caf1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -57,9 +57,9 @@ private: void FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP); void ConvertTnLst(PPTX::Logic::TnLst& tnLst, CRecordExtTimeNodeContainer* pETNC); - void FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild); + bool FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild); void FillSeq(PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq& oSec); - void FillPar( + bool FillPar( CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar); void FillCBhvr( @@ -78,7 +78,9 @@ private: CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, PPTX::Logic::Anim &oAnim); - void FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + bool FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + bool CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) const; + bool IsSlideSpId(_INT32 spid) const; void ConvertChildTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); void ConvertCTnIterate(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); void ConvertCTnEndSync(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); @@ -133,7 +135,7 @@ private: PPTX::Logic::BldLst *m_pBldLst = nullptr; // Do not delete PPTX::Logic::BldP *m_currentBldP = nullptr; - int cTnId = 0; + int cTnId = 1; int cTNLevel = TimeNodeLevel::zero; }; diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index bf4f8d1834..1cbb3acccd 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -29,6 +29,7 @@ DEFINES += UNICODE \ HEADERS += \ ../Converter/Animation/AnimationParser.h \ ../Converter/Animation/Animation_1995.h \ + ../Converter/Animation/TimingUtils.h \ ../Converter/Animation/Timing_1995.h \ ../Converter/Animation/Timing_2010.h \ ../Converter/Animation/intermediate_anim.h \ @@ -43,6 +44,7 @@ HEADERS += \ ../PPTXWriter/TxBodyConverter.h \ ../Reader/ClassesAtom.h \ ../Reader/CommonZLib.h \ + ../Reader/ExtXmlUtils.hpp \ ../Reader/PPTDocumentInfo.h \ ../Reader/PPTDocumentInfoOneUser.h \ ../Reader/PPTFileDefines.h \ @@ -305,6 +307,7 @@ SOURCES += \ ../../../Common/3dParty/pole/pole.cpp \ ../Converter/Animation/AnimationParser.cpp \ ../Converter/Animation/Animation_1995.cpp \ + ../Converter/Animation/TimingUtils.cpp \ ../Converter/Animation/Timing_1995.cpp \ ../Converter/Animation/Timing_2010.cpp \ ../Converter/Animation/intermediate_anim.cpp \ diff --git a/ASCOfficePPTFile/PPTFormatLib/Reader/ExtXmlUtils.hpp b/ASCOfficePPTFile/PPTFormatLib/Reader/ExtXmlUtils.hpp new file mode 100644 index 0000000000..e1e63c4e12 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Reader/ExtXmlUtils.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include + + +namespace XmlUtils { +std::vector FindAttrValues(const std::wstring& xml, std::wstring attrName) +{ + attrName += L"=\""; + std::vector values; + size_t posBeg = xml.find(attrName); + auto endTagPos = posBeg + attrName.size(); + size_t posEnd = xml.find(L"\"", endTagPos); + + // Repeat till end is reached + while( posBeg != std::string::npos) + { + auto strValue = xml.substr(endTagPos, posEnd - (endTagPos)); + values.push_back(strValue); + + // Get the next occurrence from the current position + posBeg = xml.find(attrName, endTagPos); + endTagPos = posBeg + attrName.size(); + posEnd = xml.find(L"\"", endTagPos); + } + return values; +} + +std::vector FindAttrValuesInt(const std::wstring& xml, std::wstring attrName) +{ + auto vecStrValues = FindAttrValues(xml, attrName); + std::vector vecIntValues; + for (const auto& strValue : vecStrValues) + { + try { + vecIntValues.push_back(std::stoi(strValue)); + } catch (...) { + } + } + return vecIntValues; +} + +} + From 687836b781cb900c64e8cc730d5194108471ec45 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Sun, 20 Nov 2022 11:52:42 +0300 Subject: [PATCH 17/22] Add correct animation spid searcher and checker. Found CRecordBuildListSubContainer problem --- .../Converter/Animation/TimingUtils.cpp | 44 ++++++++++-- .../Converter/Animation/TimingUtils.h | 3 +- .../Converter/Animation/Timing_2010.cpp | 68 +++++++++++++------ .../Converter/Animation/Timing_2010.h | 7 +- 4 files changed, 94 insertions(+), 28 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp index 7de7ccfca7..7d70219c32 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.cpp @@ -23,12 +23,10 @@ PPT::Intermediate::ShapeAnim PPT::Intermediate::ParseExisting5Level_ETNC(const C ShapeAnim spAn; for (const auto& child : pETNC->m_arrRgExtTimeNodeChildren) { - if (child->m_haveSetBehavior && - child->m_pTimeSetBehavior && - child->m_pTimeSetBehavior->m_oBehavior.m_oClientVisualElement.m_bVisualShapeAtom && - child->m_pTimeSetBehavior->m_oBehavior.m_oClientVisualElement.m_oVisualShapeAtom.m_RefType == TL_ET_ShapeType) + auto foundSpid = GetSpID(child); + if (foundSpid != -1) { - spAn.spid = child->m_pTimeSetBehavior->m_oBehavior.m_oClientVisualElement.m_oVisualShapeAtom.m_nObjectIdRef; + spAn.spid = foundSpid; break; } } @@ -54,3 +52,39 @@ bool PPT::Intermediate::operator==(const ShapeAnim &s1, const ShapeAnim &s2) return s1.spid == s2.spid && (s1.presetID == s2.presetID || s1.presetID == 1 || s2.presetID == 1); /// 1 - Appear } + +CRecordTimeBehaviorContainer* PPT::Intermediate::GetTimeBehaviorContainer(CRecordExtTimeNodeContainer *pETNC) +{ + CRecordTimeBehaviorContainer *pBhvr = nullptr; + if (pETNC->m_haveSetBehavior) + pBhvr = &(pETNC->m_pTimeSetBehavior->m_oBehavior); + else if (pETNC->m_haveEffectBehavior) + pBhvr = &(pETNC->m_pTimeEffectBehavior->m_oBehavior); + else if (pETNC->m_haveAnimateBehavior) + pBhvr = &(pETNC->m_pTimeAnimateBehavior->m_oBehavior); + else if (pETNC->m_haveColorBehavior) + pBhvr = &(pETNC->m_pTimeColorBehavior->m_oBehavior); + else if (pETNC->m_haveMotionBehavior) + pBhvr = &(pETNC->m_pTimeMotionBehavior->m_oTimeBehavior); + else if (pETNC->m_haveRotationBehavior) + pBhvr = &(pETNC->m_pTimeRotationBehavior->m_oBehavior); + else if (pETNC->m_haveScaleBehavior) + pBhvr = &(pETNC->m_pTimeScaleBehavior->m_oBehavior); + else + pBhvr = &(pETNC->m_pTimeCommandBehavior->m_oBevavior); + + return pBhvr; +} + +_INT32 PPT::Intermediate::GetSpID(CRecordExtTimeNodeContainer *pETNC) +{ + auto pBhvr = GetTimeBehaviorContainer(pETNC); + if (pBhvr == nullptr) + return -1; + + if (pBhvr->m_oClientVisualElement.m_bVisualShapeAtom && + pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_RefType == TL_ET_ShapeType) + return pBhvr->m_oClientVisualElement.m_oVisualShapeAtom.m_nObjectIdRef; + + return -1; +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h index 4faa34c914..590b69f505 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingUtils.h @@ -26,7 +26,8 @@ ShapeAnim ParseExisting4Level_ETNC(const CRecordExtTimeNodeContainer *pETNC); ShapeAnim ParseExisting5Level_CTn(const PPTX::Logic::CTn &oCTn); ShapeAnim ParseExisting5Level_ETNC(const CRecordExtTimeNodeContainer *pETNC); - +CRecordTimeBehaviorContainer* GetTimeBehaviorContainer(CRecordExtTimeNodeContainer *pETNC); +_INT32 GetSpID(CRecordExtTimeNodeContainer *pETNC); } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index d2475fe2f4..a892bf58ef 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -17,14 +17,15 @@ void Timing_2010::Convert(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRels m_pExMedia = pExMedia; m_pRels = pRels; - ConvertBldLst(timimg.bldLst.get2(), pTagExtAnim->m_pBuildListContainer); ConvertTnLst(timimg.tnLst.get2(), pTagExtAnim->m_pExtTimeNodeContainer); + ConvertBldLst(timimg.bldLst.get2(), pTagExtAnim->m_pBuildListContainer); } void Timing_2010::ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC) { if (pBLC == nullptr) return; + bldLst.list.clear(); // It maybe not correct for (IRecord* pDBC : pBLC->m_arRecords) { @@ -36,9 +37,30 @@ void Timing_2010::ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListCon continue; FillBuildNodeBase(pSub, oBuildNodeBase); + InsertBuildNode(bldLst, oBuildNodeBase); } } +void Timing_2010::InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb) +{ + if (bnb.m_node.is()) + InsertBldP(bldLst, bnb); + else // TODO BldOleChart and RT_DiagramBuild. Now it is not support (20.11.22). + bldLst.list.push_back(bnb); +} + +void Timing_2010::InsertBldP(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb) +{ + auto bldP = bnb.m_node.as(); + _INT32 spid = -1; + try { + spid = std::stoi(bldP.spid); + } catch (...) { + } + if (IsCorrectAnimationSpId(spid)) + bldLst.list.push_back(bnb); +} + void Timing_2010::FillBuildNodeBase(CRecordBuildListSubContainer *pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase) { switch (pSub->m_oHeader.RecType) @@ -308,24 +330,7 @@ bool Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par & void Timing_2010::FillCBhvr(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CBhvr &oBhvr) { - CRecordTimeBehaviorContainer *bhvr = nullptr; - if (pETNC->m_haveSetBehavior) - bhvr = &(pETNC->m_pTimeSetBehavior->m_oBehavior); - else if (pETNC->m_haveEffectBehavior) - bhvr = &(pETNC->m_pTimeEffectBehavior->m_oBehavior); - else if (pETNC->m_haveAnimateBehavior) - bhvr = &(pETNC->m_pTimeAnimateBehavior->m_oBehavior); - else if (pETNC->m_haveColorBehavior) - bhvr = &(pETNC->m_pTimeColorBehavior->m_oBehavior); - else if (pETNC->m_haveMotionBehavior) - bhvr = &(pETNC->m_pTimeMotionBehavior->m_oTimeBehavior); - else if (pETNC->m_haveRotationBehavior) - bhvr = &(pETNC->m_pTimeRotationBehavior->m_oBehavior); - else if (pETNC->m_haveScaleBehavior) - bhvr = &(pETNC->m_pTimeScaleBehavior->m_oBehavior); - else - bhvr = &(pETNC->m_pTimeCommandBehavior->m_oBevavior); - + auto *bhvr = Intermediate::GetTimeBehaviorContainer(pETNC); FillCBhvr(bhvr, oBhvr); FillCTnRecursive(pETNC, oBhvr.cTn); } @@ -584,16 +589,26 @@ bool Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Log return true; } -bool Timing_2010::CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) const +bool Timing_2010::CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) { auto anim_2010 = Intermediate::ParseExisting5Level_ETNC(pETNC); if (IsSlideSpId(anim_2010.spid) == false) return false; if (isMainSeq == false) + { + InsertAnimationSpId(anim_2010.spid); + return true; + } + if(IsCorrectAnimationSpId(anim_2010.spid)) return true; auto anim_pptx = Intermediate::ParseExisting5Level_CTn(oCTn); - return anim_pptx == anim_2010; + if (anim_pptx == anim_2010) + { + correctAnimatedShapes.insert(anim_2010.spid); + return true; + } else + return false; } bool Timing_2010::IsSlideSpId(_INT32 spid) const @@ -601,6 +616,17 @@ bool Timing_2010::IsSlideSpId(_INT32 spid) const return slideShapes.find(spid) != slideShapes.end(); } +bool Timing_2010::IsCorrectAnimationSpId(_INT32 spid) const +{ + return correctAnimatedShapes.find(spid) != correctAnimatedShapes.end(); +} + +void Timing_2010::InsertAnimationSpId(_INT32 spid) +{ + if (spid != -1) + correctAnimatedShapes.insert(spid); +} + void Timing_2010::ConvertChildTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) { if (oCTn.childTnLst.IsInit() == false) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index f5a227caf1..e34bb8c351 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -51,6 +51,8 @@ public: private: void ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC); + void InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb); + void InsertBldP(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb); void FillBuildNodeBase(CRecordBuildListSubContainer* pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase); void FillBldP(CRecordParaBuildContainer *pPBC, PPTX::Logic::BldP &oBP); void FillBldOleChart(CRecordChartBuildContainer* pCBC, PPTX::Logic::BldOleChart &oBP); @@ -79,8 +81,10 @@ private: PPTX::Logic::Anim &oAnim); bool FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); - bool CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) const; + bool CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn); bool IsSlideSpId(_INT32 spid) const; + bool IsCorrectAnimationSpId(_INT32 spid) const; + void InsertAnimationSpId(_INT32 spid); void ConvertChildTnLst(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); void ConvertCTnIterate(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); void ConvertCTnEndSync(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); @@ -128,6 +132,7 @@ private: private: CRecordPP10SlideBinaryTagExtension* pTagExtAnim = nullptr; const std::unordered_set slideShapes; + std::unordered_set correctAnimatedShapes; CExMedia *m_pExMedia = nullptr; CRelsGenerator *m_pRels = nullptr; bool isMainSeq = false; From 8085865daa3c100064645aa36aad9acb18c48296 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Sun, 20 Nov 2022 12:19:08 +0300 Subject: [PATCH 18/22] Fix CRecordBuildListSubContainer problem and FillBuildNodeBase ref missing --- .../PPTFormatLib/Converter/Animation/Timing_2010.cpp | 6 ++++-- .../PPTFormatLib/Converter/Animation/Timing_2010.h | 2 +- .../PPTFormatLib/Records/Animations/ParaBuildContainer.h | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index a892bf58ef..bdd8a3db1f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -45,8 +45,10 @@ void Timing_2010::InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::Buil { if (bnb.m_node.is()) InsertBldP(bldLst, bnb); - else // TODO BldOleChart and RT_DiagramBuild. Now it is not support (20.11.22). + else if (bnb.m_node.IsInit()) // TODO BldOleChart and RT_DiagramBuild. Now it is not support (20.11.22). bldLst.list.push_back(bnb); + else + return; } void Timing_2010::InsertBldP(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb) @@ -61,7 +63,7 @@ void Timing_2010::InsertBldP(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNode bldLst.list.push_back(bnb); } -void Timing_2010::FillBuildNodeBase(CRecordBuildListSubContainer *pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase) +void Timing_2010::FillBuildNodeBase(CRecordBuildListSubContainer *pSub, PPTX::Logic::BuildNodeBase &oBuildNodeBase) { switch (pSub->m_oHeader.RecType) { diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index e34bb8c351..586eba4679 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -53,7 +53,7 @@ private: void ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC); void InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb); void InsertBldP(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb); - void FillBuildNodeBase(CRecordBuildListSubContainer* pSub, PPTX::Logic::BuildNodeBase oBuildNodeBase); + void FillBuildNodeBase(CRecordBuildListSubContainer* pSub, PPTX::Logic::BuildNodeBase &oBuildNodeBase); void FillBldP(CRecordParaBuildContainer *pPBC, PPTX::Logic::BldP &oBP); void FillBldOleChart(CRecordChartBuildContainer* pCBC, PPTX::Logic::BldOleChart &oBP); void FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h index d7248eb288..9148900dd6 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/ParaBuildContainer.h @@ -53,10 +53,10 @@ public: virtual void ReadFromStream ( SRecordHeader & header, POLE::Stream* pStream ) override { + LONG lPos(0); StreamUtils::StreamPosition(lPos, pStream); CRecordBuildListSubContainer::ReadFromStream(header, pStream); - LONG lPos(0); StreamUtils::StreamPosition(lPos, pStream); - UINT lCurLen = buildAtom.m_oHeader.RecLen + 8; + UINT lCurLen = buildAtom.m_oHeader.RecLen + 8 + 24; // BuildAtom - 24 SRecordHeader paraBuildAtomHeader; From 6035597060306c1e98daee8d1ba9d92ebb0ef557 Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Mon, 21 Nov 2022 19:47:54 +0300 Subject: [PATCH 19/22] trying to throw exeption when timing_2010 isn't actual --- .../Converter/Animation/TimingExeption.h | 31 +++++++++++++++++++ .../Converter/Animation/Timing_2010.cpp | 20 +++++------- .../Converter/Animation/Timing_2010.h | 5 ++- .../PPTFormatLib/Converter/timing.cpp | 9 ++++-- .../PPTFormatLib/Linux/PPTFormatLib.pro | 1 + 5 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingExeption.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingExeption.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingExeption.h new file mode 100644 index 0000000000..c53e4c36b3 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/TimingExeption.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +namespace PPT { +namespace Converter { +class TimingExeption : virtual public std::exception +{ +public: + TimingExeption() {} + TimingExeption(std::string message) : errorMessage(message) {} + TimingExeption(std::string message, std::exception& ex) : std::exception(ex), errorMessage(message) {} + TimingExeption(std::wstring message) : werrorMessage(message) {} + TimingExeption(std::wstring message, std::exception& ex) : std::exception(ex), werrorMessage(message) {} + + virtual ~TimingExeption() throw () {} + + virtual const char* what() const throw () { + return errorMessage.c_str(); + } + virtual const wchar_t* what_w() const throw () { + return werrorMessage.c_str(); + } + +protected: + std::string errorMessage; + std::wstring werrorMessage; +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index bdd8a3db1f..b04fbedd14 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -1,6 +1,7 @@ #include "Timing_2010.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SchemeClr.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Colors/SrgbClr.h" +#include "TimingExeption.h" #include "TimingUtils.h" @@ -242,14 +243,10 @@ bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T } else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) { - auto pPar = oChild.m_node.smart_dynamic_cast(); - if (!pPar.IsInit()) - pPar = new PPTX::Logic::Par; + if (!oChild.m_node.IsInit()) + oChild.m_node = new PPTX::Logic::Par; - if(FillPar(pETNC, *pPar)) - oChild.m_node = pPar.smart_dynamic_cast(); - else - return false; + FillPar(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveClientVisualElement) { @@ -325,9 +322,9 @@ void Timing_2010::FillSeq(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq & } } -bool Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) +void Timing_2010::FillPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) { - return FillCTnRecursive(pETNC, oPar.cTn); + FillCTnRecursive(pETNC, oPar.cTn); } void Timing_2010::FillCBhvr(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CBhvr &oBhvr) @@ -571,11 +568,11 @@ void Timing_2010::FillAnim(CRecordTimeAnimateBehaviorContainer *pTimeAnimateBeha FillCBhvr(&(pTimeAnimateBehavior->m_oBehavior), oAnim.cBhvr); } -bool Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) +void Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn) { if (cTNLevel+1 == TimeNodeLevel::oneAnim && !CheckAnimation5Level(pETNC, oCTn)) - return false; + throw TimingExeption("Slide was edited without animation 2010 synchronization"); cTNLevel++; @@ -588,7 +585,6 @@ bool Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Log ConvertCTnStCondLst(pETNC, oCTn); cTNLevel--; - return true; } bool Timing_2010::CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index 586eba4679..76bba32af2 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -24,7 +24,6 @@ #include "../../Records/Animations/DiagramBuildContainer.h" #include "intermediate_anim.h" // it using -//#include namespace PPT { @@ -61,7 +60,7 @@ private: void ConvertTnLst(PPTX::Logic::TnLst& tnLst, CRecordExtTimeNodeContainer* pETNC); bool FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild); void FillSeq(PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq& oSec); - bool FillPar( + void FillPar( CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar); void FillCBhvr( @@ -80,7 +79,7 @@ private: CRecordTimeAnimateBehaviorContainer *pTimeAnimateBehavior, PPTX::Logic::Anim &oAnim); - bool FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); + void FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::CTn &oCTn); bool CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn); bool IsSlideSpId(_INT32 spid) const; bool IsCorrectAnimationSpId(_INT32 spid) const; diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index 8ac74b71ec..5ebfd8e44a 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -3,6 +3,7 @@ #include "Animation/intermediate_anim.h" #include "Animation/Timing_1995.h" #include "Animation/Timing_2010.h" +#include "Animation/TimingExeption.h" using namespace PPT::Converter; @@ -19,8 +20,12 @@ PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) Timing_1995(slideAnim.arrAnim_1995). Convert(timing, pExMedia, pRels); - Timing_2010(slideAnim.pAnim_2010, shapesID). - Convert(timing, pExMedia, pRels); + try { + Timing_2010(slideAnim.pAnim_2010, shapesID). + Convert(timing, pExMedia, pRels); + } catch (const TimingExeption &ex) { + } catch (...) { + } return std::move(timing); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 1cbb3acccd..5ff1469576 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -29,6 +29,7 @@ DEFINES += UNICODE \ HEADERS += \ ../Converter/Animation/AnimationParser.h \ ../Converter/Animation/Animation_1995.h \ + ../Converter/Animation/TimingExeption.h \ ../Converter/Animation/TimingUtils.h \ ../Converter/Animation/Timing_1995.h \ ../Converter/Animation/Timing_2010.h \ From bae1da1f1e8efc3a2a0d539df0538a1b298f9bbd Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Tue, 22 Nov 2022 11:10:00 +0300 Subject: [PATCH 20/22] refactoring and fix empty p:bldLst --- .../Converter/Animation/Timing_2010.cpp | 57 +++++++++---------- .../Converter/Animation/Timing_2010.h | 5 +- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index b04fbedd14..b663a3726d 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -19,14 +19,20 @@ void Timing_2010::Convert(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRels m_pRels = pRels; ConvertTnLst(timimg.tnLst.get2(), pTagExtAnim->m_pExtTimeNodeContainer); - ConvertBldLst(timimg.bldLst.get2(), pTagExtAnim->m_pBuildListContainer); + ConvertBldLst(timimg, pTagExtAnim->m_pBuildListContainer); } -void Timing_2010::ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC) +void Timing_2010::ConvertBldLst(PPTX::Logic::Timing &timimg, CRecordBuildListContainer *pBLC) { if (pBLC == nullptr) return; - bldLst.list.clear(); // It maybe not correct + if (timimg.bldLst.IsInit()) + timimg.bldLst->list.clear(); + if (pBLC->m_arRecords.empty()) + return; + if (!timimg.bldLst.IsInit()) + timimg.bldLst = new PPTX::Logic::BldLst; + for (IRecord* pDBC : pBLC->m_arRecords) { @@ -38,8 +44,11 @@ void Timing_2010::ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListCon continue; FillBuildNodeBase(pSub, oBuildNodeBase); - InsertBuildNode(bldLst, oBuildNodeBase); + InsertBuildNode(timimg.bldLst.get2(), oBuildNodeBase); } + + if (timimg.bldLst->list.empty()) // You can't leave an empty tag + timimg.bldLst.reset(); } void Timing_2010::InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb) @@ -99,6 +108,9 @@ void Timing_2010::FillBuildNodeBase(CRecordBuildListSubContainer *pSub, PPTX::Lo void Timing_2010::FillBldP(CRecordParaBuildContainer* pPBC, PPTX::Logic::BldP &oBP) { + if (pPBC == nullptr) + return; + oBP.spid = std::to_wstring(pPBC->buildAtom.m_nShapeIdRef); oBP.grpId = (int)pPBC->buildAtom.m_nBuildId; oBP.uiExpand = pPBC->buildAtom.m_fExpanded; @@ -120,6 +132,9 @@ void Timing_2010::FillBldP(CRecordParaBuildContainer* pPBC, PPTX::Logic::BldP &o void Timing_2010::FillBldOleChart(CRecordChartBuildContainer *pCBC, PPTX::Logic::BldOleChart &oBP) { + if (pCBC == nullptr) + return; + oBP.spid = std::to_wstring(pCBC->buildAtom.m_nShapeIdRef); oBP.grpId = (int)pCBC->buildAtom.m_nBuildId; oBP.uiExpand = pCBC->buildAtom.m_fExpanded; @@ -139,6 +154,9 @@ void Timing_2010::FillBldOleChart(CRecordChartBuildContainer *pCBC, PPTX::Logic: void Timing_2010::FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP) { + if (pDBC == nullptr) + return; + oBP.spid = std::to_wstring(pDBC->buildAtom.m_nShapeIdRef); oBP.grpId = (int)pDBC->buildAtom.m_nBuildId; oBP.uiExpand = pDBC->buildAtom.m_fExpanded; @@ -369,11 +387,6 @@ void Timing_2010::FillCBhvr(CRecordTimeBehaviorContainer *pBhvr, PPTX::Logic::CB m_oClientVisualElement. m_oVisualShapeAtom.m_nObjectIdRef; - // if (isSpidReal(spid) == false) - // { - // m_isPPT10Broken = true; /// TODO Here. Check with 1995 anim - // } - oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt(); oBhvr.tgtEl.spTgt->spid = std::to_wstring(spid); @@ -920,7 +933,7 @@ void Timing_2010::FillCmd(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Cmd & return; auto pCommand = pETNC->m_pTimeCommandBehavior; - auto oAtom = pCommand->m_oCommandBehaviorAtom; + const auto& oAtom = pCommand->m_oCommandBehaviorAtom; FillCBhvr(pETNC, oCmd.cBhvr); @@ -1105,12 +1118,6 @@ void Timing_2010::FillCTnHeadArgs(CRecordExtTimeNodeContainer *pETNC, PPTX::Logi if (cTNLevel == TimeNodeLevel::mainSeqOrTrigger) isMainSeq = oCTn.nodeType.get_value_or(L"") == L"mainSeq"; - if (oCTn.nodeType.IsInit() == false && (cTNLevel == TimeNodeLevel::eventOrClickGroup || cTNLevel == TimeNodeLevel::parallelShow)) - { - oCTn.nodeType = new PPTX::Limit::TLNodeType(); - oCTn.nodeType->set( cTNLevel == TimeNodeLevel::parallelShow ? L"clickPar" : L"withGroup"); - } - if (!pETNC->m_haveSequenceAtom) { // Write stCondLst @@ -1234,7 +1241,7 @@ void Timing_2010::FillAnimClr( strVal = L"accent" + std::to_wstring(index - 3); } pScheme->val = strVal; - oAnimClr.to.Color = pScheme; + oAnimClr.to.Color = smart_ptr(pScheme); } } } @@ -1278,7 +1285,7 @@ void Timing_2010::FillAnimMotion( return; auto pMotion = pETNC->m_pTimeMotionBehavior; - auto oAtom = pMotion->m_oMotionBehaviorAtom; + const auto& oAtom = pMotion->m_oMotionBehaviorAtom; FillCBhvr(pETNC, oAnim.cBhvr); @@ -1322,7 +1329,7 @@ void Timing_2010::FillAnimRot( if (!pETNC || !pETNC->m_pTimeRotationBehavior) return; auto pRot = pETNC->m_pTimeRotationBehavior; - auto oAtom = pRot->m_oRotationBehaviorAtom; + const auto& oAtom = pRot->m_oRotationBehaviorAtom; FillCBhvr(pETNC, oAnim.cBhvr); @@ -1344,7 +1351,7 @@ void Timing_2010::FillAnimScale( if (!pETNC || !pETNC->m_pTimeScaleBehavior) return; auto pScale = pETNC->m_pTimeScaleBehavior; - auto oAtom = pScale->m_oScaleBehaviorAtom; + const auto& oAtom = pScale->m_oScaleBehaviorAtom; FillCBhvr(pETNC, oAnim.cBhvr); @@ -1375,7 +1382,7 @@ void Timing_2010::FillVideo( CRecordExtTimeNodeContainer* pETNC, PPTX::Logic::Video& oVideo) { - auto video = pETNC->m_pClientVisualElement->m_oVisualShapeAtom; + const auto& video = pETNC->m_pClientVisualElement->m_oVisualShapeAtom; FillCTnRecursive(pETNC, oVideo.cMediaNode.cTn); @@ -1404,13 +1411,5 @@ void Timing_2010::FillVideo( oVideo.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(video.m_nObjectIdRef); } -void Timing_2010::FillAnimationPar(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Par &oPar) -{ - - -} - - - } } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index 76bba32af2..6b82c34196 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -49,7 +49,7 @@ public: private: - void ConvertBldLst(PPTX::Logic::BldLst &bldLst, CRecordBuildListContainer *pBLC); + void ConvertBldLst(PPTX::Logic::Timing& timimg, CRecordBuildListContainer *pBLC); void InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb); void InsertBldP(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb); void FillBuildNodeBase(CRecordBuildListSubContainer* pSub, PPTX::Logic::BuildNodeBase &oBuildNodeBase); @@ -124,9 +124,6 @@ private: void FillVideo( CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Video &oVideo); - void FillAnimationPar( // TODO next - CRecordExtTimeNodeContainer *pETNC, - PPTX::Logic::Par &oPar); private: CRecordPP10SlideBinaryTagExtension* pTagExtAnim = nullptr; From f03a7584dc29f4fddd0a54da9db3bf940ad6656b Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 24 Nov 2022 13:50:29 +0300 Subject: [PATCH 21/22] add HashCode10Atom. But it does not calculate hash correct --- .../Converter/Animation/Timing_2010.cpp | 53 +++++++---- .../Converter/Animation/Timing_2010.h | 4 +- .../Converter/Animation/hashcode10.cpp | 93 +++++++++++++++++++ .../Converter/Animation/hashcode10.h | 24 +++++ .../PPTFormatLib/Converter/timing.cpp | 7 ++ .../PPTFormatLib/Linux/PPTFormatLib.pro | 2 + .../PPTFormatLib/PPTXWriter/Converter.cpp | 5 +- .../PPTFormatLib/PPTXWriter/Converter.h | 2 +- .../Records/Animations/AnimationInfoAtom.h | 7 +- 9 files changed, 171 insertions(+), 26 deletions(-) create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.cpp create mode 100644 ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.h diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index b663a3726d..b4aaa470d0 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -13,13 +13,13 @@ Timing_2010::Timing_2010(CRecordPP10SlideBinaryTagExtension *pAnim_2010, const s slideShapes(shapesID) {} -void Timing_2010::Convert(PPTX::Logic::Timing &timimg, CExMedia *pExMedia, CRelsGenerator *pRels) +void Timing_2010::Convert(PPTX::Logic::Timing &timing, CExMedia *pExMedia, CRelsGenerator *pRels) { m_pExMedia = pExMedia; m_pRels = pRels; - ConvertTnLst(timimg.tnLst.get2(), pTagExtAnim->m_pExtTimeNodeContainer); - ConvertBldLst(timimg, pTagExtAnim->m_pBuildListContainer); + ConvertTnLst(timing, pTagExtAnim->m_pExtTimeNodeContainer); + ConvertBldLst(timing, pTagExtAnim->m_pBuildListContainer); } void Timing_2010::ConvertBldLst(PPTX::Logic::Timing &timimg, CRecordBuildListContainer *pBLC) @@ -46,15 +46,12 @@ void Timing_2010::ConvertBldLst(PPTX::Logic::Timing &timimg, CRecordBuildListCon FillBuildNodeBase(pSub, oBuildNodeBase); InsertBuildNode(timimg.bldLst.get2(), oBuildNodeBase); } - - if (timimg.bldLst->list.empty()) // You can't leave an empty tag - timimg.bldLst.reset(); } void Timing_2010::InsertBuildNode(PPTX::Logic::BldLst &bldLst, PPTX::Logic::BuildNodeBase &bnb) { if (bnb.m_node.is()) - InsertBldP(bldLst, bnb); + InsertBldP(bldLst, bnb); else if (bnb.m_node.IsInit()) // TODO BldOleChart and RT_DiagramBuild. Now it is not support (20.11.22). bldLst.list.push_back(bnb); else @@ -184,8 +181,12 @@ void Timing_2010::FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::Bl oBP.bld = ST_TLDiagramBuildType[pDBC->m_oDiagramBuildAtom.m_oDiagramBuild % 17]; } -void Timing_2010::ConvertTnLst(PPTX::Logic::TnLst &tnLst, CRecordExtTimeNodeContainer *pETNC) +void Timing_2010::ConvertTnLst(PPTX::Logic::Timing &timing, CRecordExtTimeNodeContainer *pETNC) { + if (!timing.tnLst.IsInit()) + timing.tnLst = new PPTX::Logic::TnLst; + + auto& tnLst = timing.tnLst.get2(); if (tnLst.list.empty()) tnLst.list.push_back(PPTX::Logic::TimeNodeBase()); @@ -199,23 +200,29 @@ bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T if (!oChild.m_node.IsInit()) oChild.m_node = new PPTX::Logic::Seq; - FillSeq(pETNC, oChild.m_node.as()); + if (oChild.m_node.is()) + FillSeq(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveSetBehavior) { if (!oChild.m_node.IsInit()) oChild.m_node = new PPTX::Logic::Set; - FillSet(pETNC, oChild.m_node.as()); + if (oChild.m_node.is()) + FillSet(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveAnimateBehavior) { if (!oChild.m_node.IsInit()) oChild.m_node = new PPTX::Logic::Anim; - auto& anim = oChild.m_node.as(); - FillAnim(pETNC->m_pTimeAnimateBehavior, anim); - FillCTnRecursive(pETNC, anim.cBhvr.cTn); + if (oChild.m_node.is()) + { + auto& anim = oChild.m_node.as(); + + FillAnim(pETNC->m_pTimeAnimateBehavior, anim); + FillCTnRecursive(pETNC, anim.cBhvr.cTn); + } } else if (pETNC->m_haveColorBehavior) { @@ -229,7 +236,8 @@ bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T if (!oChild.m_node.IsInit()) oChild.m_node = new PPTX::Logic::AnimEffect; - FillAnimEffect(pETNC, oChild.m_node.as()); + if (oChild.m_node.is()) + FillAnimEffect(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveMotionBehavior) { @@ -257,14 +265,16 @@ bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T if (!oChild.m_node.IsInit()) oChild.m_node = new PPTX::Logic::Cmd; - FillCmd(pETNC, oChild.m_node.as()); + if (oChild.m_node.is()) + FillCmd(pETNC, oChild.m_node.as()); } else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) { if (!oChild.m_node.IsInit()) oChild.m_node = new PPTX::Logic::Par; - FillPar(pETNC, oChild.m_node.as()); + if (oChild.m_node.is()) + FillPar(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveClientVisualElement) { @@ -387,9 +397,12 @@ void Timing_2010::FillCBhvr(CRecordTimeBehaviorContainer *pBhvr, PPTX::Logic::CB m_oClientVisualElement. m_oVisualShapeAtom.m_nObjectIdRef; - oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt(); - oBhvr.tgtEl.spTgt->spid = - std::to_wstring(spid); + if (!oBhvr.tgtEl.spTgt.IsInit()) + { + oBhvr.tgtEl.spTgt = new PPTX::Logic::SpTgt; + oBhvr.tgtEl.spTgt->spid = std::to_wstring(spid); + } + if (m_currentBldP) { m_currentBldP->spid = @@ -1407,7 +1420,7 @@ void Timing_2010::FillVideo( } - oVideo.cMediaNode.tgtEl.spTgt = PPTX::Logic::SpTgt(); + oVideo.cMediaNode.tgtEl.spTgt = new PPTX::Logic::SpTgt(); oVideo.cMediaNode.tgtEl.spTgt->spid = std::to_wstring(video.m_nObjectIdRef); } diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h index 6b82c34196..fa4e706358 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.h @@ -34,7 +34,7 @@ class Timing_2010 { public: Timing_2010(CRecordPP10SlideBinaryTagExtension* pAnim_2010, const std::unordered_set& shapesID); - void Convert(PPTX::Logic::Timing& timimg, CExMedia* pExMedia, CRelsGenerator* pRels); + void Convert(PPTX::Logic::Timing& timing, CExMedia* pExMedia, CRelsGenerator* pRels); public: enum TimeNodeLevel { @@ -57,7 +57,7 @@ private: void FillBldOleChart(CRecordChartBuildContainer* pCBC, PPTX::Logic::BldOleChart &oBP); void FillBldDgm(CRecordDiagramBuildContainer *pDBC, PPTX::Logic::BldDgm &oBP); - void ConvertTnLst(PPTX::Logic::TnLst& tnLst, CRecordExtTimeNodeContainer* pETNC); + void ConvertTnLst(PPTX::Logic::Timing &timing, CRecordExtTimeNodeContainer* pETNC); bool FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::TimeNodeBase &oChild); void FillSeq(PPT_FORMAT::CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::Seq& oSec); void FillPar( diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.cpp new file mode 100644 index 0000000000..b03168a330 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.cpp @@ -0,0 +1,93 @@ +#include "hashcode10.h" + + +namespace PPT { +namespace Converter { +std::array<_UINT32, HashCode10::RASize> HashCode10::InitRandomArray() +{ + std::array<_UINT32, 256*256> randomArray; + std::fill(randomArray.begin(), randomArray.end(), 0); + _UINT32 randomSeed = 1; + for (int iRow = 0; iRow < 256; iRow++) + for (int iCol = 0; iCol < 256; iCol++) + { + _UINT32 r0 = randomSeed; + _UINT32 r1 = ((r0 * 0x000343FD + 0x00269EC3) >> 16) & 0x00007FFF; + _UINT32 r2 = ((r1 * 0x000343FD + 0x00269EC3) >> 16) & 0x00007FFF; + _UINT32 r3 = ((r2 * 0x000343FD + 0x00269EC3) >> 16) & 0x00007FFF; + _UINT32 r4 = ((r3 * 0x000343FD + 0x00269EC3) >> 16) & 0x00007FFF; + randomSeed = r4; + r1 = (r1 % 0x100) << 0; + r2 = (r2 % 0x100) << 8; + r3 = (r3 % 0x100) << 16; + r4 = (r4 % 0x100) << 24; + randomArray[iRow*256+iCol] = r4 | r3 | r2 | r1; + } + + + return randomArray; +} + +_UINT32 HashCode10::GetHash1995(const std::vector& anim95) +{ + auto hashTabble = InitRandomArray(); + auto& randomArray = hashTabble; + _UINT32 hash = 0; + for (const auto& animInfoAtom : anim95) + { + std::array asByteArr{}; // {} - init 0 + if (animInfoAtom.anim != nullptr) + asByteArr = animInfoAtom.anim->m_AnimationAtom.asByteArr; + + const auto byteLen = 36; + const _UINT32 shapeId = animInfoAtom.shapeId; + for (int byteIndex = 0; byteIndex < byteLen; byteIndex++) + { + int rowIndex = (shapeId * (byteIndex + 1)) % 256; + hash ^= randomArray[rowIndex*256+asByteArr[byteIndex]]; + } + + } + + return hash; +} + +std::vector HashCode10::MergeSlideShapesWithAnim95Struct(const std::vector &vecAnim95, std::unordered_set<_INT32> sldShapesID) +{ + std::vector merged; + for (const auto& anim : vecAnim95) + { + merged.push_back(anim); + auto iter = sldShapesID.find(anim.shapeId); + if (iter != sldShapesID.end()) + sldShapesID.erase(iter); + } + for (const auto& spid : sldShapesID) + { + Intermediate::SOldAnimation emptyAnim; + emptyAnim.shapeId = spid; + merged.push_back(emptyAnim); + } + + return merged; +} + +_UINT32 HashCode10::GetWroteHash(CRecordPP10SlideBinaryTagExtension *pTagExt) +{ + return pTagExt->m_pHashCode10Atom->m_nHash; +} + +bool HashCode10::IsValidHash(const Intermediate::SlideAnimation &sldAnim) const +{ + if (sldAnim.pAnim_2010 == nullptr || sldAnim.pAnim_2010->m_haveHashCode == false || sldAnim.pAnim_2010->m_pHashCode10Atom == nullptr) + return false; + + auto wroteHash = GetWroteHash(sldAnim.pAnim_2010); + auto calculatedHash = GetHash1995( + MergeSlideShapesWithAnim95Struct(sldAnim.arrAnim_1995, sldAnim.realShapesIds)); + + return wroteHash == calculatedHash; +} + +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.h b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.h new file mode 100644 index 0000000000..89437db927 --- /dev/null +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/hashcode10.h @@ -0,0 +1,24 @@ +#pragma once + +#include "intermediate_anim.h" + +namespace PPT { +namespace Converter { + +// I couldn't calculate simplest correct hash. Not correct now +class HashCode10 +{ +public: + HashCode10(){}; + bool IsValidHash(const Intermediate::SlideAnimation& sldAnim)const; + +private: + // 1995 hash + static constexpr size_t RASize = 256*256; // row * col + static std::array<_UINT32, RASize> InitRandomArray(); + static _UINT32 GetHash1995(const std::vector& anim95); + static std::vector MergeSlideShapesWithAnim95Struct(const std::vector& vecAnim95, std::unordered_set<_INT32> sldShapesID); + static _UINT32 GetWroteHash(CRecordPP10SlideBinaryTagExtension* pTagExt); +}; +} +} diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index 5ebfd8e44a..d23e1a23a8 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -4,6 +4,7 @@ #include "Animation/Timing_1995.h" #include "Animation/Timing_2010.h" #include "Animation/TimingExeption.h" +#include "Animation/hashcode10.h" // not work correct using namespace PPT::Converter; @@ -20,6 +21,8 @@ PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) Timing_1995(slideAnim.arrAnim_1995). Convert(timing, pExMedia, pRels); + bool isValidHash = HashCode10().IsValidHash(slideAnim); + try { Timing_2010(slideAnim.pAnim_2010, shapesID). Convert(timing, pExMedia, pRels); @@ -27,5 +30,9 @@ PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) } catch (...) { } + if (timing.bldLst.IsInit() && timing.bldLst->list.empty()) // You can't leave an empty tag + timing.bldLst.reset(); + return std::move(timing); } + diff --git a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro index 5ff1469576..be91f9ef63 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro +++ b/ASCOfficePPTFile/PPTFormatLib/Linux/PPTFormatLib.pro @@ -33,6 +33,7 @@ HEADERS += \ ../Converter/Animation/TimingUtils.h \ ../Converter/Animation/Timing_1995.h \ ../Converter/Animation/Timing_2010.h \ + ../Converter/Animation/hashcode10.h \ ../Converter/Animation/intermediate_anim.h \ ../Converter/timing.h \ ../Converter/transition.h \ @@ -311,6 +312,7 @@ SOURCES += \ ../Converter/Animation/TimingUtils.cpp \ ../Converter/Animation/Timing_1995.cpp \ ../Converter/Animation/Timing_2010.cpp \ + ../Converter/Animation/hashcode10.cpp \ ../Converter/Animation/intermediate_anim.cpp \ ../Converter/timing.cpp \ ../Converter/transition.cpp \ diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp index 50c63c4dd0..6578899484 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.cpp @@ -1859,12 +1859,13 @@ void CPPTXWriter::WriteLayoutAfterTheme(CThemePtr pTheme, const int nIndexTheme, } -void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide, const std::unordered_set& sharesID) +void PPT_FORMAT::CPPTXWriter::WriteTiming(CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide, const std::unordered_set& shapesID) { auto slide_iter = m_pUserInfo->m_mapSlides.find(m_pUserInfo->m_arrSlidesOrder[nIndexSlide]); auto intermediateSlideAnimation = PPT::Intermediate::ParseSlideAnimation(slide_iter->second); + intermediateSlideAnimation.realShapesIds = shapesID; auto timing = - PPT::Converter::Timing(intermediateSlideAnimation, sharesID). + PPT::Converter::Timing(intermediateSlideAnimation, shapesID). Convert(&(m_pUserInfo->m_oExMedia), &oRels); oWriter.WriteString(timing.toXML()); } diff --git a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h index c54c507553..0b178c285f 100644 --- a/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h +++ b/ASCOfficePPTFile/PPTFormatLib/PPTXWriter/Converter.h @@ -89,7 +89,7 @@ namespace PPT_FORMAT // void WriteRelsMaster (std::wstring path, int type, ) void WriteSlide (int nIndexSlide); void WriteNotes (int nIndexNotes); - void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide, const std::unordered_set& sharesID); + void WriteTiming (CStringWriter& oWriter, CRelsGenerator &oRels, int nIndexSlide, const std::unordered_set& shapesID); void WriteTransition (CStringWriter& oWriter, CSlideShowInfo& oSSInfo); void WriteColorScheme (CStringWriter& oWriter, const std::wstring & name, const std::vector & colors, bool extra = false); diff --git a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/AnimationInfoAtom.h b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/AnimationInfoAtom.h index 659d44eb3a..3c0da55311 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Records/Animations/AnimationInfoAtom.h +++ b/ASCOfficePPTFile/PPTFormatLib/Records/Animations/AnimationInfoAtom.h @@ -87,6 +87,8 @@ public: BYTE m_AnimAfterEffect; BYTE m_TextBuildSubEffect; BYTE m_OleVerb; + + std::array asByteArr{}; public: CRecordAnimationInfoAtom() @@ -132,8 +134,11 @@ public: StreamUtils::StreamSkip(2, pStream); - m_OldSoundIdRef = m_SoundIdRef; + + StreamUtils::StreamSkipBack(36, pStream); + auto tempStr = StreamUtils::ReadStringA(pStream, 36); + std::copy(tempStr.begin(), tempStr.end(), asByteArr.begin()); } }; } From 919ab72ecee1ca2668abd2081f50bb3b62a317ac Mon Sep 17 00:00:00 2001 From: Ivan Morozov Date: Thu, 24 Nov 2022 18:41:48 +0300 Subject: [PATCH 22/22] return animation --- .../Converter/Animation/Timing_2010.cpp | 95 ++++++------------- .../PPTFormatLib/Converter/timing.cpp | 53 ++++++++--- .../PPTFormatLib/Converter/timing.h | 8 +- 3 files changed, 74 insertions(+), 82 deletions(-) diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp index b4aaa470d0..a68a6f4036 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/Animation/Timing_2010.cpp @@ -18,6 +18,10 @@ void Timing_2010::Convert(PPTX::Logic::Timing &timing, CExMedia *pExMedia, CRels m_pExMedia = pExMedia; m_pRels = pRels; + + if (pTagExtAnim == nullptr || pTagExtAnim->m_haveExtTime == false) + return; + ConvertTnLst(timing, pTagExtAnim->m_pExtTimeNodeContainer); ConvertBldLst(timing, pTagExtAnim->m_pBuildListContainer); } @@ -197,84 +201,56 @@ bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T { if (pETNC->m_haveSequenceAtom) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Seq; - - if (oChild.m_node.is()) - FillSeq(pETNC, oChild.m_node.as()); + oChild.m_node = new PPTX::Logic::Seq; + FillSeq(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveSetBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Set; - - if (oChild.m_node.is()) - FillSet(pETNC, oChild.m_node.as()); + oChild.m_node = new PPTX::Logic::Set; + FillSet(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveAnimateBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Anim; + oChild.m_node = new PPTX::Logic::Anim; - if (oChild.m_node.is()) - { - auto& anim = oChild.m_node.as(); - - FillAnim(pETNC->m_pTimeAnimateBehavior, anim); - FillCTnRecursive(pETNC, anim.cBhvr.cTn); - } + auto& anim = oChild.m_node.as(); + FillAnim(pETNC->m_pTimeAnimateBehavior, anim); + FillCTnRecursive(pETNC, anim.cBhvr.cTn); } else if (pETNC->m_haveColorBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::AnimClr; - + oChild.m_node = new PPTX::Logic::AnimClr; FillAnimClr(pETNC->m_pTimeColorBehavior, pETNC->m_pTimePropertyList, oChild.m_node.as()); } else if (pETNC->m_haveEffectBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::AnimEffect; - - if (oChild.m_node.is()) - FillAnimEffect(pETNC, oChild.m_node.as()); + oChild.m_node = new PPTX::Logic::AnimEffect; + FillAnimEffect(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveMotionBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::AnimMotion; - + oChild.m_node = new PPTX::Logic::AnimMotion; FillAnimMotion(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveRotationBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::AnimRot; - + oChild.m_node = new PPTX::Logic::AnimRot; FillAnimRot(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveScaleBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::AnimScale; - + oChild.m_node = new PPTX::Logic::AnimScale; FillAnimScale(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveCommandBehavior) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Cmd; - - if (oChild.m_node.is()) - FillCmd(pETNC, oChild.m_node.as()); + oChild.m_node = new PPTX::Logic::Cmd; + FillCmd(pETNC, oChild.m_node.as()); } else if (pETNC->m_oTimeNodeAtom.m_dwType == TL_TNT_Parallel) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Par; - - if (oChild.m_node.is()) - FillPar(pETNC, oChild.m_node.as()); + oChild.m_node = new PPTX::Logic::Par; + FillPar(pETNC, oChild.m_node.as()); } else if (pETNC->m_haveClientVisualElement) { @@ -286,17 +262,13 @@ bool Timing_2010::FillTnChild(CRecordExtTimeNodeContainer *pETNC, PPTX::Logic::T { if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Video) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Video; - + oChild.m_node = new PPTX::Logic::Video; FillVideo(pETNC, oChild.m_node.as()); } if (pETNC->m_pClientVisualElement->m_oVisualShapeAtom.m_Type == TL_TVET_Audio) { - if (!oChild.m_node.IsInit()) - oChild.m_node = new PPTX::Logic::Audio; - + oChild.m_node = new PPTX::Logic::Audio; FillAudio(pETNC, oChild.m_node.as()); } } @@ -616,23 +588,10 @@ void Timing_2010::FillCTnRecursive(CRecordExtTimeNodeContainer *pETNC, PPTX::Log bool Timing_2010::CheckAnimation5Level(const CRecordExtTimeNodeContainer *pETNC, const PPTX::Logic::CTn &oCTn) { auto anim_2010 = Intermediate::ParseExisting5Level_ETNC(pETNC); - if (IsSlideSpId(anim_2010.spid) == false) - return false; - if (isMainSeq == false) - { + bool isSlideShape = IsSlideSpId(anim_2010.spid); + if (isSlideShape) InsertAnimationSpId(anim_2010.spid); - return true; - } - if(IsCorrectAnimationSpId(anim_2010.spid)) - return true; - - auto anim_pptx = Intermediate::ParseExisting5Level_CTn(oCTn); - if (anim_pptx == anim_2010) - { - correctAnimatedShapes.insert(anim_2010.spid); - return true; - } else - return false; + return isSlideShape; } bool Timing_2010::IsSlideSpId(_INT32 spid) const diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp index d23e1a23a8..02534005d9 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.cpp @@ -16,19 +16,12 @@ Timing::Timing(const Intermediate::SlideAnimation& slideAnim, const std::unorder PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) { -// this->pExMedia = pExMedia; -// this->pRels = pRels; + this->pExMedia = pExMedia; + this->pRels = pRels; - Timing_1995(slideAnim.arrAnim_1995). - Convert(timing, pExMedia, pRels); - bool isValidHash = HashCode10().IsValidHash(slideAnim); - - try { - Timing_2010(slideAnim.pAnim_2010, shapesID). - Convert(timing, pExMedia, pRels); - } catch (const TimingExeption &ex) { - } catch (...) { - } + if (TryToConvertTiming2010() == false) + if (TryToConvertTiming1995() == false) + return {}; if (timing.bldLst.IsInit() && timing.bldLst->list.empty()) // You can't leave an empty tag timing.bldLst.reset(); @@ -36,3 +29,39 @@ PPTX::Logic::Timing Timing::Convert(CExMedia *pExMedia, CRelsGenerator *pRels) return std::move(timing); } +bool Timing::HasAnimation() const +{ + if (slideAnim.arrAnim_1995.empty() && (slideAnim.pAnim_2010 == nullptr || slideAnim.pAnim_2010->m_haveExtTime == false)) + return false; + else + return true; +} + +bool Timing::TryToConvertTiming2010() +{ + timing = PPTX::Logic::Timing(); + try { + Timing_2010(slideAnim.pAnim_2010, shapesID). + Convert(timing, pExMedia, pRels); + } catch (const TimingExeption &ex) { + return false; + } catch (...) { + return false; + } + return true; +} + +bool Timing::TryToConvertTiming1995() +{ + timing = PPTX::Logic::Timing(); + try { + Timing_1995(slideAnim.arrAnim_1995). + Convert(timing, pExMedia, pRels); + } catch (const TimingExeption &ex) { + return false; + } catch (...) { + return false; + } + return true; +} + diff --git a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h index dcf4de2724..5065d012c1 100644 --- a/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h +++ b/ASCOfficePPTFile/PPTFormatLib/Converter/timing.h @@ -15,10 +15,14 @@ public: bool HasAnimation() const; +private: + bool TryToConvertTiming2010(); + bool TryToConvertTiming1995(); + private: const Intermediate::SlideAnimation& slideAnim; -// CExMedia* pExMedia; -// CRelsGenerator* pRels; + CExMedia* pExMedia; + CRelsGenerator* pRels; const std::unordered_set shapesID; PPTX::Logic::Timing timing; };