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

(1.0.0.142): ASCOfficeOdfFile

презентации - шаблоны, листы, картинки, тект, списки, ...


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52895 954022d7-b5bf-4e40-9824-e11837661b57
parent f2ada85e
...@@ -24,7 +24,6 @@ docx_conversion_context::docx_conversion_context(package::docx_document * Output ...@@ -24,7 +24,6 @@ docx_conversion_context::docx_conversion_context(package::docx_document * Output
output_document_(OutputDocument), output_document_(OutputDocument),
odf_document_(OdfDocument), odf_document_(OdfDocument),
current_run_(false), current_run_(false),
current_processed_style_( NULL ),
page_break_after_(false), page_break_after_(false),
page_break_before_(false), page_break_before_(false),
in_automatic_style_(false), in_automatic_style_(false),
...@@ -428,9 +427,9 @@ void docx_conversion_context::process_styles() ...@@ -428,9 +427,9 @@ void docx_conversion_context::process_styles()
_Wostream << L"<w:pPrDefault>"; _Wostream << L"<w:pPrDefault>";
if ( odf::style_content * content = defaultParStyle->content()) if ( odf::style_content * content = defaultParStyle->content())
{ {
start_process_style(defaultParStyle); get_styles_context().start_process_style(defaultParStyle);
content->docx_convert(*this); content->docx_convert(*this);
end_process_style(); get_styles_context().end_process_style();
} }
_Wostream << L"</w:pPrDefault>"; _Wostream << L"</w:pPrDefault>";
} }
...@@ -477,9 +476,9 @@ void docx_conversion_context::process_styles() ...@@ -477,9 +476,9 @@ void docx_conversion_context::process_styles()
if (odf::style_content * content = inst->content()) if (odf::style_content * content = inst->content())
{ {
start_process_style(inst.get()); get_styles_context().start_process_style(inst.get());
content->docx_convert(*this); content->docx_convert(*this);
end_process_style(); get_styles_context().end_process_style();
} }
_Wostream << L"</w:style>\n"; _Wostream << L"</w:style>\n";
...@@ -491,15 +490,6 @@ void docx_conversion_context::process_styles() ...@@ -491,15 +490,6 @@ void docx_conversion_context::process_styles()
output_document_->get_word_files().set_styles( package::simple_element::create(L"styles.xml", styles_xml_.str()) ); output_document_->get_word_files().set_styles( package::simple_element::create(L"styles.xml", styles_xml_.str()) );
} }
void docx_conversion_context::start_process_style(const odf::style_instance * Instance)
{
current_processed_style_ = Instance;
}
void docx_conversion_context::end_process_style()
{
current_processed_style_ = NULL;
}
void docx_conversion_context::start_process_style_content() void docx_conversion_context::start_process_style_content()
{ {
......
...@@ -400,10 +400,6 @@ public: ...@@ -400,10 +400,6 @@ public:
void start_process_style_content(); void start_process_style_content();
void end_process_style_content(); void end_process_style_content();
const odf::style_instance * get_current_processed_style() const { return current_processed_style_; }
void start_process_style(const odf::style_instance * Instance);
void end_process_style();
void start_automatic_style(const std::wstring & ParentId); void start_automatic_style(const std::wstring & ParentId);
void end_automatic_style(); void end_automatic_style();
...@@ -515,7 +511,6 @@ private: ...@@ -515,7 +511,6 @@ private:
styles_context styles_context_; styles_context styles_context_;
std::wstring automatic_parent_style_; std::wstring automatic_parent_style_;
const odf::style_instance * current_processed_style_;
std::list< const odf::style_text_properties * > text_properties_stack_; std::list< const odf::style_text_properties * > text_properties_stack_;
......
...@@ -7,8 +7,19 @@ ...@@ -7,8 +7,19 @@
#include <cpdoccore/odf/odf_document.h> #include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/simple_xml_writer.h> #include <cpdoccore/xml/simple_xml_writer.h>
#include "../odf/odfcontext.h"
namespace cpdoccore { namespace cpdoccore {
namespace oox {
void styles_context::start_process_style(const odf::style_instance * Instance)
{
current_processed_style_ = Instance;
}
void styles_context::end_process_style()
{
current_processed_style_ = NULL;
}
void styles_context::start() void styles_context::start()
{ {
...@@ -23,9 +34,12 @@ void styles_context::start() ...@@ -23,9 +34,12 @@ void styles_context::start()
list_style_.str( std::wstring() ); list_style_.str( std::wstring() );
list_style_.clear(); list_style_.clear();
extern_node_ = L"a:rPr";
} }
std::wostream & styles_context::text_style() std::wstringstream & styles_context::text_style()
{ {
return text_style_; return text_style_;
} }
...@@ -35,12 +49,12 @@ std::wstringstream & styles_context::paragraph_style() ...@@ -35,12 +49,12 @@ std::wstringstream & styles_context::paragraph_style()
return paragraph_style_; return paragraph_style_;
} }
std::wostream & styles_context::table_style() std::wstringstream & styles_context::table_style()
{ {
return table_style_; return table_style_;
} }
std::wostream & styles_context::list_style() std::wstringstream & styles_context::list_style()
{ {
return list_style_; return list_style_;
} }
...@@ -73,5 +87,5 @@ void styles_context::docx_serialize_table_style(std::wostream & strm) ...@@ -73,5 +87,5 @@ void styles_context::docx_serialize_table_style(std::wostream & strm)
} }
} }
} }
}
} }
\ No newline at end of file
...@@ -5,24 +5,9 @@ ...@@ -5,24 +5,9 @@
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
namespace cpdoccore { namespace cpdoccore {
namespace oox {
class streams_man
{
public:
streams_man(std::wostream & strm) : stream_(strm)
{
}
std::wostream & get() { return stream_; }
static boost::shared_ptr<streams_man> create(std::wostream & strm) namespace odf{
{ class style_instance;
return boost::shared_ptr<streams_man>( new streams_man(strm) );
}
private:
std::wostream & stream_;
}; };
class styles_context : boost::noncopyable class styles_context : boost::noncopyable
...@@ -30,15 +15,24 @@ class styles_context : boost::noncopyable ...@@ -30,15 +15,24 @@ class styles_context : boost::noncopyable
public: public:
void start(); void start();
std::wostream & text_style(); std::wstringstream & text_style();
std::wstringstream & paragraph_style(); std::wstringstream & paragraph_style();
std::wostream & table_style(); std::wstringstream & table_style();
std::wostream & list_style(); std::wstringstream & list_style();
void docx_serialize_text_style(std::wostream & strm); void docx_serialize_text_style(std::wostream & strm);
void docx_serialize_table_style(std::wostream & strm); void docx_serialize_table_style(std::wostream & strm);
std::wstring & extern_node(){return extern_node_;}
const odf::style_instance * get_current_processed_style() const { return current_processed_style_; }
void start_process_style(const odf::style_instance * Instance);
void end_process_style();
private: private:
const odf::style_instance *current_processed_style_;
std::wstring extern_node_;
std::wstringstream list_style_; std::wstringstream list_style_;
std::wstringstream text_style_; std::wstringstream text_style_;
std::wstringstream paragraph_style_; std::wstringstream paragraph_style_;
...@@ -46,6 +40,25 @@ private: ...@@ -46,6 +40,25 @@ private:
}; };
namespace oox {
class streams_man
{
public:
streams_man(std::wostream & strm) : stream_(strm)
{
}
std::wostream & get() { return stream_; }
static boost::shared_ptr<streams_man> create(std::wostream & strm)
{
return boost::shared_ptr<streams_man>( new streams_man(strm) );
}
private:
std::wostream & stream_;
};
} }
} }
...@@ -80,7 +80,6 @@ public: ...@@ -80,7 +80,6 @@ public:
return odf_document_; return odf_document_;
} }
pptx_xml_slide & current_slide(); pptx_xml_slide & current_slide();
pptx_xml_slideLayout & current_layout(); pptx_xml_slideLayout & current_layout();
pptx_xml_slideMaster & current_master(); pptx_xml_slideMaster & current_master();
......
...@@ -59,6 +59,7 @@ private: ...@@ -59,6 +59,7 @@ private:
bool in_span; bool in_span;
bool in_paragraph; bool in_paragraph;
bool in_list;
odf::styles_container * local_styles_ptr_; odf::styles_container * local_styles_ptr_;
...@@ -100,6 +101,7 @@ pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversi ...@@ -100,6 +101,7 @@ pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversi
paragraphs_cout_(0),in_paragraph(false),in_span(false) paragraphs_cout_(0),in_paragraph(false),in_span(false)
{ {
new_list_style_number_=0; new_list_style_number_=0;
local_styles_ptr_ = NULL;
} }
void pptx_text_context::Impl::add_text(const std::wstring & text) void pptx_text_context::Impl::add_text(const std::wstring & text)
...@@ -129,6 +131,8 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName) ...@@ -129,6 +131,8 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
} }
styles_paragraph_ = styleName; styles_paragraph_ = styleName;
in_paragraph = true; in_paragraph = true;
get_styles_context().start();
} }
void pptx_text_context::Impl::end_paragraph() void pptx_text_context::Impl::end_paragraph()
...@@ -201,16 +205,42 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm) ...@@ -201,16 +205,42 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{ {
CP_XML_NODE(L"a:pPr") CP_XML_NODE(L"a:pPr")
{ {
//... if (!list_style_stack_.empty())
if (styles_paragraph_.length()>0) {
{ int level = list_style_stack_.size()-1;
if (odf::style_instance * styleInst= odf_context_.styleContainer().style_by_name(styles_paragraph_, odf::style_family::Paragraph,false) ) CP_XML_ATTR(L"lvl",level);
//if (styles_paragraph_.length()>0)
//{
// if (odf::style_instance * styleInst= odf_context_.styleContainer().style_by_name(styles_paragraph_, odf::style_family::Paragraph,false) )
// {
// }
//}
//write_list_properties(strm);
odf::list_style_container & list_styles = odf_context_.listStyleContainer();
if (!list_styles.empty())
{ {
odf::text_list_style * s = list_styles.list_style_by_name(list_style_stack_.back());
if (s)
{
odf::office_element_ptr elm = s->get_content()[level];
if (elm)
{
elm->pptx_convert(pptx_context_);
}
CP_XML_STREAM() << get_styles_context().list_style().str();
}
} }
} }
write_list_properties(strm); //else
//{
// if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
// {
// textProperties->content().pptx_convert(Context);
// CP_XML_STREAM() << get_styles_context().text_style().str();
// }
//}
} }
} }
} }
...@@ -230,51 +260,55 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm) ...@@ -230,51 +260,55 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
text_properties_.apply_from(text_properties_paragraph_); text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_); text_properties_.apply_from(text_properties_span_);
_CP_OPT(double) dValFontSize; text_properties_.pptx_convert(pptx_context_);
if (text_properties_.fo_font_size_)
dValFontSize=text_properties_.fo_font_size_->get_length().get_value(); strm << get_styles_context().text_style().str();
_CP_OPT(std::wstring) sValFontFamily; //_CP_OPT(double) dValFontSize;
if (text_properties_.fo_font_family_) //if (text_properties_.fo_font_size_)
sValFontFamily=text_properties_.fo_font_family_.get(); // dValFontSize=text_properties_.fo_font_size_->get_length().get_value();
//else if (text_properties_.style_font_name_) - font_face)decl !!!! //
// sValFontFamily=text_properties_.style_font_name_.get(); //_CP_OPT(std::wstring) sValFontFamily;
//if (text_properties_.fo_font_family_)
_CP_OPT(std::wstring) sValFontColor; // sValFontFamily=text_properties_.fo_font_family_.get();
if (text_properties_.fo_color_) ////else if (text_properties_.style_font_name_) - font_face)decl !!!!
sValFontColor=text_properties_.fo_color_->get_hex_value(); //// sValFontFamily=text_properties_.style_font_name_.get();
_CP_OPT(int) iValFontWeight; //_CP_OPT(std::wstring) sValFontColor;
if (text_properties_.fo_font_weight_) //if (text_properties_.fo_color_)
iValFontWeight=text_properties_.fo_font_weight_->get_type(); // sValFontColor=text_properties_.fo_color_->get_hex_value();
_CP_OPT(int) iValFontStyle; //_CP_OPT(int) iValFontWeight;
if(text_properties_.fo_font_style_) //if (text_properties_.fo_font_weight_)
iValFontStyle=text_properties_.fo_font_style_->get_type(); // iValFontWeight=text_properties_.fo_font_weight_->get_type();
CP_XML_WRITER(strm) //_CP_OPT(int) iValFontStyle;
{ //if(text_properties_.fo_font_style_)
//oox_serialize_style_text(strm,text_properties_); // iValFontStyle=text_properties_.fo_font_style_->get_type();
//oox_serialize_style_text(strm,odf::text_format_properties_content & properties);
CP_XML_NODE(L"a:rPr") //CP_XML_WRITER(strm)
{ // {
// 3197 // //oox_serialize_style_text(strm,text_properties_);
if (dValFontSize) {CP_XML_ATTR(L"sz", (int)(dValFontSize.get()*100));} // //oox_serialize_style_text(strm,odf::text_format_properties_content & properties);
if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_ATTR(L"i", "true");} // CP_XML_NODE(L"a:rPr")
if ((iValFontWeight) && (iValFontWeight.get() >0)) {CP_XML_ATTR(L"b", "true");} // {
if (sValFontFamily) {CP_XML_ATTR(L"typeface", sValFontFamily.get());} // // 3197
// if (dValFontSize) {CP_XML_ATTR(L"sz", (int)(dValFontSize.get()*100));}
if (sValFontColor){CP_XML_NODE(L"a:solidFill") {CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val", sValFontColor.get());}}} // if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_ATTR(L"i", "true");}
// if ((iValFontWeight) && (iValFontWeight.get() >0)) {CP_XML_ATTR(L"b", "true");}
if (hyperlink_hId.length()>0) // if (sValFontFamily) {CP_XML_ATTR(L"typeface", sValFontFamily.get());}
{ //
CP_XML_NODE(L"a:hlinkClick ") // if (sValFontColor){CP_XML_NODE(L"a:solidFill") {CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val", sValFontColor.get());}}}
{
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"); // if (hyperlink_hId.length()>0)
CP_XML_ATTR(L"r:id", hyperlink_hId); // {
} // CP_XML_NODE(L"a:hlinkClick ")
} // {
} // CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
// CP_XML_ATTR(L"r:id", hyperlink_hId);
// }
// }
// }
//CP_XML_NODE(L"charset") //CP_XML_NODE(L"charset")
//{ //{
...@@ -284,24 +318,27 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm) ...@@ -284,24 +318,27 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
//{ //{
// CP_XML_ATTR(L"val",2); // CP_XML_ATTR(L"val",2);
//} //}
} //}
} }
std::wstring pptx_text_context::Impl::dump_paragraph() std::wstring pptx_text_context::Impl::dump_paragraph()
{ {
if (text_.str().length()<1) return L"";
dump_run();//last dump_run();//last
CP_XML_WRITER(paragraph_) std::wstring & str_run = run_.str();
{
CP_XML_NODE(L"a:p") if (str_run.length() > 0)
{
CP_XML_WRITER(paragraph_)
{ {
write_pPr(CP_XML_STREAM());//write_pPr(CP_XML_STREAM()); CP_XML_NODE(L"a:p")
{
write_pPr(CP_XML_STREAM());
CP_XML_STREAM() << run_.str(); CP_XML_STREAM() << run_.str();
}
} }
run_.str(std::wstring());
} }
run_.str(std::wstring());
return paragraph_.str(); return paragraph_.str();
} }
...@@ -366,7 +403,9 @@ std::wstring pptx_text_context::Impl::end_drawing_content() ...@@ -366,7 +403,9 @@ std::wstring pptx_text_context::Impl::end_drawing_content()
} }
void pptx_text_context::Impl::start_list_item(bool restart) void pptx_text_context::Impl::start_list_item(bool restart)
{ {
in_list = true;
first_element_list_item_ = true; first_element_list_item_ = true;
if (restart && !list_style_stack_.empty()) if (restart && !list_style_stack_.empty())
{ {
const std::wstring curStyleName = current_list_style(); const std::wstring curStyleName = current_list_style();
...@@ -399,7 +438,9 @@ void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Co ...@@ -399,7 +438,9 @@ 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(); .. lstStyles - in_list = false;
list_style_stack_.pop_back();// .. lstStyles -
} }
std::wstring pptx_text_context::Impl::current_list_style() std::wstring pptx_text_context::Impl::current_list_style()
...@@ -420,6 +461,11 @@ std::wstring pptx_text_context::Impl::find_list_rename(const std::wstring & List ...@@ -420,6 +461,11 @@ std::wstring pptx_text_context::Impl::find_list_rename(const std::wstring & List
void pptx_text_context::Impl::end_list_item() void pptx_text_context::Impl::end_list_item()
{ {
dump_paragraph();
paragraphs_cout_--;
styles_paragraph_ = L"";
in_list = false;
} }
void pptx_text_context::Impl::write_list_properties(std::wostream & strm) void pptx_text_context::Impl::write_list_properties(std::wostream & strm)
...@@ -450,27 +496,28 @@ void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults ...@@ -450,27 +496,28 @@ void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults
return; return;
get_styles_context().start(); get_styles_context().start();
get_styles_context().extern_node() = L"a:defRPr";
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"a:lstStyle") CP_XML_NODE(L"a:lstStyle");
{ //{
//defPPr // //defPPr
//... // //...
//list levels 0 - 8 // //list levels 0 - 8
BOOST_FOREACH(std::wstring & st_name, list_style_stack_ ) // BOOST_FOREACH(std::wstring & st_name, list_style_stack_ )
{ // {
odf::text_list_style * s = list_styles.list_style_by_name(st_name); // odf::text_list_style * s = list_styles.list_style_by_name(st_name);
//
BOOST_FOREACH(odf::office_element_ptr & elm, s->get_content()) // BOOST_FOREACH(odf::office_element_ptr & elm, s->get_content())
{ // {
elm->pptx_convert(pptx_context_); // elm->pptx_convert(pptx_context_);
} // }
} // }
CP_XML_STREAM() << get_styles_context().list_style(); // CP_XML_STREAM() << get_styles_context().list_style().str();
} //}
} }
list_style_stack_.clear(); list_style_stack_.clear();
...@@ -561,6 +608,5 @@ styles_context & pptx_text_context::get_styles_context() ...@@ -561,6 +608,5 @@ styles_context & pptx_text_context::get_styles_context()
{ {
return impl_->get_styles_context() ; return impl_->get_styles_context() ;
} }
} }
} }
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ 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(); styles_context & get_styles_context();
private: private:
......
...@@ -275,14 +275,6 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm) ...@@ -275,14 +275,6 @@ void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
if ((iValFontWeight) && (iValFontWeight.get() >0)){CP_XML_NODE(L"b") {CP_XML_ATTR(L"val", "true");}} if ((iValFontWeight) && (iValFontWeight.get() >0)){CP_XML_NODE(L"b") {CP_XML_ATTR(L"val", "true");}}
} }
} }
//CP_XML_NODE(L"charset")
//{
// CP_XML_ATTR(L"val",204);
//}
//CP_XML_NODE(L"family")
//{
// CP_XML_ATTR(L"val",2);
//}
} }
} }
......
...@@ -334,9 +334,9 @@ void span::docx_convert(oox::docx_conversion_context & Context) ...@@ -334,9 +334,9 @@ void span::docx_convert(oox::docx_conversion_context & Context)
{ {
Context.push_text_properties(styleContent->get_style_text_properties()); Context.push_text_properties(styleContent->get_style_text_properties());
pushed = true; pushed = true;
Context.start_process_style(styleInst); Context.get_styles_context().start_process_style(styleInst);
Context.add_new_run(); Context.add_new_run();
Context.end_process_style(); Context.get_styles_context().end_process_style();
addNewRun = true; addNewRun = true;
} }
} }
...@@ -379,12 +379,16 @@ void span::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -379,12 +379,16 @@ void span::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
void span::pptx_convert(oox::pptx_conversion_context & Context) void span::pptx_convert(oox::pptx_conversion_context & Context)
{ {
Context.get_text_context().start_span(text_style_name_.style_name()); if (style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(text_style_name_.style_name(), style_family::Text,false))
Context.get_text_context().get_styles_context().start_process_style(styleInst);
Context.get_text_context().start_span(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
{ {
elm->pptx_convert(Context); elm->pptx_convert(Context);
} }
Context.get_text_context().end_span(); Context.get_text_context().end_span();
Context.get_text_context().get_styles_context().end_process_style();
} }
// text:a // text:a
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
...@@ -454,9 +458,9 @@ void a::docx_convert(oox::docx_conversion_context & Context) ...@@ -454,9 +458,9 @@ void a::docx_convert(oox::docx_conversion_context & Context)
{ {
Context.push_text_properties(styleContent->get_style_text_properties()); Context.push_text_properties(styleContent->get_style_text_properties());
pushed = true; pushed = true;
Context.start_process_style(styleInst); Context.get_styles_context().start_process_style(styleInst);
Context.add_new_run(); Context.add_new_run();
Context.end_process_style(); Context.get_styles_context().end_process_style();
addNewRun = true; addNewRun = true;
} }
} }
...@@ -499,12 +503,17 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context) ...@@ -499,12 +503,17 @@ void a::xlsx_convert(oox::xlsx_conversion_context & Context)
} }
void a::pptx_convert(oox::pptx_conversion_context & Context) void a::pptx_convert(oox::pptx_conversion_context & Context)
{ {
// Context.start_hyperlink(text_style_name_.style_name()); if (style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(text_style_name_.style_name(), style_family::Text,false))
Context.get_text_context().get_styles_context().start_process_style(styleInst);
// Context.start_hyperlink(text_style_name_.style_name());
BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_) BOOST_FOREACH(const office_element_ptr & elm, paragraph_content_)
{ {
elm->pptx_convert(Context); elm->pptx_convert(Context);
} }
// Context.end_hyperlink(xlink_href_); // Context.end_hyperlink(xlink_href_);
Context.get_text_context().get_styles_context().end_process_style();
} }
// text:note // text:note
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "fontvariant.h" #include "fontvariant.h"
#include "logging.h" #include "logging.h"
#include <cpdoccore/odf/odf_document.h> #include <cpdoccore/odf/odf_document.h>
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore { namespace cpdoccore {
namespace odf { namespace odf {
...@@ -303,8 +304,198 @@ int text_format_properties_content::process_font_style(const optional<font_style ...@@ -303,8 +304,198 @@ int text_format_properties_content::process_font_style(const optional<font_style
} }
void text_format_properties_content::pptx_convert(oox::pptx_conversion_context & Context) void text_format_properties_content::pptx_convert(oox::pptx_conversion_context & Context)
{ {
std::wostream & _rPr = Context.get_text_context().get_styles_context().text_style(); styles_context & styles_context_ = Context.get_text_context().get_styles_context();
std::wstringstream & _pPr = Context.get_text_context().get_styles_context().paragraph_style(); CP_XML_WRITER(styles_context_.text_style())//a:rPr & a:defRPr
{
CP_XML_NODE(styles_context_.extern_node())
{
const int W = process_font_weight(fo_font_weight_);
if (W>0)CP_XML_ATTR(L"b",true);
const int fontStyle = process_font_style(fo_font_style_);
if (fontStyle>0)CP_XML_ATTR(L"i",true);
double fontSizeVal = (fo_font_size_) ? process_font_size_impl(fo_font_size_, styles_context_.get_current_processed_style()) :
process_font_size_impl(font_size(percent(100.0)), styles_context_.get_current_processed_style());
double mul = 1;
if ((style_text_position_) && (style_text_position_->has_font_size()))
{
mul = style_text_position_->font_size().get_value() / 100.0;
}
if (fontSizeVal > 0)
{
CP_XML_ATTR(L"sz", (int)(fontSizeVal * mul + 0.5));
}
if (fo_font_variant_)
{
if (fo_font_variant_->get_type() == font_variant::SmallCaps)
{
CP_XML_ATTR(L"cap", "small");
}
}
//if (fo_text_transform_)
//{
// if (fo_text_transform_->get_type() == text_transform::Uppercase)
// CP_XML_ATTR(L"cap", "all");
// else if (fo_text_transform_->get_type() == text_transform::Lowercase)
// CP_XML_ATTR(L"cap", "small");
// else if (fo_text_transform_->get_type() == text_transform::None)
// CP_XML_ATTR(L"cap", "none");
//}
{// underline
line_width under = style_text_underline_width_.get_value_or(line_width::Auto);
bool underlineBold = under.get_type() == line_width::Bold ||
under.get_type() == line_width::Thick;
std::wstring underline = L"";
if ( style_text_underline_type_ && style_text_underline_type_->get_type() == line_type::None ||
style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::None
)
{
underline = L"none";
}
else if (style_text_underline_type_ &&
(!style_text_underline_style_ || style_text_underline_style_ && style_text_underline_style_->get_type() == line_style::Solid) )
{
if (underlineBold) underline = L"thick";
switch (style_text_underline_type_->get_type())
{
case line_type::Single: underline = L"sng";
break;
case line_type::Double: underline = L"double";
break;
}
}
else if (style_text_underline_style_)
{
switch (style_text_underline_style_->get_type())
{
case line_style::Solid:
if (underlineBold) underline = L"thick";
else underline = L"sng";
break;
case line_style::Dotted:
if (underlineBold) underline = L"dottedHeavy";
else underline = L"dotted";
break;
case line_style::Dash:
if (underlineBold) underline = L"dashedHeavy";
else underline = L"dash";
break;
case line_style::LongDash:
if (underlineBold) underline = L"dashLongHeavy";
else underline = L"dashLong";
break;
case line_style::DotDash:
if (underlineBold) underline = L"dashDotHeavy";
else underline = L"dotDash";
break;
case line_style::DotDotDash:
if (underlineBold) underline = L"dashDotDotHeavy";
else underline = L"dotDotDash";
break;
case line_style::Wave:
if (underlineBold) underline = L"wavyHeavy";
else if (style_text_underline_type_.get_value_or( line_type(line_type::Single) ).get_type() == line_type::Double)
underline = L"wavyDouble";
else underline = L"wave";
break;
}
}
if (!underline.empty())CP_XML_ATTR(L"u", underline);
}
if (style_text_line_through_type_)
{
if (style_text_line_through_type_->get_type() == line_type::Single)
CP_XML_ATTR(L"strike", L"sngStrike");
else if (style_text_line_through_type_->get_type() == line_type::Double)
CP_XML_ATTR(L"strike", L"dblStrike");
}
else if (style_text_line_through_style_ && style_text_line_through_style_->get_type() != line_style::None)
{
CP_XML_ATTR(L"strike", L"sngStrike");
}
else CP_XML_ATTR(L"strike",L"none");
if ((fo_letter_spacing_) && (fo_letter_spacing_->get_type() != letter_spacing::Normal))
{
CP_XML_ATTR(L"spc",(int)(20.0 * fo_letter_spacing_->get_length().get_value_unit(length::pt)));
}
if (fo_language_ || style_language_asian_ || style_language_complex_)
{
std::wstring w_val;
if (fo_language_) w_val = *fo_language_;
else if (fo_country_) w_val = *fo_country_;
else if (style_country_asian_)w_val = *style_country_asian_;
else if (style_language_asian_)w_val = *style_language_asian_;
else if (style_language_complex_)w_val = *style_language_complex_;
else if (style_country_complex_)w_val = *style_country_complex_;
CP_XML_ATTR(L"lang", w_val);
}
}
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_)
{
std::wstring w_eastAsia;
std::wstring w_hAnsi;
std::wstring w_cs;
std::wstring w_ascii = w_hAnsi = (style_font_name_ ? *style_font_name_: L"");
if (style_font_name_asian_)
w_eastAsia = *style_font_name_asian_;
if (style_font_name_complex_)
w_cs = *style_font_name_complex_;
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_hAnsi);
if (font)CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface",font->name());}
font = fonts.font_by_style_name(w_eastAsia);
if (font) CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface",font->name());}
font = fonts.font_by_style_name(w_cs);
if (font) CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface",font->name());}
}
if (fo_color_)
{
CP_XML_NODE(L"solidFill")
{
CP_XML_NODE(L"srgbClr"){CP_XML_ATTR(L"val",fo_color_->get_hex_value());}
}
}
//else if (style_use_window_font_color_ && *style_use_window_font_color_)
//{
// _rPr << L"<w:color w:val=\"auto\" />";
//}
//if (fo_background_color_)
//{
// std::wstring w_fill;
// if (fo_background_color_->get_type() == background_color::Transparent)
// w_fill = L"auto";
// else
// w_fill = fo_background_color_->get_color().get_hex_value();
// _rPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\" />";
//}
//if (hyperlink_hId.length()>0)
//{
// CP_XML_NODE(L"a:hlinkClick ")
// {
// CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
// CP_XML_ATTR(L"r:id", hyperlink_hId);
// }
//}
}
} }
void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context) void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context)
...@@ -564,8 +755,8 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -564,8 +755,8 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
noNeedSize = true; noNeedSize = true;
} }
double fontSizeVal = (fo_font_size_) ? process_font_size_impl(fo_font_size_, Context.get_current_processed_style()) : double fontSizeVal = (fo_font_size_) ? process_font_size_impl(fo_font_size_, Context.get_styles_context().get_current_processed_style()) :
process_font_size_impl(font_size(percent(100.0)), Context.get_current_processed_style()); process_font_size_impl(font_size(percent(100.0)), Context.get_styles_context().get_current_processed_style());
if (style_text_position_->get_type() == text_position::Percent) if (style_text_position_->get_type() == text_position::Percent)
{ {
...@@ -613,10 +804,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -613,10 +804,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
{ {
int fontSize=0; int fontSize=0;
if (Context.get_drop_cap_context().state()==2) if (Context.get_drop_cap_context().state()==2)
fontSize = process_font_size(fo_font_size_, Context.get_current_processed_style(),false, fontSize = process_font_size(fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7);// 1 . !!! Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7);// 1 . !!!
else else
fontSize = process_font_size(fo_font_size_, Context.get_current_processed_style()); fontSize = process_font_size(fo_font_size_, Context.get_styles_context().get_current_processed_style());
if (fontSize>0) if (fontSize>0)
{ {
...@@ -626,10 +817,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context & ...@@ -626,10 +817,10 @@ void text_format_properties_content::docx_convert(oox::docx_conversion_context &
int fontSizeComplex=0; int fontSizeComplex=0;
if (Context.get_drop_cap_context().state()==2) if (Context.get_drop_cap_context().state()==2)
fontSizeComplex = process_font_size(style_font_size_complex_, Context.get_current_processed_style(), true, fontSizeComplex = process_font_size(style_font_size_complex_, Context.get_styles_context().get_current_processed_style(), true,
Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7); Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7);
else else
fontSizeComplex = process_font_size(style_font_size_complex_, Context.get_current_processed_style(), true); fontSizeComplex = process_font_size(style_font_size_complex_, Context.get_styles_context().get_current_processed_style(), true);
if (fontSizeComplex>0) if (fontSizeComplex>0)
_rPr << L"<w:szCs w:val=\"" << fontSizeComplex << "\" />"; _rPr << L"<w:szCs w:val=\"" << fontSizeComplex << "\" />";
......
...@@ -528,13 +528,13 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C ...@@ -528,13 +528,13 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C
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;
int level = text_list_level_style_attr_.get_text_level(); int level = text_list_level_style_attr_.get_text_level();
std::wstring nodeLevel = L"a:lvl" + boost::lexical_cast<std::wstring>(level) + L"pPr"; //std::wstring nodeLevel = L"a:lvl" + boost::lexical_cast<std::wstring>(level) + L"pPr";
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(nodeLevel) //CP_XML_NODE(nodeLevel)
{ {
CP_XML_ATTR(L"lvl",level - 1); //CP_XML_ATTR(L"lvl",level - 1);
//attr ident //attr ident
//attr marL //attr marL
...@@ -547,7 +547,7 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C ...@@ -547,7 +547,7 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get())) if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
{ {
textProperties->content().pptx_convert(Context); textProperties->content().pptx_convert(Context);
// Context.get_text_context().get_styles_context().pptx_serialize_text_style(CP_XML_STREAM()); strm << Context.get_text_context().get_styles_context().text_style().str();
} }
} }
} }
......
...@@ -94,7 +94,7 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con ...@@ -94,7 +94,7 @@ void process_paragraph_drop_cap_attr(const paragraph_attrs & Attr, oox::docx_con
if ((text_properties) && (text_properties->content().fo_font_size_)) if ((text_properties) && (text_properties->content().fo_font_size_))
{ {
Context.get_drop_cap_context().FontSize = styleContent->get_style_text_properties()->content().process_font_size( Context.get_drop_cap_context().FontSize = styleContent->get_style_text_properties()->content().process_font_size(
text_properties->content().fo_font_size_, Context.get_current_processed_style(),false, text_properties->content().fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7));// !! - 7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7));// !! -
} }
return; return;
...@@ -225,7 +225,7 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context) ...@@ -225,7 +225,7 @@ void paragraph::drop_cap_docx_convert(oox::docx_conversion_context & Context)
if ((text_properties) && (text_properties->content().fo_font_size_)) if ((text_properties) && (text_properties->content().fo_font_size_))
{ {
Context.get_drop_cap_context().FontSize = styleContent->get_style_text_properties()->content().process_font_size( Context.get_drop_cap_context().FontSize = styleContent->get_style_text_properties()->content().process_font_size(
text_properties->content().fo_font_size_, Context.get_current_processed_style(),false, text_properties->content().fo_font_size_, Context.get_styles_context().get_current_processed_style(),false,
7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7)); 7.25 * (Context.get_drop_cap_context().Scale + (Context.get_drop_cap_context().Scale-1) * 0.7));
} }
} }
......
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