Commit dcec7447 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - apply theme style from format office 2010 and later

parent 5f12552f
......@@ -138,30 +138,13 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstr
}
else
CP_XML_ATTR(L"i", false);
//if (bCharSet.value())
//{
// CP_XML_NODE(L"charset")
// {
// CP_XML_ATTR(L"val", bCharSet);
// }
//}
//if ((fCondense.value()) && (*fCondense.value()))
//{
// CP_XML_NODE(L"condense")
// {
// CP_XML_ATTR(L"val", (int)(*fCondense.value()));
// }
//}
//if ((fExtend.value()) && (fExtend))
// {
// CP_XML_NODE(L"extend")
// {
// CP_XML_ATTR(L"val", fExtend);
// }
// }
switch(sss)
{
case 1: CP_XML_ATTR(L"cap", L"all");break;
case 2: CP_XML_ATTR(L"cap", L"small");break;
}
if ( (icv < 0x7fff) || color_ext.enabled )
{
if (color_ext.enabled )
......@@ -236,66 +219,7 @@ int Font::serialize_rPr(std::wostream & stream, bool rtl, bool defRPr, std::wstr
{
CP_XML_NODE(namespace_ + L"rtl");
}
//if ((fOutline.value()) && (fOutline))
// {
// CP_XML_NODE(L"outline")
// {
// CP_XML_ATTR(L"val", fOutline);
// }
// }
//if (font.scheme)
//{
// CP_XML_NODE(L"scheme")
// {
// CP_XML_ATTR(L"val", *font.scheme);
// }
//}
//if ((fShadow.value()) && (fShadow))
// {
// CP_XML_NODE(L"shadow")
// {
// CP_XML_ATTR(L"val", fShadow);
// }
// }
//if ((fStrikeOut.value()) && (fStrikeOut))
//{
// CP_XML_NODE(L"strike")
// {
// CP_XML_ATTR(L"val", fStrikeOut);
// }
//}
// if ((uls.value()) && (*uls.value() > 0))
// {
// CP_XML_NODE(L"u")
// {
//switch(uls)
//{
// case 1: CP_XML_ATTR(L"val", "single");break;
// case 2: CP_XML_ATTR(L"val", "double");break;
// case 33: CP_XML_ATTR(L"val", "singleAccounting");break;
// case 34: CP_XML_ATTR(L"val", "doubleAccounting");break;
//}
// }
// }
// if ((sss.value()) && (*sss.value() > 0))
// {
// CP_XML_NODE(L"vertAlign")
// {
//switch(*sss.value())
//{
// case 1: CP_XML_ATTR(L"val", L"superscript");break;
// case 2: CP_XML_ATTR(L"val", L"subscript");break;
//}
//
// }
// }
}
}
return 0;
......
......@@ -32,7 +32,7 @@
#include "TxO.h"
#include <Logic/Biff_records/Font.h>
#include "Font.h"
#include <utils.h>
......
......@@ -35,11 +35,10 @@
namespace XLS
{
XF::XF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell(cell_xf_current_id, style_xf_current_id),
style(cell_xf_current_id, style_xf_current_id),
ixfParent(0)
XF::XF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell (cell_xf_current_id, style_xf_current_id),
style(cell_xf_current_id, style_xf_current_id)
{
ixfParent = 0;
}
......
......@@ -32,15 +32,12 @@
#pragma once
#include "BiffRecord.h"
#include <Logic/Biff_structures/FontIndex.h>
#include <Logic/Biff_structures/CellXF.h>
#include <Logic/Biff_structures/StyleXF.h>
#include "../Biff_structures/FontIndex.h"
#include "../Biff_structures/CellXF.h"
#include "../Biff_structures/StyleXF.h"
namespace XLS
{
// Logical representation of XF record in BIFF8
class XF: public BiffRecord
{
BIFF_RECORD_DEFINE_TYPE_INFO(XF)
......
......@@ -38,13 +38,12 @@ namespace XLS
struct FillInfoExt
{
FillInfoExt() {enabled = false; xclrType = icv = 0; nTintShade = 0; xclrValue = 0;}
bool enabled;
bool enabled =false;
unsigned char xclrType;
unsigned char icv;
short nTintShade;
unsigned int xclrValue;
unsigned char xclrType = 0;
unsigned char icv = 0;
short nTintShade = 0;
unsigned int xclrValue = 0;
};
struct FillInfo
......@@ -56,9 +55,9 @@ struct FillInfo
{
}
unsigned char fls;
unsigned char icvFore;
unsigned char icvBack;
unsigned char fls = 0;
unsigned char icvFore = 0;
unsigned char icvBack = 0;
bool operator < (const FillInfo& right) const
{
......@@ -84,17 +83,17 @@ struct FillInfo
struct BorderInfo
{
unsigned char dgLeft;
unsigned char dgRight;
unsigned char dgTop;
unsigned char dgBottom;
unsigned char dgDiag;
unsigned char grbitDiag;
unsigned char icvLeft;
unsigned char icvRight;
unsigned char icvTop;
unsigned char icvBottom;
unsigned char icvDiag;
unsigned char dgLeft = 0;
unsigned char dgRight = 0;
unsigned char dgTop = 0;
unsigned char dgBottom = 0;
unsigned char dgDiag = 0;
unsigned char grbitDiag = 0;
unsigned char icvLeft = 0;
unsigned char icvRight = 0;
unsigned char icvTop = 0;
unsigned char icvBottom = 0;
unsigned char icvDiag = 0;
FillInfoExt leftFillInfo_;
FillInfoExt rightFillInfo_;
......
......@@ -38,10 +38,11 @@ namespace XLS
{
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
CellXF::CellXF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell_xf_current_id_(cell_xf_current_id),
style_xf_current_id_(style_xf_current_id)
{
alc = alcV = 0;
font_id = 0xFFFF;
}
......@@ -152,6 +153,91 @@ void CellXF::load(CFRecord& record)
}
}
void CellXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
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:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void CellXF::Update(XFProps* xfProps)
{
if (!xfProps) return;
//
// std::wstringstream strm;
// xfProps->serialize_fill(strm);
// fill.ext = strm.str();
}
void CellXF::RegisterFillBorder()
{
for (size_t i = 0; i < ext_props.size(); i++ )
......@@ -231,6 +317,8 @@ void CellXF::RegisterFillBorder()
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
m_GlobalWorkbookInfo->RegisterFontColorId(font_id, font_color);
}
......
......@@ -36,6 +36,8 @@
namespace XLS
{
class XFProps;
class ExtProp;
class CFRecord;
class GlobalWorkbookInfo;
......@@ -74,19 +76,23 @@ public:
BorderInfo border;
FillInfo fill;
BiffStructurePtrVector ext_props;
FillInfoExt font_color;
size_t font_id;
bool fHasXFExt;
bool fsxButton;
//------------------------------------------------------------------
BiffStructurePtrVector ext_props;
BiffStructurePtrVector xf_props;
size_t border_x_id;
size_t fill_x_id;
size_t& cell_xf_current_id_;
size_t& style_xf_current_id_;
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
};
......
......@@ -57,11 +57,11 @@ void List12TableStyleClientInfo::load(CFRecord& record)
unsigned short flags;
record >> flags;
nFirstColumn = GETBITS(flags, 0, 1);
nLastColumn = GETBITS(flags, 1, 2);
nRowStripes = GETBITS(flags, 3, 4);
nColumnStripes = GETBITS(flags, 5, 6);
nDefaultStyle = GETBITS(flags, 9, 10);
fFirstColumn = GETBIT(flags, 0);
fLastColumn = GETBIT(flags, 1);
fRowStripes = GETBIT(flags, 2);
fColumnStripes = GETBIT(flags, 3);
fDefaultStyle = GETBIT(flags, 6);
record >> stListStyleName;
}
......
......@@ -51,11 +51,11 @@ public:
virtual void load(CFRecord& record);
unsigned char nFirstColumn;
unsigned char nLastColumn;
unsigned char nRowStripes;
unsigned char nColumnStripes;
unsigned char nDefaultStyle;
bool fFirstColumn;
bool fLastColumn;
bool fRowStripes;
bool fColumnStripes;
bool fDefaultStyle;
XLUnicodeString stListStyleName;
};
......
......@@ -37,24 +37,20 @@ namespace XLS
{
LongRGBA::LongRGBA()
: is_alpha(true)
LongRGBA::LongRGBA() : is_alpha(true)
{
}
LongRGBA::LongRGBA(const bool alpha_present)
: is_alpha(alpha_present)
LongRGBA::LongRGBA(const bool alpha_present) : is_alpha(alpha_present)
{
}
LongRGB::LongRGB()
: LongRGBA(false)
LongRGB::LongRGB() : LongRGBA(false)
{
}
BiffStructurePtr LongRGBA::clone()
{
return BiffStructurePtr(new LongRGBA(*this));
......@@ -78,9 +74,14 @@ void LongRGBA::load(CFRecord& record)
alpha = 0;
record.skipNunBytes(1); // reserved
}
strRGB = STR::toRGB (red, green, blue);
strARGB = STR::toARGB(red, green, blue, alpha);
}
_UINT32 LongRGBA::ToRGBA()
{
return ((unsigned int)( ( (unsigned char)(red) )| ( ( (unsigned char)(green) ) << 8 ) | ( ( (unsigned char)(blue) ) << 16 ) | ( (unsigned char)(alpha) << 24 ) ) );
}
} // namespace XLS
......@@ -50,7 +50,6 @@ public:
virtual void load(CFRecord& record);
unsigned char red;
unsigned char green;
unsigned char blue;
......@@ -59,6 +58,8 @@ public:
std::wstring strARGB;
std::wstring strRGB;
_UINT32 ToRGBA();
bool is_alpha;
};
......
......@@ -29,23 +29,29 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "StyleXF.h"
#include "XFProps.h"
#include "XFProp.h"
#include "ExtProp.h"
#include "XFPropColor.h"
#include "BitMarkedStructs.h"
#include "XFPropBorder.h"
#include "../Biff_records/Font.h"
#include <Binary/CFRecord.h>
namespace XLS
{
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_id(0xFFFF)
StyleXF::StyleXF(size_t& cell_xf_current_id, size_t& style_xf_current_id) : cell_xf_current_id_(cell_xf_current_id),
style_xf_current_id_(style_xf_current_id)
{
font_id = -1;
font_id = 0xFFFF;
border_x_id = -1;
fill_x_id = -1;
font = NULL;
fill.fls = 0;
}
......@@ -58,9 +64,9 @@ BiffStructurePtr StyleXF::clone()
void StyleXF::load(CFRecord& record)
{
m_GlobalWorkbookInfo = record.getGlobalWorkbookInfo();
global_info = record.getGlobalWorkbookInfo();
if (m_GlobalWorkbookInfo->Version < 0x0600)
if (global_info->Version < 0x0600)
{
_UINT16 flags1;
_UINT32 flags2;
......@@ -146,86 +152,153 @@ void StyleXF::Update(ExtProp* ext_prop)
{
if (!ext_prop) return;
FillInfoExt color_out;
{
color_out.enabled = true;
color_out.icv = ext_prop->extPropData.color.icv;
color_out.xclrType = ext_prop->extPropData.color.xclrType;
color_out.nTintShade = ext_prop->extPropData.color.nTintShade;
color_out.xclrValue = ext_prop->extPropData.color.xclrValue;
}
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;
fill.foreFillInfo_ = color_out;
}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;
fill.backFillInfo_ = color_out;
}break;
case 0x0007:
{
border.topFillInfo_.enabled = true;
border.topFillInfo_.icv = ext_prop->extPropData.color.icv;
border.topFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.topFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.topFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.topFillInfo_ = color_out;
}break;
case 0x0008:
{
border.bottomFillInfo_.enabled = true;
border.bottomFillInfo_.icv = ext_prop->extPropData.color.icv;
border.bottomFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.bottomFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.bottomFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.bottomFillInfo_ = color_out;
}break;
case 0x0009:
{
border.leftFillInfo_.enabled = true;
border.leftFillInfo_.icv = ext_prop->extPropData.color.icv;
border.leftFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.leftFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.leftFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.leftFillInfo_ = color_out;
}break;
case 0x000A:
{
border.rightFillInfo_.enabled = true;
border.rightFillInfo_.icv = ext_prop->extPropData.color.icv;
border.rightFillInfo_.xclrType = ext_prop->extPropData.color.xclrType;
border.rightFillInfo_.nTintShade = ext_prop->extPropData.color.nTintShade;
border.rightFillInfo_.xclrValue = ext_prop->extPropData.color.xclrValue;
border.rightFillInfo_ = color_out;
}break;
//case 0x000B: //diag color
//case 0x000C: //diag color
case 0x000D:
{
font_color.enabled = true;
font_color.icv = ext_prop->extPropData.color.icv;
font_color.xclrType = ext_prop->extPropData.color.xclrType;
font_color.nTintShade = ext_prop->extPropData.color.nTintShade;
font_color.xclrValue = ext_prop->extPropData.color.xclrValue;
font_color = color_out;
}break;
//case 0x0006:
// extPropData.gradient_fill.toXML(own_tag);
// break;
case 0x000E:
{
font_id = ext_prop->extPropData.font_scheme;
font_id = ext_prop->extPropData.font_scheme;
}break;
case 0x000F:
{
cIndent = ext_prop->extPropData.indent_level;
cIndent = ext_prop->extPropData.indent_level;
}break;
}
}
void StyleXF::Update(XFProps* xfProps)
void StyleXF::Update(XFProp* xfProp)
{
if (!xfProps) return;
if (!xfProp) return;
XFPropColor* color = dynamic_cast<XFPropColor*>(xfProp->xfPropDataBlob.get());
if (color)
{
FillInfoExt color_out;
color_out.enabled = true;
color_out.icv = color->icv;
color_out.xclrType = color->xclrType;
color_out.nTintShade = color->nTintShade;
if (color->xclrType == 3)color_out.xclrValue = color->icv;
else color_out.xclrValue = color->dwRgba.ToRGBA();
switch(xfProp->xfPropType)
{
case 0x0001: fill.foreFillInfo_ = color_out; break;
case 0x0002: fill.backFillInfo_ = color_out; break;
case 0x0005: font_color = color_out; break;
}
return;
}
BIFF_BYTE* byte_ = dynamic_cast<BIFF_BYTE*>(xfProp->xfPropDataBlob.get());
if (byte_)
{
switch(xfProp->xfPropType)
{
case 0x0025:
{
font_id = *byte_->value();
if ((global_info->m_arFonts) && (font_id >=0 && font_id < global_info->m_arFonts->size()))
{
font = dynamic_cast<Font*>(global_info->m_arFonts->at(font_id).get());
}
}break;
case 0x001C: if (font) font->fItalic = *byte_->value(); break;
case 0x001D: if (font) font->fStrikeOut = *byte_->value(); break;
case 0x001E: if (font) font->fOutline = *byte_->value(); break;
case 0x001F: if (font) font->fShadow = *byte_->value(); break;
case 0x0022: if (font) font->bCharSet = *byte_->value(); break;
}
return;
}
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(xfProp->xfPropDataBlob.get());
std::wstringstream strm;
xfProps->serialize_fill(strm);
fill.ext = strm.str();
if (word)
{
switch(xfProp->xfPropType)
{
case 0x0019: if (font) font->bls = *word->value(); break;
case 0x001A: if (font) font->uls = *word->value(); break;
case 0x001B: if (font) font->sss = *word->value(); break;
}
return;
}
BIFF_DWORD* dword = dynamic_cast<BIFF_DWORD*>(xfProp->xfPropDataBlob.get());
if (dword)
{
switch(xfProp->xfPropType)
{
case 0x0024: if (font) font->dyHeight = *dword->value(); break;
}
return;
}
XFPropBorder *brdr = dynamic_cast<XFPropBorder*>(xfProp->xfPropDataBlob.get());
if (brdr)
{
FillInfoExt color_out;
color_out.enabled = true;
color_out.icv = brdr->color.icv;
color_out.xclrType = brdr->color.xclrType;
color_out.nTintShade = brdr->color.nTintShade;
if (brdr->color.xclrType == 3) color_out.xclrValue = brdr->color.icv;
else color_out.xclrValue = brdr->color.dwRgba.ToRGBA();
switch(xfProp->xfPropType)
{
case 0x0006: border.topFillInfo_ = color_out; break;
case 0x0007: border.bottomFillInfo_ = color_out; break;
case 0x0008: border.leftFillInfo_ = color_out; break;
case 0x0009: border.rightFillInfo_ = color_out; break;
//horiz, vert, diag
}
return;
}
}
void StyleXF::RegisterFillBorder()
{
......@@ -234,9 +307,15 @@ void StyleXF::RegisterFillBorder()
ExtProp* ext_prop = dynamic_cast<ExtProp*>(ext_props[i].get());
Update (ext_prop);
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
for (size_t i = 0; i < xf_props.size(); i++ )
{
XFProp* xf_prop = dynamic_cast<XFProp*>(xf_props[i].get());
Update (xf_prop);
}
border_x_id = global_info->RegisterBorderId(border);
fill_x_id = global_info->RegisterFillId(fill);
global_info->RegisterFontColorId(font_id, font_color);
}
......
......@@ -36,9 +36,10 @@
namespace XLS
{
class XFProps;
class XFProp;
class ExtProp;
class CFRecord;
class Font;
class GlobalWorkbookInfo;
typedef boost::shared_ptr<GlobalWorkbookInfo> GlobalWorkbookInfoPtr;
......@@ -52,17 +53,10 @@ public:
virtual void load(CFRecord& record);
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
static const ElementType type = typeStyleXF;
int serialize(std::wostream & stream);
void Update(ExtProp* extProp); // xls style
void Update(XFProps* xfProps); //xlsx style
void RegisterFillBorder();
unsigned char alc;
bool fWrap;
unsigned char alcV;
......@@ -72,13 +66,22 @@ public:
bool fShrinkToFit;
unsigned char iReadOrder;
//------------------------------------------------------------------
GlobalWorkbookInfoPtr global_info;
BorderInfo border;
FillInfo fill;
FillInfoExt font_color;
size_t font_id;
Font *font;
BiffStructurePtrVector ext_props;
BiffStructurePtrVector xf_props;
void Update(ExtProp* extProp); // xls style
void Update(XFProp* xfProp); //xlsx style
void RegisterFillBorder();
size_t border_x_id;
size_t fill_x_id;
......
......@@ -29,16 +29,15 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "XFProp.h"
#include <Binary/CFRecord.h>
#include "XFPropColor.h"
#include "XFPropGradient.h"
#include "XFPropGradientStop.h"
#include "XFPropBorder.h"
#include "BiffString.h"
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "BitMarkedStructs.h"
#include <utils.h>
......@@ -145,8 +144,7 @@ static void serialize_color_prop(std::wostream & stream, const std::wstring & na
XFPropColor * color = dynamic_cast<XFPropColor*>(val.get());
if (!color) return;
color->node_name = name;
color->serialize(stream);
color->serialize(stream, name);
}
static void serialize_val_prop(std::wostream & stream, const std::wstring & name, BiffStructurePtr & val)
......@@ -218,7 +216,7 @@ static void serialize_border_prop(std::wostream & stream, const std::wstring & n
}
if (border->dgBorder != 0)
{
border->color.serialize(CP_XML_STREAM());
border->color.serialize(CP_XML_STREAM(), L"color");
}
}
}
......
......@@ -32,8 +32,7 @@
#pragma once
#include "BiffStructure.h"
#include <Logic/Biff_structures/FullColorExt.h>
#include <Logic/Biff_structures/XFExtGradient.h>
#include "FullColorExt.h"
#include <simple_xml_writer.h>
......@@ -59,5 +58,6 @@ public:
unsigned short cb;
BiffStructurePtr xfPropDataBlob;
};
typedef boost::shared_ptr<XFProp> XFPropPtr;
} // namespace XLS
......@@ -49,7 +49,6 @@ public:
virtual void load(CFRecord& record);
XFPropColor color;
unsigned short dgBorder;
};
......
......@@ -47,8 +47,6 @@ BiffStructurePtr XFPropColor::clone()
void XFPropColor::load(CFRecord& record)
{
node_name = L"color";
unsigned char flags;
record >> flags;
......@@ -58,7 +56,7 @@ void XFPropColor::load(CFRecord& record)
record >> icv >> nTintShade >> dwRgba;
}
int XFPropColor::serialize(std::wostream & stream)
int XFPropColor::serialize(std::wostream & stream, const std::wstring &node_name)
{
if (xclrType > 3 )return 0;//not set
......@@ -68,11 +66,11 @@ int XFPropColor::serialize(std::wostream & stream)
{
switch(xclrType)
{
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 2:
case 3: CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
//CP_XML_ATTR(L"theme", icv); break;
case 0: CP_XML_ATTR(L"auto", 1); break;
case 1: CP_XML_ATTR(L"indexed", icv); break;
case 3: CP_XML_ATTR(L"theme", icv); break;
default:
CP_XML_ATTR(L"rgb", dwRgba.strRGB); break;
}
if (nTintShade != 0)
{
......
......@@ -47,10 +47,9 @@ public:
virtual void load(CFRecord& record);
static const ElementType type = typeXFPropColor;
int serialize(std::wostream & stream);
int serialize(std::wostream & stream, const std::wstring &sNode);
bool fValidRGBA;
unsigned char xclrType;
......
......@@ -32,7 +32,6 @@
#include "XFPropGradientStop.h"
#include <Binary/CFRecord.h>
#include <simple_xml_writer.h>
namespace XLS
......@@ -59,7 +58,7 @@ int XFPropGradientStop::serialize(std::wostream & stream)
CP_XML_NODE(L"stop")
{
CP_XML_ATTR(L"position", numPosition);
color.serialize(CP_XML_STREAM());
color.serialize(CP_XML_STREAM(), L"color");
}
}
return 0;
......
......@@ -29,10 +29,15 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include <Binary/CFRecord.h>
#include "XFProps.h"
#include <Binary/CFRecord.h>
#include <Logic/Biff_structures/BitMarkedStructs.h>
#include "XFProp.h"
#include "XFPropColor.h"
#include "XFPropGradient.h"
#include "XFPropGradientStop.h"
#include "BitMarkedStructs.h"
namespace XLS
{
......@@ -43,8 +48,6 @@ BiffStructurePtr XFProps::clone()
return BiffStructurePtr(new XFProps(*this));
}
void XFProps::load(CFRecord& record)
{
arXFPropBorder.is_present = false;
......@@ -54,21 +57,24 @@ void XFProps::load(CFRecord& record)
for(int i = 0; i < cprops; ++i)
{
XFProp prop;
record >> prop;
XFPropPtr prop(new XFProp);
if (!prop) continue;
prop->load(record);
rgExt.push_back(prop);
if (prop.xfPropType >= 0 && prop.xfPropType <= 3)
if (prop->xfPropType >= 0 && prop->xfPropType <= 3)
{
arXFPropFill.push_back(prop);
}
else if (prop.xfPropType == 4)
else if (prop->xfPropType == 4)
{
arXFPropGradient.push_back(prop);
}
else if (prop.xfPropType >= 6 && prop.xfPropType <= 14)
else if (prop->xfPropType >= 6 && prop->xfPropType <= 14)
{
arXFPropBorder.is_present = true;
switch(prop.xfPropType)
switch(prop->xfPropType)
{
case 6: arXFPropBorder.top = prop; break;
case 7: arXFPropBorder.bottom = prop; break;
......@@ -78,20 +84,20 @@ void XFProps::load(CFRecord& record)
arXFPropBorder.other.push_back(prop);
}
}
else if (prop.xfPropType >= 15 && prop.xfPropType <= 22 || prop.xfPropType == 42)
else if (prop->xfPropType >= 15 && prop->xfPropType <= 22 || prop->xfPropType == 42)
{
arXFPropAlignment.push_back(prop);
}
else if (prop.xfPropType >= 24 && prop.xfPropType <= 37 || prop.xfPropType == 5)
else if (prop->xfPropType >= 24 && prop->xfPropType <= 37 || prop->xfPropType == 5)
{
arXFPropFont.push_back(prop);
}
else if (prop.xfPropType >= 38 && prop.xfPropType <= 41)
else if (prop->xfPropType >= 38 && prop->xfPropType <= 41)
{
bool skip_codes = false;
if (prop.xfPropType == 0x0029)
if (prop->xfPropType == 0x0029)
{
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop.xfPropDataBlob.get());
BIFF_WORD* word = dynamic_cast<BIFF_WORD*>(prop->xfPropDataBlob.get());
if ((word) && (word->value() == (_UINT16)30))
{
skip_codes = true;
......@@ -101,7 +107,7 @@ void XFProps::load(CFRecord& record)
if (!skip_codes)
arXFPropNumFmt.push_back(prop);
}
else if (prop.xfPropType >= 43 && prop.xfPropType <= 44)
else if (prop->xfPropType >= 43 && prop->xfPropType <= 44)
{
arXFPropProtection.push_back(prop);
}
......@@ -115,23 +121,23 @@ int XFProps::serialize_fill(std::wostream & stream)
{
if (arXFPropFill.empty()) return 0;
CP_XML_WRITER(stream)
{
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
XFProp *pPatternType = NULL;
XFPropGradient *pGradient = NULL;
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
switch(arXFPropFill[i]->xfPropType)
{
switch(arXFPropFill[i].xfPropType)
{
case 1:
case 0: pPatternType = &arXFPropFill[i]; break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i].xfPropDataBlob.get()); break;
}
case 0: pPatternType = arXFPropFill[i].get(); break;
case 3: pGradient = dynamic_cast<XFPropGradient*>(arXFPropFill[i]->xfPropDataBlob.get()); break;
}
}
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"fill")
{
if (pGradient || arXFPropGradient.size() > 0)
{
if (pGradient || arXFPropGradient.size() > 0)
{
CP_XML_NODE(L"gradientFill")
{
......@@ -140,26 +146,37 @@ int XFProps::serialize_fill(std::wostream & stream)
for (size_t i = 0 ; i < arXFPropGradient.size(); i++)
{
if (arXFPropGradient[i].xfPropDataBlob == NULL) continue;
arXFPropGradient[i].xfPropDataBlob->serialize(CP_XML_STREAM());
if (arXFPropGradient[i]->xfPropDataBlob == NULL) continue;
arXFPropGradient[i]->xfPropDataBlob->serialize(CP_XML_STREAM());
}
}
}
else if (pPatternType)
else
{
CP_XML_NODE(L"patternFill")
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
if (pPatternType)
{
pPatternType->serialize_attr(CP_GET_XML_NODE());
}
for (size_t i = 0; i < arXFPropFill.size(); i++)
{
arXFPropFill[i].serialize(CP_XML_STREAM());
XFPropColor *pColor = dynamic_cast<XFPropColor*>(arXFPropFill[i]->xfPropDataBlob.get());
if (!pColor) continue;
std::wstring sNode = L"color";
switch(arXFPropFill[i]->xfPropType)
{
case 1: sNode = L"fgColor"; break;
case 2: sNode = L"bgColor"; break;
}
pColor->serialize(CP_XML_STREAM(), sNode);
}
}
}
}
}
return 0;
}
......@@ -173,7 +190,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
for (size_t i = 0; i < arXFPropFont.size(); i++)
{
arXFPropFont[i].serialize(CP_XML_STREAM());
arXFPropFont[i]->serialize(CP_XML_STREAM());
}
}
}
......@@ -185,11 +202,11 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
if (dxf)
{
arXFPropNumFmt[i].serialize_attr(CP_GET_XML_NODE());
arXFPropNumFmt[i]->serialize_attr(CP_GET_XML_NODE());
}
else
{
arXFPropNumFmt[i].serialize(CP_XML_STREAM());
arXFPropNumFmt[i]->serialize(CP_XML_STREAM());
}
}
}
......@@ -202,7 +219,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
{
for (size_t i = 0; i < arXFPropAlignment.size(); i++)
{
arXFPropAlignment[i].serialize(CP_XML_STREAM());
arXFPropAlignment[i]->serialize(CP_XML_STREAM());
}
}
}
......@@ -219,7 +236,7 @@ int XFProps::serialize(std::wostream & strm, bool dxf)
//----------------------------------------
for (size_t i = 0; i < arXFPropBorder.other.size(); i++)
{
arXFPropBorder.other[i].serialize(CP_XML_STREAM());
arXFPropBorder.other[i]->serialize(CP_XML_STREAM());
}
}
}
......
......@@ -32,11 +32,13 @@
#pragma once
#include "BiffStructure.h"
#include "XFProp.h"
namespace XLS
{
class XFProp;
typedef boost::shared_ptr<XFProp> XFPropPtr;
class CFRecord;
class XFProps : public BiffStructure
......@@ -56,27 +58,31 @@ public:
int serialize_fill(std::wostream & stream);
std::vector<XFProp> arXFPropFont;
std::vector<XFProp> arXFPropNumFmt;
std::vector<XFProp> arXFPropFill;
std::vector<XFProp> arXFPropAlignment;
std::vector<XFPropPtr> arXFPropFont;
std::vector<XFPropPtr> arXFPropNumFmt;
std::vector<XFPropPtr> arXFPropFill;
std::vector<XFPropPtr> arXFPropAlignment;
struct _b
{
bool is_present;
bool is_present = false;
_CP_OPT(XFProp) left;
_CP_OPT(XFProp) right;
_CP_OPT(XFProp) top;
_CP_OPT(XFProp) bottom;
std::vector<XFProp> other;
XFPropPtr left;
XFPropPtr right;
XFPropPtr top;
XFPropPtr bottom;
std::vector<XFPropPtr> other;
}arXFPropBorder;
std::vector<XFProp> arXFPropProtection;
std::vector<XFProp> arXFPropGradient;
std::vector<XFPropPtr> arXFPropProtection;
std::vector<XFPropPtr> arXFPropGradient;
//-----------------------------------------------------
BiffStructurePtrVector rgExt;
bool fNewBorder;
bool bPresent;
};
} // namespace XLS
......@@ -276,6 +276,9 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
CP_XML_ATTR(L"id", field->idField);
CP_XML_ATTR(L"name", field->strCaption.value());
if (!field->strTotal.value().empty())
CP_XML_ATTR(L"totalsRowLabel", field->strTotal.value());
if (field->dxfFmtAgg.bExist ||
field->dxfFmtInsertRow.bExist)
{
......@@ -294,11 +297,11 @@ int FEAT11::serialize(std::wostream & strm, size_t index)
{
CP_XML_NODE(L"tableStyleInfo")
{
CP_XML_ATTR(L"name", table_style->stListStyleName.value());
CP_XML_ATTR(L"showFirstColumn", table_style->nFirstColumn);
CP_XML_ATTR(L"showLastColumn", table_style->nLastColumn);
CP_XML_ATTR(L"showRowStripes", table_style->nRowStripes);
CP_XML_ATTR(L"showColumnStripes", table_style->nColumnStripes);
CP_XML_ATTR(L"name", table_style->stListStyleName.value());
CP_XML_ATTR(L"showFirstColumn", table_style->fFirstColumn);
CP_XML_ATTR(L"showLastColumn", table_style->fLastColumn);
CP_XML_ATTR(L"showRowStripes", table_style->fRowStripes);
CP_XML_ATTR(L"showColumnStripes", table_style->fColumnStripes);
}
}
}
......
......@@ -71,6 +71,7 @@ BaseObjectPtr FORMATTING::clone()
const bool FORMATTING::loadContent(BinProcessor& proc)
{
global_info = proc.getGlobalWorkbookInfo();
global_info->m_arFonts = &m_arFonts;
int count = 0;
count = proc.repeated<Font>(0, 510); // Wrong records sequence workaround (originally at least one Font is mandatory)
......@@ -156,40 +157,40 @@ void FORMATTING::update_xfs()
if (!xfs) return;
//for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
//{
// XLS::Style * style = dynamic_cast<Style*>(st->m_arStyles[i].first.get());
// XLS::StyleExt * styleExt = dynamic_cast<StyleExt*>(st->m_arStyles[i].second.get());
//
// if (styleExt && style)
// {
// if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
// {
// bool bFound = false;
// for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
// {
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
for (size_t i = 0; (st) && (i < st->m_arStyles.size()); i++)
{
XLS::Style *style = dynamic_cast<Style*> (st->m_arStyles[i].first.get());
XLS::StyleExt *styleExt = dynamic_cast<StyleExt*> (st->m_arStyles[i].second.get());
if (styleExt && style)
{
if (styleExt->fBuiltIn && styleExt->xfProps.cprops > 0)
{
bool bFound = false;
for (size_t i = 0; i < xfs->m_arCellStyles.size(); i++)
{
XF* xf = dynamic_cast<XF*>(xfs->m_arCellStyles[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->style.Update(&styleExt->xfProps);
// bFound = true;
// break;
// }
// }
// //for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++)
// //{
// // XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// // if (xf->ind_xf == style->ixfe)
// // {
// // xf->cell.Update(&styleExt->xfProps);
// // bFound = true;
// // break;
// // }
// //}
// }
// }
//}
if (xf->ind_xf == style->ixfe)
{
xf->style.xf_props = styleExt->xfProps.rgExt;
bFound = true;
break;
}
}
//for (size_t i = 0; !bFound && i < xfs->m_arCellXFs.size(); i++) небывает совпадений
//{
// XF* xf = dynamic_cast<XF*>(xfs->m_arCellXFs[i].get());
// if (xf->ind_xf == style->ixfe)
// {
// xf->cell.xf_props = styleExt->xfProps.rgExt;
// bFound = true;
// break;
// }
//}
}
}
}
xfs->RegisterFillBorder();
}
void FORMATTING::concatinate(FORMATTING* ext)
......
......@@ -94,8 +94,7 @@ std::pair<float, float> GetMaxDigitSizePixelsImpl(const std::wstring & fontName,
return std::pair<float, float>(width, maxHeight);
}
GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConverter * xls_converter_)
: CodePage(code_page)
GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConverter * converter) : CodePage(code_page), xls_converter(converter)
{
fill_x_ids[FillInfo(0, 0, 0)] = 0;
fill_x_ids[FillInfo(17, 64, 65)] = 1;
......@@ -105,8 +104,6 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
Version = 0x0600;
xls_converter = xls_converter_;
startAddedSharedStrings = 0;
current_sheet = 0;
cmt_rules = 0;
......@@ -122,6 +119,7 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
bVbaProjectExist = false;
bMacrosExist = false;
bThemePresent = false;
idPivotCache = 0;
}
......
......@@ -84,6 +84,7 @@ public:
//-----------------------------------------------------------------------------
bool bVbaProjectExist;
bool bMacrosExist;
bool bThemePresent;
unsigned short CodePage;
CRYPT::DecryptorPtr decryptor;
......
......@@ -689,9 +689,9 @@ void XlsConverter::convert(XLS::GlobalsSubstream* globals)
{
if (globals == NULL) return;
convert((XLS::FORMATTING*)globals->m_Formating.get());
convert((XLS::THEME*)globals->m_THEME.get());
convert((XLS::FORMATTING*)globals->m_Formating.get());
convert((XLS::SHAREDSTRINGS*)globals->m_SHAREDSTRINGS.get());
......@@ -1117,16 +1117,16 @@ void XlsConverter::convert(XLS::THEME* THEME_)
if (hresult != S_OK || pBuffer == NULL)
hresult = OfficeUtils.LoadFileFromArchive(tempThemePath, L"theme/theme/theme1.xml", &pBuffer, nBufferSize);
//??? переписать по нормальному
if (hresult == S_OK && pBuffer != NULL)
{
xls_global_info->bThemePresent = true;
oox::package::theme_content_ptr content = oox::package::theme_content::create((char*)pBuffer, nBufferSize);
output_document->get_xl_files().add_theme(content);
delete []pBuffer;
pBuffer = NULL;
}
}
struct _group_object
......
......@@ -2146,6 +2146,7 @@ void xlsx_drawing_context::serialize_text(std::wostream & stream, _drawing_state
if (drawing_state->wordart.italic) CP_XML_ATTR(L"i", 1);
if (drawing_state->wordart.underline) CP_XML_ATTR(L"u", L"sng");
if (drawing_state->wordart.strike) CP_XML_ATTR(L"strike", L"sngStrike");
//if (drawing_state->wordart.cap) CP_XML_ATTR(L"cap", *cap);
CP_XML_ATTR(L"kern", 10);
......
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