[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - writerfilter/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Mon Aug 16 10:18:55 UTC 2021


 writerfilter/source/dmapper/DomainMapper.cxx |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 118eb9e426fe729324347685f986ff9e78d49483
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Sat Aug 14 23:32:39 2021 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Aug 16 12:18:11 2021 +0200

    Resolves: tdf#137742 Workaround cheesy Google Docs writing language-only tags
    
    Change-Id: I2dc85abb70d53769d2e36102070e30ed71e8d888
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120495
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 23f17b7ea6fbd2f422c7e40192ae60e4df25224c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120438
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 25ce4297fa98..6f00e9fdb460 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -666,7 +666,29 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
                 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", sStringValue);
             else if (nName == NS_ooxml::LN_CT_Language_bidi)
                 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "bidi", sStringValue);
-            lang::Locale aLocale( LanguageTag::convertToLocale( sStringValue));
+            lang::Locale aLocale;
+            if (sStringValue.getLength() <= 3 && sStringValue.getLength() >= 1)
+            {
+                // Cheesy Google Docs is known to tag language-only even for
+                // "en" or others that need some region to distinguish language
+                // variants for spell-checker and hyphenation. Obtain our known
+                // fallback to clarify and match. The original value/context is
+                // unknown anyway.
+                LanguageTag aLanguageTag( sStringValue);
+                aLanguageTag.makeFallback();
+                if (aLanguageTag.getLanguage() == sStringValue)
+                    aLocale = aLanguageTag.getLocale();
+                else
+                {
+                    // Do not fallback for an unknown language, which usually
+                    // results in "en-US", or any other non-matching case.
+                    aLocale = LanguageTag::convertToLocale( sStringValue);
+                }
+            }
+            else
+            {
+                aLocale = LanguageTag::convertToLocale( sStringValue);
+            }
             if (m_pImpl->GetTopContext())
                 m_pImpl->GetTopContext()->Insert(NS_ooxml::LN_CT_Language_val== nName ? PROP_CHAR_LOCALE :
                              NS_ooxml::LN_CT_Language_eastAsia == nName ? PROP_CHAR_LOCALE_ASIAN : PROP_CHAR_LOCALE_COMPLEX,


More information about the Libreoffice-commits mailing list