Commit eb542da4 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFile2

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63586 954022d7-b5bf-4e40-9824-e11837661b57
parent c72a3f91
......@@ -2,6 +2,8 @@
#include "Dimensions.h"
#include <Logic/Biff_structures/CellRangeRef.h>
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -47,9 +49,10 @@ void Dimensions::readFields(CFRecord& record)
{
record >> rwMic >> rwMac >> colMic >> colMac;
record.skipNunBytes(2); // reserved
if(rwMac && colMac)
if(rwMac.value() && colMac.value())
{
ref_ = static_cast<std::wstring >(CellRangeRef(CellRef(rwMic, colMic, true, true), CellRef(rwMac - 1, colMac - 1, true, true)).toString(false).c_str());
ref_ = static_cast<std::wstring >(CellRangeRef(CellRef(*rwMic.value(), *colMic.value(), true, true), CellRef(*rwMac.value() - 1, *colMac.value() - 1, true, true)).toString(false).c_str());
}
else
{
......@@ -57,5 +60,18 @@ void Dimensions::readFields(CFRecord& record)
}
}
int Dimensions::serialize(std::wostream & stream)
{
if (ref_.empty()) return 0;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"dimension")
{
CP_XML_ATTR(L"ref", ref_);
}
}
return 0;
}
} // namespace XLS
......@@ -22,22 +22,15 @@ public:
static const ElementType type = typeDimensions;
int serialize(std::wostream & stream);
std::wstring ref_;
//-----------------------------
RwLongU rwMic;
BIFF_DWORD rwMac;
ColU colMic;
BIFF_WORD colMac;
BIFF_BSTR ref_;
public:
//BO_ATTRIB_MARKUP_BEGIN
/*
//BO_ATTRIB_MARKUP_ATTRIB_NAME(rwMic.rw, L"rwMic");
//BO_ATTRIB_MARKUP_ATTRIB(rwMac);
//BO_ATTRIB_MARKUP_ATTRIB_NAME(colMic.col, L"colMic");
//BO_ATTRIB_MARKUP_ATTRIB(colMac);
*/
//BO_ATTRIB_MARKUP_ATTRIB_NAME(ref_, L"ref");
//BO_ATTRIB_MARKUP_END
};
......
#include "precompiled_xls.h"
#include "MergeCells.h"
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -41,5 +43,11 @@ void MergeCells::readFields(CFRecord& record)
}
}
int MergeCells::serialize(std::wostream & stream)
{
return 0;
}
} // namespace XLS
......@@ -23,14 +23,11 @@ public:
static const ElementType type = typeMergeCells;
int serialize(std::wostream & stream);
//-----------------------------
BIFF_WORD cmcs;
BiffStructurePtrVector rgref;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(cmcs)
//BO_ATTRIB_MARKUP_VECTOR_COMPLEX(rgref, Ref8)
//BO_ATTRIB_MARKUP_END
};
......
#include "precompiled_xls.h"
#include "Row.h"
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -70,5 +72,16 @@ void Row::readFields(CFRecord& record)
fPhonetic = GETBIT(flags, 14);
}
int Row::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"row")
{
}
}
return 0;
}
} // namespace XLS
......@@ -22,6 +22,8 @@ public:
static const ElementType type = typeRow;
int serialize(std::wostream & stream);
//-----------------------------
Rw rw;
BackwardOnlyParam<unsigned short> colMic;
......
......@@ -5,27 +5,19 @@
#include <Logic/Biff_unions/CELL.h>
#include <Logic/Biff_records/DBCell.h>
#include <simple_xml_writer.h>
namespace XLS
{;
CELLTABLE::CELLTABLE(std::vector<CellRef>& shared_formulas_locations_ref) : shared_formulas_locations_ref_(shared_formulas_locations_ref)
{
}
CELLTABLE::~CELLTABLE()
{
}
// 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)
public:
CELL_GROUP(std::vector<CellRef>& shared_formulas_locations_ref) : shared_formulas_locations_ref_(shared_formulas_locations_ref) {}
CELL_GROUP(std::vector<CellRef>& shared_formulas_locations_ref) : m_rowCount(0),
shared_formulas_locations_ref_(shared_formulas_locations_ref) {}
BaseObjectPtr clone()
{
......@@ -38,18 +30,57 @@ public:
{
return false;
}
proc.repeated<Row>(0, 0);
proc.repeated(CELL(shared_formulas_locations_ref_), 0, 0);
proc.repeated<DBCell>(0, 0); // OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS])
m_rowCount = proc.repeated<Row>(0, 0);
//------------------------------------------------------------------------------------------------------------------
int count = proc.repeated(CELL(shared_formulas_locations_ref_), 0, 0);
while(count > 0)
{
m_CELL_formulas_locations_ref.insert(m_CELL_formulas_locations_ref.begin(), elements_.back());
elements_.pop_back();
count--;
}
count = proc.repeated<DBCell>(0, 0); // OpenOffice Calc stored files workaround (DBCell must be present at least once according to [MS-XLS])
while(count > 0)
{
m_DBCells.insert(m_DBCells.begin(), elements_.back());
elements_.pop_back();
count--;
}
return true;
};
int serialize(std::wostream & stream);
static const ElementType type = typeCELL_GROUP;
std::vector<BaseObjectPtr> m_CELL_formulas_locations_ref;
std::vector<BaseObjectPtr> m_DBCells;
long m_rowCount;
private:
std::vector<CellRef>& shared_formulas_locations_ref_;
};
int CELL_GROUP::serialize(std::wostream & stream)
{
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
it->get()->serialize(stream);
}
return 0;
}
//-----------------------------------------------------------------------------------------------------------------
CELLTABLE::CELLTABLE(std::vector<CellRef>& shared_formulas_locations_ref) : m_count_CELL_GROUP(0),
shared_formulas_locations_ref_(shared_formulas_locations_ref)
{
}
CELLTABLE::~CELLTABLE()
{
}
BaseObjectPtr CELLTABLE::clone()
{
......@@ -64,11 +95,21 @@ const bool CELLTABLE::loadContent(BinProcessor& proc)
{
return false;
}
proc.repeated(CELL_GROUP(shared_formulas_locations_ref_), 0, 0);
m_count_CELL_GROUP = proc.repeated(CELL_GROUP(shared_formulas_locations_ref_), 0, 0);
proc.repeated<EntExU2>(0, 0);
return true;
}
int CELLTABLE::serialize(std::wostream & stream)
{
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
it->get()->serialize(stream);
}
return 0;
}
} // namespace XLS
......@@ -20,8 +20,12 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeCELLTABLE;
private:
int serialize(std::wostream & stream);
std::vector<CellRef>& shared_formulas_locations_ref_;
long m_count_CELL_GROUP;
};
} // namespace XLS
......
......@@ -92,7 +92,7 @@ const bool FORMATTING::loadContent(BinProcessor& proc)
int FORMATTING::serialize1(std::wostream & stream)
{
CP_XML_WRITER(stream)
CP_XML_WRITER(stream)
{
if (m_Formats.size() > 0)
{
......
......@@ -71,33 +71,71 @@ WORKSHEET = BOF WORKSHEETCONTENT
*/
const bool WorksheetSubstream::loadContent(BinProcessor& proc)
{
int count = 0;
if(!proc.mandatory<BOF>())
{
return false;
}
proc.optional<Uncalced>();
proc.optional<Index>(); // OpenOffice Calc stored files workaround (Index is mandatory according to [MS-XLS])
proc.optional<Index>(); // OpenOffice Calc stored files workaround (Index is mandatory according to [MS-XLS])
proc.mandatory(GLOBALS(false)); // not dialog
proc.optional<COLUMNS>(); // OpenOffice Calc stored files workaround (DefColWidth is mandatory and located inside COLUMNS according to [MS-XLS])
// OpenOffice Calc stored files workaround (DefColWidth is mandatory and located inside COLUMNS according to [MS-XLS])
if (proc.optional<COLUMNS>())
{
m_COLUMNS = elements_.back();
elements_.pop_back();
}
proc.mandatory<PAGESETUP>();
//proc.optional<HeaderFooter>(); // Moved inside PAGESETUP
proc.optional<BACKGROUND>();
if (proc.optional<BACKGROUND>())
{
m_BACKGROUND = elements_.back();
elements_.pop_back();
}
proc.repeated<BIGNAME>(0, 0);
proc.optional<PROTECTION_COMMON>();
proc.optional<COLUMNS>();
if (proc.optional<COLUMNS>())
{
if (!m_COLUMNS)
{
m_COLUMNS = elements_.back();
elements_.pop_back();
}
}
proc.optional<SCENARIOS>();
proc.optional<SORTANDFILTER>(); // Let it be optional
proc.mandatory<Dimensions>();
if (proc.mandatory<Dimensions>())
{
m_Dimensions = elements_.back();
elements_.pop_back();
}
std::vector<CellRef> shared_formulas_locations;
proc.optional(CELLTABLE(shared_formulas_locations));
std::vector<CellRef> shared_formulas_locations;
if (proc.optional(CELLTABLE(shared_formulas_locations)))
{
m_CELLTABLE = elements_.back();
elements_.pop_back();
}
if(0 != shared_formulas_locations.size())
{
proc.optional(SHFMLA_SET(shared_formulas_locations));
if (proc.optional(SHFMLA_SET(shared_formulas_locations)))
{
m_SHFMLA_SET = elements_.back();
elements_.pop_back();
}
}
proc.optional(OBJECTS(false)); // Let it be optional
proc.repeated<HFPicture>(0, 0);
proc.repeated<Note>(0, 0);
proc.repeated<PIVOTVIEW>(0, 0);
......@@ -106,12 +144,26 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
proc.repeated<CUSTOMVIEW>(0, 0);
proc.repeated<SORT>(0, 2);
proc.optional<DxGCol>();
proc.repeated<MergeCells>(0, 0);
count = proc.repeated<MergeCells>(0, 0);
while(count > 0)
{
m_MergeCells.insert(m_MergeCells.begin(), elements_.back());
elements_.pop_back();
count--;
}
proc.optional<LRng>();
proc.repeated<QUERYTABLE>(0, 0);
proc.optional<PHONETICINFO>();
proc.optional<CONDFMTS>(); // Let it be optional
proc.repeated<HLINK>(0, 0);
if (proc.repeated<HLINK>(0, 0))
{
m_HLINK = elements_.back();
elements_.pop_back();
}
proc.optional<DVAL>();
proc.optional<CodeName>();
proc.repeated<WebPub>(0, 0);
......
......@@ -20,11 +20,18 @@ public:
BaseObjectPtr clone();
virtual const bool loadContent(BinProcessor& proc);
//virtual void toXML(MSXML2::IXMLDOMElementPtr own_tag);
static const ElementType type = typeWorksheetSubstream;
private:
size_t ws_index_;
size_t ws_index_;
std::vector<BaseObjectPtr> m_MergeCells;
BaseObjectPtr m_BACKGROUND;
BaseObjectPtr m_COLUMNS;
BaseObjectPtr m_CELLTABLE;
BaseObjectPtr m_SHFMLA_SET;
BaseObjectPtr m_Dimensions;
BaseObjectPtr m_HLINK;
};
} // namespace XLS
......
......@@ -185,7 +185,31 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
{
if (sheet == NULL) return;
if (sheet->m_Dimensions)
{
sheet->m_Dimensions->serialize(xlsx_context->current_sheet().dimension());
}
if (sheet->m_COLUMNS)
{
sheet->m_COLUMNS->serialize(xlsx_context->current_sheet().cols());
}
if (sheet->m_CELLTABLE)
{
sheet->m_CELLTABLE->serialize(xlsx_context->current_sheet().sheetData());
}
if (sheet->m_MergeCells.size() > 0)
{
CP_XML_WRITER(xlsx_context->current_sheet().mergeCells())
{
CP_XML_NODE(L"mergeCells")
{
for (long i = 0 ; i < sheet->m_MergeCells.size(); i++)
{
sheet->m_MergeCells[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
void XlsConverter::convert(XLS::GlobalsSubstream* global)
......@@ -213,7 +237,6 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
{
if (formating == NULL) return;
std::wstringstream strm;
CP_XML_WRITER(strm)
{
......
......@@ -14,12 +14,14 @@ public:
std::wstring name_;
std::wstringstream cols_;
std::wstringstream sheetFormat_;
std::wstringstream sheetFormatPr_;
std::wstringstream sheetData_;
std::wstringstream mergeCells_;
std::wstringstream drawing_;
std::wstringstream hyperlinks_;
std::wstringstream comments_;
std::wstringstream dimension_;
std::wstringstream sheetViews_;
rels hyperlinks_rels_;
......@@ -56,9 +58,17 @@ std::wostream & xlsx_xml_worksheet::cols()
{
return impl_->cols_;
}
std::wostream & xlsx_xml_worksheet::dimension()
{
return impl_->dimension_;
}
std::wostream & xlsx_xml_worksheet::sheetViews()
{
return impl_->sheetViews_;
}
std::wostream & xlsx_xml_worksheet::sheetFormat()
{
return impl_->sheetFormat_;
return impl_->sheetFormatPr_;
}
std::wostream & xlsx_xml_worksheet::sheetData()
......@@ -99,7 +109,9 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_ATTR(L"mc:Ignorable", L"x14ac");
CP_XML_ATTR(L"xmlns:x14ac", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
CP_XML_STREAM() << impl_->sheetFormat_.str();
CP_XML_STREAM() << impl_->dimension_.str();
CP_XML_STREAM() << impl_->sheetViews_.str();
CP_XML_STREAM() << impl_->sheetFormatPr_.str();
CP_XML_STREAM() << impl_->cols_.str();
......
......@@ -22,6 +22,8 @@ public:
public:
std::wstring name() const;
std::wostream & dimension();
std::wostream & sheetViews();
std::wostream & cols();
std::wostream & sheetFormat();
std::wostream & sheetData();
......
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