sw/qa/extras/ooxmlexport/data/numbers-rtl.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 +++++++++ sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 2 +- sw/source/filter/ww8/docxattributeoutput.cxx | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-)
New commits: commit 40ed8dd3a5a16f21f2e98440c62efa0fa6ec60ff Author: Hossein <hoss...@libreoffice.org> AuthorDate: Tue Aug 15 14:56:53 2023 +0200 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Mon Aug 21 14:26:51 2023 +0200 tdf#155470 DOCX export: fix RTL numbers changed to LTR When using numerals in "context" mode in "Tools > Options", in "Language Settings > Complext Text Layout > General Options > Numerals", the actual display of the numbers is dependant on the direction and the language of those numbers. Previously, when exporting the DOCX in LO the RTL direction was lost, and because of that, the numerals were shown incorrectly after saving in LibreOffice, and loading again. This patch adds <w:rtl/> where <w:lang> contains an RTL language. For example, before <w:lang w:bidi="fa-IR"/> inside <w:rPr>, it always adds <w:rtl/>. It is worth noting that this is not always the case, as there are situations that <w:rtl/> is not present in <w:rPr> with an RTL language like <w:lang w:bidi="fa-IR"/> and <w:rtl/> should not be in the output. This patch does not handle that case, because currently loading such a text is not done correctly in LO, and the LTR numbers inside RTL environment are shown just like RTL numbers. To fix it, first loading and displaying of that should be fixed. A test is added to check the export of the sample file, which can be invoked with: make CppunitTest_sw_ooxmlexport CPPUNIT_TEST_NAME=testTdf155470 Change-Id: I8fc54916fcd3295010c5c81ccb632bc6082ffaa2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155721 Tested-by: Jenkins Reviewed-by: Hossein <hoss...@libreoffice.org> diff --git a/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx b/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx new file mode 100755 index 000000000000..2142967a3619 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/numbers-rtl.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index cbca150319b7..60e097925829 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1106,6 +1106,15 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115094v3) assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblpPr", "tblpY", "1064"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf155470) +{ + loadAndSave("numbers-rtl.docx"); + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + + // Make sure that <w:rtl/> is preserved + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:rtl"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index db2abe3513a7..9458051ea6d3 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -174,7 +174,7 @@ CPPUNIT_TEST_FIXTURE(Test, testStyleInheritance) // We output exactly 2 properties in rPrDefault, nothing else was // introduced as an additional default - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 2); + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 3); // Check that we output real content of rPrDefault assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New Roman"); assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index df29dd801e08..c2a55ff8bfc7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -160,6 +160,7 @@ #include <frozen/bits/defines.h> #include <frozen/bits/elsa_std.h> #include <frozen/unordered_map.h> +#include <i18nlangtag/mslangid.hxx> using ::editeng::SvxBorderLine; @@ -7916,6 +7917,8 @@ void DocxAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage ) AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_eastAsia ), aLanguageCode ); break; case RES_CHRATR_CTL_LANGUAGE: + if (MsLangId::isRightToLeft(rLanguage.GetLanguage())) + m_pSerializer->singleElementNS(XML_w, XML_rtl); AddToAttrList( m_pCharLangAttrList, FSNS( XML_w, XML_bidi ), aLanguageCode ); break; }