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 08dbab21fa11088af519716013bcffc3bfa17b69 Author: Regényi Balázs <regenyi.bal...@nisz.hu> AuthorDate: Tue Sep 22 17:12:59 2020 +0200 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Thu Feb 25 15:13:13 2021 +0100 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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111175 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx index 27ca26fabc67..017e30f74941 100644 --- a/oox/inc/drawingml/textbodyproperties.hxx +++ b/oox/inc/drawingml/textbodyproperties.hxx @@ -47,6 +47,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 c5c77e29038f..8d15beca453e 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1449,6 +1449,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 699c15ec2632..5bc244b73fc2 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 7ccb5209c7e3..1532ce2b2ad2 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2864,18 +2864,31 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin } 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; } } } @@ -2883,6 +2896,8 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin 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 f37778217a73..b7ac23366e91 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -266,6 +266,7 @@ public: void testTdf135828_Shape_Rect(); void testTdf123353(); void testTdf133688_precedents(); + void testTdf91251_missingOverflowRoundtrip(); void testTdf126305_DataValidatyErrorAlert(); void testTdf129969(); @@ -428,6 +429,7 @@ public: CPPUNIT_TEST(testTdf135828_Shape_Rect); CPPUNIT_TEST(testTdf123353); CPPUNIT_TEST(testTdf133688_precedents); + CPPUNIT_TEST(testTdf91251_missingOverflowRoundtrip); CPPUNIT_TEST(testTdf126305_DataValidatyErrorAlert); CPPUNIT_TEST(testTdf129969); @@ -5403,6 +5405,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"); +} + void ScExportTest::testTdf126305_DataValidatyErrorAlert() { ScDocShellRef xShell = loadDoc("tdf126305.", FORMAT_ODS); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits