summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSourav <sourav.mahajan@synerzip.com>2014-03-19 18:01:45 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-03-19 15:53:12 +0100
commit35e190ba5bac01b47fbed1ea568dfb3456029d82 (patch)
treecec48beda78307c69a44f68a332a088d928b38f5
parent0fb498ccfd40a13bf99c3f36dd0cebebdaf55809 (diff)
fdo76201:File Corruption - Issue related with prstGeom for Hexagon shape.
There are two issues that are handled in this fix. 1)File created in MSO2K10 on RT gets corrupted.The root cause is found in CustomShapeProperties::pushToPropSet 2)File created in MSO2K7 on RT gets corrupted.There is an issue in shape import <a:gd> values for any shape (ex. circular arrow, hexagon etc).LO cannot import right <a:gd> values for any shape which is created in MSO-2007.Due to missing values of <a:gd> tag, after roundtrip the file gets corrupted.To avoid corruption a check introduced:- if(aAdjustments.size() == nLength) after http://opengrok.libreoffice.org/xref/core/oox/source/export/drawingml.cxx#1784 that will verify the number of <a:gd> tags associated with the shape during import and the number of <a:gd> tags during export.If there is a mismatch <a:gd> willnot be written.Changes made in DrawingML::WritePresetShape. I have written 2 test cases for the same. Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx Reviewed on: https://gerrit.libreoffice.org/8657 Change-Id: Ibb1e2dc1c098b7399c06d7b4f59fac4e80887062
-rw-r--r--oox/source/drawingml/customshapeproperties.cxx3
-rw-r--r--oox/source/export/drawingml.cxx20
-rw-r--r--sw/qa/extras/ooxmlexport/data/test76317.docxbin0 -> 17705 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/data/test76317_2K10.docxbin0 -> 20751 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx14
5 files changed, 28 insertions, 9 deletions
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index 60ef079dd7b5..52fa038c5fb2 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -170,6 +170,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
if ( aGeoPropSeq[ i ].Value >>= aAdjustmentSeq )
{
+ int nIndex=0;
for (std::vector< CustomShapeGuide >::const_iterator aIter( maAdjustmentGuideList.begin() ), aEnd(maAdjustmentGuideList.end());
aIter != aEnd; ++aIter)
{
@@ -189,7 +190,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32();
aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
aAdjustmentVal.Name = (*aIter).maName;
- aAdjustmentSeq[ 0 ] = aAdjustmentVal;
+ aAdjustmentSeq[ nIndex++ ] = aAdjustmentVal;
}
}
aGeoPropSeq[ i ].Value <<= aAdjustmentSeq;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 7d8ea84f3c3c..a71ed89b4641 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1782,19 +1782,23 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo
EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
sal_Int32 nValue, nLength = aAdjustmentSeq.getLength();
- for( sal_Int32 i=0; i < nLength; i++ )
- if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
- {
- // If the document model doesn't have an adjustment name (e.g. shape was created from VML), then take it from the predefined list.
- OString aAdjName;
- if (aAdjustmentSeq[i].Name.isEmpty() && static_cast<sal_uInt32>(i) < aAdjustments.size())
- aAdjName = aAdjustments[i];
+ //aAdjustments will give info about the number of adj values for a particular geomtery.For example for hexagon aAdjustments.size() will be 2 and for circular arrow it will be 5 as per ooxDrawingMLGetAdjNames.
+ if(aAdjustments.size() == static_cast<sal_uInt32>(nLength))// In case there is a mismatch do not write the XML_gd tag.
+ {
+ for( sal_Int32 i=0; i < nLength; i++ )
+ if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
+ {
+ // If the document model doesn't have an adjustment name (e.g. shape was created from VML), then take it from the predefined list.
+ OString aAdjName;
+ if (aAdjustmentSeq[i].Name.isEmpty() && static_cast<sal_uInt32>(i) < aAdjustments.size())
+ aAdjName = aAdjustments[i];
- mpFS->singleElementNS( XML_a, XML_gd,
+ mpFS->singleElementNS( XML_a, XML_gd,
XML_name, aAdjustmentSeq[ i ].Name.getLength() > 0 ? USS(aAdjustmentSeq[ i ].Name) : aAdjName.getStr(),
XML_fmla, OString("val " + OString::number( nValue )).getStr(),
FSEND );
}
+ }
}
mpFS->endElementNS( XML_a, XML_avLst );
diff --git a/sw/qa/extras/ooxmlexport/data/test76317.docx b/sw/qa/extras/ooxmlexport/data/test76317.docx
new file mode 100644
index 000000000000..2c86cdc384a3
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/test76317.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/test76317_2K10.docx b/sw/qa/extras/ooxmlexport/data/test76317_2K10.docx
new file mode 100644
index 000000000000..5532063408ce
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/test76317_2K10.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9461ba7a2356..90712a3a3857 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2900,6 +2900,20 @@ DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0);
}
+DECLARE_OOXMLEXPORT_TEST(test76317, "test76317.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc) return;
+ assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:prstGeom[1]", "prst", "hexagon");
+}
+
+DECLARE_OOXMLEXPORT_TEST(test76317_2K10, "test76317_2K10.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc) return;
+ assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:prstGeom[1]/a:avLst[1]/a:gd[1]", "name", "adj");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();