diff options
-rw-r--r-- | include/oox/ppt/presPropsfragmenthandler.hxx | 41 | ||||
-rw-r--r-- | oox/Library_oox.mk | 1 | ||||
-rw-r--r-- | oox/source/ppt/pptimport.cxx | 9 | ||||
-rw-r--r-- | oox/source/ppt/presPropsfragmenthandler.cxx | 55 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/loopNoPause.pptx | bin | 0 -> 32373 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 21 |
6 files changed, 127 insertions, 0 deletions
diff --git a/include/oox/ppt/presPropsfragmenthandler.hxx b/include/oox/ppt/presPropsfragmenthandler.hxx new file mode 100644 index 000000000000..d760f39f4524 --- /dev/null +++ b/include/oox/ppt/presPropsfragmenthandler.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_OOX_PPT_PRESPROPSFRAGMENTHANDLER_HXX +#define INCLUDED_OOX_PPT_PRESPROPSFRAGMENTHANDLER_HXX + +#include <oox/core/fragmenthandler2.hxx> + +namespace oox +{ +namespace core +{ +class XmlFilterBase; +} + +namespace ppt +{ +class PresPropsFragmentHandler final : public core::FragmentHandler2 +{ +public: + PresPropsFragmentHandler(core::XmlFilterBase& rFilter, const OUString& rFragmentPath); + virtual ~PresPropsFragmentHandler() override; + virtual void finalizeImport() override; + virtual core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, + const AttributeList& rAttribs) override; + +private: + bool m_bLoop = false; +}; +} // namespace ppt +} // namespace oox + +#endif // INCLUDED_OOX_PPT_PRESPROPSFRAGMENTHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk index f924d27543ba..7da04f81a6ce 100644 --- a/oox/Library_oox.mk +++ b/oox/Library_oox.mk @@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\ oox/source/ppt/pptshapegroupcontext \ oox/source/ppt/pptshapepropertiescontext \ oox/source/ppt/presentationfragmenthandler \ + oox/source/ppt/presPropsfragmenthandler \ oox/source/ppt/slidefragmenthandler \ oox/source/ppt/slidemastertextstylescontext \ oox/source/ppt/slidepersist \ diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 22f661d95546..d65e408d3c13 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -40,6 +40,7 @@ #include <oox/helper/graphichelper.hxx> #include <oox/ole/vbaproject.hxx> #include <oox/ppt/presentationfragmenthandler.hxx> +#include <oox/ppt/presPropsfragmenthandler.hxx> #include <oox/token/tokens.hxx> using namespace ::com::sun::star; @@ -125,6 +126,8 @@ bool PowerPointImport::importDocument() OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" ); FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) ); maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "tableStyles" ); + const OUString sPresPropsPath + = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc("presProps"); // importRelations() is cheap, it will do an actual import for the first time only. if (core::RelationsRef pFragmentRelations = importRelations(aFragmentPath)) @@ -137,6 +140,12 @@ bool PowerPointImport::importDocument() } bool bRet = importFragment(xPresentationFragmentHandler); + if (bRet && !sPresPropsPath.isEmpty()) + { + FragmentHandlerRef xPresPropsFragmentHandler( + new PresPropsFragmentHandler(*this, sPresPropsPath)); + importFragment(xPresPropsFragmentHandler); + } static bool bNoSmartartWarning = getenv("OOX_NO_SMARTART_WARNING"); if (!bNoSmartartWarning && mbMissingExtDrawing) diff --git a/oox/source/ppt/presPropsfragmenthandler.cxx b/oox/source/ppt/presPropsfragmenthandler.cxx new file mode 100644 index 000000000000..effee38dfaa0 --- /dev/null +++ b/oox/source/ppt/presPropsfragmenthandler.cxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/presentation/XPresentationSupplier.hpp> + +#include <oox/helper/attributelist.hxx> +#include <oox/ppt/pptimport.hxx> +#include <oox/ppt/presPropsfragmenthandler.hxx> +#include <oox/token/namespaces.hxx> + +namespace oox +{ +namespace ppt +{ +PresPropsFragmentHandler::PresPropsFragmentHandler(core::XmlFilterBase& rFilter, + const OUString& rFragmentPath) + : FragmentHandler2(rFilter, rFragmentPath) +{ +} + +PresPropsFragmentHandler::~PresPropsFragmentHandler() = default; + +void PresPropsFragmentHandler::finalizeImport() +{ + css::uno::Reference<css::presentation::XPresentationSupplier> xPresentationSupplier( + getFilter().getModel(), css::uno::UNO_QUERY_THROW); + css::uno::Reference<css::beans::XPropertySet> xPresentationProps( + xPresentationSupplier->getPresentation(), css::uno::UNO_QUERY_THROW); + xPresentationProps->setPropertyValue("IsEndless", css::uno::Any(m_bLoop)); +} + +core::ContextHandlerRef PresPropsFragmentHandler::onCreateContext(sal_Int32 aElementToken, + const AttributeList& rAttribs) +{ + switch (aElementToken) + { + case PPT_TOKEN(presentationPr): + return this; + case PPT_TOKEN(showPr): + m_bLoop = rAttribs.getBool(XML_loop, false); + return this; + } + return this; +} +} // namespace ppt +} // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sd/qa/unit/data/pptx/loopNoPause.pptx b/sd/qa/unit/data/pptx/loopNoPause.pptx Binary files differnew file mode 100644 index 000000000000..f0c9966ceeea --- /dev/null +++ b/sd/qa/unit/data/pptx/loopNoPause.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index c47982d39066..684dacbb7a84 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -197,6 +197,7 @@ public: void testTdf44223(); void testDescriptionImport(); void testTdf83247(); + void testTdf47365(); CPPUNIT_TEST_SUITE(SdImportTest); @@ -284,6 +285,7 @@ public: CPPUNIT_TEST(testTdf44223); CPPUNIT_TEST(testDescriptionImport); CPPUNIT_TEST(testTdf83247); + CPPUNIT_TEST(testTdf47365); CPPUNIT_TEST_SUITE_END(); }; @@ -2694,6 +2696,25 @@ void SdImportTest::testTdf83247() CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/ppt/loopNoPause.ppt", PPT)); } +void SdImportTest::testTdf47365() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/loopNoPause.pptx"), PPTX); + uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier( + xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(), + uno::UNO_QUERY_THROW); + + const bool bEndlessVal = xPresentationProps->getPropertyValue("IsEndless").get<bool>(); + const sal_Int32 nPauseVal = xPresentationProps->getPropertyValue("Pause").get<sal_Int32>(); + + // Check that we import "loop" attribute of the presentation, and don't introduce any pauses + CPPUNIT_ASSERT(bEndlessVal); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPauseVal); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |