Files
core/MsBinaryFile/XlsFile/Format/Auxiliary/HelpFunc.h
Alexander Trofimov 76ee07f61c [copyright] Update copyright header
Co-authored-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
Co-committed-by: Alexander Trofimov <alexander.trofimov@onlyoffice.com>
2026-05-14 08:23:56 +00:00

104 lines
4.8 KiB
C++

/*
* Copyright (C) Ascensio System SIA, 2009-2026
*
* 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, together with the
* additional terms provided in the LICENSE file.
*
* 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: https://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA by email at info@onlyoffice.com
* or by postal mail at 20A-6 Ernesta Birznieka-Upisha Street, Riga,
* LV-1050, Latvia, European Union.
*
* The interactive user interfaces in modified versions of the Program
* are required to display Appropriate Legal Notices in accordance with
* Section 5 of the GNU AGPL version 3.
*
* No trademark rights are granted under this License.
*
* All non-code elements of the Product, including illustrations,
* icon sets, and technical writing content, are licensed under the
* Creative Commons Attribution-ShareAlike 4.0 International License:
* https://creativecommons.org/licenses/by-sa/4.0/legalcode
*
* This license applies only to such non-code elements and does not
* modify or replace the licensing terms applicable to the Program's
* source code, which remains licensed under the GNU Affero General
* Public License v3.
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
#pragma once
#include <string>
#include <vector>
#include "../../../../Common/cfcpp/guid.h"
namespace XLS
{
class CellRangeRef;
};
namespace AUX
{
const int normalizeColumn (const int column, const bool xlsb = false);
const int normalizeRow (const int row, const bool xlsb = false);
const std::wstring column2str (const int column, const bool col_rel, const bool xlsb = false);
const std::wstring row2str (const int row, const bool row_rel, const bool xlsb = false);
const std::wstring loc2str (const int row, const bool row_rel, const int column, const bool col_rel, const bool xlsb = false);
void str2loc (const std::wstring& str, int& row, bool& row_rel, int& column, bool& col_rel);
void str2loc (std::wstring::const_iterator& str_begin, std::wstring::const_iterator& str_end, int& row, bool& row_rel, int& column, bool& col_rel);
void str2refs (const std::wstring& str, std::vector<XLS::CellRangeRef>& vec);
};
namespace STR
{
const std::string int2str (const int val, const int radix = 10);
const std::wstring int2wstr (const int val, const int radix = 10);
const std::wstring double2str (const double val);
const std::string bin2str (const char* buf, const size_t nbuf);
const std::wstring guid2bstr (_GUID_ & guid);
const std::string guid2str (_GUID_ & guid);
const std::wstring guidFromStr (const std::wstring & guid_str);
const bool bstr2guid (const std::wstring & guid_str, _GUID_& guid);
const std::wstring int2hex_wstr(const int val, const size_t size_of = 4);
const std::wstring wchar_t2hex_str (const wchar_t val);
const std::wstring escape_ST_Xstring (const std::wstring& str);
const std::wstring unescape_ST_Xstring (const std::wstring& str);
const std::wstring toARGB (const _UINT32 rgba);
const std::wstring toARGB (const unsigned char red, const unsigned char green, const unsigned char blue, const unsigned char alpha);
const std::wstring toRGB (const _UINT32 rgba);
const std::wstring toRGB (const unsigned char red, const unsigned char green, const unsigned char blue);
const bool fromARGB (const std::wstring& argb, unsigned char& red, unsigned char& green, unsigned char& blue, unsigned char& alpha);
const size_t hex_str2int (const std::wstring& hex);
const size_t hex_str2int (const std::wstring::const_iterator& it_begin, const std::wstring::const_iterator& it_end);
std::string toStdString (std::wstring wide_string, const _UINT32 code_page);
std::wstring toStdWString(std::string ansi_string, const _UINT32 code_page);
std::wstring toStdWString(char* ansi, int size, const _UINT32 code_page);
//std::wstring toStdWStringSystem(std::string ansi_string, const _UINT32 code_page); .. to UnicodeConverter
};
namespace XMLSTUFF
{
const std::wstring name2sheet_name(std::wstring name, const std::wstring prefix);
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix = L"");
unsigned short sheetsnames2ixti(std::wstring name);
unsigned int definenames2index(std::wstring name);
bool isTableFmla(const std::wstring& tableName, _UINT32& listIndex);
bool isColumn(const std::wstring& columnName, _UINT32 listIndex, _UINT16& indexColumn);
unsigned short AddMultysheetXti(const std::wstring& name, const _INT32& firstIxti, const _INT32& secondIxti);
unsigned int AddDefinedName(const std::wstring& name);
}