summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2023-02-02 23:24:01 +0100
committerRegina Henschel <rb.henschel@t-online.de>2023-02-03 01:17:48 +0000
commita834bbad8295cba0ca88a91a524aad48640271ec (patch)
tree5029acbb751ea3ed386b3bea8f324bc24be2d858 /oox
parentf2a2dab47dfae5c0c0bd68132e1446d571767eb8 (diff)
tdf#153246 VML export write adj attribute for Fontwork
The fix for tdf#153296 has introduced correct shapetype markup for Fontwork shapes so that handles are moveable in Word. But the actual adjustment value of the handle was not exported. This patch adds the missing 'adj' attribute to the <v:shape> element. The fix is restricted to the preset Fontwork types because for other shapetypes the VML export is not yet suitable in regard to handles. Change-Id: I7ecda9e63d50ab7d8c1fda3e09f7383546ddaf5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146537 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/qa/unit/data/tdf153246_VML_export_Fontwork_Adjustment.odtbin0 -> 20601 bytes
-rw-r--r--oox/qa/unit/export.cxx27
-rw-r--r--oox/source/export/vmlexport.cxx26
3 files changed, 53 insertions, 0 deletions
diff --git a/oox/qa/unit/data/tdf153246_VML_export_Fontwork_Adjustment.odt b/oox/qa/unit/data/tdf153246_VML_export_Fontwork_Adjustment.odt
new file mode 100644
index 000000000000..1a26191821cf
--- /dev/null
+++ b/oox/qa/unit/data/tdf153246_VML_export_Fontwork_Adjustment.odt
Binary files differ
diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx
index 64c97b56a24d..50c953135623 100644
--- a/oox/qa/unit/export.cxx
+++ b/oox/qa/unit/export.cxx
@@ -883,6 +883,33 @@ CPPUNIT_TEST_FIXTURE(Test, testVMLFontworkArchUp)
// ..., but a <v:shapetype> element with <v:textpath> subelement
assertXPath(pXmlDoc, "//v:shapetype/v:textpath", 1);
}
+
+CPPUNIT_TEST_FIXTURE(Test, testVMLAdjustmentExport)
+{
+ // The document has a Fontwork shape type 'textCirclePour' (150). When exporting to docx, the
+ // adjustment values were not exported at all.
+ loadFromURL(u"tdf153246_VML_export_Fontwork_Adjustment.odt");
+
+ // FIXME: tdf#153183 validation error in OOXML export: Errors: 1
+ // Attribute 'ID' is not allowed to appear in element 'v:shape'.
+ skipValidation();
+
+ // Save to DOCX:
+ save("Office Open XML Text");
+
+ // Examine the saved markup.
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+
+ // Make sure an "adj" attribute exists
+ assertXPath(pXmlDoc, "//v:shape[@adj]", 1);
+ // ... and has the correct values
+ OUString sAdjustments = getXPath(pXmlDoc, "//v:shape", "adj");
+ sal_Int32 nTokenStart = 0;
+ OUString sAngle = sAdjustments.getToken(0, ',', nTokenStart);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(-7341733), sAngle.toInt32(), 2);
+ OUString sRadius = sAdjustments.copy(nTokenStart);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5296), sRadius.toInt32(), 2);
+}
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 82d92536b226..3a7fb417f2fc 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1010,6 +1010,32 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle&
bAlreadyWritten[ESCHER_Prop_gtextFont] = true;
}
break;
+ case DFF_Prop_adjustValue:
+ case DFF_Prop_adjust2Value:
+ {
+ // FIXME: tdf#153296: The currently exported markup for <v:shapetype> is based on
+ // OOXML presets and unusable in regard to handles. Fontwork shapes use dedicated
+ // own markup, see FontworkHelpers::GetVMLFontworkShapetypeMarkup.
+ // Thus this is restricted to preset Fontwork shapes. Such have maximal two
+ // adjustment values.
+ if ((mso_sptTextSimple <= m_nShapeType && m_nShapeType <= mso_sptTextOnRing)
+ || (mso_sptTextPlainText <= m_nShapeType && m_nShapeType <= mso_sptTextCanDown))
+ {
+ sal_uInt32 nValue;
+ OString sAdj;
+ if (rProps.GetOpt(DFF_Prop_adjustValue, nValue))
+ {
+ sAdj = OString::number(static_cast<sal_Int32>(nValue));
+ if (rProps.GetOpt(DFF_Prop_adjust2Value, nValue))
+ sAdj += "," + OString::number(static_cast<sal_Int32>(nValue));
+ }
+ if (!sAdj.isEmpty())
+ m_pShapeAttrList->add(XML_adj, sAdj);
+ bAlreadyWritten[DFF_Prop_adjustValue] = true;
+ bAlreadyWritten[DFF_Prop_adjust2Value] = true;
+ }
+ }
+ break;
case ESCHER_Prop_Rotation:
{
// The higher half of the variable contains the angle.