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

Mark Hung marklh9 at gmail.com
Thu Mar 1 12:01:59 UTC 2018


 sw/source/filter/ww8/wrtw8esh.cxx |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit 18b4c1d0b8e030e4fa081995eccf68f01049892e
Author: Mark Hung <marklh9 at gmail.com>
Date:   Sun Feb 25 00:38:49 2018 +0800

    tdf#45999 doc: make RTL text in comments show correctly in MSWord.
    
    Both sprmPFBiDi and sprmCFBiDi need to be written to doc to make
    the word order correct. The patch output sprmCFBiDi when the
    paragraph is a RTL paragraph.
    
    Change-Id: I429d4e9cf60cf0c65831a24a7f3fa151a9dc3b9f
    Reviewed-on: https://gerrit.libreoffice.org/50294
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 0260e6c74beb..4e5c1a2838fa 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1341,6 +1341,16 @@ void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp
         OUString aStr( rEditObj.GetText( n ));
         sal_Int32 nAktPos = 0;
         const sal_Int32 nEnd = aStr.getLength();
+
+        const SfxItemSet aSet(rEditObj.GetParaAttribs(n));
+        bool bIsRTLPara = false;
+        const SfxPoolItem *pItem;
+        if(SfxItemState::SET == aSet.GetItemState(EE_PARA_WRITINGDIR, true, &pItem))
+        {
+            SvxFrameDirection nDir = static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue();
+            bIsRTLPara = SvxFrameDirection::Horizontal_RL_TB == nDir;
+        }
+
         do {
             const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
 
@@ -1355,6 +1365,17 @@ void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, sal_uInt8 nTyp
 
                                             // output of character attributes
             aAttrIter.OutAttr( nAktPos );   // nAktPos - 1 ??
+
+            if (bIsRTLPara)
+            {
+                // This is necessary to make word order correct in MS Word.
+                // In theory we should do this for complex-script runs only,
+                // but Outliner does not split runs like Writer core did.
+                // Fortunately, both MS Word and Writer seems to tolerate
+                // that we turn it on for non complex-script runs.
+                AttrOutput().OutputItem(SfxInt16Item(RES_CHRATR_BIDIRTL, 1));
+            }
+
             m_pChpPlc->AppendFkpEntry( Strm().Tell(),
                                             pO->size(), pO->data() );
             pO->clear();


More information about the Libreoffice-commits mailing list