Commit 42d1b8df authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormat Reader/Writer - review

parent e71342c4
......@@ -42,6 +42,7 @@
#include "docx_conversion_context.h"
#include "../odf/odfcontext.h"
#include "../odf/style_paragraph_properties.h"
#include "../odf/style_text_properties.h"
#include "../odf/style_graphic_properties.h"
#include "../odf/datatypes/style_ref.h"
......@@ -108,6 +109,11 @@ void text_tracked_context::set_user_info (std::wstring &author, std::wstring &da
current_state_.author = author;
current_state_.date = date;
}
void text_tracked_context::set_style_name (std::wstring style_name)
{
current_state_.style_name = style_name;
}
text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wstring id)
{
std::map<std::wstring, _state>::iterator it = mapChanges_.find(id);
......@@ -206,7 +212,7 @@ void docx_conversion_context::add_element_to_run(std::wstring parenStyleId)
textProp->content().docx_convert(*this);
}
get_styles_context().docx_serialize_text_style( output_stream(), parenStyleId);
get_styles_context().docx_serialize_text_style( output_stream(), parenStyleId, text_tracked_context_.dumpRPr_);
}
}
......@@ -818,7 +824,7 @@ void docx_conversion_context::end_process_style_content(bool in_styles)
docx_serialize_paragraph_style(output_stream(), automatic_parent_style_, in_styles);
if (automatic_parent_style_.empty())
styles_context_.docx_serialize_text_style( output_stream(), _T(""));
styles_context_.docx_serialize_text_style( output_stream(), L"", text_tracked_context_.dumpRPr_);
}
void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles)
......@@ -861,6 +867,11 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
CP_XML_STREAM() << paragraph_style.str();
docx_serialize_list_properties(CP_XML_STREAM());
if (!get_text_tracked_context().dumpPPr_.empty())
{
CP_XML_STREAM() << get_text_tracked_context().dumpPPr_;
get_text_tracked_context().dumpPPr_.clear();
}
if (run_style.tellp() > 0 && in_styles == false)
{
CP_XML_NODE(L"w:rPr")
......@@ -1286,18 +1297,70 @@ void docx_conversion_context::start_changes()
{
text_tracked_context::_state &state = it->second;
if (state.type == 3) continue; //format change ... todooo
if (state.type == 0) continue; //unknown change ... todooo
if (state.type == 1) output_stream() << L"<w:ins";
if (state.type == 2) output_stream() << L"<w:del";
std::wstring change_attr;
change_attr += L" w:date=\"" + state.date + L"\"";
change_attr += L" w:author=\"" + state.author + L"\"";
change_attr += L" w:id=\"" + std::to_wstring(current_id_changes++) + L"\"";
output_stream() << L" w:date=\"" << state.date << "\"";
output_stream() << L" w:author=\"" << state.author << "\"";
output_stream() << L" w:id=\"" << std::to_wstring(current_id_changes++) << "\"";
output_stream() << L">";
if (state.type == 1)
{
output_stream() << L"<w:ins" << change_attr << L">";
}
if (state.type == 2) output_stream() << state.content;
if (state.type == 2)
{
output_stream() << L"<w:del" << change_attr << L">";
output_stream() << state.content;
}
if (state.type == 3)
{
odf_reader::style_instance * styleInst = root()->odf_context().styleContainer().style_by_name(state.style_name, odf_types::style_family::Paragraph, false);
if (styleInst)
{
odf_reader::style_paragraph_properties * props = NULL;
props = styleInst->content()->get_style_paragraph_properties();
if (props)
{
props->docx_convert(*this);
odf_reader::style_text_properties * t_props = NULL;
t_props = styleInst->content()->get_style_text_properties();
if (t_props)
props->docx_convert(*this);
std::wstring attr = get_styles_context().paragraph_attr().str();
text_tracked_context_.dumpPPr_ = L"<w:pPrChange" + change_attr + (attr.empty() ? L">" : (L" " + attr + L">"));
text_tracked_context_.dumpPPr_ += get_styles_context().paragraph_nodes().str();
if (t_props)
{
text_tracked_context_.dumpPPr_ += L"<w:rPr>";
text_tracked_context_.dumpPPr_ += get_styles_context().text_style().str();
text_tracked_context_.dumpPPr_ += L"</w:rPr>";
}
text_tracked_context_.dumpPPr_ += L"</w:pPrChange>";
}
else
text_tracked_context_.dumpPPr_ = L"<w:pPrChange/>";
}
else if (styleInst = root()->odf_context().styleContainer().style_by_name(state.style_name, odf_types::style_family::Text, false))
{
odf_reader::style_text_properties * props = NULL;
props = styleInst->content()->get_style_text_properties();
if (props)
{
props->docx_convert(*this);
text_tracked_context_.dumpRPr_ = L"<w:rPrChange" + change_attr + L">";
text_tracked_context_.dumpRPr_ += get_styles_context().text_style().str();
text_tracked_context_.dumpRPr_ += L"</w:rPrChange>";
}else
text_tracked_context_.dumpRPr_ = L"<w:rPrChange/>";
}
else
{
}
}
}
}
......@@ -1307,12 +1370,15 @@ void docx_conversion_context::end_changes()
{
text_tracked_context::_state &state = it->second;
if (state.type == 3) continue; //format change ... todooo
if (state.type == 0) continue; //unknown change ... todooo
if (state.type == 0) continue; //unknown change ... libra format change skip
if (state.type == 3) continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
}
text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear();
}
void docx_conversion_context::end_text_changes (std::wstring id)
{
......
......@@ -495,6 +495,7 @@ public:
std::wstring date;
int type;
std::wstring content; //delete elements
std::wstring style_name;
void clear()
{
......@@ -505,6 +506,8 @@ public:
content.clear();
}
};
std::wstring dumpPPr_;
std::wstring dumpRPr_;
text_tracked_context(docx_conversion_context & context);
......@@ -516,6 +519,7 @@ public:
void set_user_info (std::wstring &author, std::wstring &date);
void set_type (int type);
void set_style_name (std::wstring style_name);
_state & get_tracked_change (std::wstring id);
......
......@@ -99,7 +99,7 @@ std::wstringstream & styles_context::list_style()
return list_style_;
}
void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId)
void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId, std::wstring & strChange)
{
if (!text_style_.str().empty())
{
......@@ -107,12 +107,18 @@ void styles_context::docx_serialize_text_style(std::wostream & strm, std::wstrin
{
CP_XML_NODE(L"w:rPr")
{
if (parenStyleId.length() > 0)
if (!parenStyleId.empty())
{
CP_XML_STREAM() << L"<w:rStyle w:val=\"" << parenStyleId << L"\" />";
}
const std::wstring & test_str = text_style_.str();
CP_XML_STREAM() << test_str;
if (!strChange.empty())//rPrChange
{
CP_XML_STREAM() << strChange;
strChange.clear();
}
}
}
}
......
......@@ -58,7 +58,7 @@ public:
std::wstringstream & table_style();
std::wstringstream & list_style();
void docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId);
void docx_serialize_text_style(std::wostream & strm, std::wstring parenStyleId, std::wstring & strChange);
void docx_serialize_table_style(std::wostream & strm);
void pptx_serialize_table_style(std::wostream & strm);
......
......@@ -325,12 +325,11 @@ xlsx_font::xlsx_font ( const odf_reader::text_format_properties_content * textP
// sz = 10.;//kDefaultFontSize; //todooo ... вытащить как в math
//}
if (textProp->style_text_underline_type_ &&
textProp->style_text_underline_type_->get_type() != odf_types::line_type::Non ||
if ((textProp->style_text_underline_type_ &&
textProp->style_text_underline_type_->get_type() != odf_types::line_type::None) ||
textProp->style_text_underline_style_ &&
textProp->style_text_underline_style_->get_type() != odf_types::line_style::None
)
(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)
......@@ -339,11 +338,11 @@ xlsx_font::xlsx_font ( const odf_reader::text_format_properties_content * textP
u = XUNDERLINE_SINGLE;
}
if (textProp->style_text_line_through_type_ &&
textProp->style_text_line_through_type_->get_type() != odf_types::line_type::Non ||
if ((textProp->style_text_line_through_type_ &&
textProp->style_text_line_through_type_->get_type() != odf_types::line_type::None) ||
textProp->style_text_line_through_style_ &&
textProp->style_text_line_through_style_->get_type() != odf_types::line_style::None)
(textProp->style_text_line_through_style_ &&
textProp->style_text_line_through_style_->get_type() != odf_types::line_style::None))
{
strike = true;
}
......
......@@ -40,7 +40,7 @@ std::wostream & operator << (std::wostream & _Wostream, const line_type & _Val)
{
switch(_Val.get_type())
{
case line_type::Non:
case line_type::None:
_Wostream << "none";
break;
case line_type::Single:
......@@ -61,15 +61,14 @@ line_type line_type::parse(const std::wstring & Str)
boost::algorithm::to_lower(tmp);
if (tmp == L"none")
return line_type( Non );
return line_type( None );
else if (tmp == L"single")
return line_type( Single );
else if (tmp == L"double")
return line_type( Double );
else
{
BOOST_THROW_EXCEPTION( errors::invalid_attribute() );
return Non;
return None;
}
}
......
......@@ -29,12 +29,7 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef _CPDOCCORE_ODF_LINETYPE_H_
#define _CPDOCCORE_ODF_LINETYPE_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <string>
#include <iosfwd>
......@@ -48,7 +43,7 @@ class line_type
public:
enum type
{
Non,
None,
Single,
Double
};
......@@ -78,5 +73,3 @@ std::wostream & operator << (std::wostream & _Wostream, const line_type & _Val);
APPLY_PARSE_XML_ATTRIBUTES(odf_types::line_type);
}
#endif
......@@ -184,7 +184,7 @@ const std::wstring & style_instance::data_style_name() const
return data_style_name_;
}
style_instance * styles_container::style_by_name(const std::wstring & Name, style_family::type Type,bool object_in_styles) const
style_instance * styles_container::style_by_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:";
......@@ -200,7 +200,7 @@ 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
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:";
......
......@@ -88,17 +88,18 @@ void text::add_text(const std::wstring & Text)
void text::docx_convert(oox::docx_conversion_context & Context)
{
Context.add_element_to_run();
std::wostream & _Wostream = Context.output_stream();
std::wostream & strm = Context.output_stream();
std::wstring textNode = L"w:t";
if (Context.get_delete_text_state()) textNode = L"w:delText";
_Wostream << L"<" << textNode;
if (preserve_ && !Context.get_delete_text_state()) _Wostream << L" xml:space=\"preserve\">";
_Wostream << L">";
strm << L"<" << textNode;
if (preserve_ && !Context.get_delete_text_state())
strm << L" xml:space=\"preserve\"";
strm << L">";
_Wostream << xml::utils::replace_text_to_xml( text_ );
_Wostream << L"</" << textNode << L">";
strm << xml::utils::replace_text_to_xml( text_ );
strm << L"</" << textNode << L">";
}
void text::xlsx_convert(oox::xlsx_conversion_context & Context)
......@@ -151,7 +152,7 @@ void s::docx_convert(oox::docx_conversion_context & Context)
strm << L"<" << textNode;
if (!Context.get_delete_text_state())
L" xml:space=\"preserve\"";
strm << L" xml:space=\"preserve\"";
strm << L">";
text_to_stream(strm);
strm << L"</" << textNode << L">";
......@@ -739,7 +740,7 @@ void title::docx_convert(oox::docx_conversion_context & Context)
strm << L"<" << textNode;
if (!Context.get_delete_text_state())
L" xml:space=\"preserve\"";
strm << L" xml:space=\"preserve\"";
strm << L">";
text_to_stream(strm);
strm << L"</" << textNode << L">";
......@@ -803,7 +804,7 @@ void subject::docx_convert(oox::docx_conversion_context & Context)
strm << L"<" << textNode;
if (!Context.get_delete_text_state())
L" xml:space=\"preserve\"";
strm << L" xml:space=\"preserve\"";
strm << L">";
text_to_stream(strm);
strm << L"</" << textNode << L">";
......@@ -866,7 +867,7 @@ void chapter::docx_convert(oox::docx_conversion_context & Context)
strm << L"<" << textNode;
if (!Context.get_delete_text_state())
L" xml:space=\"preserve\"";
strm << L" xml:space=\"preserve\"";
strm << L">";
text_to_stream(strm);
strm << L"</" << textNode << L">";
......@@ -1098,7 +1099,7 @@ void text_date::docx_convert(oox::docx_conversion_context & Context)
strm << L"<" << textNode;
if (!Context.get_delete_text_state())
L" xml:space=\"preserve\"";
strm << L" xml:space=\"preserve\"";
strm << L">";
text_to_stream(strm);
strm << L"</" << textNode << L">";
......@@ -1210,7 +1211,7 @@ void text_time::docx_convert(oox::docx_conversion_context & Context)
strm << L"<" << textNode;
if (!Context.get_delete_text_state())
L" xml:space=\"preserve\"";
strm << L" xml:space=\"preserve\"";
strm << L">";
text_to_stream(strm);
strm << L"</" << textNode << L">";
......
......@@ -473,15 +473,12 @@ void style_tab_stop::docx_convert(oox::docx_conversion_context & Context)
{
std::wstring leader;
if (style_leader_type_ && style_leader_type_->get_type() == line_type::Non ||
style_leader_style_ && style_leader_style_->get_type() == line_style::None)
if ((style_leader_type_ && style_leader_type_->get_type() == line_type::None) ||
(style_leader_style_ && style_leader_style_->get_type() == line_style::None))
{
leader = L"none";
}
else if (
!style_leader_type_ ||
style_leader_type_ && style_leader_type_->get_type() != line_type::Non
)
else if (!style_leader_type_ || style_leader_type_ && style_leader_type_->get_type() != line_type::None)
{
if (style_leader_style_)
{
......
......@@ -347,11 +347,11 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
line_width under = style_text_underline_width_.get_value_or(line_width::Auto);
bool underlineBold = under.get_type() == line_width::Bold ||
under.get_type() == line_width::Thick;
std::wstring underline = L"";
if ( style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::Non ||
style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None
)
if ((style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::None) ||
(style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None))
{
underline = L"none";
}
......@@ -362,10 +362,8 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
switch (style_text_underline_type_->get_type())
{
case line_type::Single: underline = L"sng";
break;
case line_type::Double: underline = L"double";
break;
case line_type::Single: underline = L"sng"; break;
case line_type::Double: underline = L"double"; break;
}
}
else if (style_text_underline_style_)
......@@ -520,8 +518,6 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
{
_rPr << L"<w:rStyle w:val=\"" << *r_style_ << L"\" />";
}
// 17.3.2.1
{
const int W = process_font_weight(fo_font_weight_);
if (W)
......@@ -543,14 +539,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
_rPr << L"<w:bCs w:val=\"false\" />";
}
}
// 17.3.2.5
if (fo_text_transform_)
{
_rPr << (fo_text_transform_->get_type() == text_transform::Uppercase ? L"<w:caps w:val=\"true\" />" : L"<w:caps w:val=\"false\" />");
}
// 17.3.2.16
{
const int fontStyle = process_font_style(fo_font_style_);
if (fontStyle)
......@@ -572,15 +564,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
_rPr << L"<w:iCs w:val=\"false\" />";
}
}
// 17.3.2.33
if (fo_font_variant_)
{
_rPr << (fo_font_variant_->get_type() == font_variant::SmallCaps ? L"<w:smallCaps w:val=\"true\" />" : L"<w:smallCaps w:val=\"true\" />" );
}
// 17.3.2.13
// 17.3.2.18
if (style_font_relief_)
{
if (style_font_relief_->get_type() == font_relief::Embossed)
......@@ -593,27 +580,20 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
_rPr << L"<w:imprint w:val=\"false\" />";
}
}
// 17.3.2.23
if (style_text_outline_)
{
_rPr << ((*style_text_outline_ == true) ? L"<w:outline w:val=\"true\" />" : L"<w:outline w:val=\"false\" />" );
}
// 17.3.2.31
if (fo_text_shadow_)
{
_rPr << ((fo_text_shadow_->get_type() == shadow_type::Enable) ? L"<w:shadow w:val=\"true\" />" : L"<w:shadow w:val=\"false\" />" );
}
// 17.3.2.41
if (text_display_)
{
if (text_display_->get_type() == text_display::None)
_rPr << L"<w:vanish />";
}
// 17.3.2.40
// underline
{
line_width under = style_text_underline_width_.get_value_or(line_width::Auto);
......@@ -621,9 +601,8 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
under.get_type() == line_width::Thick;
std::wstring underline = L"";
if ( style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::Non ||
style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None
)
if (( style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::None) ||
(style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None))
{
// подчеркивание выключено
underline = L"none";
......@@ -709,13 +688,9 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
_rPr << L"/>";
}
}
// 17.3.2.9
// 17.3.2.37
{
if (style_text_line_through_type_ && style_text_line_through_type_->get_type() == line_type::Non ||
style_text_line_through_style_ && style_text_line_through_style_->get_type() == line_style::None
)
if ((style_text_line_through_type_ && style_text_line_through_type_->get_type() == line_type::None) ||
(style_text_line_through_style_ && style_text_line_through_style_->get_type() == line_style::None))
{
_rPr << L"<w:dstrike w:val=\"false\" />";
_rPr << L"<w:strike w:val=\"false\" />";
......@@ -1116,9 +1091,8 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
under.get_type() == line_width::Thick;
std::wstring underline = L"";
if ( style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::Non ||
style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None
)
if ((style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::None) ||
(style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None))
{
// подчеркивание выключено
underline = L"none";
......@@ -1204,9 +1178,8 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
_rPr << L"/>";
}
}
if (style_text_line_through_type_ && style_text_line_through_type_->get_type() == line_type::Non ||
style_text_line_through_style_ && style_text_line_through_style_->get_type() == line_style::None
)
if ((style_text_line_through_type_ && style_text_line_through_type_->get_type() == line_type::None) ||
(style_text_line_through_style_ && style_text_line_through_style_->get_type() == line_style::None))
{
_rPr << L"<w:dstrike w:val=\"false\" />";
_rPr << L"<w:strike w:val=\"false\" />";
......
......@@ -94,209 +94,81 @@ private:
public:
_CP_OPT(std::wstring) r_style_;
// 15.4.1 fo:font-variant
_CP_OPT(odf_types::font_variant) fo_font_variant_; // +
// 15.4.2 fo:text-transform
_CP_OPT(odf_types::text_transform) fo_text_transform_; // +
// 15.4.3 fo:color
_CP_OPT(odf_types::color) fo_color_; // +
// 15.4.4 style:use-window-font-color
_CP_OPT(odf_types::font_variant) fo_font_variant_;
_CP_OPT(odf_types::text_transform) fo_text_transform_;
_CP_OPT(odf_types::color) fo_color_;
_CP_OPT(bool) style_use_window_font_color_;
// 15.4.5 style:text-outline
_CP_OPT(bool) style_text_outline_; // +
// 15.4.6 style:text-line-through-type
_CP_OPT(odf_types::line_type) style_text_line_through_type_; // +
// 15.4.7 style:text-line-through-style
_CP_OPT(odf_types::line_style) style_text_line_through_style_; // +
// 15.4.8 style:text-line-through-width
_CP_OPT(bool) style_text_outline_;
_CP_OPT(odf_types::line_type) style_text_line_through_type_;
_CP_OPT(odf_types::line_style) style_text_line_through_style_;
_CP_OPT(odf_types::line_width) style_text_line_through_width_;
// 15.4.9 style:text-line-through-color
_CP_OPT(odf_types::color) style_text_line_through_color_;
// 15.4.10 style:text-line-through-text
_CP_OPT(std::wstring) style_text_line_through_text_;
// 15.4.11 style:text-line-through-text-style
_CP_OPT(odf_types::style_ref) style_text_line_through_text_style_;
// 15.4.12 style:text-position
_CP_OPT(odf_types::text_position) style_text_position_; // +
// 15.4.13 style:font-name
_CP_OPT(std::wstring) style_font_name_; // +
// style:font-name-asian
_CP_OPT(std::wstring) style_font_name_asian_; // +
// style:font-name-complex
_CP_OPT(std::wstring) style_font_name_complex_; // +
// 15.4.14 fo:font-family
_CP_OPT(odf_types::text_position) style_text_position_;
_CP_OPT(std::wstring) style_font_name_;
_CP_OPT(std::wstring) style_font_name_asian_;
_CP_OPT(std::wstring) style_font_name_complex_;
_CP_OPT(std::wstring) fo_font_family_;
// style:font-family-asian
_CP_OPT(std::wstring) style_font_family_asian_;
// style:font-family-complex
_CP_OPT(std::wstring) style_font_family_complex_;
// 15.4.15 style:font-family-generic
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_;
// style:font-family-generic-asian
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_asian_;
// style:font-family-generic-complex
_CP_OPT(odf_types::font_family_generic) style_font_family_generic_complex_;
// 15.4.16 style:font-style-name
_CP_OPT(std::wstring) style_font_style_name_;
// style:font-style-name-asian
_CP_OPT(std::wstring) style_font_style_name_asian_;
// style:font-style-name-complex
_CP_OPT(std::wstring) style_font_style_name_complex_;
// 15.4.17 style:font-pitch
_CP_OPT(odf_types::font_pitch) style_font_pitch_;
// style:font-pitch
_CP_OPT(odf_types::font_pitch) style_font_pitch_asian_;
// style:font-pitch-complex
_CP_OPT(odf_types::font_pitch) style_font_pitch_complex_;
// 15.4.18 style:font-charset
_CP_OPT(std::wstring) style_font_charset_;
// style:font-charset-asian
_CP_OPT(std::wstring) style_font_charset_asian_;
// style:font-charset-complex
_CP_OPT(std::wstring) style_font_charset_complex_;
// 15.4.19 fo:font-size
_CP_OPT(odf_types::font_size) fo_font_size_; // +
// style:font-size-asian
_CP_OPT(odf_types::font_size) fo_font_size_;
_CP_OPT(odf_types::font_size) style_font_size_asian_;
// style:font-size-complex
_CP_OPT(odf_types::font_size) style_font_size_complex_;
// 15.4.20 style:font-size-rel
_CP_OPT(odf_types::length) style_font_size_rel_;
// style:font-size-rel-asian
_CP_OPT(odf_types::length) style_font_size_rel_asian_;
// style:font-size-rel-complex
_CP_OPT(odf_types::length) style_font_size_rel_complex_;
// 15.4.21 style:script-type
_CP_OPT(odf_types::script_type) style_script_type_;
// 15.4.22 fo:letter-spacing
_CP_OPT(odf_types::letter_spacing) fo_letter_spacing_; // +
// 15.4.23 fo:language
_CP_OPT(std::wstring) fo_language_; // +
// style:language-asian
_CP_OPT(odf_types::letter_spacing) fo_letter_spacing_;
_CP_OPT(std::wstring) fo_language_;
_CP_OPT(std::wstring) style_language_asian_;
// style:language-complex
_CP_OPT(std::wstring) style_language_complex_;
// 15.4.24 fo:country
_CP_OPT(std::wstring) fo_country_; // +
// style:country-asian
_CP_OPT(std::wstring) fo_country_;
_CP_OPT(std::wstring) style_country_asian_;
// style:country-complex
_CP_OPT(std::wstring) style_country_complex_;
// 15.4.25 fo:font-style
_CP_OPT(odf_types::font_style) fo_font_style_; // +
// style:font-style-asian
_CP_OPT(odf_types::font_style) fo_font_style_;
_CP_OPT(odf_types::font_style) style_font_style_asian_;
// style:font-style-complex
_CP_OPT(odf_types::font_style) style_font_style_complex_;
// 15.4.26 style:font-relief
_CP_OPT(odf_types::font_relief) style_font_relief_; // +
// 15.4.27 fo:text-shadow
_CP_OPT(odf_types::shadow_type) fo_text_shadow_; // +
// 15.4.28 style:text-underline-type
_CP_OPT(odf_types::line_type) style_text_underline_type_; // +
// 15.4.29 style:text-underline-style
_CP_OPT(odf_types::line_style) style_text_underline_style_; // +
// 15.4.30 style:text-underline-width
_CP_OPT(odf_types::line_width) style_text_underline_width_; // +
// 15.4.31 style:text-underline-color
_CP_OPT(odf_types::underline_color) style_text_underline_color_; // +
// 15.4.32 fo:font-weight
_CP_OPT(odf_types::font_weight) fo_font_weight_; // +
// style:font-weight-asian
_CP_OPT(odf_types::font_relief) style_font_relief_;
_CP_OPT(odf_types::shadow_type) fo_text_shadow_;
_CP_OPT(odf_types::line_type) style_text_underline_type_;
_CP_OPT(odf_types::line_style) style_text_underline_style_;
_CP_OPT(odf_types::line_width) style_text_underline_width_;
_CP_OPT(odf_types::underline_color) style_text_underline_color_;
_CP_OPT(odf_types::font_weight) fo_font_weight_;
_CP_OPT(odf_types::font_weight) style_font_weight_asian_;
// style:font-weight-complex
_CP_OPT(odf_types::font_weight) style_font_weight_complex_;
// 15.4.33 style:text-underline-mode
_CP_OPT(odf_types::line_mode) style_text_underline_mode_;
// 15.4.34 style:text-line-through-mode
_CP_OPT(odf_types::line_mode) style_text_line_through_mode_;
// 15.4.35 style:letter-kerning
_CP_OPT(bool) style_letter_kerning_;
// 15.4.36 style:text-blinking
_CP_OPT(bool) style_text_blinking_;
// 15.4.37 fo:background-color
_CP_OPT(odf_types::background_color) fo_background_color_;
// 15.4.38 style:text-combine
_CP_OPT(odf_types::text_combine) style_text_combine_;
// 15.4.39 style:text-combine-start-char
_CP_OPT(wchar_t) style_text_combine_start_char_;
//style:text-combine-end-char
_CP_OPT(wchar_t) style_text_combine_end_char_;
// 15.4.40 style:text-emphasize
_CP_OPT(odf_types::text_emphasize) style_text_emphasize_; // +
// 15.4.41 style:text-scale
_CP_OPT(odf_types::percent) style_text_scale_; // +
// 15.4.42 style:text-rotation-angle
_CP_OPT(odf_types::text_emphasize) style_text_emphasize_;
_CP_OPT(odf_types::percent) style_text_scale_;
_CP_OPT(int) style_text_rotation_angle_;
// 15.4.43 style:text-rotation-scale
_CP_OPT(odf_types::text_rotation_scale) style_text_rotation_scale_;
// 15.4.44 fo:hyphenate
_CP_OPT(bool) fo_hyphenate_;
// 15.4.45 fo:hyphenation-remain-char-count
_CP_OPT(unsigned int) fo_hyphenation_remain_char_count_;
// 15.4.46 fo:hyphenation-push-char-count
_CP_OPT(unsigned int) fo_hyphenation_push_char_count_;
// 15.4.47 text:display
_CP_OPT(odf_types::text_display) text_display_; // +
// text:condition
_CP_OPT(odf_types::text_display) text_display_;
_CP_OPT(std::wstring) text_condition_;
// style:text-overline-color
_CP_OPT(std::wstring) style_text_overline_color_;
// style:text-overline-mode
_CP_OPT(std::wstring) style_text_overline_mode_;
// style:text-overline-style
_CP_OPT(std::wstring) style_text_overline_style_;
};
......
......@@ -447,8 +447,10 @@ void text_list_level_style_number::docx_convert(oox::docx_conversion_context & C
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);//to style_context
Context.get_styles_context().docx_serialize_text_style( CP_XML_STREAM(), _T(""));//serialize style_context
//to style_context
textProperties->content().docx_convert(Context);
//serialize style_context
Context.get_styles_context().docx_serialize_text_style( CP_XML_STREAM(), L"", Context.get_text_tracked_context().dumpRPr_);
}
}
}
......@@ -640,7 +642,7 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM(), _T(""));
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM(), L"", Context.get_text_tracked_context().dumpRPr_);
}
}
}
......@@ -778,7 +780,7 @@ void text_list_level_style_image::docx_convert(oox::docx_conversion_context & Co
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM(), _T(""));
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM(), L"", Context.get_text_tracked_context().dumpRPr_);
}
}
}
......
......@@ -133,13 +133,14 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con
}
return;
}
typedef std::map<std::wstring, oox::text_tracked_context::_state>::iterator map_changes_iterator;
int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
{
if (!Attr.text_style_name_.empty())
{
if (style_instance * styleInst =
Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_.style_name(), style_family::Paragraph,Context.process_headers_footers_)
Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_.style_name(), style_family::Paragraph, Context.process_headers_footers_)
)
{
process_page_break_after(styleInst, Context);
......@@ -204,6 +205,13 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
}
Context.output_stream() << L"<w:pStyle w:val=\"" << id << L"\" />";
if (!Context.output_stream() << Context.get_text_tracked_context().dumpPPr_.empty())
{
Context.output_stream() << Context.get_text_tracked_context().dumpPPr_;
Context.get_text_tracked_context().dumpPPr_.clear();
}
Context.docx_serialize_list_properties(Context.output_stream());
if ((Attr.outline_level_) && (*Attr.outline_level_ > 0))
......@@ -1082,10 +1090,18 @@ void text_deletion::docx_convert(oox::docx_conversion_context & Context)
const wchar_t * text_format_change::ns = L"text";
const wchar_t * text_format_change::name = L"format-change";
void text_format_change::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"text:style-name", text_style_name_);
}
void text_format_change::docx_convert(oox::docx_conversion_context & Context)
{
Context.get_text_tracked_context().set_type(3);
if (text_style_name_)
Context.get_text_tracked_context().set_style_name(*text_style_name_);
text_unknown_base_change::docx_convert(Context);
}
//----------------------------------------------------------------------------------------------------------
......
......@@ -501,7 +501,10 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextFormatChange;
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void docx_convert(oox::docx_conversion_context & Context);
_CP_OPT(std::wstring) text_style_name_; //не по снецификации ... но КАК сохранить то что было изменено в формате?????
};
CP_REGISTER_OFFICE_ELEMENT2(text_format_change);
......
......@@ -319,7 +319,7 @@ void odf_conversion_context::add_tab(_CP_OPT(int) type, _CP_OPT(length) _length,
case 3: tab->style_leader_type_ = line_type::Single ;
tab->style_leader_style_= line_style::LongDash;
break; // tabtlcMiddleDot = 3,
case 4: tab->style_leader_type_ = line_type::Non;
case 4: tab->style_leader_type_ = line_type::None;
break; // tabtlcNone = 4,
case 5: tab->style_leader_type_ = line_type::Single;
tab->style_leader_style_= line_style::Solid;
......
......@@ -90,7 +90,6 @@ odt_conversion_context::odt_conversion_context(package::odf_document * outputDoc
is_paragraph_in_current_section_ = false;
text_changes_state_.main_text_context = NULL; //header, footer, drawing, main, ..
text_changes_state_.level = 0;
drop_cap_state_.clear();
}
......@@ -288,9 +287,6 @@ void odt_conversion_context::start_paragraph(bool styled)
}
void odt_conversion_context::add_paragraph_break(int type)
{
//office_element_ptr elm;
//create_element(L"text", L"soft-page-break", elm, this);
if (current_root_elements_.size() > 0)
{
//text_p* para = NULL;
......@@ -798,14 +794,16 @@ void odt_conversion_context::end_note()
text_context()->current_level_.pop_back();
}
//--------------------------------------------------------------------------------------------------------
void odt_conversion_context::start_change (int id, int type, std::wstring &author, std::wstring &userId, std::wstring &date)
void odt_conversion_context::start_change (int id, int type, std::wstring &author, std::wstring &userId, std::wstring &date, std::wstring style_name)
{
if (!text_changes_state_.main_text_context)
{
text_changes_state_.main_text_context = text_context();
}
text_changes_state_.level++;
if (!text_changes_state_.main_text_context) return;
if (id < 0) return;
//if (!text_changes_state_.main_text_context)
//{
// text_changes_state_.main_text_context = text_context();
//}
//if (!text_changes_state_.main_text_context) return;
text_changes_state_.current_types.push_back(type);
std::wstring strId = L"ct" + std::to_wstring(id);
//---------------------------------------------------------------------------------
......@@ -818,8 +816,12 @@ void odt_conversion_context::start_change (int id, int type, std::wstring &autho
text_add_change* change = dynamic_cast<text_add_change*>(start_elm.get());
if (change) change->text_change_id_ = strId;
text_changes_state_.main_text_context->start_element(start_elm);
text_changes_state_.main_text_context->end_element();
text_context()->start_element(start_elm);
add_to_root();//добавление/удаление параграфов и т д
text_context()->end_element();
//text_changes_state_.main_text_context->start_element(start_elm);
//text_changes_state_.main_text_context->end_element();
//---------------------------------------------------------------------------------
office_element_ptr region_elm;
create_element(L"text", L"changed-region", region_elm, this);
......@@ -843,8 +845,7 @@ void odt_conversion_context::start_change (int id, int type, std::wstring &autho
info_elm->add_child_element(creator_elm);
dc_creator* creator = dynamic_cast<dc_creator*>(creator_elm.get());
if (!creator)return;
if (creator)
creator->content_ = author;
office_element_ptr date_elm;
......@@ -852,8 +853,7 @@ void odt_conversion_context::start_change (int id, int type, std::wstring &autho
info_elm->add_child_element(date_elm);
dc_date* date_ = dynamic_cast<dc_date*>(date_elm.get());
if (!date_) return;
if (date_)
date_->content_ = date;
}
......@@ -862,20 +862,31 @@ void odt_conversion_context::start_change (int id, int type, std::wstring &autho
region_elm->add_child_element(child_elm);
if (type == 3 && !style_name.empty())
{
//не по спецификации !!!
text_format_change * format_change = dynamic_cast<text_format_change*> (child_elm.get());
if (format_change)
format_change->text_style_name_ = style_name;
}
if (type == 2)//delete
{
start_text_context();
text_context()->start_element(child_elm);
text_context()->start_paragraph();//ваще то не по стандарту .. может мы уже в параграфе (ради Libra! ... гы)
}
}
void odt_conversion_context::end_change (int id, int type)
{
if (!text_changes_state_.main_text_context) return;
//if (!text_changes_state_.main_text_context) return;
std::wstring strId = L"ct" + std::to_wstring(id);
if (type == 2)//delete
{
text_context()->end_paragraph();
text_context()->end_element();
end_text_context();
}
......@@ -887,13 +898,17 @@ void odt_conversion_context::end_change (int id, int type)
text_add_change* change = dynamic_cast<text_add_change*>(end_elm.get());
if (change) change->text_change_id_ = strId;
text_changes_state_.main_text_context->start_element(end_elm);
text_changes_state_.main_text_context->end_element();
text_context()->start_element(end_elm);
add_to_root();
text_context()->end_element();
}
text_changes_state_.level--;
text_changes_state_.current_types.pop_back();
}
bool odt_conversion_context::is_delete_changes()
{
if (text_changes_state_.current_types.empty()) return false;
if (text_changes_state_.level < 1)
text_changes_state_.main_text_context = NULL;
return (text_changes_state_.current_types.back() == 2);
}
//--------------------------------------------------------------------------------------------------------
void odt_conversion_context::start_image(const std::wstring & image_file_name)
......
......@@ -123,8 +123,9 @@ public:
void end_note_content ();
void end_note ();
void start_change (int id, int type, std::wstring &author, std::wstring &userId, std::wstring &date);
void start_change (int id, int type, std::wstring &author, std::wstring &userId, std::wstring &date, std::wstring style_name = L"");
void end_change (int id, int type);
bool is_delete_changes ();
void start_table (bool styled = false);
void start_table_columns ();
......@@ -191,7 +192,7 @@ private:
struct _text_changes_state
{
odf_text_context *main_text_context;
int level;
std::vector<int> current_types;
}text_changes_state_;
bool is_hyperlink_;
......
......@@ -484,6 +484,8 @@ void text_format_change::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"text:style-name", text_style_name_);
if (office_change_info_)
office_change_info_->serialize(CP_XML_STREAM());
......
......@@ -380,6 +380,9 @@ public:
static const ElementType type = typeTextFormatChange;
virtual void serialize(std::wostream & _Wostream);
_CP_OPT(std::wstring) text_style_name_; //не по снецификации ... но КАК сохранить то что было изменено в формате?????
};
CP_REGISTER_OFFICE_ELEMENT2(text_format_change);
......
......@@ -1270,7 +1270,7 @@ void OoxConverter::convert(OOX::Drawing::CRunProperty * oox_run_pr, odf_writer::
switch(type)
{
case SimpleTypes::underlineNone :
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Non);break;
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::None);break;
case SimpleTypes::underlineDash :
case SimpleTypes::underlineDashedHeavy:
text_properties->content().style_text_underline_style_ = odf_types::line_style(odf_types::line_style::Dash);break;
......
......@@ -114,6 +114,7 @@ namespace ComplexTypes
class CFramePr;
class CTblWidth;
class CPageBorder;
class CTrackChange;
}
}
namespace cpdoccore
......@@ -198,6 +199,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CSmartTag *oox_tag);
void convert(OOX::Logic::CPTab *oox_ptab);
int convert(ComplexTypes::Word::CTrackChange *oox_change, int type);
void convert(OOX::Logic::CIns *oox_ins);
void convert(OOX::Logic::CDel *oox_del);
int convert(OOX::Logic::CPPrChange *oox_para_prop_change);
......@@ -207,7 +209,6 @@ namespace Oox2Odf
int convert(OOX::Logic::CTcPrChange *oox_tc_prop_change);
int convert(OOX::Logic::CTblPrChange *oox_table_prop_change);
void convert(OOX::Logic::CAlternateContent *oox_alt_content);
void convert(OOX::Logic::CDrawing *oox_drawing);
void convert(OOX::Logic::CGroupShape *oox_group_shape);
......
......@@ -615,7 +615,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr)
}
convert(oox_run_pr->m_oColor.GetPointer(),text_properties->content().fo_color_);
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Non);
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::None);
if (oox_run_pr->m_oUnderline.IsInit())
{
text_properties->content().style_text_underline_style_ = odf_types::line_style(odf_types::line_style::Solid);
......@@ -631,7 +631,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CRPr *oox_run_pr)
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Double);break;
case SimpleTypes::Spreadsheet::underlineNone :
text_properties->content().style_text_underline_style_ = boost::none;
text_properties->content().style_text_underline_type_ = odf_types::line_type(odf_types::line_type::Non);break;
text_properties->content().style_text_underline_type_ = odf_types::line_type(odf_types::line_type::None);break;
case SimpleTypes::Spreadsheet::underlineSingle :
case SimpleTypes::Spreadsheet::underlineSingleAccounting :
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Single);break;
......@@ -1172,7 +1172,7 @@ void XlsxConverter::convert(OOX::Spreadsheet::CFont * font, odf_writer::style_te
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Double);break;
case SimpleTypes::Spreadsheet::underlineNone :
text_properties->content().style_text_underline_style_ = boost::none;
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Non);break;
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::None);break;
case SimpleTypes::Spreadsheet::underlineSingle :
case SimpleTypes::Spreadsheet::underlineSingleAccounting :
text_properties->content().style_text_underline_type_= odf_types::line_type(odf_types::line_type::Single);break;
......
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