Commit 86dd1863 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52861 954022d7-b5bf-4e40-9824-e11837661b57
parent 3102d178
...@@ -1406,6 +1406,14 @@ ...@@ -1406,6 +1406,14 @@
RelativePath=".\src\docx\mediaitems_utils.h" RelativePath=".\src\docx\mediaitems_utils.h"
> >
</File> </File>
<File
RelativePath=".\src\docx\oox_conversion_context.cpp"
>
</File>
<File
RelativePath=".\src\docx\oox_conversion_context.h"
>
</File>
<File <File
RelativePath=".\src\docx\oox_drawing.cpp" RelativePath=".\src\docx\oox_drawing.cpp"
> >
...@@ -1430,10 +1438,6 @@ ...@@ -1430,10 +1438,6 @@
RelativePath=".\src\docx\oox_package.h" RelativePath=".\src\docx\oox_package.h"
> >
</File> </File>
<File
RelativePath=".\src\docx\ooxconversioncontext.h"
>
</File>
<File <File
RelativePath=".\src\docx\ooxtablerowspanned.h" RelativePath=".\src\docx\ooxtablerowspanned.h"
> >
......
...@@ -52,7 +52,8 @@ void docx_conversion_context::add_element_to_run() ...@@ -52,7 +52,8 @@ void docx_conversion_context::add_element_to_run()
odf::style_text_properties_ptr textProp = this->current_text_properties(); odf::style_text_properties_ptr textProp = this->current_text_properties();
get_styles_context().start(); get_styles_context().start();
textProp->content().docx_convert(*this); textProp->content().docx_convert(*this);
get_styles_context().write_text_style( *this );
get_styles_context().docx_serialize_text_style( output_stream());
} }
} }
...@@ -505,21 +506,45 @@ void docx_conversion_context::start_process_style_content() ...@@ -505,21 +506,45 @@ void docx_conversion_context::start_process_style_content()
styles_context_.start(); styles_context_.start();
} }
void docx_conversion_context::process_page_properties() void docx_conversion_context::process_page_properties(std::wostream & strm)
{ {
if (is_next_dump_page_properties()) if (is_next_dump_page_properties())
{ {
const std::wstring pageProperties = get_page_properties(); const std::wstring pageProperties = get_page_properties();
root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties)->docx_convert(*this); root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties)->docx_convert_serialize(strm,*this);
} }
} }
void docx_conversion_context::end_process_style_content() void docx_conversion_context::end_process_style_content()
{ {
styles_context_.write_paragraph_style(*this, automatic_parent_style_); docx_serialize_paragraph_style(output_stream(), automatic_parent_style_);
if (automatic_parent_style_.empty()) if (automatic_parent_style_.empty())
styles_context_.write_text_style(*this); styles_context_.docx_serialize_text_style( output_stream());
}
void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId)
{
std::wstringstream & paragraph_style = get_styles_context().paragraph_style();
if (!paragraph_style.str().empty() || !ParentId.empty())
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:pPr")
{
process_page_properties(CP_XML_STREAM());//????????
if (!ParentId.empty())
{
CP_XML_NODE(L"w:pStyle")
{
CP_XML_ATTR(L"w:val", ParentId);
}
}
CP_XML_STREAM() << paragraph_style.str();
docx_serialize_list_properties(CP_XML_STREAM());
}
}
}
} }
void docx_conversion_context::start_automatic_style(const std::wstring & ParentId) void docx_conversion_context::start_automatic_style(const std::wstring & ParentId)
...@@ -609,65 +634,6 @@ bool docx_conversion_context::is_next_dump_page_properties() ...@@ -609,65 +634,6 @@ bool docx_conversion_context::is_next_dump_page_properties()
} }
void styles_context::start()
{
text_style_.str( std::wstring() );
text_style_.clear();
paragraph_style_.str( std::wstring() );
paragraph_style_.clear();
table_style_.str( std::wstring() );
table_style_.clear();
}
std::wostream & styles_context::text_style()
{
return text_style_;
}
std::wostream & styles_context::paragraph_style()
{
return paragraph_style_;
}
std::wostream & styles_context::table_style()
{
return table_style_;
}
void styles_context::write_text_style(docx_conversion_context & Context)
{
std::wostream & _Wostream = Context.output_stream();
if (!text_style_.str().empty())
_Wostream << L"<w:rPr>" << text_style_.str() << L"</w:rPr>";
}
void styles_context::write_paragraph_style(docx_conversion_context & Context, const std::wstring & ParentId)
{
std::wostream & _Wostream = Context.output_stream();
if (!paragraph_style_.str().empty() || !ParentId.empty())
{
_Wostream << L"<w:pPr>";
Context.process_page_properties();
if (!ParentId.empty())
_Wostream << L"<w:pStyle w:val=\"" << ParentId << "\" />";
_Wostream << paragraph_style_.str();
Context.write_list_properties();
_Wostream << L"</w:pPr>";
}
}
void styles_context::write_table_style(docx_conversion_context & Context)
{
std::wostream & _Wostream = Context.output_stream();
if (!table_style_.str().empty())
{
_Wostream << L"<w:tblPr>";
_Wostream << table_style_.str();
_Wostream << L"</w:tblPr>";
}
}
void docx_conversion_context::start_text_list_style(const std::wstring & StyleName) void docx_conversion_context::start_text_list_style(const std::wstring & StyleName)
{ {
...@@ -743,18 +709,28 @@ void docx_conversion_context::end_list_item() ...@@ -743,18 +709,28 @@ void docx_conversion_context::end_list_item()
{ {
} }
void docx_conversion_context::write_list_properties() void docx_conversion_context::docx_serialize_list_properties(std::wostream & strm)
{ {
if (!list_style_stack_.empty()) if (!list_style_stack_.empty())
{ {
if (first_element_list_item_) if (first_element_list_item_)
{ {
const int id = root()->odf_context().listStyleContainer().id_by_name( current_list_style() ); const int id = root()->odf_context().listStyleContainer().id_by_name( current_list_style() );
//const int id = list_context_.id_by_name( current_list_style() );
output_stream() << L"<w:numPr>"; CP_XML_WRITER(strm)
output_stream() << L"<w:ilvl w:val=\"" << (list_style_stack_.size() - 1) << "\" />"; {
output_stream() << L"<w:numId w:val=\"" << id << "\" />"; CP_XML_NODE(L"w:numPr")
output_stream() << L"</w:numPr>"; {
CP_XML_NODE(L"w:ilvl")
{
CP_XML_ATTR(L"w:val", (list_style_stack_.size() - 1));
}
CP_XML_NODE(L"w:numId")
{
CP_XML_ATTR(L"w:val", id );
}
}
}
first_element_list_item_ = false; first_element_list_item_ = false;
} }
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "docx_table_context.h" #include "docx_table_context.h"
#include "../odf/noteclass.h" #include "../odf/noteclass.h"
#include "ooxconversioncontext.h" #include "oox_conversion_context.h"
#include "oox_chart_context.h" #include "oox_chart_context.h"
namespace cpdoccore { namespace cpdoccore {
...@@ -83,24 +83,6 @@ private: ...@@ -83,24 +83,6 @@ private:
class styles_context : boost::noncopyable
{
public:
void start();
std::wostream & text_style();
std::wostream & paragraph_style();
std::wostream & table_style();
void write_text_style(docx_conversion_context & Context);
void write_paragraph_style(docx_conversion_context & Context, const std::wstring & ParentId);
void write_table_style(docx_conversion_context & Context);
private:
std::wstringstream text_style_;
std::wstringstream paragraph_style_;
std::wstringstream table_style_;
};
class drawing_context : boost::noncopyable class drawing_context : boost::noncopyable
{ {
public: public:
...@@ -409,7 +391,7 @@ public: ...@@ -409,7 +391,7 @@ public:
void process_fonts(); void process_fonts();
void process_list_styles(); void process_list_styles();
void process_page_properties(); void process_page_properties(std::wostream & strm);
void process_headers_footers(); void process_headers_footers();
void process_comments(); void process_comments();
...@@ -456,8 +438,11 @@ public: ...@@ -456,8 +438,11 @@ public:
const std::wstring current_list_style() const; const std::wstring current_list_style() const;
void start_list_item(bool restart = false); void start_list_item(bool restart = false);
void end_list_item(); void end_list_item();
void write_list_properties();
std::wstring find_list_rename(const std::wstring & ListStyleName) const; void docx_serialize_list_properties(std::wostream & strm);
void docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId);
std::wstring find_list_rename(const std::wstring & ListStyleName) const;
drawing_context & get_drawing_context() { return drawing_context_; } drawing_context & get_drawing_context() { return drawing_context_; }
......
#include "precompiled_cpodf.h"
#include "oox_conversion_context.h"
#include <boost/foreach.hpp>
#include <iostream>
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace oox {
void styles_context::start()
{
text_style_.str( std::wstring() );
text_style_.clear();
paragraph_style_.str( std::wstring() );
paragraph_style_.clear();
table_style_.str( std::wstring() );
table_style_.clear();
list_style_.str( std::wstring() );
list_style_.clear();
}
std::wostream & styles_context::text_style()
{
return text_style_;
}
std::wstringstream & styles_context::paragraph_style()
{
return paragraph_style_;
}
std::wostream & styles_context::table_style()
{
return table_style_;
}
std::wostream & styles_context::list_style()
{
return list_style_;
}
void styles_context::docx_serialize_text_style(std::wostream & strm)
{
if (!text_style_.str().empty())
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:rPr")
{
CP_XML_STREAM() << text_style_.str();
}
}
}
}
void styles_context::docx_serialize_table_style(std::wostream & strm)
{
if (!table_style_.str().empty())
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:tblPr")
{
CP_XML_STREAM() << table_style_.str();
}
}
}
}
}
}
\ No newline at end of file
#ifndef _CPDOCCORE_OOX_CONVERSION_CONTEXT_H_INCLUDED_
#define _CPDOCCORE_OOX_CONVERSION_CONTEXT_H_INCLUDED_
#ifdef _MSC_VER
#pragma once #pragma once
#endif
#include <iosfwd> #include <iosfwd>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
...@@ -11,7 +6,7 @@ ...@@ -11,7 +6,7 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
class streams_man class streams_man
{ {
public: public:
...@@ -30,7 +25,27 @@ private: ...@@ -30,7 +25,27 @@ private:
std::wostream & stream_; std::wostream & stream_;
}; };
class styles_context : boost::noncopyable
{
public:
void start();
std::wostream & text_style();
std::wstringstream & paragraph_style();
std::wostream & table_style();
std::wostream & list_style();
void docx_serialize_text_style(std::wostream & strm);
void docx_serialize_table_style(std::wostream & strm);
private:
std::wstringstream list_style_;
std::wstringstream text_style_;
std::wstringstream paragraph_style_;
std::wstringstream table_style_;
};
} }
} }
#endif
...@@ -31,9 +31,10 @@ namespace package ...@@ -31,9 +31,10 @@ namespace package
pptx_conversion_context:: pptx_conversion_context::
pptx_conversion_context(::cpdoccore::oox::package::pptx_document * outputDocument, pptx_conversion_context(::cpdoccore::oox::package::pptx_document * outputDocument,
::cpdoccore::odf::odf_document * odfDocument): output_document_(outputDocument), ::cpdoccore::odf::odf_document * odfDocument):
odf_document_(odfDocument), output_document_(outputDocument)
pptx_text_context_(odf_document_->odf_context()) ,odf_document_(odfDocument)
,pptx_text_context_(odf_document_->odf_context(),*this)
,pptx_slide_context_(*this/*, pptx_text_context_*/) ,pptx_slide_context_(*this/*, pptx_text_context_*/)
{ {
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "ooxconversioncontext.h"
#include "pptx_text_context.h" #include "pptx_text_context.h"
#include "pptx_slide_context.h" #include "pptx_slide_context.h"
......
...@@ -33,8 +33,6 @@ void pptx_serialize_text(std::wostream & strm, const std::vector<odf::_property> ...@@ -33,8 +33,6 @@ void pptx_serialize_text(std::wostream & strm, const std::vector<odf::_property>
CP_XML_NODE(L"p:txBody") CP_XML_NODE(L"p:txBody")
{ {
CP_XML_NODE(L"a:bodyPr"); CP_XML_NODE(L"a:bodyPr");
CP_XML_NODE(L"a:lstStyle");
if (strTextContent) if (strTextContent)
{ {
......
...@@ -310,18 +310,9 @@ void pptx_xml_presentation::write_to(std::wostream & strm) ...@@ -310,18 +310,9 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
CP_XML_STREAM() << notesSlidesSize_.str(); CP_XML_STREAM() << notesSlidesSize_.str();
CP_XML_NODE(L"p:defaultTextStyle") CP_XML_NODE(L"p:defaultTextStyle")//??
{ {
CP_XML_NODE(L"a:defPPr"); CP_XML_NODE(L"a:defPPr");
//CP_XML_NODE(L"a:lvl1pPr");
//CP_XML_NODE(L"a:lvl2pPr");
//CP_XML_NODE(L"a:lvl3pPr");
//CP_XML_NODE(L"a:lvl4pPr");
//CP_XML_NODE(L"a:lvl5pPr");
//CP_XML_NODE(L"a:lvl6pPr");
//CP_XML_NODE(L"a:lvl7pPr");
//CP_XML_NODE(L"a:lvl8pPr");
//CP_XML_NODE(L"a:lvl9pPr");
} }
} }
} }
......
...@@ -22,8 +22,10 @@ namespace oox { ...@@ -22,8 +22,10 @@ namespace oox {
class pptx_text_context::Impl: boost::noncopyable class pptx_text_context::Impl: boost::noncopyable
{ {
public: public:
Impl(odf::odf_read_context & odf_context_); Impl(odf::odf_read_context & odf_context_, pptx_conversion_context & pptx_context_);
public: public:
styles_context & get_styles_context() { return styles_context_; }
void add_text(const std::wstring & text); void add_text(const std::wstring & text);
void start_paragraph(const std::wstring & styleName); void start_paragraph(const std::wstring & styleName);
...@@ -33,9 +35,6 @@ public: ...@@ -33,9 +35,6 @@ public:
void end_span(); void end_span();
std::wstring end_span2(); std::wstring end_span2();
void start_comment_content();
std::wstring end_comment_content();
void start_drawing_content(); void start_drawing_content();
std::wstring end_drawing_content(); std::wstring end_drawing_content();
...@@ -51,15 +50,16 @@ public: ...@@ -51,15 +50,16 @@ public:
void start_list_item(bool restart = false); void start_list_item(bool restart = false);
void end_list_item(); void end_list_item();
private: private:
styles_context styles_context_;
odf::odf_read_context & odf_context_ ; odf::odf_read_context & odf_context_ ;
std::wstring hyperlink_hId; std::wstring hyperlink_hId;
bool in_comment;
bool in_span; bool in_span;
bool in_paragraph; bool in_paragraph;
odf::styles_container * local_styles_ptr_; odf::styles_container * local_styles_ptr_;
void write_rPr(std::wostream & strm); void write_rPr(std::wostream & strm);
...@@ -85,15 +85,19 @@ private: ...@@ -85,15 +85,19 @@ private:
// //
boost::unordered_map<std::wstring, std::wstring> list_style_renames_; boost::unordered_map<std::wstring, std::wstring> list_style_renames_;
void write_list_styles(std::wostream & strm);
void write_list_properties(std::wostream & strm); void write_list_properties(std::wostream & strm);
std::wstring find_list_rename(const std::wstring & ListStyleName); std::wstring find_list_rename(const std::wstring & ListStyleName);
std::wstring current_list_style(); std::wstring current_list_style();
/////////////////////////// ///////////////////////////
pptx_conversion_context & pptx_context_;
}; };
pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_): paragraphs_cout_(0),odf_context_(odf_contxt_), pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversion_context & pptx_contxt_):
in_comment(false),in_paragraph(false),in_span(false) odf_context_(odf_contxt_), pptx_context_(pptx_contxt_),
paragraphs_cout_(0),in_paragraph(false),in_span(false)
{ {
new_list_style_number_=0; new_list_style_number_=0;
} }
...@@ -193,21 +197,22 @@ void pptx_text_context::Impl::ApplyTextProperties(std::wstring style,odf::text_f ...@@ -193,21 +197,22 @@ void pptx_text_context::Impl::ApplyTextProperties(std::wstring style,odf::text_f
void pptx_text_context::Impl::write_pPr(std::wostream & strm) void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{ {
if (styles_paragraph_.length()>0) CP_XML_WRITER(strm)
{ {
if (odf::style_instance * styleInst= odf_context_.styleContainer().style_by_name(styles_paragraph_, odf::style_family::Paragraph,false) ) CP_XML_NODE(L"a:pPr")
{ {
//...
CP_XML_WRITER(strm) if (styles_paragraph_.length()>0)
{ {
CP_XML_NODE(L"w:pPr") if (odf::style_instance * styleInst= odf_context_.styleContainer().style_by_name(styles_paragraph_, odf::style_family::Paragraph,false) )
{ {
//...
write_list_properties(strm);
} }
} }
} write_list_properties(strm);
} }
}
} }
void pptx_text_context::Impl::write_rPr(std::wostream & strm) void pptx_text_context::Impl::write_rPr(std::wostream & strm)
...@@ -325,19 +330,7 @@ void pptx_text_context::Impl::dump_run() ...@@ -325,19 +330,7 @@ void pptx_text_context::Impl::dump_run()
hyperlink_hId =L""; hyperlink_hId =L"";
} }
void pptx_text_context::Impl::start_comment_content()
{
paragraphs_cout_ = 0;
run_.str(std::wstring());
text_.str(std::wstring());
paragraph_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_ = L"";
in_comment = true;
}
void pptx_text_context::Impl::start_drawing_content() void pptx_text_context::Impl::start_drawing_content()
{ {
paragraphs_cout_ = 0; paragraphs_cout_ = 0;
...@@ -348,26 +341,17 @@ void pptx_text_context::Impl::start_drawing_content() ...@@ -348,26 +341,17 @@ void pptx_text_context::Impl::start_drawing_content()
styles_paragraph_ = L""; styles_paragraph_ = L"";
styles_span_ = L""; styles_span_ = L"";
}
std::wstring pptx_text_context::Impl::end_comment_content()
{
std::wstring comment = dump_paragraph();
paragraphs_cout_ = 0;
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_=L"";
in_comment = false; get_styles_context().start();
return comment;
} }
std::wstring pptx_text_context::Impl::end_drawing_content() std::wstring pptx_text_context::Impl::end_drawing_content()
{ {
std::wstring draw_text= dump_paragraph(); std::wstringstream str_styles;
write_list_styles(str_styles);
str_styles << dump_paragraph();
paragraphs_cout_ = 0; paragraphs_cout_ = 0;
...@@ -378,7 +362,7 @@ std::wstring pptx_text_context::Impl::end_drawing_content() ...@@ -378,7 +362,7 @@ std::wstring pptx_text_context::Impl::end_drawing_content()
styles_paragraph_ = L""; styles_paragraph_ = L"";
styles_span_=L""; styles_span_=L"";
return draw_text; return str_styles.str();
} }
void pptx_text_context::Impl::start_list_item(bool restart) void pptx_text_context::Impl::start_list_item(bool restart)
{ {
...@@ -415,7 +399,7 @@ void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Co ...@@ -415,7 +399,7 @@ void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Co
void pptx_text_context::Impl::end_list() void pptx_text_context::Impl::end_list()
{ {
list_style_stack_.pop_back(); ///list_style_stack_.pop_back(); .. lstStyles -
} }
std::wstring pptx_text_context::Impl::current_list_style() std::wstring pptx_text_context::Impl::current_list_style()
...@@ -458,11 +442,47 @@ void pptx_text_context::Impl::write_list_properties(std::wostream & strm) ...@@ -458,11 +442,47 @@ void pptx_text_context::Impl::write_list_properties(std::wostream & strm)
} }
} }
} }
void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults style paragraph & lists
{
odf::list_style_container & list_styles = odf_context_.listStyleContainer();
if (list_styles.empty())
return;
get_styles_context().start();
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:lstStyle")
{
//defPPr
//...
//list levels 0 - 8
BOOST_FOREACH(std::wstring & st_name, list_style_stack_ )
{
odf::text_list_style * s = list_styles.list_style_by_name(st_name);
BOOST_FOREACH(odf::office_element_ptr & elm, s->get_content())
{
elm->pptx_convert(pptx_context_);
}
}
CP_XML_STREAM() << get_styles_context().list_style();
}
}
list_style_stack_.clear();
}
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
pptx_text_context::pptx_text_context(odf::odf_read_context & odf_context_): impl_(new pptx_text_context::Impl(odf_context_)) pptx_text_context::pptx_text_context(odf::odf_read_context & odf_context_, pptx_conversion_context & pptx_context_):
impl_(new pptx_text_context::Impl(odf_context_,pptx_context_))
{} {}
...@@ -520,18 +540,6 @@ void pptx_text_context::end_list() ...@@ -520,18 +540,6 @@ void pptx_text_context::end_list()
{ {
return impl_->end_list(); return impl_->end_list();
} }
std::wstring pptx_text_context::end_comment_content()
{
return impl_->end_comment_content();
}
void pptx_text_context::start_comment_content()
{
return impl_->start_comment_content();
}
void pptx_text_context::start_drawing_content() void pptx_text_context::start_drawing_content()
{ {
return impl_->start_drawing_content(); return impl_->start_drawing_content();
...@@ -549,7 +557,10 @@ std::wstring pptx_text_context::end_drawing_content() ...@@ -549,7 +557,10 @@ std::wstring pptx_text_context::end_drawing_content()
return impl_->end_drawing_content(); return impl_->end_drawing_content();
} }
styles_context & pptx_text_context::get_styles_context()
{
return impl_->get_styles_context() ;
}
} }
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <cpdoccore/xml/attributes.h> #include <cpdoccore/xml/attributes.h>
#include "oox_conversion_context.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf namespace odf
...@@ -22,7 +23,7 @@ class pptx_conversion_context; ...@@ -22,7 +23,7 @@ class pptx_conversion_context;
class pptx_text_context: boost::noncopyable class pptx_text_context: boost::noncopyable
{ {
public: public:
pptx_text_context(odf::odf_read_context & odf_context_); pptx_text_context(odf::odf_read_context & odf_context_, pptx_conversion_context & pptx_contxt_);
~pptx_text_context(); ~pptx_text_context();
void set_local_styles_container(odf::styles_container* local_styles_); void set_local_styles_container(odf::styles_container* local_styles_);
...@@ -53,8 +54,11 @@ public: ...@@ -53,8 +54,11 @@ public:
void start_list_item(bool restart = false); void start_list_item(bool restart = false);
void end_list_item(); void end_list_item();
styles_context & get_styles_context();
private: private:
class Impl;
class Impl;
_CP_SCOPED_PTR(Impl) impl_; _CP_SCOPED_PTR(Impl) impl_;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "ooxconversioncontext.h" #include "oox_conversion_context.h"
#include "xlsx_textcontext.h" #include "xlsx_textcontext.h"
#include "xlsx_tablecontext.h" #include "xlsx_tablecontext.h"
......
...@@ -122,7 +122,6 @@ void list_header::docx_convert(oox::docx_conversion_context & Context) ...@@ -122,7 +122,6 @@ void list_header::docx_convert(oox::docx_conversion_context & Context)
void list_header::pptx_convert(oox::pptx_conversion_context & Context) void list_header::pptx_convert(oox::pptx_conversion_context & Context)
{ {
bool restart = false; bool restart = false;
//Context.start_list_item(restart);
// //
...@@ -131,7 +130,6 @@ void list_header::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -131,7 +130,6 @@ void list_header::pptx_convert(oox::pptx_conversion_context & Context)
elm->pptx_convert(Context); elm->pptx_convert(Context);
} }
//Context.end_list_item();
} }
......
...@@ -282,7 +282,7 @@ style_page_layout_properties * page_layout_instance::properties() const ...@@ -282,7 +282,7 @@ style_page_layout_properties * page_layout_instance::properties() const
return dynamic_cast<style_page_layout_properties *>(style_page_layout_->style_page_layout_properties_.get()); return dynamic_cast<style_page_layout_properties *>(style_page_layout_->style_page_layout_properties_.get());
} }
void page_layout_instance::docx_convert(oox::docx_conversion_context & Context) void page_layout_instance::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{ {
const style_header_style * headerStyle = dynamic_cast<style_header_style *>(style_page_layout_->style_header_style_.get()); const style_header_style * headerStyle = dynamic_cast<style_header_style *>(style_page_layout_->style_header_style_.get());
const style_footer_style * footerStyle = dynamic_cast<style_footer_style *>(style_page_layout_->style_footer_style_.get()); const style_footer_style * footerStyle = dynamic_cast<style_footer_style *>(style_page_layout_->style_footer_style_.get());
...@@ -306,7 +306,7 @@ void page_layout_instance::docx_convert(oox::docx_conversion_context & Context) ...@@ -306,7 +306,7 @@ void page_layout_instance::docx_convert(oox::docx_conversion_context & Context)
Context.get_header_footer_context().set_footer(bottom); Context.get_header_footer_context().set_footer(bottom);
} }
properties()->docx_convert(Context); properties()->docx_convert_serialize(strm, Context);
} }
void page_layout_instance::pptx_convert(oox::pptx_conversion_context & Context) void page_layout_instance::pptx_convert(oox::pptx_conversion_context & Context)
{ {
......
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
const std::wstring & name() const; const std::wstring & name() const;
style_page_layout_properties * properties() const; style_page_layout_properties * properties() const;
void docx_convert(oox::docx_conversion_context & Context); void docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context);
const style_page_layout * style_page_layout_; const style_page_layout * style_page_layout_;
......
...@@ -74,7 +74,9 @@ void office_body::docx_convert(oox::docx_conversion_context & Context) ...@@ -74,7 +74,9 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
Context.get_headers_footers().set_enable_write(true); Context.get_headers_footers().set_enable_write(true);
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(Context); {
lastPageLayout->docx_convert_serialize(Context.output_stream(), Context);
}
Context.end_body(); Context.end_body();
} }
......
...@@ -140,7 +140,7 @@ std::wstring process_margin(const _CP_OPT(length_or_percent) & margin, double Mu ...@@ -140,7 +140,7 @@ std::wstring process_margin(const _CP_OPT(length_or_percent) & margin, double Mu
void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Context) void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _pPr = Context.get_styles_context().paragraph_style(); std::wstringstream & _pPr = Context.get_styles_context().paragraph_style();
if (style_writing_mode_) if (style_writing_mode_)
{ {
...@@ -450,7 +450,7 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co ...@@ -450,7 +450,7 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co
void style_tab_stops::docx_convert(oox::docx_conversion_context & Context) void style_tab_stops::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _pPr = Context.get_styles_context().paragraph_style(); std::wstringstream & _pPr = Context.get_styles_context().paragraph_style();
if (style_tab_stops_.size()) if (style_tab_stops_.size())
{ {
...@@ -463,7 +463,8 @@ void style_tab_stops::docx_convert(oox::docx_conversion_context & Context) ...@@ -463,7 +463,8 @@ void style_tab_stops::docx_convert(oox::docx_conversion_context & Context)
void style_tab_stop::docx_convert(oox::docx_conversion_context & Context) void style_tab_stop::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _pPr = Context.get_styles_context().paragraph_style(); std::wstringstream & _pPr = Context.get_styles_context().paragraph_style();
_pPr << L"<w:tab "; _pPr << L"<w:tab ";
_pPr << L"w:pos=\"" << (int)( 20.0 * style_position_.get_value_unit(length::pt) ) << "\" "; _pPr << L"w:pos=\"" << (int)( 20.0 * style_position_.get_value_unit(length::pt) ) << "\" ";
......
...@@ -301,10 +301,14 @@ int text_format_properties_content::process_font_style(const optional<font_style ...@@ -301,10 +301,14 @@ int text_format_properties_content::process_font_style(const optional<font_style
} }
return 0; return 0;
} }
void text_format_properties_content::pptx_convert(oox::pptx_conversion_context & Context)
{
std::wostream & _rPr = Context.get_text_context().get_styles_context().text_style();
std::wstringstream & _pPr = Context.get_text_context().get_styles_context().paragraph_style();
}
void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context) void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context)
{ {
std::wostream & _rPr = Context.get_styles_context().text_style();
std::wostream & _pPr = Context.get_styles_context().paragraph_style(); std::wostream & _pPr = Context.get_styles_context().paragraph_style();
// to paragraph properties // to paragraph properties
...@@ -316,6 +320,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -316,6 +320,7 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
_pPr << L"<w:suppressAutoHyphens w:val=\"true\" />"; _pPr << L"<w:suppressAutoHyphens w:val=\"true\" />";
} }
std::wostream & _rPr = Context.get_styles_context().text_style();
if (Context.rtl()) if (Context.rtl())
{ {
_rPr << L"<w:rtl w:val=\"true\" />"; _rPr << L"<w:rtl w:val=\"true\" />";
...@@ -927,6 +932,11 @@ void style_text_properties::docx_convert(oox::docx_conversion_context & Context) ...@@ -927,6 +932,11 @@ void style_text_properties::docx_convert(oox::docx_conversion_context & Context)
text_format_properties_content_.docx_convert(Context); text_format_properties_content_.docx_convert(Context);
} }
void style_text_properties::pptx_convert(oox::pptx_conversion_context & Context)
{
text_format_properties_content_.pptx_convert(Context);
}
} }
} }
...@@ -46,6 +46,7 @@ public: ...@@ -46,6 +46,7 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
void docx_convert(oox::docx_conversion_context & Context); void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
void apply_from(const text_format_properties_content & Other); void apply_from(const text_format_properties_content & Other);
void apply_to(std::vector<_property> & properties); void apply_to(std::vector<_property> & properties);
...@@ -283,6 +284,8 @@ public: ...@@ -283,6 +284,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context); void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
const text_format_properties_content & content() const { return text_format_properties_content_; } ; const text_format_properties_content & content() const { return text_format_properties_content_; } ;
text_format_properties_content & content() { return text_format_properties_content_; } ; text_format_properties_content & content() { return text_format_properties_content_; } ;
......
...@@ -772,10 +772,8 @@ std::wstring process_page_margin(const _CP_OPT(length_or_percent) & Val, const _ ...@@ -772,10 +772,8 @@ std::wstring process_page_margin(const _CP_OPT(length_or_percent) & Val, const _
} }
void style_page_layout_properties_attlist::docx_convert(oox::docx_conversion_context & Context) void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{ {
std::wostream & strm = Context.output_stream();
if (fo_page_width_ || fo_page_height_ || style_print_orientation_) if (fo_page_width_ || fo_page_height_ || style_print_orientation_)
{ {
std::wstring w_w = L""; std::wstring w_w = L"";
...@@ -863,12 +861,12 @@ void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_con ...@@ -863,12 +861,12 @@ void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_con
std::wstring w_orient = L"custom"; std::wstring w_orient = L"custom";
//if (w && h) if (w && h)
//{ {
// double ratio = (double)w/(double)h; double ratio = (double)w/(double)h;
// if (abs(ratio - 16./9.)<0.01) w_orient = L"screen16x9"; if (abs(ratio - 16./9.)<0.01) w_orient = L"screen16x9";
// if (abs(ratio - 4./3.)<0.01) w_orient = L"screen4x3"; if (abs(ratio - 4./3.)<0.01) w_orient = L"screen4x3";
//} }
strm << L"<p:sldSz "; strm << L"<p:sldSz ";
if (!w_h.empty()) if (!w_h.empty())
...@@ -925,7 +923,8 @@ void style_page_layout_properties::add_child_element( xml::sax * Reader, const : ...@@ -925,7 +923,8 @@ void style_page_layout_properties::add_child_element( xml::sax * Reader, const :
{ {
style_page_layout_properties_elements_.add_child_element(Reader, Ns, Name, getContext()); style_page_layout_properties_elements_.add_child_element(Reader, Ns, Name, getContext());
} }
void style_page_layout_properties::docx_convert(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_drawing_context().get_current_level()>0) return;
...@@ -936,57 +935,67 @@ void style_page_layout_properties::docx_convert(oox::docx_conversion_context & C ...@@ -936,57 +935,67 @@ void style_page_layout_properties::docx_convert(oox::docx_conversion_context & C
return; return;
} }
std::wostream & strm = Context.output_stream(); CP_XML_WRITER(strm)
{
strm << L"<w:sectPr>"; CP_XML_NODE(L"w:sectPr")
if (!Context.get_section_context().empty())
{
strm << L"<w:type w:val=\"continuous\" />";
const std::wstring & secStyleName = Context.get_section_context().get().Style;
if (const style_instance * secStyle =
Context.root()->odf_context().styleContainer().style_by_name(secStyleName, style_family::Section,Context.process_headers_footers_))
{ {
if (const style_content * content = secStyle->content()) if (!Context.get_section_context().empty())
{ {
if (style_section_properties * sectPr = content->get_style_section_properties()) 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 =
Context.root()->odf_context().styleContainer().style_by_name(secStyleName, style_family::Section,Context.process_headers_footers_))
{ {
if (const style_columns * columns = dynamic_cast<const style_columns *>( sectPr->style_columns_.get() )) if (const style_content * content = secStyle->content())
{ {
if (columns->fo_column_count_ && *columns->fo_column_count_ > 1) if (style_section_properties * sectPr = content->get_style_section_properties())
{ {
strm << L"<w:cols w:equalWidth=\"true\" w:num=\"" << *columns->fo_column_count_ << L"\" w:sep=\"true\" w:space=\"0\" />"; if (const style_columns * columns = dynamic_cast<const style_columns *>( sectPr->style_columns_.get() ))
} {
if (columns->fo_column_count_ && *columns->fo_column_count_ > 1)
{
CP_XML_NODE(L"w:cols")
{
CP_XML_ATTR(L"w:equalWidth", L"true");
CP_XML_ATTR(L"w:num", *columns->fo_column_count_);
CP_XML_ATTR(L"w:sep",true);
CP_XML_ATTR(L"w:space",0);
}
}
}
}
} }
} }
} }
} else
} {
else CP_XML_NODE(L"w:type")
{ {
if (!Context.get_section_context().get_after_section()) if (!Context.get_section_context().get_after_section())
{ CP_XML_ATTR(L"w:val", L"nextPage");
strm << L"<w:type w:val=\"nextPage\" />"; else
} CP_XML_ATTR(L"w:val", L"continuous");
else }
strm << L"<w:type w:val=\"continuous\" />"; }
}
{ {
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)
{ {
// 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.set_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);
} }
} }
style_page_layout_properties_attlist_.docx_convert(Context);
strm << L"</w:sectPr>";
} }
void style_page_layout_properties::pptx_convert(oox::pptx_conversion_context & Context) void style_page_layout_properties::pptx_convert(oox::pptx_conversion_context & Context)
{ {
......
...@@ -792,7 +792,7 @@ class style_page_layout_properties_attlist ...@@ -792,7 +792,7 @@ class style_page_layout_properties_attlist
public: public:
void add_attributes( const xml::attributes_wc_ptr & Attributes ); void add_attributes( const xml::attributes_wc_ptr & Attributes );
void docx_convert(oox::docx_conversion_context & Context); void docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context);
public: public:
...@@ -934,7 +934,7 @@ public: ...@@ -934,7 +934,7 @@ public:
static const ElementType type = typeStylePageLayout; static const ElementType type = typeStylePageLayout;
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context); void docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context);
const style_page_layout_properties_attlist & get_style_page_layout_properties_attlist() const const style_page_layout_properties_attlist & get_style_page_layout_properties_attlist() const
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "serialize_elements.h" #include "serialize_elements.h"
#include "style_text_properties.h" #include "style_text_properties.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
...@@ -206,27 +208,34 @@ std::wstring GetLevelText(unsigned int displayLevels, ...@@ -206,27 +208,34 @@ std::wstring GetLevelText(unsigned int displayLevels,
return res; return res;
} }
void write_label_alignment_props(std::wostream & strm, style_list_level_label_alignment * labelAlignment) void docx_serialize_label_alignment_props(std::wostream & strm, style_list_level_label_alignment * labelAlignment)
{ {
// ODF 1.2
int position = labelAlignment->get_text_list_tab_stop_position() ? labelAlignment->get_text_list_tab_stop_position()->get_value_unit(length::pt) : 0; int position = labelAlignment->get_text_list_tab_stop_position() ? labelAlignment->get_text_list_tab_stop_position()->get_value_unit(length::pt) : 0;
CP_XML_WRITER(strm)
if (position >0) {
{ if (position >0)
strm << L"<w:tabs>"; {
strm << L"<w:tab w:pos=\"" << CP_XML_NODE(L"w:tabs")
(int)( 0.5 + 20.0 * position ) << "\" w:val=\"num\"" {
<< " />"; CP_XML_NODE(L"w:tab")
strm << L"</w:tabs>"; {
} CP_XML_ATTR(L"w:pos",(int)( 0.5 + 20.0 * position ));
CP_XML_ATTR(L"w:val",L"num");
int w_hanging = (int)( 0.5 - 20.0 * labelAlignment->get_fo_text_indent().get_value_or( length(0, length::pt) ).get_value_unit(length::pt) ); }
int w_left = (int)( 0.5 + 20.0 * labelAlignment->get_fo_margin_left().get_value_or( length(0, length::pt) ).get_value_unit(length::pt) ); }
}
strm << L"<w:ind w:left=\"" << w_left << "\" w:hanging=\"" << w_hanging << "\" />"; int w_hanging = (int)( 0.5 - 20.0 * labelAlignment->get_fo_text_indent().get_value_or( length(0, length::pt) ).get_value_unit(length::pt) );
int w_left = (int)( 0.5 + 20.0 * labelAlignment->get_fo_margin_left().get_value_or( length(0, length::pt) ).get_value_unit(length::pt) );
CP_XML_NODE(L"w:ind")
{
CP_XML_ATTR(L"w:left" , w_left);
CP_XML_ATTR(L"w:hanging" , w_hanging);
}
}
} }
void write_level_justification(std::wostream & strm, style_list_level_properties * listLevelProperties) void docx_serialize_level_justification(std::wostream & strm, style_list_level_properties * listLevelProperties)
{ {
std::wstring w_lvlJc; std::wstring w_lvlJc;
...@@ -242,12 +251,18 @@ void write_level_justification(std::wostream & strm, style_list_level_properties ...@@ -242,12 +251,18 @@ void write_level_justification(std::wostream & strm, style_list_level_properties
w_lvlJc = L"left"; w_lvlJc = L"left";
if (!w_lvlJc.empty()) if (!w_lvlJc.empty())
strm << L"<w:lvlJc w:val=\"" << w_lvlJc << "\" />"; {
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:lvlJc")
{
CP_XML_ATTR(L"w:val",w_lvlJc);
}
}
}
} }
} }
void text_list_level_style_number::docx_convert(oox::docx_conversion_context & Context) void text_list_level_style_number::docx_convert(oox::docx_conversion_context & Context)
{ {
if (text_list_level_style_attr_.get_text_level() - 1 >= 9) if (text_list_level_style_attr_.get_text_level() - 1 >= 9)
...@@ -259,104 +274,121 @@ void text_list_level_style_number::docx_convert(oox::docx_conversion_context & C ...@@ -259,104 +274,121 @@ void text_list_level_style_number::docx_convert(oox::docx_conversion_context & C
style_list_level_label_alignment * labelAlignment = listLevelProperties ? style_list_level_label_alignment * labelAlignment = listLevelProperties ?
dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL; dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL;
CP_XML_WRITER(strm)
strm << L"<w:lvl w:ilvl=\"" << (text_list_level_style_attr_.get_text_level() - 1) << L"\" >";
strm << L"<w:start w:val=\"" << text_list_level_style_number_attr_.text_start_value_ << L"\" />";
strm << L"<w:numFmt w:val=\"" << GetNumFormat( text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ ) << "\" />";
if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
{ {
strm << L"<w:suff w:val=\"" << labelAlignment->text_label_followed_by_.get() << "\" />"; CP_XML_NODE(L"w:lvl")
}else {
strm << L"<w:suff w:val=\"tab\" />"; CP_XML_ATTR(L"w:ilvl",(text_list_level_style_attr_.get_text_level() - 1));
// w:lvlText CP_XML_NODE(L"w:start")
{ {
std::wstring w_lvlText; CP_XML_ATTR(L"w:val",text_list_level_style_number_attr_.text_start_value_);
w_lvlText += text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_prefix_.get_value_or(L""); }
CP_XML_NODE(L"w:numFmt")
// {
const unsigned int displayLevels = text_list_level_style_number_attr_.text_display_levels_; CP_XML_ATTR(L"w:val",GetNumFormat( text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ ));
const unsigned int textLevel = text_list_level_style_attr_.get_text_level(); }
CP_XML_NODE(L"w:suff")
w_lvlText += GetLevelText(displayLevels, textLevel, Context); {
if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
w_lvlText += text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_suffix_.get_value_or(L""); CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get());
else
if (!w_lvlText.empty()) CP_XML_ATTR(L"w:val",L"tab");
strm << L"<w:lvlText w:val=\"" << w_lvlText << "\" />"; }
}
std::wstring w_lvlText;
// w:lvlJc w_lvlText += text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_prefix_.get_value_or(L"");
write_level_justification(strm, listLevelProperties);
////////////////////////////////////////////////////
double spaceBeforeTwip = 0.0; const unsigned int displayLevels = text_list_level_style_number_attr_.text_display_levels_;
if (listLevelProperties && listLevelProperties->text_space_before_) const unsigned int textLevel = text_list_level_style_attr_.get_text_level();
{
spaceBeforeTwip = 20.0 * listLevelProperties->text_space_before_->get_value_unit(length::pt); w_lvlText += GetLevelText(displayLevels, textLevel, Context);
}
w_lvlText += text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_suffix_.get_value_or(L"");
double minLabelWidthTwip = 0.0;
if (listLevelProperties && listLevelProperties->text_min_label_width_) if (!w_lvlText.empty())
{ {
minLabelWidthTwip = 20.0 * listLevelProperties->text_min_label_width_->get_value_unit(length::pt); CP_XML_NODE(L"w:lvlText")
} {
CP_XML_ATTR(L"w:val", w_lvlText);
double minLabelDistanceTwip = 0.0; }
if (listLevelProperties && }
!text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_.empty() && /////////////////////////////////////////////////
listLevelProperties->text_min_label_distance_) docx_serialize_level_justification(CP_XML_STREAM(), listLevelProperties);
{
minLabelDistanceTwip = 20.0 * listLevelProperties->text_min_label_distance_->get_value_unit(length::pt); double spaceBeforeTwip = 0.0;
} if (listLevelProperties && listLevelProperties->text_space_before_)
{ {
strm << L"<w:pPr>"; spaceBeforeTwip = 20.0 * listLevelProperties->text_space_before_->get_value_unit(length::pt);
}
if (labelAlignment)
{ double minLabelWidthTwip = 0.0;
write_label_alignment_props(strm, labelAlignment); if (listLevelProperties && listLevelProperties->text_min_label_width_)
} {
else minLabelWidthTwip = 20.0 * listLevelProperties->text_min_label_width_->get_value_unit(length::pt);
{ }
strm << L"<w:ind";
strm << L" w:left=\"" << ((int)(minLabelWidthTwip + spaceBeforeTwip + 0.5)) << "\""; double minLabelDistanceTwip = 0.0;
if (listLevelProperties &&
if (spaceBeforeTwip < 0.0) !text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_.empty() &&
{ listLevelProperties->text_min_label_distance_)
strm << L" w:firstLine=\"" << ((int)(minLabelWidthTwip + 0.5)) << "\""; {
} minLabelDistanceTwip = 20.0 * listLevelProperties->text_min_label_distance_->get_value_unit(length::pt);
else }
{ CP_XML_NODE(L"w:pPr")
double hanging = 0.0; {
if ( (int)minLabelWidthTwip == 0) if (labelAlignment)
{ {
if (spaceBeforeTwip < 0) docx_serialize_label_alignment_props(CP_XML_STREAM(), labelAlignment);
hanging = spaceBeforeTwip; }
else else
hanging = -spaceBeforeTwip; {
} CP_XML_NODE(L"w:ind")
else {
{ CP_XML_ATTR(L"w:left",((int)(minLabelWidthTwip + spaceBeforeTwip + 0.5)));
hanging = minLabelWidthTwip;
} if (spaceBeforeTwip < 0.0)
{
strm << L" w:hanging=\"" << ((int)( hanging + 0.5)) << "\""; CP_XML_ATTR(L"w:firstLine", ((int)(minLabelWidthTwip + 0.5)));
} }
strm << L" />"; else
} {
double hanging = 0.0;
strm << L"</w:pPr>"; if ( (int)minLabelWidthTwip == 0)
} {
if (spaceBeforeTwip < 0)
hanging = spaceBeforeTwip;
else
hanging = -spaceBeforeTwip;
}
else
{
hanging = minLabelWidthTwip;
}
CP_XML_ATTR(L"w:hanging",((int)( hanging + 0.5)));
}
}
}
}
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);//to style_context
Context.get_styles_context().docx_serialize_text_style( CP_XML_STREAM());//serialize style_context
}
}
}
}
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get())) void text_list_level_style_number::pptx_convert(oox::pptx_conversion_context & Context)
{ {
Context.get_styles_context().start(); if (text_list_level_style_attr_.get_text_level() - 1 >= 9)
textProperties->content().docx_convert(Context); return;
Context.get_styles_context().write_text_style( Context );
}
strm << L"</w:lvl>";
} }
namespace namespace
...@@ -398,97 +430,127 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C ...@@ -398,97 +430,127 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C
style_list_level_label_alignment * labelAlignment = listLevelProperties ? style_list_level_label_alignment * labelAlignment = listLevelProperties ?
dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL; dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL;
//////////////////////////////////////////////////// CP_XML_WRITER(strm)
strm << L"<w:lvl w:ilvl=\"" << (text_list_level_style_attr_.get_text_level() - 1) << L"\" >";
strm << L"<w:numFmt w:val=\"bullet\" />";
if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
{ {
strm << L"<w:suff w:val=\"" << labelAlignment->text_label_followed_by_.get() << "\" />"; CP_XML_NODE(L"w:lvl")
}else {
strm << L"<w:suff w:val=\"tab\" />"; CP_XML_ATTR(L"w:ilvl",(text_list_level_style_attr_.get_text_level() - 1));
CP_XML_NODE(L"w:numFmt"){CP_XML_ATTR(L"w:val",L"bullet");}
const wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022'); CP_XML_NODE(L"w:suff")
strm << L"<w:lvlText w:val=\"" << convert_bullet_char(bullet) << "\"/>"; {
if ((labelAlignment) && (labelAlignment->text_label_followed_by_))
// w:lvlJc CP_XML_ATTR(L"w:val",labelAlignment->text_label_followed_by_.get() );
write_level_justification(strm, listLevelProperties); else
CP_XML_ATTR(L"w:val",L"tab");
}
//strm << L"<w:pPr>";
//style_list_level_label_alignment * labelAlignment = listLevelProperties ? const wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022');
// dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL; CP_XML_NODE(L"w:lvlText")
//if (labelAlignment) {
//{ CP_XML_ATTR(L"w:val",convert_bullet_char(bullet));
// write_label_alignment_props(strm, labelAlignment); }
//}
//strm << L"</w:pPr>"; docx_serialize_level_justification(CP_XML_STREAM(), listLevelProperties);
double spaceBeforeTwip = 0.0;
if (listLevelProperties && listLevelProperties->text_space_before_)
{
spaceBeforeTwip = 20.0 * listLevelProperties->text_space_before_->get_value_unit(length::pt);
}
double minLabelWidthTwip = 0.0;
if (listLevelProperties && listLevelProperties->text_min_label_width_)
{
minLabelWidthTwip = 20.0 * listLevelProperties->text_min_label_width_->get_value_unit(length::pt);
}
double minLabelDistanceTwip = 0.0;
CP_XML_NODE(L"w:pPr")
{
if (labelAlignment)
{
docx_serialize_label_alignment_props(CP_XML_STREAM(), labelAlignment);
}
else
{
CP_XML_NODE(L"w:ind")
{
CP_XML_ATTR(L"w:left",((int)(minLabelWidthTwip + spaceBeforeTwip + 0.5)));
if (spaceBeforeTwip < 0.0)
{
CP_XML_ATTR(L"w:firstLine",((int)(minLabelWidthTwip + 0.5)));
}
else
{
double hanging = 0.0;
if ( (int)minLabelWidthTwip == 0)
{
if (spaceBeforeTwip < 0)
hanging = spaceBeforeTwip;
else
hanging = -spaceBeforeTwip;
}
else
{
hanging = minLabelWidthTwip;
}
CP_XML_ATTR(L"w:hanging" ,((int)( hanging + 0.5)));
}
}
}
}
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
{
Context.get_styles_context().start();
textProperties->content().docx_convert(Context);
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM());
}
}
}
}
double spaceBeforeTwip = 0.0; void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & Context)
if (listLevelProperties && listLevelProperties->text_space_before_) {
{ if (text_list_level_style_attr_.get_text_level() - 1 >= 9)
spaceBeforeTwip = 20.0 * listLevelProperties->text_space_before_->get_value_unit(length::pt); return;
}
double minLabelWidthTwip = 0.0;
if (listLevelProperties && listLevelProperties->text_min_label_width_)
{
minLabelWidthTwip = 20.0 * listLevelProperties->text_min_label_width_->get_value_unit(length::pt);
}
double minLabelDistanceTwip = 0.0; std::wostream & strm = Context.get_text_context().get_styles_context().list_style();
{ style_list_level_properties * listLevelProperties = dynamic_cast<style_list_level_properties *>( style_list_level_properties_.get() );
strm << L"<w:pPr>";
if (labelAlignment)
{
write_label_alignment_props(strm, labelAlignment);
}
else
{
strm << L"<w:ind";
strm << L" w:left=\"" << ((int)(minLabelWidthTwip + spaceBeforeTwip + 0.5)) << "\"";
if (spaceBeforeTwip < 0.0)
{
strm << L" w:firstLine=\"" << ((int)(minLabelWidthTwip + 0.5)) << "\"";
}
else
{
double hanging = 0.0;
if ( (int)minLabelWidthTwip == 0)
{
if (spaceBeforeTwip < 0)
hanging = spaceBeforeTwip;
else
hanging = -spaceBeforeTwip;
}
else
{
hanging = minLabelWidthTwip;
}
strm << L" w:hanging=\"" << ((int)( hanging + 0.5)) << "\"";
}
strm << L" />";
}
strm << L"</w:pPr>"; style_list_level_label_alignment * labelAlignment = listLevelProperties ?
} dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL;
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get())) int level = text_list_level_style_attr_.get_text_level();
{ std::wstring nodeLevel = L"a:lvl" + boost::lexical_cast<std::wstring>(level) + L"pPr";
Context.get_styles_context().start();
textProperties->content().docx_convert(Context); CP_XML_WRITER(strm)
Context.get_styles_context().write_text_style( Context ); {
} CP_XML_NODE(nodeLevel)
{
strm << L"</w:lvl>"; CP_XML_ATTR(L"lvl",level - 1);
//attr ident
//attr marL
const wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022');
CP_XML_NODE(L"a:buChar")
{
CP_XML_ATTR(L"char",convert_bullet_char(bullet));
}
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
{
textProperties->content().pptx_convert(Context);
// Context.get_text_context().get_styles_context().pptx_serialize_text_style(CP_XML_STREAM());
}
}
}
} }
} }
......
#ifndef _CPDOCCORE_ODF_OFFCIE_STYLES_LIST_H_ #pragma once
#define _CPDOCCORE_ODF_OFFCIE_STYLES_LIST_H_
#include <iosfwd> #include <iosfwd>
#include <string> #include <string>
...@@ -170,6 +169,7 @@ public: ...@@ -170,6 +169,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context); void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_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 );
...@@ -216,6 +216,7 @@ public: ...@@ -216,6 +216,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context) ; void docx_convert(oox::docx_conversion_context & Context) ;
void pptx_convert(oox::pptx_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 );
...@@ -233,5 +234,3 @@ CP_REGISTER_OFFICE_ELEMENT2(text_list_level_style_bullet); ...@@ -233,5 +234,3 @@ CP_REGISTER_OFFICE_ELEMENT2(text_list_level_style_bullet);
} } } }
#endif
...@@ -127,7 +127,7 @@ void table_table::docx_convert(oox::docx_conversion_context & Context) ...@@ -127,7 +127,7 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
if (inst && inst->content()) if (inst && inst->content())
inst->content()->docx_convert(Context); inst->content()->docx_convert(Context);
Context.get_styles_context().write_table_style(Context); Context.get_styles_context().docx_serialize_table_style(_Wostream);
_Wostream << L"<w:tblGrid>"; _Wostream << L"<w:tblGrid>";
table_columns_and_groups_.docx_convert(Context); table_columns_and_groups_.docx_convert(Context);
......
...@@ -102,7 +102,6 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con ...@@ -102,7 +102,6 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con
int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context) int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_context & Context)
{ {
std::wostream & _Wostream = Context.output_stream();
if (!Attr.text_style_name_.empty()) if (!Attr.text_style_name_.empty())
{ {
if (style_instance * styleInst if (style_instance * styleInst
...@@ -129,10 +128,11 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co ...@@ -129,10 +128,11 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
else else
{ {
const std::wstring id = Context.get_style_map().get( styleInst->name(), styleInst->type() ); const std::wstring id = Context.get_style_map().get( styleInst->name(), styleInst->type() );
std::wostream & _Wostream = Context.output_stream();
_Wostream << L"<w:pPr>"; _Wostream << L"<w:pPr>";
Context.process_page_properties(); Context.process_page_properties(_Wostream);
_Wostream << L"<w:pStyle w:val=\"" << id << L"\" />"; _Wostream << L"<w:pStyle w:val=\"" << id << L"\" />";
Context.write_list_properties(); Context.docx_serialize_list_properties(_Wostream);
_Wostream << L"</w:pPr>"; _Wostream << L"</w:pPr>";
return 2; return 2;
} }
......
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