[Libreoffice-commits] core.git: oox/source sw/qa sw/source
umeshkadam
umesh.kadam at synerzip.com
Mon Mar 17 01:58:07 PDT 2014
oox/source/export/drawingml.cxx | 7 ++++-
sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 13 +++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 16 +++++++++---
4 files changed, 31 insertions(+), 5 deletions(-)
New commits:
commit 881ca9d48fc67665559484901ce6a670dc331ab8
Author: umeshkadam <umesh.kadam at synerzip.com>
Date: Tue Mar 11 20:42:31 2014 +0530
FDO#76013 : If original file has image whose link is broken RT gets corrupted.
- The original file contains an image which has invalid link.
- since the link is invalid the import throws an exception while loading
the image & the link is lost.
- while exporting the system used to write an empty image for an unhandled
graphic type, which is incorrect and the RT file would result in corrupt.
- Fixed this issue and added UT.
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Reviewed on:
https://gerrit.libreoffice.org/8549
Change-Id: If884f154d1fba921280d63930e7fccb979ea5608
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index aeeff25..7d8ea84 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -779,7 +779,12 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
pExtension = ".emf";
} else {
OSL_TRACE( "unhandled graphic type" );
- break;
+ /*Earlier, even in case of unhandled graphic types we were
+ proceeding to write the image, which would eventually
+ write an empty image with a zero size, and return a valid
+ relationID, which is incorrect.
+ */
+ return sRelId;
}
aData = aStream.GetData();
diff --git a/sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx b/sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx
new file mode 100644
index 0000000..6ad5cac
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/FileWithInvalidImageLink.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9a43735..2a2f7c8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2791,6 +2791,19 @@ DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx")
assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2");
}
+DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, "FileWithInvalidImageLink.docx")
+{
+ /* In case if the original file has an image whose link is
+ invalid, then the RT file used to result in corruption
+ since the exported image would be an empty image.
+ */
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]", "embed", "");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a380dd0..cfa3b47 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3319,9 +3319,6 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
nImageType = XML_embed;
}
- if ( aRelId.isEmpty() )
- return;
-
m_rExport.SdrExporter().startDMLAnchorInline(pFrmFmt, rSize);
// picture description (used for pic:cNvPr later too)
@@ -3383,7 +3380,18 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode* pGrfNode, const Size
// the actual picture
m_pSerializer->startElementNS( XML_pic, XML_blipFill,
FSEND );
- m_pSerializer->singleElementNS( XML_a, XML_blip,
+
+/* At this point we are certain that, WriteImage returns empty RelId
+ for unhandled graphic type. Therefore we write the picture description
+ and not the relation( coz there ain't any), so that the user knows
+ there is a image/graphic in the doc but it is broken instead of
+ completely discarding it.
+*/
+ if ( aRelId.isEmpty() )
+ m_pSerializer->singleElementNS( XML_a, XML_blip,
+ FSEND );
+ else
+ m_pSerializer->singleElementNS( XML_a, XML_blip,
FSNS( XML_r, nImageType ), aRelId.getStr(),
FSEND );
More information about the Libreoffice-commits
mailing list