Commit 615be05d authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - исправлен цвет маркеров в диаграмах, текстовые настройки...

OdfFormatReader - исправлен цвет маркеров в диаграмах, текстовые настройки точек данных, отступы в ячеках, поправлены именованые выражения,  ....
parent 9e5379fe
...@@ -60,102 +60,102 @@ public: ...@@ -60,102 +60,102 @@ public:
void start_table(const std::wstring & StyleName) void start_table(const std::wstring & StyleName)
{ {
xlsx_table_states_.push_back(docx_table_state(context_, StyleName)); table_states_.push_back(docx_table_state(context_, StyleName));
} }
void end_table() void end_table()
{ {
xlsx_table_states_.pop_back(); table_states_.pop_back();
} }
std::wstring current_style() const std::wstring current_style() const
{ {
return xlsx_table_states_.back().current_style(); return table_states_.back().current_style();
} }
size_t in_table() const size_t in_table() const
{ {
return xlsx_table_states_.size(); return table_states_.size();
} }
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName) void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
{ {
return xlsx_table_states_.back().start_column(repeated, defaultCellStyleName); return table_states_.back().start_column(repeated, defaultCellStyleName);
} }
void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName) void start_row(const std::wstring & StyleName, const std::wstring & defaultCellStyleName)
{ {
return xlsx_table_states_.back().start_row(StyleName, defaultCellStyleName); return table_states_.back().start_row(StyleName, defaultCellStyleName);
} }
void end_row() void end_row()
{ {
return xlsx_table_states_.back().end_row(); return table_states_.back().end_row();
} }
std::wstring current_row_style() const std::wstring current_row_style() const
{ {
return xlsx_table_states_.back().current_row_style(); return table_states_.back().current_row_style();
} }
void start_cell() void start_cell()
{ {
return xlsx_table_states_.back().start_cell(); return table_states_.back().start_cell();
} }
void end_cell() void end_cell()
{ {
return xlsx_table_states_.back().end_cell(); return table_states_.back().end_cell();
} }
bool start_covered_cell(docx_conversion_context & Context) bool start_covered_cell(docx_conversion_context & Context)
{ {
return xlsx_table_states_.back().start_covered_cell(Context); return table_states_.back().start_covered_cell(Context);
} }
void end_covered_cell() void end_covered_cell()
{ {
return xlsx_table_states_.back().end_covered_cell(); return table_states_.back().end_covered_cell();
} }
int current_column() const int current_column() const
{ {
return xlsx_table_states_.back().current_column(); return table_states_.back().current_column();
} }
void set_columns_spanned(unsigned int Val) void set_columns_spanned(unsigned int Val)
{ {
return xlsx_table_states_.back().set_columns_spanned(Val); return table_states_.back().set_columns_spanned(Val);
} }
unsigned int current_columns_spaned() const unsigned int current_columns_spaned() const
{ {
return xlsx_table_states_.back().current_columns_spaned(); return table_states_.back().current_columns_spaned();
} }
void set_rows_spanned(unsigned int Column, unsigned int Val, unsigned int ColumnsSpanned, const std::wstring & Style) void set_rows_spanned(unsigned int Column, unsigned int Val, unsigned int ColumnsSpanned, const std::wstring & Style)
{ {
return xlsx_table_states_.back().set_rows_spanned(Column, Val, ColumnsSpanned, Style); return table_states_.back().set_rows_spanned(Column, Val, ColumnsSpanned, Style);
} }
unsigned int current_rows_spanned(unsigned int Column) const unsigned int current_rows_spanned(unsigned int Column) const
{ {
return xlsx_table_states_.back().current_rows_spanned(Column); return table_states_.back().current_rows_spanned(Column);
} }
std::wstring get_default_cell_style_col(unsigned int column) std::wstring get_default_cell_style_col(unsigned int column)
{ {
return xlsx_table_states_.back().get_default_cell_style_col(column); return table_states_.back().get_default_cell_style_col(column);
} }
std::wstring get_default_cell_style_row() std::wstring get_default_cell_style_row()
{ {
return xlsx_table_states_.back().get_default_cell_style_row(); return table_states_.back().get_default_cell_style_row();
} }
private: private:
docx_conversion_context & context_; docx_conversion_context & context_;
std::list<docx_table_state> xlsx_table_states_; std::list<docx_table_state> table_states_;
}; };
......
...@@ -120,9 +120,13 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) ...@@ -120,9 +120,13 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream)
} }
} }
} }
CP_XML_NODE(L"c:delete")//visible item CP_XML_NODE(L"c:delete")//visible item
{ {
CP_XML_ATTR(L"val", 0); odf_reader::GetProperty(content_.properties_, L"visible", boolVal);
if ((boolVal) && (*boolVal == false)) CP_XML_ATTR(L"val", 1);
else CP_XML_ATTR(L"val", 0);
} }
CP_XML_NODE(L"c:axPos") CP_XML_NODE(L"c:axPos")
{ {
......
...@@ -12,39 +12,6 @@ ...@@ -12,39 +12,6 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class oox_marker_type
{
public:
static void oox_serialize(std::wostream & _Wostream,int type =0)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"c:marker")
{
CP_XML_NODE(L"c:symbol")
{
switch (type)
{
case 11: CP_XML_ATTR(L"val", L"star"); break;
case 10: CP_XML_ATTR(L"val", L"circle"); break;
case 15: CP_XML_ATTR(L"val", L"dash"); break;
case 3: CP_XML_ATTR(L"val", L"diamond"); break;
case 14: CP_XML_ATTR(L"val", L"dot"); break;
case 8: CP_XML_ATTR(L"val", L"picture"); break;
case 13: CP_XML_ATTR(L"val", L"plus"); break;
case 2: CP_XML_ATTR(L"val", L"square"); break;
case 9: CP_XML_ATTR(L"val", L"triangle"); break;
case 12: CP_XML_ATTR(L"val", L"x"); break;
case 0: //none
case 1: //auto
default:
CP_XML_ATTR(L"val", L"none");
}
}
}
}
}
};
oox_chart_series::oox_chart_series() oox_chart_series::oox_chart_series()
{ {
values_[0].type = L"c:cat";// values_[0].type = L"c:cat";//
...@@ -120,12 +87,14 @@ void oox_chart_series::parse_properties() ...@@ -120,12 +87,14 @@ void oox_chart_series::parse_properties()
if (boolVal) if (boolVal)
{ {
if (!data_labels_) data_labels_ = oox_data_labels(); if (!data_labels_) data_labels_ = oox_data_labels();
data_labels_->set_showCatName(*boolVal); data_labels_->set_showCatName(*boolVal);
} }
odf_reader::GetProperty(content_.properties_, L"data-label-number", intVal); odf_reader::GetProperty(content_.properties_, L"data-label-number", intVal);
if (intVal) if (intVal)
{ {
if (!data_labels_) data_labels_ = oox_data_labels(); if (!data_labels_) data_labels_ = oox_data_labels();
if (*intVal == 1) data_labels_->set_showVal(true); if (*intVal == 1) data_labels_->set_showVal(true);
if (*intVal == 2) data_labels_->set_showPercent(true); if (*intVal == 2) data_labels_->set_showPercent(true);
} }
...@@ -152,12 +121,47 @@ void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values) ...@@ -152,12 +121,47 @@ void oox_chart_series::setValues(int ind, std::vector<std::wstring> & values)
} }
} }
} }
void oox_chart_series::oox_serialize_marker(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE(L"c:marker")
{
CP_XML_NODE(L"c:symbol")
{
switch (iSymbolMarkerType_)
{
case 11: CP_XML_ATTR(L"val", L"star"); break;
case 10: CP_XML_ATTR(L"val", L"circle"); break;
case 15: CP_XML_ATTR(L"val", L"dash"); break;
case 3: CP_XML_ATTR(L"val", L"diamond"); break;
case 14: CP_XML_ATTR(L"val", L"dot"); break;
case 8: CP_XML_ATTR(L"val", L"picture"); break;
case 13: CP_XML_ATTR(L"val", L"plus"); break;
case 2: CP_XML_ATTR(L"val", L"square"); break;
case 9: CP_XML_ATTR(L"val", L"triangle"); break;
case 12: CP_XML_ATTR(L"val", L"x"); break;
case 0: //none
case 1: //auto
default:
CP_XML_ATTR(L"val", L"none");
}
}
if (iSymbolMarkerType_ > 0)
{
oox_chart_shape shape;
shape.set(content_.graphic_properties_, content_.fill_);
shape.oox_serialize(_Wostream);
}
}
}
}
void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
{ {
parse_properties(); parse_properties();
oox_chart_shape shape; oox_chart_shape shape;
shape.set(content_.graphic_properties_, content_.fill_);
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
...@@ -170,6 +174,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -170,6 +174,7 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
CP_XML_ATTR(L"val", id_); CP_XML_ATTR(L"val", id_);
} }
shape.set(content_.graphic_properties_, content_.fill_);
shape.oox_serialize(_Wostream); shape.oox_serialize(_Wostream);
for (int i=0; i < 5; i++) for (int i=0; i < 5; i++)
...@@ -355,6 +360,12 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -355,6 +360,12 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
} }
} }
if (!content_.text_properties_.empty())
{
if (!data_labels_) data_labels_ = oox_data_labels();
data_labels_->set_common_dLbl(content_.text_properties_);
}
bool bEmpty_dPt = true; bool bEmpty_dPt = true;
for (int i = 0 ; i < content_.points_.size(); i++) for (int i = 0 ; i < content_.points_.size(); i++)
...@@ -394,7 +405,9 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -394,7 +405,9 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
} }
if (data_labels_) if (data_labels_)
{
data_labels_->oox_serialize(_Wostream); data_labels_->oox_serialize(_Wostream);
}
} }
} }
...@@ -407,7 +420,6 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream) ...@@ -407,7 +420,6 @@ void oox_chart_series::oox_serialize_common(std::wostream & _Wostream)
//name (Trendline Name) 21.2.2.116 //name (Trendline Name) 21.2.2.116
//order (Polynomial Trendline Order) 21.2.2.129 //order (Polynomial Trendline Order) 21.2.2.129
//period (Period) 21.2.2.135 //period (Period) 21.2.2.135
//spPr (Shape Properties) 21.2.2.197
//trendlineLbl (Trendline Label) 21.2.2.212 //trendlineLbl (Trendline Label) 21.2.2.212
//trendlineType (Trendline Type) //trendlineType (Trendline Type)
...@@ -443,7 +455,7 @@ void oox_line_series::oox_serialize(std::wostream & _Wostream) ...@@ -443,7 +455,7 @@ void oox_line_series::oox_serialize(std::wostream & _Wostream)
{ {
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
oox_marker_type::oox_serialize(CP_XML_STREAM(),iSymbolMarkerType_); oox_serialize_marker(CP_XML_STREAM());
} }
} }
} }
...@@ -491,7 +503,7 @@ void oox_scatter_series::oox_serialize(std::wostream & _Wostream) ...@@ -491,7 +503,7 @@ void oox_scatter_series::oox_serialize(std::wostream & _Wostream)
{ {
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
oox_marker_type::oox_serialize(CP_XML_STREAM(),iSymbolMarkerType_); oox_serialize_marker(CP_XML_STREAM());
} }
} }
} }
...@@ -568,7 +580,7 @@ void oox_radar_series::oox_serialize(std::wostream & _Wostream) ...@@ -568,7 +580,7 @@ void oox_radar_series::oox_serialize(std::wostream & _Wostream)
{ {
oox_serialize_common(CP_XML_STREAM()); oox_serialize_common(CP_XML_STREAM());
oox_marker_type::oox_serialize(CP_XML_STREAM(),iSymbolMarkerType_); oox_serialize_marker(CP_XML_STREAM());
} }
} }
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class oox_chart_series; class oox_chart_series;
typedef _CP_PTR(oox_chart_series) oox_series_ptr; typedef _CP_PTR(oox_chart_series) oox_series_ptr;
...@@ -21,6 +20,8 @@ public: ...@@ -21,6 +20,8 @@ public:
~oox_chart_series(){} ~oox_chart_series(){}
void oox_serialize_common(std::wostream & _Wostream); void oox_serialize_common(std::wostream & _Wostream);
void oox_serialize_marker(std::wostream & _Wostream);
virtual void oox_serialize(std::wostream & _Wostream) = 0; virtual void oox_serialize(std::wostream & _Wostream) = 0;
_oox_chart_values values_[5]; //cat(labels), common, x, y, bubble, _oox_chart_values values_[5]; //cat(labels), common, x, y, bubble,
...@@ -40,11 +41,9 @@ public: ...@@ -40,11 +41,9 @@ public:
odf_reader::chart::series content_; odf_reader::chart::series content_;
//dPt (Data Point) 21.2.2.52
//extLst (Chart Extensibility) 21.2.2.64 //extLst (Chart Extensibility) 21.2.2.64
//idx (Index) 21.2.2.84 //idx (Index) 21.2.2.84
//order (Order) 21.2.2.128 //order (Order) 21.2.2.128
//spPr (Shape Properties) 21.2.2.197
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -22,6 +22,11 @@ oox_data_labels::oox_data_labels()// ...@@ -22,6 +22,11 @@ oox_data_labels::oox_data_labels()//
showVal_ = false; showVal_ = false;
} }
void oox_data_labels::set_common_dLbl ( std::vector<odf_reader::_property> & text_properties)
{
textPr_ = text_properties;
}
void oox_data_labels::add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties) void oox_data_labels::add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties)
{ {
dLbls_.insert(std::pair<int, std::vector<odf_reader::_property>>(ind, text_properties)); dLbls_.insert(std::pair<int, std::vector<odf_reader::_property>>(ind, text_properties));
...@@ -33,6 +38,8 @@ void oox_data_labels::oox_serialize(std::wostream & _Wostream) ...@@ -33,6 +38,8 @@ void oox_data_labels::oox_serialize(std::wostream & _Wostream)
{ {
CP_XML_NODE(L"c:dLbls") CP_XML_NODE(L"c:dLbls")
{ {
oox_serialize_default_text(CP_XML_STREAM(), textPr_);
for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); it++) for (std::map<int, std::vector<odf_reader::_property>>::iterator it = dLbls_.begin(); it != dLbls_.end(); it++)
{ {
CP_XML_NODE(L"c:dLbl") CP_XML_NODE(L"c:dLbl")
......
...@@ -29,6 +29,7 @@ public: ...@@ -29,6 +29,7 @@ public:
void set_showVal (bool Val){showVal_ = Val;} void set_showVal (bool Val){showVal_ = Val;}
void add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties); void add_dLbl(int ind, std::vector<odf_reader::_property> & text_properties);
void set_common_dLbl ( std::vector<odf_reader::_property> & text_properties);
private: private:
...@@ -40,12 +41,11 @@ private: ...@@ -40,12 +41,11 @@ private:
bool showSerName_; // (Show Series Name) 21.2.2.188 bool showSerName_; // (Show Series Name) 21.2.2.188
bool showVal_; // (Show Value) 21.2.2.189 bool showVal_; // (Show Value) 21.2.2.189
std::vector<odf_reader::_property> textPr_;
std::map<int, std::vector<odf_reader::_property>> dLbls_; std::map<int, std::vector<odf_reader::_property>> dLbls_;
//delete (Delete) 21.2.2.40 //delete (Delete) 21.2.2.40
//dLbl (Data Label) 21.2.2.47 -
//dLblPos (Data Label Position) 21.2.2.48 //dLblPos (Data Label Position) 21.2.2.48
//extLst (Chart Extensibility) 21.2.2.64 //extLst (Chart Extensibility) 21.2.2.64
//leaderLines (Leader Lines) 21.2.2.92 //leaderLines (Leader Lines) 21.2.2.92
......
...@@ -76,11 +76,11 @@ public: ...@@ -76,11 +76,11 @@ public:
return odf_document_; return odf_document_;
} }
pptx_xml_slide & current_slide(); pptx_xml_slide & current_slide();
pptx_xml_slideLayout & current_layout(); pptx_xml_slideLayout & current_layout();
pptx_xml_slideMaster & current_master(); pptx_xml_slideMaster & current_master();
pptx_xml_theme & current_theme(); pptx_xml_theme & current_theme();
pptx_xml_presentation & current_presentation();// pptx_xml_presentation & current_presentation();//
oox_chart_context & current_chart(); oox_chart_context & current_chart();
pptx_text_context & get_text_context() { return pptx_text_context_; } pptx_text_context & get_text_context() { return pptx_text_context_; }
......
#pragma once #pragma once
#include "xlsxconversioncontext.h"
#include "xlsx_alignment.h" #include "xlsx_alignment.h"
#include <ostream>
#include <boost/functional.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/style_paragraph_properties.h" #include "../odf/style_paragraph_properties.h"
#include "../odf/style_text_properties.h" #include "../odf/style_text_properties.h"
#include "../odf/style_table_properties.h" #include "../odf/style_table_properties.h"
#include <ostream>
#include <boost/functional.hpp>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
...@@ -54,41 +56,85 @@ bool is_default(const xlsx_alignment & rVal) ...@@ -54,41 +56,85 @@ bool is_default(const xlsx_alignment & rVal)
return rVal == defaultAlignment; return rVal == defaultAlignment;
} }
xlsx_alignment OdfProperties2XlsxAlignment(const odf_reader::text_format_properties_content * textProp, xlsx_alignment OdfProperties2XlsxAlignment( xlsx_conversion_context * context,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::text_format_properties_content * textProp,
const odf_reader::style_table_cell_properties_attlist * cellProp) const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp)
{ {
xlsx_alignment alignment; xlsx_alignment alignment;
if (parProp && parProp->fo_text_align_) if (parProp)
{ {
switch(parProp->fo_text_align_->get_type()) if (parProp->fo_text_align_)
{ {
default: switch(parProp->fo_text_align_->get_type())
case odf_types::text_align::Start: {
case odf_types::text_align::Left: default:
alignment.horizontal = L"left"; case odf_types::text_align::Start:
break; case odf_types::text_align::Left:
case odf_types::text_align::Right: alignment.horizontal = L"left";
case odf_types::text_align::End: break;
alignment.horizontal = L"right"; case odf_types::text_align::Right:
break; case odf_types::text_align::End:
case odf_types::text_align::Center: alignment.horizontal = L"right";
alignment.horizontal = L"center"; break;
break; case odf_types::text_align::Center:
case odf_types::text_align::Justify: alignment.horizontal = L"center";
alignment.horizontal = L"justify"; break;
break; case odf_types::text_align::Justify:
} alignment.horizontal = L"justify";
} break;
}
// TODO : indent }
if (parProp && parProp->fo_text_align_last_ && if (parProp->fo_text_align_last_ &&
parProp->fo_text_align_last_->get_type() == odf_types::text_align::Justify) parProp->fo_text_align_last_->get_type() == odf_types::text_align::Justify)
{ {
alignment.justifyLastLine = true; alignment.justifyLastLine = true;
} }
if (parProp->fo_margin_left_)
{
if (parProp->fo_margin_left_->get_type() == odf_types::length_or_percent::Length)
{
double indent_inch = parProp->fo_margin_left_->get_length().get_value_unit(odf_types::length::inch);
double indent_symbol = (int(( (indent_inch * 96.) - 5)/ context->getMaxDigitSize().first * 100. + 0.5)) /100.;
alignment.indent = (int)(indent_symbol / 1.5);
}
else //percent
{
}
}
}
_CP_OPT(odf_types::vertical_align) v_align;
if (parProp && parProp->style_vertical_align_)
v_align = parProp->style_vertical_align_;
else if (cellProp && cellProp->style_vertical_align_)
v_align = cellProp->style_vertical_align_;
if (v_align)
{
switch(v_align->get_type())
{
case odf_types::vertical_align::Top:
alignment.vertical = L"top";
break;
default:
case odf_types::vertical_align::Auto:
case odf_types::vertical_align::Middle:
alignment.vertical = L"center";
break;
case odf_types::vertical_align::Baseline:
case odf_types::vertical_align::Bottom:
alignment.vertical = L"bottom";
break;
case odf_types::vertical_align::Justify:
alignment.vertical = L"justify";
break;
}
}
if (textProp && textProp->style_text_rotation_angle_) if (textProp && textProp->style_text_rotation_angle_)
{ {
...@@ -97,55 +143,27 @@ xlsx_alignment OdfProperties2XlsxAlignment(const odf_reader::text_format_propert ...@@ -97,55 +143,27 @@ xlsx_alignment OdfProperties2XlsxAlignment(const odf_reader::text_format_propert
alignment.textRotation = angle; alignment.textRotation = angle;
} }
if (cellProp && cellProp->common_rotation_angle_attlist_.style_rotation_angle_) if (cellProp)
{ {
int angle = cellProp->common_rotation_angle_attlist_.style_rotation_angle_.get(); if (cellProp->common_rotation_angle_attlist_.style_rotation_angle_)
{
if (angle > 90) int angle = cellProp->common_rotation_angle_attlist_.style_rotation_angle_.get();
angle = angle - 90;
if (angle < -90) if (angle > 90) angle = angle - 90;
angle = 90 + angle; if (angle < -90) angle = 90 + angle;
alignment.textRotation = angle; alignment.textRotation = angle; //???
} }
if ((cellProp->fo_wrap_option_) &&
_CP_OPT(odf_types::vertical_align) v_align; (cellProp->fo_wrap_option_->get_type() == odf_types::wrap_option::Wrap))
{
if (parProp && parProp->style_vertical_align_) alignment.wrapText = true;
v_align = parProp->style_vertical_align_; }
else if (cellProp && cellProp->style_vertical_align_) if (cellProp->style_shrink_to_fit_)
v_align = cellProp->style_vertical_align_; {
alignment.shrinkToFit = *cellProp->style_shrink_to_fit_;
if (v_align) }
{ }
switch(v_align->get_type())
{
case odf_types::vertical_align::Top:
alignment.vertical = L"top";
break;
default:
case odf_types::vertical_align::Auto:
case odf_types::vertical_align::Middle:
alignment.vertical = L"center";
break;
case odf_types::vertical_align::Baseline:
case odf_types::vertical_align::Bottom:
alignment.vertical = L"bottom";
break;
case odf_types::vertical_align::Justify:
alignment.vertical = L"justify";
break;
}
}
if (cellProp &&
cellProp->fo_wrap_option_ &&
cellProp->fo_wrap_option_->get_type() == odf_types::wrap_option::Wrap
)
{
alignment.wrapText = true;
}
return alignment; return alignment;
} }
......
#ifndef _CPDOCCORE_XLSX_ALIGNMENT_H_INCLUDED_
#define _CPDOCCORE_XLSX_ALIGNMENT_H_INCLUDED_
#pragma once #pragma once
#include <iosfwd> #include <iosfwd>
...@@ -9,9 +7,9 @@ ...@@ -9,9 +7,9 @@
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { 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;
} }
} }
...@@ -19,7 +17,8 @@ class style_table_cell_properties_attlist; ...@@ -19,7 +17,8 @@ class style_table_cell_properties_attlist;
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
/// \struct xlsx_alignment class xlsx_conversion_context;
struct xlsx_alignment struct xlsx_alignment
{ {
_CP_OPT(std::wstring) horizontal; _CP_OPT(std::wstring) horizontal;
...@@ -40,11 +39,10 @@ struct xlsx_alignment ...@@ -40,11 +39,10 @@ struct xlsx_alignment
friend std::size_t hash_value(xlsx_alignment const & val); friend std::size_t hash_value(xlsx_alignment const & val);
}; };
xlsx_alignment OdfProperties2XlsxAlignment(const odf_reader::text_format_properties_content * textProp, xlsx_alignment OdfProperties2XlsxAlignment( xlsx_conversion_context * context,
const odf_reader::paragraph_format_properties * parProp, const odf_reader::text_format_properties_content * textProp,
const odf_reader::style_table_cell_properties_attlist * cellProp); const odf_reader::paragraph_format_properties * parProp,
const odf_reader::style_table_cell_properties_attlist * cellProp);
} }
} }
#endif
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
#include "xlsx_defined_names.h" #include "xlsx_defined_names.h"
#include <vector> #include <vector>
#include <boost/foreach.hpp>
#include <boost/functional.hpp>
#include <boost/unordered_set.hpp>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include "../formulasconvert/formulasconvert.h" #include "../formulasconvert/formulasconvert.h"
...@@ -15,49 +12,62 @@ namespace oox { ...@@ -15,49 +12,62 @@ namespace oox {
class xlsx_defined_names::Impl class xlsx_defined_names::Impl
{ {
public: public:
void add(std::wstring const & name, std::wstring const & ref, bool formula) void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId)
{ {
int is_file_link = 0; int is_file_link = 0;
if ((is_file_link = ref.find(L"\\")) >=0) return; if (!formula)
if ((is_file_link = ref.find(L"/")) >=0) return; {
if ((is_file_link = ref.find(L"\\")) >=0) return;
if ((is_file_link = ref.find(L"/")) >=0) return;
}
formulasconvert::odf2oox_converter converter; formulasconvert::odf2oox_converter converter;
std::wstring res; std::wstring oox_ref;
if (formula) if (formula)
{ {
res = converter.convert_named_expr(ref); oox_ref = converter.convert_named_expr(ref);
} }
else else
{ {
res = converter.convert_named_ref(ref); oox_ref = converter.convert_named_ref(ref);
} }
name_and_ref_.push_back(name_and_ref(name, res)); content_.push_back(name_and_ref());
content_.back().name = name;
content_.back().ref = oox_ref;
content_.back().tableId = tableId;
} }
void xlsx_serialize(std::wostream & _Wostream) void xlsx_serialize(std::wostream & _Wostream)
{ {
if (name_and_ref_.size() > 0) if (content_.size() > 0)
{ {
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
CP_XML_NODE(L"definedNames") CP_XML_NODE(L"definedNames")
{ {
BOOST_FOREACH(name_and_ref const & elm, name_and_ref_) for (int i = 0 ; i < content_.size(); i++)
{ {
CP_XML_NODE(L"definedName") CP_XML_NODE(L"definedName")
{ {
CP_XML_ATTR(L"name", elm.first); CP_XML_ATTR(L"name", content_[i].name);
if (content_[i].tableId >= 0)
{
CP_XML_ATTR(L"localSheetId", content_[i].tableId);
}
int pos; int pos;
if ( (pos = elm.second.find(L"#REF!")) >= 0 ) if ( (pos = content_[i].ref.find(L"#REF!")) >= 0 )
{ {
CP_XML_ATTR(L"comment", elm.second); CP_XML_ATTR(L"comment", content_[i].ref);
CP_XML_CONTENT(L"#REF!"); CP_XML_CONTENT(L"#REF!");
} }
else else
CP_XML_CONTENT(elm.second); CP_XML_CONTENT(content_[i].ref);
} }
} }
} }
...@@ -66,8 +76,15 @@ public: ...@@ -66,8 +76,15 @@ public:
} }
private: private:
typedef std::pair<std::wstring, std::wstring> name_and_ref; struct name_and_ref
std::vector<name_and_ref> name_and_ref_; {
name_and_ref() : tableId(-1) {}
std::wstring name;
std::wstring ref;
int tableId;
};
std::vector<name_and_ref> content_;
}; };
xlsx_defined_names::xlsx_defined_names() : impl_(new xlsx_defined_names::Impl()) xlsx_defined_names::xlsx_defined_names() : impl_(new xlsx_defined_names::Impl())
...@@ -78,9 +95,9 @@ xlsx_defined_names::~xlsx_defined_names() ...@@ -78,9 +95,9 @@ xlsx_defined_names::~xlsx_defined_names()
{ {
} }
void xlsx_defined_names::add(std::wstring const & name, std::wstring const & ref, bool formula) void xlsx_defined_names::add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId)
{ {
return impl_->add(name, ref, formula); return impl_->add(name, ref, formula, tableId);
} }
void xlsx_defined_names::xlsx_serialize(std::wostream & _Wostream) void xlsx_defined_names::xlsx_serialize(std::wostream & _Wostream)
......
...@@ -16,7 +16,7 @@ namespace oox { ...@@ -16,7 +16,7 @@ namespace oox {
~xlsx_defined_names(); ~xlsx_defined_names();
public: public:
void add(std::wstring const & name, std::wstring const & ref, bool formula = false); void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId);
void xlsx_serialize(std::wostream & _Wostream); void xlsx_serialize(std::wostream & _Wostream);
private: private:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "../odf/style_text_properties.h" #include "../odf/style_text_properties.h"
#include "../odf/style_paragraph_properties.h" #include "../odf/style_paragraph_properties.h"
#include "xlsx_styles.h" #include "xlsxconversioncontext.h"
#include "xlsx_fonts.h" #include "xlsx_fonts.h"
#include "xlsx_xf.h" #include "xlsx_xf.h"
#include "xlsx_borders.h" #include "xlsx_borders.h"
...@@ -25,7 +25,7 @@ public: ...@@ -25,7 +25,7 @@ public:
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: public:
Impl(); 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,
...@@ -47,6 +47,7 @@ private: ...@@ -47,6 +47,7 @@ private:
xlsx_num_fmts numFmts_; xlsx_num_fmts numFmts_;
private: private:
xlsx_conversion_context *context;
size_t next_index_; size_t next_index_;
void insert(xlsx_xf const & xf) void insert(xlsx_xf const & xf)
...@@ -56,45 +57,8 @@ private: ...@@ -56,45 +57,8 @@ private:
} }
}; };
xlsx_style_manager::xlsx_style_manager() : impl_(new xlsx_style_manager::Impl() )
{}
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,
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::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);
}
void xlsx_style_manager::xlsx_serialize(std::wostream & _Wostream)
{
return impl_->xlsx_serialize(_Wostream);
}
xlsx_style_manager::~xlsx_style_manager()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
xlsx_style_manager::Impl::Impl() : next_index_(0) xlsx_style_manager::Impl::Impl(xlsx_conversion_context *context_) : next_index_(0), context(context_)
{ {
xlsx_xf xfRecord; xlsx_xf xfRecord;
xfRecord.applyNumberForm = true; xfRecord.applyNumberForm = true;
...@@ -128,7 +92,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c ...@@ -128,7 +92,7 @@ size_t xlsx_style_manager::Impl::xfId(const odf_reader::text_format_properties_c
if (!default_border || !default_fill || is_visible_set/* || (fillId >2 && default_set!=default_fill)*/) if (!default_border || !default_fill || is_visible_set/* || (fillId >2 && default_set!=default_fill)*/)
is_visible = true; is_visible = true;
xlsx_alignment alignment = OdfProperties2XlsxAlignment(textProp, parProp, cellProp); xlsx_alignment alignment = OdfProperties2XlsxAlignment(context, textProp, parProp, cellProp);
const unsigned int id = next_index_;//static_cast<unsigned int>(cellXfs_.size()); const unsigned int id = next_index_;//static_cast<unsigned int>(cellXfs_.size());
xlsx_xf xfRecord; xlsx_xf xfRecord;
...@@ -224,6 +188,43 @@ void xlsx_style_manager::Impl::xlsx_serialize_xf(std::wostream & _Wostream, cons ...@@ -224,6 +188,43 @@ void xlsx_style_manager::Impl::xlsx_serialize_xf(std::wostream & _Wostream, cons
_Wostream << L"</" << nodeName << L">"; _Wostream << L"</" << nodeName << L">";
} }
//------------------------------------------------------------------------------------------
xlsx_style_manager::xlsx_style_manager(xlsx_conversion_context *context) : impl_(new xlsx_style_manager::Impl(context) )
{}
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,
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::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);
}
void xlsx_style_manager::xlsx_serialize(std::wostream & _Wostream)
{
return impl_->xlsx_serialize(_Wostream);
}
xlsx_style_manager::~xlsx_style_manager()
{
}
} }
} }
...@@ -5,36 +5,35 @@ ...@@ -5,36 +5,35 @@
#include <cpdoccore/CPScopedPtr.h> #include <cpdoccore/CPScopedPtr.h>
namespace cpdoccore { namespace cpdoccore {
namespace odf_reader { 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;
} }
namespace oox { namespace oox {
class xlsx_cell_format; class xlsx_cell_format;
class xlsx_conversion_context;
// class xlsx_style_manager
class xlsx_style_manager class xlsx_style_manager
{ {
public: public:
xlsx_style_manager(); xlsx_style_manager(xlsx_conversion_context *context);
size_t size() const; size_t size() const;
size_t xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::paragraph_format_properties * parProp, size_t xfId(const odf_reader::text_format_properties_content * textProp,
const odf_reader::style_table_cell_properties_attlist * cellProp, const odf_reader::paragraph_format_properties * parProp,
const xlsx_cell_format * xlxsCellFormat, const odf_reader::style_table_cell_properties_attlist * cellProp,
const std::wstring &num_format, bool default_set,bool & is_visible); 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, 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); const std::wstring &num_format, bool default_set);
void xlsx_serialize(std::wostream & _Wostream); void xlsx_serialize(std::wostream & _Wostream);
......
...@@ -88,10 +88,11 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream) ...@@ -88,10 +88,11 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
} }
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName) xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName, int tableId)
: context_ (Context), : context_ (Context),
table_style_ (styleName), table_style_ (styleName),
tableName_ (tableName), tableName_ (tableName),
tableId_ (tableId),
current_table_column_ (-1), current_table_column_ (-1),
current_table_row_ (-1), current_table_row_ (-1),
columns_spanned_num_ (0), columns_spanned_num_ (0),
...@@ -312,6 +313,28 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream) ...@@ -312,6 +313,28 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
odf_reader::odf_read_context & odfContext = context_->root()->odf_context(); odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
CP_XML_WRITER(_Wostream) CP_XML_WRITER(_Wostream)
{ {
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = odfContext.styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
if ((tableStyle) && (tableStyle->content()))
table_prop = tableStyle->content()->get_style_table_properties();
if (table_prop)
{
CP_XML_NODE(L"sheetPr")
{
//at filterMode="false">
if (table_prop->content().tableooo_tab_color_)
{
CP_XML_NODE(L"tabColor")
{
CP_XML_ATTR(L"rgb", table_prop->content().tableooo_tab_color_->get_hex_value());
}
}
//<pageSetUpPr fitToPage="true"/>
}
}
//<dimension ref="B1:T65536"/>
CP_XML_NODE(L"sheetView") CP_XML_NODE(L"sheetView")
{ {
// -showGridLines // -showGridLines
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
class xlsx_table_state class xlsx_table_state
{ {
public: public:
xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName); xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName, int tableId);
std::wstring current_style() const { return table_style_; } std::wstring current_style() const { return table_style_; }
...@@ -94,8 +94,8 @@ public: ...@@ -94,8 +94,8 @@ public:
void serialize_hyperlinks (std::wostream & _Wostream); void serialize_hyperlinks (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels); void dump_rels_hyperlinks (rels & Rels);
std::wstring get_current_table_name() const { return tableName_; } std::wstring get_table_name() const { return tableName_; }
int get_table_id() const { return tableId_; }
struct _group_row struct _group_row
{ {
bool enabled; bool enabled;
...@@ -111,6 +111,7 @@ private: ...@@ -111,6 +111,7 @@ private:
bool in_cell; bool in_cell;
xlsx_conversion_context * context_; xlsx_conversion_context * context_;
std::wstring tableName_; std::wstring tableName_;
int tableId_;
std::wstring table_style_; std::wstring table_style_;
std::wstring table_row_style_; std::wstring table_row_style_;
......
...@@ -21,14 +21,12 @@ namespace oox { ...@@ -21,14 +21,12 @@ namespace oox {
//----------------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------------
xlsx_table_state_ptr & xlsx_table_context::state() xlsx_table_state_ptr xlsx_table_context::state()
{ {
return xlsx_table_states_.back(); if (!xlsx_table_states_.empty())
} return xlsx_table_states_.back();
else
const xlsx_table_state_ptr & xlsx_table_context::state() const return xlsx_table_state_ptr();
{
return xlsx_table_states_.back();
} }
void xlsx_table_context::start_database_range(std::wstring tableName, std::wstring ref) void xlsx_table_context::start_database_range(std::wstring tableName, std::wstring ref)
...@@ -111,9 +109,9 @@ xlsx_text_context_(textContext) ...@@ -111,9 +109,9 @@ xlsx_text_context_(textContext)
{ {
} }
void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName) void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName, int id)
{ {
xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName); xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName, id);
xlsx_table_states_.push_back( state); xlsx_table_states_.push_back( state);
} }
...@@ -122,11 +120,6 @@ void xlsx_table_context::end_table() ...@@ -122,11 +120,6 @@ void xlsx_table_context::end_table()
xlsx_table_states_.pop_back(); xlsx_table_states_.pop_back();
} }
std::wstring xlsx_table_context::get_current_table_name() const
{
return state()->get_current_table_name();
}
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned) void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
{ {
state()->start_cell(columnsSpanned, rowsSpanned); state()->start_cell(columnsSpanned, rowsSpanned);
...@@ -180,7 +173,7 @@ void xlsx_table_context::non_empty_row() ...@@ -180,7 +173,7 @@ void xlsx_table_context::non_empty_row()
return state()->non_empty_row(); return state()->non_empty_row();
} }
bool xlsx_table_context::is_empty_row() const bool xlsx_table_context::is_empty_row()
{ {
return state()->is_empty_row(); return state()->is_empty_row();
} }
...@@ -200,22 +193,22 @@ unsigned int xlsx_table_context::columns_count() ...@@ -200,22 +193,22 @@ unsigned int xlsx_table_context::columns_count()
return state()->columns_count(); return state()->columns_count();
} }
std::wstring xlsx_table_context::default_row_cell_style() const std::wstring xlsx_table_context::default_row_cell_style()
{ {
return state()->default_row_cell_style(); return state()->default_row_cell_style();
} }
std::wstring xlsx_table_context::default_column_cell_style() const std::wstring xlsx_table_context::default_column_cell_style()
{ {
return state()->default_column_cell_style(); return state()->default_column_cell_style();
} }
int xlsx_table_context::current_column() const int xlsx_table_context::current_column()
{ {
return state()->current_column(); return state()->current_column();
} }
int xlsx_table_context::current_row() const int xlsx_table_context::current_row()
{ {
return state()->current_row(); return state()->current_row();
} }
...@@ -316,7 +309,7 @@ void xlsx_table_context::table_column_last_width(double w) ...@@ -316,7 +309,7 @@ void xlsx_table_context::table_column_last_width(double w)
return state()->table_column_last_width(w); return state()->table_column_last_width(w);
} }
double xlsx_table_context::table_column_last_width() const double xlsx_table_context::table_column_last_width()
{ {
return state()->table_column_last_width(); return state()->table_column_last_width();
} }
......
...@@ -18,19 +18,17 @@ public: ...@@ -18,19 +18,17 @@ public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext); xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
public: public:
void start_table(std::wstring tableName, std::wstring tableStyleName); void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void end_table(); void end_table();
std::wstring get_current_table_name() const;
void start_cell(const std::wstring & formula, void start_cell(const std::wstring & formula,
size_t columnsSpanned, size_t columnsSpanned,
size_t rowsSpanned); size_t rowsSpanned);
void end_cell(); void end_cell();
std::wstring default_row_cell_style() const; std::wstring default_row_cell_style();
std::wstring default_column_cell_style() const; std::wstring default_column_cell_style();
void start_covered_cell(); void start_covered_cell();
void end_covered_cell(); void end_covered_cell();
...@@ -41,20 +39,18 @@ public: ...@@ -41,20 +39,18 @@ public:
void set_current_cell_style_id(unsigned int xfId); void set_current_cell_style_id(unsigned int xfId);
int get_current_cell_style_id(); int get_current_cell_style_id();
int current_column() const; int current_column();
int current_row() const; int current_row();
void set_table_row_group(int count, bool collapsed, int level); void set_table_row_group(int count, bool collapsed, int level);
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();
void end_row(); void end_row();
void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName); void start_column(unsigned int repeated, const std::wstring & defaultCellStyleName);
size_t depth() const { return xlsx_table_states_.size(); } unsigned int columns_count();
unsigned int columns_count();
void serialize_sort (std::wostream & _Wostream); void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream); void serialize_autofilter (std::wostream & _Wostream);
...@@ -68,10 +64,9 @@ public: ...@@ -68,10 +64,9 @@ public:
xlsx_comments_context & get_comments_context(); xlsx_comments_context & get_comments_context();
void table_column_last_width (double w); void table_column_last_width (double w);
double table_column_last_width () const; double table_column_last_width ();
xlsx_table_state_ptr & state(); xlsx_table_state_ptr state();
const xlsx_table_state_ptr & state() const;
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);
......
...@@ -476,6 +476,10 @@ std::wstring xlsx_text_context::Impl::end_comment_content() ...@@ -476,6 +476,10 @@ std::wstring xlsx_text_context::Impl::end_comment_content()
paragraphs_cout_ = 0; paragraphs_cout_ = 0;
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
paragraph_style_name_ = L""; paragraph_style_name_ = L"";
span_style_name_ = L""; span_style_name_ = L"";
......
...@@ -35,6 +35,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD ...@@ -35,6 +35,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
num_format_context_ (odf_document_->odf_context()), num_format_context_ (odf_document_->odf_context()),
xlsx_text_context_ (odf_document_->odf_context().styleContainer()), xlsx_text_context_ (odf_document_->odf_context().styleContainer()),
xlsx_table_context_ (this, xlsx_text_context_), xlsx_table_context_ (this, xlsx_text_context_),
xlsx_style_ (this),
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ), maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),
default_style_ ( (std::numeric_limits<size_t>::max)() ), default_style_ ( (std::numeric_limits<size_t>::max)() ),
...@@ -252,12 +253,8 @@ void xlsx_conversion_context::create_new_sheet(std::wstring const & name) ...@@ -252,12 +253,8 @@ void xlsx_conversion_context::create_new_sheet(std::wstring const & name)
} }
bool xlsx_conversion_context::start_table(std::wstring tableName, std::wstring tableStyleName) bool xlsx_conversion_context::start_table(std::wstring tableName, std::wstring tableStyleName)
{ {
// TODO : nested tables forbidden
if (get_table_context().depth() > 0)
return false;
create_new_sheet(tableName); create_new_sheet(tableName);
get_table_context().start_table(tableName, tableStyleName); get_table_context().start_table(tableName, tableStyleName, sheets_.size() - 1);
current_sheet().cols() << L"<cols>"; current_sheet().cols() << L"<cols>";
return true; return true;
...@@ -343,14 +340,6 @@ void xlsx_conversion_context::end_table() ...@@ -343,14 +340,6 @@ void xlsx_conversion_context::end_table()
get_table_context().end_table(); get_table_context().end_table();
} }
void xlsx_conversion_context::dump_sheet()
{
if (!sheets_.empty())
{
sheets_.pop_back();
}
}
void xlsx_conversion_context::start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax) void xlsx_conversion_context::start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax)
{ {
cMin = get_table_context().columns_count(); cMin = get_table_context().columns_count();
...@@ -377,7 +366,7 @@ void xlsx_conversion_context::non_empty_row() ...@@ -377,7 +366,7 @@ void xlsx_conversion_context::non_empty_row()
return get_table_context().non_empty_row(); return get_table_context().non_empty_row();
} }
bool xlsx_conversion_context::is_empty_row() const bool xlsx_conversion_context::is_empty_row()
{ {
return get_table_context().is_empty_row(); return get_table_context().is_empty_row();
} }
...@@ -387,17 +376,17 @@ void xlsx_conversion_context::end_table_row() ...@@ -387,17 +376,17 @@ void xlsx_conversion_context::end_table_row()
get_table_context().end_row(); get_table_context().end_row();
} }
int xlsx_conversion_context::current_table_column() const int xlsx_conversion_context::current_table_column()
{ {
return xlsx_table_context_.current_column(); return xlsx_table_context_.current_column();
} }
int xlsx_conversion_context::current_table_row() const int xlsx_conversion_context::current_table_row()
{ {
return xlsx_table_context_.current_row(); return xlsx_table_context_.current_row();
} }
std::wstring xlsx_conversion_context::current_cell_address() const std::wstring xlsx_conversion_context::current_cell_address()
{ {
return oox::getCellAddress(current_table_column(), current_table_row()); return oox::getCellAddress(current_table_column(), current_table_row());
} }
...@@ -538,7 +527,7 @@ void xlsx_conversion_context::table_column_last_width(double w) ...@@ -538,7 +527,7 @@ void xlsx_conversion_context::table_column_last_width(double w)
return get_table_context().table_column_last_width(w); return get_table_context().table_column_last_width(w);
} }
double xlsx_conversion_context::table_column_last_width() const double xlsx_conversion_context::table_column_last_width()
{ {
return get_table_context().table_column_last_width(); return get_table_context().table_column_last_width();
} }
......
...@@ -72,14 +72,14 @@ public: ...@@ -72,14 +72,14 @@ public:
void start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax); void start_table_column(unsigned int repeated, const std::wstring & defaultCellStyleName, int & cMin, int & cMax);
void table_column_last_width(double w); void table_column_last_width(double w);
double table_column_last_width() const; double table_column_last_width();
void end_table_column(); void end_table_column();
void set_table_row_group(int count, bool collapsed, int level); void set_table_row_group(int count, bool collapsed, int level);
void start_table_row(const std::wstring & styleName, const std::wstring & defaultCellStyleName); void start_table_row(const std::wstring & styleName, const std::wstring & defaultCellStyleName);
void non_empty_row(); void non_empty_row();
void end_table_row(); void end_table_row();
bool is_empty_row() const; bool is_empty_row();
void set_current_row_height(size_t height_pt); void set_current_row_height(size_t height_pt);
bool in_table_cell(); bool in_table_cell();
...@@ -93,13 +93,13 @@ public: ...@@ -93,13 +93,13 @@ public:
void start_table_covered_cell(); void start_table_covered_cell();
void end_table_covered_cell(); void end_table_covered_cell();
int current_table_column() const; int current_table_column();
int current_table_row() const; int current_table_row();
void start_hyperlink(const std::wstring & styleName); void start_hyperlink(const std::wstring & styleName);
void end_hyperlink(std::wstring const & href); void end_hyperlink(std::wstring const & href);
std::wstring current_cell_address() const; std::wstring current_cell_address();
odf_reader::odf_document * root() odf_reader::odf_document * root()
{ {
...@@ -130,7 +130,6 @@ public: ...@@ -130,7 +130,6 @@ public:
private: private:
void create_new_sheet(std::wstring const & name); void create_new_sheet(std::wstring const & name);
void dump_sheet();
package::xlsx_document *output_document_; package::xlsx_document *output_document_;
const odf_reader::office_element *spreadsheet_; const odf_reader::office_element *spreadsheet_;
......
...@@ -22,9 +22,6 @@ namespace odf_reader { ...@@ -22,9 +22,6 @@ namespace odf_reader {
void table_format_properties::add_attributes( const xml::attributes_wc_ptr & Attributes ) void table_format_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
CP_APPLY_ATTR(L"style:width", style_width_);
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"table:align", table_align_);
common_horizontal_margin_attlist_.add_attributes(Attributes); common_horizontal_margin_attlist_.add_attributes(Attributes);
common_vertical_margin_attlist_.add_attributes(Attributes); common_vertical_margin_attlist_.add_attributes(Attributes);
common_margin_attlist_.add_attributes(Attributes); common_margin_attlist_.add_attributes(Attributes);
...@@ -33,10 +30,16 @@ void table_format_properties::add_attributes( const xml::attributes_wc_ptr & Att ...@@ -33,10 +30,16 @@ void table_format_properties::add_attributes( const xml::attributes_wc_ptr & Att
common_background_color_attlist_.add_attributes(Attributes); common_background_color_attlist_.add_attributes(Attributes);
common_shadow_attlist_.add_attributes(Attributes); common_shadow_attlist_.add_attributes(Attributes);
common_keep_with_next_attlist_.add_attributes(Attributes); common_keep_with_next_attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"style:may-break-between-rows", style_may_break_between_rows_);
CP_APPLY_ATTR(L"table:border-model", table_border_model_);
common_writing_mode_attlist_.add_attributes(Attributes); common_writing_mode_attlist_.add_attributes(Attributes);
CP_APPLY_ATTR(L"table:display", table_display_);
CP_APPLY_ATTR(L"style:width", style_width_);
CP_APPLY_ATTR(L"style:rel-width", style_rel_width_);
CP_APPLY_ATTR(L"style:may-break-between-rows", style_may_break_between_rows_);
CP_APPLY_ATTR(L"table:align", table_align_);
CP_APPLY_ATTR(L"table:border-model", table_border_model_);
CP_APPLY_ATTR(L"table:display", table_display_);
CP_APPLY_ATTR(L"tableooo:tab-color", tableooo_tab_color_);
} }
bool table_format_properties::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context) bool table_format_properties::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context)
......
...@@ -35,67 +35,26 @@ public: ...@@ -35,67 +35,26 @@ public:
void docx_convert(oox::docx_conversion_context & Context); void docx_convert(oox::docx_conversion_context & Context);
private:
// 15.8.1 style:width
optional<odf_types::length>::Type style_width_;
// style:rel-width
optional<odf_types::percent>::Type style_rel_width_;
// 15.8.2 table:align
optional<odf_types::table_align>::Type table_align_;
// 15.8.3 common-horizontal-margin-attlist
// fo:margin-left
// fo:margin-right
odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_; odf_types::common_horizontal_margin_attlist common_horizontal_margin_attlist_;
odf_types::common_vertical_margin_attlist common_vertical_margin_attlist_;
odf_types::common_margin_attlist common_margin_attlist_;
// 15.8.4 common-vertical-margin-attlist odf_types::common_page_number_attlist common_page_number_attlist_;
// fo:margin-top odf_types::common_break_attlist common_break_attlist_;
// fo:margin-bottom odf_types::common_background_color_attlist common_background_color_attlist_;
odf_types::common_vertical_margin_attlist common_vertical_margin_attlist_; odf_types::common_shadow_attlist common_shadow_attlist_;
odf_types::common_keep_with_next_attlist common_keep_with_next_attlist_;
// 15.8.5 common-margin-attlist odf_types::common_writing_mode_attlist common_writing_mode_attlist_;
// fo:margin
odf_types::common_margin_attlist common_margin_attlist_; _CP_OPT(odf_types::length) style_width_;
_CP_OPT(odf_types::percent) style_rel_width_;
// 15.8.6 common-page-number-attlist office_element_ptr style_background_image_;
// style:page-number _CP_OPT(bool) style_may_break_between_rows_;
odf_types::common_page_number_attlist common_page_number_attlist_;
_CP_OPT(odf_types::border_model) table_border_model_;
// 15.8.7 common-break-attlist _CP_OPT(odf_types::table_align) table_align_;
// fo:break-before _CP_OPT(bool) table_display_;
// fo:break-after _CP_OPT(odf_types::color) tableooo_tab_color_;
odf_types::common_break_attlist common_break_attlist_;
// 15.8.8
// common-background-color-attlist
odf_types::common_background_color_attlist common_background_color_attlist_;
office_element_ptr style_background_image_;
// 15.8.9
// common-shadow-attlist
// style:shadow
odf_types::common_shadow_attlist common_shadow_attlist_;
// 15.8.10
// common-keep-with-next-attlist
odf_types::common_keep_with_next_attlist common_keep_with_next_attlist_;
// 15.8.11
// style:may-break-between-rows
optional<bool>::Type style_may_break_between_rows_;
// 15.8.12
// table:border-model
optional<odf_types::border_model>::Type table_border_model_;
// 15.8.13
// common-writing-mode-attlist
odf_types::common_writing_mode_attlist common_writing_mode_attlist_;
// 15.8.14
// table:display
optional<bool>::Type table_display_;
}; };
...@@ -111,11 +70,12 @@ public: ...@@ -111,11 +70,12 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ; virtual void docx_convert(oox::docx_conversion_context & Context) ;
table_format_properties & content() {return table_format_properties_;}
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name); virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
private:
table_format_properties table_format_properties_; table_format_properties table_format_properties_;
}; };
...@@ -128,7 +88,6 @@ class style_table_column_properties_attlist ...@@ -128,7 +88,6 @@ class style_table_column_properties_attlist
public: public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
public:
_CP_OPT(odf_types::length) style_column_width_; _CP_OPT(odf_types::length) style_column_width_;
_CP_OPT(odf_types::length) style_rel_column_width_; _CP_OPT(odf_types::length) style_rel_column_width_;
_CP_OPT(bool) style_use_optimal_column_width_; _CP_OPT(bool) style_use_optimal_column_width_;
...@@ -218,70 +177,29 @@ public: ...@@ -218,70 +177,29 @@ public:
void apply_from(const style_table_cell_properties_attlist & Other); void apply_from(const style_table_cell_properties_attlist & Other);
public: public:
// 15.11.1 odf_types::common_shadow_attlist common_shadow_attlist_;
_CP_OPT(odf_types::vertical_align) style_vertical_align_; odf_types::common_background_color_attlist common_background_color_attlist_;
odf_types::common_border_attlist common_border_attlist_;
// 15.11.2 style:text-align-source
_CP_OPT(odf_types::text_align_source) style_text_align_source_;
// 15.11.3 style:direction
_CP_OPT(odf_types::direction) style_direction_;
// 15.11.4 style:glyph-orientation-vertical
_CP_OPT(std::wstring) style_glyph_orientation_vertical_;
// 15.11.5
odf_types::common_shadow_attlist common_shadow_attlist_;
// 15.11.6
odf_types::common_background_color_attlist common_background_color_attlist_;
// 15.11.7
odf_types::common_border_attlist common_border_attlist_;
// 15.11.8
_CP_OPT(std::wstring) style_diagonal_tl_br_;
_CP_OPT(odf_types::border_widths) style_diagonal_tl_br_widths_;
_CP_OPT(std::wstring) style_diagonal_bl_tr_;
_CP_OPT(odf_types::border_widths) style_diagonal_bl_tr_widths_;
// 15.11.9
// common-border-line-width-attlist
odf_types::common_border_line_width_attlist common_border_line_width_attlist_; odf_types::common_border_line_width_attlist common_border_line_width_attlist_;
odf_types::common_padding_attlist common_padding_attlist_;
// 15.11.10 odf_types::common_rotation_angle_attlist common_rotation_angle_attlist_;
odf_types::common_padding_attlist common_padding_attlist_;
_CP_OPT(odf_types::vertical_align) style_vertical_align_;
// 15.11.11 _CP_OPT(odf_types::text_align_source) style_text_align_source_;
// fo:wrap-option _CP_OPT(odf_types::direction) style_direction_;
_CP_OPT(odf_types::wrap_option) fo_wrap_option_; _CP_OPT(std::wstring) style_glyph_orientation_vertical_;
_CP_OPT(std::wstring) style_diagonal_tl_br_;
// 15.11.12 _CP_OPT(odf_types::border_widths) style_diagonal_tl_br_widths_;
odf_types::common_rotation_angle_attlist common_rotation_angle_attlist_; _CP_OPT(std::wstring) style_diagonal_bl_tr_;
_CP_OPT(odf_types::border_widths) style_diagonal_bl_tr_widths_;
// 15.11.13 _CP_OPT(odf_types::rotation_align) style_rotation_align_;
// style:rotation-align _CP_OPT(std::wstring) style_cell_protect_;
_CP_OPT(odf_types::rotation_align) style_rotation_align_; _CP_OPT(bool) style_print_content_;
_CP_OPT(unsigned int) style_decimal_places_;
// 15.11.14
// style:cell-protect
_CP_OPT(std::wstring) style_cell_protect_;
// 15.11.15
// style:print-content
_CP_OPT(bool) style_print_content_;
// 15.11.16
// style:decimal-places
_CP_OPT(unsigned int) style_decimal_places_;
// 15.11.17
// style:repeat-content
_CP_OPT(bool) style_repeat_content_; _CP_OPT(bool) style_repeat_content_;
// 15.11.18
_CP_OPT(bool) style_shrink_to_fit_; _CP_OPT(bool) style_shrink_to_fit_;
_CP_OPT(odf_types::wrap_option) fo_wrap_option_;
}; };
// style-table-cell-properties-elements // style-table-cell-properties-elements
......
...@@ -140,6 +140,11 @@ void table_table::add_child_element( xml::sax * Reader, const ::std::wstring & N ...@@ -140,6 +140,11 @@ void table_table::add_child_element( xml::sax * Reader, const ::std::wstring & N
{ {
CP_CREATE_ELEMENT(table_shapes_); CP_CREATE_ELEMENT(table_shapes_);
} }
else if ( CP_CHECK_NAME(L"table", L"named-expressions") ||
CP_CHECK_NAME(L"table", L"named-range") )
{
CP_CREATE_ELEMENT(table_named_);
}
else if CP_CHECK_NAME(L"calcext", L"conditional-formats") else if CP_CHECK_NAME(L"calcext", L"conditional-formats")
{ {
CP_CREATE_ELEMENT(conditional_formats_); CP_CREATE_ELEMENT(conditional_formats_);
......
...@@ -669,7 +669,7 @@ public: ...@@ -669,7 +669,7 @@ public:
office_element_ptr conditional_formats_; office_element_ptr conditional_formats_;
office_element_ptr table_shapes_; office_element_ptr table_shapes_;
office_element_ptr_array table_named_;
//office-dde-source //office-dde-source
//table-scenario //table-scenario
//office-forms //office-forms
......
...@@ -58,16 +58,21 @@ void table_named_range::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -58,16 +58,21 @@ void table_named_range::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
if (table_cell_range_address_ && table_name_) if (table_cell_range_address_ && table_name_)
{ {
int tableId = -1;
if (Context.get_table_context().state())
{
tableId = Context.get_table_context().state()->get_table_id();
}
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names(); oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
ctx.add(table_name_.get(), table_cell_range_address_.get()); ctx.add(table_name_.get(), table_cell_range_address_.get(), false, tableId);
} }
} }
void table_named_range::add_attributes(xml::attributes_wc_ptr const & Attributes) void table_named_range::add_attributes(xml::attributes_wc_ptr const & Attributes)
{ {
CP_APPLY_ATTR(L"table:name", table_name_); CP_APPLY_ATTR(L"table:name", table_name_);
CP_APPLY_ATTR(L"table:cell-range-address", table_cell_range_address_); CP_APPLY_ATTR(L"table:cell-range-address", table_cell_range_address_);
CP_APPLY_ATTR(L"table:base-cell-address", table_base_cell_address_); CP_APPLY_ATTR(L"table:base-cell-address", table_base_cell_address_);
} }
void table_named_range::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name) void table_named_range::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
...@@ -89,8 +94,13 @@ void table_named_expression::xlsx_convert(oox::xlsx_conversion_context & Context ...@@ -89,8 +94,13 @@ void table_named_expression::xlsx_convert(oox::xlsx_conversion_context & Context
{ {
if (table_expression_ && table_name_) if (table_expression_ && table_name_)
{ {
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names(); int tableId = -1;
ctx.add(table_name_.get(), table_expression_.get(), true); if (Context.get_table_context().state())
{
tableId = Context.get_table_context().state()->get_table_id();
}
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
ctx.add(table_name_.get(), table_expression_.get(), true, tableId);
} }
} }
......
...@@ -281,6 +281,11 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -281,6 +281,11 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
if (conditional_formats_) if (conditional_formats_)
conditional_formats_->xlsx_convert(Context); conditional_formats_->xlsx_convert(Context);
for (int i = 0 ; i < table_named_.size(); i++)
{
table_named_[i]->xlsx_convert(Context);
}
Context.end_table(); Context.end_table();
} }
......
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