[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - oox/source sd/qa

Jacobo Aragunde Pérez jaragunde at igalia.com
Fri Oct 20 18:07:52 UTC 2017


 oox/source/export/drawingml.cxx     |   14 ++++++++++----
 sd/qa/unit/data/pptx/tdf112633.pptx |binary
 sd/qa/unit/export-tests-ooxml1.cxx  |   30 ++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 4 deletions(-)

New commits:
commit 3e250d0a392c37e9e610bd83017a3045c4c02638
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Thu Oct 12 13:30:47 2017 +0200

    tdf#112633 oox: Save backup images to proper path in document
    
    Artistic effects on bitmap images in OOXML files create a backup file
    with the original image. These were not being saved into the proper
    path for PPTX files because the `/word` directory was hardcoded in the
    export code.
    
    The path saved to the relations file was incorrect too because it was
    not taking into account that the relations file is saved to a subdir
    in PPTX and XLSX documents.
    
    Finally, added a unit test.
    
    Reviewed-on: https://gerrit.libreoffice.org/43338
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 55641f5572f3168c09e096eb89ca563652889758)
    
    Change-Id: I3e880ce763dc10dbc86ccf0e00871be5d36f6d88
    Reviewed-on: https://gerrit.libreoffice.org/43600
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 4b327f63d76f..48720d923144 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -3448,16 +3448,22 @@ OString DrawingML::WriteWdpPicture( const OUString& rFileId, const Sequence< sal
         return OUStringToOString( aCachedItem->second, RTL_TEXTENCODING_UTF8 );
 
     OUString sFileName = "media/hdphoto" + OUString::number( mnWdpImageCounter++ ) + ".wdp";
-    uno::Reference< io::XOutputStream > xOutStream =
-            mpFB->openFragmentStream( "word/" + sFileName,
-                                      "image/vnd.ms-photo" );
+    Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer()
+                                                                      .appendAscii( GetComponentDir() )
+                                                                      .append( "/" )
+                                                                      .append( sFileName )
+                                                                      .makeStringAndClear(),
+                                                                      "image/vnd.ms-photo" );
     OUString sId;
     xOutStream->writeBytes( rPictureData );
     xOutStream->closeOutput();
 
     sId = mpFB->addRelation( mpFS->getOutputStream(),
                              oox::getRelationship(Relationship::HDPHOTO),
-                             sFileName );
+                             OUStringBuffer()
+                             .appendAscii( GetRelationCompPrefix() )
+                             .append( sFileName )
+                             .makeStringAndClear() );
 
     maWdpCache[rFileId] = sId;
     return OUStringToOString( sId, RTL_TEXTENCODING_UTF8 );
diff --git a/sd/qa/unit/data/pptx/tdf112633.pptx b/sd/qa/unit/data/pptx/tdf112633.pptx
new file mode 100644
index 000000000000..b9e062967132
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf112633.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index ab59ffe226b1..11f8598cedff 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -104,6 +104,7 @@ public:
     void testBulletCharAndFont();
     void testBulletMarginAndIndentation();
     void testParaMarginAndindentation();
+    void testTdf112633();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
 
@@ -131,6 +132,7 @@ public:
     CPPUNIT_TEST(testBulletCharAndFont);
     CPPUNIT_TEST(testBulletMarginAndIndentation);
     CPPUNIT_TEST(testParaMarginAndindentation);
+    CPPUNIT_TEST(testTdf112633);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -779,6 +781,34 @@ void SdOOXMLExportTest1::testTableCellBorder()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest1::testTdf112633()
+{
+    // Load document and export it to a temporary file
+    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf112633.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+    xDocShRef->DoClose();
+
+    xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
+    xmlDocPtr pRelsDoc = parseExport(tempFile, "ppt/slides/_rels/slide1.xml.rels");
+
+    // Check image with artistic effect exists in the slide
+    assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/"
+            "a14:imgLayer/a14:imgEffect/a14:artisticPencilGrayscale",
+            "pencilSize", "80");
+
+    // Check there is a relation with the .wdp file that contains the backed up image
+    OUString sEmbedId1 = getXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/"
+            "a:ext/a14:imgProps/a14:imgLayer", "embed");
+    OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId1 + "']";
+    assertXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target", "../media/hdphoto1.wdp");
+
+    // Check the .wdp file exists
+    uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
+            comphelper::getComponentContext(m_xSFactory), tempFile.GetURL());
+    CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("ppt/media/hdphoto1.wdp")));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list