[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 3 commits - filter/source sd/CppunitTest_sd_svg_export_tests.mk sd/Module_sd.mk sd/qa

Marco Cecchetti marco.cecchetti at collabora.com
Thu Dec 10 02:22:56 PST 2015


 filter/source/svg/presentation_engine.js            |   28 +++-
 filter/source/svg/svgexport.cxx                     |   55 ++++++++
 sd/CppunitTest_sd_svg_export_tests.mk               |   76 ++++++++++++
 sd/Module_sd.mk                                     |    1 
 sd/qa/unit/SVGExportTests.cxx                       |  123 ++++++++++++++++++++
 sd/qa/unit/data/odp/svg-export-text-decorations.odp |binary
 6 files changed, 278 insertions(+), 5 deletions(-)

New commits:
commit 2e39954a7cf955c296cedf7c4a7a9ccd06b10283
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Wed Dec 9 21:50:39 2015 +0100

    svg export: transition on first slide are not run - fixed
    
    A dummy slide has been added to be used as leaving slide for transition
    on first slide.
    
    SVGExportTextDecorations unit test - fixed wrong XPath.
    The new dummy slide group element caused the xpath to the slide
    group to be wrong.
    
    Change-Id: I6c1a0a80f71a79668c309bc0bcb3d5e588ef3a39

diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js
index 569a562..c1cc82b 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -1215,6 +1215,9 @@ function MetaDocument()
     this.aSlideAnimationsMap = new Object();
     this.initSlideAnimationsMap();
 
+    // We initialize dummy slide - used as leaving slide for transition on the first slide
+    this.theMetaDummySlide = new MetaSlide( 'ooo:meta_dummy_slide', this );
+
     // We initialize the set of MetaSlide objects that handle the meta
     // information for each slide.
     for( var i = 0; i < this.nNumberOfSlides; ++i )
@@ -1316,7 +1319,11 @@ function MetaSlide( sMetaSlideId, aMetaDoc )
     this.slideElement = this.theDocument.getElementById( this.slideId );
     assert( this.slideElement,
             'MetaSlide: slide element <' + this.slideId + '> not found.' );
-    this.nSlideNumber = parseInt( this.slideId.substr(2) );
+
+    if( this.slideId !== 'dummy_slide' )
+        this.nSlideNumber = parseInt( this.slideId.substr(2) );
+    else
+        this.nSlideNumber= -1;
 
     // Each slide element is wrapped by a <g> element that is responsible for
     // the slide element visibility. In fact the visibility attribute has
@@ -12588,11 +12595,22 @@ SlideShow.prototype.displaySlide = function( nNewSlide, bSkipSlideTransition )
     if( this.isEnabled() && !bSkipSlideTransition  )
     {
         // create slide transition and add to activity queue
-        if ( ( nOldSlide !== undefined ) &&
-            ( ( nNewSlide > nOldSlide ) ||
-              ( ( nNewSlide == 0) && ( nOldSlide == (aMetaDoc.nNumberOfSlides - 1) ) ) ) )
+        if ( ( ( nOldSlide !== undefined ) &&
+               ( ( nNewSlide > nOldSlide ) ||
+               ( ( nNewSlide == 0) && ( nOldSlide == (aMetaDoc.nNumberOfSlides - 1) ) ) ) ) ||
+             (  ( nOldSlide === undefined ) &&  ( nNewSlide == 0) )  // for transition on first slide
+           )
         {
-            var aOldMetaSlide = aMetaDoc.aMetaSlideSet[nOldSlide];
+
+            var aOldMetaSlide = null;
+            if( nOldSlide === undefined ) // for transition on first slide
+            {
+                aOldMetaSlide = aMetaDoc.theMetaDummySlide;
+            }
+            else
+            {
+                aOldMetaSlide = aMetaDoc.aMetaSlideSet[nOldSlide];
+            }
             var aNewMetaSlide = aMetaDoc.aMetaSlideSet[nNewSlide];
 
             var aSlideTransitionHandler = aNewMetaSlide.aTransitionHandler;
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index d62f325..83bb22b 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -1009,6 +1009,18 @@ bool SVGFilter::implGenerateMetaData()
             const OUString                aElemTextFieldId( aOOOElemTextField );
             std::vector< TextField* >     aFieldSet;
 
+            // dummy slide - used as leaving slide for transition on the first slide
+            if( mbPresentation )
+            {
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", NSPREFIX "meta_dummy_slide" );
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrSlide, "dummy-slide" );
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMaster, "dummy-master-page" );
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrBackgroundVisibility, "hidden" );
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrMasterObjectsVisibility, "hidden" );
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrHasTransition, "false" );
+                SvXMLElementExport aMetaDummySlideElem( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+            }
+
             for( sal_Int32 i = 0; i < nCount; ++i )
             {
                 const Reference< XDrawPage > &    xDrawPage = mSelectedPages[i];
@@ -1487,6 +1499,27 @@ bool SVGFilter::implExportMasterPages( const SVGFilter::XDrawPageSequence & rxPa
     OUString aContainerTag = (!mbPresentation) ? OUString( "g" ) : OUString( "defs" );
     SvXMLElementExport aContainerElement( *mpSVGExport, XML_NAMESPACE_NONE, aContainerTag, true, true );
 
+    // dummy slide - used as leaving slide for transition on the first slide
+    if( mbPresentation )
+    {
+        mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", "dummy-master-page" );
+        mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, "dummy-master-page" );
+        mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "Master_Slide" );
+        SvXMLElementExport aMasterSlideElem( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+        {
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", "bg-dummy-master-page" );
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "Background" );
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", "hidden" );
+            SvXMLElementExport aBackgroundElem( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+        }
+        {
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", "bo-dummy-master-page" );
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "BackgroundObjects" );
+            mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "visibility", "hidden" );
+            SvXMLElementExport aBackgroundObjectElem( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+        }
+    }
+
     bool bRet = false;
     for( sal_Int32 i = nFirstPage; i <= nLastPage; ++i )
     {
@@ -1515,6 +1548,28 @@ bool SVGFilter::implExportDrawPages( const SVGFilter::XDrawPageSequence & rxPage
     DBG_ASSERT( nFirstPage <= nLastPage,
                 "SVGFilter::implExportDrawPages: nFirstPage > nLastPage" );
 
+    // dummy slide - used as leaving slide for transition on the first slide
+    if( mbPresentation )
+    {
+        mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "DummySlide" );
+        SvXMLElementExport aDummySlideElement( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+        {
+           SvXMLElementExport aGElement( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+            {
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", "dummy-slide" );
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "Slide" );
+                OUString sClipPathAttrValue = "url(#" + msClipPathId + ")";
+                mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "clip-path", sClipPathAttrValue );
+                SvXMLElementExport aSlideElement( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+                {
+                    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, aOOOAttrName, "dummy-page" );
+                    mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "Page" );
+                    SvXMLElementExport aPageElement( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
+                }
+            }
+        }
+    }
+
     // We wrap all slide in a group element with class name "SlideGroup".
     mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "class", "SlideGroup" );
     SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", true, true );
