/* * (c) Copyright Ascensio System SIA 2010-2023 * * 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 * */ #include "GlobalsSubstream.h" #include "AnyObject.h" #include "Biff_unions/INTERFACE.h" #include "Biff_unions/PROTECTION.h" #include "Biff_unions/FNGROUPS.h" #include "Biff_unions/FORMATTING.h" #include "Biff_unions/PIVOTCACHEDEFINITION.h" #include "Biff_unions/DOCROUTE.h" #include "Biff_unions/BUNDLESHEET.h" #include "Biff_unions/METADATA.h" #include "Biff_unions/SUPBOOK.h" #include "Biff_unions/LBL.h" #include "Biff_unions/RTD.h" #include "Biff_unions/MSODRAWINGGROUP.h" #include "Biff_unions/SHAREDSTRINGS.h" #include "Biff_unions/THEME.h" #include "Biff_unions/STYLES.h" #include "Biff_unions/XFS.h" #include "Biff_records/BOF.h" #include "Biff_records/WriteProtect.h" #include "Biff_records/FilePass.h" #include "Biff_records/Template.h" #include "Biff_records/WriteAccess.h" #include "Biff_records/FileSharing.h" #include "Biff_records/CodePage.h" #include "Biff_records/Lel.h" #include "Biff_records/DSF.h" #include "Biff_records/Excel9File.h" #include "Biff_records/RRTabId.h" #include "Biff_records/ObProj.h" #include "Biff_records/ObNoMacros.h" #include "Biff_records/CodeName.h" #include "Biff_records/Lbl.h" #include "Biff_records/OleObjectSize.h" #include "Biff_records/Window1.h" #include "Biff_records/Backup.h" #include "Biff_records/HideObj.h" #include "Biff_records/Date1904.h" #include "Biff_records/CalcPrecision.h" #include "Biff_records/RefreshAll.h" #include "Biff_records/BookBool.h" #include "Biff_records/UserBView.h" #include "Biff_records/UsesELFs.h" #include "Biff_records/MTRSettings.h" #include "Biff_records/ForceFullCalculation.h" #include "Biff_records/Country.h" #include "Biff_records/RecalcId.h" #include "Biff_records/HFPicture.h" #include "Biff_records/ExtSST.h" #include "Biff_records/WebPub.h" #include "Biff_records/WOpt.h" #include "Biff_records/CrErr.h" #include "Biff_records/BookExt.h" #include "Biff_records/FeatHdr.h" #include "Biff_records/DConn.h" #include "Biff_records/CompressPictures.h" #include "Biff_records/Compat12.h" #include "Biff_records/GUIDTypeLib.h" #include "Biff_records/EOF.h" #include "Biff_records/BOF.h" #include "Biff_records/MDTInfo.h" #include "Biff_records/ExternSheet.h" #include "Biff_records/XFExt.h" #include "Biff_records/XFCRC.h" #include "Biff_records/DXF.h" #include "Biff_records/SupBook.h" #include "Biff_records/NameCmt.h" #include "Biff_records/SupBook.h" #include "Biff_records/ExternName.h" #include "Biff_records/ExternSheet.h" #include "Biff_records/Continue.h" //#include "Biff_records/XCT.h" //#include "Biff_records/CRN.h" #include "Biff_structures/ODRAW/SimpleOfficeArtContainers.h" namespace XLS {; static const int aCodePages[][2] = { //charset codepage 0, 1252, //ANSI 1, 0,//Default 2, 42,//Symbol 77, 10000,//Mac Roman 78, 10001,//Mac Shift Jis 79, 10003,//Mac Hangul 80, 10008,//Mac GB2312 81, 10002,//Mac Big5 83, 10005,//Mac Hebrew 84, 10004,//Mac Arabic 85, 10006,//Mac Greek 86, 10081,//Mac Turkish 87, 10021,//Mac Thai 88, 10029,//Mac East Europe 89, 10007,//Mac Russian 128, 932,//Shift JIS 129, 949,//Hangul 130, 1361,//Johab 134, 936,//GB2312 136, 950,//Big5 238, 1250,//Greek 161, 1253,//Greek 162, 1254,//Turkish 163, 1258,//Vietnamese 177, 1255,//Hebrew 178, 1256, //Arabic 186, 1257,//Baltic 204, 1251,//Russian 222, 874,//Thai 238, 1250,//Eastern European 254, 437,//PC 437 255, 850//OEM }; GlobalsSubstream::GlobalsSubstream(const unsigned short code_page) : code_page_(code_page) { } GlobalsSubstream::~GlobalsSubstream() { } BaseObjectPtr GlobalsSubstream::clone() { return BaseObjectPtr(new GlobalsSubstream(*this)); } const bool GlobalsSubstream::loadContent(BinProcessor& proc) { int count = 0; global_info_ = proc.getGlobalWorkbookInfo(); while (true) { CFRecordType::TypeId type = proc.getNextRecordType(); if (type == rt_NONE) { proc.SkipRecord(); type = proc.getNextRecordType(); if (type == rt_NONE) break; } if (type == rt_EOF) { proc.mandatory(); break; } switch(type) { case rt_BOF_BIFF8: case rt_BOF_BIFF4: case rt_BOF_BIFF3: case rt_BOF_BIFF2: { if (proc.optional()) { BOF *bof = dynamic_cast(elements_.back().get()); global_info_->Version = bof->vers; if (global_info_->Version < 0x0600) { global_info_->CodePage = 0; //??? } } }break; case rt_WriteProtect: { if (proc.optional()) { m_WriteProtect = elements_.back(); elements_.pop_back(); } }break; case rt_FilePass: { if (proc.optional()) { if (( global_info_->decryptor) && ( global_info_->decryptor->IsVerify() == false)) { if (!global_info_->decryptor->SetPassword(L"VelvetSweatshop")) return false; else global_info_->bWorkbookProtectExist = true; } } }break; case rt_Template: { if (proc.optional