[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/qa writerfilter/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Aug 28 14:21:51 UTC 2018


 sw/qa/extras/ooxmlexport/data/tdf119143.docx          |binary
 sw/qa/extras/ooxmlexport/ooxmlexport11.cxx            |   20 +++++++++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   18 +++++++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    5 +++
 writerfilter/source/ooxml/model.xml                   |   24 ++++++++++++++++++
 5 files changed, 67 insertions(+)

New commits:
commit c18e2c314a8f694abd3d31a168f670078d183011
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Aug 27 12:34:12 2018 +0300
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Tue Aug 28 16:21:20 2018 +0200

    tdf#119143: introduce tentative directional embedding import support
    
    ECMA-376-1:2016 states that w:dir is functionally equivalent to LRE/RLE+PDF
    pair around the enclosed runs. So this patch does just that.
    
    Change-Id: Ibf9775338cc38a3bbc38a42a33fc64ae787b478f
    Reviewed-on: https://gerrit.libreoffice.org/59643
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/59671
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf119143.docx b/sw/qa/extras/ooxmlexport/data/tdf119143.docx
new file mode 100644
index 000000000000..be0bc03f71c1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf119143.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index a00d8f4f546d..131953eb9723 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -315,6 +315,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112118_DOCX, "tdf112118.docx")
     }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf119143, "tdf119143.docx")
+{
+    // The runs inside <w:dir> were ignored
+    const OUString sParaText = getParagraph(1)->getString();
+    CPPUNIT_ASSERT_EQUAL(
+        OUString::fromUtf8(
+            u8"عندما يريد العالم أن يتكلّم ‬ ، فهو يتحدّث "
+            u8"بلغة "
+            u8"يونيكود. تسجّل الآن لحضور المؤتمر الدولي العاشر "
+            u8"ليونيكود (Unicode Conference)، الذي سيعقد في 10-12 "
+            u8"آذار 1997 بمدينة مَايِنْتْس، ألمانيا. و سيجمع المؤتمر "
+            u8"بين خبراء من كافة قطاعات الصناعة على الشبكة "
+            u8"العالمية انترنيت ويونيكود، حيث ستتم، على الصعيدين "
+            u8"الدولي والمحلي على حد سواء مناقشة سبل استخدام "
+            u8"يونكود في النظم القائمة وفيما يخص التطبيقات "
+            u8"الحاسوبية، الخطوط، تصميم النصوص والحوسبة متعددة "
+            u8"اللغات."),
+        sParaText);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 138954023f89..8647b4525727 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -357,6 +357,10 @@ void OOXMLFastContextHandler::endCharacterGroup()
     }
 }
 
+void OOXMLFastContextHandler::pushBiDiEmbedLevel() {}
+
+void OOXMLFastContextHandler::popBiDiEmbedLevel() {}
+
 void OOXMLFastContextHandler::startParagraphGroup()
 {
     if (isForwardEvents())
@@ -1230,6 +1234,20 @@ void OOXMLFastContextHandlerValue::setDefaultStringValue()
         setValue(pValue);
     }
 }
+
+// ECMA-376-1:2016 17.3.2.8; https://www.unicode.org/reports/tr9/#Explicit_Directional_Embeddings
+void OOXMLFastContextHandlerValue::pushBiDiEmbedLevel()
+{
+    const bool bRtl
+        = mpValue.get() && mpValue.get()->getInt() == NS_ooxml::LN_Value_ST_Direction_rtl;
+    OOXMLFactory::characters(this, bRtl ? u"\u202B" : u"\u202A"); // RLE / LRE
+}
+
+void OOXMLFastContextHandlerValue::popBiDiEmbedLevel()
+{
+    OOXMLFactory::characters(this, u"\u202C"); // PDF (POP DIRECTIONAL FORMATTING)
+}
+
 /*
   class OOXMLFastContextHandlerTable
 */
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index a89644dc6e2d..8876ff76ad2d 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -137,6 +137,8 @@ public:
     void endParagraphGroup();
     void startCharacterGroup();
     void endCharacterGroup();
+    virtual void pushBiDiEmbedLevel();
+    virtual void popBiDiEmbedLevel();
     void startSdt();
     void endSdt();
 
@@ -333,6 +335,9 @@ public:
     virtual void setDefaultHexValue() override;
     virtual void setDefaultStringValue() override;
 
+    virtual void pushBiDiEmbedLevel() override;
+    virtual void popBiDiEmbedLevel() override;
+
 private:
     OOXMLValue::Pointer_t mpValue;
 };
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 25f8a267bb8a..36328c035d75 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -13943,12 +13943,27 @@
           <element name="sdt">
             <ref name="CT_SdtRun"/>
           </element>
+          <element name="dir">
+            <ref name="CT_DirContentRun"/>
+          </element>
           <element name="r">
             <ref name="CT_R"/>
           </element>
           <ref name="EG_RunLevelElts"/>
         </choice>
       </define>
+      <define name="CT_DirContentRun">
+        <ref name="EG_PContent"/>
+        <attribute name="val">
+          <ref name="ST_Direction"/>
+        </attribute>
+      </define>
+      <define name="ST_Direction">
+        <choice>
+          <value>ltr</value>
+          <value>rtl</value>
+        </choice>
+      </define>
       <define name="CT_SdtContentRun">
         <ref name="EG_PContent"/>
       </define>
@@ -18144,6 +18159,15 @@
     <resource name="CT_SdtEndPr" resource="Properties">
       <element name="rPr" tokenid="ooxml:CT_SdtEndPr_rPr"/>
     </resource>
+    <resource name="CT_DirContentRun" resource="Value">
+      <attribute name="val" tokenid="ooxml:CT_DirContentRun_val" action="setValue"/>
+      <action name="start" action="pushBiDiEmbedLevel"/>
+      <action name="end" action="popBiDiEmbedLevel"/>
+    </resource>
+    <resource name="ST_Direction" resource="List">
+      <value tokenid="ooxml:Value_ST_Direction_ltr">ltr</value>
+      <value tokenid="ooxml:Value_ST_Direction_rtl">rtl</value>
+    </resource>
     <resource name="CT_SdtContentRun" resource="Stream"/>
     <resource name="CT_SdtContentBlock" resource="Stream"/>
     <resource name="CT_SdtContentRow" resource="Stream"/>


More information about the Libreoffice-commits mailing list