diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-02 18:43:39 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-01-02 19:03:10 +0100 |
commit | 33227dbf270bec5b7aa079b9b5e2e7e036796e20 (patch) | |
tree | f88cecb88f7d3c1ea0d877042d101ab25d7fe246 | |
parent | 65e25963e06c295ae8101f49da2774586d0110d5 (diff) |
fdo#73215 oox: don't assume single adjustment is adj during export
So far adjustment names were either taken from the document model, or in
case there the name was empty, either "adj" was used (in case of a
single adjustment) or "adj1", "adj2", etc.
The problem is that there is no consistency here, e.g. this behavior was
correct for "cube" (single adjustment is called "adj"), but not for
"bentConnector3", where the single argument is called "adj1".
Instead of trying to guess or build a long list manually, use the new
ooxDrawingMLGetAdjNames() to write the correct names.
Change-Id: I3d609975d89c7c79f4a70c7a739cab8e01f9667f
-rw-r--r-- | oox/source/export/drawingml.cxx | 18 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 3 |
2 files changed, 20 insertions, 1 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index a338170bd699..030beb5fe547 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -96,6 +96,9 @@ using ::sax_fastparser::FSHelperPtr; DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet)); +// Defined in generated code. +extern std::map< OString, std::vector<OString> > ooxDrawingMLGetAdjNames(); + namespace oox { namespace drawingml { @@ -1408,6 +1411,12 @@ void DrawingML::WritePresetShape( const char* pShape ) void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const PropertyValue& rProp ) { + static std::map< OString, std::vector<OString> > aAdjMap = ooxDrawingMLGetAdjNames(); + // If there are predefined adj names for this shape type, look them up now. + std::vector<OString> aAdjustments; + if (aAdjMap.find(OString(pShape)) != aAdjMap.end()) + aAdjustments = aAdjMap[OString(pShape)]; + mpFS->startElementNS( XML_a, XML_prstGeom, XML_prst, pShape, FSEND ); @@ -1425,10 +1434,17 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo 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]; + mpFS->singleElementNS( XML_a, XML_gd, - XML_name, aAdjustmentSeq[ i ].Name.getLength() > 0 ? USS(aAdjustmentSeq[ i ].Name) : (nLength > 1 ? OString( "adj" + OString::number( i + 1 ) ).getStr() : "adj"), + 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/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 7e1b91d51c73..1e20734dae9c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2192,6 +2192,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo73215, "fdo73215.docx") // 'rect' was 'pictureFrame', which isn't valid. assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:spPr/a:prstGeom", "prst", "rect"); + // 'adj1' was 'adj', which is not valid for bentConnector3. + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:inline/a:graphic/a:graphicData/wpg:wgp/wps:wsp[9]/wps:spPr/a:prstGeom/a:avLst/a:gd", + "name", "adj1"); } DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx") |