commit 56635089831505fff1425982bc75ae2518245cf5
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Mon Nov 9 17:50:33 2015 +0100

    tdf#95356: unit test about text decorations for svg export
    
    Added a unit test for testing that text decorations are exported
    correctly.
    
    Change-Id: I2bd71974242a0007726fbdd5ef5637a9ec62fd47
    Reviewed-on: https://gerrit.libreoffice.org/19870
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx
index 8dbbbc9..cd4259c 100644
--- a/sd/qa/unit/SVGExportTests.cxx
+++ b/sd/qa/unit/SVGExportTests.cxx
@@ -16,13 +16,52 @@
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
 
+#include <boost/preprocessor/stringize.hpp>
+
+#define MAKE_PATH_STRING( path ) BOOST_PP_STRINGIZE( path )
+#define SVG_SVG  *[name()='svg']
+#define SVG_G *[name()='g']
+#define SVG_TEXT *[name()='text']
+#define SVG_TSPAN *[name()='tspan']
+
 using namespace css;
 
-class SdSVGFilterTest : public SdModelTestBase, public XmlTestTools
+class SdSVGFilterTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools
 {
     uno::Reference<lang::XComponent> mxComponent;
     utl::TempFile maTempFile;
 
+protected:
+    virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override
+    {
+        xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"));
+    }
+
+    void load(const char* pDir, const char* pName)
+    {
+        return loadURL(getURLFromSrc(pDir) + OUString::createFromAscii(pName), pName);
+    }
+
+    void loadURL(OUString const& rURL, const char* pName)
+    {
+        if (mxComponent.is())
+            mxComponent->dispose();
+        // Output name early, so in the case of a hang, the name of the hanging input file is visible.
+        if (pName)
+            std::cout << pName << ",";
+        mxComponent = loadFromDesktop(rURL);
+        CPPUNIT_ASSERT(mxComponent.is());
+    }
+
+    void save()
+    {
+        uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+        utl::MediaDescriptor aMediaDescriptor;
+        OUString aFilterName("impress_svg_Export");
+        aMediaDescriptor["FilterName"] <<= aFilterName;
+        xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+    }
+
 public:
     SdSVGFilterTest()
     {
@@ -31,7 +70,7 @@ public:
 
     virtual void setUp() override
     {
-        SdModelTestBase::setUp();
+        test::BootstrapFixture::setUp();
 
         mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
     }
@@ -41,23 +80,35 @@ public:
         if (mxComponent.is())
             mxComponent->dispose();
 
-        SdModelTestBase::tearDown();
+        test::BootstrapFixture::tearDown();
+    }
+
+    void executeExport(const char* pName)
+    {
+        load( "/sd/qa/unit/data/odp/", pName );
+        save();
     }
 
     void testSVGExportTextDecorations()
     {
-        mxComponent = loadFromDesktop(getURLFromSrc("/sd/qa/unit/data/odp/svg-export-text-decorations.odp"));
-        CPPUNIT_ASSERT(mxComponent.is());
+        executeExport( "svg-export-text-decorations.odp" );
 
-        uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
-        utl::MediaDescriptor aMediaDescriptor;
-        OUString aFilterName("impress_svg_Export");
-        aMediaDescriptor["FilterName"] <<= aFilterName;
-        xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
-        xmlDocPtr pXmlDoc = parseXml(maTempFile);
-        CPPUNIT_ASSERT(pXmlDoc);
+        xmlDocPtr svgDoc = parseXml(maTempFile);
+        CPPUNIT_ASSERT(svgDoc);
+
+        svgDoc->name = reinterpret_cast<char *>(xmlStrdup(reinterpret_cast<xmlChar const *>(OUStringToOString(maTempFile.GetURL(), RTL_TEXTENCODING_UTF8).getStr())));
+
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG ), 1);
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2] ), "class", "SlideGroup");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G ), "class", "Slide");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1] ), "class", "TitleText");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT ), "class", "TextShape");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[1]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "underline");
 
