Commit 3a2c6d75 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

OdfFile

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63362 954022d7-b5bf-4e40-9824-e11837661b57
parent f7eb124e
......@@ -72,6 +72,8 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
if ((!strStrokeColor && !iStroke && !dStrokeWidth) && !always_draw)return;
if ((iStroke) && (*iStroke==0)) return; //none
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:ln")
......@@ -86,7 +88,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf_reader::_prope
else dash_style = _ooxDashStyle[iStroke.get()];
}
if ((dStrokeWidth) && (dStrokeWidth.get()> 0))
if ((dStrokeWidth) && (dStrokeWidth.get()>= 0))
{
CP_XML_ATTR(L"w",static_cast<size_t>(dStrokeWidth.get() * 12700));//in emu (1 pt = 12700)
if (color.length()<1)color = L"729FCF";
......
......@@ -78,7 +78,8 @@ void pptx_table_state::start_cell()
}
void pptx_table_state::end_cell()
{}
{
}
bool pptx_table_state::start_covered_cell(pptx_conversion_context & Context)
{
......@@ -127,11 +128,24 @@ void pptx_table_state::end_covered_cell()
std::wostream & _Wostream = context_.get_table_context().tableData();
if (close_table_covered_cell_)
{
const std::wstring cellStyleName = default_row_cell_style_name_.length()>0 ? default_row_cell_style_name_ : default_cell_style_name_;
const odf_reader::style_instance * style_inst = context_.root()->odf_context().styleContainer().style_by_name(cellStyleName, odf_types::style_family::TableCell,false);
std::vector<const odf_reader::style_instance *> style_instances;
std::wstring style_name;
odf_reader::style_instance *style_inst = context_.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::TableCell);
if (style_inst) style_instances.push_back(style_inst);
if (!default_cell_style_name_.empty())//template
{
style_inst = context_.root()->odf_context().styleContainer().style_by_name(default_cell_style_name_, odf_types::style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
if (!default_row_cell_style_name_.empty())
{
style_inst = context_.root()->odf_context().styleContainer().style_by_name(default_row_cell_style_name_, odf_types::style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
oox::oox_serialize_tcPr(_Wostream, style_inst, context_);
oox::oox_serialize_tcPr(_Wostream, style_instances, context_);
//
_Wostream << L"</a:tc>";
......@@ -262,20 +276,13 @@ void oox_serialize_border(std::wostream & strm, std::wstring Node, pptx_border_e
}
}
void oox_serialize_tcPr(std::wostream & strm, const odf_reader::style_instance* style_inst, oox::pptx_conversion_context & Context)
void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::style_instance *> & instances, oox::pptx_conversion_context & Context)
{
const odf_reader::style_instance * default_style_inst = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::TableCell);
std::vector<const odf_reader::style_instance *> instances;
if (default_style_inst) instances.push_back(default_style_inst);
if (style_inst) instances.push_back(style_inst);
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:tcPr")
{
if (style_inst || default_style_inst)
if (instances.size() > 0)
{
odf_reader::style_table_cell_properties_attlist style_cell_attlist = odf_reader::calc_table_cell_properties(instances);
......@@ -314,7 +321,7 @@ void oox_serialize_tcPr(std::wostream & strm, const odf_reader::style_instance*
//vert //
//style_cell_attlist.pptx_serialize(Context, CP_XML_STREAM()); //nodes
odf_reader::paragraph_format_properties style_paragraph = odf_reader::calc_paragraph_properties_content(style_inst);//instances);
odf_reader::paragraph_format_properties style_paragraph = odf_reader::calc_paragraph_properties_content(instances);//instances);
pptx_border_edge left, top, bottom, right;
......
......@@ -186,7 +186,7 @@ private:
std::list<pptx_table_state> table_state_stack_;
};
void oox_serialize_tcPr(std::wostream & strm, const odf_reader::style_instance* style_inst, oox::pptx_conversion_context & Context);
void oox_serialize_tcPr(std::wostream & strm, std::vector<const odf_reader::style_instance *> & style_inst, oox::pptx_conversion_context & Context);
}
}
......@@ -256,7 +256,7 @@ void draw_polygon::reset_polygon_path()
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;
bool res = svg_path::parsePolygon(o_Polyline_cm,draw_polygon_attlist_.draw_points_.get(),false);
bool res = svg_path::parsePolygon(o_Polyline_cm,draw_polygon_attlist_.draw_points_.get(),false, true);
BOOST_FOREACH(svg_path::_polyline & poly, o_Polyline_cm)
{
......@@ -308,7 +308,7 @@ void draw_polyline::reset_polyline_path()
std::vector<svg_path::_polyline> o_Polyline_pt;
std::vector<svg_path::_polyline> o_Polyline_cm;
bool res = svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false);
bool res = svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, false);
_CP_OPT(double) start_x, start_y;
......@@ -320,13 +320,13 @@ void draw_polyline::reset_polyline_path()
{
if (!start_x)// .. ""
start_x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu);
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu) - *start_x;
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu);// - *start_x;
}
if (poly.points[i].y)
{
if (!start_y)
start_y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu);
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu) - *start_y;
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu);// - *start_y;
}
}
o_Polyline_pt.push_back(poly);
......
......@@ -120,8 +120,15 @@ enum ElementType
typeStylePageLayout,
typeStyleMap,
typeTableBodyTemplate,
typeTableTemplate,
typeTableTemplateElement,
typeTableBodyTemplate,
typeTableFirstRowTemplate,
typeTableLastRowTemplate,
typeTableFirstColumnTemplate,
typeTableLastColumnTemplate,
typeTableOddColumnsTemplate,
typeTableOddRowsTemplate,
typeTextNotesConfiguration,
......
......@@ -743,7 +743,7 @@ namespace svg_path
return true;
}
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & rPolygonStatement, bool bWrongPositionAfterZ)
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & rPolygonStatement, bool bWrongPositionAfterZ, bool closed)
{
Polyline.clear();
......@@ -770,7 +770,7 @@ namespace svg_path
aCurrPoly.points.clear();
aCurrPoly.command = L"a:lnTo";
}
if (Polyline.size()>2)
if (Polyline.size()>2 && closed)
{
//
Polyline.push_back(Polyline[0]);
......
......@@ -45,7 +45,7 @@ namespace svg_path
void oox_serialize(std::wostream & _Wostream, std::vector<svg_path::_polyline> & path);
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ);
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & rPolygonStatement, bool bWrongPositionAfterZ);
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & rPolygonStatement, bool bWrongPositionAfterZ, bool closed);
}
}
......
......@@ -145,10 +145,10 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
{
if (table_table_template* template_ = dynamic_cast<table_table_template *>(style.get()))
{
//first row, columns, last row, columns, odd row, columns
//first row, columns, last row, columns, odd row, columns todoooo
if (template_->table_body_)
{
table_body* body_ = dynamic_cast<table_body* >(template_->table_body_.get());
table_body_template* body_ = dynamic_cast<table_body_template* >(template_->table_body_.get());
Context.get_table_context().set_default_cell_style(body_->table_style_name_);
}
}
......@@ -301,11 +301,36 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_table_context().start_cell();
CP_XML_NODE(L"a:tc")
{
std::wstring cellStyleName = table_table_cell_attlist_.table_style_name_ ?
table_table_cell_attlist_.table_style_name_->style_name() : //from cell attlist
Context.get_table_context().get_default_cell_style_row();// from row attlist
std::vector<const style_instance *> style_instances;
if (cellStyleName.length() < 1)cellStyleName = Context.get_table_context().get_default_cell_style(); //from template
std::wstring style_name;
style_instance *style_inst = Context.root()->odf_context().styleContainer().style_default_by_type(odf_types::style_family::TableCell);
if (style_inst) style_instances.push_back(style_inst);
style_name = Context.get_table_context().get_default_cell_style();
if (!style_name.empty())
{
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
style_name = Context.get_table_context().get_default_cell_style_col(Context.get_table_context().current_column());
if (!style_name.empty())
{
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst)style_instances.push_back(style_inst);
}
style_name = Context.get_table_context().get_default_cell_style_row();
if (!style_name.empty())
{
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
style_name = table_table_cell_attlist_.table_style_name_ ? table_table_cell_attlist_.table_style_name_->style_name() : L"";
if (!style_name.empty())
{
style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name, style_family::TableCell,false);
if (style_inst) style_instances.push_back(style_inst);
}
if (table_table_cell_attlist_extra_.table_number_rows_spanned_ > 1)
{
......@@ -315,7 +340,7 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_table_context().set_rows_spanned(Context.get_table_context().current_column(),
table_table_cell_attlist_extra_.table_number_rows_spanned_ - 1,
table_table_cell_attlist_extra_.table_number_columns_spanned_ - 1,
cellStyleName);
style_name);
}
if (table_table_cell_attlist_extra_.table_number_columns_spanned_ > 1)
......@@ -343,8 +368,7 @@ void table_table_cell::pptx_convert(oox::pptx_conversion_context & Context)
CP_XML_STREAM() << emptyParTable;
const style_instance * style_inst = Context.root()->odf_context().styleContainer().style_by_name(cellStyleName, style_family::TableCell,false);
oox_serialize_tcPr(CP_XML_STREAM(), style_inst,Context);
oox_serialize_tcPr(CP_XML_STREAM(), style_instances, Context);
}
......
......@@ -11,15 +11,45 @@ namespace cpdoccore {
namespace odf_reader {
const wchar_t * table_body::ns = L"table";
const wchar_t * table_body::name = L"body";
const wchar_t * table_template_element::ns = L"table";
const wchar_t * table_template_element::name = L"template_element";
void table_body::add_attributes( const xml::attributes_wc_ptr & Attributes )
void table_template_element::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
std::wstring text_style_name_;
const std::wstring empty = L"";
CP_APPLY_ATTR(L"table:style-name", table_style_name_, empty);
CP_APPLY_ATTR(L"text:style-name", text_style_name_, empty);
if (table_style_name_.empty())
table_style_name_ = text_style_name_;
//http://lists.freedesktop.org/archives/libreoffice-bugs/2011-March/007109.html
// 1 (7).odp
}
const wchar_t * table_body_template::ns = L"table";
const wchar_t * table_body_template::name = L"body";
const wchar_t * table_first_row_template::ns = L"table";
const wchar_t * table_first_row_template::name = L"first-row";
const wchar_t * table_last_row_template::ns = L"table";
const wchar_t * table_last_row_template::name = L"last-row";
const wchar_t * table_first_column_template::ns = L"table";
const wchar_t * table_first_column_template::name = L"first-column";
const wchar_t * table_last_column_template::ns = L"table";
const wchar_t * table_last_column_template::name = L"last-column";
const wchar_t * table_odd_columns_template::ns = L"table";
const wchar_t * table_odd_columns_template::name = L"odd-columns";
const wchar_t * table_odd_rows_template::ns = L"table";
const wchar_t * table_odd_rows_template::name = L"odd-rows";
//----------------------------------------------------------------------------------------
const wchar_t * table_table_template::ns = L"table";
const wchar_t * table_table_template::name = L"table-template";
......@@ -34,8 +64,29 @@ void table_table_template::add_child_element( xml::sax * Reader, const ::std::ws
{
CP_CREATE_ELEMENT(table_body_);
}
else
else if CP_CHECK_NAME(L"table", L"first-row")
{
CP_CREATE_ELEMENT(table_first_row_);
}
else if CP_CHECK_NAME(L"table", L"last-row")
{
CP_CREATE_ELEMENT(table_last_row_);
}
else if CP_CHECK_NAME(L"table", L"first-column")
{
CP_CREATE_ELEMENT(table_first_column_);
}
else if CP_CHECK_NAME(L"table", L"last-column")
{
CP_CREATE_ELEMENT(table_last_column_);
}
else if CP_CHECK_NAME(L"table", L"odd-rows")
{
CP_CREATE_ELEMENT(table_odd_rows_);
}
else if CP_CHECK_NAME(L"table", L"odd-columns")
{
CP_CREATE_ELEMENT(table_odd_columns_);
}
}
}
......
......@@ -17,18 +17,29 @@
namespace cpdoccore {
namespace odf_reader {
class table_body: public office_element_impl<table_body>
//<define name="common-table-template-attlist">
// <attribute name="table:style-name">
// <ref name="styleNameRef"/>
// </attribute>
// <optional>
// <attribute name="table:paragraph-style-name">
// <ref name="styleNameRef"/>
// </attribute>
// </optional>
//</define>
class table_template_element: public office_element_impl<table_template_element>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableBodyTemplate;
static const ElementType type = typeTableTemplateElement;
CPDOCCORE_DEFINE_VISITABLE();
//common-table-template-attlist
std::wstring table_style_name_;
private:
......@@ -39,8 +50,78 @@ private:
friend class odf_document;
};
CP_REGISTER_OFFICE_ELEMENT2(table_body);
class table_body_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableBodyTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_body_template);
class table_first_row_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableFirstRowTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_first_row_template);
class table_last_row_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableLastRowTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_last_row_template);
class table_first_column_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableFirstColumnTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_first_column_template);
class table_last_column_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableLastColumnTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_last_column_template);
class table_odd_columns_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableOddColumnsTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_odd_columns_template);
class table_odd_rows_template: public table_template_element
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableOddRowsTemplate;
};
CP_REGISTER_OFFICE_ELEMENT2(table_odd_rows_template);
//--------------------------------------------------------------------
class table_table_template: public office_element_impl<table_table_template>
{
......@@ -55,6 +136,12 @@ public:
std::wstring get_text_style_name(){return text_style_name_.get_value_or(L"");}
office_element_ptr table_body_;
office_element_ptr table_first_row_;
office_element_ptr table_last_row_;
office_element_ptr table_first_column_;
office_element_ptr table_last_column_;
office_element_ptr table_odd_rows_;
office_element_ptr table_odd_columns_;
private:
_CP_OPT(std::wstring) text_style_name_;
......
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