oox/inc/drawingml/textbodyproperties.hxx | 2 + oox/source/drawingml/shape.cxx | 7 ++++ oox/source/drawingml/textbodypropertiescontext.cxx | 4 +- oox/source/export/drawingml.cxx | 19 +++++++++- sc/qa/unit/data/xlsx/tdf91251_missingOverflowRoundtrip.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 21 ++++++++++++ 6 files changed, 49 insertions(+), 4 deletions(-)
New commits: commit 79737c8b0d84d4967c5f1c41b740a8a52db8b551 Author: Regényi Balázs <regenyi.bal...@nisz.hu> AuthorDate: Tue Sep 22 17:12:59 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Sep 29 12:26:25 2020 +0200 tdf#91251 XLSX textbox export: fix missing overflow properties by grab-bagging them. Co-authored-by: Szabolcs Toth Change-Id: I242bf33e1272d913805c90a2ef902be8633618fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103182 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx index 26e34ac6a5f7..8a51c2bb906e 100644 --- a/oox/inc/drawingml/textbodyproperties.hxx +++ b/oox/inc/drawingml/textbodyproperties.hxx @@ -46,6 +46,8 @@ struct TextBodyProperties sal_Int32 mnNumCol = 1; /// Normal autofit: font scale (default: 100%). sal_Int32 mnFontScale = 100000; + OUString msHorzOverflow; + OUString msVertOverflow; explicit TextBodyProperties(); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index ddc5a96b8018..5af4d51cbfd4 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1429,6 +1429,13 @@ Reference< XShape > const & Shape::createAndInsert( degrees anticlockwise. */ mpCustomShapePropertiesPtr->setTextRotateAngle(-1 * nTextRotateAngle / 60000); } + + auto sHorzOverflow = getTextBody()->getTextProperties().msHorzOverflow; + if (!sHorzOverflow.isEmpty()) + putPropertyToGrabBag("horzOverflow", uno::makeAny(getTextBody()->getTextProperties().msHorzOverflow)); + auto nVertOverflow = getTextBody()->getTextProperties().msVertOverflow; + if (!nVertOverflow.isEmpty()) + putPropertyToGrabBag("vertOverflow", uno::makeAny(getTextBody()->getTextProperties().msVertOverflow)); } // Note that the script oox/source/drawingml/customshapes/generatePresetsData.pl looks diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index d3add310097f..6a6d9e90ef63 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -80,9 +80,9 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper cons mrTextBodyProp.maPropertyMap.setProperty(PROP_FromWordArt, bFromWordArt); // ST_TextHorzOverflowType -// sal_Int32 nHorzOverflow = rAttribs.getToken( XML_horzOverflow, XML_overflow ); + mrTextBodyProp.msHorzOverflow = rAttribs.getString(XML_horzOverflow, ""); // ST_TextVertOverflowType -// sal_Int32 nVertOverflow = rAttribs.getToken( XML_vertOverflow, XML_overflow ); + mrTextBodyProp.msVertOverflow = rAttribs.getString(XML_vertOverflow, ""); // ST_TextColumnCount mrTextBodyProp.mnNumCol = rAttribs.getInteger( XML_numCol, 1 ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 8ea8035ea39a..0612fe56ed43 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2955,18 +2955,31 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo } bool isUpright = false; + std::optional<OUString> sHorzOverflow; + std::optional<OUString> sVertOverflow; if (GetProperty(rXPropSet, "InteropGrabBag")) { if (rXPropSet->getPropertySetInfo()->hasPropertyByName("InteropGrabBag")) { uno::Sequence<beans::PropertyValue> aGrabBag; rXPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag; - for (auto& aProp : aGrabBag) + for (const auto& aProp : std::as_const(aGrabBag)) { if (aProp.Name == "Upright") { aProp.Value >>= isUpright; - break; + } + else if (aProp.Name == "horzOverflow") + { + OUString sValue; + aProp.Value >>= sValue; + sHorzOverflow = sValue; + } + else if (aProp.Name == "vertOverflow") + { + OUString sValue; + aProp.Value >>= sValue; + sVertOverflow = sValue; } } } @@ -2974,6 +2987,8 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo mpFS->startElementNS( (nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr, XML_wrap, pWrap, + XML_horzOverflow, sHorzOverflow, + XML_vertOverflow, sVertOverflow, XML_fromWordArt, sax_fastparser::UseIf("1", bFromWordArt), XML_lIns, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nLeft)), nLeft != DEFLRINS), XML_rIns, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nRight)), nRight != DEFLRINS), diff --git a/sc/qa/unit/data/xlsx/tdf91251_missingOverflowRoundtrip.xlsx b/sc/qa/unit/data/xlsx/tdf91251_missingOverflowRoundtrip.xlsx new file mode 100644 index 000000000000..656ea5628c8c Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf91251_missingOverflowRoundtrip.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index e0543656631c..a5e935dfb740 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -269,6 +269,7 @@ public: void testTdf135828_Shape_Rect(); void testTdf123353(); void testTdf133688_precedents(); + void testTdf91251_missingOverflowRoundtrip(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -432,6 +433,7 @@ public: CPPUNIT_TEST(testTdf135828_Shape_Rect); CPPUNIT_TEST(testTdf123353); CPPUNIT_TEST(testTdf133688_precedents); + CPPUNIT_TEST(testTdf91251_missingOverflowRoundtrip); CPPUNIT_TEST_SUITE_END(); @@ -5462,6 +5464,25 @@ void ScExportTest::testTdf133688_precedents() assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor[1]", 0); } +void ScExportTest::testTdf91251_missingOverflowRoundtrip() +{ + // tdf#91251 check whether textBox overflow property (horzOverflow and vertOverflow) is + // getting preserved after roundtrip + ScDocShellRef xShell = loadDoc("tdf91251_missingOverflowRoundtrip.", FORMAT_XLSX); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); + + xmlDocUniquePtr pDrawing = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml"); + CPPUNIT_ASSERT(pDrawing); + + assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:txBody/a:bodyPr", "horzOverflow", "clip"); + assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:txBody/a:bodyPr", "horzOverflow", "clip"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits