Kaydet (Commit) 33227dbf authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 65e25963
...@@ -96,6 +96,9 @@ using ::sax_fastparser::FSHelperPtr; ...@@ -96,6 +96,9 @@ using ::sax_fastparser::FSHelperPtr;
DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet)); DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet));
// Defined in generated code.
extern std::map< OString, std::vector<OString> > ooxDrawingMLGetAdjNames();
namespace oox { namespace oox {
namespace drawingml { namespace drawingml {
...@@ -1408,6 +1411,12 @@ void DrawingML::WritePresetShape( const char* pShape ) ...@@ -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 ) 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, mpFS->startElementNS( XML_a, XML_prstGeom,
XML_prst, pShape, XML_prst, pShape,
FSEND ); FSEND );
...@@ -1425,10 +1434,17 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo ...@@ -1425,10 +1434,17 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo
sal_Int32 nValue, nLength = aAdjustmentSeq.getLength(); sal_Int32 nValue, nLength = aAdjustmentSeq.getLength();
for( sal_Int32 i=0; i < nLength; i++ ) for( sal_Int32 i=0; i < nLength; i++ )
if( EscherPropertyContainer::GetAdjustmentValue( aAdjustmentSeq[ i ], i, nAdjustmentsWhichNeedsToBeConverted, nValue ) ) 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) : (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(), XML_fmla, OString("val " + OString::number( nValue )).getStr(),
FSEND ); FSEND );
}
} }
mpFS->endElementNS( XML_a, XML_avLst ); mpFS->endElementNS( XML_a, XML_avLst );
......
...@@ -2192,6 +2192,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo73215, "fdo73215.docx") ...@@ -2192,6 +2192,9 @@ DECLARE_OOXMLEXPORT_TEST(testFdo73215, "fdo73215.docx")
// 'rect' was 'pictureFrame', which isn't valid. // '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", 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"); "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") DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
......
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