From 5483547ee7cde62d32469e376f3481e8d61b4c06 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Fri, 15 Mar 2019 15:47:26 +0300 Subject: [PATCH 1/8] . --- .../source/OdfFormat/odf_drawing_context.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp index bbe826bea1..981cda1f63 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp @@ -2052,8 +2052,8 @@ void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) & double x = x_pt ? *x_pt : 0; double y = y_pt ? *y_pt : 0; - double cx = *impl_->current_drawing_state_.cx_; - double cy = *impl_->current_drawing_state_.cy_; + //double cx = *impl_->current_drawing_state_.cx_; + //double cy = *impl_->current_drawing_state_.cy_; if (impl_->current_drawing_state_.in_group_) { @@ -2067,8 +2067,8 @@ void odf_drawing_context::set_position(_CP_OPT(double) & x_pt, _CP_OPT(double) & x = (x + impl_->group_list_[i]->shift_x) * impl_->group_list_[i]->scale_cx ; y = (y + impl_->group_list_[i]->shift_y) * impl_->group_list_[i]->scale_cy; - cx *= impl_->group_list_[i]->scale_cx; - cy *= impl_->group_list_[i]->scale_cy; + //cx *= impl_->group_list_[i]->scale_cx; + //cy *= impl_->group_list_[i]->scale_cy; } } From 1157d6f97f4eb88194708fe7f5133b915d431bc0 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Fri, 15 Mar 2019 17:27:25 +0300 Subject: [PATCH 2/8] . --- .../formulasconvert/formulasconvert_odf.cpp | 21 +++++++++++++------ ASCOfficeOdfFile/src/docx/oox_chart_values.h | 10 ++++----- ASCOfficeOdfFile/src/odf/chart_build_oox.cpp | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp b/ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp index 90f7ec1bff..b7a6c8cb28 100644 --- a/ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp +++ b/ASCOfficeOdfFile/formulasconvert/formulasconvert_odf.cpp @@ -210,32 +210,41 @@ namespace formulasconvert { bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last) { + std::wstring workstr = expr; + workstr = boost::regex_replace( + workstr, + boost::wregex(L"('.*?')|(\".*?\")"), + &convert_scobci, boost::match_default | boost::format_all); + std::vector< std::wstring > splitted; - boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L".:"), boost::algorithm::token_compress_on); - + boost::algorithm::split(splitted, workstr, boost::algorithm::is_any_of(L".:"), boost::algorithm::token_compress_on); + + bool res = false; if (splitted.size() == 2) { table = splitted[0]; ref_first = splitted[1]; ref_last = splitted[1]; - return true; + res = true; } if (splitted.size() == 3) { table = splitted[0]; ref_first = splitted[1]; ref_last = splitted[2]; - return true; + res = true; } if (splitted.size() == 4) { table = splitted[0]; ref_first = splitted[1]; ref_last = splitted[3]; - return true; + res = true; } - return false; + replace_tmp_back( table ); + + return res; } bool odf2oox_converter::Impl::find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref) diff --git a/ASCOfficeOdfFile/src/docx/oox_chart_values.h b/ASCOfficeOdfFile/src/docx/oox_chart_values.h index c1b3df27ce..dbc93dba91 100644 --- a/ASCOfficeOdfFile/src/docx/oox_chart_values.h +++ b/ASCOfficeOdfFile/src/docx/oox_chart_values.h @@ -55,21 +55,21 @@ struct _oox_numLit struct _oox_strRef { - bool present; + bool present = false; std::wstring formula; - int str_cache_count; + int str_cache_count = 0; std::vector str_cache; }; struct _oox_numRef { - bool present; + bool present = false; std::wstring formula; std::wstring formatCode; - bool link_to_source; - int num_cache_count; + bool link_to_source = false; + int num_cache_count = 0; std::vector num_cache; }; diff --git a/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp b/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp index 2a0bee19b6..27539b21f4 100644 --- a/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp +++ b/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp @@ -457,14 +457,14 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context) } else { //x - if (false == domain_cash.empty() || cash_values.empty()) + if (false == domain_cash.empty() || false == cash_values.empty()) { if (!bPivotChart_) current->set_formula_series(2, domain_cell_range_adress_, formatCode, boolVal.get_value_or(true)); current->set_values_series (2, domain_cash); } //y - if (false == cell_cash.empty() || cash_values.empty()) + if (false == cell_cash.empty() || false == cash_values.empty()) { if (!bPivotChart_) current->set_formula_series(3, series_[i].cell_range_address_, formatCode, boolVal.get_value_or(true)); From ae9a7f7fad4cf96ac6c9fe061b93f5c8d703a856 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Fri, 15 Mar 2019 19:26:57 +0300 Subject: [PATCH 3/8] [zlib] Fix 7-zip Warning: Headers error Problem in header field: "last mod file date". tm_sec = tm_min = tm_hour = tm_mday = tm_mon = tm_year = 0; is considered as 0 Jan 1980 (0x00200000 in file) default value of tm_mon should be -1 (zip64local_TmzDateToDosDate tm_mon+1) --- OfficeUtils/src/ZipUtilsCP.cpp | 66 ++++------------------------------ 1 file changed, 6 insertions(+), 60 deletions(-) diff --git a/OfficeUtils/src/ZipUtilsCP.cpp b/OfficeUtils/src/ZipUtilsCP.cpp index a86686a792..b2bbce4165 100644 --- a/OfficeUtils/src/ZipUtilsCP.cpp +++ b/OfficeUtils/src/ZipUtilsCP.cpp @@ -506,7 +506,7 @@ namespace ZLibZipUtils /*========================================================================================================*/ -int oneZipFile(zipFile & zf, zip_fileinfo & zi, std::wstring & file_name, std::wstring & zip_file_name, int method, int compressionLevel) +int oneZipFile(zipFile & zf, zip_fileinfo* zi, std::wstring & file_name, std::wstring & zip_file_name, int method, int compressionLevel) { int err = -1; @@ -518,7 +518,7 @@ int oneZipFile(zipFile & zf, zip_fileinfo & zi, std::wstring & file_name, std::w if(oFile.ReadFile(pData, oFile.GetFileSize(), dwSizeRead)) { std::string zipFileNameA = codepage_issue_fixToOEM(zip_file_name); - err = zipOpenNewFileInZip( zf, zipFileNameA.c_str(), &zi, NULL, 0, NULL, 0, NULL, method, compressionLevel ); + err = zipOpenNewFileInZip( zf, zipFileNameA.c_str(), zi, NULL, 0, NULL, 0, NULL, method, compressionLevel ); err = zipWriteInFileInZip( zf, pData, dwSizeRead ); err = zipCloseFileInZip( zf ); } @@ -541,27 +541,6 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* zipFile zf = zipOpenHelp(outputFile); - zip_fileinfo zi; - - zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = - zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; - zi.dosDate = 0; - zi.internal_fa = 0; - zi.external_fa = 0; - -#if defined(_WIN32) || defined (_WIN64) - SYSTEMTIME currTime; - - GetLocalTime( &currTime ); - - zi.tmz_date.tm_sec = currTime.wSecond; - zi.tmz_date.tm_min = currTime.wMinute; - zi.tmz_date.tm_hour = currTime.wHour; - zi.tmz_date.tm_mday = currTime.wDay; - zi.tmz_date.tm_mon = currTime.wMonth; - zi.tmz_date.tm_year = currTime.wYear; -#endif - unsigned int filesCount = get_files_count( dir ); unsigned int currentFileIndex = 0; @@ -599,7 +578,7 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* file = NSSystemPath::Combine(szText, cFileName); zipFileName = zipDir + cFileName; - oneZipFile(zf, zi, file, zipFileName, 0, compressionLevel); + oneZipFile(zf, NULL, file, zipFileName, 0, compressionLevel); aCurFiles.erase(aCurFiles.begin() + i, aCurFiles.begin() + i + 1); break; @@ -612,7 +591,7 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* file = NSSystemPath::Combine(szText, cFileName); zipFileName = zipDir + cFileName; - oneZipFile(zf, zi, file, zipFileName, method, compressionLevel); + oneZipFile(zf, NULL, file, zipFileName, method, compressionLevel); if ( progress != NULL ) { @@ -660,27 +639,6 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* { zipFile zf = zipOpenHelp(outputFile); - zip_fileinfo zi; - - zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = - zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; - zi.dosDate = 0; - zi.internal_fa = 0; - zi.external_fa = 0; - -#if defined(_WIN32) || defined (_WIN64) - SYSTEMTIME currTime; - - GetLocalTime( &currTime ); - - zi.tmz_date.tm_sec = currTime.wSecond; - zi.tmz_date.tm_min = currTime.wMinute; - zi.tmz_date.tm_hour = currTime.wHour; - zi.tmz_date.tm_mday = currTime.wDay; - zi.tmz_date.tm_mon = currTime.wMonth; - zi.tmz_date.tm_year = currTime.wYear; -#endif - wstring inputFileName( inputFile ); wstring::size_type pos = 0; @@ -699,7 +657,7 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* zipFileName = wstring( inputFileName.begin(), inputFileName.end() ); } std::string zipFileNameA = codepage_issue_fixToOEM(zipFileName); - err = zipOpenNewFileInZip( zf, zipFileNameA.c_str(), &zi, NULL, 0, NULL, 0, NULL, method, compressionLevel ); + err = zipOpenNewFileInZip( zf, zipFileNameA.c_str(), NULL, NULL, 0, NULL, 0, NULL, method, compressionLevel ); err = zipWriteInFileInZip( zf, pData, dwSizeRead ); err = zipCloseFileInZip( zf ); err = zipClose( zf, NULL ); @@ -929,25 +887,13 @@ int ZipDir( const WCHAR* dir, const WCHAR* outputFile, const OnProgressCallback* if(NULL != zip_file_handle) { - zip_fileinfo zi = {0}; -#if defined(_WIN32) || defined (_WIN64) - SYSTEMTIME currTime; - GetLocalTime( &currTime ); - zi.tmz_date.tm_sec = currTime.wSecond; - zi.tmz_date.tm_min = currTime.wMinute; - zi.tmz_date.tm_hour = currTime.wHour; - zi.tmz_date.tm_mday = currTime.wDay; - zi.tmz_date.tm_mon = currTime.wMonth; - zi.tmz_date.tm_year = currTime.wYear; -#endif - BYTE* pData = NULL; long nSize; std::wstring in_zip_filename; while(callback(in_zip_filename, pData, nSize, pParam)) { std::string in_zip_filenameA = codepage_issue_fixToOEM(in_zip_filename); - if (ZIP_OK != zipOpenNewFileInZip( zip_file_handle, in_zip_filenameA.c_str(), &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, compression_level ) || + if (ZIP_OK != zipOpenNewFileInZip( zip_file_handle, in_zip_filenameA.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, compression_level ) || ZIP_OK != zipWriteInFileInZip(zip_file_handle, pData, nSize) || ZIP_OK != zipCloseFileInZip(zip_file_handle)) { From c07bd58bda34f75b797be68be480b01e9befdf0a Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Mon, 18 Mar 2019 19:58:20 +0300 Subject: [PATCH 4/8] XlsFormat -... --- .../Logic/Biff_records/ContinueFrt.cpp | 17 +++++---- .../Logic/Biff_records/ContinueFrt.h | 10 +++--- .../Logic/Biff_records/ContinueFrt11.cpp | 13 +++++-- .../Logic/Biff_records/ContinueFrt11.h | 7 ++-- .../XlsFormat/Logic/Biff_records/CrtMlFrt.cpp | 11 +++--- .../XlsFormat/Logic/Biff_records/CrtMlFrt.h | 9 +++-- .../Logic/Biff_records/Feature11.cpp | 21 ++++++++++- .../XlsFormat/Logic/Biff_records/Feature11.h | 8 +++-- .../Logic/Biff_records/Feature12.cpp | 14 +++++++- .../Biff_structures/CachedDiskHeader.cpp | 5 ++- .../Logic/Biff_structures/CachedDiskHeader.h | 3 ++ .../Logic/Biff_structures/DXFN12List.cpp | 1 + .../Logic/Biff_structures/DXFN12List.h | 2 +- .../Biff_structures/Feat11FdaAutoFilter.cpp | 1 + .../Biff_structures/Feat11FieldDataItem.cpp | 7 ++-- .../Biff_structures/Feat11FieldDataItem.h | 3 +- .../Logic/Biff_structures/FrtHeader.h | 2 -- .../Biff_structures/TableFeatureType.cpp | 23 ++++++++++-- .../Logic/Biff_structures/TableFeatureType.h | 4 +++ .../XlsFormat/Logic/Biff_unions/FEAT11.cpp | 35 ++++++++++++++----- .../XlsFormat/Logic/ChartSheetSubstream.cpp | 7 +++- 21 files changed, 155 insertions(+), 48 deletions(-) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.cpp index 4105baeea3..0f9c2327c6 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.cpp @@ -35,16 +35,14 @@ namespace XLS { -ContinueFrt::ContinueFrt() +ContinueFrt::ContinueFrt() : nData(0) { } - ContinueFrt::~ContinueFrt() { } - BaseObjectPtr ContinueFrt::clone() { return BaseObjectPtr(new ContinueFrt(*this)); @@ -52,10 +50,15 @@ BaseObjectPtr ContinueFrt::clone() void ContinueFrt::readFields(CFRecord& record) { -#pragma message("####################### ContinueFrt record is not implemented") - Log::error("ContinueFrt record is not implemented."); - - record.skipNunBytes(record.getDataSize() - record.getRdPtr()); + record >> frtHeaderOld; + + nData = record.getDataSize() - 4; + + pData = boost::shared_array(new char[nData]); + + memcpy(pData.get(), record.getCurData(), nData); + + record.skipNunBytes(nData); } } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.h index c17f7acc4c..8a6aaec308 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt.h @@ -31,13 +31,12 @@ */ #pragma once +#include "../Biff_structures/FrtHeaderOld.h" #include "BiffRecord.h" namespace XLS { - -// Logical representation of ContinueFrt record in BIFF8 class ContinueFrt: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(ContinueFrt) @@ -47,11 +46,14 @@ public: ~ContinueFrt(); BaseObjectPtr clone(); - void readFields(CFRecord& record); - static const ElementType type = typeContinueFrt; + static const ElementType type = typeContinueFrt; + + FrtHeaderOld frtHeaderOld; + boost::shared_array pData; + size_t nData; }; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.cpp index 40e2f212a3..7e4de26555 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.cpp @@ -35,16 +35,14 @@ namespace XLS { -ContinueFrt11::ContinueFrt11() +ContinueFrt11::ContinueFrt11(): nData(0) { } - ContinueFrt11::~ContinueFrt11() { } - BaseObjectPtr ContinueFrt11::clone() { return BaseObjectPtr(new ContinueFrt11(*this)); @@ -53,6 +51,15 @@ BaseObjectPtr ContinueFrt11::clone() void ContinueFrt11::readFields(CFRecord& record) { + record >> frtHeaderOld; + + nData = record.getDataSize() - 4; + + pData = boost::shared_array(new char[nData]); + + memcpy(pData.get(), record.getCurData(), nData); + + record.skipNunBytes(nData); } } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.h index f0a6fcb510..56e22cd48b 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ContinueFrt11.h @@ -31,13 +31,12 @@ */ #pragma once +#include "../Biff_structures/FrtHeaderOld.h" #include "BiffRecord.h" namespace XLS { - -// Logical representation of ContinueFrt11 record in BIFF8 class ContinueFrt11: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(ContinueFrt11) @@ -47,12 +46,14 @@ public: ~ContinueFrt11(); BaseObjectPtr clone(); - void readFields(CFRecord& record); static const ElementType type = typeContinueFrt11; + FrtHeaderOld frtHeaderOld; + boost::shared_array pData; + size_t nData; }; } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.cpp index fac87a76a2..e95d608901 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.cpp @@ -52,10 +52,13 @@ BaseObjectPtr CrtMlFrt::clone() void CrtMlFrt::readFields(CFRecord& record) { -#pragma message("####################### CrtMlFrt record is not implemented") - Log::error("CrtMlFrt record is not implemented."); - - record.skipNunBytes(record.getDataSize() - record.getRdPtr()); + record >> frtHeader >> cbXmltkChain; + + //xmltkChain.cb = cbXmltkChain; + //record >> xmltkChain; + record.skipNunBytes(cbXmltkChain); + + record.skipNunBytes(4); } } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.h index 4daa32c2ec..b3a02f1f05 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/CrtMlFrt.h @@ -31,13 +31,12 @@ */ #pragma once +#include "../Biff_structures/FrtHeader.h" #include "BiffRecord.h" namespace XLS { - -// Logical representation of CrtMlFrt record in BIFF8 class CrtMlFrt: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(CrtMlFrt) @@ -47,12 +46,16 @@ public: ~CrtMlFrt(); BaseObjectPtr clone(); - void readFields(CFRecord& record); static const ElementType type = typeCrtMlFrt; + FrtHeader frtHeader; + _UINT32 cbXmltkChain; + + //XmlTkChain xmltkChain; + //----------------------------- _UINT32 cb; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.cpp index afa25b5277..a3d1140289 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.cpp @@ -31,11 +31,12 @@ */ #include "Feature11.h" +#include "ContinueFrt11.h" namespace XLS { -Feature11::Feature11() +Feature11::Feature11(bool bFeat12) : bFeature12(bFeat12) { } @@ -50,6 +51,18 @@ BaseObjectPtr Feature11::clone() void Feature11::readFields(CFRecord& record) { + size_t sz = continue_records.size(); + std::list& recs = continue_records[rt_ContinueFrt11]; + + while (!recs.empty()) + { + ContinueFrt11 continueFrt; + continueFrt.readFields(*recs.front()); + + record.appendRawData(continueFrt.pData.get(), continueFrt.nData); + recs.pop_front(); + } + record >> frtRefHeaderU; record >> isf; @@ -67,7 +80,13 @@ void Feature11::readFields(CFRecord& record) refs2.push_back(BiffStructurePtr(new Ref8U(reff))); sqref += reff.toString() + ((i == cref2 - 1) ? L"" : L" "); } + if (cbFeatData == 0) + { + cbFeatData = record.getDataSize() - (cref2 * 8) - 27; + } + rgbFeat.bFeature12 = bFeature12; + rgbFeat.cbFeatData = cbFeatData; record >> rgbFeat; } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.h index 554f5fb352..49f2f414ab 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature11.h @@ -31,7 +31,7 @@ */ #pragma once -#include "BiffRecord.h" +#include "BiffRecordContinued.h" #include "../Biff_structures/FrtRefHeaderU.h" #include "../Biff_structures/CellRangeRef.h" @@ -40,12 +40,12 @@ namespace XLS { -class Feature11: public BiffRecord +class Feature11 : public BiffRecordContinued //: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(Feature11) BASE_OBJECT_DEFINE_CLASS_NAME(Feature11) public: - Feature11(); + Feature11(bool bFeat12 = false); ~Feature11(); BaseObjectPtr clone(); @@ -62,6 +62,8 @@ public: std::wstring sqref; TableFeatureType rgbFeat; + + bool bFeature12; }; } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature12.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature12.cpp index 1e2eeb8cd5..dbd4f43421 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature12.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Feature12.cpp @@ -31,11 +31,12 @@ */ #include "Feature12.h" +#include "ContinueFrt.h" namespace XLS { -Feature12::Feature12() +Feature12::Feature12() : feature11(true) { } @@ -51,6 +52,17 @@ BaseObjectPtr Feature12::clone() void Feature12::readFields(CFRecord& record) { + size_t sz = continue_records.size(); + std::list& recs = continue_records[rt_ContinueFrt]; + + while (!recs.empty()) + { + ContinueFrt continueFrt; + continueFrt.readFields(*recs.front()); + + record.appendRawData(continueFrt.pData.get(), continueFrt.nData); + recs.pop_front(); + } feature11.readFields(record); } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.cpp index 9ca39b2658..3e72cf0f97 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.cpp @@ -50,7 +50,10 @@ void CachedDiskHeader::load(CFRecord& record) rgHdrDisk.size = cbdxfHdrDisk; rgHdrDisk.load(record); } - record >> strStyleName; + if (fSaveStyleName) + { + record >> strStyleName; + } } } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.h index 5e9ce875bb..c210145cd6 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/CachedDiskHeader.h @@ -52,6 +52,9 @@ public: _UINT32 cbdxfHdrDisk; DXFN12List rgHdrDisk; XLUnicodeString strStyleName; + + bool fSaveStyleName; + }; typedef boost::shared_ptr CachedDiskHeaderPtr; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.cpp index e8585d8f0f..4d9e1f0799 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.cpp @@ -64,6 +64,7 @@ void DXFN12List::load(CFRecord& record) bExist = true; record >> dxfn; size -= (record.getRdPtr() - pos_record); + pos_record = record.getRdPtr(); } if (size > 0) { diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.h index 336f34941f..3a4efd47ad 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/DXFN12List.h @@ -57,7 +57,7 @@ public: XFExtNoFRT xfext; //----------------------------------------------------------------- bool bExist; - _UINT32 size; + _INT32 size; }; typedef boost::shared_ptr DXFN12ListPtr; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FdaAutoFilter.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FdaAutoFilter.cpp index 0253176b72..b048500f3e 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FdaAutoFilter.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FdaAutoFilter.cpp @@ -49,6 +49,7 @@ void Feat11FdaAutoFilter::load(CFRecord& record) if (cbAutoFilter >= 0xffff0000) { //LCA BI - Financial Report Usage2010.xls + record.RollRdPtrBack(4); return; } record.skipNunBytes(2); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.cpp index 78fe02a84b..9d08a252a4 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.cpp @@ -36,7 +36,7 @@ namespace XLS { -Feat11FieldDataItem::Feat11FieldDataItem(_UINT32 _lt, bool bDskHeaderCache) : lt(_lt), bDiskHdrCache(bDskHeaderCache) +Feat11FieldDataItem::Feat11FieldDataItem(_UINT32 _lt, bool bDskHeaderCache, bool bFeat12) : lt(_lt), bDiskHdrCache(bDskHeaderCache), bFeature12(bFeat12) { } BiffStructurePtr Feat11FieldDataItem::clone() @@ -96,7 +96,7 @@ void Feat11FieldDataItem::load(CFRecord& record) { fmla.load(record); } - if (fLoadTotalFmla) + if (fLoadTotalFmla && bFeature12) { if (fLoadTotalArray) { @@ -107,7 +107,7 @@ void Feat11FieldDataItem::load(CFRecord& record) totalFmla.load(record); } } - if (fLoadTotalStr) + if (fLoadTotalStr && bFeature12) { record >> strTotal; } @@ -122,6 +122,7 @@ void Feat11FieldDataItem::load(CFRecord& record) } if (bDiskHdrCache) { + dskHdrCache.fSaveStyleName = fSaveStyleName; record >> dskHdrCache; } } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.h index b1980bedd5..502dca6ca8 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/Feat11FieldDataItem.h @@ -50,7 +50,7 @@ class Feat11FieldDataItem : public BiffStructure { BASE_STRUCTURE_DEFINE_CLASS_NAME(Feat11FieldDataItem) public: - Feat11FieldDataItem(_UINT32 lt, bool bDskHeaderCache); + Feat11FieldDataItem(_UINT32 lt, bool bDskHeaderCache, bool bFeat12); BiffStructurePtr clone(); static const ElementType type = typeFeat11FieldDataItem; @@ -97,6 +97,7 @@ public: //------------------------------------------------ _UINT32 lt; bool bDiskHdrCache; + bool bFeature12; }; typedef boost::shared_ptr Feat11FieldDataItemPtr; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/FrtHeader.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/FrtHeader.h index f9b9c685be..0d5b671921 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/FrtHeader.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/FrtHeader.h @@ -50,8 +50,6 @@ public: BiffStructurePtr clone(); virtual void load(CFRecord& record); - - static const ElementType type = typeFrtHeader; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.cpp index b36e8bd0e3..b075b0d1ab 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.cpp @@ -87,6 +87,25 @@ void TableFeatureType::load(CFRecord& record) fLoadCSPName = GETBIT(flags, 14); fLoadPldwIdChanged = GETBIT(flags, 15); + if (bFeature12) + { + //crwHeader = 0; + //lt = 0x00000003; + //fSingleCell = false; + } + else + { + //lt != 0x00000003; + //crwHeader == 0 && fSingleCell == false -> lt = 0 + } + + if (fAutoFilter) crwHeader = 1; + if (fSingleCell) + { + crwHeader = 0; + crwTotals = 0; + } + record >> flags; verXL = GETBITS(flags, 0, 4); fLoadEntryId = GETBIT(flags, 4); @@ -105,7 +124,7 @@ void TableFeatureType::load(CFRecord& record) record.skipNunBytes(16); // rgbHashParam record >> rgbName; - record >> cFieldData; //from 1 to 100 + record >> cFieldData; //from 1 to 0x100 if (fLoadCSPName) record >> cSPName; @@ -118,7 +137,7 @@ void TableFeatureType::load(CFRecord& record) if (record.getRdPtr() >= record.getDataSize()) return; - arFieldData.push_back(BiffStructurePtr(new Feat11FieldDataItem(lt, (crwHeader == 0x0000 && fSingleCell)))); + arFieldData.push_back(BiffStructurePtr(new Feat11FieldDataItem(lt, (crwHeader == 0x0000 && fSingleCell == 0x0000), bFeature12))); arFieldData.back()->load(record); } if (fLoadPldwIdDeleted) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.h index 601420df9f..981e680e0d 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/TableFeatureType.h @@ -93,6 +93,10 @@ public: BiffStructurePtr idDeleted; BiffStructurePtr idChanged; BiffStructurePtr cellInvalid; +//------- + _UINT32 cbFeatData; + bool bFeature12; + }; typedef boost::shared_ptr TableFeatureTypePtr; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp index 91a3738693..fdc27a5df3 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp @@ -80,9 +80,7 @@ public: return false; } } - int count = 0; - count = proc.repeated(0, 0); - count = proc.repeated(0, 0); + int count = proc.repeated(0, 0); while (proc.optional()) { @@ -199,10 +197,15 @@ int FEAT11::serialize(std::wostream & strm, size_t index) { if (display.empty()) display = feature11->rgbFeat.rgbName.value(); - CP_XML_ATTR(L"id", feature11->rgbFeat.idList); - CP_XML_ATTR(L"name", feature11->rgbFeat.rgbName.value()); - CP_XML_ATTR(L"displayName", display); - CP_XML_ATTR(L"ref", feature11->sqref); + CP_XML_ATTR(L"id", feature11->rgbFeat.idList); + CP_XML_ATTR(L"name", feature11->rgbFeat.rgbName.value()); + CP_XML_ATTR(L"displayName", display); + CP_XML_ATTR(L"ref", feature11->sqref); + if (feature11->rgbFeat.crwHeader > 0) + CP_XML_ATTR(L"headerRowCount", feature11->rgbFeat.crwHeader); + if (feature11->rgbFeat.crwTotals > 0) + CP_XML_ATTR(L"totalsRowCount", feature11->rgbFeat.crwTotals); + //CP_XML_ATTR(L"totalsRowShown", feature11->rgbFeat.fShownTotalRow); if (!comment.empty()) CP_XML_ATTR(L"comment", comment); @@ -289,7 +292,23 @@ int FEAT11::serialize(std::wostream & strm, size_t index) //if (!field->stData.value().empty()) // CP_XML_ATTR(L"dataDxfId", field->stData.value()); } - //totalsRowFunction + if (field->fmla.bFmlaExist) + { + CP_XML_NODE(L"calculatedColumnFormula") + { + CP_XML_STREAM() << field->fmla.fmla.getAssembledFormula(); + } + } + if (field->fLoadTotalFmla) + { + CP_XML_NODE(L"totalsRowFormula") + { + if (field->fLoadTotalArray) + CP_XML_STREAM() << field->totalArrayFmla.getAssembledFormula(); + else + CP_XML_STREAM() << field->totalFmla.getAssembledFormula(); + } + } } } } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp index 6693ef682d..47be65b897 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp @@ -70,6 +70,7 @@ #include "Biff_records/Chart.h" #include "Biff_records/ExternSheet.h" #include "Biff_records/FrtFontList.h" +#include "Biff_records/ChartFrtInfo.h" #include "Biff_unions/FONTLIST.h" #include "Biff_unions/PAGESETUP.h" @@ -385,7 +386,11 @@ const bool ChartSheetSubstream::loadContent(BinProcessor& proc) count--; } }break; - + case rt_ChartFrtInfo: + { + //skipped record + count = proc.repeated(0, 0); + }break; default://unknown .... skip { proc.SkipRecord(); From 29c197f383849e7cb664aecb0278b99a1cf1f01e Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Tue, 19 Mar 2019 19:49:40 +0300 Subject: [PATCH 5/8] XlsFormat - fix bug #40879 --- .gitignore | 1 + .../XlsFormat/Logic/Biff_records/MulBlank.h | 4 - .../source/XlsFormat/Logic/Biff_records/Row.h | 5 +- .../source/XlsFormat/Logic/Biff_unions/CELL.h | 3 +- .../XlsFormat/Logic/Biff_unions/CELLTABLE.cpp | 321 +++++++++--------- .../XlsFormat/Logic/Biff_unions/CELLTABLE.h | 6 +- .../XlsFormat/Logic/Biff_unions/CELL_bu.cpp | 2 +- .../XlsFormat/Logic/Biff_unions/FEAT11.cpp | 7 +- .../XlsFormat/Logic/GlobalWorkbookInfo.h | 8 + .../XlsFormat/Logic/WorksheetSubstream.cpp | 11 +- 10 files changed, 180 insertions(+), 188 deletions(-) diff --git a/.gitignore b/.gitignore index 053b850f3a..4af1c6a82e 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ X2tConverter/Common/DocxFormat/DocxFormatLib/Makefile *.tar.gz **/*.build/ +*.log diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/MulBlank.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/MulBlank.h index d793e6dcb2..d325a0c9d2 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/MulBlank.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/MulBlank.h @@ -36,7 +36,6 @@ namespace XLS { - class IXFCellMulBlankSpecial : public BiffStructure { BASE_STRUCTURE_DEFINE_CLASS_NAME(IXFCellMulBlankSpecial) @@ -53,9 +52,6 @@ public: std::vector rgixfe; }; - - -// Logical representation of MulBlank record in BIFF8 class MulBlank: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(MulBlank) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h index 33d3b4aca9..35e0d832a8 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/Row.h @@ -36,8 +36,6 @@ namespace XLS { - -// Logical representation of Row record in BIFF8 class Row: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(Row) @@ -47,13 +45,12 @@ public: ~Row(); BaseObjectPtr clone(); - void readFields(CFRecord& record); int serialize(std::wostream & stream); - static const ElementType type = typeRow; + static const ElementType type = typeRow; GlobalWorkbookInfoPtr global_info_; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL.h index 22b5db57c1..aa7743839b 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL.h @@ -38,7 +38,6 @@ namespace XLS class CellRef; -// Logical representation of CELL union of records class CELL: public CompositeObject { BASE_OBJECT_DEFINE_CLASS_NAME(CELL) @@ -52,7 +51,7 @@ public: int serialize(std::wostream & stream); - static const ElementType type = typeCELL; + static const ElementType type = typeCELL; int RowNumber; int ColumnNumber; diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp index ceef633953..3d3150928e 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.cpp @@ -31,18 +31,19 @@ */ #include "CELLTABLE.h" -#include -#include -#include -#include +#include "CELL.h" + +#include "../Biff_records/EntExU2.h" +#include "../Biff_records/Row.h" +#include "../Biff_records/DBCell.h" +#include "../Biff_records/MulBlank.h" +#include "../Biff_records/MulRk.h" #include namespace XLS { -// This class is made a deriver of CompositeObject intentionally. -// This is an optimization step - to form a CELLTABLE that is divided into smaller groups class CELL_GROUP : public CompositeObject { BASE_OBJECT_DEFINE_CLASS_NAME(CELL_GROUP) @@ -59,11 +60,10 @@ public: const bool loadContent(BinProcessor& proc) { - global_info_ = proc.getGlobalWorkbookInfo(); + global_info_ = proc.getGlobalWorkbookInfo(); + int index_sheet_info_ = global_info_->current_sheet - 1; - XLS::GlobalWorkbookInfo::_sheet_info zero; - XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->current_sheet >=0 ? - global_info_->sheets_info[global_info_->current_sheet - 1] : zero; + GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->sheets_info[index_sheet_info_]; int count, count_row = 0; @@ -81,7 +81,22 @@ public: sheet_info.customRowsHeight.insert(std::make_pair(row->rw, row->miyRw / 20.)); } } - m_rows.push_back(elements_.front()); + std::map::iterator pFindRow = sheet_info.mapRows.find(row->rw); + if (pFindRow == sheet_info.mapRows.end()) + { + GlobalWorkbookInfo::_row_info row_info; + + row_info.row_info = elements_.front(); + sheet_info.mapRows.insert(std::make_pair(row->rw, row_info)); + } + else + { + if (!pFindRow->second.row_info) + { + pFindRow->second.row_info = elements_.front(); + } + } + elements_.pop_front(); count--; } @@ -97,16 +112,25 @@ public: CELL * cell = dynamic_cast(elements_.front().get()); if (cell) { - std::map>::iterator it = m_cells.find(cell->RowNumber); - if (it == m_cells.end()) + std::map::iterator pFindRow = sheet_info.mapRows.find(cell->RowNumber); + if (pFindRow == sheet_info.mapRows.end()) { - std::list c; - c.push_back(elements_.front()); - m_cells.insert(std::make_pair(cell->RowNumber, c)); + GlobalWorkbookInfo::_row_info row_info; + sheet_info.mapRows.insert(std::make_pair(cell->RowNumber, row_info)); + + pFindRow = sheet_info.mapRows.find(cell->RowNumber); + } + std::map::iterator pFindCell = pFindRow->second.mapCells.find(cell->ColumnNumber); + + if (pFindCell != pFindRow->second.mapCells.end()) + { + CELL* cell_prev = dynamic_cast(pFindCell->second.get()); + + pFindCell->second = elements_.front(); } else { - it->second.push_back(elements_.front()); + pFindRow->second.mapCells.insert(std::make_pair(cell->ColumnNumber, elements_.front())); } } elements_.pop_front(); @@ -124,158 +148,19 @@ public: else return false; } - int serialize(std::wostream & stream); - static const ElementType type = typeCELL_GROUP; + static const ElementType type = typeCELL_GROUP; //--------------------------------------------------------------------------- - std::map> m_cells; - std::list m_rows; - std::list m_DBCells; + std::list m_DBCells; private: std::vector& shared_formulas_locations_ref_; GlobalWorkbookInfoPtr global_info_; }; - - -struct _CompareRowCell -{ - bool operator()(XLS::BaseObjectPtr & first, XLS::BaseObjectPtr & second) - { - CELL * cell_1 = dynamic_cast(first.get()); - CELL * cell_2 = dynamic_cast(second.get()); - - if (!cell_1 || !cell_2) - return true; - - if (cell_1->RowNumber < cell_2->RowNumber) - return true; - else - return false; - } -}CompareRowCell; - -struct _CompareColumnCell -{ - bool operator()(XLS::BaseObjectPtr & first, XLS::BaseObjectPtr & second) - { - CELL * cell_1 = dynamic_cast(first.get()); - CELL * cell_2 = dynamic_cast(second.get()); - - if (!cell_1 || !cell_2) - return true; - - if (cell_1->ColumnNumber < cell_2->ColumnNumber) - return true; - else - return false; - } -}CompareColumnCell; - -int CELL_GROUP::serialize(std::wostream & stream) -{ - XLS::GlobalWorkbookInfo::_sheet_info zero; - XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->current_sheet >=0 ? - global_info_->sheets_info[global_info_->current_sheet - 1] : zero; - - CP_XML_WRITER(stream) - { - std::list::iterator current_row = m_rows.begin(); - - for (std::map>::iterator it_row = m_cells.begin(); it_row != m_cells.end(); it_row++) - { - it_row->second.sort(CompareColumnCell); - - Row * row = NULL; - - if (current_row != m_rows.end()) - { - row = dynamic_cast(current_row->get()); - - while ((row) && (row->rw < it_row->first)) - {//skip cells - row->serialize(stream); - current_row++; - - if (current_row == m_rows.end()) - break; - row = dynamic_cast(current_row->get()); - } - } - CP_XML_NODE(L"row") - { - CP_XML_ATTR(L"r", it_row->first + 1); - if ((row) && (row->rw == it_row->first)) - { - bool xf_set = true; - if (row->fGhostDirty == false) xf_set = false; - - if (xf_set) - { - int xf = row->ixfe_val >= global_info_->cellStyleXfs_count ? row->ixfe_val - global_info_->cellStyleXfs_count : -1/*row->ixfe_val*/; - - if (xf < global_info_->cellXfs_count && xf >= 0) - { - CP_XML_ATTR(L"s", xf); - CP_XML_ATTR(L"customFormat", true); - } - } - if (row->miyRw > 0 && row->miyRw < 0x8000) //v8_14A_1b13.xls - { - CP_XML_ATTR(L"ht", row->miyRw / 20.); - CP_XML_ATTR(L"customHeight", true); - } - if (row->iOutLevel > 0) - { - CP_XML_ATTR(L"outlineLevel", row->iOutLevel); - } - if (row->fCollapsed) - { - CP_XML_ATTR(L"collapsed", row->fCollapsed); - } - if (row->fExAsc) - { - CP_XML_ATTR(L"thickTop", true); - } - if (row->fExDes) - { - CP_XML_ATTR(L"thickBot", true); - } - if (row->fDyZero) - { - CP_XML_ATTR(L"hidden", true); - } - - row = NULL; - current_row++; - if (current_row != m_rows.end()) - row = dynamic_cast(current_row->get()); - - } - for ( std::list::iterator it_cell = it_row->second.begin(); it_cell != it_row->second.end(); it_cell++) - { - (*it_cell)->serialize(CP_XML_STREAM()); - } - } - - } - while (current_row != m_rows.end()) - {//skip cells ... last rows - (*current_row)->serialize(stream); - current_row++; - } - } - - return 0; -} - //----------------------------------------------------------------------------------------------------------------- - - CELLTABLE::CELLTABLE(std::vector& shared_formulas_locations_ref) : - m_count_CELL_GROUP(0) - ,shared_formulas_locations_ref_(shared_formulas_locations_ref) + isConcatinate_(false), shared_formulas_locations_ref_(shared_formulas_locations_ref) { } @@ -293,16 +178,31 @@ BaseObjectPtr CELLTABLE::clone() // CELLTABLE = 1*(1*Row *CELL 1*DBCell) *EntExU2 const bool CELLTABLE::loadContent(BinProcessor& proc) { - CELL_GROUP cell_group1(shared_formulas_locations_ref_); - if(!proc.mandatory(cell_group1)) + global_info_ = proc.getGlobalWorkbookInfo(); + index_sheet_info_ = global_info_->current_sheet - 1; + + GlobalWorkbookInfo::_sheet_info zero; + while (index_sheet_info_ >= global_info_->sheets_info.size()) + { + global_info_->sheets_info.push_back(zero); + } + + CELL_GROUP cell_group(shared_formulas_locations_ref_); + if(!proc.mandatory(cell_group)) { return false; } + + int count = 1 + proc.repeated(cell_group, 0, 0); - CELL_GROUP cell_group2(shared_formulas_locations_ref_); - m_count_CELL_GROUP = proc.repeated(cell_group2, 0, 0); - - int count = proc.repeated(0, 0); + while(!elements_.empty()) + { + //m_arCELLGROUP.insert(m_arCELLGROUP.begin(), elements_.back()); + elements_.pop_back(); + count--; + } + + count = proc.repeated(0, 0); while(count > 0) { m_arEntExU2.insert(m_arEntExU2.begin(), elements_.back()); @@ -311,12 +211,95 @@ const bool CELLTABLE::loadContent(BinProcessor& proc) } return true; } - int CELLTABLE::serialize(std::wostream & stream) { - for (std::list::iterator it = elements_.begin(); it != elements_.end(); ++it) - { - it->get()->serialize(stream); + GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->sheets_info[index_sheet_info_]; + + CP_XML_WRITER(stream) + { + + for (std::map::iterator it_row = sheet_info.mapRows.begin(); it_row != sheet_info.mapRows.end(); it_row++) + { + Row* row = dynamic_cast(it_row->second.row_info.get()); + + if (row && it_row->second.mapCells.empty()) + { + it_row->second.row_info->serialize(stream); + } + else + { + CP_XML_NODE(L"row") + { + CP_XML_ATTR(L"r", it_row->first + 1); + + if (row) + { + bool xf_set = true; + if (row->fGhostDirty == false) xf_set = false; + + if (xf_set) + { + int xf = row->ixfe_val >= global_info_->cellStyleXfs_count ? row->ixfe_val - global_info_->cellStyleXfs_count : -1/*row->ixfe_val*/; + + if (xf < global_info_->cellXfs_count && xf >= 0) + { + CP_XML_ATTR(L"s", xf); + CP_XML_ATTR(L"customFormat", true); + } + } + if (row->miyRw > 0 && row->miyRw < 0x8000) //v8_14A_1b13.xls + { + CP_XML_ATTR(L"ht", row->miyRw / 20.); + CP_XML_ATTR(L"customHeight", true); + } + if (row->iOutLevel > 0) + { + CP_XML_ATTR(L"outlineLevel", row->iOutLevel); + } + if (row->fCollapsed) + { + CP_XML_ATTR(L"collapsed", row->fCollapsed); + } + if (row->fExAsc) + { + CP_XML_ATTR(L"thickTop", true); + } + if (row->fExDes) + { + CP_XML_ATTR(L"thickBot", true); + } + if (row->fDyZero) + { + CP_XML_ATTR(L"hidden", true); + } + } + for ( std::map::iterator it_cell = it_row->second.mapCells.begin(); it_cell != it_row->second.mapCells.end(); it_cell++) + { + if (isConcatinate_) + { + CELL* cell = dynamic_cast((it_cell->second).get()); + + MulBlank *mulblank = dynamic_cast(cell->elements_.begin()->get()); + MulRk *mulrk = dynamic_cast(cell->elements_.begin()->get()); + + if (mulblank || mulrk) + { + std::map::iterator it_next_cell = it_cell; it_next_cell++; + if (it_next_cell != it_row->second.mapCells.end()) + { + CELL* cell_next = dynamic_cast((it_next_cell->second).get()); + + if (mulblank) mulblank->colLast = (std::min)((int)mulblank->colLast, cell_next->ColumnNumber - 1); + if (mulrk) mulrk->colLast = (std::min)((int)mulrk->colLast, cell_next->ColumnNumber - 1); + } + } + } + (it_cell->second)->serialize(CP_XML_STREAM()); + } + } + } + } + } return 0; } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.h index 126958f555..aba4e81fc0 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELLTABLE.h @@ -54,8 +54,12 @@ public: int serialize(std::wostream & stream); std::vector& shared_formulas_locations_ref_; - int m_count_CELL_GROUP; + std::vector m_arEntExU2; + + GlobalWorkbookInfoPtr global_info_; + int index_sheet_info_; + bool isConcatinate_; }; } // namespace XLS diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL_bu.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL_bu.cpp index 54de4496ab..17b877a27b 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL_bu.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CELL_bu.cpp @@ -35,8 +35,8 @@ #include "../Biff_records/Blank.h" #include "../Biff_records/MulBlank.h" -#include "../Biff_records/RK.h" #include "../Biff_records/MulRk.h" +#include "../Biff_records/RK.h" #include "../Biff_records/BoolErr.h" #include "../Biff_records/Number.h" #include "../Biff_records/LabelSst.h" diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp index fdc27a5df3..b37174be9a 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/FEAT11.cpp @@ -201,10 +201,9 @@ int FEAT11::serialize(std::wostream & strm, size_t index) CP_XML_ATTR(L"name", feature11->rgbFeat.rgbName.value()); CP_XML_ATTR(L"displayName", display); CP_XML_ATTR(L"ref", feature11->sqref); - if (feature11->rgbFeat.crwHeader > 0) - CP_XML_ATTR(L"headerRowCount", feature11->rgbFeat.crwHeader); - if (feature11->rgbFeat.crwTotals > 0) - CP_XML_ATTR(L"totalsRowCount", feature11->rgbFeat.crwTotals); + + CP_XML_ATTR(L"headerRowCount", feature11->rgbFeat.crwHeader); + CP_XML_ATTR(L"totalsRowCount", feature11->rgbFeat.crwTotals); //CP_XML_ATTR(L"totalsRowShown", feature11->rgbFeat.fShownTotalRow); if (!comment.empty()) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h index 1416536ab3..b562f1cecb 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/GlobalWorkbookInfo.h @@ -150,6 +150,12 @@ public: unsigned int startAddedSharedStrings; std::vector arAddedSharedStrings; + + struct _row_info + { + BaseObjectPtr row_info; + std::map mapCells; + }; struct _sheet_info { @@ -161,6 +167,8 @@ public: double defaultColumnWidth = 8.0; double defaultRowHeight = 14.4; + + std::map mapRows; }; std::vector<_sheet_info> sheets_info; std::vector external_sheets_info; //current diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp index df2a16d0e5..bb477e8739 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp @@ -239,10 +239,15 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) case rt_Label://file(6).xls case rt_Row: { - CELLTABLE cell_table(shared_formulas_locations); - if (proc.optional(cell_table)) + CELLTABLE cell_table_temlate(shared_formulas_locations); + if (proc.optional(cell_table_temlate)) { - m_CELLTABLE = elements_.back(); + if (m_CELLTABLE) + { + CELLTABLE *cell_table = dynamic_cast(elements_.back().get()); + cell_table->isConcatinate_ = true; + } + m_CELLTABLE = elements_.back(); //пофиг какой тут элемент - данные вынесены во вне elements_.pop_back(); } if(0 != shared_formulas_locations.size()) From 72c4727a1e0dafa9befbd75b459e147b122becfb Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 20 Mar 2019 12:54:00 +0300 Subject: [PATCH 6/8] XlsFormat - fix bug #40895 --- .../source/XlsFormat/Logic/Biff_structures/PtgArea3d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/PtgArea3d.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/PtgArea3d.cpp index 45a621b2ff..562751b256 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/PtgArea3d.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_structures/PtgArea3d.cpp @@ -131,7 +131,7 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f ptg_stack.push(strRange + range_ref); } } - if (ixti != 0xffff) + if (ixti & 0xfff0 != 0xfff0) { std::wstring link = global_info->arXti_External[ixti].link; if (!link.empty() && !range_ref.empty()) From 7e0e30d00fde018e4981a0f0f96fe86435f1b897 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Wed, 20 Mar 2019 14:00:05 +0300 Subject: [PATCH 7/8] [x2t] Fix xlsx->Editor.bin conversion with invalid cell refs GetValue(); nCol = m_oCol->GetValue(); } - else - { - nRow = 0; - nCol = 0; - } + return bRes; } void setRowCol(int nRow, int nCol) { diff --git a/XlsxSerializerCom/Reader/BinaryWriter.cpp b/XlsxSerializerCom/Reader/BinaryWriter.cpp index 998357a1d4..fe80cedb57 100644 --- a/XlsxSerializerCom/Reader/BinaryWriter.cpp +++ b/XlsxSerializerCom/Reader/BinaryWriter.cpp @@ -2963,12 +2963,10 @@ void BinaryWorksheetTableWriter::WriteCell(const OOX::Spreadsheet::CCell& oCell) { int nCurPos; //Ref - if (oCell.isInitRef()) + int nRow = 0; + int nCol = 0; + if (oCell.isInitRef() && oCell.getRowCol(nRow, nCol)) { - int nRow = 0; - int nCol = 0; - oCell.getRowCol(nRow, nCol); - // Пишем теперь не строку, а 2 числа (чтобы не парсить на JavaScript, т.к. на C++ быстрее парсинг). Ускорение открытия файла. nCurPos = m_oBcw.WriteItemStart(c_oSerCellTypes::RefRowCol); m_oBcw.m_oStream.WriteLONG(nRow); diff --git a/XlsxSerializerCom/Writer/CSVWriter.cpp b/XlsxSerializerCom/Writer/CSVWriter.cpp index a9225f2df1..5ab96ed485 100644 --- a/XlsxSerializerCom/Writer/CSVWriter.cpp +++ b/XlsxSerializerCom/Writer/CSVWriter.cpp @@ -234,9 +234,8 @@ namespace CSVWriter INT nRowTmp = 0; INT nCol = 0; - if (pCell->isInitRef()) + if (pCell->isInitRef() && pCell->getRowCol(nRowTmp, nCol)) { - pCell->getRowCol(nRowTmp, nCol); nRowTmp++; nCol++; } From 4e337b5ef12d731f3c3c9701b13ff0f5d3c57829 Mon Sep 17 00:00:00 2001 From: ElenaSubbotina Date: Wed, 20 Mar 2019 18:49:38 +0300 Subject: [PATCH 8/8] XlsFormat - fix user file --- .../Logic/Biff_records/ExternSheet.cpp | 9 ++++-- .../XlsFormat/Logic/Biff_records/LineFormat.h | 5 +--- .../XlsFormat/Logic/Biff_unions/AXISPARENT.h | 2 -- .../XlsFormat/Logic/Biff_unions/CHART_bu.cpp | 30 ++++++++++++++++--- .../source/XlsFormat/Logic/Biff_unions/CRT.h | 2 -- .../XlsFormat/Logic/Biff_unions/INTERFACE.cpp | 6 ++-- .../XlsFormat/Logic/Biff_unions/IVAXIS.cpp | 4 +-- .../Logic/Biff_unions/SERIESFORMAT.cpp | 20 +++++++++++-- .../source/XlsFormat/Logic/Biff_unions/SS.cpp | 11 ++++++- .../XlsFormat/Logic/ChartSheetSubstream.cpp | 2 +- .../XlsFormat/Logic/WorksheetSubstream.cpp | 11 +++++-- 11 files changed, 74 insertions(+), 28 deletions(-) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ExternSheet.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ExternSheet.cpp index a10d1922c5..bf08c26b24 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ExternSheet.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/ExternSheet.cpp @@ -58,12 +58,15 @@ void ExternSheet::readFields(CFRecord& record) if (record.getGlobalWorkbookInfo()->Version < 0x0600) { unsigned char type; + unsigned char size; - ShortXLAnsiString stName; - record >> type >> stName; + record >> size >> type; + + LPAnsiStringNoCch stName(size); + record >> stName; name = stName.value(); - //int type = stName.value().substr(0, 1).c_str()[0]; + //if (!name.empty()) // record.getGlobalWorkbookInfo()->arExternalNames.push_back(name); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/LineFormat.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/LineFormat.h index f352cd133e..c16848ae77 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/LineFormat.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_records/LineFormat.h @@ -32,13 +32,11 @@ #pragma once #include "BiffRecord.h" -#include +#include "../Biff_structures/LongRGB.h" namespace XLS { - -// Logical representation of LineFormat record in BIFF8 class LineFormat: public BiffRecord { BIFF_RECORD_DEFINE_TYPE_INFO(LineFormat) @@ -48,7 +46,6 @@ public: ~LineFormat(); BaseObjectPtr clone(); - void readFields(CFRecord& record); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AXISPARENT.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AXISPARENT.h index cf86ec2624..679eb7d395 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AXISPARENT.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/AXISPARENT.h @@ -36,8 +36,6 @@ namespace XLS { - -// Logical representation of AXISPARENT union of records class AXISPARENT: public CompositeObject { BASE_OBJECT_DEFINE_CLASS_NAME(AXISPARENT) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CHART_bu.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CHART_bu.cpp index 4b46c87f9a..c75fb07b9c 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CHART_bu.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CHART_bu.cpp @@ -31,9 +31,12 @@ */ #include "CHART.h" -#include -#include -#include +#include "../ChartSheetSubstream.h" +#include "../Biff_records/BOF.h" +#include "../Biff_records/Continue.h" +#include "../Biff_unions/CELLTABLE.h" +#include "../Biff_structures/CellRangeRef.h" +#include "../Biff_records/EOF.h" namespace XLS { @@ -51,12 +54,17 @@ BaseObjectPtr CHART::clone() const bool CHART::loadContent(BinProcessor& proc) { + GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo(); + unsigned short ss_type; if(!proc.getNextSubstreamType(ss_type) || BOF::st_Chart != ss_type) { return false; } - ChartSheetSubstream chart_sheet(-1); + + size_t tmp_index_table = global_info->sheets_info.size(); //if present table + + ChartSheetSubstream chart_sheet(tmp_index_table); if(!proc.mandatory(chart_sheet)) { return false; @@ -82,6 +90,20 @@ const bool CHART::loadContent(BinProcessor& proc) elements_.pop_back(); count--; } +//chart_sourcedata_missing_import_biff5.xls + if (proc.getGlobalWorkbookInfo()->Version < 0x0600) + { + std::vector shared_formulas_locations; + CELLTABLE cell_table_temlate(shared_formulas_locations); + + if (proc.optional(cell_table_temlate)) + { + //cash table + } + if (proc.optional()) + {//??? + } + } return true; } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CRT.h b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CRT.h index 7cfdb6cc5f..ae96a3c873 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CRT.h +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/CRT.h @@ -36,8 +36,6 @@ namespace XLS { - -// Logical representation of CRT union of records class CRT: public CompositeObject { BASE_OBJECT_DEFINE_CLASS_NAME(CRT) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/INTERFACE.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/INTERFACE.cpp index eb07bc4af1..40aa555916 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/INTERFACE.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/INTERFACE.cpp @@ -31,9 +31,9 @@ */ #include "INTERFACE.h" -#include -#include -#include +#include "../Biff_records/InterfaceHdr.h" +#include "../Biff_records/Mms.h" +#include "../Biff_records/InterfaceEnd.h" namespace XLS { diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/IVAXIS.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/IVAXIS.cpp index 9e00fb2268..82f51781ca 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/IVAXIS.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/IVAXIS.cpp @@ -95,7 +95,7 @@ const bool IVAXIS::loadContent(BinProcessor& proc) elements_.pop_back(); } - if (proc.mandatory()) // 4-th place + if (proc.optional()) // 4-th place { m_AxcExt = elements_.back(); elements_.pop_back(); @@ -109,7 +109,7 @@ const bool IVAXIS::loadContent(BinProcessor& proc) m_CatLab = elements_.back(); elements_.pop_back(); } - if (proc.mandatory()) + if (proc.optional()) { m_AXS = elements_.back(); elements_.pop_back(); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SERIESFORMAT.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SERIESFORMAT.cpp index 1cdb82b5aa..30878b994c 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SERIESFORMAT.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SERIESFORMAT.cpp @@ -134,7 +134,14 @@ const bool SERIESFORMAT::loadContent(BinProcessor& proc) m_Series = elements_.back(); elements_.pop_back(); - proc.mandatory(); elements_.pop_back(); //skip + if (proc.getGlobalWorkbookInfo()->Version < 0x0600) + { + if (proc.optional()) elements_.pop_back(); //skip + } + else + { + if (proc.mandatory()) elements_.pop_back(); //skip + } count = proc.repeated(4, 4); while(count > 0 && elements_.size() > 0) @@ -174,7 +181,7 @@ const bool SERIESFORMAT::loadContent(BinProcessor& proc) count = elements_.size(); while(count > 0) { - if ("SerParent" == elements_.front()->getClassName()) + if ("SerParent" == elements_.front()->getClassName()) m_SerParent = elements_.front(); else if ("SerToCrt" == elements_.front()->getClassName()) m_SerToCrt = elements_.front(); @@ -224,7 +231,14 @@ const bool SERIESFORMAT::loadContent(BinProcessor& proc) m_SeriesEx.push_back(ex); } - if (proc.mandatory()) elements_.pop_back(); //skip + if (proc.getGlobalWorkbookInfo()->Version < 0x0600) + { + if (proc.optional()) elements_.pop_back(); //skip + } + else + { + if (proc.mandatory()) elements_.pop_back(); //skip + } return true; } diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SS.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SS.cpp index 9f649a7686..9d9d409119 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SS.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/Biff_unions/SS.cpp @@ -113,9 +113,18 @@ const bool SS::loadContent(BinProcessor& proc) m_DataFormat = elements_.back(); elements_.pop_back(); - if (proc.mandatory()) + bool bRead = false; + if (proc.getGlobalWorkbookInfo()->Version < 0x0600) { + bRead = true; + } + if (proc.optional()) //при biff5 может быть или нет, biff8 - обязано быть + { + bRead = true; elements_.pop_back(); + } + if (bRead) + { while (true) { CFRecordType::TypeId type = proc.getNextRecordType(); diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp index 47be65b897..f2533b504b 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/ChartSheetSubstream.cpp @@ -143,7 +143,7 @@ const bool ChartSheetSubstream::loadContent(BinProcessor& proc) { CFRecordType::TypeId type = proc.getNextRecordType(); - //Log::warning(CFRecordType::getStringById(type)); + Log::warning(CFRecordType::getStringById(type)); if (type == rt_NONE || type == rt_BOF ) break; if (type == rt_EOF) diff --git a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp index bb477e8739..e64295d213 100644 --- a/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp +++ b/ASCOfficeXlsFile2/source/XlsFormat/Logic/WorksheetSubstream.cpp @@ -243,7 +243,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) if (proc.optional(cell_table_temlate)) { if (m_CELLTABLE) - { + {//Daily Flash Report - Demand_Store_427.xls CELLTABLE *cell_table = dynamic_cast(elements_.back().get()); cell_table->isConcatinate_ = true; } @@ -264,13 +264,18 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) case rt_Obj: case rt_MsoDrawing: { - OBJECTS objects(false); - if (proc.optional(objects)) + OBJECTS objects_template(false); + if (proc.optional(objects_template)) { if (!m_OBJECTS) m_OBJECTS = elements_.back(); else { Log::warning(L"Double set OBJECTS!!!"); + OBJECTS *objects = dynamic_cast(elements_.back().get()); + OBJECTS *prev_objects = dynamic_cast(m_OBJECTS.get()); + + prev_objects->elements_.insert(prev_objects->elements_.end(), objects->elements_.begin(), objects->elements_.end()); + } elements_.pop_back(); }