Commit 369596b8 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - fix dropCap, sections

parent 15af8f56
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="Urlmon.lib" AdditionalDependencies="Urlmon.lib"
LinkIncremental="1" LinkIncremental="1"
IgnoreDefaultLibraryNames="LIBCMTD.lib" IgnoreDefaultLibraryNames=""
IgnoreEmbeddedIDL="true" IgnoreEmbeddedIDL="true"
GenerateDebugInformation="true" GenerateDebugInformation="true"
SubSystem="1" SubSystem="1"
......
...@@ -59,7 +59,7 @@ HRESULT convert_single(std::wstring srcFileName) ...@@ -59,7 +59,7 @@ HRESULT convert_single(std::wstring srcFileName)
switch(fileChecker.nFileType) switch(fileChecker.nFileType)
{ {
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX: case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX:
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"document"; break; case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCM: dstPath += L"-my.odt"; type = L"text"; break;
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX: case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: dstPath += L"-my.ods"; type = L"spreadsheet"; break; case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSM: dstPath += L"-my.ods"; type = L"spreadsheet"; break;
......
...@@ -118,7 +118,7 @@ void odt_conversion_context::start_document() ...@@ -118,7 +118,7 @@ void odt_conversion_context::start_document()
void odt_conversion_context::end_document() void odt_conversion_context::end_document()
{ {
//add sections to root //add sections to root
for (size_t i = 0; i< sections_.size(); i++) for (size_t i = 0; i < sections_.size(); i++)
{ {
root_document_->add_child_element(sections_[i].elm); root_document_->add_child_element(sections_[i].elm);
} }
...@@ -183,7 +183,8 @@ odf_text_context* odt_conversion_context::text_context() ...@@ -183,7 +183,8 @@ odf_text_context* odt_conversion_context::text_context()
} }
void odt_conversion_context::start_text_context() void odt_conversion_context::start_text_context()
{ {
odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, odf_conversion_context::styles_context())); odf_text_context_ptr new_text_context_ = boost::shared_ptr<odf_text_context>(new odf_text_context(this, /*odf_conversion_context::*/styles_context()));
//объекты с текстом в колонтитулах
if (!new_text_context_)return; if (!new_text_context_)return;
text_context_.push_back(new_text_context_); text_context_.push_back(new_text_context_);
...@@ -199,17 +200,18 @@ void odt_conversion_context::add_text_content(const std::wstring & text) ...@@ -199,17 +200,18 @@ void odt_conversion_context::add_text_content(const std::wstring & text)
{ {
if (drop_cap_state_.enabled) if (drop_cap_state_.enabled)
{ {
int count = text.size(); int count = text.length();
drop_cap_state_.characters += count; drop_cap_state_.characters += count;
if (drop_cap_state_.inline_style == false)
style_text_properties * props = text_context()->get_text_properties();
if (props)
{ {
style_text_properties * props = text_context()->get_text_properties(); if (drop_cap_state_.inline_style == false)
if (props)
{ {
std::wstring f_name = props->content_.fo_font_family_.get_value_or(L"Arial"); std::wstring f_name = props->content_.fo_font_family_.get_value_or(L"Arial");
double f_size = props->content_.fo_font_size_.get_value_or(font_size(length(12,length::pt))).get_length().get_value_unit(length::pt); double f_size = props->content_.fo_font_size_.get_value_or(font_size(length(12, length::pt))).get_length().get_value_unit(length::pt);
drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size, applicationFonts_); drop_cap_state_.characters_size_pt += utils::calculate_size_font_symbols(text, f_name, f_size, applicationFonts_);
} }
} }
} }
...@@ -479,6 +481,14 @@ int odt_conversion_context::get_current_section_columns() ...@@ -479,6 +481,14 @@ int odt_conversion_context::get_current_section_columns()
} }
void odt_conversion_context::add_section(bool continuous) void odt_conversion_context::add_section(bool continuous)
{ {
//--dump first elements to root------------------------------------------------
for (size_t i = 0; i< current_root_elements_.size(); i++)
{
root_document_->add_child_element(current_root_elements_[i].elm);
}
current_root_elements_.clear();
//----------------------------------------------------------------------------
odt_section_state state; odt_section_state state;
state.empty = true; state.empty = true;
...@@ -662,9 +672,9 @@ void odt_conversion_context::set_no_list() ...@@ -662,9 +672,9 @@ void odt_conversion_context::set_no_list()
} }
void odt_conversion_context::flush_section() void odt_conversion_context::flush_section()
{ {
if (sections_.size() > 0 && sections_.back().empty) if (!sections_.empty() && sections_.back().empty)
{ {
for (size_t i=0; i< current_root_elements_.size(); i++) for (size_t i = 0; i < current_root_elements_.size(); i++)
{ {
if ((sections_.back().continuous && i < 2) || !sections_.back().continuous) if ((sections_.back().continuous && i < 2) || !sections_.back().continuous)
// при вставлении параграфа возможен искусственный разрыв в параграфах - см add_page_break // при вставлении параграфа возможен искусственный разрыв в параграфах - см add_page_break
...@@ -697,7 +707,7 @@ void odt_conversion_context::start_run(bool styled) ...@@ -697,7 +707,7 @@ void odt_conversion_context::start_run(bool styled)
if (is_hyperlink_ && text_context_.size() > 0) return; if (is_hyperlink_ && text_context_.size() > 0) return;
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && !current_field_.in_span) if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && !current_field_.in_span)
{ {
text_context()->start_field(current_field_.type); text_context()->start_field(current_field_.type);
current_field_.started = true; current_field_.started = true;
...@@ -705,7 +715,14 @@ void odt_conversion_context::start_run(bool styled) ...@@ -705,7 +715,14 @@ void odt_conversion_context::start_run(bool styled)
text_context()->start_span(styled); text_context()->start_span(styled);
if (current_field_.started== false && current_field_.type >1 && current_field_.enabled ==true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля if (drop_cap_state_.enabled)
{
style_text_properties *props = text_context()->get_text_properties();
if (props)
props->apply_from(dynamic_cast<style_text_properties*>(drop_cap_state_.text_properties.get()));
}
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
{ {
text_context()->start_field(current_field_.type); text_context()->start_field(current_field_.type);
current_field_.started = true; current_field_.started = true;
...@@ -945,7 +962,14 @@ void odt_conversion_context::end_change (int id, int type) ...@@ -945,7 +962,14 @@ void odt_conversion_context::end_change (int id, int type)
// return (text_changes_state_.current_types.back() == 2); // return (text_changes_state_.current_types.back() == 2);
//} //}
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
style_text_properties* odt_conversion_context::get_drop_cap_properties()
{
if (!drop_cap_state_.text_properties)
{
create_element(L"style", L"text-properties", drop_cap_state_.text_properties, this);
}
return dynamic_cast<style_text_properties *>(drop_cap_state_.text_properties.get());
}
void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties) void odt_conversion_context::start_drop_cap(style_paragraph_properties *paragraph_properties)
{ {
if (drop_cap_state_.enabled) if (drop_cap_state_.enabled)
...@@ -967,6 +991,8 @@ void odt_conversion_context::set_drop_cap_lines(int lines) ...@@ -967,6 +991,8 @@ void odt_conversion_context::set_drop_cap_lines(int lines)
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get()); style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get());
if (drop_cap)drop_cap->style_lines_ = lines; if (drop_cap)drop_cap->style_lines_ = lines;
drop_cap_state_.lines = lines;
} }
void odt_conversion_context::set_drop_cap_margin(bool val) void odt_conversion_context::set_drop_cap_margin(bool val)
{ {
...@@ -977,7 +1003,7 @@ void odt_conversion_context::end_drop_cap() ...@@ -977,7 +1003,7 @@ void odt_conversion_context::end_drop_cap()
{ {
if (!drop_cap_state_.enabled) return; if (!drop_cap_state_.enabled) return;
if (drop_cap_state_.characters >0 && drop_cap_state_.paragraph_properties) if (drop_cap_state_.characters > 0 && drop_cap_state_.paragraph_properties)
{ {
style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get()); style_drop_cap *drop_cap = dynamic_cast<style_drop_cap*>(drop_cap_state_.paragraph_properties->content_.style_drop_cap_.get());
if (drop_cap) if (drop_cap)
......
...@@ -113,6 +113,8 @@ public: ...@@ -113,6 +113,8 @@ public:
void set_drop_cap_lines (int lines); void set_drop_cap_lines (int lines);
void set_drop_cap_margin(bool val); void set_drop_cap_margin(bool val);
void end_drop_cap (); void end_drop_cap ();
bool in_drop_cap () {return drop_cap_state_.enabled;}
style_text_properties* get_drop_cap_properties();
bool start_comment (int oox_comment_id); bool start_comment (int oox_comment_id);
void end_comment (int oox_comment_id); void end_comment (int oox_comment_id);
...@@ -203,14 +205,25 @@ private: ...@@ -203,14 +205,25 @@ private:
struct _drop_cap_state struct _drop_cap_state
{ {
void clear(){enabled = false; paragraph_properties = NULL; characters = 0; inline_style = true; characters_size_pt =0;} void clear()
{
bool enabled; enabled = false;
style_paragraph_properties *paragraph_properties; paragraph_properties = NULL;
characters = 0;
int characters; inline_style = true;
bool inline_style; characters_size_pt = 0;
double characters_size_pt; lines = 0;
text_properties = office_element_ptr();
}
bool enabled = false;
style_paragraph_properties *paragraph_properties = NULL;
office_element_ptr text_properties;
int lines = 0;
int characters = 0;
bool inline_style = false;
double characters_size_pt = 0;
}drop_cap_state_; }drop_cap_state_;
}; };
......
...@@ -269,8 +269,15 @@ void style_paragraph_properties::apply_from(style_paragraph_properties * Other) ...@@ -269,8 +269,15 @@ void style_paragraph_properties::apply_from(style_paragraph_properties * Other)
content_.apply_from(Other->content_); content_.apply_from(Other->content_);
} }
void paragraph_format_properties::clear() void paragraph_format_properties::clear(bool bEraseDropCap)
{ {
if (bEraseDropCap)
{
style_drop_cap_ = office_element_ptr();
fo_text_indent_ = boost::none;
}
style_tab_stops_ = office_element_ptr();
style_background_image_ = office_element_ptr();
fo_line_height_ = boost::none; fo_line_height_ = boost::none;
style_line_height_at_least_ = boost::none; style_line_height_at_least_ = boost::none;
style_line_spacing_ = boost::none; style_line_spacing_ = boost::none;
...@@ -287,7 +294,6 @@ void paragraph_format_properties::clear() ...@@ -287,7 +294,6 @@ void paragraph_format_properties::clear()
style_register_true_ = boost::none; style_register_true_ = boost::none;
fo_margin_left_ = boost::none; fo_margin_left_ = boost::none;
fo_margin_right_ = boost::none; fo_margin_right_ = boost::none;
//fo_text_indent_ = boost::none;//заточено под буквицу
style_auto_text_indent_ = boost::none; style_auto_text_indent_ = boost::none;
fo_margin_top_ = boost::none; fo_margin_top_ = boost::none;
fo_margin_bottom_ = boost::none; fo_margin_bottom_ = boost::none;
...@@ -318,7 +324,11 @@ void paragraph_format_properties::clear() ...@@ -318,7 +324,11 @@ void paragraph_format_properties::clear()
text_number_lines_ = boost::none; text_number_lines_ = boost::none;
style_shadow_ = boost::none; style_shadow_ = boost::none;
//todooo borders common_border_attlist_.fo_border_ = boost::none;
common_border_attlist_.fo_border_top_ = boost::none;
common_border_attlist_.fo_border_bottom_= boost::none;
common_border_attlist_.fo_border_left_ = boost::none;
common_border_attlist_.fo_border_right_ = boost::none;
} }
void paragraph_format_properties::apply_from(paragraph_format_properties & Other) void paragraph_format_properties::apply_from(paragraph_format_properties & Other)
......
...@@ -192,9 +192,8 @@ public: ...@@ -192,9 +192,8 @@ public:
void apply_from( paragraph_format_properties & Other); void apply_from( paragraph_format_properties & Other);
void clear(); void clear(bool bEraseDropCap = true);
public:
_CP_OPT(odf_types::length) style_line_height_at_least_; _CP_OPT(odf_types::length) style_line_height_at_least_;
_CP_OPT(odf_types::length_or_percent) style_line_spacing_; _CP_OPT(odf_types::length_or_percent) style_line_spacing_;
_CP_OPT(odf_types::Bool) style_font_independent_line_spacing_; _CP_OPT(odf_types::Bool) style_font_independent_line_spacing_;
...@@ -277,7 +276,7 @@ public: ...@@ -277,7 +276,7 @@ public:
virtual void serialize(std::wostream & strm); virtual void serialize(std::wostream & strm);
paragraph_format_properties content_; paragraph_format_properties content_;
}; };
......
...@@ -58,6 +58,37 @@ using namespace cpdoccore; ...@@ -58,6 +58,37 @@ using namespace cpdoccore;
namespace Oox2Odf namespace Oox2Odf
{ {
bool compare (OOX::Logic::CSectionProperty* props1, OOX::Logic::CSectionProperty* props2)
{
size_t cols_1 = 1, cols_2 = 1;
if (props1 && props1->m_oCols.IsInit())
{
cols_1 = props1->m_oCols->m_oNum.IsInit() ? props1->m_oCols->m_oNum->GetValue() : 1;
if (!props1->m_oCols->m_arrColumns.empty())
cols_1 = min(cols_1, props1->m_oCols->m_arrColumns.size());
}
if (props2)
{
if (props2->m_oCols.IsInit())
{
cols_2 = props2->m_oCols->m_oNum.IsInit() ? props2->m_oCols->m_oNum->GetValue() : 1;
if (!props2->m_oCols->m_arrColumns.empty())
cols_2 = min(cols_2, props2->m_oCols->m_arrColumns.size());
}
else
{
if (props2->m_oType.IsInit() && props2->m_oType->m_oVal.IsInit())
{
if (props2->m_oType->m_oVal->GetValue() == SimpleTypes::sectionmarkContinious)
cols_2 = cols_1;
}
}
}
return cols_1 == cols_2;
}
DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback* CallBack) DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback* CallBack)
{ {
const OOX::CPath oox_path(std::wstring(path.c_str())); const OOX::CPath oox_path(std::wstring(path.c_str()));
...@@ -181,16 +212,18 @@ void DocxConverter::convert_document() ...@@ -181,16 +212,18 @@ void DocxConverter::convert_document()
std::vector<_section> sections; std::vector<_section> sections;
//---------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------
std::vector<OOX::WritingElement*>::const_iterator last_section_start = document->m_arrItems.begin();
//считаем количесво секций и запоминаем их свойства .. //считаем количесво секций и запоминаем их свойства ..
for (std::vector<OOX::WritingElement*>::const_iterator it = document->m_arrItems.begin(); it != document->m_arrItems.end(); ++it) size_t last_section_start = 0;
OOX::Logic::CSectionProperty* prev = NULL;
for (size_t i = 0; i < document->m_arrItems.size(); ++i)
{ {
if ((*it) == NULL) continue; if ((document->m_arrItems[i]) == NULL) continue;
if ((*it)->getType() == OOX::et_w_p) if (document->m_arrItems[i]->getType() == OOX::et_w_p)
{ {
OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(*it); OOX::Logic::CParagraph * para = dynamic_cast<OOX::Logic::CParagraph *>(document->m_arrItems[i]);
if ((para) && (para->m_oParagraphProperty)) if ((para) && (para->m_oParagraphProperty))
{ {
...@@ -200,11 +233,13 @@ void DocxConverter::convert_document() ...@@ -200,11 +233,13 @@ void DocxConverter::convert_document()
section.props = para->m_oParagraphProperty->m_oSectPr.GetPointer(); section.props = para->m_oParagraphProperty->m_oSectPr.GetPointer();
section.start_para = last_section_start; section.start_para = last_section_start;
section.end_para = it; section.end_para++; section.end_para = i + 1;
section.bContinue = compare (prev, section.props);
sections.push_back(section); sections.push_back(section);
last_section_start = it; last_section_start++; last_section_start = i + 1;
prev = section.props;
} }
} }
} }
...@@ -213,7 +248,9 @@ void DocxConverter::convert_document() ...@@ -213,7 +248,9 @@ void DocxConverter::convert_document()
section.props = document->m_oSectPr.GetPointer(); section.props = document->m_oSectPr.GetPointer();
section.start_para = last_section_start; section.start_para = last_section_start;
section.end_para = document->m_arrItems.end(); section.end_para = document->m_arrItems.size();
section.bContinue = compare (prev, section.props);
sections.push_back(section); sections.push_back(section);
//---------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------
...@@ -224,9 +261,9 @@ void DocxConverter::convert_document() ...@@ -224,9 +261,9 @@ void DocxConverter::convert_document()
{ {
current_section_properties = &sections[sect]; current_section_properties = &sections[sect];
for (std::vector<OOX::WritingElement*>::const_iterator it = sections[sect].start_para; it != sections[sect].end_para; ++it) for (size_t i = sections[sect].start_para; i < sections[sect].end_para; ++i)
{ {
convert(*it); convert(document->m_arrItems[i]);
} }
} }
} }
...@@ -382,7 +419,7 @@ void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt) ...@@ -382,7 +419,7 @@ void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
{ {
if (oox_paragraph == NULL) return; if (oox_paragraph == NULL) return;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
if (current_section_properties) if (current_section_properties)
{ {
...@@ -479,20 +516,29 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) ...@@ -479,20 +516,29 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
if (odt_context->text_context()->get_KeepNextParagraph()) if (odt_context->text_context()->get_KeepNextParagraph())
{ {
odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph); odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
if (state) if (state)
{ {
paragraph_properties = state->get_paragraph_properties(); paragraph_properties = state->get_paragraph_properties();
if (bRunPara) if (bRunPara)
text_properties = state->get_text_properties(); text_properties = state->get_text_properties();
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit()) if (odt_context->in_drop_cap()) //после буквицы (Nadpis.docx) - нужно накатить свойства параграфа нормального
{ {
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами //очистить все кроме drop_cap
paragraph_properties->content_.clear(); paragraph_properties->content_.clear(false);
if (text_properties) }
text_properties->content_.clear(); else
{
// ????
if (oox_paragraph->m_oParagraphProperty && oox_paragraph->m_oParagraphProperty->m_oPStyle.IsInit() && oox_paragraph->m_oParagraphProperty->m_oPStyle->m_sVal.IsInit())
{
//перезатираем все свойства ... наложение не катит -- ваще то надо чистить после буквицы (Nadpis.docx) .. проверить надобность с остальными случами
paragraph_properties->content_.clear(true);
if (text_properties)
text_properties->content_.clear();
}
} }
} }
} }
...@@ -510,10 +556,25 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) ...@@ -510,10 +556,25 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
odt_context->styles_context()->last_state()->set_list_style_name(list_style_name); odt_context->styles_context()->last_state()->set_list_style_name(list_style_name);
} }
} }
if (odt_context->in_drop_cap())
{
odt_context->end_drop_cap();
}
convert(oox_paragraph->m_oParagraphProperty, paragraph_properties); convert(oox_paragraph->m_oParagraphProperty, paragraph_properties);
if (text_properties && oox_paragraph->m_oParagraphProperty) if (text_properties && oox_paragraph->m_oParagraphProperty)
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties); {
if (odt_context->in_drop_cap())
{
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), odt_context->get_drop_cap_properties());
//вообще то свойства правильные параграфа идут в следующем после буквицы параграфе
}
else
{
convert(oox_paragraph->m_oParagraphProperty->m_oRPr.GetPointer(), text_properties);
}
}
} }
else else
{ {
...@@ -572,8 +633,6 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) ...@@ -572,8 +633,6 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
if (odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_drop_cap();
if (!odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_paragraph(); if (!odt_context->text_context()->get_KeepNextParagraph()) odt_context->end_paragraph();
if(list_present && !odt_context->text_context()->get_KeepNextParagraph()) if(list_present && !odt_context->text_context()->get_KeepNextParagraph())
...@@ -1055,7 +1114,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp ...@@ -1055,7 +1114,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
{ {
if (current_section_properties) if (current_section_properties)
{ {
convert(current_section_properties->props, current_section_properties->root); convert(current_section_properties->props, !current_section_properties->bContinue);
} }
return; return;
} }
...@@ -1232,7 +1291,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp ...@@ -1232,7 +1291,7 @@ void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cp
{ {
paragraph_properties->content_.style_page_number_ = current_section_properties->props->m_oPgNumType->m_oStart->GetValue(); paragraph_properties->content_.style_page_number_ = current_section_properties->props->m_oPgNumType->m_oStart->GetValue();
} }
convert(current_section_properties->props, current_section_properties->root); convert(current_section_properties->props, !current_section_properties->bContinue);
//odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph); //odf_writer::odf_style_state_ptr state = odt_context->styles_context()->last_state(odf_types::style_family::Paragraph);
//if (odt_context->is_paragraph_in_current_section_ && state) //if (odt_context->is_paragraph_in_current_section_ && state)
...@@ -1328,7 +1387,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi ...@@ -1328,7 +1387,7 @@ void DocxConverter::apply_HF_from(OOX::Logic::CSectionProperty *props, OOX::Logi
} }
} }
} }
void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root) void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection)
{ {
if (oox_section_pr == NULL) return; if (oox_section_pr == NULL) return;
current_section_properties = NULL; current_section_properties = NULL;
...@@ -1353,18 +1412,18 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r ...@@ -1353,18 +1412,18 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
} }
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!last_section_properties && (root || continuous == false || oox_section_pr->m_oTitlePg.IsInit())) if (!last_section_properties && (!bSection || continuous == false || oox_section_pr->m_oTitlePg.IsInit()))
{ {
last_section_properties = oox_section_pr; last_section_properties = oox_section_pr;
} }
else if (root || continuous == false) else if (!bSection || continuous == false)
{ {
apply_HF_from(last_section_properties, oox_section_pr); apply_HF_from(last_section_properties, oox_section_pr);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (root || continuous == false) if (!bSection || continuous == false)
{ {
odt_context->page_layout_context()->add_master_page(root ? L"Standard" : L""); odt_context->page_layout_context()->add_master_page(bSection ? L"" : L"Standard");
} }
bool present_header = false; bool present_header = false;
...@@ -1499,7 +1558,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r ...@@ -1499,7 +1558,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle; //nullable<SimpleTypes::CDecimalNumber<> > m_oChapStyle;
} }
if (continuous == false || root || oox_section_pr->m_oTitlePg.IsInit()) if (continuous == false || oox_section_pr->m_oTitlePg.IsInit())
{ {
OOX::Logic::CSectionProperty* s = last_section_properties; OOX::Logic::CSectionProperty* s = last_section_properties;
...@@ -1590,53 +1649,46 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r ...@@ -1590,53 +1649,46 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r
//nullable<ComplexTypes::Word::CRel > m_oPrinterSettings; //nullable<ComplexTypes::Word::CRel > m_oPrinterSettings;
//nullable<OOX::Logic::CSectPrChange > m_oSectPrChange; //nullable<OOX::Logic::CSectPrChange > m_oSectPrChange;
//-------------------------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------------------------
if (bSection)
int num_columns = 1; {
odt_context->add_section(continuous);
}
if (oox_section_pr->m_oCols.IsInit()) if (bSection && oox_section_pr->m_oCols.IsInit())
{ {
num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1; int num_columns = oox_section_pr->m_oCols->m_oNum.IsInit() ? oox_section_pr->m_oCols->m_oNum->GetValue() : 1;
if (num_columns > 1 && oox_section_pr->m_oCols->m_arrColumns.size() > 0) if (num_columns > 1 && oox_section_pr->m_oCols->m_arrColumns.size() > 0)
num_columns = /*(std::max)*/( /*num_columns,*/ (int)oox_section_pr->m_oCols->m_arrColumns.size()) ; num_columns = /*(std::max)*/( /*num_columns,*/ (int)oox_section_pr->m_oCols->m_arrColumns.size()) ;
}
if (/*num_columns != odt_context->get_current_section_columns() || */num_columns >= 1) //колонки double default_space_pt = -1;
{ if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints();
if (!root || num_columns > 1)
odt_context->add_section(continuous);
if (oox_section_pr->m_oCols.IsInit()) bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
{
double default_space_pt = -1; odt_context->add_section_columns(num_columns,
if (oox_section_pr->m_oCols->m_oSpace.IsInit()) default_space_pt = oox_section_pr->m_oCols->m_oSpace->ToPoints(); oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
bool separator = oox_section_pr->m_oCols->m_oSep.IsInit() && oox_section_pr->m_oCols->m_oSep->ToBool();
odt_context->add_section_columns(num_columns,
oox_section_pr->m_oCols->m_arrColumns.size() > 0 ? -1 : default_space_pt , separator );
std::vector<std::pair<double,double>> width_space; std::vector<std::pair<double,double>> width_space;
for (size_t i =0; i< oox_section_pr->m_oCols->m_arrColumns.size(); i++) for (size_t i =0; i< oox_section_pr->m_oCols->m_arrColumns.size(); i++)
{ {
if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue; if (oox_section_pr->m_oCols->m_arrColumns[i] == NULL) continue;
double space = default_space_pt; double space = default_space_pt;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit()) if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace.IsInit())
space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints(); space = oox_section_pr->m_oCols->m_arrColumns[i]->m_oSpace->ToPoints();
double w = -1;
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oW.IsInit())
w = oox_section_pr->m_oCols->m_arrColumns[i]->m_oW->ToPoints();
double w = -1; width_space.push_back(std::pair<double,double>(w, space));
if (oox_section_pr->m_oCols->m_arrColumns[i]->m_oW.IsInit())
w = oox_section_pr->m_oCols->m_arrColumns[i]->m_oW->ToPoints();
width_space.push_back(std::pair<double,double>(w, space));
}
//for (size_t i= oox_section_pr->m_oCols->m_arrColumns.size(); i< num_columns; i ++)
//{
// width_space.push_back(std::pair<double,double>(-1, default_space_pt));
//}
odt_context->add_section_column(width_space);
} }
//for (size_t i= oox_section_pr->m_oCols->m_arrColumns.size(); i< num_columns; i ++)
//{
// width_space.push_back(std::pair<double,double>(-1, default_space_pt));
//}
odt_context->add_section_column(width_space);
} }
} }
void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type) void DocxConverter::convert(OOX::Logic::CBackground *oox_background, int type)
...@@ -3612,7 +3664,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table) ...@@ -3612,7 +3664,7 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
if (in_frame) if (in_frame)
{ {
if (current_section_properties) if (current_section_properties)
convert(current_section_properties->props, current_section_properties->root); convert(current_section_properties->props, !current_section_properties->bContinue);
odt_context->start_paragraph(); odt_context->start_paragraph();
......
...@@ -158,11 +158,11 @@ namespace Oox2Odf ...@@ -158,11 +158,11 @@ namespace Oox2Odf
private: private:
struct _section struct _section
{ {
OOX::Logic::CSectionProperty *props; OOX::Logic::CSectionProperty *props;
std::vector<OOX::WritingElement*>::const_iterator start_para; size_t start_para;
std::vector<OOX::WritingElement*>::const_iterator end_para; size_t end_para;
bool root; bool bContinue = false;
} *current_section_properties; } *current_section_properties;
OOX::CDocx *docx_document; OOX::CDocx *docx_document;
cpdoccore::odf_writer::package::odf_document *output_document; cpdoccore::odf_writer::package::odf_document *output_document;
...@@ -184,7 +184,7 @@ namespace Oox2Odf ...@@ -184,7 +184,7 @@ namespace Oox2Odf
void convert(OOX::Logic::CBackground *oox_background, int type); void convert(OOX::Logic::CBackground *oox_background, int type);
void convert(OOX::Logic::CSdt *oox_sdt); void convert(OOX::Logic::CSdt *oox_sdt);
void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root = false); void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool bSection);
void convert(OOX::Logic::CParagraph *oox_paragraph); void convert(OOX::Logic::CParagraph *oox_paragraph);
void convert(OOX::Logic::CRun *oox_run); void convert(OOX::Logic::CRun *oox_run);
void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties); void convert(OOX::Logic::CParagraphProperty *oox_para_prop, odf_writer::style_paragraph_properties *paragraph_properties);
......
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