Commit bff7e2cd authored by ElenaSubbotina's avatar ElenaSubbotina

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

parent 342c2aed
......@@ -292,7 +292,7 @@ void docx_conversion_context::end_document()
count++;
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);
......
......@@ -44,7 +44,7 @@ std::wostream & oox_chart_context::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)
{
......
......@@ -29,7 +29,7 @@ public:
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();
......
......@@ -81,7 +81,7 @@ public:
pptx_comments_->add(d);
}
void write_comments(std::wostream & strm)
void serialize(std::wostream & strm)
{
pptx_serialize(strm, *pptx_comments_);
}
......@@ -146,9 +146,9 @@ bool pptx_comments_context::empty() const
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();
}
pptx_comments_ptr pptx_comments_context::get_comments()
......
......@@ -52,7 +52,7 @@ public:
bool empty() const;
void write_comments(std::wostream & strm);
void serialize(std::wostream & strm);
pptx_comments_ptr get_comments();
......
......@@ -267,7 +267,7 @@ void pptx_conversion_context::end_document()
count++;
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);
......@@ -487,7 +487,7 @@ void pptx_conversion_context::end_page()
if (!get_comments_context().empty())
{
std::wstringstream strm;
get_comments_context().write_comments(strm);
get_comments_context().serialize(strm);
const std::pair<std::wstring, std::wstring> commentsName =
comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() );
......
......@@ -168,7 +168,7 @@ public:
}
};
void xlsx_serialize(std::wostream & _Wostream)
void serialize(std::wostream & _Wostream)
{
std::vector<xlsx_border> inst_array;
......@@ -212,9 +212,9 @@ size_t xlsx_borders::borderId(const odf_reader::style_table_cell_properties_attl
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())
......@@ -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
#define _CPDOCCORE_XLSX_BORDERS_H_INCLUDED_da8e414a
#pragma once
#include <iosfwd>
#include <cpdoccore/CPOptional.h>
......@@ -24,17 +23,13 @@ namespace oox {
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);
void xlsx_serialize(std::wostream & _Wostream);
void serialize(std::wostream & _Wostream);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, xlsx_borders & borders);
}
}
#endif
......@@ -19,9 +19,10 @@ public:
xlsx_cell_styles::xlsx_cell_styles() : impl_(new xlsx_cell_styles::Impl())
{
xlsx_cell_style default_style;
default_style.xfId = 0;
default_style.xfId = 0;
default_style.builtinId = 0;
default_style.name = L"Default";
default_style.name = L"Default";
impl_->cell_styles_.push_back(default_style);
}
......@@ -29,7 +30,7 @@ xlsx_cell_styles::xlsx_cell_styles() : impl_(new xlsx_cell_styles::Impl())
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)
{
......@@ -39,7 +40,7 @@ void xlsx_cell_styles::xlsx_serialize(std::wostream & _Wostream) const
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_
#define _CPDOCCORE_XLSX_CELL_STYLES_
#pragma once
#include <cpdoccore/CPScopedPtr.h>
......@@ -13,7 +12,7 @@ public:
~xlsx_cell_styles();
public:
void xlsx_serialize(std::wostream & _Wostream) const;
void serialize(std::wostream & _Wostream) const;
private:
class Impl;
......@@ -21,6 +20,4 @@ private:
};
}
}
#endif
}
\ No newline at end of file
#pragma once
#include <iosfwd>
......@@ -11,11 +10,11 @@ namespace oox {
struct xlsx_color
{
_CP_OPT(bool) autoVal;
_CP_OPT(unsigned int) indexed;
_CP_OPT(std::wstring) rgb;
_CP_OPT(unsigned int) theme;
_CP_OPT(double) tint;
_CP_OPT(bool) autoVal;
_CP_OPT(unsigned int) indexed;
_CP_OPT(std::wstring) rgb;
_CP_OPT(unsigned int) theme;
_CP_OPT(double) tint;
bool operator == (const xlsx_color & rVal) const;
bool operator != (const xlsx_color & rVal) const;
......
#include "xlsx_comments.h"
#include <boost/foreach.hpp>
#include "docx_rels.h"
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "docx_rels.h"
namespace cpdoccore {
namespace oox {
......@@ -31,8 +31,9 @@ public:
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_STREAM() << a;
......@@ -42,8 +43,10 @@ public:
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_ATTR(L"ref", c.ref_);
......
......@@ -50,9 +50,9 @@ class xlsx_comments
public:
xlsx_comments();
~xlsx_comments();
static xlsx_comments_ptr create();
static xlsx_comments_ptr create();
public:
void add(_xlsx_comment & d);
bool empty() const;
......
......@@ -93,11 +93,11 @@ public:
xlsx_comments_->add(d);
}
void write_comments(std::wostream & strm)
void serialize(std::wostream & strm)
{
xlsx_serialize(strm, *xlsx_comments_);
}
void write_comments_vml(std::wostream & strm)
void serialize_vml(std::wostream & strm)
{
xlsx_serialize_vml(strm, *xlsx_comments_);
}
......@@ -166,13 +166,13 @@ bool xlsx_comments_context::empty() const
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()
......
......@@ -54,8 +54,8 @@ public:
bool empty() const;
void write_comments(std::wostream & strm);
void write_comments_vml(std::wostream & strm);
void serialize (std::wostream & strm);
void serialize_vml (std::wostream & strm);
xlsx_comments_ptr get_comments();
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:
mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); }
void write_drawing(std::wostream & strm)
void serialize(std::wostream & strm)
{
xlsx_serialize(strm, *xlsx_drawings_);
}
......@@ -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:
bool empty() const;
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);
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 "../odf/style_table_properties.h"
#include "../odf/style_graphic_properties.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <boost/functional/hash/hash.hpp>
namespace cpdoccore {
......@@ -11,9 +12,9 @@ namespace oox {
bool xlsx_patternFill::operator == (const xlsx_patternFill & rVal) const
{
return fgColor == rVal.fgColor &&
bgColor == rVal.bgColor &&
patternType == rVal.patternType;
return fgColor == rVal.fgColor &&
bgColor == rVal.bgColor &&
patternType == rVal.patternType;
}
bool xlsx_patternFill::operator != (const xlsx_patternFill & rVal) const
......@@ -50,7 +51,7 @@ std::size_t hash_value(xlsx_patternFill const & val)
void xlsx_serialize(std::wostream & _Wostream, const xlsx_gradientFill & gradientFill)
{
// TODO
// todooo
}
std::size_t hash_value(xlsx_gradientFill const & val)
......@@ -70,27 +71,19 @@ bool xlsx_gradientFill::operator != (const xlsx_gradientFill & rVal) const
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fill & fill)
{
if (!fill.patternFill && !fill.gradientFill) return;
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"fill")
{
if (fill.patternFill)
xlsx_serialize(CP_XML_STREAM(), fill.patternFill.get());
xlsx_serialize(CP_XML_STREAM(), *fill.patternFill);
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)
......@@ -103,8 +96,8 @@ std::size_t hash_value(xlsx_fill const & val)
}
bool xlsx_fill::operator == (const xlsx_fill & rVal) const
{
return patternFill == rVal.patternFill &&
gradientFill == rVal.gradientFill;
return patternFill == rVal.patternFill &&
gradientFill == rVal.gradientFill;
}
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));
}
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,14 +4,23 @@
#include <cpdoccore/CPOptional.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 oox {
struct xlsx_patternFill
{
_CP_OPT(xlsx_color) fgColor;
_CP_OPT(xlsx_color) bgColor;
_CP_OPT(std::wstring) patternType;
_CP_OPT(xlsx_color) fgColor;
_CP_OPT(xlsx_color) bgColor;
_CP_OPT(std::wstring) patternType;
bool operator == (const xlsx_patternFill & rVal) const;
bool operator != (const xlsx_patternFill & rVal) const;
......@@ -27,15 +36,22 @@ namespace oox {
struct xlsx_fill
{
_CP_OPT(xlsx_patternFill) patternFill;
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_gradientFill) gradientFill;
std::size_t index;
bool bDefault;
bool bDefault;
bool bEnabled;
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);
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_gradientFill & gradientFill);
......
#include "xlsx_fill.h"
#include "xlsx_fills.h"
#include "../odf/style_table_properties.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <boost/unordered_set.hpp>
......@@ -18,12 +16,12 @@ public:
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_fills::xlsx_fills(): impl_( new xlsx_fills::Impl() )
{
//defaults fill
{
xlsx_patternFill patternFill;
patternFill.patternType = L"none";
......@@ -59,70 +57,54 @@ size_t xlsx_fills::size() const
return impl_->fills_.size();
}
size_t xlsx_fills::fillId(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 default_set)
size_t xlsx_fills::fillId( 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 default_set)
{
bool is_default;
return fillId(textProp, parProp, cellProp,default_set, is_default);
}
size_t xlsx_fills::fillId(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 default_set, bool & is_default)
size_t xlsx_fills::fillId( 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 default_set, bool & is_default)
{
is_default = true;
if (cellProp)
{
if (_CP_OPT(odf_types::background_color) bgClr = cellProp->common_background_color_attlist_.fo_background_color_)
xlsx_fill fill(NULL, cellProp);
if (fill.bEnabled)
{
fill.bDefault = default_set;
Impl::xlsx_fill_array::const_iterator i = impl_->fills_.find(fill);
if (i != impl_->fills_.end())
{
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;
fill.patternFill = patternFill;
fill.bDefault = default_set;
Impl::xlsx_fill_array::const_iterator i = impl_->fills_.find(fill);
if (i != impl_->fills_.end())
{
//const unsigned int dbgId = i - impl_->fills_.begin();
const std::size_t dbgId = i->index;
if (default_set && i->bDefault != default_set)
{
fill.index = i->index;
impl_->fills_.insert(i,fill);
is_default = default_set;
return fill.index;
}
is_default = i->bDefault;
return dbgId;
}
else
{
fill.index = impl_->fills_.size();
impl_->fills_.insert(fill);
is_default = default_set;
return fill.index;
}
}
}
}
// TODO
const std::size_t dbgId = i->index;
if (default_set && i->bDefault != default_set)
{
fill.index = i->index;
impl_->fills_.insert(i,fill);
is_default = default_set;
return fill.index;
}
is_default = i->bDefault;
return dbgId;
}
else
{
fill.index = impl_->fills_.size();
impl_->fills_.insert(fill);
is_default = default_set;
return fill.index;
}
}
return 0;
}
......@@ -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;
......@@ -155,9 +137,10 @@ void xlsx_fills::xlsx_serialize(std::wostream & _Wostream) const
CP_XML_NODE(L"fills")
{
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
//_Wostream << L"</fills>";
}
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills)
{
fills.xlsx_serialize(_Wostream);
}
}
}
......@@ -12,7 +12,6 @@ namespace odf_reader {
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
}
......@@ -26,22 +25,21 @@ namespace oox {
~xlsx_fills();
public:
size_t size() const;
size_t fillId(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 default_set);
size_t fillId( 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 default_set);
size_t fillId(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 default_set,bool & is_default);
size_t fillId( 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 default_set,bool & is_default);
void xlsx_serialize(std::wostream & _Wostream) const;
void serialize(std::wostream & _Wostream) const;
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fills & fills);
}
}
#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 <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_text_properties.h"
namespace cpdoccore {
namespace oox {
......@@ -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
......@@ -276,5 +229,113 @@ std::size_t hash_value(xlsx_font const & val)
boost::hash_combine(seed, val.vertAlign.get_value_or(vertAlignBaseline));
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
#include <iosfwd>
......@@ -9,6 +7,15 @@
#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 oox {
......@@ -65,20 +72,27 @@ namespace oox {
struct xlsx_font
{
_CP_OPT(bool) bold;
_CP_OPT(unsigned int) charset;
_CP_OPT(xlsx_color) color;
_CP_OPT(bool) condense;
_CP_OPT(bool) extend;
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(unsigned int) charset;
_CP_OPT(xlsx_color) color;
_CP_OPT(bool) condense;
_CP_OPT(bool) extend;
_CP_OPT(XlsxFontFamily) family;
_CP_OPT(bool) i; ///< italic
_CP_OPT(std::wstring) name;
_CP_OPT(bool) outline;
_CP_OPT(std::wstring) scheme;
_CP_OPT(bool) shadow;
_CP_OPT(bool) strike;
_CP_OPT(double) sz;
_CP_OPT(XlsxUnderline) u;
_CP_OPT(bool) i; ///< italic
_CP_OPT(std::wstring) name;
_CP_OPT(bool) outline;
_CP_OPT(std::wstring) scheme;
_CP_OPT(bool) shadow;
_CP_OPT(bool) strike;
_CP_OPT(double) sz;
_CP_OPT(XlsxUnderline) u;
_CP_OPT(xlsx_vertAlign) vertAlign;
mutable std::size_t index;
......@@ -90,8 +104,6 @@ namespace oox {
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_font & font);
}
}
#endif
#include "xlsx_font.h"
#include "xlsx_fonts.h"
#include "xlsx_font.h"
#include <cpdoccore/xml/simple_xml_writer.h>
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <boost/unordered_set.hpp>
#include "../odf/style_text_properties.h"
namespace cpdoccore {
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
{
public:
Impl()
{
}
Impl(){}
size_t size() const;
size_t fontId(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 xlsx_font & getFont(size_t id) const;
void xlsx_serialize(std::wostream & _Wostream) const;
size_t fontId( const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
void serialize(std::wostream & _Wostream) const;
private:
/*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:
typedef boost::unordered_set<xlsx_font, boost::hash<xlsx_font> > fonts_array_t;
......@@ -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;
......@@ -180,20 +55,26 @@ void xlsx_fonts::Impl::xlsx_serialize(std::wostream & _Wostream) const
std::sort(fonts.begin(), fonts.end(), compare_xlsx_fonts());
_Wostream << L"<fonts count=\"" << fonts.size() << "\">";
for (size_t i = 0; i < fonts.size(); ++i)
::cpdoccore::oox::xlsx_serialize(_Wostream, fonts[i]);
_Wostream << L"</fonts>";
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)
{
xlsx_serialize(CP_XML_STREAM(), fonts[i]);
}
}
}
}
size_t xlsx_fonts::Impl::fontId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
size_t xlsx_fonts::Impl::fontId(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 fnt = OdfFont2XlsxFont(textProp, parProp, cellProp);
fonts_array_t::const_iterator i = fonts_.find(fnt);
xlsx_font fnt = xlsx_font(textProp, parProp, cellProp);
fonts_array_t::const_iterator i = fonts_.find(fnt);
if (i != fonts_.end())
return i->index;
else
......@@ -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(); }
void xlsx_serialize(std::wostream & _Wostream, const xlsx_fonts & fonts)
{
fonts.xlsx_serialize(_Wostream);
}
////////////////////////////////////////////////////////////////////////////////////////////////
xlsx_fonts::xlsx_fonts(): impl_(new xlsx_fonts::Impl())
......@@ -249,9 +124,9 @@ size_t xlsx_fonts::size() const
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,
......
......@@ -9,7 +9,6 @@ namespace odf_reader {
class text_format_properties_content;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
}
......@@ -26,20 +25,19 @@ namespace oox {
public:
size_t size() const;
size_t fontId(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 xlsx_font & getFont(size_t id) const;
size_t fontId( 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 xlsx_font & getFont(size_t id) const;
void xlsx_serialize(std::wostream & _Wostream) const;
void serialize(std::wostream & _Wostream) const;
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, xlsx_fonts const & fonts);
}
}
#include "xlsx_merge_cells.h"
#include "xlsx_utils.h"
#include <ostream>
#include <vector>
#include <boost/foreach.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
......@@ -35,8 +34,10 @@ public:
{
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_ATTR(L"ref", getCellAddress(m.c, m.r) + L":" + getCellAddress(m.c + m.cols, m.r + m.rows));
......
#pragma once
#include <boost/noncopyable.hpp>
#include <cpdoccore/CPScopedPtr.h>
namespace cpdoccore {
......@@ -11,10 +10,11 @@ class xlsx_merge_cells
public:
xlsx_merge_cells();
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();
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);
private:
class Impl;
......
......@@ -41,7 +41,7 @@ size_t xlsx_num_fmts::num_format_id(const std::wstring & 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"\">";
for (size_t i = 0; i < impl_->formats_.size(); ++i)
......@@ -53,10 +53,7 @@ void xlsx_num_fmts::xlsx_serialize(std::wostream & _Wostream) const
_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 {
~xlsx_num_fmts();
public:
size_t num_format_id(const std::wstring & format_code);
void xlsx_serialize(std::wostream & _Wostream) const;
void serialize(std::wostream & _Wostream) const;
private:
struct Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
void xlsx_serialize(std::wostream & _Wostream, const xlsx_num_fmts & numFmts);
}
}
......@@ -22,6 +22,7 @@ public:
std::wstringstream comments_;
std::wstringstream sort_;
std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
rels hyperlinks_rels_;
......@@ -72,6 +73,10 @@ std::wostream & xlsx_xml_worksheet::mergeCells()
{
return impl_->mergeCells_;
}
std::wostream & xlsx_xml_worksheet::conditionalFormatting()
{
return impl_->conditionalFormatting_;
}
std::wostream & xlsx_xml_worksheet::sort()
{
return impl_->sort_;
......@@ -125,7 +130,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->sort_.str();
//conditional formats
CP_XML_STREAM() << impl_->conditionalFormatting_.str();
if (!impl_->hyperlinks_.str().empty())
{
......
......@@ -13,7 +13,6 @@ namespace oox {
class xlsx_xml_worksheet;
typedef _CP_PTR(xlsx_xml_worksheet) xlsx_xml_worksheet_ptr;
// xlsx_xml_worksheet
class xlsx_xml_worksheet: noncopyable
{
public:
......@@ -30,6 +29,7 @@ public:
std::wostream & drawing();
std::wostream & comments();
std::wostream & autofilter();
std::wostream & conditionalFormatting();
std::wostream & sort();
rels & hyperlinks_rels();
......
......@@ -12,14 +12,14 @@ namespace oox {
class xlsx_shared_strings::Impl
{
public:
void xlsx_serialize(std::wostream & _Wostream) const;
void serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content);
private:
std::vector<std::wstring> strings_;
};
void xlsx_shared_strings::Impl::xlsx_serialize(std::wostream & _Wostream) const
void xlsx_shared_strings::Impl::serialize(std::wostream & _Wostream) const
{
_Wostream << L"<sst xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" count=\"" <<
strings_.size() << "\" uniqueCount=\"" << strings_.size() << "\">";
......@@ -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)
......
......@@ -15,8 +15,8 @@ public:
~xlsx_shared_strings();
public:
void xlsx_serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content);
void serialize(std::wostream & _Wostream) const;
size_t add(const std::wstring & content);
private:
class Impl;
......
......@@ -6,6 +6,7 @@
#include "xlsxconversioncontext.h"
#include "xlsx_fonts.h"
#include "xlsx_xf.h"
#include "xlsx_dxfs.h"
#include "xlsx_borders.h"
#include "xlsx_fills.h"
#include "xlsx_cell_format.h"
......@@ -21,34 +22,41 @@ namespace oox {
class xlsx_style_manager::Impl
{
public:
//typedef std::vector<xlsx_xf> xlsx_xf_array;
typedef boost::unordered_set<xlsx_xf, boost::hash<xlsx_xf> > xlsx_xf_array;
public:
Impl(xlsx_conversion_context * context);
size_t size() const;
size_t xfId(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 xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set, bool & is_visible);
void xlsx_serialize(std::wostream & _Wostream);
void xlsx_serialize_xf(std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName);
size_t size() const;
size_t xfId( 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 xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set, bool & is_visible);
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);
void serialize_xf (std::wostream & _Wostream, const xlsx_xf_array & xfArray, const std::wstring & nodeName);
private:
xlsx_fonts fonts_;
xlsx_borders borders_;
xlsx_fills fills_;
xlsx_xf_array cellXfs_;
xlsx_fonts fonts_;
xlsx_borders borders_;
xlsx_fills fills_;
xlsx_num_fmts numFmts_;
xlsx_xf_array cellXfs_;
xlsx_cell_styles cellStyles_;
xlsx_xf_array cellStyleXfs_;
xlsx_num_fmts numFmts_;
xlsx_cell_styles cellStyles_;
xlsx_xf_array cellStyleXfs_;
xlsx_dxfs dxfs_;
private:
xlsx_conversion_context *context;
size_t next_index_;
//-------------------------------------------------
xlsx_conversion_context *context;
size_t next_index_;
void insert(xlsx_xf const & xf)
{
......@@ -72,6 +80,13 @@ size_t xlsx_style_manager::Impl::size() const
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,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp,
......@@ -116,12 +131,12 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
xfRecord.numFmtId = numFmts_.num_format_id(num_format);
}
else
if (xlxsCellFormat &&
xlxsCellFormat->get_cell_type() != XlsxCellType::null)
{
xfRecord.applyNumberForm = true;
xfRecord.numFmtId = xlxsCellFormat->get_num_format();
}
if (xlxsCellFormat &&
xlxsCellFormat->get_cell_type() != XlsxCellType::null)
{
xfRecord.applyNumberForm = true;
xfRecord.numFmtId = xlxsCellFormat->get_num_format();
}
xfRecord.xfId = 0;
xfRecord.alignment = alignment;
......@@ -140,19 +155,21 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
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\">";
cpdoccore::oox::xlsx_serialize(_Wostream, numFmts_);
cpdoccore::oox::xlsx_serialize(_Wostream, fonts_);
cpdoccore::oox::xlsx_serialize(_Wostream, fills_);
cpdoccore::oox::xlsx_serialize(_Wostream, borders_);
numFmts_.serialize (_Wostream);
fonts_.serialize (_Wostream);
fills_.serialize (_Wostream);
borders_.serialize (_Wostream);
serialize_xf(_Wostream, cellStyleXfs_ , L"cellStyleXfs");
serialize_xf(_Wostream, cellXfs_ , L"cellXfs");
xlsx_serialize_xf(_Wostream, cellStyleXfs_, L"cellStyleXfs");
xlsx_serialize_xf(_Wostream, cellXfs_, L"cellXfs");
cellStyles_.xlsx_serialize(_Wostream);
cellStyles_.serialize(_Wostream);
dxfs_.serialize(_Wostream);
_Wostream << L"</styleSheet>";
......@@ -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_;
......@@ -198,9 +215,9 @@ size_t xlsx_style_manager::size() const
return impl_->size();
}
size_t xlsx_style_manager::xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp,
size_t xlsx_style_manager::xfId(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 xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set)
{
......@@ -208,18 +225,24 @@ 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);
}
size_t xlsx_style_manager::xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp,
size_t xlsx_style_manager::xfId(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 xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set, bool & 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)
{
return impl_->xlsx_serialize(_Wostream);
return impl_->serialize(_Wostream);
}
xlsx_style_manager::~xlsx_style_manager()
......
......@@ -8,6 +8,7 @@ namespace cpdoccore {
namespace odf_reader {
class text_format_properties_content;
class graphic_format_properties;
class paragraph_format_properties;
class style_table_cell_properties_attlist;
}
......@@ -23,18 +24,21 @@ public:
xlsx_style_manager(xlsx_conversion_context *context);
size_t size() const;
size_t xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp,
size_t xfId(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 xlsx_cell_format * xlxsCellFormat,
const std::wstring &num_format, bool default_set,bool & is_visible);
size_t xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp,
size_t xfId(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 xlsx_cell_format * xlxsCellFormat,
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);
......
......@@ -183,7 +183,7 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
//
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 )
{
......@@ -368,14 +368,17 @@ void xlsx_table_state::serialize_table_format(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)
{
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)
{
return xlsx_hyperlinks_.dump_rels(Rels);
......
......@@ -8,6 +8,7 @@
#include "xlsx_drawing_context.h"
#include "xlsx_comments_context.h"
#include "xlsx_hyperlinks.h"
#include "xlsx_conditionalFormatting.h"
namespace cpdoccore {
namespace oox {
......@@ -51,19 +52,20 @@ public:
std::wstring current_style() const { return table_style_; }
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row(const std::wstring & StyleName, 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 non_empty_row();
bool is_empty_row() const;
void end_row();
void non_empty_row ();
bool is_empty_row () const;
void end_row ();
std::wstring current_row_style() const;
std::wstring default_row_cell_style() const;
std::wstring default_column_cell_style() const;
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
std::wstring default_column_cell_style () const;
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 start_covered_cell();
......@@ -75,27 +77,30 @@ public:
int current_column() const;
int current_row() const;
unsigned int current_columns_spaned() const;
unsigned int current_rows_spanned(unsigned int Column) const;
unsigned int columns_count() const;
unsigned int current_columns_spaned () const;
unsigned int current_rows_spanned (unsigned int Column) const;
unsigned int columns_count () const;
xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; }
xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_context_; }
xlsx_comments_context & get_comments_context() { return xlsx_comments_context_; }
xlsx_table_metrics & get_table_metrics() { return xlsx_table_metrics_; }
xlsx_drawing_context & get_drawing_context() { return xlsx_drawing_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; }
double table_column_last_width() const { return table_column_last_width_; };
void start_hyperlink();
std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);
void start_hyperlink ();
std::wstring end_hyperlink (std::wstring const & ref, std::wstring const & href, std::wstring const & display);
void serialize_table_format (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void serialize_conditionalFormatting (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
std::wstring get_table_name() const { return tableName_; }
int get_table_id() const { return tableId_; }
struct _group_row
{
bool enabled;
......@@ -108,34 +113,37 @@ public:
friend class xlsx_table_context;
private:
bool in_cell;
xlsx_conversion_context * context_;
std::wstring tableName_;
int tableId_;
std::wstring table_style_;
std::wstring table_row_style_;
std::wstring cell_style_;
std::vector<std::wstring> column_default_cell_style_name_;
std::wstring row_default_cell_style_name_;
xlsx_conversion_context * context_;
std::wstring tableName_;
int tableId_;
std::wstring table_style_;
std::wstring table_row_style_;
std::wstring cell_style_;
std::vector<std::wstring> column_default_cell_style_name_;
std::wstring row_default_cell_style_name_;
int current_table_column_;
int current_table_row_;
bool empty_row_;
int current_table_column_;
int current_table_row_;
bool empty_row_;
bool in_cell;
unsigned int columns_spanned_num_;
std::wstring columns_spanned_style_;
unsigned int columns_spanned_num_;
std::wstring columns_spanned_style_;
std::vector<xlsx_row_spanned> rows_spanned_;
std::vector<unsigned int> columns_;
unsigned int columns_count_;
double table_column_last_width_;
std::vector<xlsx_row_spanned> rows_spanned_;
std::vector<unsigned int> columns_;
unsigned int columns_count_;
double table_column_last_width_;
xlsx_merge_cells merge_cells_;
xlsx_table_metrics xlsx_table_metrics_;
xlsx_drawing_context xlsx_drawing_context_;
xlsx_comments_context xlsx_comments_context_;
xlsx_hyperlinks xlsx_hyperlinks_;
xlsx_drawing_context xlsx_drawing_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_;
};
......
......@@ -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)
{
return state()->serialize_merge_cells(_Wostream);
......
......@@ -52,10 +52,11 @@ public:
unsigned int columns_count();
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream);
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream);
void serialize_conditionalFormatting(std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();
......
......@@ -51,7 +51,7 @@ public:
void start_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 ApplyParagraphProperties (std::wstring style, odf_reader::paragraph_format_properties & propertiesOut, odf_types::style_family::type Type);
......@@ -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()
{
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:
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();
......
......@@ -166,7 +166,7 @@ void xlsx_conversion_context::end_document()
count++;
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);
......@@ -175,7 +175,7 @@ void xlsx_conversion_context::end_document()
{
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()) );
}
......@@ -288,13 +288,13 @@ void xlsx_conversion_context::end_table()
}
current_sheet().cols() << L"</cols>";
get_table_context().serialize_table_format(current_sheet().sheetFormat());
get_table_context().serialize_autofilter (current_sheet().autofilter());
get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
get_table_context().serialize_hyperlinks (current_sheet().hyperlinks());
get_table_context().dump_rels_hyperlinks (current_sheet().hyperlinks_rels());
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_sort (current_sheet().sort());
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
get_table_context().serialize_hyperlinks (current_sheet().hyperlinks());
get_table_context().dump_rels_hyperlinks (current_sheet().hyperlinks_rels());
get_drawing_context().set_odf_packet_path(root()->get_folder());
......@@ -303,7 +303,7 @@ void xlsx_conversion_context::end_table()
if (!get_drawing_context().empty())
{
std::wstringstream strm;
get_drawing_context().write_drawing(strm);
get_drawing_context().serialize(strm);
const std::pair<std::wstring, std::wstring> drawingName
= xlsx_drawing_context_handle_.add_drawing_xml(strm.str(), get_drawing_context().get_drawings() );
......@@ -322,10 +322,10 @@ void xlsx_conversion_context::end_table()
if (!get_comments_context().empty())
{
std::wstringstream strm;
get_comments_context().write_comments(strm);
get_comments_context().serialize(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
= 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)
}
}
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:
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()
{
return odf_document_;
......
......@@ -13,6 +13,7 @@
#include <cpdoccore/odf/odf_document.h>
#include "serialize_elements.h"
#include "calcs_styles.h"
namespace cpdoccore {
......@@ -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:positive-color", calcext_positive_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 )
......@@ -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)
{
for (int i = 0 ; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
}
// calcext_conditional_format
......@@ -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)
{
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
......@@ -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 )
{
CP_APPLY_ATTR(L"calcext:show-value", calcext_show_value_);
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)
{
......@@ -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)
{
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
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -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)
{
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
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -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 )
{
CP_APPLY_ATTR(L"calcext:show-value", calcext_show_value_);
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)
......@@ -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)
{
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
......@@ -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 )
{
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)
{
......@@ -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)
{
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
......@@ -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)
{
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
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -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)
{
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
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -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)
{
//Context.start_conditional_format_rule(5);
//Context.end_conditional_format_rule();
}
}
......
......@@ -23,9 +23,11 @@ class calcext_data_bar_attr
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(odf_types::color) calcext_axis_color_;
_CP_OPT(odf_types::color) calcext_positive_color_;
_CP_OPT(odf_types::color) calcext_negative_color_;
_CP_OPT(odf_types::color) calcext_axis_color_;
_CP_OPT(odf_types::color) calcext_positive_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
......@@ -33,9 +35,9 @@ class calcext_condition_attr
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(std::wstring) calcext_base_cell_address_;
_CP_OPT(odf_types::style_ref) calcext_apply_style_name_;
_CP_OPT(std::wstring) calcext_value_;
_CP_OPT(std::wstring) calcext_base_cell_address_;
_CP_OPT(std::wstring) calcext_apply_style_name_;
_CP_OPT(std::wstring) calcext_value_;
};
......@@ -44,7 +46,7 @@ class calcext_icon_set_attr
public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
_CP_OPT(odf_types::iconset_type) calcext_icon_set_type_;
_CP_OPT(odf_types::iconset_type) calcext_icon_set_type_;
};
......@@ -117,10 +119,9 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
calcext_icon_set_attr calcext_icon_set_attr_;
private:
office_element_ptr_array content_;//entries
_CP_OPT(bool) calcext_show_value_;
calcext_icon_set_attr calcext_icon_set_attr_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_icon_set);
......@@ -140,10 +141,9 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
calcext_data_bar_attr calcext_data_bar_attr_;
private:
office_element_ptr_array content_;//entries
_CP_OPT(bool) calcext_show_value_;
calcext_data_bar_attr calcext_data_bar_attr_;
office_element_ptr_array content_;
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_data_bar)
......@@ -162,7 +162,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
private:
office_element_ptr_array content_;//color_scale_entries
};
CP_REGISTER_OFFICE_ELEMENT2(calcext_color_scale)
......@@ -222,7 +221,6 @@ public:
_CP_OPT(std::wstring) calcext_target_range_address_;
private:
office_element_ptr_array content_;
};
......@@ -243,8 +241,6 @@ public:
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
private:
office_element_ptr_array content_;
};
......
......@@ -311,14 +311,16 @@ void odf_document::Impl::parse_styles()
continue;
}
context_->styleContainer().add_style(L"common:" + styleInst->style_name_,
styleInst->style_family_.get_type(),
&(styleInst->style_content_),
true,
false,
styleInst->style_parent_style_name_.get_value_or(L""),
styleInst->style_next_style_name_.get_value_or(L""),
styleInst->style_data_style_name_.get_value_or(L"")
context_->styleContainer().add_style
( L"common:" + styleInst->style_name_,
styleInst->style_display_name_.get_value_or(L""),
styleInst->style_family_.get_type(),
&(styleInst->style_content_),
true,
false,
styleInst->style_parent_style_name_.get_value_or(L""),
styleInst->style_next_style_name_.get_value_or(L""),
styleInst->style_data_style_name_.get_value_or(L"")
);
}
// list styles
......@@ -384,6 +386,7 @@ void odf_document::Impl::parse_styles()
}
context_->styleContainer().add_style(L"",
L"",
styleInst->style_family_.get_type(),
&(styleInst->style_content_),
false,
......@@ -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_style(styleInst->style_name_,
styleInst->style_display_name_.get_value_or(L""),
styleInst->style_family_.get_type(),
&(styleInst->style_content_),
false,
......@@ -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_style(styleInst->style_name_,
styleInst->style_display_name_.get_value_or(L""),
styleInst->style_family_.get_type(),
&(styleInst->style_content_),
true,
......
......@@ -46,14 +46,15 @@ style_instance * styles_container::hyperlink_style()
return NULL;
}
void styles_container::add_style(const std::wstring & Name,
style_family::type Type,
style_content * Content,
bool IsAutomatic,
bool IsDefault,
const std::wstring & ParentStyleName_,
const std::wstring & NextStyleName,
const std::wstring & DataStyleName)
void styles_container::add_style( const std::wstring & Name,
const std::wstring & DisplayName,
style_family::type Type,
style_content * Content,
bool IsAutomatic,
bool IsDefault,
const std::wstring & ParentStyleName_,
const std::wstring & NextStyleName,
const std::wstring & DataStyleName)
{
std::wstring ParentStyleName = ParentStyleName_;
......@@ -79,9 +80,14 @@ void styles_container::add_style(const std::wstring & Name,
//if ( boost::algorithm::contains(lName, L"internet_20_link") )
if (lName == L"internet_20_link")///???????????????
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)
default_map_[Type] = pos;
......@@ -152,7 +158,8 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl
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 = map_.find(n);
map_wstring_int_t::const_iterator res = map_.find(n);
if (res != map_.end())
{
......@@ -162,7 +169,22 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl
else
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)
{
master_page_name_[StyleName] = MasterPageName;
......
......@@ -106,20 +106,24 @@ public:
typedef std::vector<style_instance_ptr> instances_array;
void add_style(const std::wstring & Name,
odf_types::style_family::type Type,
style_content * Content,
bool IsAutomatic,
bool IsDefault,
const std::wstring & ParentStyleName,
const std::wstring & NextStyleName,
const std::wstring & DataStyleName);
void add_style( const std::wstring & Name,
const std::wstring & DisplayName,
odf_types::style_family::type Type,
style_content * Content,
bool IsAutomatic,
bool IsDefault,
const std::wstring & ParentStyleName,
const std::wstring & NextStyleName,
const std::wstring & DataStyleName);
void add_master_page_name(const std::wstring & StyleName, const std::wstring & MasterPageName);
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;
......@@ -135,14 +139,17 @@ private:
instances_array instances_;
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;
map_wstring_wstring master_page_name_;
typedef boost::unordered_map<odf_types::style_family::type, int> map_style_family_int;
map_style_family_int default_map_;
int hyperlink_style_pos_;
int hyperlink_style_pos_;
};
class page_layout_instance;
......
......@@ -5,7 +5,6 @@
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/CPOptional.h>
#include "office_elements.h"
#include "office_elements_create.h"
......@@ -34,14 +33,9 @@
#include "datatypes/styleposition.h"
#include "datatypes/borderwidths.h"
//#include "common_draw_data.h"
#include "office_binary_data.h"
#include "datatypes/common_attlists.h"
//#include "office_elements.h"
//#include "office_elements_create.h"
namespace cpdoccore{
namespace oox{
......
......@@ -598,30 +598,6 @@
<Filter
Name="xlsx"
>
<File
RelativePath="..\src\docx\xlsx_alignment.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_alignment.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_border.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_border.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_borders.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_borders.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_cell_format.cpp"
>
......@@ -646,14 +622,6 @@
RelativePath="..\src\docx\xlsx_cell_styles.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_color.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_color.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_comments.cpp"
>
......@@ -678,6 +646,14 @@
RelativePath="..\src\docx\xlsx_complex_number_format.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_conditionalFormatting.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_conditionalFormatting.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_defined_names.cpp"
>
......@@ -710,38 +686,6 @@
RelativePath="..\src\docx\xlsx_drawings.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fill.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fill.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fills.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fills.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_font.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_font.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fonts.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fonts.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_formula.h"
>
......@@ -770,14 +714,6 @@
RelativePath="..\src\docx\xlsx_num_format_context.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_numFmts.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_numFmts.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_output_xml.cpp"
>
......@@ -794,14 +730,6 @@
RelativePath="..\src\docx\xlsx_package.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_protection.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_protection.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_row_spanned.h"
>
......@@ -866,14 +794,6 @@
RelativePath="..\src\docx\xlsx_utils.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_xf.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_xf.h"
>
</File>
<File
RelativePath="..\src\docx\xlsxconversioncontext.cpp"
>
......@@ -882,6 +802,106 @@
RelativePath="..\src\docx\xlsxconversioncontext.h"
>
</File>
<Filter
Name="styles"
>
<File
RelativePath="..\src\docx\xlsx_alignment.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_alignment.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_border.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_border.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_borders.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_borders.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_color.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_color.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_dxfs.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_dxfs.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fill.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fill.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fills.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fills.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_font.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_font.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fonts.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_fonts.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_numFmts.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_numFmts.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_protection.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_protection.h"
>
</File>
<File
RelativePath="..\src\docx\xlsx_xf.cpp"
>
</File>
<File
RelativePath="..\src\docx\xlsx_xf.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="oox"
......
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