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

XlsFile2

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63628 954022d7-b5bf-4e40-9824-e11837661b57
parent aa754596
#include "Blank.h"
#include <simple_xml_writer.h>
namespace XLS
......
#include "BoolErr.h"
#include <simple_xml_writer.h>
namespace XLS
{;
extern int cellStyleXfs_count;
BoolErr::BoolErr()
{
......@@ -37,5 +38,25 @@ const CellRef BoolErr::getLocation() const
return cell.getLocation();
}
int BoolErr::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);
if (cell.ixfe.value())
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
}
}
}
return 0;
}
} // namespace XLS
......@@ -25,6 +25,8 @@ public:
static const ElementType type = typeBoolErr;
int serialize(std::wostream & stream);
const CellRef getLocation() const;
//-----------------------------
......
......@@ -34,23 +34,6 @@ public:
BIFF_BOOL fPhonetic;
BIFF_BYTE iOutLevel;
BIFF_BOOL fCollapsed;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(colFirst)
//BO_ATTRIB_MARKUP_ATTRIB(colLast)
//BO_ATTRIB_MARKUP_ATTRIB(coldx)
//BO_ATTRIB_MARKUP_ATTRIB(ixfe)
//BO_ATTRIB_MARKUP_ATTRIB(fHidden)
//BO_ATTRIB_MARKUP_ATTRIB(fUserSet)
//BO_ATTRIB_MARKUP_ATTRIB(fBestFit)
//BO_ATTRIB_MARKUP_ATTRIB(fPhonetic)
//BO_ATTRIB_MARKUP_ATTRIB(iOutLevel)
//BO_ATTRIB_MARKUP_ATTRIB(fCollapsed)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
......@@ -24,11 +24,6 @@ public:
//-----------------------------
BIFF_WORD cchdefColWidth;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(cchdefColWidth)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
......@@ -29,21 +29,6 @@ public:
BIFF_BOOL fExDsc;
BIFF_SHORT miyRw; // measured in twips (1/20 of of a printer's point)
BIFF_SHORT miyRwHidden;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(fUnsynced)
//BO_ATTRIB_MARKUP_ATTRIB(fDyZero)
//BO_ATTRIB_MARKUP_ATTRIB(fExAsc)
//BO_ATTRIB_MARKUP_ATTRIB(fExDsc)
//if(!fDyZero)
//{
// //BO_ATTRIB_MARKUP_ATTRIB(miyRw)
//}
//else
//{
// //BO_ATTRIB_MARKUP_ATTRIB(miyRwHidden)
//}
//BO_ATTRIB_MARKUP_END
};
......
......@@ -25,11 +25,6 @@ public:
//-----------------------------
XLUnicodeString ast;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(ast)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
......@@ -25,11 +25,6 @@ public:
//-----------------------------
BIFF_WORD iLevelRwMac;
BIFF_WORD iLevelColMac;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(iLevelRwMac)
//BO_ATTRIB_MARKUP_ATTRIB(iLevelColMac)
//BO_ATTRIB_MARKUP_END
};
......
......@@ -24,10 +24,6 @@ public:
static const ElementType type = typeHeader;
//-----------------------------
XLUnicodeString ast;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(ast)
//BO_ATTRIB_MARKUP_END
};
......
#include "LabelSst.h"
#include <simple_xml_writer.h>
namespace XLS
{;
extern int cellStyleXfs_count;
LabelSst::LabelSst()
{
......@@ -37,5 +38,24 @@ const CellRef LabelSst::getLocation() const
return cell.getLocation();
}
int LabelSst::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);
if (cell.ixfe.value())
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
}
}
}
return 0;
}
} // namespace XLS
......@@ -22,18 +22,14 @@ public:
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
int serialize(std::wostream & stream);
const CellRef getLocation() const;
//-----------------------------
CellOffsetResender resender;
Cell cell;
BIFF_DWORD isst;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_COMPLEX(resender);
//BO_ATTRIB_MARKUP_COMPLEX(cell);
//BO_ATTRIB_MARKUP_ATTRIB(isst)
//BO_ATTRIB_MARKUP_END
};
......
......@@ -17,14 +17,12 @@ public:
BaseObjectPtr clone();
static const ElementType type = typeLeftMargin;
void writeFields(CFRecord& record);
void readFields(CFRecord& record);
//-----------------------------
BIFF_DOUBLE num;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(num)
//BO_ATTRIB_MARKUP_END
};
......
......@@ -88,7 +88,7 @@ int MulBlank::serialize(std::wostream & stream)
{
int row = GetRow();
for (long i = colFirst; i < colLast; i++)
for (long i = colFirst; i <= colLast; i++)
{
std::wstring ref = getColRowRef(i, row);
CP_XML_NODE(L"c")
......
#include "MulRk.h"
#include <simple_xml_writer.h>
namespace XLS
{;
extern int cellStyleXfs_count;
MulRk::MulRk()
{
......@@ -54,5 +55,29 @@ const long MulRk::GetRow() const
return static_cast<unsigned short>(rw);
}
int MulRk::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
int row = GetRow();
for (long i = 0; i < cells.size(); i++)
{
Cell * cell = dynamic_cast<Cell *>(cells[i].get());
std::wstring ref = cell->getLocation().toString();// getColRowRef(i, row);
CP_XML_NODE(L"c")
{
CP_XML_ATTR(L"r", ref);
if (cell->ixfe.value())
{
CP_XML_ATTR(L"s", *(cell->ixfe.value()) - cellStyleXfs_count);
}
}
}
}
return 0;
}
} // namespace XLS
......@@ -24,16 +24,11 @@ public:
const long GetRow() const;
int serialize(std::wostream & stream);
//-----------------------------
Rw rw;
BiffStructurePtrVector rgrkrec;
BiffStructurePtrVector cells;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_VECTOR_COMPLEX(rgrkrec, RkRec)
//BO_ATTRIB_MARKUP_VECTOR_COMPLEX(cells, Cell)
//BO_ATTRIB_MARKUP_END
};
......
#include "Number.h"
#include <simple_xml_writer.h>
namespace XLS
{;
extern int cellStyleXfs_count;
Number::Number()
{
......@@ -37,5 +38,25 @@ const CellRef Number::getLocation() const
return cell.getLocation();
}
int Number::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);
if (cell.ixfe.value())
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
}
}
}
return 0;
}
} // namespace XLS
......@@ -24,18 +24,15 @@ public:
static const ElementType type = typeNumber;
int serialize(std::wostream & stream);
const CellRef getLocation() const;
//-----------------------------
CellOffsetResender resender;
Cell cell;
BIFF_DOUBLE num;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_COMPLEX(resender)
//BO_ATTRIB_MARKUP_COMPLEX(cell)
//BO_ATTRIB_MARKUP_ATTRIB(num)
//BO_ATTRIB_MARKUP_END
};
......
#include "RK.h"
#include <simple_xml_writer.h>
namespace XLS
{;
extern int cellStyleXfs_count;
RK::RK()
{
......@@ -41,5 +42,24 @@ const CellRef RK::getLocation() const
return cell.getLocation();
}
int RK::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);
if (cell.ixfe.value())
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
}
}
}
return 0;
}
} // namespace XLS
......@@ -24,17 +24,13 @@ public:
static const ElementType type = typeRK;
int serialize(std::wostream & stream);
const CellRef getLocation() const;
//-----------------------------
RkRec rkrec;
Cell cell;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_COMPLEX(rkrec)
//BO_ATTRIB_MARKUP_COMPLEX(cell)
//BO_ATTRIB_MARKUP_END
};
......
......@@ -24,10 +24,6 @@ public:
//-----------------------------
BIFF_DOUBLE num;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(num)
//BO_ATTRIB_MARKUP_END
};
......
......@@ -150,6 +150,8 @@ void CellXF::store(CFRecord& record)
void CellXF::load(CFRecord& record)
{
m_GlobalWorkbookInfo = record.getGlobalWorkbookInfo();
unsigned int flags1;
unsigned int flags2;
unsigned int flags3;
......@@ -170,11 +172,11 @@ void CellXF::load(CFRecord& record)
fAtrPat = GETBIT(flags1, 30);
fAtrProt = GETBIT(flags1, 31);
border.dgLeft = static_cast<unsigned char>(GETBITS(flags2, 0, 3));
border.dgRight = static_cast<unsigned char>(GETBITS(flags2, 4, 7));
border.dgTop = static_cast<unsigned char>(GETBITS(flags2, 8, 11));
border.dgLeft = static_cast<unsigned char>(GETBITS(flags2, 0, 3));
border.dgRight = static_cast<unsigned char>(GETBITS(flags2, 4, 7));
border.dgTop = static_cast<unsigned char>(GETBITS(flags2, 8, 11));
border.dgBottom = static_cast<unsigned char>(GETBITS(flags2, 12, 15));
border.dgDiag = static_cast<unsigned char>(GETBITS(flags3, 21, 24));
border.dgDiag = static_cast<unsigned char>(GETBITS(flags3, 21, 24));
border.icvLeft = 0 != border.dgLeft ? static_cast<unsigned char>(GETBITS(flags2, 16, 22)) : 0;
border.icvRight = 0 != border.dgRight ? static_cast<unsigned char>(GETBITS(flags2, 23, 29)) : 0;
......@@ -184,15 +186,25 @@ void CellXF::load(CFRecord& record)
border.grbitDiag = static_cast<unsigned char>(GETBITS(flags2, 30, 31));
fHasXFExt = GETBIT(flags3, 25);
fill.fls = static_cast<unsigned char>(GETBITS(flags3, 26, 31));
fHasXFExt = GETBIT(flags3, 25);
fill.fls = static_cast<unsigned char>(GETBITS(flags3, 26, 31));
fill.icvFore = GETBITS(flags4, 0, 6);
fill.icvBack = GETBITS(flags4, 7, 13);
fsxButton = GETBIT(flags4, 14);
fill.icvFore = GETBITS(flags4, 0, 6);
fill.icvBack = GETBITS(flags4, 7, 13);
fsxButton = GETBIT(flags4, 14);
}
border_x_id = record.getGlobalWorkbookInfo()->RegisterBorderId(border);
fill_x_id = record.getGlobalWorkbookInfo()->RegisterFillId(fill);
void CellXF::RegisterFillBorder()
{
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
if (ext_props.size() > 0 )
{
}
else
{
}
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
}
int CellXF::serialize(std::wostream & stream)
......
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/BorderFillInfo.h>
#include "BorderFillInfo.h"
#include "ExtProp.h"
namespace XLS
{;
......@@ -18,6 +19,8 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
int serialize(std::wostream & stream);
......@@ -39,6 +42,8 @@ public:
BorderInfo border;
FillInfo fill;
BiffStructurePtrVector ext_props;
bool fHasXFExt;
bool fsxButton;
......@@ -47,6 +52,8 @@ public:
size_t& cell_xf_current_id_;
size_t& style_xf_current_id_;
void RegisterFillBorder();
};
} // namespace XLS
......
......@@ -47,13 +47,6 @@ BiffStructurePtr ExtProp::clone()
//
//}
//
//const bool ExtProp::fromXML(BiffStructurePtr & parent)
//{
//#pragma message("####################### ExtProp record has no BiffStructure::fromXML() implemented")
// Log::error(" Error!!! ExtProp record has no BiffStructure::fromXML() implemented.");
// return false;
//}
void ExtProp::store(CFRecord& record)
{
......
......@@ -59,6 +59,8 @@ void StyleXF::store(CFRecord& record)
void StyleXF::load(CFRecord& record)
{
m_GlobalWorkbookInfo = record.getGlobalWorkbookInfo();
unsigned int flags1;
unsigned int flags2;
unsigned int flags3;
......@@ -90,10 +92,20 @@ void StyleXF::load(CFRecord& record)
fill.icvFore = GETBITS(flags4, 0, 6);
fill.icvBack = GETBITS(flags4, 7, 13);
border_x_id = record.getGlobalWorkbookInfo()->RegisterBorderId(border);
fill_x_id = record.getGlobalWorkbookInfo()->RegisterFillId(fill);
}
void StyleXF::RegisterFillBorder()
{
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
if (ext_props.size() > 0 )
{
}
else
{
}
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
}
int StyleXF::serialize(std::wostream & stream)
{
return 0;
......
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/BorderFillInfo.h>
#include "BorderFillInfo.h"
#include "ExtProp.h"
namespace XLS
{;
......@@ -18,8 +19,11 @@ public:
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
int serialize(std::wostream & stream);
void RegisterFillBorder();
unsigned char alc;
bool fWrap;
......@@ -30,8 +34,10 @@ public:
bool fShrinkToFit;
unsigned char iReadOrder;
BorderInfo border;
FillInfo fill;
BorderInfo border;
FillInfo fill;
BiffStructurePtrVector ext_props;
size_t border_x_id;
size_t fill_x_id;
......
......@@ -7,8 +7,6 @@
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -82,6 +80,7 @@ int CELL_GROUP::serialize(std::wostream & stream)
CP_XML_NODE(L"row")
{
current_row = *row->rw.value();
CP_XML_ATTR(L"r", current_row + 1);
bool xf_set = true;
......@@ -89,12 +88,24 @@ int CELL_GROUP::serialize(std::wostream & stream)
if (row->ixfe_val.value() && xf_set)
{
CP_XML_ATTR(L"s", *row->ixfe_val.value() - cellStyleXfs_count);
CP_XML_ATTR(L"s", row->ixfe_val - cellStyleXfs_count);
CP_XML_ATTR(L"customFormat", true);
}
for (std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start; it_cell != elements_.end(); it_cell++)
if (row->miyRw.value())
{
CP_XML_ATTR(L"ht", row->miyRw / 20.);
CP_XML_ATTR(L"customHeight", true);
}
std::list<XLS::BaseObjectPtr>::iterator it_cell = current_cell_start;
while(true)
{
if (it_cell == elements_.end())
{
current_cell_start = it_cell;
break;
}
CELL * cell = dynamic_cast<CELL *>(it_cell->get());
if (cell == NULL) continue;
......@@ -105,7 +116,7 @@ int CELL_GROUP::serialize(std::wostream & stream)
break;
}
cell->serialize(CP_XML_STREAM());
it_cell++;
}
}
}
......
......@@ -3,9 +3,12 @@
#include <Logic/Biff_records/DefColWidth.h>
#include <Logic/Biff_records/ColInfo.h>
#include <simple_xml_writer.h>
namespace XLS
{;
extern int cellStyleXfs_count;
COLUMNS::COLUMNS()
{
......@@ -26,15 +29,57 @@ BaseObjectPtr COLUMNS::clone()
// COLUMNS = DefColWidth *255ColInfo
const bool COLUMNS::loadContent(BinProcessor& proc)
{
// if(!proc.mandatory<DefColWidth>())
// {
// return false;
// }
bool def_ok = proc.optional<DefColWidth>(); // OpenOffice Calc stored files workaround (DefColWidth is mandatory according to [MS-XLS])
bool def_ok = proc.optional<DefColWidth>();
// OpenOffice Calc stored files workaround (DefColWidth is mandatory according to [MS-XLS])
if (def_ok)
{
m_DefColWidth = elements_.back();
elements_.pop_back();
}
bool col_ok = proc.repeated<ColInfo>(0, 255);
return def_ok || col_ok;
}
int COLUMNS::serialize(std::wostream & stream)
{
if (elements_.size() < 1) return 0;
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"cols")
{
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
ColInfo* column_info = dynamic_cast<ColInfo*>(it->get());
CP_XML_NODE(L"col")
{
if (column_info->coldx.value())
{
CP_XML_ATTR(L"width", column_info->coldx / 256.);
CP_XML_ATTR(L"customWidth", true);
}
if (column_info->colFirst.value())
CP_XML_ATTR(L"min", column_info->colFirst + 1);/// from 0
if (column_info->colLast.value())
CP_XML_ATTR(L"max", column_info->colLast + 1);
if ((column_info->ixfe.value()) && (column_info->ixfe > cellStyleXfs_count))
{
CP_XML_ATTR(L"style", column_info->ixfe - cellStyleXfs_count);
}
}
}
}
}
return 0;
}
} // namespace XLS
......@@ -18,7 +18,11 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & stream);
static const ElementType type = typeCOLUMNS;
BaseObjectPtr m_DefColWidth;
};
} // namespace XLS
......
#include "GLOBALS.h"
#include <Logic/Biff_records/DefColWidth.h>
#include <Logic/Biff_records/Protect.h>
#include <Logic/Biff_records/CalcMode.h>
#include <Logic/Biff_records/CalcCount.h>
......@@ -18,6 +20,8 @@
#include <Logic/Biff_records/HorizontalPageBreaks.h>
#include <Logic/Biff_records/VerticalPageBreaks.h>
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -59,8 +63,19 @@ const bool GLOBALS::loadContent(BinProcessor& proc)
proc.optional<PrintRowCol>();// OpenOffice Calc stored files workaround (PrintRowCol is mandatory according to [MS-XLS])
proc.optional<PrintGrid>();// OpenOffice Calc stored files workaround (PrintGrid is mandatory according to [MS-XLS])
proc.optional<GridSet>();// OpenOffice Calc stored files workaround (GridSet is mandatory according to [MS-XLS])
proc.mandatory<Guts>();
proc.mandatory<DefaultRowHeight>();
if (proc.mandatory<Guts>())
{
m_Guts = elements_.back();
elements_.pop_back();
}
if (proc.mandatory<DefaultRowHeight>())
{
m_DefaultRowHeight = elements_.back();
elements_.pop_back();
}
proc.mandatory(WsBool(is_dialog)); // The most interesting
proc.optional<Sync>();
proc.optional<LPr>();
......@@ -72,5 +87,44 @@ const bool GLOBALS::loadContent(BinProcessor& proc)
return true;
}
int GLOBALS::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"sheetFormatPr")
{
if (m_DefaultRowHeight)
{
DefaultRowHeight* def_row = dynamic_cast<DefaultRowHeight*>(m_DefaultRowHeight.get());
if(!def_row->fDyZero.value() || ((def_row->fDyZero.value()) && (!def_row->fDyZero)))
CP_XML_ATTR(L"defaultRowHeight", def_row->miyRw / 20.);
else
{
CP_XML_ATTR(L"zeroHeight", true);
CP_XML_ATTR(L"defaultRowHeight", def_row->miyRwHidden /20.);
}
if ((def_row->fExAsc.value()) && (def_row->fExAsc)) CP_XML_ATTR(L"thickTop", true);
if ((def_row->fExDsc.value()) && (def_row->fExDsc)) CP_XML_ATTR(L"thickBottom", true);
}
if (m_DefColWidth)
{
DefColWidth* def_col = dynamic_cast<DefColWidth*>(m_DefColWidth.get());
CP_XML_ATTR(L"defaultColWidth", def_col->cchdefColWidth);
}
if (m_Guts)
{
Guts * guts= dynamic_cast<Guts*>(m_Guts.get());
if ((guts->iLevelRwMac.value()) && (guts->iLevelRwMac > 0))
CP_XML_ATTR(L"outlineLevelRow", guts->iLevelRwMac);
if ((guts->iLevelColMac.value()) && (guts->iLevelColMac > 0))
CP_XML_ATTR(L"outlineLevelCol", guts->iLevelColMac);
}
}
}
return 0;
}
} // namespace XLS
......@@ -20,7 +20,13 @@ public:
static const ElementType type = typeGLOBALS;
int serialize(std::wostream & stream);
bool is_dialog;
BaseObjectPtr m_DefColWidth;
BaseObjectPtr m_DefaultRowHeight;
BaseObjectPtr m_Guts;
};
} // namespace XLS
......
......@@ -13,6 +13,8 @@
#include <Logic/Biff_records/Setup.h>
#include <Logic/Biff_records/HeaderFooter.h> // Moved from WorksheetSubstream
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -65,20 +67,88 @@ const bool PAGESETUP::loadContent(BinProcessor& proc)
proc.mandatory<Footer>();
proc.mandatory<HCenter>();
proc.mandatory<VCenter>();
proc.optional<BottomMargin>(); // OpenOffice Calc stored files workaround
proc.optional<TopMargin>(); // OpenOffice Calc stored files workaround
proc.optional<BottomMargin>();// OpenOffice Calc stored files workaround
proc.optional<TopMargin>();// OpenOffice Calc stored files workaround
proc.optional<LeftMargin>();
proc.optional<RightMargin>();
proc.optional<TopMargin>();
proc.optional<BottomMargin>();
proc.optional<Parenthesis_PAGESETUP_1>();
proc.optional(Pls(proc.getParent())); // OpenOffice Calc stored files workaround ?????????
proc.mandatory<Setup>();
proc.optional<HeaderFooter>(); // Moved from WorksheetSubstream
if (proc.mandatory<Setup>())
{
m_Setup = elements_.back();
elements_.pop_back();
}
if (proc.optional<HeaderFooter>())
{
m_HeaderFooter = elements_.back();
elements_.pop_back();
}
return true;
}
int PAGESETUP::serialize(std::wostream & stream)
{
Setup * setup = dynamic_cast<Setup*>(m_Setup.get());
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"pageMargins")
{
if (setup)
{
if (setup->numHdr.value())
CP_XML_ATTR(L"header", setup->numHdr);
if (setup->numFtr.value())
CP_XML_ATTR(L"footer", setup->numFtr);
}
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
bool b = false, t = false; //double set???
switch((*it)->get_type())
{
case typeTopMargin:
if (!t)
{
TopMargin* top = dynamic_cast<TopMargin*>(it->get());
CP_XML_ATTR(L"top", top->num);
t = true;
}break;
case typeBottomMargin:
if (!b)
{
BottomMargin* bottom = dynamic_cast<BottomMargin*>(it->get());
CP_XML_ATTR(L"bottom", bottom->num);
b= true;
}break;
case typeLeftMargin:
{
LeftMargin* left = dynamic_cast<LeftMargin*>(it->get());
CP_XML_ATTR(L"left", left->num);
}break;
case typeRightMargin:
{
RightMargin* right = dynamic_cast<RightMargin*>(it->get());
CP_XML_ATTR(L"right", right->num);
}break;
}
}
}
CP_XML_NODE(L"pageSetup")
{
}
}
return 0;
}
} // namespace XLS
......@@ -18,7 +18,13 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & stream);
static const ElementType type = typePAGESETUP;
BaseObjectPtr m_HeaderFooter;
BaseObjectPtr m_Setup;
};
} // namespace XLS
......
......@@ -4,6 +4,7 @@
#include <Logic/Biff_records/XFCRC.h>
#include <Logic/Biff_records/XFExt.h>
#include <Logic/Biff_structures/ExtProp.h>
#include <simple_xml_writer.h>
namespace XLS
......@@ -38,32 +39,69 @@ const bool XFS::loadContent(BinProcessor& proc)
while (count > 0)
{
// style & complex
XF* xfs = dynamic_cast<XF*>(elements_.back().get());
XF* xfs = dynamic_cast<XF*>(elements_.front().get());
if ((xfs->fStyle.value()) && (*xfs->fStyle.value()))
{
m_cell_styles.insert(m_cell_styles.begin(), elements_.back());
m_cell_styles.push_back(elements_.front());
cellStyleXfs_count++;
}
else
{
m_cell_xfs.insert(m_cell_xfs.begin(), elements_.back());
m_cell_xfs.push_back(elements_.front());
}
elements_.pop_back();
elements_.pop_front();
count--;
}
if(proc.optional<XFCRC>())
{
elements_.pop_back(); // Crc
count = proc.repeated<XFExt>(16, 4050);
while (count > 0)
{
m_xf_ext.insert(m_xf_ext.begin(), elements_.back());
elements_.pop_back();
XFExt* ext = dynamic_cast<XFExt*>(elements_.front().get());
m_xf_ext.push_back(elements_.front());
elements_.pop_front();
count--;
}
}
for (long i = 0 ; i < m_cell_styles.size(); i++)
{
XF *xfs = dynamic_cast<XF*>(m_cell_styles[i].get());
if (m_xf_ext.size() > 0)
{
XFExt *ext = dynamic_cast<XFExt*>(m_xf_ext[i].get());
{
xfs->style.ext_props = ext->rgExt;
}
}
xfs->style.RegisterFillBorder();
}
for (long i = 0 ; i < m_cell_xfs.size(); i++)
{
XF *xfs = dynamic_cast<XF*>(m_cell_xfs[i].get());
if (m_xf_ext.size() > cellStyleXfs_count)
{
XFExt*ext = dynamic_cast<XFExt*>(m_xf_ext[i + cellStyleXfs_count].get());
if (ext)
{
xfs->cell.ext_props = ext->rgExt;
}
}
xfs->cell.RegisterFillBorder();
}
return true;
}
int XFS::serialize(std::wostream & stream)
......
......@@ -25,10 +25,9 @@ public:
size_t cell_xf_current_id;
size_t style_xf_current_id;
std::vector<BaseObjectPtr> m_cell_xfs;
std::vector<BaseObjectPtr> m_cell_styles;
std::vector<BaseObjectPtr> m_xf_ext;
std::vector<BaseObjectPtr> m_cell_xfs;
std::vector<BaseObjectPtr> m_cell_styles;
std::vector<BaseObjectPtr> m_xf_ext;
};
......
......@@ -14,8 +14,9 @@ class GlobalWorkbookInfo
public:
GlobalWorkbookInfo(const unsigned short code_page);
const size_t RegisterBorderId(const BorderInfo& border);
const size_t RegisterFillId(const FillInfo& fill);
const size_t RegisterBorderId (const BorderInfo& border);
const size_t RegisterFillId (const FillInfo& fill);
const unsigned int GenerateAXESId();
unsigned short CodePage;
......
......@@ -80,7 +80,12 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
proc.optional<Uncalced>();
proc.optional<Index>(); // OpenOffice Calc stored files workaround (Index is mandatory according to [MS-XLS])
proc.mandatory(GLOBALS(false)); // not dialog
if (proc.mandatory(GLOBALS(false)))
{
m_GLOBALS = elements_.back();
elements_.pop_back();
}
// OpenOffice Calc stored files workaround (DefColWidth is mandatory and located inside COLUMNS according to [MS-XLS])
if (proc.optional<COLUMNS>())
......@@ -88,8 +93,11 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
m_COLUMNS = elements_.back();
elements_.pop_back();
}
proc.mandatory<PAGESETUP>();
//proc.optional<HeaderFooter>(); // Moved inside PAGESETUP
if (proc.mandatory<PAGESETUP>())
{
m_PAGESETUP = elements_.back();
elements_.pop_back();
}
if (proc.optional<BACKGROUND>())
{
......@@ -181,11 +189,6 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
return true;
}
//void WorksheetSubstream::toXML(MSXML2::IXMLDOMElementPtr own_tag)
//{
// static std::wstring index_name("index");
// own_tag->setAttribute(index_name, ws_index_);
//}
} // namespace XLS
......@@ -26,6 +26,8 @@ public:
std::vector<BaseObjectPtr> m_MergeCells;
BaseObjectPtr m_GLOBALS;
BaseObjectPtr m_PAGESETUP;
BaseObjectPtr m_BACKGROUND;
BaseObjectPtr m_COLUMNS;
BaseObjectPtr m_CELLTABLE;
......
......@@ -12,14 +12,10 @@
#include "../XlsFormat/Logic/Biff_unions/FORMATTING.h"
#include "../XlsFormat/Logic/Biff_unions/THEME.h"
#include "../XlsFormat/Logic/Biff_unions/GLOBALS.h"
#include "../XlsFormat/Logic/Biff_unions/COLUMNS.h"
//#include "../XlsFormat/Binary/CFStreamCacheWriter.h"
//#include "../XlsFormat/Logic/BaseObject.h"
//#include "../XlsFormat/Binary/BinSmartPointers.h"
//#include "../XlsFormat\Auxiliary\HelpersTagsGenerator.h"
#include "xlsx_conversion_context.h"
#include "xlsx_package.h"
......@@ -189,6 +185,17 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
{
sheet->m_Dimensions->serialize(xlsx_context->current_sheet().dimension());
}
if (sheet->m_GLOBALS)
{
XLS::GLOBALS * globals = dynamic_cast<XLS::GLOBALS *>(sheet->m_GLOBALS.get());
XLS::COLUMNS * columns = dynamic_cast<XLS::COLUMNS *>(sheet->m_COLUMNS.get());
if (globals && columns)
{
globals->m_DefColWidth = columns->m_DefColWidth;
}
sheet->m_GLOBALS->serialize(xlsx_context->current_sheet().sheetFormat());
}
if (sheet->m_COLUMNS)
{
sheet->m_COLUMNS->serialize(xlsx_context->current_sheet().cols());
......@@ -210,6 +217,10 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
}
}
}
if (sheet->m_PAGESETUP)
{
sheet->m_PAGESETUP->serialize(xlsx_context->current_sheet().pageProperties());
}
}
void XlsConverter::convert(XLS::GlobalsSubstream* global)
......
......@@ -22,6 +22,7 @@ public:
std::wstringstream comments_;
std::wstringstream dimension_;
std::wstringstream sheetViews_;
std::wstringstream pageProperties_;
rels hyperlinks_rels_;
......@@ -85,6 +86,10 @@ std::wostream & xlsx_xml_worksheet::drawing()
{
return impl_->drawing_;
}
std::wostream & xlsx_xml_worksheet::pageProperties()
{
return impl_->pageProperties_;
}
std::wostream & xlsx_xml_worksheet::comments()
{
return impl_->comments_;
......@@ -141,6 +146,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
}
}
CP_XML_STREAM() << impl_->pageProperties_.str();
//CP_XML_NODE(L"headerFooter){}
//CP_XML_NODE(L"rowBreaks){}
......
......@@ -31,6 +31,7 @@ public:
std::wostream & mergeCells();
std::wostream & drawing();
std::wostream & comments();
std::wostream & pageProperties();
rels & hyperlinks_rels();
......
......@@ -109,10 +109,11 @@
Optimization="0"
AdditionalIncludeDirectories="..\XlsFormat; ..\Common"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
ProgramDataBaseFileName="$(IntDir)\XlsFormat.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
......
......@@ -113,6 +113,7 @@
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
ProgramDataBaseFileName="$(IntDir)\XlsXlsxConverter.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
......
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