Commit bff7e2cd authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - условное форматирование, стили условного форматирования

parent 342c2aed
...@@ -292,7 +292,7 @@ void docx_conversion_context::end_document() ...@@ -292,7 +292,7 @@ void docx_conversion_context::end_document()
count++; count++;
package::chart_content_ptr content = package::chart_content::create(); package::chart_content_ptr content = package::chart_content::create();
chart->write_to(content->content()); chart->serialize(content->content());
output_document_->get_word_files().add_charts(content); output_document_->get_word_files().add_charts(content);
......
...@@ -44,7 +44,7 @@ std::wostream & oox_chart_context::chartData() ...@@ -44,7 +44,7 @@ std::wostream & oox_chart_context::chartData()
return impl_->chartData_; return impl_->chartData_;
} }
void oox_chart_context::write_to(std::wostream & strm) void oox_chart_context::serialize(std::wostream & strm)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
......
...@@ -29,7 +29,7 @@ public: ...@@ -29,7 +29,7 @@ public:
bool empty() const; bool empty() const;
void write_to(std::wostream & strm); void serialize(std::wostream & strm);
static oox_chart_context_ptr create(std::wstring const & name); static oox_chart_context_ptr create(std::wstring const & name);
static oox_chart_context_ptr create(); static oox_chart_context_ptr create();
......
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
pptx_comments_->add(d); pptx_comments_->add(d);
} }
void write_comments(std::wostream & strm) void serialize(std::wostream & strm)
{ {
pptx_serialize(strm, *pptx_comments_); pptx_serialize(strm, *pptx_comments_);
} }
...@@ -146,9 +146,9 @@ bool pptx_comments_context::empty() const ...@@ -146,9 +146,9 @@ bool pptx_comments_context::empty() const
return impl_->empty(); return impl_->empty();
} }
void pptx_comments_context::write_comments(std::wostream & strm) void pptx_comments_context::serialize(std::wostream & strm)
{ {
impl_->write_comments(strm); impl_->serialize(strm);
impl_->clear(); impl_->clear();
} }
pptx_comments_ptr pptx_comments_context::get_comments() pptx_comments_ptr pptx_comments_context::get_comments()
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
bool empty() const; bool empty() const;
void write_comments(std::wostream & strm); void serialize(std::wostream & strm);
pptx_comments_ptr get_comments(); pptx_comments_ptr get_comments();
......
...@@ -267,7 +267,7 @@ void pptx_conversion_context::end_document() ...@@ -267,7 +267,7 @@ void pptx_conversion_context::end_document()
count++; count++;
package::chart_content_ptr content = package::chart_content::create(); package::chart_content_ptr content = package::chart_content::create();
chart->write_to(content->content()); chart->serialize(content->content());
output_document_->get_ppt_files().add_charts(content); output_document_->get_ppt_files().add_charts(content);
...@@ -487,7 +487,7 @@ void pptx_conversion_context::end_page() ...@@ -487,7 +487,7 @@ void pptx_conversion_context::end_page()
if (!get_comments_context().empty()) if (!get_comments_context().empty())
{ {
std::wstringstream strm; std::wstringstream strm;
get_comments_context().write_comments(strm); get_comments_context().serialize(strm);
const std::pair<std::wstring, std::wstring> commentsName = const std::pair<std::wstring, std::wstring> commentsName =
comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() ); comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() );
......
...@@ -168,7 +168,7 @@ public: ...@@ -168,7 +168,7 @@ public:
} }
}; };
void xlsx_serialize(std::wostream & _Wostream) void serialize(std::wostream & _Wostream)
{ {
std::vector<xlsx_border> inst_array; std::vector<xlsx_border> inst_array;
...@@ -212,9 +212,9 @@ size_t xlsx_borders::borderId(const odf_reader::style_table_cell_properties_attl ...@@ -212,9 +212,9 @@ size_t xlsx_borders::borderId(const odf_reader::style_table_cell_properties_attl
return impl_->borderId(cellProp, is_default); return impl_->borderId(cellProp, is_default);
} }
void xlsx_borders::xlsx_serialize(std::wostream & _Wostream) void xlsx_borders::serialize(std::wostream & _Wostream)
{ {
return impl_->xlsx_serialize(_Wostream); return impl_->serialize(_Wostream);
} }
xlsx_borders::xlsx_borders(): impl_(new Impl()) xlsx_borders::xlsx_borders(): impl_(new Impl())
...@@ -225,11 +225,6 @@ xlsx_borders::~xlsx_borders() ...@@ -225,11 +225,6 @@ xlsx_borders::~xlsx_borders()
{ {
} }
void xlsx_serialize(std::wostream & _Wostream, xlsx_borders & borders)
{
return borders.xlsx_serialize(_Wostream);
}
} }
} }
......
#ifndef _CPDOCCORE_XLSX_BORDERS_H_INCLUDED_da8e414a #pragma once
#define _CPDOCCORE_XLSX_BORDERS_H_INCLUDED_da8e414a
#include <iosfwd> #include <iosfwd>
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
...@@ -24,17 +23,13 @@ namespace oox { ...@@ -24,17 +23,13 @@ namespace oox {
size_t borderId(odf_reader::style_table_cell_properties_attlist * cellProp); size_t borderId(odf_reader::style_table_cell_properties_attlist * cellProp);
size_t borderId(const odf_reader::style_table_cell_properties_attlist * cellProp, bool & is_default); size_t borderId(const odf_reader::style_table_cell_properties_attlist * cellProp, bool & is_default);
void xlsx_serialize(std::wostream & _Wostream); void serialize(std::wostream & _Wostream);
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
}; };
void xlsx_serialize(std::wostream & _Wostream, xlsx_borders & borders);
} }
} }
#endif
...@@ -19,6 +19,7 @@ public: ...@@ -19,6 +19,7 @@ public:
xlsx_cell_styles::xlsx_cell_styles() : impl_(new xlsx_cell_styles::Impl()) xlsx_cell_styles::xlsx_cell_styles() : impl_(new xlsx_cell_styles::Impl())
{ {
xlsx_cell_style default_style; xlsx_cell_style default_style;
default_style.xfId = 0; default_style.xfId = 0;
default_style.builtinId = 0; default_style.builtinId = 0;
default_style.name = L"Default"; default_style.name = L"Default";
...@@ -29,7 +30,7 @@ xlsx_cell_styles::xlsx_cell_styles() : impl_(new xlsx_cell_styles::Impl()) ...@@ -29,7 +30,7 @@ xlsx_cell_styles::xlsx_cell_styles() : impl_(new xlsx_cell_styles::Impl())
xlsx_cell_styles::~xlsx_cell_styles() xlsx_cell_styles::~xlsx_cell_styles()
{} {}
void xlsx_cell_styles::xlsx_serialize(std::wostream & _Wostream) const void xlsx_cell_styles::serialize(std::wostream & _Wostream) const
{ {
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
...@@ -39,7 +40,7 @@ void xlsx_cell_styles::xlsx_serialize(std::wostream & _Wostream) const ...@@ -39,7 +40,7 @@ void xlsx_cell_styles::xlsx_serialize(std::wostream & _Wostream) const
BOOST_FOREACH(const xlsx_cell_style & s, impl_->cell_styles_) BOOST_FOREACH(const xlsx_cell_style & s, impl_->cell_styles_)
{ {
::cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), s); oox::xlsx_serialize(CP_XML_STREAM(), s);
} }
} }
} }
......
#ifndef _CPDOCCORE_XLSX_CELL_STYLES_ #pragma once
#define _CPDOCCORE_XLSX_CELL_STYLES_
#include <cpdoccore/CPScopedPtr.h> #include <cpdoccore/CPScopedPtr.h>
...@@ -13,7 +12,7 @@ public: ...@@ -13,7 +12,7 @@ public:
~xlsx_cell_styles(); ~xlsx_cell_styles();
public: public:
void xlsx_serialize(std::wostream & _Wostream) const; void serialize(std::wostream & _Wostream) const;
private: private:
class Impl; class Impl;
...@@ -22,5 +21,3 @@ private: ...@@ -22,5 +21,3 @@ private:
} }
} }
\ No newline at end of file
#endif
#pragma once #pragma once
#include <iosfwd> #include <iosfwd>
......
#include "xlsx_comments.h" #include "xlsx_comments.h"
#include <boost/foreach.hpp> #include "docx_rels.h"
#include <vector> #include <vector>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include "docx_rels.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -31,8 +31,9 @@ public: ...@@ -31,8 +31,9 @@ public:
CP_XML_NODE(L"authors") CP_XML_NODE(L"authors")
{ {
BOOST_FOREACH(std::wstring const & a, author_list_) for (int i = 0 ; i < author_list_.size(); i++)
{ {
const std::wstring & a = author_list_[i];
CP_XML_NODE(L"author") CP_XML_NODE(L"author")
{ {
CP_XML_STREAM() << a; CP_XML_STREAM() << a;
...@@ -42,8 +43,10 @@ public: ...@@ -42,8 +43,10 @@ public:
CP_XML_NODE(L"commentList") CP_XML_NODE(L"commentList")
{ {
BOOST_FOREACH(_xlsx_comment const & c, xlsx_comment_) for (int i = 0 ; i < xlsx_comment_.size(); i++)
{ {
const _xlsx_comment & c = xlsx_comment_[i];
CP_XML_NODE(L"comment") CP_XML_NODE(L"comment")
{ {
CP_XML_ATTR(L"ref", c.ref_); CP_XML_ATTR(L"ref", c.ref_);
......
...@@ -50,9 +50,9 @@ class xlsx_comments ...@@ -50,9 +50,9 @@ class xlsx_comments
public: public:
xlsx_comments(); xlsx_comments();
~xlsx_comments(); ~xlsx_comments();
static xlsx_comments_ptr create(); static xlsx_comments_ptr create();
public:
void add(_xlsx_comment & d); void add(_xlsx_comment & d);
bool empty() const; bool empty() const;
......
...@@ -93,11 +93,11 @@ public: ...@@ -93,11 +93,11 @@ public:
xlsx_comments_->add(d); xlsx_comments_->add(d);
} }
void write_comments(std::wostream & strm) void serialize(std::wostream & strm)
{ {
xlsx_serialize(strm, *xlsx_comments_); xlsx_serialize(strm, *xlsx_comments_);
} }
void write_comments_vml(std::wostream & strm) void serialize_vml(std::wostream & strm)
{ {
xlsx_serialize_vml(strm, *xlsx_comments_); xlsx_serialize_vml(strm, *xlsx_comments_);
} }
...@@ -166,13 +166,13 @@ bool xlsx_comments_context::empty() const ...@@ -166,13 +166,13 @@ bool xlsx_comments_context::empty() const
return impl_->empty(); return impl_->empty();
} }
void xlsx_comments_context::write_comments(std::wostream & strm) void xlsx_comments_context::serialize(std::wostream & strm)
{ {
impl_->write_comments(strm); impl_->serialize(strm);
} }
void xlsx_comments_context::write_comments_vml(std::wostream & strm) void xlsx_comments_context::serialize_vml(std::wostream & strm)
{ {
impl_->write_comments_vml(strm); impl_->serialize_vml(strm);
} }
xlsx_comments_ptr xlsx_comments_context::get_comments() xlsx_comments_ptr xlsx_comments_context::get_comments()
......
...@@ -54,8 +54,8 @@ public: ...@@ -54,8 +54,8 @@ public:
bool empty() const; bool empty() const;
void write_comments(std::wostream & strm); void serialize (std::wostream & strm);
void write_comments_vml(std::wostream & strm); void serialize_vml (std::wostream & strm);
xlsx_comments_ptr get_comments(); xlsx_comments_ptr get_comments();
private: private:
......
#include "xlsx_conditionalFormatting.h"
#include "xlsx_utils.h"
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../formulasconvert/formulasconvert.h"
namespace cpdoccore {
namespace oox {
struct _cfvo
{
int type;
_CP_OPT(bool) gte;
_CP_OPT(std::wstring) val;
void serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"cfvo")
{
switch(type)
{
case 0: CP_XML_ATTR(L"type", L"percent"); break;
case 1: CP_XML_ATTR(L"type", L"num"); break;
case 2: CP_XML_ATTR(L"type", L"max"); break;
case 3: CP_XML_ATTR(L"type", L"min"); break;
case 4: CP_XML_ATTR(L"type", L"max"); break; //todooo ext - autoMax
case 5: CP_XML_ATTR(L"type", L"min"); break;
}
if (val)
CP_XML_ATTR(L"val", *val);
}
}
}
};
struct rule
{
int type;
_CP_OPT(int) dxfId;
_CP_OPT(bool) percent;
_CP_OPT(bool) stopIfTrue;
_CP_OPT(std::wstring) operator_;
//expr
_CP_OPT(std::wstring) formula;
//color scale icon set data_bar
std::vector<_cfvo> cfvo;
//color scale data_bar(1 element)
std::vector<std::wstring> color;
//data_bar icon_set
_CP_OPT(bool) showValue;
//data_bar
_CP_OPT(int) minLength;
_CP_OPT(int) maxLength;
//icon set
_CP_OPT(bool) reverse;
_CP_OPT(bool) iconset_percent;
_CP_OPT(int) iconset_type;
};
struct conditionalFormatting
{
std::wstring ref;
std::vector<rule> rules;
};
class xlsx_conditionalFormatting_context::Impl
{
public:
void serialize(std::wostream & _Wostream)
{
if (!conditionalFormattings_.empty())
{
int priority = 1;
CP_XML_WRITER(_Wostream)
{
for (int i = 0 ; i < conditionalFormattings_.size(); i++)
{
conditionalFormatting & c = conditionalFormattings_[i];
CP_XML_NODE(L"conditionalFormatting")
{
CP_XML_ATTR(L"sqref", c.ref);
for (int j = 0 ; j < c.rules.size(); j++)
{
if (c.rules[j].type < 1 || c.rules[j].type > 4) continue;
CP_XML_NODE(L"cfRule")
{
CP_XML_ATTR(L"priority", priority++);
if (c.rules[j].dxfId) CP_XML_ATTR(L"dxfId", *c.rules[j].dxfId);
if (c.rules[j].percent) CP_XML_ATTR(L"percent", *c.rules[j].percent);
if (c.rules[j].operator_) CP_XML_ATTR(L"operator", *c.rules[j].operator_);
if (c.rules[j].stopIfTrue) CP_XML_ATTR(L"stopIfTrue", *c.rules[j].stopIfTrue);
//CP_XML_ATTR(L"text" , L"");
//CP_XML_ATTR(L"rank" , 0);
//CP_XML_ATTR(L"bottom" , 0);
//CP_XML_ATTR(L"equalAverage" , 0);
//CP_XML_ATTR(L"aboveAverage" , 0);
if (c.rules[j].type == 1)
{
CP_XML_ATTR(L"type", L"expression");
if (c.rules[j].formula)
{
CP_XML_NODE(L"formula")
{
CP_XML_CONTENT(*c.rules[j].formula);
}
}
}
else if (c.rules[j].type == 2)
{
CP_XML_ATTR(L"type", L"dataBar");
CP_XML_NODE(L"dataBar")
{
if (c.rules[j].showValue) CP_XML_ATTR(L"showValue", *c.rules[j].showValue);
if (c.rules[j].minLength) CP_XML_ATTR(L"minLength", *c.rules[j].minLength);
if (c.rules[j].maxLength) CP_XML_ATTR(L"maxLength", *c.rules[j].maxLength);
for (int k = 0; k < c.rules[j].cfvo.size(); k++)
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
if (c.rules[j].color.size() > 0)
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"rgb", c.rules[j].color[0]);
}
}
}
}
else if (c.rules[j].type == 3)
{
CP_XML_ATTR(L"type", L"colorScale");
CP_XML_NODE(L"colorScale")
{
for (int k = 0; k < c.rules[j].cfvo.size(); k++)
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
for (int k = 0; k < c.rules[j].color.size(); k++)
{
CP_XML_NODE(L"color")
{
CP_XML_ATTR(L"rgb", c.rules[j].color[k]);
}
}
}
}
else if (c.rules[j].type == 4)
{
CP_XML_ATTR(L"type", L"iconSet");
CP_XML_NODE(L"iconSet")
{
if (c.rules[j].showValue) CP_XML_ATTR(L"showValue", *c.rules[j].showValue);
for (int k = 0; k < c.rules[j].cfvo.size(); k++)
{
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
}
}
}
}
}
}
}
}
}
}
std::vector<conditionalFormatting> conditionalFormattings_;
};
xlsx_conditionalFormatting_context::xlsx_conditionalFormatting_context() :
impl_(new xlsx_conditionalFormatting_context::Impl())
{}
xlsx_conditionalFormatting_context::~xlsx_conditionalFormatting_context()
{
}
void xlsx_conditionalFormatting_context::serialize(std::wostream & _Wostream)
{
return impl_->serialize(_Wostream);
}
void xlsx_conditionalFormatting_context::add(std::wstring ref)
{
formulasconvert::odf2oox_converter converter;
impl_->conditionalFormattings_.push_back(conditionalFormatting());
ref = converter.convert_named_ref(ref);
//'Fitness Plan'!N20:'Fitness Plan'!P22; K25 -> N20:P22
int pos_cells = ref.find(L":");
std::wstring ref2;
if (pos_cells >0)
{
ref2 = ref.substr(pos_cells + 1);
ref = ref.substr(0, pos_cells);
pos_cells = ref2.find(L"!");
if (pos_cells > 0)
ref2 = ref2.substr(pos_cells + 1);
}
pos_cells = ref.find(L"!");
if (pos_cells > 0)
ref = ref.substr(pos_cells + 1);
if (!ref2.empty()) ref += L":" + ref2;
impl_->conditionalFormattings_.back().ref = ref;
}
void xlsx_conditionalFormatting_context::add_rule(int type)
{
impl_->conditionalFormattings_.back().rules.push_back(rule());
impl_->conditionalFormattings_.back().rules.back().type = type;
}
void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
{
int pos = f.find(L"formula-is(");
if ( pos >= 0 )
{
f = f.substr(11, f.size() - 12);
}
formulasconvert::odf2oox_converter converter;
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert_named_expr(f);
}
void xlsx_conditionalFormatting_context::set_dataBar(_CP_OPT(int) min, _CP_OPT(int) max)
{
impl_->conditionalFormattings_.back().rules.back().minLength = min;
impl_->conditionalFormattings_.back().rules.back().maxLength = max;
}
void xlsx_conditionalFormatting_context::set_dxf(int dxfId)
{
impl_->conditionalFormattings_.back().rules.back().dxfId = dxfId;
}
void xlsx_conditionalFormatting_context::add_sfv(int type, std::wstring value)
{
_cfvo cfvo;
cfvo.type = type;
if (!value.empty()) cfvo.val = value;
impl_->conditionalFormattings_.back().rules.back().cfvo.push_back(cfvo);
}
void xlsx_conditionalFormatting_context::add_color(std::wstring col)
{
impl_->conditionalFormattings_.back().rules.back().color.push_back(col);
}
void xlsx_conditionalFormatting_context::set_showVal(bool val)
{
impl_->conditionalFormattings_.back().rules.back().showValue = val;
}
}
}
#pragma once
#include <cpdoccore/CPOptional.h>
#include <cpdoccore/CPScopedPtr.h>
#include <string>
namespace cpdoccore {
namespace oox {
class xlsx_conditionalFormatting_context
{
public:
xlsx_conditionalFormatting_context();
~xlsx_conditionalFormatting_context();
void add(std::wstring ref);
void add_rule(int type);
void set_formula(std::wstring f);
void set_dataBar(_CP_OPT(int) min, _CP_OPT(int) max);
void set_dxf (int dxf_id);
void set_showVal(bool val);
void add_sfv (int type, std::wstring value);
void add_color (std::wstring col);
void serialize(std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); } mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); }
void write_drawing(std::wostream & strm) void serialize(std::wostream & strm)
{ {
xlsx_serialize(strm, *xlsx_drawings_); xlsx_serialize(strm, *xlsx_drawings_);
} }
...@@ -581,9 +581,9 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio ...@@ -581,9 +581,9 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
} }
} }
void xlsx_drawing_context::write_drawing(std::wostream & strm) void xlsx_drawing_context::serialize(std::wostream & strm)
{ {
impl_->write_drawing(strm); impl_->serialize(strm);
} }
......
...@@ -88,7 +88,7 @@ public: ...@@ -88,7 +88,7 @@ public:
bool empty() const; bool empty() const;
void clear(); void clear();
void write_drawing(std::wostream & strm); void serialize(std::wostream & strm);
std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h); std::wstring dump_path(std::vector<svg_path::_polyline> & path, double w,double h);
xlsx_drawings_ptr get_drawings(); xlsx_drawings_ptr get_drawings();
......
#include "xlsx_dxfs.h"
#include "xlsx_fill.h"
#include "xlsx_font.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include <ostream>
#include <vector>
namespace cpdoccore {
namespace oox {
struct xlsx_dxf
{
xlsx_fill fill;
xlsx_font font;
};
class xlsx_dxfs::Impl
{
public:
Impl(){}
std::vector<xlsx_dxf> dxf_array;
};
xlsx_dxfs::xlsx_dxfs(): impl_( new xlsx_dxfs::Impl() )
{
}
xlsx_dxfs::~xlsx_dxfs()
{
}
size_t xlsx_dxfs::dxfId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{
xlsx_dxf dxf;
dxf.fill = xlsx_fill( graphProp, cellProp);
dxf.font = xlsx_font( textProp, NULL, cellProp);
impl_->dxf_array.push_back(dxf);
return impl_->dxf_array.size() - 1;
}
void xlsx_dxfs::serialize(std::wostream & _Wostream) const
{
if (impl_->dxf_array.size() < 1) return;
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"dxfs")
{
CP_XML_ATTR(L"count", impl_->dxf_array.size());
for (int i = 0; i < impl_->dxf_array.size(); i++)
{
CP_XML_NODE(L"dxf")
{
xlsx_serialize(CP_XML_STREAM(), impl_->dxf_array[i].fill);
xlsx_serialize(CP_XML_STREAM(), impl_->dxf_array[i].font);
}
}
}
}
}
}
}
#pragma once
#include <iosfwd>
#include <string>
#include <cpdoccore/CPScopedPtr.h>
namespace cpdoccore {
namespace odf_reader {
class text_format_properties_content;
class graphic_format_properties;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
namespace oox {
class xlsx_dxfs
{
public:
xlsx_dxfs();
~xlsx_dxfs();
size_t dxfId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
void serialize(std::wostream & _Wostream) const;
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}
#include "xlsx_fill.h" #include "xlsx_fill.h"
#include "../odf/style_table_properties.h"
#include "../odf/style_graphic_properties.h"
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <boost/functional/hash/hash.hpp> #include <boost/functional/hash/hash.hpp>
namespace cpdoccore { namespace cpdoccore {
...@@ -50,7 +51,7 @@ std::size_t hash_value(xlsx_patternFill const & val) ...@@ -50,7 +51,7 @@ std::size_t hash_value(xlsx_patternFill const & val)
void xlsx_serialize(std::wostream & _Wostream, const xlsx_gradientFill & gradientFill) void xlsx_serialize(std::wostream & _Wostream, const xlsx_gradientFill & gradientFill)
{ {
// TODO // todooo
} }
std::size_t hash_value(xlsx_gradientFill const & val) std::size_t hash_value(xlsx_gradientFill const & val)
...@@ -70,27 +71,19 @@ bool xlsx_gradientFill::operator != (const xlsx_gradientFill & rVal) const ...@@ -70,27 +71,19 @@ bool xlsx_gradientFill::operator != (const xlsx_gradientFill & rVal) const
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fill & fill) void xlsx_serialize(std::wostream & _Wostream, const xlsx_fill & fill)
{ {
if (!fill.patternFill && !fill.gradientFill) return;
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"fill") CP_XML_NODE(L"fill")
{ {
if (fill.patternFill) if (fill.patternFill)
xlsx_serialize(CP_XML_STREAM(), fill.patternFill.get()); xlsx_serialize(CP_XML_STREAM(), *fill.patternFill);
if (fill.gradientFill) if (fill.gradientFill)
xlsx_serialize(CP_XML_STREAM(), fill.gradientFill.get()); xlsx_serialize(CP_XML_STREAM(), *fill.gradientFill);
} }
} }
//_Wostream << L"<fill>";
//if (fill.patternFill)
// xlsx_serialize(_Wostream, fill.patternFill.get());
//if (fill.gradientFill)
// xlsx_serialize(_Wostream, fill.gradientFill.get());
//
//_Wostream << L"</fill>";
} }
std::size_t hash_value(xlsx_fill const & val) std::size_t hash_value(xlsx_fill const & val)
...@@ -112,5 +105,31 @@ bool xlsx_fill::operator != (const xlsx_fill & rVal) const ...@@ -112,5 +105,31 @@ bool xlsx_fill::operator != (const xlsx_fill & rVal) const
return !(this->operator ==(rVal)); return !(this->operator ==(rVal));
} }
xlsx_fill::xlsx_fill( const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{
bEnabled = false;
bDefault = false;
if (cellProp)
{
if (_CP_OPT(odf_types::background_color) bgClr = cellProp->common_background_color_attlist_.fo_background_color_)
{
if (bgClr->get_type() != odf_types::background_color::Transparent)
{
bEnabled = true;
xlsx_color color;
// alfa + rgb
color.rgb = L"ff" + bgClr->get_color().get_hex_value();
patternFill = xlsx_patternFill();
patternFill->bgColor = color;
patternFill->fgColor = color;
patternFill->patternType = L"solid";
}
}
}
}
} }
} }
...@@ -4,6 +4,15 @@ ...@@ -4,6 +4,15 @@
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
#include "xlsx_color.h" #include "xlsx_color.h"
namespace cpdoccore {
namespace odf_reader {
class paragraph_format_properties;
class style_table_cell_properties_attlist;
class graphic_format_properties;
}
}
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -27,14 +36,21 @@ namespace oox { ...@@ -27,14 +36,21 @@ namespace oox {
struct xlsx_fill struct xlsx_fill
{ {
xlsx_fill() {}
xlsx_fill( const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
_CP_OPT(xlsx_patternFill) patternFill; _CP_OPT(xlsx_patternFill) patternFill;
_CP_OPT(xlsx_gradientFill) gradientFill; _CP_OPT(xlsx_gradientFill) gradientFill;
std::size_t index; std::size_t index;
bool bDefault; bool bDefault;
bool bEnabled;
bool operator == (const xlsx_fill & rVal) const; bool operator == (const xlsx_fill & rVal) const;
bool operator != (const xlsx_fill & rVal) const; bool operator != (const xlsx_fill & rVal) const;
friend std::size_t hash_value(xlsx_fill const & val); friend std::size_t hash_value(xlsx_fill const & val);
}; };
......
#include "xlsx_fill.h" #include "xlsx_fill.h"
#include "xlsx_fills.h" #include "xlsx_fills.h"
#include "../odf/style_table_properties.h"
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/functional.hpp> #include <boost/functional.hpp>
#include <boost/unordered_set.hpp> #include <boost/unordered_set.hpp>
...@@ -18,12 +16,12 @@ public: ...@@ -18,12 +16,12 @@ public:
typedef boost::unordered_set<xlsx_fill, boost::hash<xlsx_fill> > xlsx_fill_array; typedef boost::unordered_set<xlsx_fill, boost::hash<xlsx_fill> > xlsx_fill_array;
// typedef std::vector<xlsx_fill> xlsx_fill_array;
xlsx_fill_array fills_; xlsx_fill_array fills_;
}; };
xlsx_fills::xlsx_fills(): impl_( new xlsx_fills::Impl() ) xlsx_fills::xlsx_fills(): impl_( new xlsx_fills::Impl() )
{ {
//defaults fill
{ {
xlsx_patternFill patternFill; xlsx_patternFill patternFill;
patternFill.patternType = L"none"; patternFill.patternType = L"none";
...@@ -59,7 +57,7 @@ size_t xlsx_fills::size() const ...@@ -59,7 +57,7 @@ size_t xlsx_fills::size() const
return impl_->fills_.size(); return impl_->fills_.size();
} }
size_t xlsx_fills::fillId(const odf_reader::text_format_properties_content * textProp, size_t xlsx_fills::fillId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set) const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set)
{ {
...@@ -67,36 +65,22 @@ size_t xlsx_fills::fillId(const odf_reader::text_format_properties_content * tex ...@@ -67,36 +65,22 @@ size_t xlsx_fills::fillId(const odf_reader::text_format_properties_content * tex
return fillId(textProp, parProp, cellProp,default_set, is_default); return fillId(textProp, parProp, cellProp,default_set, is_default);
} }
size_t xlsx_fills::fillId(const odf_reader::text_format_properties_content * textProp, size_t xlsx_fills::fillId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set, bool & is_default) const odf_reader::style_table_cell_properties_attlist * cellProp,
bool default_set, bool & is_default)
{ {
is_default = true; is_default = true;
if (cellProp) xlsx_fill fill(NULL, cellProp);
{
if (_CP_OPT(odf_types::background_color) bgClr = cellProp->common_background_color_attlist_.fo_background_color_)
{
if (bgClr->get_type() != odf_types::background_color::Transparent)
{
xlsx_color color;
// alfa + rgb
color.rgb = L"ff" + bgClr->get_color().get_hex_value();
xlsx_patternFill patternFill;
patternFill.bgColor = color;
patternFill.fgColor = color;
patternFill.patternType = L"solid";
xlsx_fill fill; if (fill.bEnabled)
fill.patternFill = patternFill; {
fill.bDefault = default_set; fill.bDefault = default_set;
Impl::xlsx_fill_array::const_iterator i = impl_->fills_.find(fill); Impl::xlsx_fill_array::const_iterator i = impl_->fills_.find(fill);
if (i != impl_->fills_.end()) if (i != impl_->fills_.end())
{ {
//const unsigned int dbgId = i - impl_->fills_.begin();
const std::size_t dbgId = i->index; const std::size_t dbgId = i->index;
if (default_set && i->bDefault != default_set) if (default_set && i->bDefault != default_set)
{ {
...@@ -120,9 +104,7 @@ size_t xlsx_fills::fillId(const odf_reader::text_format_properties_content * tex ...@@ -120,9 +104,7 @@ size_t xlsx_fills::fillId(const odf_reader::text_format_properties_content * tex
return fill.index; return fill.index;
} }
} }
}
}
// TODO
return 0; return 0;
} }
...@@ -139,7 +121,7 @@ struct compare_xlsx_fills ...@@ -139,7 +121,7 @@ struct compare_xlsx_fills
} }
void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const void xlsx_fills::serialize(std::wostream & _Wostream) const
{ {
std::vector<xlsx_fill> inst_array; std::vector<xlsx_fill> inst_array;
...@@ -155,9 +137,10 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const ...@@ -155,9 +137,10 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const
CP_XML_NODE(L"fills") CP_XML_NODE(L"fills")
{ {
CP_XML_ATTR(L"count", inst_array.size()); CP_XML_ATTR(L"count", inst_array.size());
BOOST_FOREACH(const xlsx_fill & f, inst_array)
for (int i = 0; i < inst_array.size(); i++)
{ {
cpdoccore::oox::xlsx_serialize(CP_XML_STREAM(), f); xlsx_serialize(CP_XML_STREAM(), inst_array[i]);
} }
} }
} }
...@@ -170,10 +153,5 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const ...@@ -170,10 +153,5 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const
//_Wostream << L"</fills>"; //_Wostream << L"</fills>";
} }
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills)
{
fills.xlsx_serialize(_Wostream);
}
} }
} }
...@@ -12,7 +12,6 @@ namespace odf_reader { ...@@ -12,7 +12,6 @@ namespace odf_reader {
class text_format_properties_content; class text_format_properties_content;
class paragraph_format_properties; class paragraph_format_properties;
class style_table_cell_properties_attlist; class style_table_cell_properties_attlist;
} }
} }
...@@ -26,22 +25,21 @@ namespace oox { ...@@ -26,22 +25,21 @@ namespace oox {
~xlsx_fills(); ~xlsx_fills();
public: public:
size_t size() const; size_t size() const;
size_t fillId(const odf_reader::text_format_properties_content * textProp,
size_t fillId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set); const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set);
size_t fillId(const odf_reader::text_format_properties_content * textProp, size_t fillId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set,bool & is_default); const odf_reader::style_table_cell_properties_attlist * cellProp, bool default_set,bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const; void serialize(std::wostream & _Wostream) const;
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
}; };
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills);
} }
} }
#include "xlsx_font.h" #include "xlsx_font.h"
#include <boost/foreach.hpp>
#include "../odf/style_text_properties.h"
#include "../odf/style_table_properties.h"
#include "../odf/style_paragraph_properties.h"
#include <boost/functional.hpp> #include <boost/functional.hpp>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_text_properties.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -177,56 +180,6 @@ void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font) ...@@ -177,56 +180,6 @@ void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font)
} }
} }
/*
_Wostream << L"<font>";
if (font.bold)
_Wostream << L"<b val=\"" << (int)(*font.bold) << "\" />";
if (font.charset)
_Wostream << L"<charset val=\"" << *font.charset << "\" />";
if (font.color)
xlsx_serialize(_Wostream, *font.color);
if (font.condense)
_Wostream << L"<condense val=\"" << (int)(*font.condense) << "\" />";
if (font.extend)
_Wostream << L"<extend val=\"" << (int)(*font.extend) << "\" />";
if (font.family)
_Wostream << L"<family val=\"" << (int)(*font.family) << "\" />";
if (font.i)
_Wostream << L"<i val=\"" << (int)(*font.i) << "\" />";
if (font.name)
_Wostream << L"<name val=\"" << *font.name << "\" />";
if (font.outline)
_Wostream << L"<outline val=\"" << (int)(*font.outline) << "\" />";
if (font.scheme)
_Wostream << L"<scheme val=\"" << *font.scheme << "\" />";
if (font.shadow)
_Wostream << L"<shadow val=\"" << (int)(*font.shadow) << "\" />";
if (font.strike)
_Wostream << L"<strike val=\"" << (int)(*font.strike) << "\" />";
if (font.sz)
_Wostream << L"<sz val=\"" << *font.sz << "\" />";
if (font.u)
_Wostream << L"<u val=\"" << *font.u << "\" />";
if (font.vertAlign)
_Wostream << L"<vertAlign val=\"" << *font.vertAlign << "\" />";
_Wostream << L"</font>";
*/
} }
bool xlsx_font::operator == (const xlsx_font & rVal) const bool xlsx_font::operator == (const xlsx_font & rVal) const
...@@ -276,5 +229,113 @@ std::size_t hash_value(xlsx_font const & val) ...@@ -276,5 +229,113 @@ std::size_t hash_value(xlsx_font const & val)
boost::hash_combine(seed, val.vertAlign.get_value_or(vertAlignBaseline)); boost::hash_combine(seed, val.vertAlign.get_value_or(vertAlignBaseline));
return seed; return seed;
} }
//----------------------------------------------------------------------------------
XlsxFontCharset GetXlsxFontCharset(const odf_reader::text_format_properties_content * textProp)
{
// TODO
return XCHARSET_EMPTY;
}
XlsxFontFamily GetXlsxFontFamily(const odf_reader::text_format_properties_content * textProp)
{
// TODO
return XFAMILY_EMPTY;
}
xlsx_font::xlsx_font ( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{
bEnabled = false;
if (!textProp) return;
bEnabled = true;
if (textProp->fo_font_weight_)
{
if (textProp->fo_font_weight_.get().get_type() == odf_types::font_weight::WBold)
bold = true;
else
bold = false;
}
if (textProp->fo_font_style_)
{
if (textProp->fo_font_style_.get().get_type() == odf_types::font_style::Italic)
i = true;
else
i = false;
}
XlsxFontCharset charset_ = GetXlsxFontCharset(textProp);
if (charset_ != XCHARSET_EMPTY)
{
charset = (unsigned int)charset_;
}
XlsxFontFamily family_ = GetXlsxFontFamily(textProp);
if (family_ != XFAMILY_EMPTY)
{
family = family_;
}
if (textProp->style_font_name_)
{
name = textProp->style_font_name_.get();
}
if (textProp->fo_font_size_)
{
sz = textProp->fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
}
//else
//{
// sz = 10.;//kDefaultFontSize; //todooo ... math
//}
if (textProp->style_text_underline_type_ &&
textProp->style_text_underline_type_->get_type() != odf_types::line_type::Non ||
textProp->style_text_underline_style_ &&
textProp->style_text_underline_style_->get_type() != odf_types::line_style::None
)
{
if (textProp->style_text_underline_type_ &&
textProp->style_text_underline_type_->get_type() == odf_types::line_type::Double)
u = XUNDERLINE_DOUBLE;
else
u = XUNDERLINE_SINGLE;
}
if (textProp->style_text_line_through_type_ &&
textProp->style_text_line_through_type_->get_type() != odf_types::line_type::Non ||
textProp->style_text_line_through_style_ &&
textProp->style_text_line_through_style_->get_type() != odf_types::line_style::None)
{
strike = true;
}
if (textProp->fo_text_shadow_)
{
if (textProp->fo_text_shadow_->get_type() == odf_types::shadow_type::Enable)
shadow = true;
else
shadow = false;
}
bool default_color = false;
if (textProp->style_use_window_font_color_)
default_color = true;
if (textProp->fo_color_ && !default_color)
{
color = xlsx_color();
color->rgb = L"ff" + textProp->fo_color_->get_hex_value();
}
}
} }
} }
#ifndef _CPDOCCORE_XLSX_FONT_H_INCLUDED
#define _CPDOCCORE_XLSX_FONT_H_INCLUDED
#pragma once #pragma once
#include <iosfwd> #include <iosfwd>
...@@ -9,6 +7,15 @@ ...@@ -9,6 +7,15 @@
#include "xlsx_color.h" #include "xlsx_color.h"
namespace cpdoccore {
namespace odf_reader {
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
}
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -65,6 +72,13 @@ namespace oox { ...@@ -65,6 +72,13 @@ namespace oox {
struct xlsx_font struct xlsx_font
{ {
xlsx_font () {};
xlsx_font ( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
bool bEnabled;
_CP_OPT(bool) bold; _CP_OPT(bool) bold;
_CP_OPT(unsigned int) charset; _CP_OPT(unsigned int) charset;
_CP_OPT(xlsx_color) color; _CP_OPT(xlsx_color) color;
...@@ -90,8 +104,6 @@ namespace oox { ...@@ -90,8 +104,6 @@ namespace oox {
}; };
void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font); void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font);
} }
} }
#endif
#include "xlsx_font.h"
#include "xlsx_fonts.h" #include "xlsx_fonts.h"
#include "xlsx_font.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/functional.hpp> #include <boost/functional.hpp>
#include <boost/unordered_set.hpp> #include <boost/unordered_set.hpp>
#include "../odf/style_text_properties.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
namespace
{
const double kDefaultFontSize = 10.0;
}
namespace
{
XlsxFontCharset GetXlsxFontCharset(const odf_reader::text_format_properties_content * textProp)
{
// TODO
return XCHARSET_EMPTY;
}
XlsxFontFamily GetXlsxFontFamily(const odf_reader::text_format_properties_content * textProp)
{
// TODO
return XFAMILY_EMPTY;
}
xlsx_font OdfFont2XlsxFont(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{
xlsx_font font;
if (!textProp)
return font;
if (textProp->fo_font_weight_)
{
if (textProp->fo_font_weight_.get().get_type() == odf_types::font_weight::WBold)
font.bold = true;
else
font.bold = false;
}
if (textProp->fo_font_style_)
{
if (textProp->fo_font_style_.get().get_type() == odf_types::font_style::Italic)
font.i = true;
else
font.i = false;
}
XlsxFontCharset charset = GetXlsxFontCharset(textProp);
if (charset != XCHARSET_EMPTY)
{
font.charset = (unsigned int)charset;
}
XlsxFontFamily family = GetXlsxFontFamily(textProp);
if (family != XFAMILY_EMPTY)
{
font.family = family;
}
if (textProp->style_font_name_)
{
font.name = textProp->style_font_name_.get();
}
if (textProp->fo_font_size_)
{
font.sz = textProp->fo_font_size_->get_length().get_value_unit(odf_types::length::pt);
}
else
{
font.sz = kDefaultFontSize;
}
if (textProp->style_text_underline_type_ &&
textProp->style_text_underline_type_->get_type() != odf_types::line_type::Non ||
textProp->style_text_underline_style_ &&
textProp->style_text_underline_style_->get_type() != odf_types::line_style::None
)
{
if (textProp->style_text_underline_type_ &&
textProp->style_text_underline_type_->get_type() == odf_types::line_type::Double)
font.u = XUNDERLINE_DOUBLE;
else
font.u = XUNDERLINE_SINGLE;
}
if (textProp->style_text_line_through_type_ &&
textProp->style_text_line_through_type_->get_type() != odf_types::line_type::Non ||
textProp->style_text_line_through_style_ &&
textProp->style_text_line_through_style_->get_type() != odf_types::line_style::None)
{
font.strike = true;
}
if (textProp->fo_text_shadow_)
{
if (textProp->fo_text_shadow_->get_type() == odf_types::shadow_type::Enable)
font.shadow = true;
else
font.shadow = false;
}
bool default_color = false;
if (textProp->style_use_window_font_color_)
default_color = true;
if (textProp->fo_color_ && !default_color)
{
xlsx_color color;
// alfa + rgb
color.rgb = L"ff" + textProp->fo_color_->get_hex_value();
std::wstring test = color.rgb.get();
font.color = color;
}
return font;
}
} // namespace
class xlsx_fonts::Impl class xlsx_fonts::Impl
{ {
public: public:
Impl() Impl(){}
{
}
size_t size() const; size_t size() const;
size_t fontId(const odf_reader::text_format_properties_content * textProp, size_t fontId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp); const odf_reader::style_table_cell_properties_attlist * cellProp);
//const xlsx_font & getFont(size_t id) const;
void xlsx_serialize(std::wostream & _Wostream) const;
private: void serialize(std::wostream & _Wostream) const;
/*int getIndex(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp) const;*/
private: private:
typedef boost::unordered_set<xlsx_font, boost::hash<xlsx_font> > fonts_array_t; typedef boost::unordered_set<xlsx_font, boost::hash<xlsx_font> > fonts_array_t;
...@@ -169,7 +44,7 @@ struct compare_xlsx_fonts ...@@ -169,7 +44,7 @@ struct compare_xlsx_fonts
} }
void xlsx_fonts::Impl::xlsx_serialize(std::wostream & _Wostream) const void xlsx_fonts::Impl::serialize(std::wostream & _Wostream) const
{ {
std::vector<xlsx_font> fonts; std::vector<xlsx_font> fonts;
...@@ -180,19 +55,25 @@ void xlsx_fonts::Impl::xlsx_serialize(std::wostream & _Wostream) const ...@@ -180,19 +55,25 @@ void xlsx_fonts::Impl::xlsx_serialize(std::wostream & _Wostream) const
std::sort(fonts.begin(), fonts.end(), compare_xlsx_fonts()); std::sort(fonts.begin(), fonts.end(), compare_xlsx_fonts());
_Wostream << L"<fonts count=\"" << fonts.size() << "\">"; CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"fonts")
{
CP_XML_ATTR(L"count", fonts.size());
for (size_t i = 0; i < fonts.size(); ++i) for (size_t i = 0; i < fonts.size(); ++i)
::cpdoccore::oox::xlsx_serialize(_Wostream, fonts[i]); {
xlsx_serialize(CP_XML_STREAM(), fonts[i]);
_Wostream << L"</fonts>"; }
}
}
} }
size_t xlsx_fonts::Impl::fontId(const odf_reader::text_format_properties_content * textProp, size_t xlsx_fonts::Impl::fontId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp) const odf_reader::style_table_cell_properties_attlist * cellProp)
{ {
xlsx_font fnt = OdfFont2XlsxFont(textProp, parProp, cellProp); xlsx_font fnt = xlsx_font(textProp, parProp, cellProp);
fonts_array_t::const_iterator i = fonts_.find(fnt); fonts_array_t::const_iterator i = fonts_.find(fnt);
if (i != fonts_.end()) if (i != fonts_.end())
return i->index; return i->index;
...@@ -228,12 +109,6 @@ int xlsx_fonts::Impl::getIndex(const odf_reader::text_format_properties_content ...@@ -228,12 +109,6 @@ int xlsx_fonts::Impl::getIndex(const odf_reader::text_format_properties_content
size_t xlsx_fonts::Impl::size() const { return fonts_.size(); } size_t xlsx_fonts::Impl::size() const { return fonts_.size(); }
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fonts & fonts)
{
fonts.xlsx_serialize(_Wostream);
}
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
xlsx_fonts::xlsx_fonts(): impl_(new xlsx_fonts::Impl()) xlsx_fonts::xlsx_fonts(): impl_(new xlsx_fonts::Impl())
...@@ -249,9 +124,9 @@ size_t xlsx_fonts::size() const ...@@ -249,9 +124,9 @@ size_t xlsx_fonts::size() const
return impl_->size(); return impl_->size();
} }
void xlsx_fonts::xlsx_serialize(std::wostream & _Wostream) const void xlsx_fonts::serialize(std::wostream & _Wostream) const
{ {
return impl_->xlsx_serialize(_Wostream); return impl_->serialize(_Wostream);
} }
size_t xlsx_fonts::fontId(const odf_reader::text_format_properties_content * textProp, size_t xlsx_fonts::fontId(const odf_reader::text_format_properties_content * textProp,
......
...@@ -9,7 +9,6 @@ namespace odf_reader { ...@@ -9,7 +9,6 @@ namespace odf_reader {
class text_format_properties_content; class text_format_properties_content;
class paragraph_format_properties; class paragraph_format_properties;
class style_table_cell_properties_attlist; class style_table_cell_properties_attlist;
} }
} }
...@@ -26,20 +25,19 @@ namespace oox { ...@@ -26,20 +25,19 @@ namespace oox {
public: public:
size_t size() const; size_t size() const;
size_t fontId(const odf_reader::text_format_properties_content * textProp,
size_t fontId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp); const odf_reader::style_table_cell_properties_attlist * cellProp);
const xlsx_font & getFont(size_t id) const; const xlsx_font & getFont(size_t id) const;
void xlsx_serialize(std::wostream & _Wostream) const; void serialize(std::wostream & _Wostream) const;
private: private:
class Impl; class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
}; };
void xlsx_serialize(std::wostream & _Wostream, xlsx_fonts const & fonts);
} }
} }
#include "xlsx_merge_cells.h" #include "xlsx_merge_cells.h"
#include "xlsx_utils.h" #include "xlsx_utils.h"
#include <ostream>
#include <vector> #include <vector>
#include <boost/foreach.hpp>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore { namespace cpdoccore {
...@@ -35,8 +34,10 @@ public: ...@@ -35,8 +34,10 @@ public:
{ {
CP_XML_ATTR(L"count", merges_.size()); CP_XML_ATTR(L"count", merges_.size());
BOOST_FOREACH(const merge & m, merges_) for (int i = 0 ; i < merges_.size(); i++)
{ {
merge & m = merges_[i];
CP_XML_NODE(L"mergeCell") CP_XML_NODE(L"mergeCell")
{ {
CP_XML_ATTR(L"ref", getCellAddress(m.c, m.r) + L":" + getCellAddress(m.c + m.cols, m.r + m.rows)); CP_XML_ATTR(L"ref", getCellAddress(m.c, m.r) + L":" + getCellAddress(m.c + m.cols, m.r + m.rows));
......
#pragma once #pragma once
#include <boost/noncopyable.hpp>
#include <cpdoccore/CPScopedPtr.h> #include <cpdoccore/CPScopedPtr.h>
namespace cpdoccore { namespace cpdoccore {
...@@ -11,9 +10,10 @@ class xlsx_merge_cells ...@@ -11,9 +10,10 @@ class xlsx_merge_cells
public: public:
xlsx_merge_cells(); xlsx_merge_cells();
xlsx_merge_cells(const xlsx_merge_cells & m); xlsx_merge_cells(const xlsx_merge_cells & m);
const xlsx_merge_cells & operator=(const xlsx_merge_cells & m); const xlsx_merge_cells & operator=(const xlsx_merge_cells & m);
~xlsx_merge_cells(); ~xlsx_merge_cells();
public:
void add_merge(size_t column, size_t row, size_t colsMerged, size_t rowsMerged); void add_merge(size_t column, size_t row, size_t colsMerged, size_t rowsMerged);
void xlsx_serialize(std::wostream & _Wostream); void xlsx_serialize(std::wostream & _Wostream);
private: private:
......
...@@ -41,7 +41,7 @@ size_t xlsx_num_fmts::num_format_id(const std::wstring & format_code) ...@@ -41,7 +41,7 @@ size_t xlsx_num_fmts::num_format_id(const std::wstring & format_code)
return impl_->num_format_id(format_code); return impl_->num_format_id(format_code);
} }
void xlsx_num_fmts::xlsx_serialize(std::wostream & _Wostream) const void xlsx_num_fmts::serialize(std::wostream & _Wostream) const
{ {
_Wostream << L"<numFmts count=\"" << impl_->formats_.size() << L"\">"; _Wostream << L"<numFmts count=\"" << impl_->formats_.size() << L"\">";
for (size_t i = 0; i < impl_->formats_.size(); ++i) for (size_t i = 0; i < impl_->formats_.size(); ++i)
...@@ -53,10 +53,7 @@ void xlsx_num_fmts::xlsx_serialize(std::wostream & _Wostream) const ...@@ -53,10 +53,7 @@ void xlsx_num_fmts::xlsx_serialize(std::wostream & _Wostream) const
_Wostream << L"</numFmts>"; _Wostream << L"</numFmts>";
} }
void xlsx_serialize(std::wostream & _Wostream, const xlsx_num_fmts & numFmts)
{
return numFmts.xlsx_serialize(_Wostream);
}
} }
} }
...@@ -17,15 +17,12 @@ namespace oox { ...@@ -17,15 +17,12 @@ namespace oox {
~xlsx_num_fmts(); ~xlsx_num_fmts();
public: public:
size_t num_format_id(const std::wstring & format_code); size_t num_format_id(const std::wstring & format_code);
void xlsx_serialize(std::wostream & _Wostream) const; void serialize(std::wostream & _Wostream) const;
private: private:
struct Impl; struct Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
}; };
void xlsx_serialize(std::wostream & _Wostream, const xlsx_num_fmts & numFmts);
} }
} }
...@@ -22,6 +22,7 @@ public: ...@@ -22,6 +22,7 @@ public:
std::wstringstream comments_; std::wstringstream comments_;
std::wstringstream sort_; std::wstringstream sort_;
std::wstringstream autofilter_; std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
rels hyperlinks_rels_; rels hyperlinks_rels_;
...@@ -72,6 +73,10 @@ std::wostream & xlsx_xml_worksheet::mergeCells() ...@@ -72,6 +73,10 @@ std::wostream & xlsx_xml_worksheet::mergeCells()
{ {
return impl_->mergeCells_; return impl_->mergeCells_;
} }
std::wostream & xlsx_xml_worksheet::conditionalFormatting()
{
return impl_->conditionalFormatting_;
}
std::wostream & xlsx_xml_worksheet::sort() std::wostream & xlsx_xml_worksheet::sort()
{ {
return impl_->sort_; return impl_->sort_;
...@@ -125,7 +130,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm) ...@@ -125,7 +130,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->sort_.str(); CP_XML_STREAM() << impl_->sort_.str();
//conditional formats CP_XML_STREAM() << impl_->conditionalFormatting_.str();
if (!impl_->hyperlinks_.str().empty()) if (!impl_->hyperlinks_.str().empty())
{ {
......
...@@ -13,7 +13,6 @@ namespace oox { ...@@ -13,7 +13,6 @@ namespace oox {
class xlsx_xml_worksheet; class xlsx_xml_worksheet;
typedef _CP_PTR(xlsx_xml_worksheet) xlsx_xml_worksheet_ptr; typedef _CP_PTR(xlsx_xml_worksheet) xlsx_xml_worksheet_ptr;
// xlsx_xml_worksheet
class xlsx_xml_worksheet: noncopyable class xlsx_xml_worksheet: noncopyable
{ {
public: public:
...@@ -30,6 +29,7 @@ public: ...@@ -30,6 +29,7 @@ public:
std::wostream & drawing(); std::wostream & drawing();
std::wostream & comments(); std::wostream & comments();
std::wostream & autofilter(); std::wostream & autofilter();
std::wostream & conditionalFormatting();
std::wostream & sort(); std::wostream & sort();
rels & hyperlinks_rels(); rels & hyperlinks_rels();
......
...@@ -12,14 +12,14 @@ namespace oox { ...@@ -12,14 +12,14 @@ namespace oox {
class xlsx_shared_strings::Impl class xlsx_shared_strings::Impl
{ {
public: public:
void xlsx_serialize(std::wostream & _Wostream) const; void serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content); size_t add(const std::wstring & content);
private: private:
std::vector<std::wstring> strings_; std::vector<std::wstring> strings_;
}; };
void xlsx_shared_strings::Impl::xlsx_serialize(std::wostream & _Wostream) const void xlsx_shared_strings::Impl::serialize(std::wostream & _Wostream) const
{ {
_Wostream << L"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"" << _Wostream << L"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"" <<
strings_.size() << "\" uniqueCount=\"" << strings_.size() << "\">"; strings_.size() << "\" uniqueCount=\"" << strings_.size() << "\">";
...@@ -48,9 +48,9 @@ xlsx_shared_strings::~xlsx_shared_strings() ...@@ -48,9 +48,9 @@ xlsx_shared_strings::~xlsx_shared_strings()
{ {
} }
void xlsx_shared_strings::xlsx_serialize(std::wostream & _Wostream) const void xlsx_shared_strings::serialize(std::wostream & _Wostream) const
{ {
return impl_->xlsx_serialize(_Wostream); return impl_->serialize(_Wostream);
} }
size_t xlsx_shared_strings::add(const std::wstring & content) size_t xlsx_shared_strings::add(const std::wstring & content)
......
...@@ -15,7 +15,7 @@ public: ...@@ -15,7 +15,7 @@ public:
~xlsx_shared_strings(); ~xlsx_shared_strings();
public: public:
void xlsx_serialize(std::wostream & _Wostream) const; void serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content); size_t add(const std::wstring & content);
private: private:
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "xlsxconversioncontext.h" #include "xlsxconversioncontext.h"
#include "xlsx_fonts.h" #include "xlsx_fonts.h"
#include "xlsx_xf.h" #include "xlsx_xf.h"
#include "xlsx_dxfs.h"
#include "xlsx_borders.h" #include "xlsx_borders.h"
#include "xlsx_fills.h" #include "xlsx_fills.h"
#include "xlsx_cell_format.h" #include "xlsx_cell_format.h"
...@@ -21,32 +22,39 @@ namespace oox { ...@@ -21,32 +22,39 @@ namespace oox {
class xlsx_style_manager::Impl class xlsx_style_manager::Impl
{ {
public: public:
//typedef std::vector<xlsx_xf> xlsx_xf_array;
typedef boost::unordered_set<xlsx_xf, boost::hash<xlsx_xf> > xlsx_xf_array; typedef boost::unordered_set<xlsx_xf, boost::hash<xlsx_xf> > xlsx_xf_array;
public:
Impl(xlsx_conversion_context * context); Impl(xlsx_conversion_context * context);
size_t size() const; size_t size() const;
size_t xfId(const odf_reader::text_format_properties_content * textProp,
size_t xfId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, const odf_reader::style_table_cell_properties_attlist * cellProp,
const xlsx_cell_format * xlxsCellFormat, const xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set, bool & is_visible); const std::wstring &num_format, bool default_set, bool & is_visible);
void xlsx_serialize(std::wostream & _Wostream); size_t dxfId( const odf_reader::text_format_properties_content * textProp,
void xlsx_serialize_xf(std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName); const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
void serialize (std::wostream & _Wostream);
void serialize_xf (std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName);
private: private:
xlsx_fonts fonts_; xlsx_fonts fonts_;
xlsx_borders borders_; xlsx_borders borders_;
xlsx_fills fills_; xlsx_fills fills_;
xlsx_num_fmts numFmts_;
xlsx_xf_array cellXfs_; xlsx_xf_array cellXfs_;
xlsx_cell_styles cellStyles_; xlsx_cell_styles cellStyles_;
xlsx_xf_array cellStyleXfs_; xlsx_xf_array cellStyleXfs_;
xlsx_num_fmts numFmts_;
private: xlsx_dxfs dxfs_;
//-------------------------------------------------
xlsx_conversion_context *context; xlsx_conversion_context *context;
size_t next_index_; size_t next_index_;
...@@ -72,6 +80,13 @@ size_t xlsx_style_manager::Impl::size() const ...@@ -72,6 +80,13 @@ size_t xlsx_style_manager::Impl::size() const
return cellXfs_.size(); return cellXfs_.size();
} }
size_t xlsx_style_manager::Impl::dxfId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{
return dxfs_.dxfId(textProp, graphProp, cellProp);
}
size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_content * textProp, size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, const odf_reader::style_table_cell_properties_attlist * cellProp,
...@@ -140,19 +155,21 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c ...@@ -140,19 +155,21 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
return id; return id;
} }
void xlsx_style_manager::Impl::xlsx_serialize(std::wostream & _Wostream) void xlsx_style_manager::Impl::serialize(std::wostream & _Wostream)
{ {
_Wostream << L"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">"; _Wostream << L"<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">";
cpdoccore::oox::xlsx_serialize(_Wostream, numFmts_); numFmts_.serialize (_Wostream);
cpdoccore::oox::xlsx_serialize(_Wostream, fonts_); fonts_.serialize (_Wostream);
cpdoccore::oox::xlsx_serialize(_Wostream, fills_); fills_.serialize (_Wostream);
cpdoccore::oox::xlsx_serialize(_Wostream, borders_); borders_.serialize (_Wostream);
serialize_xf(_Wostream, cellStyleXfs_ , L"cellStyleXfs");
serialize_xf(_Wostream, cellXfs_ , L"cellXfs");
xlsx_serialize_xf(_Wostream, cellStyleXfs_, L"cellStyleXfs"); cellStyles_.serialize(_Wostream);
xlsx_serialize_xf(_Wostream, cellXfs_, L"cellXfs");
cellStyles_.xlsx_serialize(_Wostream); dxfs_.serialize(_Wostream);
_Wostream << L"</styleSheet>"; _Wostream << L"</styleSheet>";
...@@ -169,7 +186,7 @@ namespace ...@@ -169,7 +186,7 @@ namespace
}; };
} }
void xlsx_style_manager::Impl::xlsx_serialize_xf(std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName) void xlsx_style_manager::Impl::serialize_xf(std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName)
{ {
std::vector<xlsx_xf> xfs_; std::vector<xlsx_xf> xfs_;
...@@ -216,10 +233,16 @@ size_t xlsx_style_manager::xfId(const odf_reader::text_format_properties_content ...@@ -216,10 +233,16 @@ size_t xlsx_style_manager::xfId(const odf_reader::text_format_properties_content
{ {
return impl_->xfId(textProp, parProp, cellProp, xlxsCellFormat, num_format, default_set,is_visible); return impl_->xfId(textProp, parProp, cellProp, xlxsCellFormat, num_format, default_set,is_visible);
} }
size_t xlsx_style_manager::dxfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{
return impl_->dxfId(textProp, graphProp, cellProp);
}
void xlsx_style_manager::xlsx_serialize(std::wostream & _Wostream) void xlsx_style_manager::xlsx_serialize(std::wostream & _Wostream)
{ {
return impl_->xlsx_serialize(_Wostream); return impl_->serialize(_Wostream);
} }
xlsx_style_manager::~xlsx_style_manager() xlsx_style_manager::~xlsx_style_manager()
......
...@@ -8,6 +8,7 @@ namespace cpdoccore { ...@@ -8,6 +8,7 @@ namespace cpdoccore {
namespace odf_reader { namespace odf_reader {
class text_format_properties_content; class text_format_properties_content;
class graphic_format_properties;
class paragraph_format_properties; class paragraph_format_properties;
class style_table_cell_properties_attlist; class style_table_cell_properties_attlist;
} }
...@@ -35,6 +36,9 @@ public: ...@@ -35,6 +36,9 @@ public:
const xlsx_cell_format * xlxsCellFormat, const xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set); const std::wstring &num_format, bool default_set);
size_t dxfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::graphic_format_properties * graphProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
void xlsx_serialize(std::wostream & _Wostream); void xlsx_serialize(std::wostream & _Wostream);
......
...@@ -183,7 +183,7 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned) ...@@ -183,7 +183,7 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
// //
if (columnsSpanned != 0 || rowsSpanned != 0) if (columnsSpanned != 0 || rowsSpanned != 0)
merge_cells_.add_merge(current_table_column_, current_table_row_, columnsSpanned, rowsSpanned); xlsx_merge_cells_.add_merge(current_table_column_, current_table_row_, columnsSpanned, rowsSpanned);
if ( current_columns_spaned() > 0 ) if ( current_columns_spaned() > 0 )
{ {
...@@ -368,14 +368,17 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream) ...@@ -368,14 +368,17 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
} }
void xlsx_table_state::serialize_merge_cells(std::wostream & _Wostream) void xlsx_table_state::serialize_merge_cells(std::wostream & _Wostream)
{ {
return merge_cells_.xlsx_serialize(_Wostream); return xlsx_merge_cells_.xlsx_serialize(_Wostream);
} }
void xlsx_table_state::serialize_hyperlinks(std::wostream & _Wostream) void xlsx_table_state::serialize_hyperlinks(std::wostream & _Wostream)
{ {
return xlsx_hyperlinks_.xlsx_serialize(_Wostream); return xlsx_hyperlinks_.xlsx_serialize(_Wostream);
} }
void xlsx_table_state::serialize_conditionalFormatting(std::wostream & _Wostream)
{
return xlsx_conditionalFormatting_context_.serialize(_Wostream);
}
void xlsx_table_state::dump_rels_hyperlinks(rels & Rels) void xlsx_table_state::dump_rels_hyperlinks(rels & Rels)
{ {
return xlsx_hyperlinks_.dump_rels(Rels); return xlsx_hyperlinks_.dump_rels(Rels);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "xlsx_drawing_context.h" #include "xlsx_drawing_context.h"
#include "xlsx_comments_context.h" #include "xlsx_comments_context.h"
#include "xlsx_hyperlinks.h" #include "xlsx_hyperlinks.h"
#include "xlsx_conditionalFormatting.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -51,18 +52,19 @@ public: ...@@ -51,18 +52,19 @@ public:
std::wstring current_style() const { return table_style_; } std::wstring current_style() const { return table_style_; }
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName); void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName); void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
void non_empty_row(); void non_empty_row ();
bool is_empty_row() const; bool is_empty_row () const;
void end_row(); void end_row ();
std::wstring current_row_style() const; std::wstring current_row_style () const;
std::wstring default_row_cell_style() const; std::wstring default_row_cell_style () const;
std::wstring default_column_cell_style() const; std::wstring default_column_cell_style () const;
void set_table_row_group(int count, bool collapsed, int level); void set_table_row_group(int count, bool collapsed, int level);
void start_cell(size_t columnsSpanned, size_t rowsSpanned); void start_cell(size_t columnsSpanned, size_t rowsSpanned);
void end_cell(); void end_cell();
...@@ -75,20 +77,22 @@ public: ...@@ -75,20 +77,22 @@ public:
int current_column() const; int current_column() const;
int current_row() const; int current_row() const;
unsigned int current_columns_spaned() const; unsigned int current_columns_spaned () const;
unsigned int current_rows_spanned(unsigned int Column) const; unsigned int current_rows_spanned (unsigned int Column) const;
unsigned int columns_count() const; unsigned int columns_count () const;
xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; } xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; }
xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_context_; } xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_context_; }
xlsx_comments_context & get_comments_context() { return xlsx_comments_context_; } xlsx_comments_context & get_comments_context() { return xlsx_comments_context_; }
xlsx_conditionalFormatting_context & get_conditionalFormatting_context() {return xlsx_conditionalFormatting_context_;}
void table_column_last_width(double w) { table_column_last_width_ = w; } void table_column_last_width(double w) { table_column_last_width_ = w; }
double table_column_last_width() const { return table_column_last_width_; }; double table_column_last_width() const { return table_column_last_width_; };
void start_hyperlink(); void start_hyperlink ();
std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display); std::wstring end_hyperlink (std::wstring const & ref, std::wstring const & href, std::wstring const & display);
void serialize_conditionalFormatting (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream); void serialize_table_format (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream); void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream); void serialize_hyperlinks (std::wostream & _Wostream);
...@@ -96,6 +100,7 @@ public: ...@@ -96,6 +100,7 @@ public:
std::wstring get_table_name() const { return tableName_; } std::wstring get_table_name() const { return tableName_; }
int get_table_id() const { return tableId_; } int get_table_id() const { return tableId_; }
struct _group_row struct _group_row
{ {
bool enabled; bool enabled;
...@@ -108,8 +113,8 @@ public: ...@@ -108,8 +113,8 @@ public:
friend class xlsx_table_context; friend class xlsx_table_context;
private: private:
bool in_cell;
xlsx_conversion_context * context_; xlsx_conversion_context * context_;
std::wstring tableName_; std::wstring tableName_;
int tableId_; int tableId_;
...@@ -122,6 +127,7 @@ private: ...@@ -122,6 +127,7 @@ private:
int current_table_column_; int current_table_column_;
int current_table_row_; int current_table_row_;
bool empty_row_; bool empty_row_;
bool in_cell;
unsigned int columns_spanned_num_; unsigned int columns_spanned_num_;
std::wstring columns_spanned_style_; std::wstring columns_spanned_style_;
...@@ -131,10 +137,12 @@ private: ...@@ -131,10 +137,12 @@ private:
unsigned int columns_count_; unsigned int columns_count_;
double table_column_last_width_; double table_column_last_width_;
xlsx_merge_cells merge_cells_;
xlsx_table_metrics xlsx_table_metrics_;
xlsx_drawing_context xlsx_drawing_context_; xlsx_drawing_context xlsx_drawing_context_;
xlsx_comments_context xlsx_comments_context_; xlsx_comments_context xlsx_comments_context_;
xlsx_conditionalFormatting_context xlsx_conditionalFormatting_context_;
xlsx_merge_cells xlsx_merge_cells_;
xlsx_table_metrics xlsx_table_metrics_;
xlsx_hyperlinks xlsx_hyperlinks_; xlsx_hyperlinks xlsx_hyperlinks_;
}; };
......
...@@ -273,6 +273,10 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream) ...@@ -273,6 +273,10 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
} }
} }
} }
void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
{
return state()->serialize_conditionalFormatting(_Wostream);
}
void xlsx_table_context::serialize_merge_cells(std::wostream & _Wostream) void xlsx_table_context::serialize_merge_cells(std::wostream & _Wostream)
{ {
return state()->serialize_merge_cells(_Wostream); return state()->serialize_merge_cells(_Wostream);
......
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
void serialize_autofilter (std::wostream & _Wostream); void serialize_autofilter (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream); void serialize_merge_cells (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream); void serialize_table_format (std::wostream & _Wostream);
void serialize_conditionalFormatting(std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics(); xlsx_table_metrics & get_table_metrics();
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
void start_drawing_content(); void start_drawing_content();
std::wstring end_drawing_content(); std::wstring end_drawing_content();
void write_shared_strings(std::wostream & strm); void serialize_shared_strings(std::wostream & strm);
void ApplyTextProperties (std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type); void ApplyTextProperties (std::wstring style, odf_reader::text_format_properties_content & propertiesOut, odf_types::style_family::type Type);
void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type); void ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
...@@ -95,9 +95,9 @@ private: ...@@ -95,9 +95,9 @@ private:
}; };
void xlsx_text_context::Impl::write_shared_strings(std::wostream & strm) void xlsx_text_context::Impl::serialize_shared_strings(std::wostream & strm)
{ {
xlsx_shared_strings_.xlsx_serialize(strm); xlsx_shared_strings_.serialize(strm);
} }
...@@ -603,9 +603,9 @@ std::wstring xlsx_text_context::end_drawing_content() ...@@ -603,9 +603,9 @@ std::wstring xlsx_text_context::end_drawing_content()
{ {
return impl_->end_drawing_content(); return impl_->end_drawing_content();
} }
void xlsx_text_context::write_shared_strings(std::wostream & strm) void xlsx_text_context::serialize_shared_strings(std::wostream & strm)
{ {
return impl_->write_shared_strings(strm); return impl_->serialize_shared_strings(strm);
} }
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
void add_text(const std::wstring & text); void add_text(const std::wstring & text);
void write_shared_strings(std::wostream & strm); void serialize_shared_strings(std::wostream & strm);
bool is_drawing_context(); bool is_drawing_context();
......
...@@ -166,7 +166,7 @@ void xlsx_conversion_context::end_document() ...@@ -166,7 +166,7 @@ void xlsx_conversion_context::end_document()
count++; count++;
package::chart_content_ptr content = package::chart_content::create(); package::chart_content_ptr content = package::chart_content::create();
chart->write_to(content->content()); chart->serialize(content->content());
output_document_->get_xl_files().add_charts(content); output_document_->get_xl_files().add_charts(content);
...@@ -175,7 +175,7 @@ void xlsx_conversion_context::end_document() ...@@ -175,7 +175,7 @@ void xlsx_conversion_context::end_document()
{ {
std::wstringstream strm; std::wstringstream strm;
xlsx_text_context_.write_shared_strings(strm); xlsx_text_context_.serialize_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", strm.str()) );
} }
...@@ -288,8 +288,8 @@ void xlsx_conversion_context::end_table() ...@@ -288,8 +288,8 @@ void xlsx_conversion_context::end_table()
} }
current_sheet().cols() << L"</cols>"; current_sheet().cols() << L"</cols>";
get_table_context().serialize_table_format(current_sheet().sheetFormat()); get_table_context().serialize_table_format (current_sheet().sheetFormat());
get_table_context().serialize_conditionalFormatting (current_sheet().conditionalFormatting());
get_table_context().serialize_autofilter (current_sheet().autofilter()); get_table_context().serialize_autofilter (current_sheet().autofilter());
get_table_context().serialize_sort (current_sheet().sort()); get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_merge_cells (current_sheet().mergeCells()); get_table_context().serialize_merge_cells (current_sheet().mergeCells());
...@@ -303,7 +303,7 @@ void xlsx_conversion_context::end_table() ...@@ -303,7 +303,7 @@ void xlsx_conversion_context::end_table()
if (!get_drawing_context().empty()) if (!get_drawing_context().empty())
{ {
std::wstringstream strm; std::wstringstream strm;
get_drawing_context().write_drawing(strm); get_drawing_context().serialize(strm);
const std::pair<std::wstring, std::wstring> drawingName const std::pair<std::wstring, std::wstring> drawingName
= xlsx_drawing_context_handle_.add_drawing_xml(strm.str(), get_drawing_context().get_drawings() ); = xlsx_drawing_context_handle_.add_drawing_xml(strm.str(), get_drawing_context().get_drawings() );
...@@ -322,10 +322,10 @@ void xlsx_conversion_context::end_table() ...@@ -322,10 +322,10 @@ void xlsx_conversion_context::end_table()
if (!get_comments_context().empty()) if (!get_comments_context().empty())
{ {
std::wstringstream strm; std::wstringstream strm;
get_comments_context().write_comments(strm); get_comments_context().serialize(strm);
std::wstringstream vml_strm; std::wstringstream vml_strm;
get_comments_context().write_comments_vml(vml_strm); get_comments_context().serialize_vml(vml_strm);
const std::pair<std::wstring, std::wstring> commentsName const std::pair<std::wstring, std::wstring> commentsName
= xlsx_comments_context_handle_.add_comments_xml(strm.str(), vml_strm.str(),get_comments_context().get_comments() ); = xlsx_comments_context_handle_.add_comments_xml(strm.str(), vml_strm.str(),get_comments_context().get_comments() );
...@@ -556,5 +556,39 @@ void xlsx_conversion_context::end_hyperlink(std::wstring const & href) ...@@ -556,5 +556,39 @@ void xlsx_conversion_context::end_hyperlink(std::wstring const & href)
} }
} }
void xlsx_conversion_context::start_conditional_format(std::wstring ref)
{
get_table_context().state()->get_conditionalFormatting_context().add(ref);
}
void xlsx_conversion_context::start_conditional_format_rule(int type)
{
get_table_context().state()->get_conditionalFormatting_context().add_rule(type);
}
void xlsx_conversion_context::set_conditional_format_formula (std::wstring f)
{
get_table_context().state()->get_conditionalFormatting_context().set_formula(f);
}
void xlsx_conversion_context::set_conditional_format_dxf (int dxfId)
{
get_table_context().state()->get_conditionalFormatting_context().set_dxf(dxfId);
}
void xlsx_conversion_context::add_conditional_format_entry (int type, std::wstring value)
{
get_table_context().state()->get_conditionalFormatting_context().add_sfv(type, value);
}
void xlsx_conversion_context::set_conditional_format_showval (bool val)
{
get_table_context().state()->get_conditionalFormatting_context().set_showVal(val);
}
void xlsx_conversion_context::add_conditional_format_color (std::wstring col)
{
get_table_context().state()->get_conditionalFormatting_context().add_color(col);
}
void xlsx_conversion_context::set_conditional_format_dataBar (_CP_OPT(int) min, _CP_OPT(int) max)
{
get_table_context().state()->get_conditionalFormatting_context().set_dataBar(min, max);
}
} }
} }
...@@ -101,6 +101,22 @@ public: ...@@ -101,6 +101,22 @@ public:
std::wstring current_cell_address(); std::wstring current_cell_address();
//------------------------------------------------------------------------------------
void start_conditional_format (std::wstring ref);
void end_conditional_format (){}
void start_conditional_format_rule (int type);
void end_conditional_format_rule (){}
void set_conditional_format_formula (std::wstring f);
void set_conditional_format_dxf (int dxfId);
void set_conditional_format_showval (bool val);
void add_conditional_format_color (std::wstring col);
void add_conditional_format_entry (int type, std::wstring value);
void set_conditional_format_dataBar (_CP_OPT(int) min, _CP_OPT(int) max);
//------------------------------------------------------------------------------------
odf_reader::odf_document * root() odf_reader::odf_document * root()
{ {
return odf_document_; return odf_document_;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <cpdoccore/odf/odf_document.h> #include <cpdoccore/odf/odf_document.h>
#include "serialize_elements.h" #include "serialize_elements.h"
#include "calcs_styles.h"
namespace cpdoccore { namespace cpdoccore {
...@@ -26,6 +27,8 @@ void calcext_data_bar_attr::add_attributes( const xml::attributes_wc_ptr & Attri ...@@ -26,6 +27,8 @@ void calcext_data_bar_attr::add_attributes( const xml::attributes_wc_ptr & Attri
CP_APPLY_ATTR(L"calcext:axis-color", calcext_axis_color_); CP_APPLY_ATTR(L"calcext:axis-color", calcext_axis_color_);
CP_APPLY_ATTR(L"calcext:positive-color", calcext_positive_color_); CP_APPLY_ATTR(L"calcext:positive-color", calcext_positive_color_);
CP_APPLY_ATTR(L"calcext:negative-color", calcext_negative_color_); CP_APPLY_ATTR(L"calcext:negative-color", calcext_negative_color_);
CP_APPLY_ATTR(L"calcext:min-length", calcext_min_length_);
CP_APPLY_ATTR(L"calcext:max-length", calcext_max_length_);
} }
void calcext_icon_set_attr::add_attributes( const xml::attributes_wc_ptr & Attributes ) void calcext_icon_set_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
...@@ -58,6 +61,10 @@ void calcext_conditional_formats::add_child_element( xml::sax * Reader, const :: ...@@ -58,6 +61,10 @@ void calcext_conditional_formats::add_child_element( xml::sax * Reader, const ::
} }
void calcext_conditional_formats::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_conditional_formats::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
for (int i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
} }
// calcext_conditional_format // calcext_conditional_format
...@@ -75,6 +82,15 @@ void calcext_conditional_format::add_child_element( xml::sax * Reader, const ::s ...@@ -75,6 +82,15 @@ void calcext_conditional_format::add_child_element( xml::sax * Reader, const ::s
} }
void calcext_conditional_format::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_conditional_format::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
if (!calcext_target_range_address_) return;
Context.start_conditional_format(*calcext_target_range_address_);
for (int i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.end_conditional_format();
} }
// calcext_data_bar // calcext_data_bar
...@@ -84,7 +100,9 @@ const wchar_t * calcext_data_bar::name = L"data-bar"; ...@@ -84,7 +100,9 @@ const wchar_t * calcext_data_bar::name = L"data-bar";
void calcext_data_bar::add_attributes( const xml::attributes_wc_ptr & Attributes ) void calcext_data_bar::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
CP_APPLY_ATTR(L"calcext:show-value", calcext_show_value_);
calcext_data_bar_attr_.add_attributes(Attributes); calcext_data_bar_attr_.add_attributes(Attributes);
} }
void calcext_data_bar::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void calcext_data_bar::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{ {
...@@ -92,7 +110,20 @@ void calcext_data_bar::add_child_element( xml::sax * Reader, const ::std::wstrin ...@@ -92,7 +110,20 @@ void calcext_data_bar::add_child_element( xml::sax * Reader, const ::std::wstrin
} }
void calcext_data_bar::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_data_bar::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_conditional_format_rule(2);
if (calcext_show_value_)
Context.set_conditional_format_showval(*calcext_show_value_);
if (calcext_data_bar_attr_.calcext_positive_color_)
Context.add_conditional_format_color(L"ff" + calcext_data_bar_attr_.calcext_positive_color_->get_hex_value());
Context.set_conditional_format_dataBar(calcext_data_bar_attr_.calcext_min_length_, calcext_data_bar_attr_.calcext_max_length_);
for (int i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.end_conditional_format_rule();
} }
// calcext_color_scale // calcext_color_scale
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -108,7 +139,12 @@ void calcext_color_scale::add_child_element( xml::sax * Reader, const ::std::wst ...@@ -108,7 +139,12 @@ void calcext_color_scale::add_child_element( xml::sax * Reader, const ::std::wst
} }
void calcext_color_scale::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_color_scale::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_conditional_format_rule(3);
for (int i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.end_conditional_format_rule();
} }
// calcext_icon_set // calcext_icon_set
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -117,6 +153,7 @@ const wchar_t * calcext_icon_set::name = L"icon-set"; ...@@ -117,6 +153,7 @@ const wchar_t * calcext_icon_set::name = L"icon-set";
void calcext_icon_set::add_attributes( const xml::attributes_wc_ptr & Attributes ) void calcext_icon_set::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
CP_APPLY_ATTR(L"calcext:show-value", calcext_show_value_);
calcext_icon_set_attr_.add_attributes(Attributes); calcext_icon_set_attr_.add_attributes(Attributes);
} }
void calcext_icon_set::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void calcext_icon_set::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
...@@ -125,6 +162,15 @@ void calcext_icon_set::add_child_element( xml::sax * Reader, const ::std::wstrin ...@@ -125,6 +162,15 @@ void calcext_icon_set::add_child_element( xml::sax * Reader, const ::std::wstrin
} }
void calcext_icon_set::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_icon_set::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_conditional_format_rule(4);
if (calcext_show_value_)
Context.set_conditional_format_showval(*calcext_show_value_);
for (int i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.end_conditional_format_rule();
} }
// calcext_formatting_entry // calcext_formatting_entry
...@@ -134,6 +180,8 @@ const wchar_t * calcext_formatting_entry::name = L"formatting-entry"; ...@@ -134,6 +180,8 @@ const wchar_t * calcext_formatting_entry::name = L"formatting-entry";
void calcext_formatting_entry::add_attributes( const xml::attributes_wc_ptr & Attributes ) void calcext_formatting_entry::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
CP_APPLY_ATTR(L"calcext:value", calcext_value_);
CP_APPLY_ATTR(L"calcext:type", calcext_type_);
} }
void calcext_formatting_entry::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void calcext_formatting_entry::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{ {
...@@ -141,6 +189,8 @@ void calcext_formatting_entry::add_child_element( xml::sax * Reader, const ::std ...@@ -141,6 +189,8 @@ void calcext_formatting_entry::add_child_element( xml::sax * Reader, const ::std
} }
void calcext_formatting_entry::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_formatting_entry::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
calcext_type::type type_ = calcext_type_.get_value_or(calcext_type::Number).get_type();
Context.add_conditional_format_entry((int)type_, calcext_value_.get_value_or(L""));
} }
// calcext_color_scale_entry // calcext_color_scale_entry
...@@ -157,6 +207,13 @@ void calcext_color_scale_entry::add_child_element( xml::sax * Reader, const ::st ...@@ -157,6 +207,13 @@ void calcext_color_scale_entry::add_child_element( xml::sax * Reader, const ::st
} }
void calcext_color_scale_entry::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_color_scale_entry::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
if (calcext_color_)
Context.add_conditional_format_color(L"ff" + calcext_color_->get_hex_value());
else
Context.add_conditional_format_color(L"ffffffff");
calcext_type::type type_ = calcext_type_.get_value_or(calcext_type::Number).get_type();
Context.add_conditional_format_entry((int)type_, calcext_value_.get_value_or(L""));
} }
// calcext_condition // calcext_condition
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -173,6 +230,28 @@ void calcext_condition::add_child_element( xml::sax * Reader, const ::std::wstri ...@@ -173,6 +230,28 @@ void calcext_condition::add_child_element( xml::sax * Reader, const ::std::wstri
} }
void calcext_condition::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_condition::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_conditional_format_rule(1);
if (calcext_condition_attr_.calcext_value_)
{
Context.set_conditional_format_formula(*calcext_condition_attr_.calcext_value_);
}
std::wstring style_name = calcext_condition_attr_.calcext_apply_style_name_.get_value_or(L"");
style_instance * instStyle =
Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell, false);
if (!instStyle)
instStyle = Context.root()->odf_context().styleContainer().style_by_display_name(style_name, style_family::TableCell, false);
if (instStyle)
{
text_format_properties_content textFormats = calc_text_properties_content (instStyle);
graphic_format_properties graphicFormats = calc_graphic_properties_content (instStyle);
style_table_cell_properties_attlist cellFormats = calc_table_cell_properties (instStyle);
int dxfId = Context.get_style_manager().dxfId(&textFormats, &graphicFormats, &cellFormats);
Context.set_conditional_format_dxf(dxfId);
}
Context.end_conditional_format_rule();
} }
// calcext_condition // calcext_condition
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -189,6 +268,8 @@ void calcext_date_is::add_child_element( xml::sax * Reader, const ::std::wstring ...@@ -189,6 +268,8 @@ void calcext_date_is::add_child_element( xml::sax * Reader, const ::std::wstring
} }
void calcext_date_is::xlsx_convert(oox::xlsx_conversion_context & Context) void calcext_date_is::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
//Context.start_conditional_format_rule(5);
//Context.end_conditional_format_rule();
} }
} }
......
...@@ -26,6 +26,8 @@ public: ...@@ -26,6 +26,8 @@ public:
_CP_OPT(odf_types::color) calcext_axis_color_; _CP_OPT(odf_types::color) calcext_axis_color_;
_CP_OPT(odf_types::color) calcext_positive_color_; _CP_OPT(odf_types::color) calcext_positive_color_;
_CP_OPT(odf_types::color) calcext_negative_color_; _CP_OPT(odf_types::color) calcext_negative_color_;
_CP_OPT(int) calcext_max_length_;
_CP_OPT(int) calcext_min_length_;
}; };
class calcext_condition_attr class calcext_condition_attr
...@@ -34,7 +36,7 @@ public: ...@@ -34,7 +36,7 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(std::wstring) calcext_base_cell_address_; _CP_OPT(std::wstring) calcext_base_cell_address_;
_CP_OPT(odf_types::style_ref) calcext_apply_style_name_; _CP_OPT(std::wstring) calcext_apply_style_name_;
_CP_OPT(std::wstring) calcext_value_; _CP_OPT(std::wstring) calcext_value_;
}; };
...@@ -117,10 +119,9 @@ public: ...@@ -117,10 +119,9 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
_CP_OPT(bool) calcext_show_value_;
calcext_icon_set_attr calcext_icon_set_attr_; calcext_icon_set_attr calcext_icon_set_attr_;
office_element_ptr_array content_;
private:
office_element_ptr_array content_;//entries
}; };
CP_REGISTER_OFFICE_ELEMENT2(calcext_icon_set); CP_REGISTER_OFFICE_ELEMENT2(calcext_icon_set);
...@@ -140,10 +141,9 @@ public: ...@@ -140,10 +141,9 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
_CP_OPT(bool) calcext_show_value_;
calcext_data_bar_attr calcext_data_bar_attr_; calcext_data_bar_attr calcext_data_bar_attr_;
office_element_ptr_array content_;
private:
office_element_ptr_array content_;//entries
}; };
CP_REGISTER_OFFICE_ELEMENT2(calcext_data_bar) CP_REGISTER_OFFICE_ELEMENT2(calcext_data_bar)
...@@ -162,7 +162,6 @@ public: ...@@ -162,7 +162,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
private:
office_element_ptr_array content_;//color_scale_entries office_element_ptr_array content_;//color_scale_entries
}; };
CP_REGISTER_OFFICE_ELEMENT2(calcext_color_scale) CP_REGISTER_OFFICE_ELEMENT2(calcext_color_scale)
...@@ -222,7 +221,6 @@ public: ...@@ -222,7 +221,6 @@ public:
_CP_OPT(std::wstring) calcext_target_range_address_; _CP_OPT(std::wstring) calcext_target_range_address_;
private:
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
...@@ -243,8 +241,6 @@ public: ...@@ -243,8 +241,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
private:
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
......
...@@ -311,7 +311,9 @@ void odf_document::Impl::parse_styles() ...@@ -311,7 +311,9 @@ void odf_document::Impl::parse_styles()
continue; continue;
} }
context_->styleContainer().add_style(L"common:" + styleInst->style_name_, context_->styleContainer().add_style
( L"common:" + styleInst->style_name_,
styleInst->style_display_name_.get_value_or(L""),
styleInst->style_family_.get_type(), styleInst->style_family_.get_type(),
&(styleInst->style_content_), &(styleInst->style_content_),
true, true,
...@@ -384,6 +386,7 @@ void odf_document::Impl::parse_styles() ...@@ -384,6 +386,7 @@ void odf_document::Impl::parse_styles()
} }
context_->styleContainer().add_style(L"", context_->styleContainer().add_style(L"",
L"",
styleInst->style_family_.get_type(), styleInst->style_family_.get_type(),
&(styleInst->style_content_), &(styleInst->style_content_),
false, false,
...@@ -416,6 +419,7 @@ void odf_document::Impl::parse_styles() ...@@ -416,6 +419,7 @@ void odf_document::Impl::parse_styles()
context_->styleContainer().add_master_page_name(styleInst->style_name_, *styleInst->style_master_page_name_); context_->styleContainer().add_master_page_name(styleInst->style_name_, *styleInst->style_master_page_name_);
context_->styleContainer().add_style(styleInst->style_name_, context_->styleContainer().add_style(styleInst->style_name_,
styleInst->style_display_name_.get_value_or(L""),
styleInst->style_family_.get_type(), styleInst->style_family_.get_type(),
&(styleInst->style_content_), &(styleInst->style_content_),
false, false,
...@@ -547,6 +551,7 @@ void odf_document::Impl::parse_styles() ...@@ -547,6 +551,7 @@ void odf_document::Impl::parse_styles()
context_->styleContainer().add_master_page_name(styleInst->style_name_, *styleInst->style_master_page_name_); context_->styleContainer().add_master_page_name(styleInst->style_name_, *styleInst->style_master_page_name_);
context_->styleContainer().add_style(styleInst->style_name_, context_->styleContainer().add_style(styleInst->style_name_,
styleInst->style_display_name_.get_value_or(L""),
styleInst->style_family_.get_type(), styleInst->style_family_.get_type(),
&(styleInst->style_content_), &(styleInst->style_content_),
true, true,
......
...@@ -46,7 +46,8 @@ style_instance * styles_container::hyperlink_style() ...@@ -46,7 +46,8 @@ style_instance * styles_container::hyperlink_style()
return NULL; return NULL;
} }
void styles_container::add_style(const std::wstring & Name, void styles_container::add_style( const std::wstring & Name,
const std::wstring & DisplayName,
style_family::type Type, style_family::type Type,
style_content * Content, style_content * Content,
bool IsAutomatic, bool IsAutomatic,
...@@ -79,7 +80,12 @@ void styles_container::add_style(const std::wstring & Name, ...@@ -79,7 +80,12 @@ void styles_container::add_style(const std::wstring & Name,
//if ( boost::algorithm::contains(lName, L"internet_20_link") ) //if ( boost::algorithm::contains(lName, L"internet_20_link") )
if (lName == L"internet_20_link")///??????????????? if (lName == L"internet_20_link")///???????????????
hyperlink_style_pos_ = pos; hyperlink_style_pos_ = pos;
}
if (!DisplayName.empty())
{
std::wstring n = DisplayName + L":" + boost::lexical_cast<std::wstring>( style_family(Type) );
map2_[n] = pos;
} }
if (IsDefault) if (IsDefault)
...@@ -152,6 +158,7 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl ...@@ -152,6 +158,7 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl
std::wstring n = L""; std::wstring n = L"";
if (object_in_styles) n = L"common:"; if (object_in_styles) n = L"common:";
n = n + Name + L":" + boost::lexical_cast<std::wstring>( style_family(Type) ); n = n + Name + L":" + boost::lexical_cast<std::wstring>( style_family(Type) );
map_wstring_int_t::const_iterator res = map_.find(n); map_wstring_int_t::const_iterator res = map_.find(n);
if (res != map_.end()) if (res != map_.end())
...@@ -162,7 +169,22 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl ...@@ -162,7 +169,22 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl
else else
return NULL; return NULL;
} }
style_instance * styles_container::style_by_display_name(const std::wstring & Name, style_family::type Type,bool object_in_styles) const
{
std::wstring n = L"";
if (object_in_styles) n = L"common:";
n = n + Name + L":" + boost::lexical_cast<std::wstring>( style_family(Type) );
map_wstring_int_t::const_iterator res = map2_.find(n);
if (res != map2_.end())
{
int index = res->second;
return instances_[index].get();
}
else
return NULL;
}
void styles_container::add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName) void styles_container::add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName)
{ {
master_page_name_[StyleName] = MasterPageName; master_page_name_[StyleName] = MasterPageName;
......
...@@ -106,7 +106,8 @@ public: ...@@ -106,7 +106,8 @@ public:
typedef std::vector<style_instance_ptr> instances_array; typedef std::vector<style_instance_ptr> instances_array;
void add_style(const std::wstring & Name, void add_style( const std::wstring & Name,
const std::wstring & DisplayName,
odf_types::style_family::type Type, odf_types::style_family::type Type,
style_content * Content, style_content * Content,
bool IsAutomatic, bool IsAutomatic,
...@@ -118,8 +119,11 @@ public: ...@@ -118,8 +119,11 @@ public:
void add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName); void add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName);
style_instance * hyperlink_style(); style_instance * hyperlink_style();
style_instance * style_by_name(const std::wstring & Name, odf_types::style_family::type Type,bool object_in_styles) const;
style_instance * style_default_by_type(odf_types::style_family::type Type) const; style_instance * style_by_name (const std::wstring & Name, odf_types::style_family::type Type,bool object_in_styles) const;
style_instance * style_by_display_name (const std::wstring & Name, odf_types::style_family::type Type,bool object_in_styles) const;
style_instance * style_default_by_type (odf_types::style_family::type Type) const;
const std::wstring master_page_name_by_name(const std::wstring & StyleName) const; const std::wstring master_page_name_by_name(const std::wstring & StyleName) const;
...@@ -135,13 +139,16 @@ private: ...@@ -135,13 +139,16 @@ private:
instances_array instances_; instances_array instances_;
typedef boost::unordered_map<std::wstring, int> map_wstring_int_t; typedef boost::unordered_map<std::wstring, int> map_wstring_int_t;
map_wstring_int_t map_;
map_wstring_int_t map_; //by style name
map_wstring_int_t map2_; //by style display name
typedef boost::unordered_map<std::wstring, std::wstring> map_wstring_wstring; typedef boost::unordered_map<std::wstring, std::wstring> map_wstring_wstring;
map_wstring_wstring master_page_name_; map_wstring_wstring master_page_name_;
typedef boost::unordered_map<odf_types::style_family::type, int> map_style_family_int; typedef boost::unordered_map<odf_types::style_family::type, int> map_style_family_int;
map_style_family_int default_map_; map_style_family_int default_map_;
int hyperlink_style_pos_; int hyperlink_style_pos_;
}; };
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <cpdoccore/xml/attributes.h> #include <cpdoccore/xml/attributes.h>
#include <cpdoccore/CPOptional.h> #include <cpdoccore/CPOptional.h>
#include "office_elements.h" #include "office_elements.h"
#include "office_elements_create.h" #include "office_elements_create.h"
...@@ -34,14 +33,9 @@ ...@@ -34,14 +33,9 @@
#include "datatypes/styleposition.h" #include "datatypes/styleposition.h"
#include "datatypes/borderwidths.h" #include "datatypes/borderwidths.h"
//#include "common_draw_data.h"
#include "office_binary_data.h" #include "office_binary_data.h"
#include "datatypes/common_attlists.h" #include "datatypes/common_attlists.h"
//#include "office_elements.h"
//#include "office_elements_create.h"
namespace cpdoccore{ namespace cpdoccore{
namespace oox{ namespace oox{
......
This diff is collapsed.
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