oox/source/export/drawingml.cxx | 19 ++++++++++++ oox/source/shape/WpsContext.cxx | 11 ++++++ sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 10 ++++++ 4 files changed, 40 insertions(+)
New commits: commit d3094b98231730b8e6d863c6a2fc0dd62f3e991a Author: Szabolcs Toth <toth.szabo...@nisz.hu> AuthorDate: Mon Sep 14 17:16:51 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Sep 22 09:48:30 2020 +0200 tdf#123610 DOCX shape import: keep text upright Grab-bag attribute upright to keep text upright regardless of shape rotation, fixing the text direction in MSO after a round-trip. Co-authored-by: Balázs Regényi Change-Id: If18a12c7728317a7af093048b07bc392d2964389 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102690 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index c02cfac613a8..87e80e4ce12a 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -2891,6 +2891,24 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo else if( bVertical && eHorizontalAlignment == TextHorizontalAdjust_LEFT ) sVerticalAlignment = "b"; + bool isUpright = false; + if (GetProperty(rXPropSet, "InteropGrabBag")) + { + if (rXPropSet->getPropertySetInfo()->hasPropertyByName("InteropGrabBag")) + { + uno::Sequence<beans::PropertyValue> aGrabBag; + rXPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag; + for (auto& aProp : aGrabBag) + { + if (aProp.Name == "Upright") + { + aProp.Value >>= isUpright; + break; + } + } + } + } + bool bHasWrap = false; bool bWrap = false; // Only custom shapes obey the TextWordWrap option, normal text always wraps. @@ -2922,6 +2940,7 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo XML_anchor, sVerticalAlignment, XML_anchorCtr, sax_fastparser::UseIf("1", bHorizontalCenter), XML_vert, sWritingMode, + XML_upright, isUpright ? "1" : "0", XML_rot, sax_fastparser::UseIf(oox::drawingml::calcRotationValue((nTextPreRotateAngle + nTextRotateAngle) * 100), (nTextPreRotateAngle + nTextRotateAngle) != 0)); if (bIsFontworkShape) { diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index f78c38ff91e9..076fd1124307 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -96,6 +96,17 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken } } + if (bool bUpright = rAttribs.getBool(XML_upright, false)) + { + uno::Sequence<beans::PropertyValue> aGrabBag; + xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag; + sal_Int32 length = aGrabBag.getLength(); + aGrabBag.realloc(length + 1); + aGrabBag[length].Name = "Upright"; + aGrabBag[length].Value <<= bUpright; + xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag)); + } + if (xServiceInfo.is()) { // Handle inset attributes for Writer textframes. diff --git a/sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx b/sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx new file mode 100644 index 000000000000..d7dc1978a067 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf123610_handle_upright.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index 76ccf318e8c9..0085734450c0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -1142,6 +1142,16 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testRelativeAnchorWidthFromInsideOutsideMarg assertXPath(pXmlDoc, "(//SwAnchoredDrawObject)[4]/bounds", "width", "1440"); } +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testBodyPrUpright, "tdf123610_handle_upright.docx") +{ + // tdf#123610: Check grab-bag attribute upright to keep text upright regardless of shape rotation. + + xmlDocUniquePtr pXmlDocument = parseExport("word/document.xml"); + + assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor" + "/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "upright", "1"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits