[Libreoffice-commits] core.git: 2 commits - oox/source sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Thu Jan 2 10:03:34 PST 2014
oox/source/export/drawingml.cxx | 18 +++++++++++-
oox/source/export/preset-definitions-to-shape-types.pl | 25 +++++++++++++++++
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 3 ++
3 files changed, 45 insertions(+), 1 deletion(-)
New commits:
commit 33227dbf270bec5b7aa079b9b5e2e7e036796e20
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 2 18:43:39 2014 +0100
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
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a338170..030beb5 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 7e1b91d..1e20734 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")
commit 65e25963e06c295ae8101f49da2774586d0110d5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Jan 2 18:27:11 2014 +0100
oox: extract adjustment names by type from spec XML
The naming of adjustments is not consistent for drawingML shapes, some
of them have the first parameter as "adj1", some of them have it as
"adj". We already have a script that generates some code based on these
XML files, make it generate a function that returns the naming for each
type.
Change-Id: I2250f72854295055e1b31f2df9aec25a997db749
diff --git a/oox/source/export/preset-definitions-to-shape-types.pl b/oox/source/export/preset-definitions-to-shape-types.pl
index fc0b781..8f5904d 100644
--- a/oox/source/export/preset-definitions-to-shape-types.pl
+++ b/oox/source/export/preset-definitions-to-shape-types.pl
@@ -59,6 +59,7 @@ my $shape_name = "";
my $state = "";
my $path = "";
my $adjust = "";
+my %adj_names;
my $max_adj_no = 0;
my @formulas = ();
my %variables = ();
@@ -887,6 +888,10 @@ sub start_element( $% )
elsif ( $state eq "adjust" ) {
if ( $element eq "gd" ) {
my $adj_no = $attr{'name'};
+
+ # Save this adj number for this type for later use.
+ push(@{$adj_names{$shape_name}}, $adj_no);
+
my $is_const = 0;
$adj_no =~ s/^adj//;
@@ -1189,6 +1194,7 @@ print <<EOF;
// '$src_text'
// which are part of the OOXML documentation
+#include <map>
#include <filter/msfilter/escherex.hxx>
const char* pShapeTypes[ ESCHER_ShpInst_COUNT ] =
@@ -1224,4 +1230,23 @@ for ( my $i = 0; $i < 203; ++$i ) {
print <<EOF;
};
+
+std::map< OString, std::vector<OString> > ooxDrawingMLGetAdjNames()
+{
+ std::map< OString, std::vector<OString> > aMap;
EOF
+
+foreach my $adj_name (keys %adj_names)
+{
+ foreach my $adj (@{$adj_names{$adj_name}})
+ {
+ print " aMap[\"$adj_name\"].push_back(\"$adj\");\n";
+ }
+}
+
+print <<EOF;
+ return aMap;
+}
+EOF
+
+# vim:set ft=perl shiftwidth=4 softtabstop=4 expandtab: #
More information about the Libreoffice-commits
mailing list