Kaydet (Commit) ad2809b4 authored tarafından Mike Kaganski's avatar Mike Kaganski

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst c9611c5e
/* -*- 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: */
...@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\ ...@@ -266,6 +266,7 @@ $(eval $(call gb_Library_add_exception_objects,oox,\
oox/source/ppt/pptshapegroupcontext \ oox/source/ppt/pptshapegroupcontext \
oox/source/ppt/pptshapepropertiescontext \ oox/source/ppt/pptshapepropertiescontext \
oox/source/ppt/presentationfragmenthandler \ oox/source/ppt/presentationfragmenthandler \
oox/source/ppt/presPropsfragmenthandler \
oox/source/ppt/slidefragmenthandler \ oox/source/ppt/slidefragmenthandler \
oox/source/ppt/slidemastertextstylescontext \ oox/source/ppt/slidemastertextstylescontext \
oox/source/ppt/slidepersist \ oox/source/ppt/slidepersist \
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <oox/helper/graphichelper.hxx> #include <oox/helper/graphichelper.hxx>
#include <oox/ole/vbaproject.hxx> #include <oox/ole/vbaproject.hxx>
#include <oox/ppt/presentationfragmenthandler.hxx> #include <oox/ppt/presentationfragmenthandler.hxx>
#include <oox/ppt/presPropsfragmenthandler.hxx>
#include <oox/token/tokens.hxx> #include <oox/token/tokens.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -125,6 +126,8 @@ bool PowerPointImport::importDocument() ...@@ -125,6 +126,8 @@ bool PowerPointImport::importDocument()
OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" ); OUString aFragmentPath = getFragmentPathFromFirstTypeFromOfficeDoc( "officeDocument" );
FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) ); FragmentHandlerRef xPresentationFragmentHandler( new PresentationFragmentHandler( *this, aFragmentPath ) );
maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "tableStyles" ); maTableStyleListPath = xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( "tableStyles" );
const OUString sPresPropsPath
= xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc("presProps");
// importRelations() is cheap, it will do an actual import for the first time only. // importRelations() is cheap, it will do an actual import for the first time only.
if (core::RelationsRef pFragmentRelations = importRelations(aFragmentPath)) if (core::RelationsRef pFragmentRelations = importRelations(aFragmentPath))
...@@ -137,6 +140,12 @@ bool PowerPointImport::importDocument() ...@@ -137,6 +140,12 @@ bool PowerPointImport::importDocument()
} }
bool bRet = importFragment(xPresentationFragmentHandler); bool bRet = importFragment(xPresentationFragmentHandler);
if (bRet && !sPresPropsPath.isEmpty())
{
FragmentHandlerRef xPresPropsFragmentHandler(
new PresPropsFragmentHandler(*this, sPresPropsPath));
importFragment(xPresPropsFragmentHandler);
}
static bool bNoSmartartWarning = getenv("OOX_NO_SMARTART_WARNING"); static bool bNoSmartartWarning = getenv("OOX_NO_SMARTART_WARNING");
if (!bNoSmartartWarning && mbMissingExtDrawing) if (!bNoSmartartWarning && mbMissingExtDrawing)
......
/* -*- 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: */
...@@ -197,6 +197,7 @@ public: ...@@ -197,6 +197,7 @@ public:
void testTdf44223(); void testTdf44223();
void testDescriptionImport(); void testDescriptionImport();
void testTdf83247(); void testTdf83247();
void testTdf47365();
CPPUNIT_TEST_SUITE(SdImportTest); CPPUNIT_TEST_SUITE(SdImportTest);
...@@ -284,6 +285,7 @@ public: ...@@ -284,6 +285,7 @@ public:
CPPUNIT_TEST(testTdf44223); CPPUNIT_TEST(testTdf44223);
CPPUNIT_TEST(testDescriptionImport); CPPUNIT_TEST(testDescriptionImport);
CPPUNIT_TEST(testTdf83247); CPPUNIT_TEST(testTdf83247);
CPPUNIT_TEST(testTdf47365);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -2694,6 +2696,25 @@ void SdImportTest::testTdf83247() ...@@ -2694,6 +2696,25 @@ void SdImportTest::testTdf83247()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/ppt/loopNoPause.ppt", PPT)); 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_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment