i18npool/source/localedata/LocaleNode.cxx |    6 +++---
 include/i18npool/reservedconstants.hxx    |   21 +++++++++++++++++++++
 svl/source/numbers/zforlist.cxx           |    7 +++++++
 3 files changed, 31 insertions(+), 3 deletions(-)

New commits:
commit 3eb837565878ebb2da5a11c3286a1f1ef0899183
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Mon Aug 19 18:28:19 2019 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Mon Aug 19 19:50:03 2019 +0200

    Add build time check for NF_INDEX_TABLE_ENTRIES <= nFirstFreeFormatIndex
    
    This was just tribal knowledge..
    
    Change-Id: I3d4d93d6eae01c2f3f73a309043bf59dcca10ff6
    Reviewed-on: https://gerrit.libreoffice.org/77749
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/i18npool/source/localedata/LocaleNode.cxx 
b/i18npool/source/localedata/LocaleNode.cxx
index c79c2dae88bf..11a12bd3d6eb 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -28,6 +28,7 @@
 #include <sal/macros.h>
 
 #include "LocaleNode.hxx"
+#include <i18npool/reservedconstants.hxx>
 #include <com/sun/star/i18n/NumberFormatIndex.hpp>
 #include <com/sun/star/xml/sax/XAttributeList.hpp>
 
@@ -574,7 +575,6 @@ void LCFormatNode::generateCode (const OFileWriter &of) 
const
     bool bCtypeIsRef = false;
     bool bHaveEngineering = false;
     bool bShowNextFreeFormatIndex = false;
-    const sal_Int16 nFirstFreeFormatIndex = 60;
 
     for (sal_Int32 i = 0; i< getNumberOfChildren() ; i++, formatCount++)
     {
@@ -621,7 +621,7 @@ void LCFormatNode::generateCode (const OFileWriter &of) 
const
         sal_Int16 formatindex = static_cast<sal_Int16>(aFormatIndex.toInt32());
         // Ensure the new reserved range is not used anymore, free usage start
         // was up'ed from 50 to 60.
-        if (50 <= formatindex && formatindex < nFirstFreeFormatIndex)
+        if (50 <= formatindex && formatindex < i18npool::nFirstFreeFormatIndex)
         {
             incErrorInt( "Error: Reserved formatindex=\"%d\" in 
FormatElement.\n", formatindex);
             bShowNextFreeFormatIndex = true;
@@ -828,7 +828,7 @@ void LCFormatNode::generateCode (const OFileWriter &of) 
const
 
     if (bShowNextFreeFormatIndex)
     {
-        sal_Int16 nNext = nFirstFreeFormatIndex;
+        sal_Int16 nNext = i18npool::nFirstFreeFormatIndex;
         std::set<sal_Int16>::const_iterator it( aFormatIndexSet.find( nNext));
         if (it != aFormatIndexSet.end())
         {
diff --git a/include/i18npool/reservedconstants.hxx 
b/include/i18npool/reservedconstants.hxx
new file mode 100644
index 000000000000..400344ce5a8d
--- /dev/null
+++ b/include/i18npool/reservedconstants.hxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/types.h>
+
+/** Constant values shared between i18npool and, for example, the number 
formatter. */
+namespace i18npool
+{
+/** The number of reserved (with defined meaning) built-in format code indices,
+    additional locale data format codes can be defined starting at this index
+    value. */
+constexpr sal_Int16 nFirstFreeFormatIndex = 60;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 6d8a906a0038..5b7aadb8ebd5 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -45,6 +45,7 @@
 #include "zforscan.hxx"
 #include "zforfind.hxx"
 #include <svl/zformat.hxx>
+#include <i18npool/reservedconstants.hxx>
 
 #include <unotools/syslocaleoptions.hxx>
 #include <unotools/digitgroupingiterator.hxx>
@@ -92,6 +93,12 @@ using namespace ::std;
 
 static_assert( ZF_STANDARD_TEXT == NF_STANDARD_FORMAT_TEXT, "definition 
mismatch" );
 
+static_assert( NF_INDEX_TABLE_ENTRIES <= i18npool::nFirstFreeFormatIndex,
+        "NfIndexTableOffset crosses i18npool's locale data reserved format 
code index bounds.\n"
+        "You will need to adapt all locale data files defining index values "
+        "(formatIndex=\"...\") in that range and increment those and when done 
"
+        "adjust nFirstFreeFormatIndex in i18npool/reservedconstants.hxx");
+
 /* Locale that is set if an unknown locale (from another system) is loaded of
  * legacy documents. Can not be SYSTEM because else, for example, a German "DM"
  * (old currency) is recognized as a date (#53155#). */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to