[Libreoffice-commits] core.git: sw/qa sw/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 23 07:33:28 UTC 2020


 sw/qa/extras/ww8export/data/tdf99197_defaultLTR.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx               |    9 ++++++++
 sw/source/filter/ww8/ww8par2.cxx                    |   21 ++++++++------------
 sw/source/filter/ww8/ww8par2.hxx                    |    1 
 sw/source/filter/ww8/ww8par6.cxx                    |    3 ++
 5 files changed, 22 insertions(+), 12 deletions(-)

New commits:
commit 7b9878671a74dc9043d0cdc93e019fdd7d622e8c
Author:     Justin Luth <justin.luth at collabora.com>
AuthorDate: Sat Apr 18 11:35:11 2020 +0300
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Apr 23 09:32:52 2020 +0200

    tdf#99197 ww8import: all root-level para-styles default to LTR
    
    It is not just the "Normal" paragraph style that should
    default to LTR. Any new style that does not inherit from
    anything should be set to LTR, regardless of page/section
    settings.
    
    Change-Id: Ibe1241b813b82afa9b218eae50d6c78042131893
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92468
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ww8export/data/tdf99197_defaultLTR.doc b/sw/qa/extras/ww8export/data/tdf99197_defaultLTR.doc
new file mode 100644
index 000000000000..721b688827e8
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf99197_defaultLTR.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 42cc8237b873..fbc4e0d7a6b4 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -294,6 +294,15 @@ DECLARE_WW8EXPORT_TEST(testTdf80635_pageLeft, "tdf80635_pageLeft.doc")
     CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Indent", long(-2750), getProperty<long>(xTable, "LeftMargin"), 100);
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf99197_defaultLTR, "tdf99197_defaultLTR.doc")
+{
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Default Paragraph style, LTR",
+        text::WritingMode2::LR_TB, getProperty<sal_Int16>(getParagraph(1), "WritingMode") );
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "myDefaultStyle - no base style, LTR",
+        text::WritingMode2::LR_TB, getProperty<sal_Int16>(getParagraph(2), "WritingMode") );
+}
+
 DECLARE_WW8EXPORT_TEST(testTdf107773, "tdf107773.doc")
 {
     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index a18dd5185ccc..d11d9fb71567 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3751,6 +3751,7 @@ WW8RStyle::WW8RStyle(WW8Fib& _rFib, SwWW8ImplReader* pI)
     , mbFSizeChanged(false)
     , mbFCTLSizeChanged(false)
     , mbWidowsChanged(false)
+    , mbBidiChanged(false)
 {
     mpIo->m_vColl.resize(m_cstd);
 }
@@ -3796,6 +3797,14 @@ void WW8RStyle::Set1StyleDefaults()
             mpIo->m_pCurrentColl->SetFormatAttr( SvxWidowsItem( 2, RES_PARATR_WIDOWS ) );
             mpIo->m_pCurrentColl->SetFormatAttr( SvxOrphansItem( 2, RES_PARATR_ORPHANS ) );
         }
+
+        // Word defaults to ltr, not inheriting from the environment like Writer. Regardless of
+        // the page/sections rtl setting, the standard/no-inherit styles lack of rtl still means ltr
+        if( !mbBidiChanged )  // likely, since no UI to change LTR except in default style
+        {
+            mpIo->m_pCurrentColl->SetFormatAttr(
+                SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR));
+        }
     }
 }
 
@@ -4550,18 +4559,6 @@ void WW8RStyle::Import()
 
             mpIo->m_pStandardFormatColl->SetFormatAttr( aAttr );
         }
-
-        /*
-        Word defaults to ltr not from environment like writer. Regardless of
-        the page/sections rtl setting the standard style lack of rtl still
-        means ltr
-        */
-        if (SfxItemState::SET != mpIo->m_pStandardFormatColl->GetItemState(RES_FRAMEDIR,
-            false))
-        {
-           mpIo->m_pStandardFormatColl->SetFormatAttr(
-                SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, RES_FRAMEDIR));
-        }
     }
 
     // we do not read styles anymore:
diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx
index 86f84364aa0e..22ca540b54a9 100644
--- a/sw/source/filter/ww8/ww8par2.hxx
+++ b/sw/source/filter/ww8/ww8par2.hxx
@@ -105,6 +105,7 @@ friend class SwWW8ImplReader;
     bool mbFSizeChanged;     // For Simulating Default-FontSize
     bool mbFCTLSizeChanged;  // For Simulating Default-CTL FontSize
     bool mbWidowsChanged;    // For Simulating Default-Widows / Orphans
+    bool mbBidiChanged;      // For Simulating Default-LTR
 
     void ImportSprms(std::size_t nPosFc, short nLen, bool bPap);
     void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap);
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 47545c6e9166..dd260b4804a1 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3071,6 +3071,9 @@ void SwWW8ImplReader::Read_Bidi(sal_uInt16, const sal_uInt8* pData, short nLen)
         m_bBidi = true;
         sal_uInt8 nBidi = *pData;
         NewAttr( SfxInt16Item( RES_CHRATR_BIDIRTL, (nBidi!=0)? 1 : 0 ) );
+
+        if( m_pCurrentColl && m_xStyles )    // in style definition
+            m_xStyles->mbBidiChanged = true;
     }
 }
 


More information about the Libreoffice-commits mailing list