diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp
index 1290ff5c80cb5cdd08130cf4b55c6453c74632fd..1286ae943f083bfb1ca8e4afd0791a5c08b83c79 100644
--- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp
+++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.cpp
@@ -82,6 +82,8 @@ void text_tracked_context::start_changes_content()
 
 void text_tracked_context::end_changes_content()
 {
+	docx_context_.finish_run();	//0106GS-GettingStartedWithWriter_el.odt - удаленный заголовок
+
 	current_state_.content.push_back(changes_stream_.str());
 	
 	docx_context_.set_delete_text_state	(false);		
@@ -130,7 +132,6 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
 //----------------------------------------------------------------------------------------------------------------
 
 docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) : 
-	mediaitems_			(OdfDocument->get_folder() ),
 	next_dump_page_properties_	(false),
 	page_break_after_			(false),
 	page_break_before_			(false),
@@ -150,7 +151,8 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
 	delayed_converting_			(false),
 	process_headers_footers_	(false),
 	process_comment_			(false),
-	math_context_				(false),
+	mediaitems_					(OdfDocument->get_folder() ),
+	math_context_				(OdfDocument->odf_context().fontContainer(), false),
 	odf_document_				(OdfDocument)
 {
 	streams_man_		= streams_man::create(temp_stream_);
@@ -832,13 +834,19 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
  //in_styles = true -> styles.xml
 //почему то конструкция <pPr><rPr/></pPr><rPr/> "не работает" в части в rPr в ms2010 )
 {
+	bool in_drawing	= false;
+
+ 	if (get_drawing_context().get_current_shape() || get_drawing_context().get_current_frame())
+	{
+		in_drawing = true;
+	}
 	std::wstringstream & paragraph_style	= get_styles_context().paragraph_nodes();
  	std::wstringstream & run_style			= get_styles_context().text_style();
    
 	CP_XML_WRITER(strm)
 	{
 		if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_) 
-			 && !get_table_context().in_table())
+			 && !get_table_context().in_table() && !in_drawing)
 		{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
 			CP_XML_NODE(L"w:pPr")
 			{
@@ -853,7 +861,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
 		{		
 			CP_XML_NODE(L"w:pPr")
 			{
-				if ( !get_table_context().in_table() )
+				if ( !get_table_context().in_table() && !in_drawing)
 				{
 					CP_XML_STREAM() << get_section_context().dump_;
 					get_section_context().dump_.clear();
diff --git a/ASCOfficeOdfFile/src/docx/docx_drawing.cpp b/ASCOfficeOdfFile/src/docx/docx_drawing.cpp
index 73d908e3738bc84daa1da59b7949e6f399fb3891..62512f12b13ad17cefe6b64bd61da1cca0a9d1af 100644
--- a/ASCOfficeOdfFile/src/docx/docx_drawing.cpp
+++ b/ASCOfficeOdfFile/src/docx/docx_drawing.cpp
@@ -270,7 +270,7 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
 				{
 					CP_XML_ATTR(L"txBox", 1);
 				}
-				if (val.inGroup == false)
+				if (val.inGroup == false && val.sub_type != 1 && val.sub_type != 2)
 				{
 					CP_XML_NODE(L"a:spLocks")
 					{
@@ -439,8 +439,6 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
 					{
 						std::wstring relativeFrom = L"margin";
 						if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
-						
-						if (relativeFrom == L"column") relativeFrom = L"margin";
 
 						CP_XML_ATTR(L"relativeFrom", relativeFrom);
 
@@ -510,8 +508,10 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
 				}
 				if (val.pctHeight)
 				{
-					std::wstring relativeFrom = L"paragraph";
-					if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();					
+					std::wstring relativeFrom = L"margin";
+					if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();	
+
+					if (relativeFrom == L"paragraph") relativeFrom = L"margin";
 					
 					CP_XML_NODE(L"wp14:sizeRelV")
 					{
diff --git a/ASCOfficeOdfFile/src/docx/headers_footers.cpp b/ASCOfficeOdfFile/src/docx/headers_footers.cpp
index 73c331351bfe359f2f52c18ff773f714b6224d01..551f73cf75eeb62d1ea589e8842f5b86c5644cf9 100644
--- a/ASCOfficeOdfFile/src/docx/headers_footers.cpp
+++ b/ASCOfficeOdfFile/src/docx/headers_footers.cpp
@@ -97,9 +97,12 @@ void headers_footers::dump_rels(rels & Rels) const//внешние релсы
     }        
 }
 
-bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const
+bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_page/*not used*/, std::wostream & _Wostream)
 {
-    if (!instances_.count(StyleName))return false;
+    if (!instances_.count(StyleName))	return false;
+	if (last_write_style_ == StyleName)	return true;
+
+	last_write_style_ = StyleName;
 
 	bool first	=	false, left	=	false;
 	bool res	=	false;
diff --git a/ASCOfficeOdfFile/src/docx/headers_footers.h b/ASCOfficeOdfFile/src/docx/headers_footers.h
index 26cd6e89f84e4658f8ca64902e5ba526da8f5c54..186d08cb9fb246ec70f1e329fb94290cb58ed119 100644
--- a/ASCOfficeOdfFile/src/docx/headers_footers.h
+++ b/ASCOfficeOdfFile/src/docx/headers_footers.h
@@ -49,7 +49,8 @@ namespace oox {
 class headers_footers
 {
 public:
-    headers_footers() : size_(0),enable_write_(false){}
+    headers_footers() : size_(0) {}
+
     enum Type { header, footer, headerLeft, footerLeft, headerFirst, footerFirst, none };
     std::wstring add(const std::wstring & StyleName, const std::wstring & Content, Type type,rels &_rels);
    
@@ -66,18 +67,17 @@ public:
     };
 
     void dump_rels(rels & Rels) const;
-    bool write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const;
+    bool write_sectPr(const std::wstring & StyleName, bool next_page, std::wostream & _Wostream);
 
     typedef boost::shared_ptr<instance> instance_ptr;
     typedef std::vector<instance_ptr> instances_array;
     typedef boost::unordered_map<std::wstring, instances_array> instances_map; 
-    const instances_map & instances() const { return instances_; }
-
-	bool get_enable_write(){return enable_write_;}
-	void set_enable_write(bool val){enable_write_ = val;}
+    
+	const instances_map & instances() const { return instances_; }
 
 private:
-	bool enable_write_;
+	std::wstring last_write_style_;
+
 	static std::wstring create_id(size_t i);
 	static std::wstring create_name(size_t i, Type _Type);
 	instances_map instances_;
diff --git a/ASCOfficeOdfFile/src/docx/oox_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/oox_conversion_context.cpp
index 6c1952e95de24e5e3ba707d60231358c2bf3939b..30cbc982ffd87d14e4c4d83954a5a23b9275371d 100644
--- a/ASCOfficeOdfFile/src/docx/oox_conversion_context.cpp
+++ b/ASCOfficeOdfFile/src/docx/oox_conversion_context.cpp
@@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
 }
 namespace oox
 {
-math_context::math_context(bool graphic) :  base_font_size_(12)
+math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) :  base_font_size_(12), fonts_container_(fonts)
 {
 	graphRPR_ = graphic;
 
diff --git a/ASCOfficeOdfFile/src/docx/oox_conversion_context.h b/ASCOfficeOdfFile/src/docx/oox_conversion_context.h
index 4f1d1c02840961027d89d5efe2c371875aa3fb52..be09379a4b4d058d8530223bd54d34a74d9e7983 100644
--- a/ASCOfficeOdfFile/src/docx/oox_conversion_context.h
+++ b/ASCOfficeOdfFile/src/docx/oox_conversion_context.h
@@ -44,6 +44,7 @@ namespace odf_reader
 {
 	class	style_instance;
 	class	style_text_properties;
+	class	fonts_container;
 	typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
 };
 
@@ -90,7 +91,7 @@ namespace oox {
 	class math_context : boost::noncopyable
 	{
 	public:
-		math_context(bool graphic = false);
+		math_context(odf_reader::fonts_container & fonts, bool graphic = false);
 		
 		void				start();
 		std::wstring		end();
@@ -99,6 +100,7 @@ namespace oox {
 		
 		std::wstringstream	& math_style_stream()	{ return math_style_stream_; }
 		
+		odf_reader::fonts_container &			fonts_container_;
 		int										base_font_size_;
 		odf_reader::style_text_properties_ptr	text_properties_;
 
diff --git a/ASCOfficeOdfFile/src/docx/oox_drawing.cpp b/ASCOfficeOdfFile/src/docx/oox_drawing.cpp
index c6f7e43644eb8cf206cc3128c913911fa301e324..d26a5ee0aac1e409177f7cdbece0447dab938f23 100644
--- a/ASCOfficeOdfFile/src/docx/oox_drawing.cpp
+++ b/ASCOfficeOdfFile/src/docx/oox_drawing.cpp
@@ -260,8 +260,8 @@ void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::w
 			if (val.inGroup == false)
 			{
 				_CP_OPT(int)	iWrap;
-				odf_reader::GetProperty(prop,L"text-wrap"	, iWrap);
-				if ((iWrap) && (*iWrap == 0))CP_XML_ATTR(L"wrap", L"none");
+				odf_reader::GetProperty(prop, L"text-wrap"	, iWrap);
+				if ((iWrap) && (*iWrap == 0)) CP_XML_ATTR(L"wrap", L"none");
 			}
 
 			_CP_OPT(int) iAlign;
@@ -419,13 +419,13 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
 		std::wstring xfrm = name_space + L":xfrm";
 
 		_CP_OPT(double) dRotate;
-		odf_reader::GetProperty(val.additional,L"svg:rotate",dRotate);
+		odf_reader::GetProperty(val.additional, L"svg:rotate", dRotate);
 	
 		_CP_OPT(double) dSkewX;
-		odf_reader::GetProperty(val.additional,L"svg:skewX",dSkewX);		
+		odf_reader::GetProperty(val.additional, L"svg:skewX", dSkewX);		
 
 		_CP_OPT(double) dSkewY;
-		odf_reader::GetProperty(val.additional,L"svg:skewY",dSkewY);	
+		odf_reader::GetProperty(val.additional, L"svg:skewY", dSkewY);	
 
 		_CP_OPT(double) dRotateAngle;
 		
@@ -443,7 +443,7 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
 		{      
 			if (dRotateAngle)
 			{
-				double d =360-dRotateAngle.get()*180./3.14159265358979323846;
+				double d =360 - dRotateAngle.get() * 180. / 3.14159265358979323846;
 				d *= 60000; //60 000 per 1 gr - 19.5.5 oox 
 				CP_XML_ATTR(L"rot", (int)d);
 			}
@@ -456,11 +456,19 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wst
 
 			CP_XML_NODE(L"a:off") 
 			{
-				CP_XML_ATTR(L"x", val.x);
-				CP_XML_ATTR(L"y", val.y);
+				if (val.inGroup)
+				{	
+					CP_XML_ATTR(L"x", val.x);
+					CP_XML_ATTR(L"y", val.y);
+				}
+				else
+				{
+					CP_XML_ATTR(L"x", 0);
+					CP_XML_ATTR(L"y", 0);
+				}
 			}
 
-			if (val.cx >0 || val.cy >0)
+			if (val.cx > 0 || val.cy > 0)
 			{
 				CP_XML_NODE(L"a:ext")
 				{
diff --git a/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp b/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp
index 51cfca3921e2187f9d326b18658c6ddb807811a1..55bfff365b65966f0569b6d0fd719b0a5ce52b2b 100644
--- a/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp
+++ b/ASCOfficeOdfFile/src/docx/pptx_conversion_context.cpp
@@ -61,16 +61,16 @@ namespace package
     class pptx_document;
 }
 
-pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument): 
-	output_document_(NULL)
-	,odf_document_(odfDocument)
-	,pptx_text_context_(odf_document_->odf_context(),*this)
-	,pptx_table_context_(*this)
-	,pptx_comments_context_(comments_context_handle_)
-	,pptx_slide_context_(*this/*, pptx_text_context_*/)
-	,math_context_(true)
-	,last_idx_placeHolder(1)
-	,last_uniq_big_id(1)
+pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument)
+	:output_document_		(NULL)
+	,odf_document_			(odfDocument)
+	,pptx_text_context_		(odf_document_->odf_context(), *this)
+	,pptx_table_context_	(*this)
+	,pptx_comments_context_	(comments_context_handle_)
+	,pptx_slide_context_	(*this/*, pptx_text_context_*/)
+	,math_context_			(odf_document_->odf_context().fontContainer(), true)
+	,last_idx_placeHolder	(1)
+	,last_uniq_big_id		(1)
 {
     applicationFonts_ = new CApplicationFonts();
 }
diff --git a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp
index 09181bdf30618f95dd5fffdc31adfe21a584f924..6b9405b5edb043e948ca43ca49757c484987a3d7 100644
--- a/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp
+++ b/ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp
@@ -66,7 +66,7 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
 	num_format_context_	(odf_document_->odf_context()),
 	xlsx_text_context_	(odf_document_->odf_context().styleContainer()),
 	xlsx_table_context_	(this, xlsx_text_context_),
-	math_context_		(true),
+	math_context_		(odf_document_->odf_context().fontContainer(), true),
 	xlsx_style_			(this),
 	
 	maxDigitSize_	(std::pair<float,float>(-1.0, -1.0) ),
diff --git a/ASCOfficeOdfFile/src/odf/datatypes/custom_shape_types_convert.h b/ASCOfficeOdfFile/src/odf/datatypes/custom_shape_types_convert.h
index ed6103b18776afc027986d173f337d781e03e00d..6abaa2083d73948e2f831829f7dc9dbbc7c5bcff 100644
--- a/ASCOfficeOdfFile/src/odf/datatypes/custom_shape_types_convert.h
+++ b/ASCOfficeOdfFile/src/odf/datatypes/custom_shape_types_convert.h
@@ -52,10 +52,10 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
 {L"hexagon"						,L"hexagon"	,0	,0	,0	},
 {L"octagon"						,L"octagon"	,0	,0	,0	},
 {L"star4"						,L"star4"	,1	,0	,50000	},
-{L"star5"						,L"star5"	,1	,0	,50000	},
+{L"star5"						,L"star5"	,0	,0	,50000	},//??? 19098 неверно
 {L"star8"						,L"star8"	,1	,0	,50000	},
 {L"star24"						,L"star24"	,1	,0	,50000	},
-{L"star6"						,L"star6"	,1	,0	,50000	},
+{L"star6"						,L"star6"	,0	,0	,50000	},
 {L"star12"						,L"star12"	,1	,0	,50000	},
 {L"round-rectangle"				,L"roundRect"	,0	,0	,0	},
 {L"ellipse"						,L"ellipse"	,0	,0	,0	},
@@ -137,6 +137,7 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
 {L"mso-spt14"						,L"thickArrow" 	,0	,0	,0	},
 {L"mso-spt17"						,L"Balloon" 	,0	,0	,0	},
 {L"mso-spt18"						,L"irregularSeal1"	,0	,0	,0	},
+{L"mso-spt19"						,L"rect"	,0	,0	,0	},
 {L"mso-spt24"						,L"textBox" 	,0	,0	,0	},
 {L"mso-spt25"				,L""	,0	,0	,0	},
 {L"mso-spt26"				,L""	,0	,0	,0	},
diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
index b9372db51a1b3b6e12564c19aa1b1933f63aadd1..6c8934ea57fd660076344538ae9ea67e4808fc01 100644
--- a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
+++ b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp
@@ -1286,7 +1286,10 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context)
 		if (drawing.cx > max_x) drawing.cy = max_x;
 	}
 	if (auto_fit_shape)
+	{
+		drawing.additional.push_back(_property(L"text-wrap"	, 0));
 		drawing.additional.push_back(_property(L"auto-grow-height", auto_fit_shape));
+	}
 	else if (auto_fit_text)
 		drawing.additional.push_back(_property(L"fit-to-size",	auto_fit_text));
 
diff --git a/ASCOfficeOdfFile/src/odf/draw_shapes.cpp b/ASCOfficeOdfFile/src/odf/draw_shapes.cpp
index 616989ae9345d0b4d07c398a152c0e483a12a781..46ac40ba398f4d81fbeb08ca8e7004a4c4d40c32 100644
--- a/ASCOfficeOdfFile/src/odf/draw_shapes.cpp
+++ b/ASCOfficeOdfFile/src/odf/draw_shapes.cpp
@@ -230,7 +230,11 @@ void draw_path::add_attributes( const xml::attributes_wc_ptr & Attributes )
 }
 void draw_path::reset_svg_path()
 {
-	if (draw_path_attlist_.svg_d_)
+	if (!draw_path_attlist_.svg_d_)
+	{
+		bad_shape_ = true;
+	}
+	else
 	{
 		std::vector<svg_path::_polyline> o_Polyline_pt;
 		std::vector<svg_path::_polyline> o_Polyline_cm;
@@ -286,7 +290,11 @@ void draw_polygon::add_attributes( const xml::attributes_wc_ptr & Attributes )
 }
 void draw_polygon::reset_polygon_path()
 {
-	if (draw_polygon_attlist_.draw_points_)
+	if (!draw_polygon_attlist_.draw_points_)
+	{
+		bad_shape_ = true;
+	}
+	else
 	{
 		std::vector<svg_path::_polyline> o_Polyline_pt;
 		std::vector<svg_path::_polyline> o_Polyline_cm;
@@ -338,7 +346,11 @@ void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
 }
 void draw_polyline::reset_polyline_path()
 {
-	if (draw_polyline_attlist_.draw_points_)
+	if (!draw_polyline_attlist_.draw_points_)
+	{
+		bad_shape_ = true;
+	}
+	else
 	{
 		std::vector<svg_path::_polyline> o_Polyline_pt;
 		std::vector<svg_path::_polyline> o_Polyline_cm;
@@ -601,7 +613,11 @@ void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
 }
 void draw_connector::reset_svg_path()
 {
-	if (draw_connector_attlist_.svg_d_)
+	if (!draw_connector_attlist_.svg_d_)
+	{
+		bad_shape_ = true;
+	}
+	else
 	{
 		std::vector<svg_path::_polyline> o_Polyline_pt;
 		std::vector<svg_path::_polyline> o_Polyline_cm;
diff --git a/ASCOfficeOdfFile/src/odf/math_layout_elements.cpp b/ASCOfficeOdfFile/src/odf/math_layout_elements.cpp
index bfc8fab1e464643357f81155b881ea552b23ffe0..1d02a8cc3e64b5aaa891b36642f0d39d31804eeb 100644
--- a/ASCOfficeOdfFile/src/odf/math_layout_elements.cpp
+++ b/ASCOfficeOdfFile/src/odf/math_layout_elements.cpp
@@ -292,7 +292,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
 		{ 
 			CP_XML_NODE(L"m:ctrlPr")
 			{
-				Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
+				Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
 			}
 		}
 	}
@@ -317,7 +317,7 @@ void math_mstyle::oox_convert(oox::math_context & Context)
 		{ 
 			CP_XML_NODE(L"m:ctrlPr")
 			{
-				Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
+				Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
 			}
 		}
 	}
diff --git a/ASCOfficeOdfFile/src/odf/math_table_elements.cpp b/ASCOfficeOdfFile/src/odf/math_table_elements.cpp
index b9d5c6fddd844a60686a3c81b5943867c96fdeca..860918f45326a238a39937ed03d4bb08b676b9ff 100644
--- a/ASCOfficeOdfFile/src/odf/math_table_elements.cpp
+++ b/ASCOfficeOdfFile/src/odf/math_table_elements.cpp
@@ -94,8 +94,10 @@ void math_mtr::oox_convert(oox::math_context & Context)
 	strm << L"<m:mr>";		
 		for (int i = 0; i < content_.size(); i++)
 		{
+		strm << L"<m:e>";
 			office_math_element* math_element = dynamic_cast<office_math_element*>(content_[i].get());
 			math_element->oox_convert(Context);
+		strm << L"</m:e>";
 		}
 	strm << L"</m:mr>";
 }
diff --git a/ASCOfficeOdfFile/src/odf/math_token_elements.cpp b/ASCOfficeOdfFile/src/odf/math_token_elements.cpp
index 8789f53fe5baa001b0d6b205655284f9589169ef..f95b8f061ec38a483ea2785fbe3de3ac28f7be6e 100644
--- a/ASCOfficeOdfFile/src/odf/math_token_elements.cpp
+++ b/ASCOfficeOdfFile/src/odf/math_token_elements.cpp
@@ -114,7 +114,7 @@ void math_mi::oox_convert(oox::math_context & Context)
 				}
 			}
 
-			Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
+			Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
 
 			CP_XML_NODE(L"m:t")
 			{
@@ -162,7 +162,7 @@ void math_mo::oox_convert(oox::math_context & Context)
         {
 			// + доп стили текста ... todoooo
 
-			Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
+			Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
 			
 			CP_XML_NODE(L"m:t")
 			{
@@ -203,7 +203,7 @@ void math_mn::oox_convert(oox::math_context & Context)
 		{
 			// + доп стили текста ... todoooo
 
-			Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_);
+			Context.text_properties_->content().oox_convert(CP_XML_STREAM(), Context.graphRPR_, Context.fonts_container_);
 	
 			CP_XML_NODE(L"m:t")
 			{
diff --git a/ASCOfficeOdfFile/src/odf/office_body.cpp b/ASCOfficeOdfFile/src/odf/office_body.cpp
index 81be583ab525c50812766f62c7af917214cde9bc..292e3c89bee91a312e84d04dac65956f934dc3a7 100644
--- a/ASCOfficeOdfFile/src/odf/office_body.cpp
+++ b/ASCOfficeOdfFile/src/odf/office_body.cpp
@@ -128,8 +128,6 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
 	if (content_)
         content_->docx_convert(Context);
 
-	Context.get_headers_footers().set_enable_write(true);
-
 	if (!Context.get_section_context().dump_.empty() && !Context.get_table_context().in_table())
 	{
 		Context.output_stream() << Context.get_section_context().dump_;
diff --git a/ASCOfficeOdfFile/src/odf/style_text_properties.cpp b/ASCOfficeOdfFile/src/odf/style_text_properties.cpp
index 84dfe59be67e803b1fee4632800e48291f7d99a5..4edfd8f703e06e06f0794565823039f01217b9cb 100644
--- a/ASCOfficeOdfFile/src/odf/style_text_properties.cpp
+++ b/ASCOfficeOdfFile/src/odf/style_text_properties.cpp
@@ -276,18 +276,20 @@ void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_c
 		{
 			std::wstring w_font	= (fo_font_family_ ? *fo_font_family_: L""); 
 
-			if (w_font.length() < 1)
+			if (w_font.empty())
 			{
-				std::wstring w_ascii	= (style_font_name_ ? *style_font_name_: L"");
-				std::wstring w_eastAsia = (style_font_name_asian_ ? *style_font_name_asian_: L"");
-				std::wstring w_cs		= (style_font_name_complex_ ? *style_font_name_complex_: L"");
+				std::wstring w_ascii	= (style_font_name_			? *style_font_name_			: L"");
+				std::wstring w_eastAsia = (style_font_name_asian_	? *style_font_name_asian_	: L"");
+				std::wstring w_cs		= (style_font_name_complex_ ? *style_font_name_complex_	: L"");
 				
 				fonts_container & fonts = Context.root()->odf_context().fontContainer();	        
 		
-				font_instance * font = fonts.font_by_style_name(w_ascii);
-				if (font == NULL)font = fonts.font_by_style_name(w_eastAsia);
-				if (font == NULL)font = fonts.font_by_style_name(w_cs);
-				if (font)w_font = font->name();
+				font_instance *		font = fonts.font_by_style_name(w_ascii);
+				if (font == NULL)	font = fonts.font_by_style_name(w_eastAsia);
+				if (font == NULL)	font = fonts.font_by_style_name(w_cs);
+				
+				if (font)		
+					w_font = font->name();
 
 				//'Arial' глючит
 				removeCharsFromString(w_font, _T("'"));
@@ -852,22 +854,38 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
 
     if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
     {
+		fonts_container & fonts = Context.root()->odf_context().fontContainer();	        
+
         std::wstring w_eastAsia;
         std::wstring w_hAnsi;
         std::wstring w_cs;
-        std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
+        std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
 
-        _rPr << L"<w:rFonts ";
-        if (!w_ascii.empty())
-            _rPr << L"w:ascii=\"" << w_ascii <<"\" ";
-        if (!w_hAnsi.empty())
-            _rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
-        if (!w_eastAsia.empty())
-            _rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
-        if (!w_cs.empty())
-            _rPr << L"w:cs=\"" << w_cs <<"\" ";
+		if (style_font_name_complex_)
+		{
+			font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
+			if (font)
+				w_cs = font->name();
+		}
+		if (style_font_name_asian_)
+		{
+			font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
+			if (font)
+				w_eastAsia	= font->name();
+		}
+		if (style_font_name_)
+		{
+			font_instance * font = fonts.font_by_style_name(*style_font_name_);
+			if (font) 
+				w_ascii = w_hAnsi = font->name();
+		}
 
-        _rPr << L" />";
+		_rPr << L"<w:rFonts";
+			if (!w_ascii.empty())		_rPr << L" w:ascii=\""		<< w_ascii		<<"\"";
+			if (!w_hAnsi.empty())		_rPr << L" w:hAnsi=\""		<< w_hAnsi		<<"\"";
+			if (!w_eastAsia.empty())	_rPr << L" w:eastAsia=\""	<< w_eastAsia	<<"\"";
+			if (!w_cs.empty())			_rPr << L" w:cs=\""			<< w_cs			<<"\"";
+        _rPr << L"/>";
     }
 
 	_CP_OPT(color) color_text = fo_color_;
@@ -974,12 +992,12 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
 }
 
 
-void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic)
+void text_format_properties_content::oox_convert (std::wostream & _rPr, bool graphic, fonts_container & fonts)
 {
 	const int W			= process_font_weight	(fo_font_weight_);
 	const int fontStyle = process_font_style	(fo_font_style_);
 	const int WCs		= process_font_weight	(style_font_weight_complex_);
-	
+
 	if (graphic)
 	{	
 		_rPr << L"<a:rPr";
@@ -1324,19 +1342,33 @@ void text_format_properties_content::oox_convert (std::wostream & _rPr, bool gra
 			std::wstring w_eastAsia;
 			std::wstring w_hAnsi;
 			std::wstring w_cs;
-			std::wstring w_ascii = w_hAnsi = w_cs = (style_font_name_ ? *style_font_name_: L"");
-
-			_rPr << L"<w:rFonts ";
-			if (!w_ascii.empty())
-				_rPr << L"w:ascii=\"" << w_ascii <<"\" ";
-			if (!w_hAnsi.empty())
-				_rPr << L"w:hAnsi=\"" << w_hAnsi <<"\" ";
-			if (!w_eastAsia.empty())
-				_rPr << L"w:eastAsia=\"" << w_eastAsia <<"\" ";
-			if (!w_cs.empty())
-				_rPr << L"w:cs=\"" << w_cs <<"\" ";
+			std::wstring w_ascii = w_hAnsi = w_cs = (fo_font_family_ ? *fo_font_family_ : L"");
+					
+			if (style_font_name_complex_)
+			{
+				font_instance * font = fonts.font_by_style_name(*style_font_name_complex_);
+				if (font)
+					w_cs = font->name();
+			}
+			if (style_font_name_asian_)
+			{
+				font_instance * font = fonts.font_by_style_name(*style_font_name_asian_);
+				if (font)
+					w_eastAsia	= font->name();
+			}
+			if (style_font_name_)
+			{
+				font_instance * font = fonts.font_by_style_name(*style_font_name_);
+				if (font)
+					w_ascii = w_hAnsi	= font->name();
+			}
 
-			_rPr << L" />";
+			_rPr << L"<w:rFonts";
+				if (!w_ascii.empty())		_rPr << L" w:ascii=\""		<< w_ascii		<<"\"";
+				if (!w_hAnsi.empty())		_rPr << L" w:hAnsi=\""		<< w_hAnsi		<<"\"";
+				if (!w_eastAsia.empty())	_rPr << L" w:eastAsia=\""	<< w_eastAsia	<<"\"";
+				if (!w_cs.empty())			_rPr << L" w:cs=\""			<< w_cs			<<"\"";
+			_rPr << L"/>";
 		}
 
 		_CP_OPT(color) color_text = fo_color_;
diff --git a/ASCOfficeOdfFile/src/odf/style_text_properties.h b/ASCOfficeOdfFile/src/odf/style_text_properties.h
index fc52b2308ad3c0027f48e7a960b36066fefb1d6d..4907e3e1073068b81495ce55cec53622501c0889 100644
--- a/ASCOfficeOdfFile/src/odf/style_text_properties.h
+++ b/ASCOfficeOdfFile/src/odf/style_text_properties.h
@@ -69,6 +69,7 @@ namespace cpdoccore {
 namespace odf_reader {
 
 class style_instance;
+class fonts_container;
 
 // 15.4
 class text_format_properties_content : public oox::conversion_element
@@ -79,7 +80,8 @@ public:
     void docx_convert			(oox::docx_conversion_context & Context);
 	void pptx_convert			(oox::pptx_conversion_context & Context);
 	void pptx_convert_as_list	(oox::pptx_conversion_context & Context);
-	void oox_convert			(std::wostream & stream, bool graphic);
+	
+	void oox_convert			(std::wostream & stream, bool graphic, fonts_container & fonts);
 
     void apply_from			(const text_format_properties_content & Other);
 	void apply_to			(std::vector<_property> & properties);
diff --git a/ASCOfficeOdfFile/src/odf/styles.cpp b/ASCOfficeOdfFile/src/odf/styles.cpp
index ce5b65a989bab9bf0f8cb69cce29f0ece5682b9f..c2690acfe66659683232f8999dafd4d4d10ba437 100644
--- a/ASCOfficeOdfFile/src/odf/styles.cpp
+++ b/ASCOfficeOdfFile/src/odf/styles.cpp
@@ -1134,14 +1134,14 @@ void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream
 
 			CP_XML_NODE(L"w:pgMar")
 			{
-				CP_XML_ATTR(L"w:header"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_top_	) );
-				CP_XML_ATTR(L"w:footer"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
-				CP_XML_ATTR(L"w:gutter"	, 0 );
-				
 				CP_XML_ATTR(L"w:left"	, process_page_margin(common_horizontal_margin_attlist_.fo_margin_left_	, margin_left_length) );
 				CP_XML_ATTR(L"w:right"	, process_page_margin(common_horizontal_margin_attlist_.fo_margin_right_, margin_right_length) );
 				CP_XML_ATTR(L"w:top"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_top_	, Context.get_header_footer_context().header()) );
 				CP_XML_ATTR(L"w:bottom"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_	, Context.get_header_footer_context().footer()) );
+				
+				CP_XML_ATTR(L"w:header"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_top_	) );
+				CP_XML_ATTR(L"w:footer"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
+				CP_XML_ATTR(L"w:gutter"	, 0 );
 			}
 		}
 
@@ -1286,19 +1286,17 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
 		{
 			Context.process_section( CP_XML_STREAM(), columns);
 			
+			bool next_page = Context.is_next_dump_page_properties();
+			
 			CP_XML_NODE(L"w:type")
 			{				
-				if (Context.is_next_dump_page_properties())
-				{
-					CP_XML_ATTR(L"w:val", L"nextPage");
-				}else
-				{
-					CP_XML_ATTR(L"w:val", L"continuous");
-				}
+				if (next_page)	CP_XML_ATTR(L"w:val", L"nextPage");
+				else			CP_XML_ATTR(L"w:val", L"continuous");
 			}			
 
 			std::wstring masterPageName = Context.get_master_page_name();
-			bool res = Context.get_headers_footers().write_sectPr(masterPageName, strm);
+			bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
+			
 			if (res == false)
 			{
 				// default???
@@ -1308,7 +1306,7 @@ void style_page_layout_properties::docx_convert_serialize(std::wostream & strm,
 				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, next_page, strm);
 			}
 	
 			oox::section_context::_section & section = Context.get_section_context().get();
diff --git a/ASCOfficeOdfFile/src/odf/text_elements.cpp b/ASCOfficeOdfFile/src/odf/text_elements.cpp
index 9f9c8f3cec5c6a5bb36aaa9dd9cee050a21a4aef..38fa01c6187a07f05ee560414bbf6a3628dffd9b 100644
--- a/ASCOfficeOdfFile/src/odf/text_elements.cpp
+++ b/ASCOfficeOdfFile/src/odf/text_elements.cpp
@@ -137,7 +137,14 @@ typedef std::map<std::wstring, oox::text_tracked_context::_state>::iterator map_
 
 int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
 {
-    if (!Attr.text_style_name_.empty())
+	bool in_drawing	= false;
+
+ 	if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
+	{
+		in_drawing = true;
+	}
+	
+	if (!Attr.text_style_name_.empty())
     {
         if (style_instance * styleInst =
 				Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_.style_name(), style_family::Paragraph, Context.process_headers_footers_)
@@ -188,9 +195,10 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
                 const std::wstring id = Context.styles_map_.get( styleInst->name(), styleInst->type() );
                 Context.output_stream() << L"<w:pPr>";
 //todooo причесать			
-					if (!Context.get_section_context().dump_.empty()	&&  
-						!Context.get_table_context().in_table()			&& 
-						(Context.get_process_note() == oox::docx_conversion_context::noNote))
+					if (!Context.get_section_context().dump_.empty()
+						&& !Context.get_table_context().in_table()
+						&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
+						&& !in_drawing)
 					{
 						if (Context.is_paragraph_header() )
 						{
@@ -236,9 +244,10 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
 			}
 		}
 	}
-	if (!Context.get_section_context().dump_.empty()	&&  
-		!Context.get_table_context().in_table()			&& 
-		(Context.get_process_note() == oox::docx_conversion_context::noNote))
+	if (!Context.get_section_context().dump_.empty() 
+		&& !Context.get_table_context().in_table()
+		&& (Context.get_process_note() == oox::docx_conversion_context::noNote)
+		&& !in_drawing)
 	{
         Context.output_stream() << L"<w:pPr>";
 			Context.output_stream() << Context.get_section_context().dump_;
@@ -361,18 +370,18 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
 {
     const std::wstring & styleName = attrs_.text_style_name_.style_name();
 	
-	bool drawing	= false;
+	bool in_drawing	= false;
 
  	if (Context.get_drawing_context().get_current_shape() || Context.get_drawing_context().get_current_frame())
 	{
-		drawing = true;
+		in_drawing = true;
 	}
 		
 	bool bIsNewParagraph = true;
 	
 	bool is_empty = content_.empty();
 
-	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) && !in_drawing)
     {//вложеннные элементы ... или после графики embedded_linux_kernel_and_drivers_labs_zh_TW.odt
 		bIsNewParagraph = false;
 		
@@ -425,8 +434,6 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
 		Context.remove_page_properties();
 		Context.add_page_properties(masterPageNameLayout);
 
-		Context.set_page_break(true);
-
 		is_empty = false;
     }    
 
@@ -453,7 +460,8 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
 		if (Context.get_page_break())
 		{
 			if (Context.process_headers_footers_ == false) 
-				_Wostream << L"<w:lastRenderedPageBreak/>";
+				//_Wostream << L"<w:lastRenderedPageBreak/>";
+				_Wostream << L"<w:br w:type=\"page\"/>";  
 			Context.set_page_break(false);
 		}
         elm->docx_convert(Context); 
@@ -482,7 +490,7 @@ void paragraph::docx_convert(oox::docx_conversion_context & Context)
 
 		is_empty = false;
         Context.add_new_run(_T(""));
-        _Wostream << L"<w:br w:type=\"page\" />";        
+        _Wostream << L"<w:br w:type=\"page\"/>";        
         Context.finish_run();
     }