Commit ffefc7ba 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@52956 954022d7-b5bf-4e40-9824-e11837661b57
parent 4e5d17e4
......@@ -309,6 +309,10 @@
RelativePath=".\src\odf\style_paragraph_properties_docx.cpp"
>
</File>
<File
RelativePath=".\src\odf\style_paragraph_properties_pptx.cpp"
>
</File>
<File
RelativePath=".\src\odf\style_presentation.cpp"
>
......
......@@ -515,7 +515,7 @@ void docx_conversion_context::end_process_style_content()
void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & strm, const std::wstring & ParentId)
{
std::wstringstream & paragraph_style = get_styles_context().paragraph_style();
std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes();
if (!paragraph_style.str().empty() || !ParentId.empty())
{
CP_XML_WRITER(strm)
......
#ifndef _CPDOCCORE_DOCX_CONVERSIONCONTEXT_H_
#define _CPDOCCORE_DOCX_CONVERSIONCONTEXT_H_
#pragma once
#include "../odf/stylefamily.h"
#include "../odf/length.h"
#include <boost/unordered_map.hpp>
......@@ -565,5 +565,3 @@ private:
}
}
#endif
......@@ -26,8 +26,11 @@ void styles_context::start()
text_style_.str( std::wstring() );
text_style_.clear();
paragraph_style_.str( std::wstring() );
paragraph_style_.clear();
paragraph_nodes_.str( std::wstring() );
paragraph_nodes_.clear();
paragraph_attr_.str( std::wstring() );
paragraph_attr_.clear();
table_style_.str( std::wstring() );
table_style_.clear();
......@@ -44,9 +47,14 @@ std::wstringstream & styles_context::text_style()
return text_style_;
}
std::wstringstream & styles_context::paragraph_style()
std::wstringstream & styles_context::paragraph_nodes()
{
return paragraph_nodes_;
}
std::wstringstream & styles_context::paragraph_attr()
{
return paragraph_style_;
return paragraph_attr_;
}
std::wstringstream & styles_context::table_style()
......
......@@ -16,7 +16,8 @@ public:
void start();
std::wstringstream & text_style();
std::wstringstream & paragraph_style();
std::wstringstream & paragraph_nodes();
std::wstringstream & paragraph_attr();
std::wstringstream & table_style();
std::wstringstream & list_style();
......@@ -35,7 +36,8 @@ private:
std::wstringstream list_style_;
std::wstringstream text_style_;
std::wstringstream paragraph_style_;
std::wstringstream paragraph_nodes_;
std::wstringstream paragraph_attr_;
std::wstringstream table_style_;
};
......
......@@ -55,14 +55,14 @@ static const std::wstring _ooxDashStyle[]=
L"sysDashDotDot"
};
void oox_serialize_ln(std::wostream & strm, const std::vector<odf::_property> & properties)
void oox_serialize_ln(std::wostream & strm, const std::vector<odf::_property> & prop)
{
_CP_OPT(std::wstring) strVal;
_CP_OPT(int) iVal;
_CP_OPT(double) dVal;
odf::GetProperty(properties,L"stroke-color",strVal);
odf::GetProperty(properties,L"stroke",iVal);
odf::GetProperty(properties,L"stroke-width",dVal);
odf::GetProperty(prop,L"stroke-color",strVal);
odf::GetProperty(prop,L"stroke",iVal);
odf::GetProperty(prop,L"stroke-width",dVal);
if (!strVal && !iVal && !dVal)return;
CP_XML_WRITER(strm)
......@@ -93,7 +93,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf::_property> &
CP_XML_NODE(L"a:srgbClr")
{
CP_XML_ATTR(L"val",color);
odf::GetProperty(properties,L"stroke-opacity",strVal);
odf::GetProperty(prop,L"stroke-opacity",strVal);
if (strVal)CP_XML_NODE(L"a:alpha"){CP_XML_ATTR(L"val",strVal.get());}
}
......@@ -103,12 +103,12 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf::_property> &
{
CP_XML_NODE(L"a:prstDash"){CP_XML_ATTR(L"val",dash_style);}
}
odf::GetProperty(properties,L"marker-start",strVal);
odf::GetProperty(prop,L"marker-start",strVal);
if (strVal)
{
CP_XML_NODE(L"a:headEnd"){CP_XML_ATTR(L"type",strVal.get());}
}
odf::GetProperty(properties,L"marker-end",strVal);
odf::GetProperty(prop,L"marker-end",strVal);
if (strVal)
{
CP_XML_NODE(L"a:tailEnd"){CP_XML_ATTR(L"type",strVal.get());}
......@@ -116,10 +116,10 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf::_property> &
}
}
}
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf::_property> & properties)
void oox_serialize_aLst(std::wostream & strm, const std::vector<odf::_property> & prop)
{
_CP_OPT(int) iShapeIndex;
odf::GetProperty(properties,L"draw-type-index",iShapeIndex);
odf::GetProperty(prop,L"draw-type-index",iShapeIndex);
if (!iShapeIndex)return;
......@@ -128,7 +128,7 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf::_property>
CP_XML_NODE(L"a:avLst")
{
_CP_OPT(std::wstring) strVal;
if (odf::GetProperty(properties,L"draw-modifiers",strVal))
if (odf::GetProperty(prop,L"draw-modifiers",strVal))
{
std::vector< std::wstring > values;
boost::algorithm::split(values, strVal.get(), boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
......@@ -139,8 +139,8 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf::_property>
int i=1;
_CP_OPT(int) iMax,iMin;
odf::GetProperty(properties,L"draw-modifiers-min",iMin);
odf::GetProperty(properties,L"draw-modifiers-max",iMax);
odf::GetProperty(prop,L"draw-modifiers-min",iMin);
odf::GetProperty(prop,L"draw-modifiers-max",iMax);
values.resize(_OO_OOX_custom_shapes[*iShapeIndex].count_values);
BOOST_FOREACH(std::wstring & v, values)
......@@ -174,6 +174,37 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf::_property>
}
}
}
void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property> & prop)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:bodyPr")
{
_CP_OPT(int) iAlign;
odf::GetProperty(prop,L"textalign-horizontal",iAlign);
//if (iAlign) CP_XML_ATTR(L"name", val.name);
odf::GetProperty(prop,L"textalign-vertiacal",iAlign);
if (iAlign)
{
switch (iAlign.get())
{
case 0://Baseline,
CP_XML_ATTR(L"anchor", L"dist");break;
case 1://Top,
case 4://Auto,
CP_XML_ATTR(L"anchor", L"t");break;
case 2://Middle,
CP_XML_ATTR(L"anchor", L"ctr");break;
case 3://Bottom,
CP_XML_ATTR(L"anchor", L"b");break;
case 5://Justify
CP_XML_ATTR(L"anchor", L"just");break;
}
}
}
}
}
void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val)
{
_CP_OPT(std::wstring) strVal;
......
......@@ -65,7 +65,7 @@ struct _oox_drawing
friend void oox_serialize_ln (std::wostream & _Wostream, const std::vector<odf::_property> & val);
friend void oox_serialize_hlink (std::wostream & _Wostream, const std::vector<_hlink_desc> & val);
friend void oox_serialize_clipping(std::wostream & strm, _oox_drawing const & val);
friend void oox_serialize_bodyPr(std::wostream & strm, const std::vector<odf::_property> & val);
};
}
......
......@@ -32,7 +32,7 @@ void pptx_serialize_text(std::wostream & strm, const std::vector<odf::_property>
{
CP_XML_NODE(L"p:txBody")
{
CP_XML_NODE(L"a:bodyPr");
oox_serialize_bodyPr(CP_XML_STREAM(),properties);
if (strTextContent)
{
......
......@@ -39,6 +39,7 @@ public:
std::wstring end_drawing_content();
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);
void set_local_styles_container(odf::styles_container* local_styles_);//
......@@ -50,6 +51,7 @@ public:
void start_list_item(bool restart = false);
void end_list_item();
bool in_list_;
private:
styles_context styles_context_;
......@@ -59,7 +61,6 @@ private:
bool in_span;
bool in_paragraph;
bool in_list;
odf::styles_container * local_styles_ptr_;
......@@ -131,8 +132,6 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
}
styles_paragraph_ = styleName;
in_paragraph = true;
get_styles_context().start();
}
void pptx_text_context::Impl::end_paragraph()
......@@ -154,8 +153,10 @@ void pptx_text_context::Impl::start_span(const std::wstring & styleName)//
void pptx_text_context::Impl::end_span()
{
dump_run();
styles_span_ = L"";
in_span=false;
in_span = false;
}
std::wstring pptx_text_context::Impl::end_span2()
......@@ -175,50 +176,82 @@ void pptx_text_context::Impl::end_hyperlink(std::wstring hId)
{
hyperlink_hId = hId;
}
void pptx_text_context::Impl::ApplyTextProperties(std::wstring style,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;
if (local_styles_ptr_)
{
odf::style_instance * defaultStyle = local_styles_ptr_->style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
odf::style_instance* styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
}
else
{
odf::style_instance * defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
if (defaultStyle)instances.push_back(defaultStyle);
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
odf::style_instance* styleInst = odf_context_.styleContainer().style_by_name(style, Type,false/*process_headers_footers_*/);
if(styleInst)instances.push_back(styleInst);
styleInst = odf_context_.styleContainer().style_by_name(style, Type,false/*process_headers_footers_*/);
}
if (defaultStyle)instances.push_back(defaultStyle);
if(styleInst)instances.push_back(styleInst);
get_styles_context().start_process_style(styleInst);
propertiesOut.apply_from(calc_text_properties_content(instances));
}
void pptx_text_context::Impl::write_pPr(std::wostream & strm)
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style,odf::paragraph_format_properties & propertiesOut, odf::style_family::type Type)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:pPr")
std::vector<const odf::style_instance *> instances;
odf::style_instance* styleInst = NULL;
odf::style_instance * defaultStyle = NULL;
if (local_styles_ptr_)
{
if (!list_style_stack_.empty())
defaultStyle = local_styles_ptr_->style_default_by_type(Type);
styleInst = local_styles_ptr_->style_by_name(style, Type,false/*process_headers_footers_*/);
}
else
{
int level = list_style_stack_.size()-1;
CP_XML_ATTR(L"lvl",level);
//if (styles_paragraph_.length()>0)
defaultStyle = odf_context_.styleContainer().style_default_by_type(Type);
styleInst = odf_context_.styleContainer().style_by_name(style, Type,false/*process_headers_footers_*/);
}
if (defaultStyle)instances.push_back(defaultStyle);
if(styleInst)instances.push_back(styleInst);
get_styles_context().start_process_style(styleInst);
propertiesOut.apply_from(calc_paragraph_properties_content(instances));
}
void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{
get_styles_context().start();
//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")
// {
// }
//}
//write_list_properties(strm);
strm << L"<a:pPr ";
int level = list_style_stack_.size()-1;
if (level>=0)
strm << L"lvl=\"" << level << L"\" ";
odf::paragraph_format_properties paragraph_format_properties_;
ApplyParagraphProperties (styles_paragraph_, paragraph_format_properties_,odf::style_family::Paragraph);
paragraph_format_properties_.pptx_convert(pptx_context_);
strm << get_styles_context().paragraph_attr().str();
strm << ">";
strm << get_styles_context().paragraph_nodes().str();
odf::list_style_container & list_styles = odf_context_.listStyleContainer();
if (!list_styles.empty())
if (!list_styles.empty() && level>=0)
{
odf::text_list_style * s = list_styles.list_style_by_name(list_style_stack_.back());
if (s)
......@@ -228,21 +261,13 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
{
elm->pptx_convert(pptx_context_);
}
CP_XML_STREAM() << get_styles_context().list_style().str();
}
strm << get_styles_context().list_style().str();
}
}
//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();
strm << L"</a:pPr>";
// }
//}
}
}
}
void pptx_text_context::Impl::write_rPr(std::wostream & strm)
......@@ -260,65 +285,11 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
text_properties_.apply_from(text_properties_paragraph_);
text_properties_.apply_from(text_properties_span_);
get_styles_context().start();
text_properties_.pptx_convert(pptx_context_);
strm << get_styles_context().text_style().str();
//_CP_OPT(double) dValFontSize;
//if (text_properties_.fo_font_size_)
// dValFontSize=text_properties_.fo_font_size_->get_length().get_value();
//
//_CP_OPT(std::wstring) sValFontFamily;
//if (text_properties_.fo_font_family_)
// sValFontFamily=text_properties_.fo_font_family_.get();
////else if (text_properties_.style_font_name_) - font_face)decl !!!!
//// sValFontFamily=text_properties_.style_font_name_.get();
//_CP_OPT(std::wstring) sValFontColor;
//if (text_properties_.fo_color_)
// sValFontColor=text_properties_.fo_color_->get_hex_value();
//_CP_OPT(int) iValFontWeight;
//if (text_properties_.fo_font_weight_)
// iValFontWeight=text_properties_.fo_font_weight_->get_type();
//_CP_OPT(int) iValFontStyle;
//if(text_properties_.fo_font_style_)
// iValFontStyle=text_properties_.fo_font_style_->get_type();
//CP_XML_WRITER(strm)
// {
// //oox_serialize_style_text(strm,text_properties_);
// //oox_serialize_style_text(strm,odf::text_format_properties_content & properties);
// CP_XML_NODE(L"a:rPr")
// {
// // 3197
// if (dValFontSize) {CP_XML_ATTR(L"sz", (int)(dValFontSize.get()*100));}
// if ((iValFontStyle) && (iValFontStyle.get() >0)) {CP_XML_ATTR(L"i", "true");}
// if ((iValFontWeight) && (iValFontWeight.get() >0)) {CP_XML_ATTR(L"b", "true");}
// if (sValFontFamily) {CP_XML_ATTR(L"typeface", sValFontFamily.get());}
//
// if (sValFontColor){CP_XML_NODE(L"a:solidFill") {CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val", sValFontColor.get());}}}
// 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);
// }
// }
// }
//CP_XML_NODE(L"charset")
//{
// CP_XML_ATTR(L"val",204);
//}
//CP_XML_NODE(L"family")
//{
// CP_XML_ATTR(L"val",2);
//}
//}
}
std::wstring pptx_text_context::Impl::dump_paragraph()
{
......@@ -379,8 +350,6 @@ void pptx_text_context::Impl::start_drawing_content()
styles_paragraph_ = L"";
styles_span_ = L"";
get_styles_context().start();
}
std::wstring pptx_text_context::Impl::end_drawing_content()
......@@ -403,7 +372,7 @@ std::wstring pptx_text_context::Impl::end_drawing_content()
}
void pptx_text_context::Impl::start_list_item(bool restart)
{
in_list = true;
in_list_ = true;
first_element_list_item_ = true;
if (restart && !list_style_stack_.empty())
......@@ -438,7 +407,7 @@ void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Co
void pptx_text_context::Impl::end_list()
{
in_list = false;
in_list_ = false;
list_style_stack_.pop_back();// .. lstStyles -
}
......@@ -465,7 +434,7 @@ void pptx_text_context::Impl::end_list_item()
paragraphs_cout_--;
styles_paragraph_ = L"";
in_list = false;
in_list_ = false;
}
void pptx_text_context::Impl::write_list_properties(std::wostream & strm)
......@@ -495,9 +464,6 @@ void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults
if (list_styles.empty())
return;
get_styles_context().start();
get_styles_context().extern_node() = L"a:defRPr";
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:lstStyle");
......@@ -545,7 +511,10 @@ void pptx_text_context::add_text(const std::wstring & text)
{
return impl_->add_text(text);
}
bool pptx_text_context::in_list()
{
return impl_->in_list_;
}
void pptx_text_context::start_paragraph(const std::wstring & styleName)
{
return impl_->start_paragraph(styleName);
......
......@@ -46,7 +46,7 @@ public:
void start_hyperlink();
void end_hyperlink(std::wstring hId);
bool is_drawing_context();
bool in_list();
void start_list(const std::wstring & StyleName, bool Continue = false);
void end_list();
......
......@@ -184,13 +184,6 @@ public:
}
}
}
//_Wostream << L"<borders count=\"" << inst_array.size() << "\" >";
//BOOST_FOREACH(const xlsx_border & border, inst_array)
//{
// ::cpdoccore::oox::xlsx_serialize(_Wostream, border);
//}
//_Wostream << L"</borders>";
}
private:
......
......@@ -31,7 +31,7 @@ void xlsx_serialize_text(std::wostream & strm, const std::vector<odf::_property>
{
CP_XML_NODE(L"xdr:txBody")
{
CP_XML_NODE(L"a:bodyPr");
oox_serialize_bodyPr(CP_XML_STREAM(),properties);
CP_XML_NODE(L"a:lstStyle");
CP_XML_NODE(L"a:p")
{
......
......@@ -169,7 +169,8 @@ style_instance * styles_container::style_by_name(const std::wstring & Name, styl
if (res != map_.end())
{
return instances_[res->second].get();
int index = res->second;
return instances_[index].get();
}
else
return NULL;
......
#ifndef _CPDOCCORE_ODF_OFFCIE_ELEMENTS_H_
#define _CPDOCCORE_ODF_OFFCIE_ELEMENTS_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <vector>
......@@ -131,4 +126,3 @@ public:
}
}
#endif // #ifndef _CPDOCCORE_ODF_OFFCIE_ELEMENTS_H_
......@@ -22,6 +22,8 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A
CP_APPLY_ATTR(L"draw:marker-end", draw_marker_end_);
CP_APPLY_ATTR(L"draw:opacity", draw_opacity_);
CP_APPLY_ATTR(L"draw:wrap-influence-on-position", draw_wrap_influence_on_position_);
CP_APPLY_ATTR(L"draw:textarea-horizontal-align", draw_textarea_horizontal_align_);
CP_APPLY_ATTR(L"draw:textarea-vertical-align", draw_textarea_vertical_align_);
CP_APPLY_ATTR(L"svg:stroke-color", svg_stroke_color_);
CP_APPLY_ATTR(L"svg:stroke-width", svg_stroke_width_);
......@@ -65,22 +67,20 @@ void graphic_format_properties::add_attributes( const xml::attributes_wc_ptr & A
void graphic_format_properties::apply_to(std::vector<_property> & properties)
{
if (draw_fill_color_) properties.push_back(_property(L"fill-color", draw_fill_color_.get().get_hex_value() ));
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_.get().get_hex_value() ));
if (draw_fill_color_) properties.push_back(_property(L"fill-color", draw_fill_color_->get_hex_value() ));
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_->get_hex_value() ));
if (draw_fill_) properties.push_back(_property(L"fill", draw_fill_.get()));
if (draw_stroke_) properties.push_back(_property(L"stroke", draw_stroke_.get().get_type() ));
if (draw_stroke_) properties.push_back(_property(L"stroke", draw_stroke_->get_type() ));
if (draw_stroke_dash_) properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
if (svg_stroke_width_) properties.push_back(_property(L"stroke-width", svg_stroke_width_.get().get_length().get_value_unit(odf::length::pt) ));
if (draw_opacity_) properties.push_back(_property(L"opacity", draw_opacity_.get().get_percent().get_value()));
if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_.get().get_percent().get_value()));
if (draw_marker_start_) properties.push_back(_property(L"marker-start", draw_marker_start_.get().get() ));
if (draw_marker_end_) properties.push_back(_property(L"marker-end", draw_marker_end_.get().get() ));
if (svg_stroke_width_) properties.push_back(_property(L"stroke-width", svg_stroke_width_->get_length().get_value_unit(odf::length::pt) ));
if (draw_opacity_) properties.push_back(_property(L"opacity", draw_opacity_->get_percent().get_value()));
if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_->get_percent().get_value()));
if (draw_marker_start_) properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
if (draw_marker_end_) properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
if (draw_textarea_horizontal_align_)properties.push_back(_property(L"textalign-horizontal", draw_textarea_horizontal_align_->get_type() ));
if (draw_textarea_vertical_align_)properties.push_back(_property(L"textalign-vertical", draw_textarea_vertical_align_->get_type() ));
//if (draw_fill_gradient_name_)
//{
// //parsing
//}
}
void graphic_format_properties::apply_from(const graphic_format_properties & Other)
{
......@@ -91,6 +91,8 @@ void graphic_format_properties::apply_from(const graphic_format_properties & Oth
_CP_APPLY_PROP2(draw_marker_start_);
_CP_APPLY_PROP2(draw_marker_end_);
_CP_APPLY_PROP2(draw_opacity_);
_CP_APPLY_PROP2(draw_textarea_horizontal_align_);
_CP_APPLY_PROP2(draw_textarea_vertical_align_);
_CP_APPLY_PROP2(svg_stroke_color_);
_CP_APPLY_PROP2(svg_stroke_width_);
......@@ -148,9 +150,5 @@ void style_graphic_properties::add_child_element( xml::sax * Reader, const ::std
CP_NOT_APPLICABLE_ELM();
}
void style_graphic_properties::docx_convert(oox::docx_conversion_context & Context)
{
}
}
}
......@@ -22,6 +22,8 @@
#include "runthrough.h"
#include "linestyle.h"
#include "markerstyle.h"
#include "verticalalign.h"
namespace cpdoccore {
namespace odf {
......@@ -39,10 +41,8 @@ public:
// 1
common_draw_rel_size_attlist common_draw_rel_size_attlist_;
_CP_OPT(length_or_percent) fo_min_width_;
// 2
_CP_OPT(length_or_percent) fo_min_height_;
// 3
_CP_OPT(length_or_percent) fo_max_width_;
_CP_OPT(length_or_percent) fo_max_height_;
......@@ -60,85 +60,61 @@ public:
_CP_OPT(marker_style) draw_marker_end_;
_CP_OPT(marker_style) draw_marker_start_;
// 4
_CP_OPT(text_align) draw_textarea_horizontal_align_;
_CP_OPT(vertical_align) draw_textarea_vertical_align_;
common_horizontal_margin_attlist common_horizontal_margin_attlist_;
// 5
common_vertical_margin_attlist common_vertical_margin_attlist_;
// 6
common_margin_attlist common_margin_attlist_;
// 7
_CP_OPT(bool) style_print_content_;
// 8
_CP_OPT(std::wstring) style_protect_;
// 9
common_horizontal_pos_attlist common_horizontal_pos_attlist_;
// 10
common_horizontal_rel_attlist common_horizontal_rel_attlist_;
// 11
common_vertical_pos_attlist common_vertical_pos_attlist_;
// 12
common_vertical_rel_attlist common_vertical_rel_attlist_;
// 13
common_text_anchor_attlist common_text_anchor_attlist_;
// 14
common_border_attlist common_border_attlist_;
// 15
common_border_line_width_attlist common_border_line_width_attlist_;
// 16
common_padding_attlist common_padding_attlist_;
// 17
common_shadow_attlist common_shadow_attlist_;
// 18
common_background_color_attlist common_background_color_attlist_;
// 20
_CP_OPT(bool) style_editable_;
// 21
_CP_OPT(style_wrap) style_wrap_;
// 22
_CP_OPT(unsigned int) style_wrap_dynamic_treshold_;
// 23
_CP_OPT(integer_or_nolimit) style_number_wrapped_paragraphs_;
// 24
_CP_OPT(bool) style_wrap_contour_;
// 25
_CP_OPT(wrap_contour_mode) style_wrap_contour_mode_;
// 26
_CP_OPT(run_through) style_run_through_;
// 27
_CP_OPT(bool) style_flow_with_text_;
// 28
_CP_OPT(std::wstring) style_overflow_behavior_;
// 29
_CP_OPT(std::wstring) style_mirror_;
// 30
_CP_OPT(std::wstring) fo_clip_;
// 31
_CP_OPT(std::wstring) draw_wrap_influence_on_position_;
office_element_ptr style_background_image_;
......@@ -156,11 +132,9 @@ public:
static const ElementType type = typeStyleGraphicPropertis;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) ;
const graphic_format_properties & content() const { return graphic_format_properties_; }
//std::vector<_property> content_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......
......@@ -2,6 +2,10 @@
#include <iosfwd>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/CPOptional.h>
#include "office_elements.h"
#include "office_elements_create.h"
#include "linewidth.h"
#include "length.h"
......@@ -33,11 +37,19 @@
#include "office_binary_data.h"
#include "common_attlists.h"
#include "office_elements.h"
#include "office_elements_create.h"
#include "../docx/docx_conversion_context.h"
//#include "office_elements.h"
//#include "office_elements_create.h"
namespace cpdoccore { namespace odf {
namespace cpdoccore{
namespace oox{
class docx_conversion_context;
class pptx_conversion_context;
};
namespace odf {
/// \class style_tab_stop
class style_tab_stop : public office_element_impl<style_tab_stop>
......@@ -50,10 +62,9 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......@@ -90,10 +101,9 @@ public:
size_t size() const { return style_tab_stops_.size(); }
public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
private:
......@@ -130,8 +140,6 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
_CP_OPT(common_draw_data_attlist) common_draw_data_attlist_;
};
......@@ -181,6 +189,7 @@ public:
void apply_from(const paragraph_format_properties & Other);
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
// 15.5.1 fo:line-height
......@@ -362,8 +371,8 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
const paragraph_format_properties & content() const { return style_paragraph_properties_content_; }
......
This diff is collapsed.
#ifndef _CPDOCCORE_ODF_STYLE_TABLE_PROPERTIES_H_
#define _CPDOCCORE_ODF_STYLE_TABLE_PROPERTIES_H_
#pragma once
#include <iosfwd>
#include <cpdoccore/xml/attributes.h>
......@@ -322,5 +321,3 @@ CP_REGISTER_OFFICE_ELEMENT2(style_table_cell_properties);
}
}
#endif
......@@ -188,48 +188,6 @@ void text_format_properties_content::add_attributes( const xml::attributes_wc_pt
}
/*
[ ] w:rStyle Referenced Character Style
[+] w:rFonts Run Fonts
[+] w:b Bold
[+] w:bCs Complex Script Bold
[+] w:i Italics
[+] w:iCs Complex Script Italics
[+] w:caps Display All Characters As Capital Letters
[+] w:smallCaps Small Caps
[+] w:strike Single Strikethrough
[+] w:dstrike Double Strikethrough
[+] w:outline Display Character Outline
[+] w:shadow Shadow
[+] w:emboss Embossing
[+] w:imprint Imprinting
[ ] w:noProof Do Not Check Spelling or Grammar
[ ] w:snapToGrid Use Document Grid Settings For Inter-Character Spacing
[+] w:vanish Hidden Text
[ ] w:webHidden Web Hidden Text
[+] w:color Run Content Color
[+] w:spacing Character Spacing Adjustment
[+] w:w Expanded/Compressed Text
[ ] w:kern Font Kerning
[+] w:position Vertically Raised or Lowered Text
[+] w:sz Font Size
[+] w:szCs Complex Script Font Size
[+] w:highlight Text Highlighting
[+] w:u Underline
[*] w:effect Animated Text Effect
[ ] w:bdr Text Border
[ ] w:shd Run Shading
[ ] w:fitText Manual Run Width
[+] w:vertAlign Subscript/Superscript Text
[ ] w:rtl Right To Left Text
[ ] w:cs Use Complex Script Formatting on Run
[+] w:em Emphasis Mark
[+] w:lang Languages for Run Content
[ ] w:eastAsianLayout East Asian Typography Settings
[ ] w:specVanish Paragraph Mark Is Always Hidden
[ ] w:oMath Office Open XML Math
[ ] w:rPrChange
*/
int text_format_properties_content::process_font_size(const _CP_OPT(font_size) & FontSize, const style_instance * currnetStyle, bool Complex, double Mul)
{
......@@ -302,6 +260,88 @@ int text_format_properties_content::process_font_style(const optional<font_style
}
return 0;
}
void text_format_properties_content::pptx_convert_as_list(oox::pptx_conversion_context & Context)
{
styles_context & styles_context_ = Context.get_text_context().get_styles_context();
CP_XML_WRITER(styles_context_.text_style())
{
if (fo_color_)
{
CP_XML_NODE(L"a:buClr")
{
CP_XML_NODE(L"a:srgbClr"){CP_XML_ATTR(L"val",fo_color_->get_hex_value());}
}
}
if (fo_font_size_)
{
if(fo_font_size_->get_type() == font_size::Percent)
{
double fontSizePct = fo_font_size_->get_percent().get_value();
CP_XML_NODE(L"a:buSzPct")
{
CP_XML_ATTR(L"val", int(fontSizePct * 1000 + 0.5));//% * 1000
}
}
else
{
double fontSizePt = fo_font_size_->get_length().get_value();
CP_XML_NODE(L"a:buSzPts")
{
CP_XML_ATTR(L"val", (int)(fontSizePt * 100 + 0.5));//pt * 100
}
}
}
//const int fontStyle = process_font_style(fo_font_style_);
//if (fontStyle>0)CP_XML_ATTR(L"i",true);
//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_ || fo_font_family_)
{
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
if (w_font.length() < 1)
{
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: L"");
std::wstring w_eastAsia = (style_font_name_asian_ ? *style_font_name_asian_: L"");
std::wstring w_cs = (style_font_name_complex_ ? *style_font_name_complex_: L"");
fonts_container & fonts = Context.root()->odf_context().fontContainer();
font_instance * font = fonts.font_by_style_name(w_ascii);
if (font == NULL)font = fonts.font_by_style_name(w_eastAsia);
if (font == NULL)font = fonts.font_by_style_name(w_cs);
if (font)w_font = font->name();
}
if (w_font.length()>0)
{
CP_XML_NODE(L"a:buFont")
{
CP_XML_ATTR(L"typeface",w_font);
if ((style_font_charset_))
{
if ((*style_font_charset_!=L"x-symbol")) CP_XML_ATTR(L"charset",(*style_font_charset_));
//else CP_XML_ATTR(L"charset",0x02);
}
}
}
}
}
}
void text_format_properties_content::pptx_convert(oox::pptx_conversion_context & Context)
{
styles_context & styles_context_ = Context.get_text_context().get_styles_context();
......@@ -309,13 +349,14 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
{
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()) :
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()))
......@@ -324,7 +365,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
}
if (fontSizeVal > 0)
{
CP_XML_ATTR(L"sz", (int)(fontSizeVal * mul + 0.5));
CP_XML_ATTR(L"sz", (int)(fontSizeVal/2. * mul *100 + 0.5));//in pt *100
}
if (fo_font_variant_)
{
......@@ -333,16 +374,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
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
// 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;
......@@ -404,7 +436,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
}
}
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)
......@@ -416,7 +448,7 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
{
CP_XML_ATTR(L"strike", L"sngStrike");
}
else CP_XML_ATTR(L"strike",L"none");
else CP_XML_ATTR(L"strike",L"noStrike");
if ((fo_letter_spacing_) && (fo_letter_spacing_->get_type() != letter_spacing::Normal))
{
......@@ -435,7 +467,7 @@ 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_)
{
std::wstring w_eastAsia;
......@@ -463,13 +495,6 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
}
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\" />";
......@@ -494,13 +519,20 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
// CP_XML_ATTR(L"r:id", hyperlink_hId);
// }
//}
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());}
}
}
}
}
}
void text_format_properties_content::docx_convert(oox::docx_conversion_context & Context)
{
std::wostream & _pPr = Context.get_styles_context().paragraph_style();
std::wostream & _pPr = Context.get_styles_context().paragraph_nodes();
// to paragraph properties
if (fo_hyphenate_)
......
......@@ -47,6 +47,7 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
void pptx_convert_as_list(oox::pptx_conversion_context & Context);
void apply_from(const text_format_properties_content & Other);
void apply_to(std::vector<_property> & properties);
......@@ -57,7 +58,6 @@ private:
static double process_font_size_impl(const _CP_OPT(font_size) & FontSize, const style_instance * currnetStyle, bool Complex = false, double Mul = 1.0);
static int process_font_weight(const optional<font_weight>::Type & FontWeight);
static int process_font_style(const optional<font_style>::Type & FontStyle);
public:
_CP_OPT(std::wstring) r_style_;
......
......@@ -90,10 +90,8 @@ void text_list_level_style_number::add_child_element( xml::sax * Reader, const :
{
if (L"style" == Ns && L"list-level-properties" == Name)
CP_CREATE_ELEMENT(style_list_level_properties_);
else if (L"style" == Ns && L"style-text-properties" == Name)
CP_CREATE_ELEMENT(style_text_properties_);
else if (L"style" == Ns && L"text-properties" == Name)
CP_CREATE_ELEMENT(text_properties_);
CP_CREATE_ELEMENT(style_text_properties_);
else
{
CP_NOT_APPLICABLE_ELM();
......@@ -388,7 +386,29 @@ void text_list_level_style_number::pptx_convert(oox::pptx_conversion_context & C
if (text_list_level_style_attr_.get_text_level() - 1 >= 9)
return;
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() );
style_list_level_label_alignment * labelAlignment = listLevelProperties ?
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();
CP_XML_WRITER(strm)
{
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))///
// !!!
{
textProperties->content().pptx_convert_as_list(Context);
strm << Context.get_text_context().get_styles_context().text_style().str();
}
CP_XML_NODE(L"a:buAutoNum")//ms !! .. , - 2010 !!!
{
CP_XML_ATTR(L"startAt",text_list_level_style_number_attr_.text_start_value_);
CP_XML_ATTR(L"type",L"arabicParenBoth");
}
}
}
namespace
......@@ -509,7 +529,6 @@ void text_list_level_style_bullet::docx_convert(oox::docx_conversion_context & C
textProperties->content().docx_convert(Context);
Context.get_styles_context().docx_serialize_text_style(CP_XML_STREAM());
}
}
}
}
......@@ -522,33 +541,32 @@ void text_list_level_style_bullet::pptx_convert(oox::pptx_conversion_context & C
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() );
style_list_level_label_alignment * labelAlignment = listLevelProperties ?
dynamic_cast<style_list_level_label_alignment *>(listLevelProperties->style_list_level_label_alignment_.get()) : NULL;
// style_list_level_properties * listLevelProperties = dynamic_cast<style_list_level_properties *>( style_list_level_properties_.get() );
//
//style_list_level_label_alignment * labelAlignment = listLevelProperties ?
// 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();
//std::wstring nodeLevel = L"a:lvl" + boost::lexical_cast<std::wstring>(level) + L"pPr";
//int level = text_list_level_style_attr_.get_text_level();
CP_XML_WRITER(strm)
{
//CP_XML_NODE(nodeLevel)
{
//CP_XML_ATTR(L"lvl",level - 1);
//attr ident
//attr marL
style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get());
wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022');
const wchar_t bullet = text_list_level_style_bullet_attr_.text_bullet_char_.get_value_or(L'\x2022');
CP_XML_NODE(L"a:buChar")
if (textProperties)///
// !!!
{
CP_XML_ATTR(L"char",convert_bullet_char(bullet));
textProperties->content().pptx_convert_as_list(Context);
strm << Context.get_text_context().get_styles_context().text_style().str();
}
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))
CP_XML_NODE(L"a:buChar")
{
textProperties->content().pptx_convert(Context);
strm << Context.get_text_context().get_styles_context().text_style().str();
}
//if ((textProperties) && (textProperties->content().style_font_charset_))
//{
// if (textProperties->content().style_font_charset_.get() == L"x-xsymbol")bullet = bullet + 0xf000;
//}
CP_XML_ATTR(L"char",bullet/*convert_bullet_char(bullet)*/);
}
}
}
......
......@@ -181,7 +181,6 @@ private:
office_element_ptr style_list_level_properties_;
office_element_ptr style_text_properties_;
office_element_ptr text_properties_;
};
......
#ifndef _CPDOCCORE_ODF_TEXTALIGN_H_
#define _CPDOCCORE_ODF_TEXTALIGN_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
#include <string>
#include "odfattributes.h"
namespace cpdoccore { namespace odf {
namespace cpdoccore {
namespace odf {
// text_align horizontal_align . ..
class text_align
{
public:
......@@ -48,5 +45,3 @@ std::wostream & operator << (std::wostream & _Wostream, const text_align & _Val)
APPLY_PARSE_XML_ATTRIBUTES(odf::text_align);
}
#endif
#ifndef _CPDOCCORE_ODF_VERTICALALIGN_H_
#define _CPDOCCORE_ODF_VERTICALALIGN_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <iosfwd>
#include <string>
......@@ -34,7 +30,6 @@ public:
{
return type_;
};
static vertical_align parse(const std::wstring & Str);
private:
......@@ -50,4 +45,3 @@ APPLY_PARSE_XML_ATTRIBUTES(odf::vertical_align);
}
#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