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

(1.0.0.151): ASCOfficeOdfFile

поправлены стили текста и параграфов в презентациях

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53162 954022d7-b5bf-4e40-9824-e11837661b57
parent b942e79d
......@@ -182,7 +182,7 @@ void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property
{
_CP_OPT(int) iAlign;
odf::GetProperty(prop,L"textalign-vertiacal",iAlign);
odf::GetProperty(prop,L"textalign-vertical",iAlign);
if (iAlign)
{
switch (iAlign.get())
......@@ -200,7 +200,7 @@ void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property
CP_XML_ATTR(L"anchor", L"just");break;
}
}
else CP_XML_ATTR(L"anchor", L"dist");break;
//else CP_XML_ATTR(L"anchor", L"dist");break;
}
}
......
......@@ -35,8 +35,11 @@ public:
void end_span();
std::wstring end_span2();
void start_drawing_content();
std::wstring end_drawing_content();
void start_object();
std::wstring end_object();
void start_base_style(const std::wstring baseStyleName, const odf::style_family::type baseStyleType);
void end_base_style();
void ApplyTextProperties(std::wstring style,odf::text_format_properties_content & propertiesOut, odf::style_family::type Type);
void ApplyParagraphProperties(std::wstring style,odf::paragraph_format_properties & propertiesOut, odf::style_family::type Type);
......@@ -76,9 +79,11 @@ private:
std::wstringstream paragraph_; //
std::wstringstream run_; //
std::wstring styles_paragraph_;// ... , ,, -
std::wstring styles_span_;
std::wstring paragraph_style_name_;
std::wstring span_style_name_;
std::wstring base_style_name_;
odf::style_family::type base_style_family_;//Presentation Or SpreadSheet
/////////////lists////////////
std::list<std::wstring> list_style_stack_;
bool first_element_list_item_;
......@@ -119,7 +124,7 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
if (paragraphs_cout_++ > 0)
{
if (styles_paragraph_ != styleName)
if (paragraph_style_name_ != styleName)
{
dump_paragraph();
}
......@@ -130,7 +135,7 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
text_.str(std::wstring());
}
styles_paragraph_ = styleName;
paragraph_style_name_ = styleName;
in_paragraph = true;
}
......@@ -141,12 +146,12 @@ void pptx_text_context::Impl::end_paragraph()
void pptx_text_context::Impl::start_span(const std::wstring & styleName)// () - 1
{
if (styles_span_ !=styleName || in_span)
if (span_style_name_ !=styleName || in_span)
{
dump_run();
}
styles_span_ = styleName;
span_style_name_ = styleName;
in_span=true;
}
......@@ -154,7 +159,7 @@ void pptx_text_context::Impl::start_span(const std::wstring & styleName)//
void pptx_text_context::Impl::end_span()
{
dump_run();
styles_span_ = L"";
span_style_name_ = L"";
in_span = false;
}
......@@ -162,7 +167,7 @@ void pptx_text_context::Impl::end_span()
std::wstring pptx_text_context::Impl::end_span2()
{
dump_run();
styles_span_ = L"";
span_style_name_ = L"";
in_span = false;
return run_.str();
......@@ -178,53 +183,65 @@ void pptx_text_context::Impl::end_hyperlink(std::wstring hId)
dump_run();
hyperlink_hId = L"";
}
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style,odf::text_format_properties_content & propertiesOut, odf::style_family::type Type)
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name,odf::text_format_properties_content & propertiesOut, odf::style_family::type Type)
{
std::vector<const odf::style_instance *> instances;
odf::style_instance * defaultStyle = NULL;
odf::style_instance* styleInst = NULL;
odf::style_instance* defaultStyle = NULL;
odf::style_instance* style = NULL;
odf::style_instance* baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
baseStyle = local_styles_ptr_->style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
}
else
{
style = odf_context_.styleContainer().style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
styleInst = odf_context_.styleContainer().style_by_name(style, Type,false/*process_headers_footers_*/);
baseStyle = odf_context_.styleContainer().style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
}
if (defaultStyle)instances.push_back(defaultStyle);
if(styleInst)instances.push_back(styleInst);
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
get_styles_context().start_process_style(styleInst);
if (style)get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_text_properties_content(instances));
}
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style,odf::paragraph_format_properties & propertiesOut, odf::style_family::type Type)
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name,odf::paragraph_format_properties & propertiesOut, odf::style_family::type Type)
{
std::vector<const odf::style_instance *> instances;
odf::style_instance* styleInst = NULL;
odf::style_instance* style = NULL;
odf::style_instance * defaultStyle = NULL;
odf::style_instance * baseStyle = NULL;
if (local_styles_ptr_)
{
style = local_styles_ptr_->style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
baseStyle = local_styles_ptr_->style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
}
else
{
style = odf_context_.styleContainer().style_by_name(style_name, Type,false/*process_headers_footers_*/);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
styleInst = odf_context_.styleContainer().style_by_name(style, Type,false/*process_headers_footers_*/);
baseStyle= odf_context_.styleContainer().style_by_name(base_style_name_, base_style_family_,false/*process_headers_footers_*/);
}
if (defaultStyle)instances.push_back(defaultStyle);
if(styleInst)instances.push_back(styleInst);
get_styles_context().start_process_style(styleInst);
if (defaultStyle) instances.push_back(defaultStyle);
if (baseStyle) instances.push_back(baseStyle);
if (style) instances.push_back(style);
if (style)get_styles_context().start_process_style(style);
else get_styles_context().start_process_style(baseStyle);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
......@@ -235,7 +252,7 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
int level = list_style_stack_.size()-1;
odf::paragraph_format_properties paragraph_format_properties_;
ApplyParagraphProperties (styles_paragraph_, paragraph_format_properties_,odf::style_family::Paragraph);
ApplyParagraphProperties (paragraph_style_name_, paragraph_format_properties_,odf::style_family::Paragraph);
paragraph_format_properties_.pptx_convert(pptx_context_);
......@@ -274,13 +291,13 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
void pptx_text_context::Impl::write_rPr(std::wostream & strm)
{
if (styles_paragraph_.length()<1 && styles_span_.length()<1 && !(hyperlink_hId.length()>0) )return;
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0) && base_style_name_.length()<1)return;
odf::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (styles_paragraph_, text_properties_paragraph_,odf::style_family::Paragraph);
odf::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf::style_family::Paragraph);
odf::text_format_properties_content text_properties_span_;
ApplyTextProperties(styles_span_, text_properties_span_,odf::style_family::Text);
ApplyTextProperties(span_style_name_, text_properties_span_,odf::style_family::Text);
odf::text_format_properties_content text_properties_;
......@@ -301,7 +318,7 @@ std::wstring pptx_text_context::Impl::dump_paragraph()
std::wstring & str_run = run_.str();
if (str_run.length() > 0 || styles_paragraph_.length() > 0)
if (str_run.length() > 0 || paragraph_style_name_.length() > 0)
{
CP_XML_WRITER(paragraph_)
{
......@@ -327,7 +344,7 @@ void pptx_text_context::Impl::dump_run()
{
const std::wstring content = xml::utils::replace_text_to_xml(text_.str());
if (content.length()<1 && styles_span_.length()<1) return ;
if (content.length()<1 && span_style_name_.length()<1) return ;
CP_XML_WRITER(run_)
{
......@@ -349,8 +366,19 @@ void pptx_text_context::Impl::dump_run()
hyperlink_hId =L"";
}
void pptx_text_context::Impl::start_base_style(const std::wstring baseStyleName, const odf::style_family::type baseStyleType)
{
base_style_name_ = baseStyleName;
base_style_family_ = baseStyleType;
}
void pptx_text_context::Impl::start_drawing_content()
void pptx_text_context::Impl::end_base_style()
{
base_style_name_ = L"";
base_style_family_ = odf::style_family::None;
}
void pptx_text_context::Impl::start_object()
{
paragraphs_cout_ = 0;
......@@ -358,12 +386,12 @@ void pptx_text_context::Impl::start_drawing_content()
paragraph_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_ = L"";
paragraph_style_name_ = L"";
span_style_name_ = L"";
}
std::wstring pptx_text_context::Impl::end_drawing_content()
std::wstring pptx_text_context::Impl::end_object()
{
dump_paragraph();
......@@ -383,8 +411,8 @@ std::wstring pptx_text_context::Impl::end_drawing_content()
paragraph_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_=L"";
paragraph_style_name_ = L"";
span_style_name_=L"";
return str_styles.str();
}
......@@ -450,7 +478,7 @@ void pptx_text_context::Impl::end_list_item()
{
dump_paragraph();
paragraphs_cout_--;
styles_paragraph_ = L"";
paragraph_style_name_ = L"";
in_list_ = false;
}
......@@ -570,9 +598,19 @@ void pptx_text_context::end_list()
{
return impl_->end_list();
}
void pptx_text_context::start_drawing_content()
void pptx_text_context::start_base_style(const std::wstring baseStyleName, const odf::style_family::type baseStyleType)
{
return impl_->start_base_style(baseStyleName, baseStyleType);
}
void pptx_text_context::end_base_style()
{
return impl_->end_base_style();
}
void pptx_text_context::start_object()
{
return impl_->start_drawing_content();
return impl_->start_object();
}
void pptx_text_context::start_hyperlink()
{
......@@ -582,9 +620,9 @@ void pptx_text_context::end_hyperlink(std::wstring hId)
{
return impl_->end_hyperlink(hId);
}
std::wstring pptx_text_context::end_drawing_content()
std::wstring pptx_text_context::end_object()
{
return impl_->end_drawing_content();
return impl_->end_object();
}
styles_context & pptx_text_context::get_styles_context()
......
......@@ -8,6 +8,7 @@
#include <cpdoccore/xml/attributes.h>
#include "oox_conversion_context.h"
#include "../odf/stylefamily.h"
namespace cpdoccore {
namespace odf
......@@ -40,8 +41,11 @@ public:
void start_comment_content();
std::wstring end_comment_content();
void start_drawing_content();
std::wstring end_drawing_content();
void start_base_style(const std::wstring baseStyleName, const odf::style_family::type baseStyleType);
void end_base_style();
void start_object();
std::wstring end_object();
void start_hyperlink();
void end_hyperlink(std::wstring hId);
......
......@@ -74,8 +74,8 @@ private:
std::wstringstream output_;
xlsx_shared_strings xlsx_shared_strings_;
std::wstring styles_paragraph_;// ... , ,, -
std::wstring styles_span_;
std::wstring paragraph_style_name_;// ... , ,, -
std::wstring span_style_name_;
};
......@@ -107,7 +107,7 @@ void xlsx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
if (paragraphs_cout_++ > 0)
{
if (styles_paragraph_ != styleName)
if (paragraph_style_name_ != styleName)
{
dump_text();
}
......@@ -118,7 +118,7 @@ void xlsx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
text_.str(std::wstring());
}
styles_paragraph_ = styleName;
paragraph_style_name_ = styleName;
in_paragraph = true;
}
......@@ -127,7 +127,7 @@ void xlsx_text_context::Impl::end_paragraph()
if (!in_comment && !in_draw)
{
dump_text();
styles_paragraph_ = L"";
paragraph_style_name_ = L"";
}
in_paragraph = false;
}
......@@ -140,12 +140,12 @@ void xlsx_text_context::Impl::start_span(const std::wstring & styleName)//
}
else
{
if (styles_span_ !=styleName || in_span)
if (span_style_name_ !=styleName || in_span)
{
dump_text();
}
}
styles_span_ = styleName;
span_style_name_ = styleName;
in_span=true;
}
......@@ -155,7 +155,7 @@ void xlsx_text_context::Impl::end_span() //odf
if (!in_comment && !in_draw)
{
dump_text();
styles_span_=L"";
span_style_name_=L"";
}
in_span=false;
}
......@@ -163,7 +163,7 @@ void xlsx_text_context::Impl::end_span() //odf
std::wstring xlsx_text_context::Impl::end_span2()
{
const std::wstring content = dump_text();
styles_span_ = L"";
span_style_name_ = L"";
in_span = false;
return content;
......@@ -203,13 +203,13 @@ void xlsx_text_context::Impl::ApplyTextProperties(std::wstring style,odf::text_f
void xlsx_text_context::Impl::write_rPr(std::wostream & strm)
{
if (styles_paragraph_.length()<1 && styles_span_.length()<1 && !(hyperlink_hId.length()>0 && in_draw) )return;
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0 && in_draw) )return;
odf::text_format_properties_content text_properties_paragraph_;
ApplyTextProperties (styles_paragraph_, text_properties_paragraph_,odf::style_family::Paragraph);
ApplyTextProperties (paragraph_style_name_, text_properties_paragraph_,odf::style_family::Paragraph);
odf::text_format_properties_content text_properties_span_;
ApplyTextProperties(styles_span_, text_properties_span_,odf::style_family::Text);
ApplyTextProperties(span_style_name_, text_properties_span_,odf::style_family::Text);
odf::text_format_properties_content text_properties_;
......@@ -319,8 +319,8 @@ void xlsx_text_context::Impl::start_cell_content()
text_.str(std::wstring()); //
styles_paragraph_ = L"";
styles_span_ = L"";
paragraph_style_name_ = L"";
span_style_name_ = L"";
in_cell_content = true;
}
......@@ -332,8 +332,8 @@ void xlsx_text_context::Impl::start_comment_content()
output_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_ = L"";
paragraph_style_name_ = L"";
span_style_name_ = L"";
in_comment = true;
}
......@@ -344,8 +344,8 @@ void xlsx_text_context::Impl::start_drawing_content()
output_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_ = L"";
paragraph_style_name_ = L"";
span_style_name_ = L"";
in_draw = true;
}
......@@ -360,8 +360,8 @@ std::wstring xlsx_text_context::Impl::end_comment_content()
output_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_=L"";
paragraph_style_name_ = L"";
span_style_name_=L"";
in_comment = false;
return comment;
......@@ -377,8 +377,8 @@ std::wstring xlsx_text_context::Impl::end_drawing_content()
output_.str(std::wstring());
text_.str(std::wstring());
styles_paragraph_ = L"";
styles_span_=L"";
paragraph_style_name_ = L"";
span_style_name_=L"";
in_draw = false;
return draw;
......
......@@ -143,6 +143,8 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
}
if (office_event_listeners_)office_event_listeners_->pptx_convert(Context);
Context.get_text_context().start_base_style(baseStyleName ,odf::style_family::Presentation);
////////////////////////////////////////////////
int i=0;
int size = content_.size();
......@@ -153,6 +155,8 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
elm->pptx_convert(Context);
i++;
}
Context.get_text_context().end_base_style();
//Context.get_slide_context().end_drawing();
}
......@@ -162,7 +166,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_image(href);
//////////////////////////////////// ...
Context.get_text_context().start_drawing_content();//... -
Context.get_text_context().start_object();
int i=0;
int size = content_.size();
......@@ -172,7 +176,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
content_[i]->pptx_convert(Context);
i++;
}
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
{
......@@ -203,7 +207,7 @@ void draw_chart::pptx_convert(oox::pptx_conversion_context & Context)
void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().start_shape(2);//rect
Context.get_text_context().start_drawing_content();
Context.get_text_context().start_object();
int i=0;
int size = content_.size();
......@@ -213,7 +217,7 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context)
content_[i]->pptx_convert(Context);
i++;
}
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
{
......@@ -265,14 +269,14 @@ void draw_object::pptx_convert(oox::pptx_conversion_context & Context)
if (chartBuild.object_type_ == 2)//
{
Context.get_slide_context().start_shape(2);
Context.get_text_context().start_drawing_content();
Context.get_text_context().start_object();
// ... !!
Context.get_text_context().set_local_styles_container(&objectSubDoc.odf_context().styleContainer());
chartBuild.office_text_->pptx_convert(Context);
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
std::wstring text_content_ = Context.get_text_context().end_object();
Context.get_text_context().set_local_styles_container(NULL);// ...
if (text_content_.length()>0)
......
......@@ -470,31 +470,30 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
CP_XML_ATTR(L"lang", w_val);
}
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_)
if (fo_color_)
{
CP_XML_NODE(L"a:solidFill")
{
CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val",fo_color_->get_hex_value());}
}
}
if (style_font_name_ || style_font_name_asian_ || style_font_name_complex_ || fo_font_family_)
{
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"");
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: w_font);
if (w_ascii.length()>0) CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface",w_ascii);}
if (style_font_name_asian_)
w_eastAsia = *style_font_name_asian_;
{
std::wstring w_eastAsia = *style_font_name_asian_;
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface",w_eastAsia);}
}
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());}
{
std::wstring w_cs = *style_font_name_complex_;
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface",w_cs);}
}
}
//else if (style_use_window_font_color_ && *style_use_window_font_color_)
......@@ -513,13 +512,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
// _rPr << L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"" << w_fill << "\" />";
//}
if (fo_color_)
{
CP_XML_NODE(L"a:solidFill")
{
CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val",fo_color_->get_hex_value());}
}
}
if (styles_context_.hlinkClick().length()>0)
{
CP_XML_NODE(L"a:hlinkClick")
......
#ifndef _CPDOCCORE_ODF_STYLEFAMILY_H_
#define _CPDOCCORE_ODF_STYLEFAMILY_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
#include <string>
......@@ -58,5 +53,3 @@ std::wostream & operator << (std::wostream & _Wostream, const style_family & _Va
APPLY_PARSE_XML_ATTRIBUTES(odf::style_family);
}
#endif
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