From d8d540bd02717c2dd83c5fb306b9f37d5c13088f Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Mon, 14 Oct 2024 20:35:01 +0600 Subject: [PATCH] Add local info class --- .../CellFormatController/DateReader.cpp | 2 + .../Reader/CellFormatController/LocalInfo.cpp | 68 +++++++++++++++++ .../Reader/CellFormatController/LocalInfo.h | 74 +++++++++++++++++++ .../Linux/BinDocument/BinDocument.pro | 4 +- 4 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.cpp create mode 100644 OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.h diff --git a/OOXML/Binary/Sheets/Reader/CellFormatController/DateReader.cpp b/OOXML/Binary/Sheets/Reader/CellFormatController/DateReader.cpp index 1baeb7f82f..6f328dd499 100644 --- a/OOXML/Binary/Sheets/Reader/CellFormatController/DateReader.cpp +++ b/OOXML/Binary/Sheets/Reader/CellFormatController/DateReader.cpp @@ -31,6 +31,7 @@ */ #include "DateReader.h" +#include "LocalInfo.h" #include #include @@ -82,6 +83,7 @@ std::vector DateFormatsShort = { bool DateReader::GetDigitalDate(const std::wstring &date, double &result, bool &Hasdate, bool &Hastime) { + auto locInf = lcInfo::getLocalInfo(lcid_); //делим форматы на длинные и короткие для уменьшения перебора std::vector * requiredFormats; if(date.size() > 10) diff --git a/OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.cpp b/OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.cpp new file mode 100644 index 0000000000..cc291c0070 --- /dev/null +++ b/OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.cpp @@ -0,0 +1,68 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +#pragma once + +#include "LocalInfo.h" +#include + +namespace lcInfo +{ +std::map<_INT32, LocalInfo> InfoMap +{ + {-1, LocalInfo{-1, L"default", L".", L":", L"135", L"%d %B %Y"}}, + {25, LocalInfo{25, L"ru", L".", L":", L"135", L"%d %B %Y г."}} +}; + + +LocalInfo getLocalInfo(const _INT32 lcid) +{ + auto result = InfoMap.find(lcid); + if(result == InfoMap.end()) + return InfoMap.at(-1); + return InfoMap.at(lcid); +} + + +//LocalInfo methods + +//todo сборка кода формата из сокращенного формата и разделителя +std::wstring LocalInfo::GetshortYearDateFormat() +{ + return L"%d.%m.%Y"; +} + +std::wstring LocalInfo::GetLongYearDateFormat() +{ + return L"%d.%m.%Y"; +} +} diff --git a/OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.h b/OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.h new file mode 100644 index 0000000000..ba63153566 --- /dev/null +++ b/OOXML/Binary/Sheets/Reader/CellFormatController/LocalInfo.h @@ -0,0 +1,74 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2024 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +#pragma once + +#include "../../../../Base/Base.h" + +#include + +namespace lcInfo +{ + +/// @brief класс содержащий в себе информацию о локали и используемых в ней стандартах +class LocalInfo +{ +public: + + std::wstring GetshortYearDateFormat(); + + std::wstring GetLongYearDateFormat(); + + /// @brief id локали + _INT32 lcid; + + /// @brief название локали + std::wstring Name; + + /// @brief разделитель даты + std::wstring DateSeparator; + + /// @brief разделитель времени + std::wstring TimeSeparator; + + /// @brief сокращенная дата + std::wstring ShortDatePattern; + + /// @brief полное представление даты + std::wstring LongDatePattern; + +}; + +/// @brief получение информации о локали по её id +LocalInfo getLocalInfo(const _INT32 lcid); + +} diff --git a/OOXML/Projects/Linux/BinDocument/BinDocument.pro b/OOXML/Projects/Linux/BinDocument/BinDocument.pro index e82d53635a..d49218d6d2 100644 --- a/OOXML/Projects/Linux/BinDocument/BinDocument.pro +++ b/OOXML/Projects/Linux/BinDocument/BinDocument.pro @@ -67,8 +67,9 @@ SOURCES += \ ../../../Binary/Sheets/Reader/XMLReader/XMLMap.cpp \ ../../../Binary/Sheets/Reader/XMLReader/XMLReader2.cpp \ ../../../Binary/Sheets/Reader/CellFormatController/CellFormatController.cpp \ + ../../../Binary/Sheets/Reader/CellFormatController/DigitReader.cpp\ ../../../Binary/Sheets/Reader/CellFormatController/DateReader.cpp\ - ../../../Binary/Sheets/Reader/CellFormatController/DigitReader.cpp\ + ../../../Binary/Sheets/Reader/CellFormatController/LocalInfo.cpp\ ../../../Binary/Sheets/Reader/CellFormatController/CurrencyReader.cpp HEADERS += \ @@ -114,6 +115,7 @@ HEADERS += \ ../../../Binary/Sheets/Reader/XMLReader/XMLConverter2.h \ ../../../Binary/Sheets/Reader/XMLReader/XMLMap.h \ ../../../Binary/Sheets/Reader/CellFormatController/CellFormatController.h \ + ../../../Binary/Sheets/Reader/CellFormatController/LocalInfo.h\ ../../../Binary/Sheets/Reader/CellFormatController/DateReader.h\ ../../../Binary/Sheets/Reader/CellFormatController/DigitReader.h\ ../../../Binary/Sheets/Reader/CellFormatController/CurrencyReader.h