-        // TODO use assertXPath() here.
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT ), "class", "TextShape");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "class", "TextParagraph");
+        assertXPath(svgDoc, MAKE_PATH_STRING( /SVG_SVG/SVG_G[2]/SVG_G/SVG_G/SVG_G/SVG_G[2]/SVG_G/SVG_TEXT/SVG_TSPAN ), "text-decoration", "line-through");
     }
 
     CPPUNIT_TEST_SUITE(SdSVGFilterTest);
commit e1d1cdd618f43706c47ae119f0409ba9d587f127
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date:   Thu Nov 5 12:49:20 2015 +0100

    sd: add support for svg export unit tests
    
    Change-Id: Iafeaecad612b724c4eeb85e0c01c942afb6445d8

diff --git a/sd/CppunitTest_sd_svg_export_tests.mk b/sd/CppunitTest_sd_svg_export_tests.mk
new file mode 100644
index 0000000..36f64ea
--- /dev/null
+++ b/sd/CppunitTest_sd_svg_export_tests.mk
@@ -0,0 +1,76 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# 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/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sd_svg_export_tests))
+
+$(eval $(call gb_CppunitTest_use_externals,sd_svg_export_tests,\
+	boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_svg_export_tests, \
+    sd/qa/unit/SVGExportTests \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sd_svg_export_tests, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    for \
+    forui \
+    i18nlangtag \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sd \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+    test \
+    tl \
+    tk \
+    ucbhelper \
+    unotest \
+    utl \
+    vcl \
+    xo \
+    $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sd_svg_export_tests,\
+    -I$(SRCDIR)/sd/source/ui/inc \
+    -I$(SRCDIR)/sd/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sd_svg_export_tests,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sd_svg_export_tests))
+$(eval $(call gb_CppunitTest_use_vcl,sd_svg_export_tests))
+
+$(eval $(call gb_CppunitTest_use_rdb,sd_svg_export_tests,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,sd_svg_export_tests))
+
+$(call gb_CppunitTest_get_target,sd_svg_export_tests) : $(call gb_AllLangResTarget_get_target,sd)
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 4bd26ac..c62ea20 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -34,6 +34,7 @@ $(eval $(call gb_Module_add_check_targets,sd,\
     CppunitTest_sd_filters_test \
     CppunitTest_sd_html_export_tests \
     CppunitTest_sd_tiledrendering \
+    CppunitTest_sd_svg_export_tests \
 ))
 endif
 
diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx
new file mode 100644
index 0000000..8dbbbc9
--- /dev/null
+++ b/sd/qa/unit/SVGExportTests.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "sdmodeltestbase.hxx"
+
+#include <test/xmltesttools.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+
+using namespace css;
+
+class SdSVGFilterTest : public SdModelTestBase, public XmlTestTools
+{
+    uno::Reference<lang::XComponent> mxComponent;
+    utl::TempFile maTempFile;
+
+public:
+    SdSVGFilterTest()
+    {
+        maTempFile.EnableKillingFile();
+    }
+
+    virtual void setUp() override
+    {
+        SdModelTestBase::setUp();
+
+        mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
+    }
+
+    virtual void tearDown() override
+    {
+        if (mxComponent.is())
+            mxComponent->dispose();
+
+        SdModelTestBase::tearDown();
+    }
+
+    void testSVGExportTextDecorations()
+    {
+        mxComponent = loadFromDesktop(getURLFromSrc("/sd/qa/unit/data/odp/svg-export-text-decorations.odp"));
+        CPPUNIT_ASSERT(mxComponent.is());
+
+        uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+        utl::MediaDescriptor aMediaDescriptor;
+        OUString aFilterName("impress_svg_Export");
+        aMediaDescriptor["FilterName"] <<= aFilterName;
+        xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+        xmlDocPtr pXmlDoc = parseXml(maTempFile);
+        CPPUNIT_ASSERT(pXmlDoc);
+
+        // TODO use assertXPath() here.
+    }
+
+    CPPUNIT_TEST_SUITE(SdSVGFilterTest);
+    CPPUNIT_TEST(testSVGExportTextDecorations);
+    CPPUNIT_TEST_SUITE_END();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SdSVGFilterTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/data/odp/svg-export-text-decorations.odp b/sd/qa/unit/data/odp/svg-export-text-decorations.odp
new file mode 100644
index 0000000..d516617
Binary files /dev/null and b/sd/qa/unit/data/odp/svg-export-text-decorations.odp differ


More information about the Libreoffice-commits mailing list