summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-08-27 12:34:12 +0300
committerAndras Timar <andras.timar@collabora.com>2018-09-21 00:24:37 -0700
commit6a03a91c4ee7fb875aa7818b026ff0fa6d72c83c (patch)
treeed577bfa6c3f02ebbdec7914b4238e25d600b976 /writerfilter
parentdab16fd108e13b94deea01cd2fa325e9ab94fb22 (diff)
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@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/59672 Reviewed-by: Aron Budea <aron.budea@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com> (cherry picked from commit 348a1e11045ca8d9dbceab43a68d44dbde3f922c)
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx18
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.hxx5
-rw-r--r--writerfilter/source/ooxml/model.xml24
3 files changed, 47 insertions, 0 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 388f02603f85..6958d15aaae2 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -387,6 +387,10 @@ void OOXMLFastContextHandler::endCharacterGroup()
}
}
+void OOXMLFastContextHandler::pushBiDiEmbedLevel() {}
+
+void OOXMLFastContextHandler::popBiDiEmbedLevel() {}
+
void OOXMLFastContextHandler::startParagraphGroup()
{
if (isForwardEvents())
@@ -1276,6 +1280,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, OUString(sal_Unicode(bRtl ? 0x202B : 0x202A))); // RLE / LRE
+}
+
+void OOXMLFastContextHandlerValue::popBiDiEmbedLevel()
+{
+ OOXMLFactory::characters(this, OUString(sal_Unicode(0x202C))); // PDF (POP DIRECTIONAL FORMATTING)
+}
+
/*
class OOXMLFastContextHandlerTable
*/
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 62a4e00822df..e21132210d1b 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -144,6 +144,8 @@ public:
void endParagraphGroup();
void startCharacterGroup();
void endCharacterGroup();
+ virtual void pushBiDiEmbedLevel();
+ virtual void popBiDiEmbedLevel();
void startSdt();
void endSdt();
@@ -341,6 +343,9 @@ public:
virtual void setDefaultHexValue() override;
virtual void setDefaultStringValue() override;
+ virtual void pushBiDiEmbedLevel() override;
+ virtual void popBiDiEmbedLevel() override;
+
protected:
OOXMLValue::Pointer_t mpValue;
};
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 76d718450e50..884c559fc2fe 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -13939,12 +13939,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>
@@ -18128,6 +18143,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"/>