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

XlsFile2 -расширение стилей (aligments, apply)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63992 954022d7-b5bf-4e40-9824-e11837661b57
parent 22ff4543
......@@ -67,6 +67,8 @@ void XF::readFields(CFRecord& record)
cell.load(record);
}
}
static const std::wstring HorAlign[8] = {L"general", L"left", L"center", L"right", L"fill", L"justify", L"centerContinuous", L"distributed"};
static const std::wstring VerAlign[5] = {L"top", L"center", L"bottom", L"justify", L"distributed"};
int XF::serialize(std::wostream & stream)
{
......@@ -74,10 +76,9 @@ int XF::serialize(std::wostream & stream)
{
CP_XML_NODE(L"xf")
{
if (ifnt.value())
{
CP_XML_ATTR(L"fontId" , ifnt.getValue());
}
if (style.font_scheme >=0) CP_XML_ATTR(L"fontId" , style.font_scheme);
else if (cell.font_scheme >=0) CP_XML_ATTR(L"fontId" , cell.font_scheme);
else if (ifnt.value()) CP_XML_ATTR(L"fontId" , ifnt.getValue());
if (ifmt.value())
{
......@@ -88,12 +89,53 @@ int XF::serialize(std::wostream & stream)
{
CP_XML_ATTR(L"borderId" , style.border_x_id);
CP_XML_ATTR(L"fillId" , style.fill_x_id);
//CP_XML_ATTR(L"applyFill" , style.fAtrPat);
//CP_XML_ATTR(L"applyBorder" , style.fAtrBdr);
//CP_XML_ATTR(L"applyNumberFormat" , style.fAtrNum);
if (style.alc >=0 && style.alc <8 && style.alcV >=0 && style.alcV <5)
{
//CP_XML_ATTR(L"applyAlignment", style.fAtrAlc);
CP_XML_NODE(L"alignment")
{
if (style.alc >=0 && style.alc <8) CP_XML_ATTR(L"horizontal" , HorAlign[style.alc]);
if (style.alcV >=0 && style.alcV <5) CP_XML_ATTR(L"vertical" , VerAlign[style.alcV] );
CP_XML_ATTR(L"shrinkToFit" , style.fShrinkToFit);
if (cell.cIndent > 0) CP_XML_ATTR(L"indent", style.cIndent);
CP_XML_ATTR(L"wrapText" , style.fWrap);
if (style.trot > 0) CP_XML_ATTR(L"textRotation" , style.trot);
}
}
}
else
{
CP_XML_ATTR(L"xfId" , ixfParent );
CP_XML_ATTR(L"borderId" , cell.border_x_id);
CP_XML_ATTR(L"fillId" , cell.fill_x_id);
CP_XML_ATTR(L"applyFill" , cell.fAtrPat);
CP_XML_ATTR(L"applyBorder" , cell.fAtrBdr);
CP_XML_ATTR(L"applyNumberFormat", cell.fAtrNum);
CP_XML_ATTR(L"applyFont" , cell.fAtrFnt);
if (cell.fAtrAlc)
{
CP_XML_ATTR(L"applyAlignment", cell.fAtrAlc);
CP_XML_NODE(L"alignment")
{
if (cell.alc >=0 && cell.alc <8) CP_XML_ATTR(L"horizontal" , HorAlign[cell.alc]);
if (cell.alcV >=0 && cell.alcV <5) CP_XML_ATTR(L"vertical" , VerAlign[cell.alcV] );
CP_XML_ATTR(L"shrinkToFit" , cell.fShrinkToFit);
if (cell.cIndent > 0) CP_XML_ATTR(L"indent", cell.cIndent);
CP_XML_ATTR(L"wrapText" , cell.fWrap);
if (cell.trot > 0) CP_XML_ATTR(L"textRotation" , cell.trot);
}
}
}
}
}
......
......@@ -197,7 +197,39 @@ void serialize1(std::wostream & _stream, unsigned char type, unsigned color, con
}
}
}
void serialize1(std::wostream & _stream, unsigned char type, FillInfoExt & color, const std::wstring & name)
{
if (type < 1 || type > 13) return;
CP_XML_WRITER(_stream)
{
CP_XML_NODE(name)
{
CP_XML_ATTR(L"style", border_type[type]);
if (color.enabled)
{
CP_XML_NODE(L"color")
{
switch(color.xclrType)
{
case 0://auto
/*CP_XML_ATTR(L"auto");*/ break;
case 1://indexed
CP_XML_ATTR(L"indexed", color.icv); break;
case 2://rgb
CP_XML_ATTR(L"rgb", STR::toARGB(color.xclrValue)); break;
case 3://theme color
CP_XML_ATTR(L"theme", color.xclrValue + 1);
CP_XML_ATTR(L"tint", color.nTintShade / 32767.0); break;
case 4://not set
break;
}
}
}
}
}
}
int BorderInfo::serialize(std::wostream & stream)
{
CP_XML_WRITER(stream)
......@@ -209,11 +241,19 @@ int BorderInfo::serialize(std::wostream & stream)
if (grbitDiag == 1 || grbitDiag == 3)
CP_XML_ATTR(L"diagonalDown", true);
serialize1(CP_XML_STREAM(), dgLeft , icvLeft , L"left");
serialize1(CP_XML_STREAM(), dgRight , icvRight , L"right");
serialize1(CP_XML_STREAM(), dgTop , icvTop , L"top");
serialize1(CP_XML_STREAM(), dgBottom, icvBottom , L"bottom");
serialize1(CP_XML_STREAM(), dgDiag , icvDiag , L"diagonal");
if (leftFillInfo_.enabled) serialize1(CP_XML_STREAM(), dgLeft , leftFillInfo_ , L"left");
else serialize1(CP_XML_STREAM(), dgLeft , icvLeft , L"left");
if (rightFillInfo_.enabled) serialize1(CP_XML_STREAM(), dgRight , rightFillInfo_, L"right");
else serialize1(CP_XML_STREAM(), dgRight , icvRight , L"right");
if (topFillInfo_.enabled) serialize1(CP_XML_STREAM(), dgTop , topFillInfo_ , L"top");
else serialize1(CP_XML_STREAM(), dgTop , icvTop , L"top");
if (bottomFillInfo_.enabled)serialize1(CP_XML_STREAM(), dgBottom, bottomFillInfo_, L"bottom");
else serialize1(CP_XML_STREAM(), dgBottom, icvBottom , L"bottom");
serialize1(CP_XML_STREAM(), dgDiag , icvDiag , L"diagonal");
}
}
return 0;
......
......@@ -65,6 +65,11 @@ struct BorderInfo
unsigned char icvBottom;
unsigned char icvDiag;
FillInfoExt leftFillInfo_;
FillInfoExt rightFillInfo_;
FillInfoExt topFillInfo_;
FillInfoExt bottomFillInfo_;
BorderInfo(){}
BorderInfo( const unsigned char dgLeft_set, const unsigned char dgRight_set, const unsigned char dgTop_set,
......
......@@ -10,7 +10,7 @@ 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)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_scheme(-1)
{
}
......@@ -136,34 +136,56 @@ void CellXF::RegisterFillBorder()
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:
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: //text color
// 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;
case 0x000E:
font_scheme = ext_prop->extPropData.font_scheme;
break;
case 0x000F:
cIndent = ext_prop->extPropData.indent_level;
break;
}
}
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
border_x_id = m_GlobalWorkbookInfo->RegisterBorderId(border);
fill_x_id = m_GlobalWorkbookInfo->RegisterFillId(fill);
}
int CellXF::serialize(std::wostream & stream)
{
return 0;
}
......
......@@ -25,8 +25,6 @@ public:
GlobalWorkbookInfoPtr m_GlobalWorkbookInfo;
int serialize(std::wostream & stream);
unsigned char alc;
bool fWrap;
unsigned char alcV;
......@@ -35,6 +33,7 @@ public:
unsigned char cIndent;
bool fShrinkToFit;
unsigned char iReadOrder;
bool fAtrNum;
bool fAtrFnt;
bool fAtrAlc;
......@@ -47,6 +46,8 @@ public:
BiffStructurePtrVector ext_props;
int font_scheme;
bool fHasXFExt;
bool fsxButton;
......
......@@ -23,6 +23,7 @@ OfficeArtCOLORREF::OfficeArtCOLORREF(const long raw_data)
fSchemeIndex = GETBIT(raw_data, 27);
fSysIndex = GETBIT(raw_data, 28);
if(!fSchemeIndex && !fPaletteIndex && !fSysIndex)
{
colorRGB = STR::toRGB(red, green, blue);
......@@ -46,40 +47,4 @@ XLS::BiffStructurePtr OfficeArtCOLORREF::clone()
return XLS::BiffStructurePtr(new OfficeArtCOLORREF(*this));
}
//void OfficeArtCOLORREF::setXMLAttributes(MSXML2::IXMLDOMElementPtr own_tag)
//{
// if(!fSchemeIndex && !fPaletteIndex && !fSysIndex)
// {
// own_tag->setAttribute(L"rgb", STR::toRGB(red, green, blue).c_str());
// }
// else if(fSchemeIndex)
// {
// own_tag->setAttribute(L"scheme_index", STR::int2str(red).c_str());
// }
// else if(fPaletteIndex)
// {
// own_tag->setAttribute(L"palette_index", STR::int2str((static_cast<unsigned short>(green) << 8) + red).c_str());
// }
// else if(fSysIndex)
// {
// own_tag->setAttribute(L"system_index", STR::int2str((static_cast<unsigned short>(green) << 8) + red).c_str());
// }
//
// own_tag->setAttribute(L"fPaletteIndex", fPaletteIndex);
// own_tag->setAttribute(L"fPaletteRGB", fPaletteRGB);
// own_tag->setAttribute(L"fSystemRGB", fSystemRGB);
// own_tag->setAttribute(L"fSchemeIndex", fSchemeIndex);
// own_tag->setAttribute(L"fSysIndex", fSysIndex);
//
//}
//
//void OfficeArtCOLORREF::getXMLAttributes(MSXML2::IXMLDOMElementPtr xml_tag)
//{
// // We don't support xlsx to xls conversion
//}
//
//
//
//
} // namespace XLS
......@@ -328,19 +328,6 @@ void TextBooleanProperties::load(XLS::CFRecord& record)
fUsefSelectText = GETBIT(op, 20);
}
void lineColor::load(XLS::CFRecord& record)
{
unsigned short flags;
record >> flags >> op;
OfficeArtCOLORREF c(op);
color = c;
opid = GETBITS(flags, 0, 13);
fBid = GETBIT(flags, 14);
fComplex = GETBIT(flags, 15);
}
//void fillShadeType::setXMLAttributes(MSXML2::IXMLDOMElementPtr own_tag)
//{
// msoshadeNone = GETBIT(op, 0);
......
......@@ -67,9 +67,6 @@ class TextBooleanProperties : public OfficeArtFOPTE
class lineColor : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineColor)
virtual void load(XLS::CFRecord& record);
OfficeArtCOLORREF color;
};
class fillType : public OfficeArtFOPTE
......
......@@ -10,7 +10,7 @@ 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)
: cell_xf_current_id_(cell_xf_current_id), style_xf_current_id_(style_xf_current_id), font_scheme(-1)
{
}
......@@ -119,24 +119,52 @@ void StyleXF::RegisterFillBorder()
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:
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: //text color
// 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;
case 0x000E:
font_scheme = ext_prop->extPropData.font_scheme;
break;
case 0x000F:
cIndent = ext_prop->extPropData.indent_level;
break;
}
}
......
......@@ -42,6 +42,8 @@ public:
BiffStructurePtrVector ext_props;
int font_scheme;
size_t border_x_id;
size_t fill_x_id;
......
......@@ -565,9 +565,11 @@ void XlsConverter::convert_line_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
case 0x01C0:
{
ODRAW::lineColor * color = (ODRAW::lineColor *)props[i].get();
if (!color->color.colorRGB.empty())
xlsx_context->get_drawing_context().set_line_color(color->color.colorRGB);
ODRAW::OfficeArtCOLORREF color(props[i]->op);
if (!color.colorRGB.empty())
xlsx_context->get_drawing_context().set_line_color(color.colorRGB);
else
xlsx_context->get_drawing_context().set_line_color(color.index, color.fSchemeIndex ? 1 : (color. fPaletteIndex ? 2 : 3 ));
}break;
case 0x01C4:
{
......
......@@ -10,6 +10,8 @@
namespace oox {
const static std::wstring shemeColor[17] =
{L"accent1",L"accent2",L"accent3",L"accent4",L"accent5",L"accent6",L"bg1",L"bg2",L"dk1",L"dk2",L"folHlink",L"hlink",L"lt1",L"lt2",L"phClr",L"tx1",L"tx2"};
class xlsx_drawing_context_handle::Impl
{
......@@ -289,20 +291,38 @@ void xlsx_drawing_context::serialize_none_fill(std::wostream & stream)
CP_XML_NODE(L"a:noFill");
}
}
void xlsx_drawing_context::serialize_color (std::wostream & stream, const _color &color)
{
CP_XML_WRITER(stream)
{
if (!color.rgb.empty())
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val", color.rgb);
}
}
else if (color.bPalette){CP_XML_NODE(L"a:prstClr") { CP_XML_ATTR(L"val",L"black");}}
else if (color.bScheme)
//else
{
CP_XML_NODE(L"a:schemeClr")
{
CP_XML_ATTR(L"val", (color.index >=0 && color.index < 17) ? shemeColor[color.index] : L"tx1");
}
}
else{CP_XML_NODE(L"a:sysClr") { CP_XML_ATTR(L"val",L"windowText");}}
}
}
void xlsx_drawing_context::serialize_line(std::wostream & stream)
{
CP_XML_WRITER(stream)
{
CP_XML_NODE(L"a:ln")
{
CP_XML_NODE(L"a:" + drawing_state.back().line.type)
{
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val", drawing_state.back().line.color);
}
serialize_color(CP_XML_STREAM(), drawing_state.back().line.color);
}
}
}
......@@ -472,7 +492,16 @@ void xlsx_drawing_context::set_rotation (long val)
void xlsx_drawing_context::set_line_color (std::wstring color)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().line.color = color;
drawing_state.back().line.color.rgb = color;
}
void xlsx_drawing_context::set_line_color (int index, int type)
{
if (drawing_state.size() < 1 )return;
drawing_state.back().line.color.index = index;
if (type == 1) drawing_state.back().line.color.bScheme = true;
else if (type == 2) drawing_state.back().line.color.bPalette = true;
}
void xlsx_drawing_context::set_line_type (long val)
{
......
......@@ -26,6 +26,15 @@ private:
_CP_PTR(Impl) impl_;
};
struct _color
{
_color() : index(-1), bScheme(false), bPalette(false){}
std::wstring rgb;
int index;
bool bScheme;
bool bPalette;
};
class _drawing_state
{
public:
......@@ -60,8 +69,8 @@ public:
struct _line
{
_line() {opacity = 0; type = L"solid"; style = L"simple";}
std::wstring color;
_line() {opacity = 0; type = L"solidFill"; style = L"simple";}
_color color;
int opacity;
std::wstring type;
std::wstring style;
......@@ -102,7 +111,8 @@ public:
void set_rotation (long val);
void set_line_color (std::wstring val);
void set_line_color (std::wstring color);
void set_line_color (int index, int type);
void set_line_type (long val);
void set_line_style (long val);
......@@ -116,6 +126,7 @@ public:
void serialize_pic(std::wstring rId);
void serialize_shape();
void serialize_color (std::wostream & stream, const _color &color);
void serialize_line (std::wostream & stream);
void serialize_fill (std::wostream & stream);
void serialize_bitmap_fill (std::wostream & stream, std::wstring rId, const std::wstring ns = L"a:");
......
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