Kaydet (Commit) 35e190ba authored tarafından Sourav's avatar Sourav Kaydeden (comit) Miklos Vajna

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
üst 0fb498cc
...@@ -170,6 +170,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi ...@@ -170,6 +170,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq; uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq;
if ( aGeoPropSeq[ i ].Value >>= aAdjustmentSeq ) if ( aGeoPropSeq[ i ].Value >>= aAdjustmentSeq )
{ {
int nIndex=0;
for (std::vector< CustomShapeGuide >::const_iterator aIter( maAdjustmentGuideList.begin() ), aEnd(maAdjustmentGuideList.end()); for (std::vector< CustomShapeGuide >::const_iterator aIter( maAdjustmentGuideList.begin() ), aEnd(maAdjustmentGuideList.end());
aIter != aEnd; ++aIter) aIter != aEnd; ++aIter)
{ {
...@@ -189,7 +190,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi ...@@ -189,7 +190,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi
aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32(); aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32();
aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentVal.State = PropertyState_DIRECT_VALUE;
aAdjustmentVal.Name = (*aIter).maName; aAdjustmentVal.Name = (*aIter).maName;
aAdjustmentSeq[ 0 ] = aAdjustmentVal; aAdjustmentSeq[ nIndex++ ] = aAdjustmentVal;
} }
} }
aGeoPropSeq[ i ].Value <<= aAdjustmentSeq; aGeoPropSeq[ i ].Value <<= aAdjustmentSeq;
......
...@@ -1782,19 +1782,23 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo ...@@ -1782,19 +1782,23 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo
EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted ); EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted );
sal_Int32 nValue, nLength = aAdjustmentSeq.getLength(); sal_Int32 nValue, nLength = aAdjustmentSeq.getLength();
for( sal_Int32 i=0; i < nLength; 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( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) ) if(aAdjustments.size() == static_cast<sal_uInt32>(nLength))// In case there is a mismatch do not write the XML_gd tag.
{ {
// If the document model doesn't have an adjustment name (e.g. shape was created from VML), then take it from the predefined list. for( sal_Int32 i=0; i < nLength; i++ )
OString aAdjName; if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) )
if (aAdjustmentSeq[i].Name.isEmpty() && static_cast<sal_uInt32>(i) < aAdjustments.size()) {
aAdjName = aAdjustments[i]; // 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_name, aAdjustmentSeq[ i ].Name.getLength() > 0 ? USS(aAdjustmentSeq[ i ].Name) : aAdjName.getStr(),
XML_fmla, OString("val " + OString::number( nValue )).getStr(), XML_fmla, OString("val " + OString::number( nValue )).getStr(),
FSEND ); FSEND );
} }
}
} }
mpFS->endElementNS( XML_a, XML_avLst ); mpFS->endElementNS( XML_a, XML_avLst );
......
...@@ -2900,6 +2900,20 @@ DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx") ...@@ -2900,6 +2900,20 @@ DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0); 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 #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment