Commit 71aabb5f authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - fix bugs in track changes

parent 18a96323
...@@ -82,12 +82,13 @@ void text_tracked_context::start_changes_content() ...@@ -82,12 +82,13 @@ void text_tracked_context::start_changes_content()
void text_tracked_context::end_changes_content() void text_tracked_context::end_changes_content()
{ {
current_state_.content.push_back(changes_stream_.str());
docx_context_.set_delete_text_state (false);
docx_context_.set_paragraph_state (bParaStateDocx_); docx_context_.set_paragraph_state (bParaStateDocx_);
docx_context_.set_run_state (bRunStateDocx_); docx_context_.set_run_state (bRunStateDocx_);
docx_context_.set_delete_text_state (false);
current_state_.content = changes_stream_.str(); docx_context_.set_stream_man (docx_stream_);
docx_context_.set_stream_man(docx_stream_);
} }
void text_tracked_context::start_change (std::wstring id) void text_tracked_context::start_change (std::wstring id)
{ {
...@@ -130,28 +131,27 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst ...@@ -130,28 +131,27 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) : docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
mediaitems_ (OdfDocument->get_folder() ), mediaitems_ (OdfDocument->get_folder() ),
next_dump_page_properties_(false), next_dump_page_properties_ (false),
page_break_after_ (false), page_break_after_ (false),
page_break_before_ (false), page_break_before_ (false),
in_run_ (false), in_run_ (false),
in_automatic_style_ (false), in_automatic_style_ (false),
in_paragraph_ (false), in_paragraph_ (false),
in_header_ (false), in_header_ (false),
in_drawing_content_ (false), in_drawing_content_ (false),
text_tracked_context_ (*this), text_tracked_context_ (*this),
table_context_ (*this), table_context_ (*this),
output_document_ (NULL), output_document_ (NULL),
section_properties_in_table_(NULL), process_note_ (noNote),
process_note_ (noNote), new_list_style_number_ (0),
new_list_style_number_ (0), is_rtl_ (false),
is_rtl_ (false), is_paragraph_keep_ (false),
is_paragraph_keep_ (false), is_delete_text_ (false),
is_delete_text_ (false), delayed_converting_ (false),
delayed_converting_ (false), process_headers_footers_ (false),
process_headers_footers_(false), process_comment_ (false),
process_comment_ (false), math_context_ (false),
math_context_ (false), odf_document_ (OdfDocument)
odf_document_ (OdfDocument)
{ {
streams_man_ = streams_man::create(temp_stream_); streams_man_ = streams_man::create(temp_stream_);
applicationFonts_ = new CApplicationFonts(); applicationFonts_ = new CApplicationFonts();
...@@ -1128,19 +1128,6 @@ void section_context::add_section(const std::wstring & SectionName, const std::w ...@@ -1128,19 +1128,6 @@ void section_context::add_section(const std::wstring & SectionName, const std::w
sections_.push_back(newSec); sections_.push_back(newSec);
} }
void docx_conversion_context::section_properties_in_table(odf_reader::office_element * Elm)
{
section_properties_in_table_ = Elm;
}
odf_reader::office_element * docx_conversion_context::get_section_properties_in_table()
{
odf_reader::office_element * elm = section_properties_in_table_;
section_properties_in_table_ = NULL;
return elm;
}
namespace namespace
{ {
// обработка Header/Footer // обработка Header/Footer
...@@ -1273,31 +1260,47 @@ typedef std::map<std::wstring, text_tracked_context::_state>::iterator map_chang ...@@ -1273,31 +1260,47 @@ typedef std::map<std::wstring, text_tracked_context::_state>::iterator map_chang
void docx_conversion_context::start_text_changes (std::wstring id) void docx_conversion_context::start_text_changes (std::wstring id)
{ {
text_tracked_context::_state &state = text_tracked_context_.get_tracked_change(id); text_tracked_context::_state &state_add = text_tracked_context_.get_tracked_change(id);
if (state.id != id) return; if (state_add.id != id) return;
map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state)); map_current_changes_.insert(std::pair<std::wstring, text_tracked_context::_state> (id, state_add));
if (in_paragraph_ && (state.type == 1 || state.type == 2)) if (in_paragraph_ && ( state_add.type == 1 || state_add.type == 2 ))
{ {
finish_run(); map_changes_iterator it = map_current_changes_.find(id);
text_tracked_context::_state &state = it->second;
std::wstring format_change = L" w:date=\"" + state.date + L"\"" +
L" w:author=\"" + state.author + L"\"" ;
if (state.type == 1) output_stream() << L"<w:ins"; finish_run();
if (state.type == 2) output_stream() << L"<w:del"; state.active = true;
if (state.type == 1)
{
output_stream() << L" w:date=\"" << state.date << L"\""; output_stream() << L"<w:ins" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
output_stream() << L" w:author=\"" << state.author << L"\""; }
output_stream() << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\"";
output_stream() << L">";
if (state.type == 2) if (state.type == 2)
output_stream() << state.content; {
for (int i = 0 ; i < state.content.size(); i++)
{
output_stream() << L"<w:del" << format_change << L" w:id=\"" << std::to_wstring(current_id_changes++) << L"\">";
output_stream() << state.content[i];
output_stream() << L"</w:del>";
}
map_current_changes_.erase(it);
}
} }
} }
void docx_conversion_context::start_changes() void docx_conversion_context::start_changes()
{ {
if (map_current_changes_.empty()) return; if (map_current_changes_.empty()) return;
if (process_comment_) return;
text_tracked_context_.dumpPPr_.clear(); text_tracked_context_.dumpPPr_.clear();
text_tracked_context_.dumpRPr_.clear(); text_tracked_context_.dumpRPr_.clear();
...@@ -1309,8 +1312,8 @@ void docx_conversion_context::start_changes() ...@@ -1309,8 +1312,8 @@ void docx_conversion_context::start_changes()
{ {
text_tracked_context::_state &state = it->second; text_tracked_context::_state &state = it->second;
if (state.type == 0) continue; //unknown change ... todooo if (state.type == 0) continue; //unknown change ... todooo
if (state.active) continue;
std::wstring change_attr; std::wstring change_attr;
change_attr += L" w:date=\"" + state.date + L"\""; change_attr += L" w:date=\"" + state.date + L"\"";
...@@ -1396,16 +1399,21 @@ void docx_conversion_context::start_changes() ...@@ -1396,16 +1399,21 @@ void docx_conversion_context::start_changes()
void docx_conversion_context::end_changes() void docx_conversion_context::end_changes()
{ {
//for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++) if (process_comment_) return;
//{
// text_tracked_context::_state &state = it->second;
// if (state.type == 0) continue; //unknown change ... libra format change skip for (map_changes_iterator it = map_current_changes_.begin(); it != map_current_changes_.end(); it++)
// if (state.type == 3) continue; {
text_tracked_context::_state &state = it->second;
// if (state.type == 1) output_stream() << L"</w:ins>"; if (state.type == 0) continue; //unknown change ... libra format change skip
// if (state.type == 2) output_stream() << L"</w:del>"; if (state.type == 3) continue;
//} if (!state.active) continue;
if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>";
state.active = false;
}
text_tracked_context_.dumpTcPr_.clear(); text_tracked_context_.dumpTcPr_.clear();
text_tracked_context_.dumpTblPr_.clear(); text_tracked_context_.dumpTblPr_.clear();
...@@ -1421,14 +1429,15 @@ void docx_conversion_context::end_text_changes (std::wstring id) ...@@ -1421,14 +1429,15 @@ void docx_conversion_context::end_text_changes (std::wstring id)
if (it == map_current_changes_.end()) return; if (it == map_current_changes_.end()) return;
if (in_paragraph_) text_tracked_context::_state &state = it->second;
if (state.active)
{ {
finish_run(); if (in_paragraph_)
finish_run();
text_tracked_context::_state &state = it->second;
if (state.type == 1) output_stream() << L"</w:ins>"; if (state.type == 1) output_stream() << L"</w:ins>";
if (state.type == 2) output_stream() << L"</w:del>"; if (state.type == 2) output_stream() << L"</w:del>";
} }
map_current_changes_.erase(it); map_current_changes_.erase(it);
......
...@@ -490,13 +490,14 @@ class text_tracked_context ...@@ -490,13 +490,14 @@ class text_tracked_context
public: public:
struct _state struct _state
{ {
std::wstring id; std::wstring id;
std::wstring author; std::wstring author;
std::wstring date; std::wstring date;
int type; int type;
std::wstring content; //delete elements std::wstring style_name;
std::wstring style_name; std::vector<std::wstring> content; //delete elements
bool active;
void clear() void clear()
{ {
type = 0; type = 0;
...@@ -504,6 +505,7 @@ public: ...@@ -504,6 +505,7 @@ public:
author.clear(); author.clear();
date.clear(); date.clear();
content.clear(); content.clear();
active = false;
} }
}; };
std::wstring dumpPPr_; std::wstring dumpPPr_;
...@@ -683,9 +685,6 @@ public: ...@@ -683,9 +685,6 @@ public:
docx_table_context & get_table_context() { return table_context_; } docx_table_context & get_table_context() { return table_context_; }
odf_reader::office_element * get_section_properties_in_table();
void section_properties_in_table (odf_reader::office_element * Elm);
StreamsManPtr get_stream_man() const { return streams_man_; } StreamsManPtr get_stream_man() const { return streams_man_; }
void set_stream_man(StreamsManPtr Sm) { streams_man_ = Sm; } void set_stream_man(StreamsManPtr Sm) { streams_man_ = Sm; }
...@@ -752,23 +751,23 @@ private: ...@@ -752,23 +751,23 @@ private:
odf_reader::odf_document * odf_document_; odf_reader::odf_document * odf_document_;
CApplicationFonts * applicationFonts_; CApplicationFonts * applicationFonts_;
std::vector<odf_reader::_property> settings_properties_; std::vector<odf_reader::_property> settings_properties_;
hyperlinks hyperlinks_; hyperlinks hyperlinks_;
mediaitems mediaitems_; mediaitems mediaitems_;
std::vector<oox_chart_context_ptr> charts_;
headers_footers headers_footers_;
std::wstring automatic_parent_style_; std::wstring automatic_parent_style_;
std::wstring current_master_page_name_;
std::list< const odf_reader::style_text_properties * > text_properties_stack_; std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool page_break_after_; bool page_break_after_;
bool page_break_before_; bool page_break_before_;
bool page_break_; bool page_break_;
std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
bool in_automatic_style_; bool in_automatic_style_;
bool in_drawing_content_; bool in_drawing_content_;
bool in_paragraph_; bool in_paragraph_;
...@@ -777,25 +776,14 @@ private: ...@@ -777,25 +776,14 @@ private:
bool is_delete_text_; bool is_delete_text_;
bool is_rtl_; // right-to-left bool is_rtl_; // right-to-left
bool is_paragraph_keep_; bool is_paragraph_keep_;
NoteType process_note_; int new_list_style_number_; // счетчик для нумерации имен созданных в процессе конвертации стилей
NoteType process_note_;
std::list<odf_reader::office_element *> delayed_elements_; std::list<odf_reader::office_element *> delayed_elements_;
std::vector<oox_chart_context_ptr> charts_; std::list< const odf_reader::style_text_properties * > text_properties_stack_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
odf_reader::office_element * section_properties_in_table_; boost::unordered_map<std::wstring, std::wstring> list_style_renames_;// цепочки переименований нумераций
headers_footers headers_footers_;
std::wstring current_master_page_name_;
// счетчик для нумерации имен созданных в процессе конвертации стилей
int new_list_style_number_;
std::map<std::wstring, text_tracked_context::_state> map_current_changes_;
// цепочки переименований нумераций
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;
}; };
} }
......
...@@ -332,7 +332,7 @@ const wchar_t * span::name = L"span"; ...@@ -332,7 +332,7 @@ const wchar_t * span::name = L"span";
std::wostream & span::text_to_stream(std::wostream & _Wostream) const std::wostream & span::text_to_stream(std::wostream & _Wostream) const
{ {
BOOST_FOREACH(const office_element_ptr & parElement, paragraph_content_) BOOST_FOREACH(const office_element_ptr & parElement, content_)
{ {
parElement->text_to_stream(_Wostream); parElement->text_to_stream(_Wostream);
} }
...@@ -359,13 +359,13 @@ void span::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -359,13 +359,13 @@ void span::add_attributes( const xml::attributes_wc_ptr & Attributes )
void span::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) void span::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(paragraph_content_); CP_CREATE_ELEMENT(content_);
} }
void span::add_text(const std::wstring & Text) void span::add_text(const std::wstring & Text)
{ {
office_element_ptr elm = text::create(Text); office_element_ptr elm = text::create(Text);
paragraph_content_.push_back( elm ); content_.push_back( elm );
} }
void span::docx_convert(oox::docx_conversion_context & Context) void span::docx_convert(oox::docx_conversion_context & Context)
...@@ -406,7 +406,7 @@ void span::docx_convert(oox::docx_conversion_context & Context) ...@@ -406,7 +406,7 @@ void span::docx_convert(oox::docx_conversion_context & Context)
if (!addNewRun)Context.add_new_run(); if (!addNewRun)Context.add_new_run();
BOOST_FOREACH(const office_element_ptr & parElement, paragraph_content_) BOOST_FOREACH(const office_element_ptr & parElement, content_)
{ {
parElement->docx_convert(Context); parElement->docx_convert(Context);
} }
...@@ -420,7 +420,7 @@ void span::docx_convert(oox::docx_conversion_context & Context) ...@@ -420,7 +420,7 @@ void span::docx_convert(oox::docx_conversion_context & Context)
void span::xlsx_convert(oox::xlsx_conversion_context & Context) void span::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_span(text_style_name_.style_name()); Context.start_span(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->xlsx_convert(Context); elm->xlsx_convert(Context);
} }
...@@ -432,7 +432,7 @@ void span::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -432,7 +432,7 @@ void span::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_text_context().get_styles_context().start_process_style(styleInst); Context.get_text_context().get_styles_context().start_process_style(styleInst);
Context.get_text_context().start_span(text_style_name_.style_name()); Context.get_text_context().start_span(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->pptx_convert(Context); elm->pptx_convert(Context);
} }
...@@ -446,7 +446,7 @@ const wchar_t * a::name = L"a"; ...@@ -446,7 +446,7 @@ const wchar_t * a::name = L"a";
std::wostream & a::text_to_stream(std::wostream & _Wostream) const std::wostream & a::text_to_stream(std::wostream & _Wostream) const
{ {
BOOST_FOREACH(const office_element_ptr & element, paragraph_content_) BOOST_FOREACH(const office_element_ptr & element, content_)
{ {
element->text_to_stream(_Wostream); element->text_to_stream(_Wostream);
} }
...@@ -465,13 +465,13 @@ void a::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -465,13 +465,13 @@ void a::add_attributes( const xml::attributes_wc_ptr & Attributes )
void a::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) void a::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(paragraph_content_); CP_CREATE_ELEMENT(content_);
} }
void a::add_text(const std::wstring & Text) void a::add_text(const std::wstring & Text)
{ {
office_element_ptr elm = text::create(Text) ; office_element_ptr elm = text::create(Text) ;
paragraph_content_.push_back( elm ); content_.push_back( elm );
} }
void a::docx_convert(oox::docx_conversion_context & Context) void a::docx_convert(oox::docx_conversion_context & Context)
...@@ -527,7 +527,7 @@ void a::docx_convert(oox::docx_conversion_context & Context) ...@@ -527,7 +527,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
if (!addNewRun) if (!addNewRun)
Context.add_new_run(); Context.add_new_run();
BOOST_FOREACH(const office_element_ptr & parElement, paragraph_content_) BOOST_FOREACH(const office_element_ptr & parElement, content_)
{ {
parElement->docx_convert(Context); parElement->docx_convert(Context);
} }
...@@ -542,7 +542,7 @@ void a::docx_convert(oox::docx_conversion_context & Context) ...@@ -542,7 +542,7 @@ void a::docx_convert(oox::docx_conversion_context & Context)
void a::xlsx_convert(oox::xlsx_conversion_context & Context) void a::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_hyperlink(text_style_name_.style_name()); Context.start_hyperlink(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->xlsx_convert(Context); elm->xlsx_convert(Context);
} }
...@@ -551,7 +551,7 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -551,7 +551,7 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context)
void a::pptx_convert(oox::pptx_conversion_context & Context) void a::pptx_convert(oox::pptx_conversion_context & Context)
{ {
Context.get_text_context().start_hyperlink(); Context.get_text_context().start_hyperlink();
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->pptx_convert(Context); elm->pptx_convert(Context);
} }
......
...@@ -378,7 +378,7 @@ public: ...@@ -378,7 +378,7 @@ public:
span() {} span() {}
office_element_ptr_array paragraph_content_; office_element_ptr_array content_;
odf_types::style_ref text_style_name_; odf_types::style_ref text_style_name_;
odf_types::style_ref_array text_class_names_; odf_types::style_ref_array text_class_names_;
...@@ -424,7 +424,7 @@ private: ...@@ -424,7 +424,7 @@ private:
odf_types::style_ref text_style_name_; odf_types::style_ref text_style_name_;
odf_types::style_ref text_visited_style_name_; odf_types::style_ref text_visited_style_name_;
office_element_ptr_array paragraph_content_; office_element_ptr_array content_;
}; };
CP_REGISTER_OFFICE_ELEMENT2(a); CP_REGISTER_OFFICE_ELEMENT2(a);
......
...@@ -55,7 +55,7 @@ const wchar_t * ruby_base::name = L"ruby-base"; ...@@ -55,7 +55,7 @@ const wchar_t * ruby_base::name = L"ruby-base";
std::wostream & ruby_base::text_to_stream(std::wostream & _Wostream) const std::wostream & ruby_base::text_to_stream(std::wostream & _Wostream) const
{ {
serialize_elements_text(_Wostream, paragraph_content_); serialize_elements_text(_Wostream, content_);
return _Wostream; return _Wostream;
} }
...@@ -65,13 +65,13 @@ void ruby_base::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -65,13 +65,13 @@ void ruby_base::add_attributes( const xml::attributes_wc_ptr & Attributes )
void ruby_base::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) void ruby_base::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
{ {
CP_CREATE_ELEMENT(paragraph_content_); CP_CREATE_ELEMENT(content_);
} }
void ruby_base::add_text(const std::wstring & Text) void ruby_base::add_text(const std::wstring & Text)
{ {
office_element_ptr elm = text::create(Text) ; office_element_ptr elm = text::create(Text) ;
paragraph_content_.push_back( elm ); content_.push_back( elm );
} }
// text:ruby-text // text:ruby-text
......
...@@ -64,7 +64,7 @@ private: ...@@ -64,7 +64,7 @@ private:
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
private: private:
office_element_ptr_array paragraph_content_; office_element_ptr_array content_;
}; };
...@@ -94,8 +94,8 @@ private: ...@@ -94,8 +94,8 @@ private:
virtual void add_text(const std::wstring & Text); virtual void add_text(const std::wstring & Text);
private: private:
odf_types::style_ref text_style_name_; odf_types::style_ref text_style_name_;
office_element_ptr_array content_; office_element_ptr_array content_;
}; };
......
...@@ -1275,13 +1275,6 @@ bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox ...@@ -1275,13 +1275,6 @@ bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox
} }
void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context) void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{ {
if (Context.get_table_context().in_table())
{
// мы находимся внутри таблицы, устанавливаем специальное значение
Context.section_properties_in_table(this);
return;
}
style_columns * columns = dynamic_cast<style_columns *>( style_page_layout_properties_elements_.style_columns_.get()); style_columns * columns = dynamic_cast<style_columns *>( style_page_layout_properties_elements_.style_columns_.get());
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
......
...@@ -175,18 +175,6 @@ void table_table::docx_convert(oox::docx_conversion_context & Context) ...@@ -175,18 +175,6 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
Context.get_table_context().end_table(); Context.get_table_context().end_table();
_Wostream << L"</w:tbl>"; _Wostream << L"</w:tbl>";
if (office_element * elm = Context.get_section_properties_in_table())
{
if (Context.get_table_context().in_table())
Context.section_properties_in_table(elm);
else
{
_Wostream << L"<w:p><w:pPr>";
elm->docx_convert(Context);
_Wostream << L"</w:pPr></w:p>";
}
}
} }
void table_columns::docx_convert(oox::docx_conversion_context & Context) void table_columns::docx_convert(oox::docx_conversion_context & Context)
......
...@@ -249,25 +249,25 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co ...@@ -249,25 +249,25 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
std::wostream & paragraph::text_to_stream(std::wostream & _Wostream) const std::wostream & paragraph::text_to_stream(std::wostream & _Wostream) const
{ {
// TODO!!!! // TODO!!!!
CP_SERIALIZE_TEXT(paragraph_content_); CP_SERIALIZE_TEXT(content_);
_Wostream << L"\n"; _Wostream << L"\n";
return _Wostream; return _Wostream;
} }
void paragraph::add_attributes( const xml::attributes_wc_ptr & Attributes ) void paragraph::add_attributes( const xml::attributes_wc_ptr & Attributes )
{ {
paragraph_attrs_.add_attributes(Attributes); attrs_.add_attributes(Attributes);
} }
void paragraph::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context) void paragraph::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
{ {
CP_CREATE_ELEMENT_SIMPLE(paragraph_content_); CP_CREATE_ELEMENT_SIMPLE(content_);
} }
void paragraph::add_text(const std::wstring & Text) void paragraph::add_text(const std::wstring & Text)
{ {
office_element_ptr elm = text::create(Text) ; office_element_ptr elm = text::create(Text) ;
paragraph_content_.push_back( elm ); content_.push_back( elm );
} }
void paragraph::afterCreate(document_context * Context) void paragraph::afterCreate(document_context * Context)
...@@ -301,7 +301,7 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element ...@@ -301,7 +301,7 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
str = store_str.substr(0,Context.get_drop_cap_context().Length); str = store_str.substr(0,Context.get_drop_cap_context().Length);
int textStyle = process_paragraph_attr(paragraph_attrs_, Context); int textStyle = process_paragraph_attr(attrs_, Context);
first_text_paragraph->docx_convert(Context); first_text_paragraph->docx_convert(Context);
int str_start = Context.get_drop_cap_context().Length; int str_start = Context.get_drop_cap_context().Length;
...@@ -314,16 +314,16 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element ...@@ -314,16 +314,16 @@ void paragraph::drop_cap_text_docx_convert(office_element_ptr first_text_element
} }
void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context) void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
{ {
if ( paragraph_content_.empty()) return; if ( content_.empty()) return;
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!- todooo сделать возможным множественным span //в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!- todooo сделать возможным множественным span
if ( paragraph_content_[0]->get_type() == typeTextText) if ( content_[0]->get_type() == typeTextText)
{ {
drop_cap_text_docx_convert(paragraph_content_[0],Context); drop_cap_text_docx_convert(content_[0],Context);
} }
else if (paragraph_content_[0]->get_type() == typeTextSpan) else if (content_[0]->get_type() == typeTextSpan)
{ {
span* first_span_in_paragraph = dynamic_cast<span*>(paragraph_content_[0].get()); span* first_span_in_paragraph = dynamic_cast<span*>(content_[0].get());
if (Context.get_drop_cap_context().FontSize < 1) if (Context.get_drop_cap_context().FontSize < 1)
{ {
style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(first_span_in_paragraph->text_style_name_.style_name(), style_family::Text,Context.process_headers_footers_); style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(first_span_in_paragraph->text_style_name_.style_name(), style_family::Text,Context.process_headers_footers_);
...@@ -343,10 +343,10 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context) ...@@ -343,10 +343,10 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
} }
} }
//в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!! //в рассчет берутся только первые элементы !!! разные там break-и отменяют реэжим drop_cap!!
if ((first_span_in_paragraph->paragraph_content_.size()>0) && if ((first_span_in_paragraph->content_.size()>0) &&
(first_span_in_paragraph->paragraph_content_[0]->get_type() == typeTextText)) (first_span_in_paragraph->content_[0]->get_type() == typeTextText))
{ {
drop_cap_text_docx_convert(first_span_in_paragraph->paragraph_content_[0],Context); drop_cap_text_docx_convert(first_span_in_paragraph->content_[0],Context);
} }
} }
} }
...@@ -361,9 +361,9 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -361,9 +361,9 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
bool bIsNewParagraph = true; bool bIsNewParagraph = true;
if (Context.get_paragraph_state() && (Context.get_process_note() == oox::docx_conversion_context::noNote) && !drawing ) if (Context.get_paragraph_state() && (Context.get_process_note() == oox::docx_conversion_context::noNote) && !drawing && !Context.get_delete_text_state())
{//вложеннные элементы {//вложеннные элементы
if (paragraph_content_.empty())//?? if (content_.empty())//??
{ {
Context.output_stream() << L"<w:p>"; Context.output_stream() << L"<w:p>";
Context.output_stream() << emptyParagraphContent; Context.output_stream() << emptyParagraphContent;
...@@ -377,15 +377,15 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -377,15 +377,15 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
if (!Context.get_paragraph_keep()) if (!Context.get_paragraph_keep())
{ {
for (int i = 0; i < paragraph_content_.size(); i++) for (int i = 0; i < content_.size(); i++)
{ {
paragraph_content_[i]->docx_convert(Context); content_[i]->docx_convert(Context);
} }
return; return;
} }
} }
} }
bool is_empty = paragraph_content_.empty(); bool is_empty = content_.empty();
if (bIsNewParagraph) if (bIsNewParagraph)
Context.start_paragraph(is_header_); Context.start_paragraph(is_header_);
...@@ -398,7 +398,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -398,7 +398,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
// если да — устанавливаем контексту флаг на то что необходимо в конце текущего параграфа // если да — устанавливаем контексту флаг на то что необходимо в конце текущего параграфа
// распечатать свойства секции // распечатать свойства секции
//проверить ... не она ли основная - может быть прописан дубляж - и тогда разрыв нарисуется ненужный //проверить ... не она ли основная - может быть прописан дубляж - и тогда разрыв нарисуется ненужный
const std::wstring & next_styleName = next_par_->paragraph_attrs_.text_style_name_.style_name(); const std::wstring & next_styleName = next_par_->attrs_.text_style_name_.style_name();
const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName); const _CP_OPT(std::wstring) next_masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(next_styleName);
if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName)) if ((next_masterPageName) && (Context.get_master_page_name() != *next_masterPageName))
...@@ -413,7 +413,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -413,7 +413,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty = false; is_empty = false;
} }
const std::wstring & styleName = paragraph_attrs_.text_style_name_.style_name(); const std::wstring & styleName = attrs_.text_style_name_.style_name();
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName); const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName);
if (masterPageName) if (masterPageName)
...@@ -430,7 +430,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -430,7 +430,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
is_empty = false; is_empty = false;
} }
process_paragraph_drop_cap_attr(paragraph_attrs_, Context); process_paragraph_drop_cap_attr(attrs_, Context);
if (Context.get_drop_cap_context().state() == 2)//active if (Context.get_drop_cap_context().state() == 2)//active
{ {
...@@ -444,11 +444,11 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -444,11 +444,11 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
} }
int textStyle = process_paragraph_attr(paragraph_attrs_, Context); int textStyle = process_paragraph_attr(attrs_, Context);
Context.add_note_reference(); Context.add_note_reference();
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
if (Context.get_page_break()) if (Context.get_page_break())
{ {
...@@ -501,8 +501,8 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -501,8 +501,8 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context) void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
{ {
Context.start_paragraph(paragraph_attrs_.text_style_name_.style_name()); Context.start_paragraph(attrs_.text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->xlsx_convert(Context); elm->xlsx_convert(Context);
} }
...@@ -510,12 +510,14 @@ void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -510,12 +510,14 @@ void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
void paragraph::pptx_convert(oox::pptx_conversion_context & Context) void paragraph::pptx_convert(oox::pptx_conversion_context & Context)
{ {
Context.get_text_context().start_paragraph(paragraph_attrs_.text_style_name_.style_name()); Context.get_text_context().start_paragraph(attrs_.text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
BOOST_FOREACH(const office_element_ptr & elm, content_)
{ {
elm->pptx_convert(Context); elm->pptx_convert(Context);
} }
Context.get_text_context().end_paragraph();
Context.get_text_context().end_paragraph();
} }
/////////////////////////////////////////// ///////////////////////////////////////////
void soft_page_break::docx_convert(oox::docx_conversion_context & Context) void soft_page_break::docx_convert(oox::docx_conversion_context & Context)
...@@ -546,7 +548,7 @@ void h::add_attributes( const xml::attributes_wc_ptr & Attributes ) ...@@ -546,7 +548,7 @@ void h::add_attributes( const xml::attributes_wc_ptr & Attributes )
paragraph_.add_attributes(Attributes); paragraph_.add_attributes(Attributes);
paragraph_.is_header_ = true; paragraph_.is_header_ = true;
paragraph_.paragraph_attrs_.outline_level_ = text_outline_level_; paragraph_.attrs_.outline_level_ = text_outline_level_;
} }
void h::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) void h::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
...@@ -1071,12 +1073,29 @@ void text_unknown_base_change::docx_convert(oox::docx_conversion_context & Conte ...@@ -1071,12 +1073,29 @@ void text_unknown_base_change::docx_convert(oox::docx_conversion_context & Conte
if (content_.empty()) return; if (content_.empty()) return;
//тут удаленный текст. не по стандарту сделать бы и форматы - стилями чтоли .... //тут удаленный текст. не по стандарту сделать бы и форматы - стилями чтоли ....
Context.get_text_tracked_context().start_changes_content();
for (int i = 0; i < content_.size(); i++) for (int i = 0; i < content_.size(); i++)
{
Context.get_text_tracked_context().start_changes_content();
{ {
content_[i]->docx_convert(Context); h *h_ = dynamic_cast<h*>(content_[i].get());
p *p_ = dynamic_cast<p*>(content_[i].get());
paragraph *para = NULL;
if (h_) para = &h_->paragraph_;
if (p_) para = &p_->paragraph_;
if (para)
{
for (int j = 0; j < para->content_.size(); j++)
{
para->content_[j]->docx_convert(Context);
}
}
} }
Context.get_text_tracked_context().end_changes_content(); Context.get_text_tracked_context().end_changes_content();
}
} }
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
const wchar_t * text_insertion::ns = L"text"; const wchar_t * text_insertion::ns = L"text";
......
...@@ -56,12 +56,12 @@ public: ...@@ -56,12 +56,12 @@ public:
std::wostream & text_to_stream(std::wostream & _Wostream) const; std::wostream & text_to_stream(std::wostream & _Wostream) const;
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes ( const xml::attributes_wc_ptr & Attributes );
void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context); void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context);
void add_text(const std::wstring & Text); void add_text (const std::wstring & Text);
paragraph * get_next() { return next_par_; } paragraph * get_next() { return next_par_; }
void set_next(paragraph * next) {next_par_ = next;} void set_next(paragraph * next) {next_par_ = next;}
void set_next_section(bool Val) void set_next_section(bool Val)
{ {
...@@ -75,17 +75,17 @@ public: ...@@ -75,17 +75,17 @@ public:
void afterCreate(document_context * ctx); void afterCreate(document_context * ctx);
void docx_convert(oox::docx_conversion_context & Context) ; void docx_convert (oox::docx_conversion_context & Context) ;
void xlsx_convert(oox::xlsx_conversion_context & Context) ; void xlsx_convert (oox::xlsx_conversion_context & Context) ;
void pptx_convert(oox::pptx_conversion_context & Context) ; void pptx_convert (oox::pptx_conversion_context & Context) ;
void drop_cap_docx_convert(oox::docx_conversion_context & Context); void drop_cap_docx_convert(oox::docx_conversion_context & Context);
office_element_ptr_array content_;
private: private:
void drop_cap_text_docx_convert(office_element_ptr first_text_paragraph,oox::docx_conversion_context & Context); void drop_cap_text_docx_convert(office_element_ptr first_text_paragraph,oox::docx_conversion_context & Context);
paragraph_attrs paragraph_attrs_; paragraph_attrs attrs_;
office_element_ptr_array paragraph_content_;
paragraph *next_par_; paragraph *next_par_;
...@@ -117,6 +117,7 @@ public: ...@@ -117,6 +117,7 @@ public:
virtual void afterCreate(); virtual void afterCreate();
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const; virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
paragraph paragraph_;
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
...@@ -130,8 +131,6 @@ private: ...@@ -130,8 +131,6 @@ private:
_CP_OPT(bool) text_is_list_header_; _CP_OPT(bool) text_is_list_header_;
_CP_OPT(std::wstring) text_number_; _CP_OPT(std::wstring) text_number_;
paragraph paragraph_;
friend class par_docx_convert_class; friend class par_docx_convert_class;
}; };
......
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