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 691de5dc45a86844c53723b4e32180876a0fc1c9
Author:     Szabolcs Toth <toth.szabo...@nisz.hu>
AuthorDate: Mon Sep 14 17:16:51 2020 +0200
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Thu Feb 18 15:59:47 2021 +0100

    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>
    (cherry picked from commit d3094b98231730b8e6d863c6a2fc0dd62f3e991a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111141
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index de2d34979471..70ecafec02f9 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2813,6 +2813,24 @@ void DrawingML::WriteText( const Reference< XInterface 
>& rXIface, const OUStrin
     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.
@@ -2844,6 +2862,7 @@ void DrawingML::WriteText( const Reference< XInterface >& 
rXIface, const OUStrin
                                XML_anchor, sVerticalAlignment,
                                XML_anchorCtr, bHorizontalCenter ? "1" : 
nullptr,
                                XML_vert, sWritingMode,
+                               XML_upright, isUpright ? "1" : "0",
                                XML_rot, ((nTextPreRotateAngle + 
nTextRotateAngle) != 0) ? oox::drawingml::calcRotationValue( 
(nTextPreRotateAngle + nTextRotateAngle) * 100 ).getStr() : nullptr );
         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 a7fa86d47a14..61ba601ed1c5 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1190,6 +1190,16 @@ 
DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorWidthFromInsideOutsideMargin, "tdf133
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2552), nAnchoredWidth);
 }
 
+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

Reply via email to