oox/source/drawingml/customshapeproperties.cxx    |    3 ++-
 oox/source/export/drawingml.cxx                   |   20 ++++++++++++--------
 sw/qa/extras/ooxmlexport/data/test76317.docx      |binary
 sw/qa/extras/ooxmlexport/data/test76317_2K10.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx          |   14 ++++++++++++++
 5 files changed, 28 insertions(+), 9 deletions(-)

New commits:
commit 35e190ba5bac01b47fbed1ea568dfb3456029d82
Author: Sourav <sourav.maha...@synerzip.com>
Date:   Wed Mar 19 18:01:45 2014 +0530

    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

diff --git a/oox/source/drawingml/customshapeproperties.cxx 
b/oox/source/drawingml/customshapeproperties.cxx
index 60ef079..52fa038 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 7d8ea84..a71ed89 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 0000000..2c86cdc
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/test76317.docx 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 0000000..5532063
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/test76317_2K10.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9461ba7..90712a3 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();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to