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

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Sun Dec 20 21:11:46 UTC 2020


 i18npool/source/localedata/LocaleNode.cxx |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

New commits:
commit ff804ebff0c94e8780f01dde80c402afd3a5d208
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Sun Dec 20 19:24:36 2020 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Sun Dec 20 22:11:08 2020 +0100

    Check Calendar unoid for unknown and duplicates
    
    https://gerrit.libreoffice.org/c/core/+/108015 tried to add
    another Gregorian calendar with a made-up "gregorian_en" unoid.
    Prevent that already at build time.
    
    Change-Id: Id1bed6bea28b9c80e75b03753cdb367d3160dac1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108055
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index 3040f3312d42..34c77516cc73 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -22,6 +22,7 @@
 #include <algorithm>
 #include <memory>
 #include <vector>
+#include <map>
 #include <o3tl/sorted_vector.hxx>
 
 #include <rtl/ustrbuf.hxx>
@@ -1559,6 +1560,23 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
     std::unique_ptr<sal_Int16[]> nbOfGenitiveMonths( new sal_Int16[nbOfCalendars] );
     std::unique_ptr<sal_Int16[]> nbOfPartitiveMonths( new sal_Int16[nbOfCalendars] );
     std::unique_ptr<sal_Int16[]> nbOfEras( new sal_Int16[nbOfCalendars] );
+
+    // Known allowed calendar identifiers (unoid) and whether used or not.
+    // Of course there must be an implementation for new to be added
+    // identifiers.. see data/locale.dtd
+    std::map< OUString, bool > aCalendars;
+    aCalendars["buddhist"]   = false;
+    aCalendars["gengou"]     = false;
+    aCalendars["gregorian"]  = false;
+    aCalendars["hanja"]      = false;
+    aCalendars["hanja_yoil"] = false;
+    aCalendars["hijri"]      = false;
+    aCalendars["jewish"]     = false;
+    aCalendars["ROC"]        = false;
+    // Not in ODF:
+    aCalendars["dangi"]      = false;
+    aCalendars["persian"]    = false;
+
     sal_Int16 j;
     sal_Int16 i;
     bool bHasGregorian = false;
@@ -1571,6 +1589,13 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
         bool bGregorian = calendarID == "gregorian";
         if (!bHasGregorian)
             bHasGregorian = bGregorian;
+        auto calIt = aCalendars.find(calendarID);
+        if (calIt == aCalendars.end())
+            incErrorStr( "Error: unknown Calendar unoid: %s\n", calendarID);
+        else if (calIt->second)
+            incErrorStr( "Error: duplicate Calendar unoid: %s\n", calendarID);
+        else
+            calIt->second = true;
         str = calNode -> getAttr().getValueByName("default");
         of.writeDefaultParameter("Calendar", str, i);
 


More information about the Libreoffice-commits mailing list