Commit 66d4c193 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

OdfFormatReader - поправлена конвертация разделов и колонок (разрывы и настройки страниц)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68553 954022d7-b5bf-4e40-9824-e11837661b57
parent 5d9e5869
...@@ -32,8 +32,10 @@ docx_conversion_context::docx_conversion_context(package::docx_document * Output ...@@ -32,8 +32,10 @@ docx_conversion_context::docx_conversion_context(package::docx_document * Output
current_run_(false), current_run_(false),
page_break_after_(false), page_break_after_(false),
page_break_before_(false), page_break_before_(false),
page_break_(false),
in_automatic_style_(false), in_automatic_style_(false),
next_dump_page_properties_(false), next_dump_page_properties_(false),
next_dump_section_(false),
mediaitems_( OdfDocument->get_folder() ), mediaitems_( OdfDocument->get_folder() ),
in_paragraph_(false), in_paragraph_(false),
table_context_(*this), table_context_(*this),
...@@ -586,14 +588,23 @@ void docx_conversion_context::start_process_style_content() ...@@ -586,14 +588,23 @@ void docx_conversion_context::start_process_style_content()
styles_context_.start(); styles_context_.start();
} }
void docx_conversion_context::process_page_properties(std::wostream & strm) bool docx_conversion_context::process_page_properties(std::wostream & strm)
{ {
if (is_next_dump_page_properties()) if (is_next_dump_page_properties() || get_section_context().get().is_dump_)
{
std::wstring pageProperties = get_page_properties();
if (!pageProperties.empty())//??? ???
{ {
const std::wstring pageProperties = get_page_properties();
odf_reader::page_layout_instance * page_layout_instance_ = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties); odf_reader::page_layout_instance * page_layout_instance_ = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties);
if (page_layout_instance_) page_layout_instance_->docx_convert_serialize(strm,*this);
if (page_layout_instance_)
page_layout_instance_->docx_convert_serialize(strm,*this);
} }
next_dump_page_properties(false);
return true;
}
return false;
} }
void docx_conversion_context::end_process_style_content(bool in_styles) void docx_conversion_context::end_process_style_content(bool in_styles)
...@@ -611,13 +622,26 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str ...@@ -611,13 +622,26 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes(); std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes();
std::wstringstream & run_style = get_styles_context().text_style(); std::wstringstream & run_style = get_styles_context().text_style();
if (!paragraph_style.str().empty() || !ParentId.empty())
{
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{
if (get_section_context().dump_.empty() == false && !ParentId.empty())
{
CP_XML_NODE(L"w:pPr")
{
CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();
}
finish_paragraph();
start_paragraph();
}
if (!paragraph_style.str().empty() || !ParentId.empty())
{ {
CP_XML_NODE(L"w:pPr") CP_XML_NODE(L"w:pPr")
{ {
process_page_properties(CP_XML_STREAM());//???????? CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();
if (!ParentId.empty()) if (!ParentId.empty())
{ {
CP_XML_NODE(L"w:pStyle") CP_XML_NODE(L"w:pStyle")
...@@ -688,7 +712,14 @@ bool docx_conversion_context::get_page_break_after() ...@@ -688,7 +712,14 @@ bool docx_conversion_context::get_page_break_after()
{ {
return page_break_after_ ; return page_break_after_ ;
} }
void docx_conversion_context::set_page_break(bool val)
{
page_break_ = val;
}
bool docx_conversion_context::get_page_break()
{
return page_break_;
}
void docx_conversion_context::set_page_break_before(bool val) void docx_conversion_context::set_page_break_before(bool val)
{ {
page_break_before_ = val; page_break_before_ = val;
...@@ -700,31 +731,49 @@ bool docx_conversion_context::get_page_break_before() ...@@ -700,31 +731,49 @@ bool docx_conversion_context::get_page_break_before()
} }
void docx_conversion_context::set_page_properties(const std::wstring & StyleName) void docx_conversion_context::add_page_properties(const std::wstring & StyleName)
{ {
current_page_properties_ = StyleName; section_context::_section & s = section_context_.get();
s.page_properties_.push_back( StyleName);
} }
const std::wstring & docx_conversion_context::get_page_properties() const std::wstring docx_conversion_context::get_page_properties()
{ {
return current_page_properties_; section_context::_section & s = section_context_.get();
if (s.page_properties_.size() > 1) return s.page_properties_[1];
else if (s.page_properties_.size() == 1) return s.page_properties_[0];
else return L"";
} }
void docx_conversion_context::remove_page_properties()
{
section_context::_section & s = section_context_.get();
void docx_conversion_context::next_dump_page_properties() if (s.page_properties_.size() > 1)
{
// ( ) -
s.page_properties_.erase(s.page_properties_.begin() + 1, s.page_properties_.begin() + 2);
}
else if (s.page_properties_.size() == 1)
{
s.page_properties_.clear();
}
}
void docx_conversion_context::next_dump_page_properties(bool val)
{ {
if (!process_headers_footers_) if (process_headers_footers_ && val) return;
next_dump_page_properties_ = true;
next_dump_page_properties_ = val;
} }
bool docx_conversion_context::is_next_dump_page_properties() bool docx_conversion_context::is_next_dump_page_properties()
{ {
bool t = next_dump_page_properties_; return next_dump_page_properties_;
next_dump_page_properties_ = false;
return t;
} }
void docx_conversion_context::start_text_list_style(const std::wstring & StyleName) void docx_conversion_context::start_text_list_style(const std::wstring & StyleName)
{ {
text_list_style_name_ = StyleName; text_list_style_name_ = StyleName;
...@@ -848,17 +897,12 @@ void docx_conversion_context::docx_convert_delayed() ...@@ -848,17 +897,12 @@ void docx_conversion_context::docx_convert_delayed()
delayed_converting_=false; delayed_converting_=false;
} }
void section_context::start_section(const std::wstring & SectionName, const std::wstring & Style) void section_context::add_section(const std::wstring & SectionName, const std::wstring & Style, const std::wstring & PageProperties)
{ {
section newSec = {SectionName, Style}; _section newSec(SectionName, Style, PageProperties );
sections_.push_back(newSec); sections_.push_back(newSec);
} }
void section_context::end_section()
{
sections_.pop_back();
set_after_section(true);
}
void docx_conversion_context::section_properties_in_table(odf_reader::office_element * Elm) void docx_conversion_context::section_properties_in_table(odf_reader::office_element * Elm)
{ {
...@@ -929,7 +973,7 @@ void docx_conversion_context::process_headers_footers() ...@@ -929,7 +973,7 @@ void docx_conversion_context::process_headers_footers()
{ {
const std::wstring & styleName = page->style_master_page_attlist_.style_name_.get_value_or( odf_types::style_ref(L"") ).style_name(); const std::wstring & styleName = page->style_master_page_attlist_.style_name_.get_value_or( odf_types::style_ref(L"") ).style_name();
const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName); const std::wstring masterPageNameLayout =context.pageLayoutContainer().page_layout_name_by_style(styleName);
set_page_properties(masterPageNameLayout); add_page_properties(masterPageNameLayout);
process_one_header_footer(*this, styleName, page->style_header_.get(), headers_footers::header); process_one_header_footer(*this, styleName, page->style_header_.get(), headers_footers::header);
process_one_header_footer(*this, styleName, page->style_footer_.get(), headers_footers::footer ); process_one_header_footer(*this, styleName, page->style_footer_.get(), headers_footers::footer );
...@@ -945,6 +989,8 @@ void docx_conversion_context::process_headers_footers() ...@@ -945,6 +989,8 @@ void docx_conversion_context::process_headers_footers()
rels rels_; rels rels_;
get_headers_footers().add(styleName, L"", headers_footers::none, rels_); get_headers_footers().add(styleName, L"", headers_footers::none, rels_);
} }
remove_page_properties();
} }
process_headers_footers_ = false; process_headers_footers_ = false;
} }
......
...@@ -209,21 +209,52 @@ private: ...@@ -209,21 +209,52 @@ private:
class section_context : boost::noncopyable class section_context : boost::noncopyable
{ {
public: public:
section_context() : after_section_(false) {} section_context() /*: after_section_(false) */{}
struct section { std::wstring Name; std::wstring Style; };
void start_section(const std::wstring & SectionName, const std::wstring & Style); struct _section
void end_section(); {
_section() {is_dump_ = false;}
_section(const std::wstring & SectionName, const std::wstring & Style, const std::wstring & PageProperties)
{
is_dump_ = false;
name_ = SectionName;
style_ = Style;
page_properties_.push_back(PageProperties);
}
std::wstring name_;
std::wstring style_;
std::vector<std::wstring> page_properties_;
bool empty() const { return sections_.empty(); } bool is_dump_;
const section & get() const { return sections_.back(); } };
void set_after_section(bool Val) { after_section_ = Val; } void add_section(const std::wstring & SectionName, const std::wstring & Style, const std::wstring & PageProperties);
bool get_after_section() { return after_section_; }
bool is_empty()
{
return sections_.empty();
}
_section & get()
{
if (sections_.empty())
return main_section_;
else
return sections_[0];
}
void remove_section()
{
if (!sections_.empty())
{
sections_.erase(sections_.begin(), sections_.begin() + 1);
}
}
std::wstring dump_;
private: private:
std::list<section> sections_; _section main_section_;
bool after_section_; std::vector<_section> sections_;
}; };
class header_footer_context class header_footer_context
...@@ -396,6 +427,9 @@ public: ...@@ -396,6 +427,9 @@ public:
void dump_headers_footers(rels & Rels) const; void dump_headers_footers(rels & Rels) const;
void dump_notes(rels & Rels) const; void dump_notes(rels & Rels) const;
bool next_dump_page_properties_;
bool next_dump_section_;
odf_reader::odf_document * root() odf_reader::odf_document * root()
{ {
return odf_document_; return odf_document_;
...@@ -406,18 +440,19 @@ public: ...@@ -406,18 +440,19 @@ public:
std::wstring dump_settings_document(); std::wstring dump_settings_document();
void start_body(); void start_body ();
void end_body(); void end_body ();
void start_office_text();
void end_office_text();
void process_styles(); void start_office_text ();
void process_fonts(); void end_office_text ();
void process_list_styles(); void process_styles ();
void process_page_properties(std::wostream & strm); void process_fonts ();
void process_list_styles ();
bool process_page_properties(std::wostream & strm);
void process_headers_footers(); void process_headers_footers();
void process_comments(); void process_comments ();
void set_settings_property(const odf_reader::_property & prop); void set_settings_property(const odf_reader::_property & prop);
std::vector<odf_reader::_property> & get_settings_properties(); std::vector<odf_reader::_property> & get_settings_properties();
...@@ -442,9 +477,14 @@ public: ...@@ -442,9 +477,14 @@ public:
void set_page_break_before(bool val); void set_page_break_before(bool val);
bool get_page_break_before(); bool get_page_break_before();
void set_page_properties(const std::wstring & StyleName); void set_page_break (bool val);
const std::wstring & get_page_properties() const; bool get_page_break ();
void next_dump_page_properties();
void add_page_properties (const std::wstring & StyleName);
std::wstring get_page_properties ();
void remove_page_properties ();
void next_dump_page_properties(bool val);
bool is_next_dump_page_properties(); bool is_next_dump_page_properties();
void set_master_page_name(const std::wstring & MasterPageName); void set_master_page_name(const std::wstring & MasterPageName);
...@@ -542,11 +582,11 @@ private: ...@@ -542,11 +582,11 @@ private:
bool page_break_after_; bool page_break_after_;
bool page_break_before_; bool page_break_before_;
bool page_break_;
bool in_automatic_style_; bool in_automatic_style_;
std::wstring current_page_properties_;
bool next_dump_page_properties_;
std::wstring text_list_style_name_; std::wstring text_list_style_name_;
std::list<std::wstring> list_style_stack_; std::list<std::wstring> list_style_stack_;
......
...@@ -70,8 +70,9 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream ...@@ -70,8 +70,9 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream
{ {
if (!instances_.count(StyleName))return false; if (!instances_.count(StyleName))return false;
bool first=false, left=false; bool first = false, left = false;
bool res=false; bool res = false;
BOOST_FOREACH(const instance_ptr & inst, instances_.at(StyleName)) BOOST_FOREACH(const instance_ptr & inst, instances_.at(StyleName))
{ {
std::wstring type = L"default"; std::wstring type = L"default";
...@@ -79,12 +80,12 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream ...@@ -79,12 +80,12 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream
if ( inst->type_ == headerFirst || inst->type_ == footerFirst ) if ( inst->type_ == headerFirst || inst->type_ == footerFirst )
{ {
type = L"first"; type = L"first";
first=true; first = true;
} }
else if ( inst->type_ == footerLeft || inst->type_ == headerLeft ) else if ( inst->type_ == footerLeft || inst->type_ == headerLeft )
{ {
type = L"even"; type = L"even";
left=true; left = true;
} }
std::wstring name; std::wstring name;
...@@ -97,10 +98,12 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream ...@@ -97,10 +98,12 @@ bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream
{ {
_Wostream << L"<" << name << L" r:id=\"" << inst->id_ << L"\" w:type=\"" << type << "\" />"; _Wostream << L"<" << name << L" r:id=\"" << inst->id_ << L"\" w:type=\"" << type << "\" />";
} }
if (first)_Wostream << L"<w:titlePg/>";
res=true; res=true;
}
if (first)
{
_Wostream << L"<w:titlePg/>";
} }
return res; return res;
} }
......
...@@ -117,24 +117,6 @@ private: ...@@ -117,24 +117,6 @@ private:
rels_files * rels_; rels_files * rels_;
}; };
//class xl_vml_drawings;
//typedef _CP_PTR(xl_vml_drawings) xl_vml_drawings_ptr;
//
///// \class xl_drawings
//class xl_vml_drawings: public element
//{
//public:
// virtual void write(const std::wstring & RootPath);
// xl_vml_drawings(const std::vector<comment_elm> & elms) : vml_drawings_ ( comment_elm )
// {
// }
//
// static xl_vml_drawings_ptr create(const std::vector<comment_elm> & elms);
//
//private:
// const std::vector<comment_elm> & vml_drawings_;
//
//};
/// \class xl_files /// \class xl_files
class xl_files : public element class xl_files : public element
......
...@@ -740,9 +740,10 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio ...@@ -740,9 +740,10 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
if (pageLayoutInst) pagePropertiesNode = pageLayoutInst->properties(); if (pageLayoutInst) pagePropertiesNode = pageLayoutInst->properties();
/*const */style_page_layout_properties_attlist emptyPageProperties; style_page_layout_properties_attlist emptyPageProperties;
const style_page_layout_properties_attlist & pageProperties = const style_page_layout_properties_attlist & pageProperties =
pagePropertiesNode ? pagePropertiesNode->get_style_page_layout_properties_attlist() : emptyPageProperties; pagePropertiesNode ? pagePropertiesNode->style_page_layout_properties_attlist_ : emptyPageProperties;
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -62,7 +62,6 @@ void office_body::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -62,7 +62,6 @@ void office_body::xlsx_convert(oox::xlsx_conversion_context & Context)
void office_body::docx_convert(oox::docx_conversion_context & Context) void office_body::docx_convert(oox::docx_conversion_context & Context)
{ {
std::vector<style_master_page*> & masterPages = Context.root()->odf_context().pageLayoutContainer().master_pages(); std::vector<style_master_page*> & masterPages = Context.root()->odf_context().pageLayoutContainer().master_pages();
if (!masterPages.empty()) if (!masterPages.empty())
{ {
...@@ -70,7 +69,17 @@ void office_body::docx_convert(oox::docx_conversion_context & Context) ...@@ -70,7 +69,17 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
} }
const page_layout_instance * layout = Context.root()->odf_context().pageLayoutContainer().page_layout_first(); const page_layout_instance * layout = Context.root()->odf_context().pageLayoutContainer().page_layout_first();
if (layout) Context.set_page_properties(layout->name());
if (layout) //äâà ðàçà - ÷òîáû äåôîëòîâûå íàñòðîéêè âñåãäà áûëè
{
Context.add_page_properties(layout->name());
Context.add_page_properties(layout->name());
}
else
{
Context.add_page_properties(L""); //
Context.add_page_properties(L"");
}
//backcolor (for all pages) //backcolor (for all pages)
if (page_layout_instance * firtsPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties())) if (page_layout_instance * firtsPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{ {
...@@ -92,6 +101,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context) ...@@ -92,6 +101,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
if (page_layout_instance * lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties())) if (page_layout_instance * lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
{ {
lastPageLayout->docx_convert_serialize(Context.output_stream(), Context); lastPageLayout->docx_convert_serialize(Context.output_stream(), Context);
//Context.remove_page_properties();
} }
Context.end_body(); Context.end_body();
......
...@@ -191,7 +191,7 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context & ...@@ -191,7 +191,7 @@ void style_table_column_properties::docx_convert(oox::docx_conversion_context &
const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();// const page_layout_instance * pp = Context.root()->odf_context().pageLayoutContainer().page_layout_first();//
if (pp) if (pp)
{ {
const style_page_layout_properties_attlist & attr_page = pp->properties()->get_style_page_layout_properties_attlist(); style_page_layout_properties_attlist & attr_page = pp->properties()->style_page_layout_properties_attlist_;
if (attr_page.fo_page_width_) if (attr_page.fo_page_width_)
{ {
int val = 0.5 + 20.0 * attr_page.fo_page_width_->get_value_unit(length::pt); int val = 0.5 + 20.0 * attr_page.fo_page_width_->get_value_unit(length::pt);
......
...@@ -1194,15 +1194,15 @@ void style_page_layout_properties::add_child_element( xml::sax * Reader, const : ...@@ -1194,15 +1194,15 @@ void style_page_layout_properties::add_child_element( xml::sax * Reader, const :
} }
bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context) bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{ {
if (!get_style_page_layout_properties_attlist().common_background_color_attlist_.fo_background_color_)return false; if (!style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_)return false;
if (get_style_page_layout_properties_attlist().common_background_color_attlist_.fo_background_color_->get_type() == background_color::Transparent) return true; if (style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_type() == background_color::Transparent) return true;
// //
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"w:background") CP_XML_NODE(L"w:background")
{ {
std::wstring color = get_style_page_layout_properties_attlist().common_background_color_attlist_.fo_background_color_->get_color().get_hex_value(); std::wstring color = style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_color().get_hex_value();
CP_XML_ATTR(L"w:color",color); CP_XML_ATTR(L"w:color",color);
} }
} }
...@@ -1210,8 +1210,6 @@ bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox ...@@ -1210,8 +1210,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_drawing_context().get_current_level()>0) return;
if (Context.get_table_context().in_table()) if (Context.get_table_context().in_table())
{ {
// , // ,
...@@ -1241,15 +1239,10 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, ...@@ -1241,15 +1239,10 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
{ {
CP_XML_NODE(L"w:sectPr") CP_XML_NODE(L"w:sectPr")
{ {
if (!Context.get_section_context().empty()) oox::section_context::_section & section = Context.get_section_context().get();
{
CP_XML_NODE(L"w:type")
{
CP_XML_ATTR(L"w:val","continuous");
}
const std::wstring & secStyleName = Context.get_section_context().get().Style;
if (const style_instance * secStyle = if (const style_instance * secStyle =
Context.root()->odf_context().styleContainer().style_by_name(secStyleName, style_family::Section,Context.process_headers_footers_)) Context.root()->odf_context().styleContainer().style_by_name(section.style_, style_family::Section,Context.process_headers_footers_))
{ {
if (const style_content * content = secStyle->content()) if (const style_content * content = secStyle->content())
{ {
...@@ -1272,19 +1265,21 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, ...@@ -1272,19 +1265,21 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
sect_margin_right_ = sectPr->common_horizontal_margin_attlist_.fo_margin_right_; sect_margin_right_ = sectPr->common_horizontal_margin_attlist_.fo_margin_right_;
} }
} }
if (section.is_dump_)
{
Context.get_section_context().remove_section();
} }
} }
else
{
CP_XML_NODE(L"w:type") CP_XML_NODE(L"w:type")
{ {
if (!Context.get_section_context().get_after_section()) if (Context.is_next_dump_page_properties())
{
CP_XML_ATTR(L"w:val", L"nextPage"); CP_XML_ATTR(L"w:val", L"nextPage");
else }else
{
CP_XML_ATTR(L"w:val", L"continuous"); CP_XML_ATTR(L"w:val", L"continuous");
} }
} }
if (count_columns > 1) if (count_columns > 1)
{ {
CP_XML_NODE(L"w:cols") CP_XML_NODE(L"w:cols")
...@@ -1295,8 +1290,6 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, ...@@ -1295,8 +1290,6 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
CP_XML_ATTR(L"w:space",0); CP_XML_ATTR(L"w:space",0);
} }
} }
{
std::wstring masterPageName = Context.get_master_page_name();// document.xml!!! std::wstring masterPageName = Context.get_master_page_name();// document.xml!!!
bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm); bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
if (res == false) if (res == false)
...@@ -1304,10 +1297,13 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, ...@@ -1304,10 +1297,13 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
// default??? // default???
masterPageName = L"Standard"; masterPageName = L"Standard";
const std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterPageName); const std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterPageName);
Context.set_page_properties(masterPageNameLayout);
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm); bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
} }
}
style_page_layout_properties_attlist_.docx_convert_serialize(strm, Context, sect_margin_left_, sect_margin_right_); style_page_layout_properties_attlist_.docx_convert_serialize(strm, Context, sect_margin_left_, sect_margin_right_);
//todooo - !! //todooo - !!
} }
......
...@@ -1030,10 +1030,6 @@ public: ...@@ -1030,10 +1030,6 @@ public:
bool docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context); bool docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context);
const style_page_layout_properties_attlist & get_style_page_layout_properties_attlist() const
{
return style_page_layout_properties_attlist_;
};
public: public:
style_page_layout_properties() { } style_page_layout_properties() { }
......
...@@ -107,8 +107,8 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co ...@@ -107,8 +107,8 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
{ {
if (!Attr.text_style_name_.empty()) if (!Attr.text_style_name_.empty())
{ {
if (style_instance * styleInst 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); process_page_break_after(styleInst, Context);
...@@ -319,30 +319,33 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -319,30 +319,33 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
if (!masterPageName.empty() && Context.get_master_page_name() != masterPageName) if (!masterPageName.empty() && Context.get_master_page_name() != masterPageName)
{ {
const std::wstring pageLayoutName = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterPageName); Context.next_dump_page_properties(true);
Context.next_dump_page_properties();
Context.get_section_context().set_after_section(false);
is_empty = false; is_empty = false;
} }
} }
if (next_section_ || next_end_section_) if (next_section_ || next_end_section_)
{ {
Context.next_dump_page_properties(); Context.get_section_context().get().is_dump_ = true;
is_empty = false; is_empty = false;
} }
const std::wstring & styleName = paragraph_attrs_.text_style_name_.style_name(); const std::wstring & styleName = paragraph_attrs_.text_style_name_.style_name();
const std::wstring masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName); const std::wstring masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(styleName);
if (!masterPageName.empty()) if (!masterPageName.empty())
{ {
const std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterPageName);
Context.set_page_properties(masterPageNameLayout);
Context.set_master_page_name(masterPageName); Context.set_master_page_name(masterPageName);
const std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterPageName);
Context.remove_page_properties();
Context.add_page_properties(masterPageNameLayout);
Context.set_page_break(true);
is_empty = false; is_empty = false;
} }
process_paragraph_drop_cap_attr(paragraph_attrs_, Context); process_paragraph_drop_cap_attr(paragraph_attrs_, Context);
if (Context.get_drop_cap_context().state() == 2)//active if (Context.get_drop_cap_context().state() == 2)//active
...@@ -363,19 +366,15 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -363,19 +366,15 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
{ {
elm->docx_convert(Context); if (Context.get_page_break())
if (Context.get_drop_cap_context().state() >0)
Context.get_drop_cap_context().state(0);//disable
if (elm->get_type() == typeTextSoftPageBreak && !Context.get_page_break_after() && !Context.get_page_break_before())
{ {
_Wostream << L"<w:lastRenderedPageBreak/>"; _Wostream << L"<w:lastRenderedPageBreak/>";
Context.set_page_break(false);
if (next_section_ || next_end_section_)
Context.set_page_break_before(true);
} }
elm->docx_convert(Context);
if (Context.get_drop_cap_context().state() >0)
Context.get_drop_cap_context().state(0);//disable
} }
if (textStyle>0) if (textStyle>0)
...@@ -407,6 +406,12 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context) ...@@ -407,6 +406,12 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
Context.finish_paragraph(); Context.finish_paragraph();
std::wstringstream strm;
if (Context.process_page_properties(strm))
{
Context.get_section_context().dump_ = strm.str();
}
} }
void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context) void paragraph::xlsx_convert(oox::xlsx_conversion_context & Context)
...@@ -427,6 +432,15 @@ void paragraph::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -427,6 +432,15 @@ void paragraph::pptx_convert(oox::pptx_conversion_context & Context)
} }
Context.get_text_context().end_paragraph(); Context.get_text_context().end_paragraph();
} }
///////////////////////////////////////////
void soft_page_break::docx_convert(oox::docx_conversion_context & Context)
{
if (!Context.get_page_break_after() && !Context.get_page_break_before())
{
Context.output_stream() << L"<w:lastRenderedPageBreak/>";
}
}
////////////////////////////////////////////// //////////////////////////////////////////////
::std::wostream & h::text_to_stream(::std::wostream & _Wostream) const ::std::wostream & h::text_to_stream(::std::wostream & _Wostream) const
...@@ -670,17 +684,16 @@ void text_section::add_child_element( xml::sax * Reader, const ::std::wstring & ...@@ -670,17 +684,16 @@ void text_section::add_child_element( xml::sax * Reader, const ::std::wstring &
void text_section::docx_convert(oox::docx_conversion_context & Context) void text_section::docx_convert(oox::docx_conversion_context & Context)
{ {
Context.get_section_context().start_section( Context.get_section_context().add_section(
text_section_attr_.text_name_, text_section_attr_.text_name_,
text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name() text_section_attr_.text_style_name_.get_value_or(style_ref()).style_name(),
Context.get_page_properties()
); );
BOOST_FOREACH(const office_element_ptr & elm, text_content_) BOOST_FOREACH(const office_element_ptr & elm, text_content_)
{ {
elm->docx_convert(Context); elm->docx_convert(Context);
} }
Context.get_section_context().end_section();
} }
// text-section-source-attr // text-section-source-attr
......
...@@ -192,6 +192,7 @@ public: ...@@ -192,6 +192,7 @@ public:
public: public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const; virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
void docx_convert(oox::docx_conversion_context & Context);
private: private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......
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