Commit b474b960 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov
parent 5c7a88b4
...@@ -526,49 +526,53 @@ void docx_conversion_context::process_styles() ...@@ -526,49 +526,53 @@ void docx_conversion_context::process_styles()
BOOST_FOREACH(odf_reader::style_instance_ptr & inst, styles.instances()) BOOST_FOREACH(odf_reader::style_instance_ptr & inst, styles.instances())
{ {
if (!inst->is_automatic() && if (!inst->is_automatic() &&
( (
inst->type() == odf_types::style_family::Paragraph || inst->type() == odf_types::style_family::Paragraph ||
inst->type() == odf_types::style_family::Text inst->type() == odf_types::style_family::Text
) ))
)
{ {
const std::wstring id = style_map_.get(inst->name(), inst->type()); const std::wstring id = style_map_.get(inst->name(), inst->type());
_Wostream << L"<w:style w:styleId=\"" << id << L"\" w:type=\"" << StyleTypeOdf2Docx(inst->type()) << L"\" >\n"; _Wostream << L"<w:style w:styleId=\"" << id << L"\" w:type=\"" << StyleTypeOdf2Docx(inst->type()) << L"\"";
if (!inst->is_default())
{
_Wostream << L" w:customStyle=\"1\"";
}
_Wostream << L">";
const std::wstring displayName = StyleDisplayName(inst->name(), inst->type()); const std::wstring displayName = StyleDisplayName(inst->name(), inst->type());
_Wostream << L"<w:name w:val=\"" << displayName << L"\" />\n"; _Wostream << L"<w:name w:val=\"" << displayName << L"\" />";
if (odf_reader::style_instance * baseOn = inst->parent()) if (odf_reader::style_instance * baseOn = inst->parent())
{ {
const std::wstring basedOnId = style_map_.get(baseOn->name(), baseOn->type()); const std::wstring basedOnId = style_map_.get(baseOn->name(), baseOn->type());
_Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />\n"; _Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />";
} }
else if (!inst->is_default() && style_map_.check(L"", inst->type())) else if (!inst->is_default() && style_map_.check(L"", inst->type()))
{ {
const std::wstring basedOnId = style_map_.get(L"", inst->type()); const std::wstring basedOnId = style_map_.get(L"", inst->type());
_Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />\n"; _Wostream << L"<w:basedOn w:val=\"" << basedOnId << "\" />";
} }
if (odf_reader::style_instance * next = inst->next()) if (odf_reader::style_instance * next = inst->next())
{ {
const std::wstring nextId = style_map_.get(next->name(), next->type()); const std::wstring nextId = style_map_.get(next->name(), next->type());
_Wostream << L"<w:next w:val=\"" << nextId << "\" />\n"; _Wostream << L"<w:next w:val=\"" << nextId << "\" />";
} }
else if (inst->is_default()) else if (inst->is_default())
{ {
// self // self
_Wostream << L"<w:next w:val=\"" << id << "\" />\n"; _Wostream << L"<w:next w:val=\"" << id << "\" />";
} }
if (odf_reader::style_content * content = inst->content()) if (odf_reader::style_content * content = inst->content())
{ {
get_styles_context().start_process_style(inst.get()); get_styles_context().start_process_style(inst.get());
content->docx_convert(*this); content->docx_convert(*this, true);
get_styles_context().end_process_style(); get_styles_context().end_process_style();
} }
_Wostream << L"</w:style>\n"; _Wostream << L"</w:style>";
} }
} }
} }
...@@ -593,15 +597,17 @@ void docx_conversion_context::process_page_properties(std::wostream & strm) ...@@ -593,15 +597,17 @@ void docx_conversion_context::process_page_properties(std::wostream & strm)
} }
} }
void docx_conversion_context::end_process_style_content() void docx_conversion_context::end_process_style_content(bool in_styles)
{ {
docx_serialize_paragraph_style(output_stream(), automatic_parent_style_); docx_serialize_paragraph_style(output_stream(), automatic_parent_style_, in_styles);
if (automatic_parent_style_.empty()) if (automatic_parent_style_.empty())
styles_context_.docx_serialize_text_style( output_stream(), _T("")); styles_context_.docx_serialize_text_style( output_stream(), _T(""));
} }
void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId) void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles)
//in_styles = true -> styles.xml
// <pPr><rPr/></pPr><rPr/> " " rPr ms2010 )
{ {
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();
...@@ -623,7 +629,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str ...@@ -623,7 +629,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
CP_XML_STREAM() << paragraph_style.str(); CP_XML_STREAM() << paragraph_style.str();
docx_serialize_list_properties(CP_XML_STREAM()); docx_serialize_list_properties(CP_XML_STREAM());
if (run_style.tellp() > 0) if (run_style.tellp() > 0 && in_styles == false)
{ {
CP_XML_NODE(L"w:rPr") CP_XML_NODE(L"w:rPr")
{ {
......
...@@ -423,7 +423,7 @@ public: ...@@ -423,7 +423,7 @@ public:
std::vector<odf_reader::_property> & get_settings_properties(); std::vector<odf_reader::_property> & get_settings_properties();
void start_process_style_content(); void start_process_style_content();
void end_process_style_content(); void end_process_style_content(bool in_styles = false);
void start_automatic_style(const std::wstring & ParentId); void start_automatic_style(const std::wstring & ParentId);
void end_automatic_style(); void end_automatic_style();
...@@ -460,7 +460,7 @@ public: ...@@ -460,7 +460,7 @@ public:
void end_list_item(); void end_list_item();
void docx_serialize_list_properties(std::wostream & strm); void docx_serialize_list_properties(std::wostream & strm);
void docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId); void docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId, bool in_styles = false);
std::wstring find_list_rename(const std::wstring & ListStyleName) const; std::wstring find_list_rename(const std::wstring & ListStyleName) const;
......
...@@ -60,6 +60,7 @@ void headers_footers::dump_rels(rels & Rels) const// ...@@ -60,6 +60,7 @@ void headers_footers::dump_rels(rels & Rels) const//
{ {
BOOST_FOREACH(const instance_ptr & inst, instAr.second) BOOST_FOREACH(const instance_ptr & inst, instAr.second)
{ {
if (inst->type_ == none) continue;
Rels.add( relationship( inst->id_, get_rel_type(inst->type_), inst->name_, L"" ) ); Rels.add( relationship( inst->id_, get_rel_type(inst->type_), inst->name_, L"" ) );
} }
} }
......
...@@ -25,12 +25,17 @@ style_instance::style_instance( ...@@ -25,12 +25,17 @@ style_instance::style_instance(
content_(Content), content_(Content),
is_automatic_(IsAutomatic), is_automatic_(IsAutomatic),
is_default_(IsDefault), is_default_(IsDefault),
parent_name_(ParentStyleName),
next_name_(NextStyleName), next_name_(NextStyleName),
parent_(Container->style_by_name(ParentStyleName, style_type_,false)),//???? next_(Container->style_by_name(NextStyleName, style_type_,false)),
next_(Container->style_by_name(NextStyleName, style_type_,false)),//?????
data_style_name_(DataStyleName) data_style_name_(DataStyleName)
{ {
parent_name_ = ParentStyleName;
if (parent_name_ == L"Textformatvorlage")//http://ask.libreoffice.org/en/question/35136/textformatvorlage-style/
{
parent_name_ = L"Standard";
}
parent_ = Container->style_by_name(parent_name_, style_type_,false);
} }
std::wostream & style_instance::dbg_dump(std::wostream & _Wostream) std::wostream & style_instance::dbg_dump(std::wostream & _Wostream)
......
...@@ -587,7 +587,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -587,7 +587,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
if (W) if (W)
{ {
if (W > 0) if (W > 0)
_rPr << L"<w:b />"; _rPr << L"<w:b/>";
else else
_rPr << L"<w:b w:val=\"false\" />"; _rPr << L"<w:b w:val=\"false\" />";
} }
...@@ -598,7 +598,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -598,7 +598,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
if (WCs) if (WCs)
{ {
if (WCs > 0) if (WCs > 0)
_rPr << L"<w:bCs />"; _rPr << L"<w:bCs/>";
else else
_rPr << L"<w:bCs w:val=\"false\" />"; _rPr << L"<w:bCs w:val=\"false\" />";
} }
......
...@@ -177,7 +177,7 @@ void style_content::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -177,7 +177,7 @@ void style_content::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
void style_content::docx_convert(oox::docx_conversion_context & Context) void style_content::docx_convert(oox::docx_conversion_context & Context, bool in_styles)
{ {
Context.start_process_style_content(); Context.start_process_style_content();
...@@ -199,7 +199,7 @@ void style_content::docx_convert(oox::docx_conversion_context & Context) ...@@ -199,7 +199,7 @@ void style_content::docx_convert(oox::docx_conversion_context & Context)
if (style_table_cell_properties_) if (style_table_cell_properties_)
style_table_cell_properties_->docx_convert(Context); style_table_cell_properties_->docx_convert(Context);
Context.end_process_style_content(); Context.end_process_style_content(in_styles);
} }
void style_content::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context) void style_content::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name, document_context * Context)
......
...@@ -56,7 +56,7 @@ class style_content : noncopyable ...@@ -56,7 +56,7 @@ class style_content : noncopyable
public: public:
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 docx_convert(oox::docx_conversion_context & Context); void docx_convert(oox::docx_conversion_context & Context, bool in_styles = false);
void xlsx_convert(oox::xlsx_conversion_context & Context); void xlsx_convert(oox::xlsx_conversion_context & Context);
style_text_properties * get_style_text_properties() const; style_text_properties * get_style_text_properties() const;
......
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