[Libreoffice-commits] core.git: include/oox oox/Library_oox.mk oox/source sd/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Feb 23 10:50:19 UTC 2019
include/oox/ppt/presPropsfragmenthandler.hxx | 41 ++++++++++++++++++++
oox/Library_oox.mk | 1
oox/source/ppt/pptimport.cxx | 9 ++++
oox/source/ppt/presPropsfragmenthandler.cxx | 55 +++++++++++++++++++++++++++
sd/qa/unit/data/pptx/loopNoPause.pptx |binary
sd/qa/unit/import-tests.cxx | 21 ++++++++++
6 files changed, 127 insertions(+)
New commits:
commit ad2809b4b6dc4837b0c1cadd89a14a234d995fb2
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Feb 23 01:52:05 2019 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Feb 23 11:49:51 2019 +0100
tdf#47365: import support for PPTX presentation's loop attribute
presProps stream handler is added to do this.
Export is not handled here.
Change-Id: I1979941a09c472c14f96c778ca9960ec14786fbe
Reviewed-on: https://gerrit.libreoffice.org/68237
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
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
new file mode 100644
index 000000000000..f0c9966ceeea
Binary files /dev/null and b/sd/qa/unit/data/pptx/loopNoPause.pptx differ
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();
More information about the Libreoffice-commits
mailing list