Commit af81688a authored by ElenaSubbotina's avatar ElenaSubbotina Committed by Alexander Trofimov

XlsFormat - правка багов (файлы с com-сервера)

parent e5f9ea50
...@@ -28,16 +28,16 @@ int _tmain(int argc, _TCHAR* argv[]) ...@@ -28,16 +28,16 @@ int _tmain(int argc, _TCHAR* argv[])
hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password1", L"C:\\Windows\\Fonts", NULL); hr = ConvertXls2Xlsx(srcFileName, dstTempPath, L"password1", L"C:\\Windows\\Fonts", NULL);
if (hr != S_OK) return hr; if (hr == S_OK)
{
COfficeUtils oCOfficeUtils(NULL); COfficeUtils oCOfficeUtils(NULL);
if (S_OK != oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), -1)) hr = oCOfficeUtils.CompressFileOrDirectory(dstTempPath.c_str(), dstPath.c_str(), -1);
return hr; }
FileSystem::Directory::DeleteDirectory(dstTempPath); FileSystem::Directory::DeleteDirectory(dstTempPath);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
std::cout << "\n\nTime : " << t1.elapsed() << "\n"; std::cout << "\n\nTime : " << t1.elapsed() << "\n";
return 0;
return 0; return hr;
} }
...@@ -371,6 +371,7 @@ CFRecordTypeValues[] = ...@@ -371,6 +371,7 @@ CFRecordTypeValues[] =
{"GelFrame", rt_GelFrame}, {"GelFrame", rt_GelFrame},
{"BopPopCustom", rt_BopPopCustom}, {"BopPopCustom", rt_BopPopCustom},
{"Fbi2", rt_Fbi2}, {"Fbi2", rt_Fbi2},
{"CommentText", rt_CommentText},
{"ANY_TYPE", rt_ANY_TYPE} {"ANY_TYPE", rt_ANY_TYPE}
}; };
......
...@@ -230,6 +230,7 @@ typedef enum CF_RECORD_TYPE ...@@ -230,6 +230,7 @@ typedef enum CF_RECORD_TYPE
rt_DefaultRowHeight = 0x0225, rt_DefaultRowHeight = 0x0225,
rt_Table = 0x0236, rt_Table = 0x0236,
rt_Window2 = 0x023e, rt_Window2 = 0x023e,
rt_CommentText = 0x027d,//??
rt_RK = 0x027e, rt_RK = 0x027e,
rt_Style = 0x0293, rt_Style = 0x0293,
rt_BigName = 0x0418, rt_BigName = 0x0418,
......
...@@ -34,13 +34,13 @@ void CFStream::read(void* buf, const size_t size) ...@@ -34,13 +34,13 @@ void CFStream::read(void* buf, const size_t size)
{ {
if(NULL == buf || stream_ == NULL) if(NULL == buf || stream_ == NULL)
{ {
throw;// EXCEPT::RT::CompoundFileFormatError("Wrong buffer pointer (NULL)"); return;//throw;EXCEPT::RT::CompoundFileFormatError("Wrong buffer pointer (NULL)");
} }
POLE::uint64 num_read = stream_->read((unsigned char*)buf, size); POLE::uint64 num_read = stream_->read((unsigned char*)buf, size);
if(num_read < size) if(num_read < size)
{ {
throw;// EXCEPT::RT::EndOfStreamReached(stream_->fullName(), num_read, size); return;//throw; EXCEPT::RT::EndOfStreamReached(stream_->fullName(), num_read, size);
} }
// Tipa successful // Tipa successful
} }
......
...@@ -61,6 +61,10 @@ CFStreamPtr CompoundFile::getWorkbookStream() ...@@ -61,6 +61,10 @@ CFStreamPtr CompoundFile::getWorkbookStream()
if (stream == NULL) if (stream == NULL)
stream = getNamedStream("Book"); stream = getNamedStream("Book");
if (stream == NULL)
stream = getNamedStream("BOOK");//file(6).xls
if (stream == NULL)
stream = getNamedStream("book");
return stream; return stream;
} }
......
#include "BoundSheet8.h" #include "BoundSheet8.h"
//#include <Exception/AttributeDataWrong.h> #include <boost/lexical_cast.hpp>
namespace XLS namespace XLS
{ {
...@@ -85,6 +86,10 @@ void BoundSheet8::readFields(CFRecord& record) ...@@ -85,6 +86,10 @@ void BoundSheet8::readFields(CFRecord& record)
name_ = name_.substr(0, 31); name_ = name_.substr(0, 31);
//cell_links_broken.xls //cell_links_broken.xls
} }
if (name_.empty())
{//file(6).xls
name_ = L"Sheet_" + boost::lexical_cast<std::wstring>(record.getGlobalWorkbookInfo()->current_sheet + 1);
}
record.getGlobalWorkbookInfo()->sheets_names.push_back(name_); record.getGlobalWorkbookInfo()->sheets_names.push_back(name_);
record.getGlobalWorkbookInfo()->sheets_state.push_back(hsState); record.getGlobalWorkbookInfo()->sheets_state.push_back(hsState);
......
#include "ExternSheet.h" #include "ExternSheet.h"
#include <Logic/Biff_structures/XTI.h> #include <Logic/Biff_structures/XTI.h>
#include <Logic/Biff_structures/BiffString.h>
namespace XLS namespace XLS
{ {
...@@ -36,7 +37,16 @@ void ExternSheet::readFields(CFRecord& record) ...@@ -36,7 +37,16 @@ void ExternSheet::readFields(CFRecord& record)
{ {
if (record.getGlobalWorkbookInfo()->Version < 0x0600) if (record.getGlobalWorkbookInfo()->Version < 0x0600)
{ {
record.skipNunBytes(record.getDataSize() - record.getRdPtr()); unsigned char type;
//record.skipNunBytes(record.getDataSize() - record.getRdPtr());
ShortXLAnsiString stName;
record >> type >> stName;
std::wstring name = stName.value();
//int type = stName.value().substr(0, 1).c_str()[0];
if (!name.empty())
record.getGlobalWorkbookInfo()->arExternalNames.push_back(name);
} }
else else
{ {
......
...@@ -76,6 +76,87 @@ int Label::serialize(std::wostream & stream) ...@@ -76,6 +76,87 @@ int Label::serialize(std::wostream & stream)
} }
return 0; return 0;
} }
//----------------------------------------------------------------
CommentText::CommentText()
{
isst_ = -1;
}
CommentText::~CommentText()
{
}
BaseObjectPtr CommentText::clone()
{
return BaseObjectPtr(new CommentText(*this));
}
void CommentText::writeFields(CFRecord& record)
{
global_info_ = record.getGlobalWorkbookInfo();
record << cell << st;
}
void CommentText::readFields(CFRecord& record)
{
global_info_ = record.getGlobalWorkbookInfo();
//record >> cell;
Rw row;
Col col;
XLUnicodeString stText;
unsigned short flags;
record >> row >> col;
if (global_info_->Version < 0x0600)
{
LPAnsiString stText1;
record >> stText1;
stText = stText1;
}
else
{
}
isst_ = global_info_->startAddedSharedStrings + global_info_->arAddedSharedStrings.size() ;
global_info_->arAddedSharedStrings.push_back(st.value());
}
int CommentText::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
int row = cell.rw;
std::wstring ref = cell.getLocation().toString();// getColRowRef(i, row);
CP_XML_NODE(L"c")
{
CP_XML_ATTR(L"r", ref);
int st = (int)cell.ixfe - global_info_->cellStyleXfs_count;
if (cell.ixfe > global_info_->cellStyleXfs_count)
{
CP_XML_ATTR(L"s", cell.ixfe - global_info_->cellStyleXfs_count);
}
CP_XML_ATTR(L"t", L"s");
CP_XML_NODE(L"v")
{
CP_XML_STREAM() << isst_;
}
}
}
return 0;
}
} // namespace XLS } // namespace XLS
...@@ -34,5 +34,31 @@ public: ...@@ -34,5 +34,31 @@ public:
int isst_; int isst_;
}; };
class CommentText: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(CommentText)
BASE_OBJECT_DEFINE_CLASS_NAME(CommentText)
public:
CommentText();
~CommentText();
BaseObjectPtr clone();
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
int serialize(std::wostream & stream);
static const ElementType type = typeLabel;
Cell cell;
XLUnicodeString st;
//-----------------------------
GlobalWorkbookInfoPtr global_info_;
int isst_;
};
} // namespace XLS } // namespace XLS
...@@ -16,7 +16,6 @@ public: ...@@ -16,7 +16,6 @@ public:
AF12Criteria(); AF12Criteria();
~AF12Criteria(); ~AF12Criteria();
virtual void load(CFRecord& record); virtual void load(CFRecord& record);
virtual void store(CFRecord& record); virtual void store(CFRecord& record);
...@@ -25,7 +24,7 @@ public: ...@@ -25,7 +24,7 @@ public:
AFDOper doper; AFDOper doper;
XLUnicodeStringNoCch str; XLUnicodeStringNoCch str;
BIFF_BSTR _str; std::wstring _str;
}; };
typedef boost::shared_ptr<AF12Criteria> AF12CriteriaPtr; typedef boost::shared_ptr<AF12Criteria> AF12CriteriaPtr;
......
...@@ -195,7 +195,7 @@ int AUTOFILTER::serialize(std::wostream & stream) ...@@ -195,7 +195,7 @@ int AUTOFILTER::serialize(std::wostream & stream)
CP_XML_NODE(L"filter") CP_XML_NODE(L"filter")
{ {
CP_XML_ATTR(L"val", *af12Criteria->_str.value()); CP_XML_ATTR(L"val", af12Criteria->_str);
} }
} }
} }
......
...@@ -63,7 +63,12 @@ const bool PAGESETUP::loadContent(BinProcessor& proc) ...@@ -63,7 +63,12 @@ const bool PAGESETUP::loadContent(BinProcessor& proc)
{ {
CFRecordType::TypeId type = proc.getNextRecordType(); CFRecordType::TypeId type = proc.getNextRecordType();
if (type == rt_NONE) break; if (type == rt_NONE)
{
proc.SkipRecord();
continue; //file(6).xls
//break;
}
switch(type) switch(type)
{ {
......
...@@ -47,14 +47,15 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -47,14 +47,15 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
{ {
bool to_continue = true; bool to_continue = true;
unsigned short substream_type;
bool GlobalsSubstream_found = false; bool GlobalsSubstream_found = false;
bool WorksheetSubstream_found = false; bool WorksheetSubstream_found = false;
size_t ws_index = 0; size_t ws_index = 0;
// Find all substreams in this stream // Find all substreams in this stream
while(proc.getNextSubstreamType(substream_type)) while(to_continue)
{ {
unsigned short substream_type = 0;
to_continue = proc.getNextSubstreamType(substream_type);
switch(substream_type) switch(substream_type)
{ {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <Logic/Biff_records/EOF.h> #include <Logic/Biff_records/EOF.h>
#include <Logic/Biff_records/BOF.h> #include <Logic/Biff_records/BOF.h>
#include <Logic/Biff_records/DefaultRowHeight.h> #include <Logic/Biff_records/DefaultRowHeight.h>
#include <Logic/Biff_records/Label.h>
#include <Logic/Biff_unions/BACKGROUND.h> #include <Logic/Biff_unions/BACKGROUND.h>
#include <Logic/Biff_unions/BIGNAME.h> #include <Logic/Biff_unions/BIGNAME.h>
...@@ -185,9 +186,10 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -185,9 +186,10 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
elements_.pop_back(); elements_.pop_back();
} }
}break; }break;
case rt_Label://file(6).xls
case rt_Row: case rt_Row:
{ {
CELLTABLE cell_table(shared_formulas_locations); CELLTABLE cell_table(shared_formulas_locations);
if (proc.optional(cell_table)) if (proc.optional(cell_table))
{ {
m_CELLTABLE = elements_.back(); m_CELLTABLE = elements_.back();
...@@ -219,6 +221,18 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -219,6 +221,18 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
} }
}break; }break;
case rt_HFPicture: proc.repeated<HFPicture>(0, 0); break; case rt_HFPicture: proc.repeated<HFPicture>(0, 0); break;
case rt_CommentText:
{
count = proc.repeated<CommentText>(0, 0);
while(count > 0)
{
m_arNote.insert(m_arNote.begin(), elements_.back());
elements_.pop_back();
count--;
}
}break;
case rt_Note: case rt_Note:
{ {
count = proc.repeated<Note>(0, 0); count = proc.repeated<Note>(0, 0);
......
...@@ -49,6 +49,7 @@ public: ...@@ -49,6 +49,7 @@ public:
std::vector<BaseObjectPtr> m_arNote; std::vector<BaseObjectPtr> m_arNote;
std::vector<BaseObjectPtr> m_arHLINK; std::vector<BaseObjectPtr> m_arHLINK;
std::vector<BaseObjectPtr> m_arSORT; std::vector<BaseObjectPtr> m_arSORT;
std::vector<BaseObjectPtr> m_arLabel;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -383,7 +383,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet) ...@@ -383,7 +383,7 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
{ {
for (int i = 0 ; i < sheet->m_arNote.size(); i++) for (int i = 0 ; i < sheet->m_arNote.size(); i++)
{ {
convert((XLS::Note*)sheet->m_arNote[i].get()); convert(dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get()));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment