diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-22 13:54:42 +0200 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-05-23 10:04:00 +0200 |
commit | 2e68a1468c035fc3bb4d02ad0b3187872fe1e67b (patch) | |
tree | 0bd5ccdee8253233ca7f919a70c5bd337b3b5a37 /sw/qa | |
parent | 642a252cf1a2f1d08c4bbfcae15527bb82c7664d (diff) |
ooxml: Preserve the original picture in artistic effects
When Word applies an artistic effect, it creates two embedded files;
one contains the bitmap with the effect and the other one contains the
original bitmap to be able to undo the effect.
This patch reads the original bitmap, stores it in the shape grab bag
and saves it back to the docx file. Added unit tests too.
TODO: right now, if two effects point to the same original bitmap it
is stored twice, we should improve this.
Change-Id: Ia72034a257739abe4ffafa0f42b2a912e4bf9436
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 43f5b6e7751d..0284347daa86 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -1341,9 +1341,13 @@ DECLARE_OOXMLEXPORT_TEST(testPictureEffectPreservation, "picture-effects-preserv DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artistic-effects-preservation.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) + xmlDocPtr pRelsDoc = parseExport("word/_rels/document.xml.rels"); + if (!pXmlDoc || !pRelsDoc) return; + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( + comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); + // 1st picture: marker effect assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/" "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/" @@ -1354,6 +1358,13 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti "a14:artisticMarker", "size", "80"); + OUString sEmbedId1 = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer", + "embed"); + OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId1 + "']"; + OUString sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target"); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile))); + // 2nd picture: pencil grayscale assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/" "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/" @@ -1364,6 +1375,13 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti "a14:artisticPencilGrayscale", "pencilSize", "66"); + OUString sEmbedId2 = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer", + "embed"); + sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId2 + "']"; + sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target"); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile))); + // 3rd picture: pencil sketch assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/" "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/" @@ -1374,6 +1392,13 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti "a14:artisticPencilSketch", "pressure", "17"); + OUString sEmbedId3 = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer", + "embed"); + sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId3 + "']"; + sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target"); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile))); + // 4th picture: light screen assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/" "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/" @@ -1384,16 +1409,37 @@ DECLARE_OOXMLEXPORT_TEST(testPictureArtisticEffectPreservation, "picture-artisti "a14:artisticLightScreen", "gridSize", "1"); + OUString sEmbedId4 = getXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer", + "embed"); + sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId4 + "']"; + sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target"); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile))); + // 5th picture: watercolor sponge assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/" "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/" "a14:artisticWatercolorSponge", "brushSize", "4"); + OUString sEmbedId5 = getXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer", + "embed"); + sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId5 + "']"; + sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target"); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile))); + // 6th picture: photocopy (no attributes) assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/" "a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer/a14:imgEffect/" "a14:artisticPhotocopy", 1); + + OUString sEmbedId6 = getXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/a14:imgLayer", + "embed"); + sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId6 + "']"; + sFile = getXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target"); + CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("word/" + sFile))); } DECLARE_OOXMLEXPORT_TEST(fdo77719, "fdo77719.docx") |