sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx                        |   10 ++++
 sw/source/filter/ww8/docxattributeoutput.cxx                      |   25 
++++++++++
 sw/source/filter/ww8/docxattributeoutput.hxx                      |    4 +
 4 files changed, 39 insertions(+)

New commits:
commit deb1a14adb115710b5e40dd305dc5da4a4e3b065
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Sat Apr 22 15:54:35 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Sun Apr 23 02:56:50 2023 +0200

    tdf#97128 tdf#154703 docx export framePr: export frame textDirection
    
    textDirection attributes were lost on framePr round-tripping
    
    No existing unit tests were affected by/matched the change.
    
    make CppunitTest_sw_ooxmlexport18 \
        CPPUNIT_TEST_NAME=testTdf154703_framePrTextDirection
    
    Change-Id: I2184b9350391f510c7a2e77096b080e05d3d62da
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150820
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx 
b/sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx
new file mode 100644
index 000000000000..e01c2cf9f495
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf154703_framePrTextDirection.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 72cfe1723870..22e1f21f5707 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -244,6 +244,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePrWrapSpacing, 
"tdf154703_framePrWra
     assertXPath(pXmlDoc, "//w:body/w:p/w:pPr/w:framePr", "hSpace", "2552");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf154703_framePrTextDirection, 
"tdf154703_framePrTextDirection.docx")
+{
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL), 
getProperty<sal_Int16>(getShape(1), "WritingMode"));
+    if (!isExported())
+        return;
+
+    xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+    assertXPath(pXmlDoc, "//w:body/w:p/w:pPr/w:textDirection", "val", "tbRl");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf153613_anchoredAfterPgBreak, 
"tdf153613_anchoredAfterPgBreak.docx")
 {
     const auto& pLayout = parseLayoutDump();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 94ed8bac2ba9..87446d03c786 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -584,6 +584,7 @@ void FramePrHelper::SetFrame(ww8::Frame* pFrame, sal_Int32 
nTableDepth)
     {
         m_bUseFrameBorders = true;
         m_bUseFrameBackground = true;
+        m_bUseFrameTextDirection = true;
     }
 }
 
@@ -603,6 +604,14 @@ bool FramePrHelper::UseFrameBackground()
     return m_bUseFrameBackground;
 }
 
+bool FramePrHelper::UseFrameTextDirection(sal_Int32 nTableDepth)
+{
+    if (!m_pFrame || m_nTableDepth < nTableDepth)
+        return false;
+
+    return m_bUseFrameTextDirection;
+}
+
 void SdtBlockHelper::DeleteAndResetTheLists()
 {
     if (m_pTokenChildren.is() )
@@ -1571,9 +1580,24 @@ void DocxAttributeOutput::EndParagraphProperties(const 
SfxItemSet& rParagraphMar
             }
         }
 
+        if (m_aFramePr.UseFrameTextDirection(!m_xTableWrt ? -1 : 
m_tableReference.m_nTableDepth))
+        {
+            const SvxFrameDirectionItem& rFrameDir = 
rFrameFormat.GetFrameDir();
+            if (rFrameDir.GetValue() != SvxFrameDirection::Environment)
+            {
+                assert(!m_rExport.m_bOutPageDescs);
+                // hack: use existing variable to write out the full 
TextDirection attribute.
+                // This is valid for paragraphs/styles - just not native in 
LO, so hack for now.
+                m_rExport.m_bOutPageDescs = true;
+                FormatFrameDirection(rFrameDir);
+                m_rExport.m_bOutPageDescs = false;
+            }
+        }
+
         // reset to true in preparation for the next paragraph in the frame
         m_aFramePr.SetUseFrameBorders(true);
         m_aFramePr.SetUseFrameBackground(true);
+        m_aFramePr.SetUseFrameTextDirection(true);
     }
 
     m_pSerializer->endElementNS( XML_w, XML_pPr );
@@ -9775,6 +9799,7 @@ void DocxAttributeOutput::FormatFrameDirection( const 
SvxFrameDirectionItem& rDi
             m_pSerializer->singleElementNS(XML_w, XML_bidi, FSNS(XML_w, 
XML_val), "1");
         else
             m_pSerializer->singleElementNS(XML_w, XML_bidi, FSNS(XML_w, 
XML_val), "0");
+        m_aFramePr.SetUseFrameTextDirection(false);
     }
 }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx 
b/sw/source/filter/ww8/docxattributeoutput.hxx
index 5b4708936605..35171507cd38 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -133,6 +133,7 @@ class FramePrHelper
     sal_Int32 m_nTableDepth;
     bool m_bUseFrameBorders;
     bool m_bUseFrameBackground;
+    bool m_bUseFrameTextDirection;
 
 public:
     FramePrHelper()
@@ -140,6 +141,7 @@ public:
         , m_nTableDepth(0)
         , m_bUseFrameBorders(true)
         , m_bUseFrameBackground(true)
+        , m_bUseFrameTextDirection(true)
     {}
 
     ww8::Frame* Frame() { return m_pFrame; }
@@ -148,6 +150,8 @@ public:
     void SetUseFrameBorders(bool bSet) { m_bUseFrameBorders = bSet; }
     bool UseFrameBackground();
     void SetUseFrameBackground(bool bSet) { m_bUseFrameBackground = bSet; }
+    bool UseFrameTextDirection(sal_Int32 nTableDepth);
+    void SetUseFrameTextDirection(bool bSet) { m_bUseFrameTextDirection = 
bSet; }
 };
 
 class SdtBlockHelper

Reply via email to