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

XlsFile2 - расширение стилей, буковки и цыферки, застиленные ес-но

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63653 954022d7-b5bf-4e40-9824-e11837661b57
parent 0d7992ff
......@@ -48,9 +48,9 @@ int Blank::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"r", ref);
if (cell.ixfe.value())
if ((cell.ixfe.value()) && (cell.ixfe > cellStyleXfs_count))
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
CP_XML_ATTR(L"s", cell.ixfe - cellStyleXfs_count);
}
}
}
......
......@@ -21,14 +21,6 @@ public:
void readFields(CFRecord& record);
static const ElementType type = typeContinue;
//-----------------------------
// BIFF_WORD userName;
public:
//BO_ATTRIB_MARKUP_BEGIN
// //BO_ATTRIB_MARKUP_ATTRIB(userName)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
#include "LabelSst.h"
#include <simple_xml_writer.h>
namespace XLS
......@@ -49,9 +50,19 @@ int LabelSst::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"r", ref);
if (cell.ixfe.value())
if ((cell.ixfe.value()) && (cell.ixfe > cellStyleXfs_count))
{
CP_XML_ATTR(L"s", cell.ixfe - cellStyleXfs_count);
}
CP_XML_ATTR(L"t", L"s");
if (isst.value())
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
CP_XML_NODE(L"v")
{
CP_XML_STREAM() << isst;
}
}
}
}
......
......@@ -95,11 +95,11 @@ int MulBlank::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"r", ref);
if (rgixfe.common_ixfe > 0)
if ((rgixfe.common_ixfe > 0) && (rgixfe.common_ixfe > cellStyleXfs_count))
{
CP_XML_ATTR(L"s", rgixfe.common_ixfe - cellStyleXfs_count);
}
else if( i < rgixfe.rgixfe.size())
else if(( i < rgixfe.rgixfe.size()) && (rgixfe.rgixfe[i] > cellStyleXfs_count))
{
CP_XML_ATTR(L"s", rgixfe.rgixfe[i] - cellStyleXfs_count);
}
......
#include "Number.h"
#include <Auxiliary/HelpFunc.h>
#include <simple_xml_writer.h>
namespace XLS
......@@ -49,9 +50,16 @@ int Number::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"r", ref);
if (cell.ixfe.value())
if ((cell.ixfe.value()) && (cell.ixfe > cellStyleXfs_count))
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
CP_XML_ATTR(L"s", cell.ixfe - cellStyleXfs_count);
}
if (num.value())
{
CP_XML_NODE(L"v")
{
CP_XML_STREAM() << STR::double2str(num);
}
}
}
}
......
......@@ -53,9 +53,13 @@ int RK::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"r", ref);
if (cell.ixfe.value())
if ((cell.ixfe.value()) && (cell.ixfe > cellStyleXfs_count))
{
CP_XML_ATTR(L"s", *cell.ixfe.value() - cellStyleXfs_count);
CP_XML_ATTR(L"s", cell.ixfe - cellStyleXfs_count);
}
CP_XML_NODE(L"v")
{
CP_XML_STREAM() << rkrec.RK_.value();
}
}
}
......
#include "SST.h"
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -74,5 +75,31 @@ void SST::readFields(CFRecord& record)
}
}
int SST::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"sst")
{
CP_XML_ATTR(L"uniqueCount", rgb.size());
CP_XML_ATTR(L"xmlns", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
for (long i=0; i < rgb.size(); i++)
{
CP_XML_NODE(L"si")
{
CP_XML_NODE(L"t")
{
XLUnicodeRichExtendedString *richText = dynamic_cast<XLUnicodeRichExtendedString *>(rgb[i].get());
CP_XML_STREAM() << richText->str_;
}
}
}
}
}
return 0;
}
} // namespace XLS
......@@ -23,6 +23,8 @@ public:
static const ElementType type = typeSST;
int serialize(std::wostream & stream);
//-----------------------------
BIFF_LONG cstTotal;
BIFF_LONG cstUnique;
......@@ -31,14 +33,6 @@ public:
//-----------------------------
unsigned short code_page_;
public:
//BO_ATTRIB_MARKUP_BEGIN
//BO_ATTRIB_MARKUP_ATTRIB(cstTotal)
//BO_ATTRIB_MARKUP_ATTRIB(cstUnique)
//proc.markVector(rgb, XLUnicodeRichExtendedString(continue_records[rt_Continue]));
////BO_ATTRIB_MARKUP_VECTOR_COMPLEX(rgb, XLUnicodeRichExtendedString)
//BO_ATTRIB_MARKUP_END
};
} // namespace XLS
......
......@@ -81,7 +81,7 @@ int XF::serialize(std::wostream & stream)
if (ifmt.value())
{
CP_XML_ATTR(L"numFmtIs" , *ifmt.value());
CP_XML_ATTR(L"numFmtId" , *ifmt.value());
}
if(fStyle)
......
......@@ -3,7 +3,7 @@
#include "../../../Common/DocxFormat/Source/Base/Types_32.h"
#include "BiffStructure.h"
#include "BiffAttribute.h"
//#include <Exception/WrongBiffRecord.h>
#include <Auxiliary/HelpFunc.h>
#include "Boolean.h"
#pragma pack(1)
......@@ -75,6 +75,18 @@ struct RkNumber : public BiffStructure_NoVtbl
return fX100 ? toDouble() / 100.0 : toDouble();
}
}
std::wstring value()
{
if(fInt)
{
//return fX100 ? num / 100 : num;
return fX100 ? STR::double2str(num / 100.0) : STR::int2wstr(num);
}
else
{
return STR::double2str( fX100 ? toDouble() / 100.0 : toDouble() );
}
}
private:
const double toDouble() const
{
......
#include "BorderFillInfo.h"
#include <Auxiliary/HelpFunc.h>
#include <boost/functional/hash/hash.hpp>
#include <simple_xml_writer.h>
......@@ -86,13 +87,48 @@ int FillInfo::serialize(std::wostream & stream)
{
CP_XML_NODE(L"fgColor")
{
//if (icvFore < 65 )
if (foreFillInfo_.enabled)
{
switch(foreFillInfo_.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_ATTR(L"indexed", foreFillInfo_.icv); break;
case 2://rgb
CP_XML_ATTR(L"rgb", STR::toARGB(foreFillInfo_.xclrValue)); break;
case 3://theme color
CP_XML_ATTR(L"theme", foreFillInfo_.xclrValue + 1);
CP_XML_ATTR(L"tint", foreFillInfo_.nTintShade / 32767.0); break;
case 4://not set
break;
}
}else
CP_XML_ATTR(L"indexed", icvFore);
}
CP_XML_NODE(L"bgColor")
{
//if (icvBack < 65 )
if (backFillInfo_.enabled)
{
switch(backFillInfo_.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_ATTR(L"indexed", backFillInfo_.icv); break;
case 2://rgb
CP_XML_ATTR(L"rgb", STR::toARGB(backFillInfo_.xclrValue)); break;
case 3://theme color
CP_XML_ATTR(L"theme", backFillInfo_.xclrValue + 1);
CP_XML_ATTR(L"tint", backFillInfo_.nTintShade / 32767.0); break;
case 4://not set
break;
}
}
else
CP_XML_ATTR(L"indexed", icvBack);
}
}
}
......
......@@ -5,6 +5,17 @@
namespace XLS
{;
struct FillInfoExt
{
FillInfoExt() {enabled = false; xclrType = icv = 0; nTintShade = 0; xclrValue = 0;}
bool enabled;
unsigned char xclrType;
unsigned char icv;
short nTintShade;
unsigned int xclrValue;
};
struct FillInfo
{
FillInfo(){}
......@@ -31,6 +42,13 @@ struct FillInfo
friend std::size_t hash_value(FillInfo const & val);
int serialize(std::wostream & stream);
//additional ( , )
FillInfoExt foreFillInfo_;
FillInfoExt backFillInfo_;
};
struct BorderInfo
......
#include "CellXF.h"
#include "ExtProp.h"
#include <Binary/CFRecord.h>
#include <simple_xml_writer.h>
......@@ -19,89 +20,6 @@ BiffStructurePtr CellXF::clone()
return BiffStructurePtr(new CellXF(*this));
}
//void CellXF::setXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// xml_tag->setAttribute(L"alc", alc);
// xml_tag->setAttribute(L"fWrap", fWrap);
// xml_tag->setAttribute(L"alcV", alcV);
// xml_tag->setAttribute(L"fJustLast", fJustLast);
// xml_tag->setAttribute(L"trot", trot);
// xml_tag->setAttribute(L"cIndent", cIndent);
// xml_tag->setAttribute(L"fShrinkToFit", fShrinkToFit);
// xml_tag->setAttribute(L"iReadOrder", iReadOrder);
// xml_tag->setAttribute(L"fAtrNum", fAtrNum);
// xml_tag->setAttribute(L"fAtrFnt", fAtrFnt);
// xml_tag->setAttribute(L"fAtrAlc", fAtrAlc);
// xml_tag->setAttribute(L"fAtrBdr", fAtrBdr);
// xml_tag->setAttribute(L"fAtrPat", fAtrPat);
// xml_tag->setAttribute(L"fAtrProt", fAtrProt);
//
// xml_tag->setAttribute(L"dgLeft", border.dgLeft);
// xml_tag->setAttribute(L"dgRight", border.dgRight);
// xml_tag->setAttribute(L"dgTop", border.dgTop);
// xml_tag->setAttribute(L"dgBottom", border.dgBottom);
// xml_tag->setAttribute(L"icvLeft", border.icvLeft);
// xml_tag->setAttribute(L"icvRight", border.icvRight);
// xml_tag->setAttribute(L"grbitDiag", border.grbitDiag);
//
// xml_tag->setAttribute(L"icvTop", border.icvTop);
// xml_tag->setAttribute(L"icvBottom", border.icvBottom);
// xml_tag->setAttribute(L"icvDiag", border.icvDiag);
// xml_tag->setAttribute(L"dgDiag", border.dgDiag);
// xml_tag->setAttribute(L"fHasXFExt", fHasXFExt);
// xml_tag->setAttribute(L"fls", fill.fls);
//
// xml_tag->setAttribute(L"icvFore", fill.icvFore);
// xml_tag->setAttribute(L"icvBack", fill.icvBack);
// xml_tag->setAttribute(L"fsxButton", fsxButton);
//
// xml_tag->setAttribute(L"xf_current_id", cell_xf_current_id_ + style_xf_current_id_);
// xml_tag->setAttribute(L"cell_xf_current_id", cell_xf_current_id_++);
//
// xml_tag->setAttribute(L"border_x_id", border_x_id);
// xml_tag->setAttribute(L"fill_x_id", fill_x_id);
//}
//
//
//void CellXF::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// alc = getStructAttribute(xml_tag, L"alc");
// fWrap = getStructAttribute(xml_tag, L"fWrap");
// alcV = getStructAttribute(xml_tag, L"alcV");
// fJustLast = getStructAttribute(xml_tag, L"fJustLast");
// trot = getStructAttribute(xml_tag, L"trot");
// cIndent = getStructAttribute(xml_tag, L"cIndent");
// fShrinkToFit = getStructAttribute(xml_tag, L"fShrinkToFit");
// iReadOrder = getStructAttribute(xml_tag, L"iReadOrder");
// fAtrNum = getStructAttribute(xml_tag, L"fAtrNum");
// fAtrFnt = getStructAttribute(xml_tag, L"fAtrFnt");
// fAtrAlc = getStructAttribute(xml_tag, L"fAtrAlc");
// fAtrBdr = getStructAttribute(xml_tag, L"fAtrBdr");
// fAtrPat = getStructAttribute(xml_tag, L"fAtrPat");
// fAtrProt = getStructAttribute(xml_tag, L"fAtrProt");
//
// border.dgLeft = getStructAttribute(xml_tag, L"dgLeft");
// border.dgRight = getStructAttribute(xml_tag, L"dgRight");
// border.dgTop = getStructAttribute(xml_tag, L"dgTop");
// border.dgBottom = getStructAttribute(xml_tag, L"dgBottom");
// border.icvLeft = getStructAttribute(xml_tag, L"icvLeft");
// border.icvRight = getStructAttribute(xml_tag, L"icvRight");
// border.grbitDiag = getStructAttribute(xml_tag, L"grbitDiag");
//
// border.icvTop = getStructAttribute(xml_tag, L"icvTop");
// border.icvBottom = getStructAttribute(xml_tag, L"icvBottom");
// border.icvDiag = getStructAttribute(xml_tag, L"icvDiag");
// border.dgDiag = getStructAttribute(xml_tag, L"dgDiag");
// fHasXFExt = getStructAttribute(xml_tag, L"fHasXFExt");
// fill.fls = getStructAttribute(xml_tag, L"fls");
//
// fill.icvFore = getStructAttribute(xml_tag, L"icvFore");
// fill.icvBack = getStructAttribute(xml_tag, L"icvBack");
// fsxButton = getStructAttribute(xml_tag, L"fsxButton");
//}
//
//
void CellXF::store(CFRecord& record)
{
unsigned int flags = 0;
......@@ -196,14 +114,49 @@ void CellXF::load(CFRecord& record)
void CellXF::RegisterFillBorder()
{
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
if (ext_props.size() > 0 )
for (long i = 0; i < ext_props.size(); i++ )
{
}
else
{
}
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x0007:
//case 0x0008:
//case 0x0009:
//case 0x000A:
//case 0x000B:
//case 0x000C:
//case 0x000D:
// extPropData.color.toXML(own_tag);
// break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
//case 0x000E:
// own_tag->Puttext(STR::int2str(extPropData.font_scheme, 10).c_str());
// break;
//case 0x000F:
// own_tag->Puttext(STR::int2str(extPropData.indent_level, 10).c_str());
// break;
}
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
}
......
......@@ -2,12 +2,13 @@
#include "BiffStructure.h"
#include "BorderFillInfo.h"
#include "ExtProp.h"
namespace XLS
{;
class CFRecord;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
class CellXF : public BiffStructure
{
......
......@@ -12,42 +12,6 @@ BiffStructurePtr ExtProp::clone()
return BiffStructurePtr(new ExtProp(*this));
}
//void ExtProp::toXML(BiffStructurePtr & parent)
//{
// MSXML2::IXMLDOMElementPtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
// own_tag->setAttribute(L"extType", extType);
// own_tag->setAttribute(L"cb", cb);
//
// switch(extType)
// {
// case 0x0004:
// case 0x0005:
// case 0x0007:
// case 0x0008:
// case 0x0009:
// case 0x000A:
// case 0x000B:
// case 0x000C:
// case 0x000D:
// extPropData.color.toXML(own_tag);
// break;
// case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
// case 0x000E:
// own_tag->Puttext(STR::int2str(extPropData.font_scheme, 10).c_str());
// break;
// case 0x000F:
// own_tag->Puttext(STR::int2str(extPropData.indent_level, 10).c_str());
// break;
// default:
// break;
// }
//
//}
//
void ExtProp::store(CFRecord& record)
{
#pragma message("####################### ExtProp record has no BiffStructure::store() implemented")
......
......@@ -15,14 +15,12 @@ class ExtProp : public BiffStructure
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent);
//virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
private:
unsigned short extType;
unsigned short cb;
struct extPropData_Tag
{
FullColorExt color;
......
......@@ -11,27 +11,6 @@ BiffStructurePtr FullColorExt::clone()
return BiffStructurePtr(new FullColorExt(*this));
}
//
//void FullColorExt::toXML(BiffStructurePtr & parent)
//{
// MSXML2::IXMLDOMElementPtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
// own_tag->setAttribute(L"xclrType", xclrType);
// own_tag->setAttribute(L"numTint", static_cast<double>(nTintShade) / 32767.0); // universal names for any color providing structures
// own_tag->setAttribute(L"xclrValue", xclrValue);
// if(2 == xclrType) // if the type is ARGB
// {
// own_tag->setAttribute(L"argb", STR::toARGB(xclrValue).c_str());
// }
//}
//const bool FullColorExt::fromXML(BiffStructurePtr & parent)
//{
//#pragma message("####################### FullColorExt record has no BiffStructure::fromXML() implemented")
// Log::error(" Error!!! FullColorExt record has no BiffStructure::fromXML() implemented.");
// return false;
//}
void FullColorExt::store(CFRecord& record)
{
#pragma message("####################### FullColorExt record has no BiffStructure::store() implemented")
......@@ -42,7 +21,7 @@ void FullColorExt::store(CFRecord& record)
void FullColorExt::load(CFRecord& record)
{
record >> xclrType >> nTintShade >> xclrValue;
record >> xclrType >> icv >> nTintShade >> xclrValue;
record.skipNunBytes(8); //unused
}
......
......@@ -13,15 +13,13 @@ class FullColorExt : public BiffStructure
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent);
//virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
private:
unsigned short xclrType;
short nTintShade;
unsigned int xclrValue;
unsigned char icv;
unsigned char xclrType;
short nTintShade;
unsigned int xclrValue;
};
} // namespace XLS
......@@ -11,30 +11,6 @@ BiffStructurePtr GradStop::clone()
return BiffStructurePtr(new GradStop(*this));
}
//
//void GradStop::toXML(BiffStructurePtr & parent)
//{
// MSXML2::IXMLDOMElementPtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
// own_tag->setAttribute(L"xclrType", xclrType);
// if(2 == xclrType)
// {
// xclrValue_rgb.toXML(own_tag);
// }
// else
// {
// own_tag->setAttribute(L"xclrValue", xclrValue);
// }
// own_tag->setAttribute(L"numPosition", numPosition);
// own_tag->setAttribute(L"numTint", numTint);
//}
//
//const bool GradStop::fromXML(BiffStructurePtr & parent)
//{
//#pragma message("####################### GradStop record has no BiffStructure::fromXML() implemented")
// Log::error(" Error!!! GradStop record has no BiffStructure::fromXML() implemented.");
// return false;
//}
void GradStop::store(CFRecord& record)
{
......
......@@ -14,12 +14,9 @@ class GradStop : public BiffStructure
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent);
//virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
private:
unsigned short xclrType;
unsigned int xclrValue;
LongRGBA xclrValue_rgb;
......
......@@ -4,30 +4,13 @@
namespace XLS
{;
extern int cellStyleXfs_count;
BiffStructurePtr RkRec::clone()
{
return BiffStructurePtr(new RkRec(*this));
}
//
//void RkRec::toXML(BiffStructurePtr & parent)
//{
// MSXML2::IXMLDOMElementPtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
//
// own_tag->setAttribute(L"RK", RK_);
//}
//
//
//const bool RkRec::fromXML(BiffStructurePtr & parent)
//{
//#pragma message("####################### RkRec record has no BiffStructure::fromXML() implemented")
// Log::error(" Error!!! RkRec record has no BiffStructure::fromXML() implemented.");
// return false;
//}
void RkRec::store(CFRecord& record)
{
record << ixfe << RK_;
......
......@@ -14,13 +14,11 @@ class RkRec : public BiffStructure
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent);
//virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
const unsigned short get_ixfe() const;
public:
unsigned short ixfe;
RkNumber RK_;
};
......
#include "StyleXF.h"
#include "ExtProp.h"
#include <Binary/CFRecord.h>
#include <simple_xml_writer.h>
......@@ -96,15 +97,53 @@ void StyleXF::load(CFRecord& record)
void StyleXF::RegisterFillBorder()
{
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
if (ext_props.size() > 0 )
{
}
else
for (long i = 0; i < ext_props.size(); i++ )
{
}
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
switch(ext_prop->extType)
{
case 0x0004:
{
fill.foreFillInfo_.enabled = true;
fill.foreFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.foreFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.foreFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.foreFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0005:
{
fill.backFillInfo_.enabled = true;
fill.backFillInfo_.icv = ext_prop->extPropData.color.icv;
fill.backFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
fill.backFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
fill.backFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x0007:
//case 0x0008:
//case 0x0009:
//case 0x000A:
//case 0x000B:
//case 0x000C:
//case 0x000D:
// extPropData.color.toXML(own_tag);
// break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
//case 0x000E:
// own_tag->Puttext(STR::int2str(extPropData.font_scheme, 10).c_str());
// break;
//case 0x000F:
// own_tag->Puttext(STR::int2str(extPropData.indent_level, 10).c_str());
// break;
}
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
}
int StyleXF::serialize(std::wostream & stream)
{
......
......@@ -2,12 +2,13 @@
#include "BiffStructure.h"
#include "BorderFillInfo.h"
#include "ExtProp.h"
namespace XLS
{;
class CFRecord;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
class StyleXF : public BiffStructure
{
......@@ -25,14 +26,14 @@ public:
void RegisterFillBorder();
unsigned char alc;
bool fWrap;
unsigned char alcV;
bool fJustLast;
unsigned char trot;
unsigned char cIndent;
bool fShrinkToFit;
unsigned char iReadOrder;
unsigned char alc;
bool fWrap;
unsigned char alcV;
bool fJustLast;
unsigned char trot;
unsigned char cIndent;
bool fShrinkToFit;
unsigned char iReadOrder;
BorderInfo border;
FillInfo fill;
......
......@@ -9,23 +9,18 @@ namespace XLS
class CFRecord;
//#pragma pack(1)
class XFExtGradient : public BiffStructure
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(XFExtGradient)
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent);
//virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
private:
XFPropGradient gradient;
unsigned int cGradStops;
std::vector<GradStop> rgGradStops;
XFPropGradient gradient;
unsigned int cGradStops;
std::vector<GradStop> rgGradStops;
};
//#pragma pack() // restore
} // namespace XLS
......@@ -11,26 +11,6 @@ BiffStructurePtr XFPropGradient::clone()
return BiffStructurePtr(new XFPropGradient(*this));
}
//void XFPropGradient::toXML(BiffStructurePtr & parent)
//{
// MSXML2::IXMLDOMElementPtr own_tag = XMLSTUFF::createElement(getClassName(), parent);
// own_tag->setAttribute(L"type", type);
// own_tag->setAttribute(L"numDegree", numDegree);
// own_tag->setAttribute(L"numFillToLeft", numFillToLeft);
// own_tag->setAttribute(L"numFillToRight", numFillToRight);
// own_tag->setAttribute(L"numFillToTop", numFillToTop);
// own_tag->setAttribute(L"numFillToBottom", numFillToBottom);
//}
//const bool XFPropGradient::fromXML(BiffStructurePtr & parent)
//{
//#pragma message("####################### XFPropGradient record has no BiffStructure::fromXML() implemented")
// Log::error(" Error!!! XFPropGradient record has no BiffStructure::fromXML() implemented.");
// return false;
//}
void XFPropGradient::store(CFRecord& record)
{
#pragma message("####################### XFPropGradient record has no BiffStructure::store() implemented")
......
......@@ -13,13 +13,9 @@ class XFPropGradient : public BiffStructure
BASE_STRUCTURE_DEFINE_CLASS_NAME(XFPropGradient)
public:
BiffStructurePtr clone();
//virtual void toXML(BiffStructurePtr & parent);
//virtual const bool fromXML(BiffStructurePtr & parent);
virtual void load(CFRecord& record);
virtual void store(CFRecord& record);
private:
Boolean<unsigned int> type;
double numDegree;
double numFillToLeft;
......
......@@ -30,16 +30,16 @@ public:
const size_t getNonVariablePartSize() const;
const size_t getFullSize() const;
//private:
// Append data of the next Continue record if exists and remove it from the list
const bool appendNextContinue(CFRecord& record, const bool read_high_byte);
private:
std::wstring str_;
bool fHighByte;
bool fExtSt;
bool fRichSt;
std::vector<FormatRun> rgRun;
ExtRst extRst;
std::list<CFRecordPtr>& cont_recs_;
bool mark_set_start;
......
......@@ -3,6 +3,8 @@
#include <Logic/Biff_records/SST.h>
#include <Logic/Biff_records/Continue.h>
#include <simple_xml_writer.h>
namespace XLS
{;
......@@ -35,5 +37,15 @@ const bool SHAREDSTRINGS::loadContent(BinProcessor& proc)
return true;
}
int SHAREDSTRINGS::serialize(std::wostream & stream)
{
for (std::list<XLS::BaseObjectPtr>::iterator it = elements_.begin(); it != elements_.end(); it++)
{
(*it)->serialize(stream);
}
return 0;
}
} // namespace XLS
......@@ -20,6 +20,7 @@ public:
static const ElementType type = typeSHAREDSTRINGS;
int serialize(std::wostream & stream);
unsigned short code_page_;
};
......
......@@ -175,7 +175,13 @@ const bool GlobalsSubstream::loadContent(BinProcessor& proc)
proc.optional<RecalcId>();
proc.repeated<HFPicture>(0, 0); /////
proc.repeated(MSODRAWINGGROUP(false), 0, 0);
proc.optional(SHAREDSTRINGS(code_page_));
if (proc.optional(SHAREDSTRINGS(code_page_)))
{
m_SHAREDSTRINGS = elements_.back();
elements_.pop_back();
}
proc.optional<ExtSST>(); // OpenOffice Calc stored files workaround (ExtSST is mandatory according to [MS-XLS])
proc.repeated<WebPub>(0, 0);
proc.optional<WOpt>();
......
......@@ -28,6 +28,7 @@ public:
BaseObjectPtr m_Theme;
BaseObjectPtr m_Formating;
BaseObjectPtr m_Template;
BaseObjectPtr m_SHAREDSTRINGS;
unsigned short code_page_;
};
......
......@@ -14,6 +14,7 @@
#include "../XlsFormat/Logic/Biff_unions/THEME.h"
#include "../XlsFormat/Logic/Biff_unions/GLOBALS.h"
#include "../XlsFormat/Logic/Biff_unions/COLUMNS.h"
#include "../XlsFormat/Logic/Biff_unions/SHAREDSTRINGS.h"
#include "xlsx_conversion_context.h"
......@@ -151,7 +152,7 @@ void XlsConverter::convert(XLS::BaseObject *xls_unknown)
{
for (std::list<XLS::BaseObjectPtr>::iterator it = xls_unknown->elements_.begin(); it != xls_unknown->elements_.end(); it++)
{
it->get()->serialize(xlsx_context->current_stream());
(*it)->serialize(xlsx_context->current_stream());
}
}
}
......@@ -230,16 +231,8 @@ void XlsConverter::convert(XLS::GlobalsSubstream* global)
convert((XLS::THEME*)global->m_Theme.get());
convert((XLS::SHAREDSTRINGS*)global->m_SHAREDSTRINGS.get());
}
template<class T>
struct map_data_compare : public std::binary_function<typename T::value_type,typename T::mapped_type,bool>
{
public:
bool operator() (typename T::value_type &pair,typename T::mapped_type i)
{
return pair.second == i;
}
};
typedef boost::unordered_map<XLS::FillInfo, int> mapFillInfo;
typedef boost::unordered_map<XLS::BorderInfo, int> mapBorderInfo;
......@@ -301,4 +294,14 @@ void XlsConverter::convert(XLS::FORMATTING* formating)
void XlsConverter::convert(XLS::THEME* theme)
{
if (theme == NULL) return;
}
void XlsConverter::convert(XLS::SHAREDSTRINGS* sharedstrings)
{
if (sharedstrings == NULL) return;
for (std::list<XLS::BaseObjectPtr>::iterator it = sharedstrings->elements_.begin(); it != sharedstrings->elements_.end(); it++)
{
(*it)->serialize(xlsx_context->shared_strings());
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ namespace XLS
class FORMATTING;
class THEME;
class SHAREDSTRINGS;
}
......@@ -58,6 +59,7 @@ private:
void convert(XLS::GlobalsSubstream * elem);
void convert(XLS::FORMATTING * formating);
void convert(XLS::THEME * theme);
void convert(XLS::SHAREDSTRINGS * sharedstrings);
};
......@@ -228,10 +228,8 @@ void xlsx_conversion_context::end_document()
//}
//workbook_content << L"<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.0001\" />";
{
std::wstringstream strm;
xlsx_text_context_.write_shared_strings(strm);
output_document_->get_xl_files().set_sharedStrings( package::simple_element::create(L"sharedStrings.xml", strm.str()) );
{
output_document_->get_xl_files().set_sharedStrings( package::simple_element::create(L"sharedStrings.xml", xlsx_shared_strings_.str()) );
}
......
......@@ -28,6 +28,7 @@ public:
void end_document();
std::wostream & current_stream();
std::wostream & shared_strings() {return xlsx_shared_strings_;}
// void start_chart(std::wstring const & name);
......@@ -124,6 +125,8 @@ private:
//xlsx_defined_names xlsx_defined_names_;
xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_;
std::wstringstream xlsx_shared_strings_;
//xlsx_drawing_context_handle xlsx_drawing_context_handle_;
//xlsx_comments_context_handle xlsx_comments_context_handle_;
......
#include <vector>
#include <boost/foreach.hpp>
#include "utils.h"
#include "xlsx_sharedstrings.h"
namespace oox {
class xlsx_shared_strings::Impl
{
public:
void xlsx_serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content);
private:
std::vector<std::wstring> strings_;
};
void xlsx_shared_strings::Impl::xlsx_serialize(std::wostream & _Wostream) const
{
_Wostream << L"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"" <<
strings_.size() << "\" uniqueCount=\"" << strings_.size() << "\">";
BOOST_FOREACH(const std::wstring & str, strings_)
{
_Wostream << L"<si>";
_Wostream << str;
_Wostream << L"</si>";
}
_Wostream << L"</sst>";
}
size_t xlsx_shared_strings::Impl::add(const std::wstring & content)
{
strings_.push_back(content);
return strings_.size() - 1;
}
xlsx_shared_strings::xlsx_shared_strings(): impl_( new xlsx_shared_strings::Impl() )
{
}
xlsx_shared_strings::~xlsx_shared_strings()
{
}
void xlsx_shared_strings::xlsx_serialize(std::wostream & _Wostream) const
{
return impl_->xlsx_serialize(_Wostream);
}
size_t xlsx_shared_strings::add(const std::wstring & content)
{
return impl_->add(content);
}
}
#pragma once
#include <string>
#include <iosfwd>
#include <boost/scoped_ptr.hpp>
namespace oox {
class xlsx_shared_strings: boost::noncopyable
{
public:
xlsx_shared_strings();
~xlsx_shared_strings();
public:
void xlsx_serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content);
private:
class Impl;
boost::scoped_ptr<Impl> impl_;
};
}
......@@ -45,8 +45,7 @@ public:
void start_drawing_content();
std::wstring end_drawing_content();
void write_shared_strings(std::wostream & strm);
void ApplyTextProperties();
void set_local_styles_container();//это если стили объектов содержатся в другом документе
......@@ -76,17 +75,12 @@ private:
std::wstringstream text_;
std::wstringstream output_;
xlsx_shared_strings xlsx_shared_strings_;
std::wstring paragraph_style_name_;//был вектор ... не нужен, так как в один момент времени может быть тока один стиль параграфа,текста,объекта при приходе нового - дампится
std::wstring span_style_name_;
};
void xlsx_text_context::Impl::write_shared_strings(std::wostream & strm)
{
xlsx_shared_strings_.xlsx_serialize(strm);
}
xlsx_text_context::Impl::Impl(): paragraphs_cout_(0),
......@@ -341,7 +335,7 @@ int xlsx_text_context::Impl::end_cell_content()
{
dump_text();
const int sharedStrId = output_.str().empty() ? (-1) : static_cast<int>(xlsx_shared_strings_.add(output_.str()));
const int sharedStrId = 0;//output_.str().empty() ? (-1) : static_cast<int>(xlsx_shared_strings_.add(output_.str()));
//???? нужно ли здесь очищать все ????? - проверить стили на кучках - и проверить как меняются стили внутри одной ячейки - то есть здешнее переопределение внешнего стиля
in_cell_content = false;
return sharedStrId;
......@@ -436,10 +430,6 @@ std::wstring xlsx_text_context::end_drawing_content()
{
return impl_->end_drawing_content();
}
void xlsx_text_context::write_shared_strings(std::wostream & strm)
{
return impl_->write_shared_strings(strm);
}
}
......@@ -42,8 +42,6 @@ public:
void add_text(const std::wstring & text);
void write_shared_strings(std::wostream & strm);
bool is_drawing_context();
private:
......
......@@ -372,14 +372,6 @@
RelativePath="..\XlsXlsxConverter\xlsx_package.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_sharedstrings.cpp"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_sharedstrings.h"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_tablecontext.cpp"
>
......
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