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

(1.0.0.158): ASCOfficeOdfFile


git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53350 954022d7-b5bf-4e40-9824-e11837661b57
parent 71b3e205
......@@ -358,10 +358,6 @@
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\version.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
......
......@@ -2,6 +2,6 @@
//1
//0
//0
//154
#define INTVER 1,0,0,154
#define STRVER "1,0,0,154\0"
//158
#define INTVER 1,0,0,158
#define STRVER "1,0,0,158\0"
......@@ -39,7 +39,7 @@ void pptx_serialize_text(std::wostream & strm, const std::vector<odf::_property>
{
CP_XML_NODE(L"a:p")//empty a:p
{
//CP_XML_NODE(L"a:endParaRPr");
CP_XML_NODE(L"a:endParaRPr");
}
}
}
......
......@@ -43,6 +43,7 @@ public:
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 ApplyListProperties(odf::paragraph_format_properties & propertiesOut, int Level);
void set_local_styles_container(odf::styles_container* local_styles_);//
......@@ -93,7 +94,7 @@ private:
boost::unordered_map<std::wstring, std::wstring> list_style_renames_;
void write_list_styles(std::wostream & strm);
void write_list_properties(std::wostream & strm);
//void write_list_properties(std::wostream & strm);
std::wstring find_list_rename(const std::wstring & ListStyleName);
std::wstring current_list_style();
///////////////////////////
......@@ -130,7 +131,7 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
}
//
//text_ << L"&#10;";
text_ << L"\n";
//text_ << L"\n";
}else
{
text_.str(std::wstring());
......@@ -146,7 +147,7 @@ void pptx_text_context::Impl::end_paragraph()
void pptx_text_context::Impl::start_span(const std::wstring & styleName)// () - 1
{
if (span_style_name_ !=styleName || in_span)
if ((span_style_name_ !=styleName && span_style_name_.length()>0) || in_span)
{
dump_run();
}
......@@ -213,6 +214,54 @@ void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name,odf::t
propertiesOut.apply_from(calc_text_properties_content(instances));
}
void pptx_text_context::Impl::ApplyListProperties(odf::paragraph_format_properties & propertiesOut, int Level)
{
if (Level <0)return;
if (list_style_stack_.empty())return;
odf::style_list_level_properties *list_properties= NULL;
odf::text_list_style * text_list_style = odf_context_.listStyleContainer().list_style_by_name(list_style_stack_.back());
if (text_list_style)
{
odf::office_element_ptr elm = text_list_style->get_content()[Level];
odf::office_element_ptr elm_list;
if (elm->get_type() == odf::typeTextListLevelStyleBullet)
{
odf::text_list_level_style_bullet* list_bullet = dynamic_cast<odf::text_list_level_style_bullet *>(elm.get());
if (list_bullet)elm_list = list_bullet->style_list_level_properties_;
}
if (elm->get_type() == odf::typeTextListLevelStyleNumber)
{
odf::text_list_level_style_number* list_number = dynamic_cast<odf::text_list_level_style_number *>(elm.get());
if (list_number)elm_list = list_number->style_list_level_properties_;
}
////////////////////
if (elm_list)
{
list_properties = dynamic_cast<odf::style_list_level_properties *>(elm_list.get());
}
elm->pptx_convert(pptx_context_);
}
if (list_properties)
{
propertiesOut.fo_text_indent_ = list_properties->text_min_label_width_;
if (list_properties->text_space_before_)
{
double spaceBeforeTwip = list_properties->text_space_before_->get_value_unit(odf::length::pt);
if (list_properties->text_min_label_width_)
{
spaceBeforeTwip += list_properties->text_min_label_width_->get_value_unit(odf::length::pt);
}
if (spaceBeforeTwip>0)
propertiesOut.fo_margin_left_ = odf::length(spaceBeforeTwip,odf::length::pt);
}
}
}
void pptx_text_context::Impl::ApplyParagraphProperties(std::wstring style_name,odf::paragraph_format_properties & propertiesOut, odf::style_family::type Type)
{
......@@ -251,10 +300,12 @@ 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 (paragraph_style_name_, paragraph_format_properties_,odf::style_family::Paragraph);
odf::paragraph_format_properties paragraph_properties_;
ApplyParagraphProperties (paragraph_style_name_, paragraph_properties_,odf::style_family::Paragraph);
ApplyListProperties (paragraph_properties_,level);//
paragraph_format_properties_.pptx_convert(pptx_context_);
paragraph_properties_.pptx_convert(pptx_context_);
const std::wstring & paragraphAttr = get_styles_context().paragraph_attr().str();
const std::wstring & paragraphNodes = get_styles_context().paragraph_nodes().str();
......@@ -264,27 +315,20 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
strm << L"<a:pPr ";
if (level>=0)
{
strm << L"lvl=\"" << level << L"\" ";
}
strm << paragraphAttr;
strm << ">";
strm << paragraphNodes;
odf::list_style_container & list_styles = odf_context_.listStyleContainer();
if (level >=0 )
{
if (!list_styles.empty() && level>=0)
{
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_);
}
strm << get_styles_context().list_style().str();
}
strm << get_styles_context().list_style().str();
}
strm << L"</a:pPr>";
}
......@@ -312,7 +356,7 @@ void pptx_text_context::Impl::write_rPr(std::wostream & strm)
strm << get_styles_context().text_style().str();
}
std::wstring pptx_text_context::Impl::dump_paragraph()
std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
{
dump_run();//last
......@@ -328,10 +372,9 @@ std::wstring pptx_text_context::Impl::dump_paragraph()
CP_XML_STREAM() << run_.str();
//CP_XML_NODE(L"a:endParaRPr");
//- /
//if (last)
//{
// CP_XML_ATTR(L"dirty", 0);
// CP_XML_NODE(L"a:endParaRPr");//- /
//}
}
}
......@@ -393,7 +436,7 @@ void pptx_text_context::Impl::start_object()
std::wstring pptx_text_context::Impl::end_object()
{
dump_paragraph();
dump_paragraph(/*true*/);
std::wstring & str_paragraph = paragraph_.str();
......@@ -418,6 +461,11 @@ std::wstring pptx_text_context::Impl::end_object()
}
void pptx_text_context::Impl::start_list_item(bool restart)
{
if (paragraphs_cout_ > 0 && restart)
{
dump_paragraph();
}
in_list_ = true;
first_element_list_item_ = true;
......@@ -437,7 +485,12 @@ void pptx_text_context::Impl::start_list_item(bool restart)
void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Continue)
{
if (!StyleName.empty())
if (paragraphs_cout_ > 0)
{
dump_paragraph();
}
if (!StyleName.empty())
{
std::wstring name = StyleName;
if (Continue)
......@@ -483,22 +536,22 @@ void pptx_text_context::Impl::end_list_item()
in_list_ = false;
}
void pptx_text_context::Impl::write_list_properties(std::wostream & strm)
{
if (!list_style_stack_.empty())
{
const int id = odf_context_.listStyleContainer().id_by_name( current_list_style() );
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"a:buAutoNum")
{
CP_XML_ATTR(L"type",L"arabicPeriod");
CP_XML_ATTR(L"startAt",id);//
}
}
first_element_list_item_ = false;
}
}
//void pptx_text_context::Impl::write_list_properties(std::wostream & strm)
//{
// if (!list_style_stack_.empty())
// {
// const int id = odf_context_.listStyleContainer().id_by_name( current_list_style() );
// CP_XML_WRITER(strm)
// {
// CP_XML_NODE(L"a:buAutoNum")
// {
// CP_XML_ATTR(L"type",L"arabicPeriod");
// CP_XML_ATTR(L"startAt",id);//
// }
// }
// first_element_list_item_ = false;
// }
//}
void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults style paragraph & lists
{
odf::list_style_container & list_styles = odf_context_.listStyleContainer();
......
......@@ -111,9 +111,6 @@ void xlsx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
dump_text();
}
//
//text_ << L"&#10;";
text_ << L"\n";
}else
{
text_.str(std::wstring());
......
......@@ -317,8 +317,6 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, styles_lite_con
{
fill.type = 0;
if (props.draw_fill_)fill.type = props.draw_fill_->get_type();
if (props.draw_opacity_) fill.opacity = props.draw_opacity_->get_value();
if (props.draw_opacity_name_)
{
......@@ -394,7 +392,7 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, styles_lite_con
fill.hatch->color_back_ref = props.draw_fill_color_->get_hex_value();
}
}
if (props.draw_fill_)fill.type = props.draw_fill_->get_type();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -79,20 +79,17 @@ std::wstring process_border(const border_style & borderStyle,
return res;
}
std::wstring process_margin(const _CP_OPT(length_or_percent) & margin, double Mul)
std::wstring process_margin(const _CP_OPT(length_or_percent) & margin, length::unit unit, double Mul)
{
if (margin)
{
if (margin->get_type() == length_or_percent::Length)
{
int val = (int)(0.5 + Mul * margin->get_length().get_value_unit(length::pt));
int val = (int)(0.5 + Mul * margin->get_length().get_value_unit(unit));
return boost::lexical_cast<std::wstring>( val );
}
else
{
#ifdef _DEBUG
_CP_LOG(info) << L"[pptx_convert] convert margin warning: invalid type (percent)\n";
#endif
}
}
return L"";
......@@ -126,25 +123,22 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
if (fo_margin_left_ || fo_margin_right_ || fo_text_indent_ )
{
// TODO auto indent
std::wstring w_left, w_right, w_hanging, w_firstLine;
std::wstring w_left, w_right, w_firstLine;
w_left = process_margin(fo_margin_left_, 20.0);
w_right = process_margin(fo_margin_right_, 20.0);
w_firstLine = process_margin(fo_text_indent_, 20.0);
w_left = process_margin(fo_margin_left_, length::emu, 1.);
w_right = process_margin(fo_margin_right_, length::emu, 1.);
w_firstLine = process_margin(fo_text_indent_,length::emu, 1.);
if (w_left.empty()) w_left = L"0";
if (w_right.empty()) w_right = L"0";
if (w_firstLine.empty()) w_hanging = L"0";
//if (w_left.empty()) w_left = L"0";
//if (w_right.empty()) w_right = L"0";
//if (w_firstLine.empty()) w_hanging = L"0";
_pPr << L"marL=\"" << w_left << "\" ";
_pPr << L"marR=\"" << w_right << "\" ";
if (!w_left.empty())
_pPr << L"marL=\"" << w_left << "\" ";
if (!w_right.empty())
_pPr << L"marR=\"" << w_right << "\" ";
if (!w_firstLine.empty())
_pPr << L"indent=\"" << w_firstLine << "\" ";
if (!w_hanging.empty())
_pPr << L"hangingPunct=\"" << w_hanging << "\" ";
}
if (style_vertical_align_)
{
......@@ -285,7 +279,7 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
}
if (fo_margin_top_ || fo_margin_)
{
std::wstring w_before = process_margin(fo_margin_top_, 1000.0);
std::wstring w_before = process_margin(fo_margin_top_, length::pt, 1000.0);
CP_XML_NODE(L"a:spcBef")
{
CP_XML_NODE(L"a:spcPct")
......@@ -296,7 +290,7 @@ void paragraph_format_properties::pptx_convert(oox::pptx_conversion_context & Co
}
if (fo_margin_bottom_ || fo_margin_)
{
std::wstring w_after = process_margin(fo_margin_bottom_, 1000.0);
std::wstring w_after = process_margin(fo_margin_bottom_, length::pt, 1000.0);
CP_XML_NODE(L"a:spcAft")
{
CP_XML_NODE(L"a:spcPct")
......
......@@ -947,12 +947,12 @@ void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_con
std::wstring w_orient = L"custom";
if (w && h)
{
double ratio = (double)w/(double)h;
if (abs(ratio - 16./9.)<0.01) w_orient = L"screen16x9";
if (abs(ratio - 4./3.)<0.01) w_orient = L"screen4x3";
}
//if (w && h)
//{
// double ratio = (double)w/(double)h;
// if (abs(ratio - 16./9.)<0.01) w_orient = L"screen16x9";
// if (abs(ratio - 4./3.)<0.01) w_orient = L"screen4x3";
//}
strm << L"<p:sldSz ";
if (!w_h.empty())
......
......@@ -395,6 +395,39 @@ void text_list_level_style_number::pptx_convert(oox::pptx_conversion_context & C
//int level = text_list_level_style_attr_.get_text_level();
std::wstring num_format;
if (text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ == L"1")
num_format= L"arabic";
else if (text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ == L"I")
num_format= L"romanUc";
else if (text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ == L"i")
num_format= L"romanLc";
else if (text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ == L"A")
num_format= L"alphaUc";
else if (text_list_level_style_number_attr_.common_num_format_attlist_.style_num_format_ == L"a")
num_format= L"alphaLc";
else
num_format= L"arabic";
if (text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_prefix_)
{
num_format += L"ParenBoth";
}
else
{
if (text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_suffix_)
{
if (*text_list_level_style_number_attr_.common_num_format_prefix_suffix_attlist_.style_num_suffix_ == L".")
num_format += L"Period";
else
num_format += L"ParenR";
}
else
num_format += L"Period";
}
CP_XML_WRITER(strm)
{
if (style_text_properties * textProperties = dynamic_cast<style_text_properties *>(style_text_properties_.get()))///
......@@ -406,7 +439,7 @@ void text_list_level_style_number::pptx_convert(oox::pptx_conversion_context & C
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");
CP_XML_ATTR(L"type", num_format);
}
}
}
......
......@@ -65,9 +65,11 @@ public:
private:
optional<style_ref>::Type text_style_name_;
common_num_format_attlist common_num_format_attlist_;
common_num_format_attlist common_num_format_attlist_;
common_num_format_prefix_suffix_attlist common_num_format_prefix_suffix_attlist_;
unsigned int text_display_levels_;
unsigned int text_display_levels_;
unsigned int text_start_value_;
friend class text_list_level_style_number;
......@@ -104,9 +106,11 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
const common_text_align & get_common_text_align() const { return common_text_align_; }
friend class text_list_level_style_number;
friend class text_list_level_style_bullet;
const common_text_align & get_common_text_align() const { return common_text_align_; }
private:
common_text_align common_text_align_;
optional<length>::Type text_space_before_;
optional<length>::Type text_min_label_width_;
......@@ -114,13 +118,12 @@ private:
optional<std::wstring>::Type style_font_name_;
optional<length>::Type fo_width_;
optional<length>::Type fo_height_;
common_vertical_rel_attlist common_vertical_rel_attlist_;
common_vertical_rel_attlist common_vertical_rel_attlist_;
common_vertical_pos_attlist common_vertical_pos_attlist_;
office_element_ptr style_list_level_label_alignment_;
friend class text_list_level_style_number;
friend class text_list_level_style_bullet;
};
......@@ -170,6 +173,8 @@ public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
office_element_ptr style_list_level_properties_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......@@ -179,7 +184,6 @@ private:
text_list_level_style_attr text_list_level_style_attr_;
text_list_level_style_number_attr text_list_level_style_number_attr_;
office_element_ptr style_list_level_properties_;
office_element_ptr style_text_properties_;
};
......@@ -211,11 +215,13 @@ public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextListLevelStyleNumber;
static const ElementType type = typeTextListLevelStyleBullet;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context) ;
void pptx_convert(oox::pptx_conversion_context & Context) ;
office_element_ptr style_list_level_properties_;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......@@ -225,7 +231,6 @@ private:
text_list_level_style_attr text_list_level_style_attr_;
text_list_level_style_bullet_attr text_list_level_style_bullet_attr_;
office_element_ptr style_list_level_properties_;
office_element_ptr style_text_properties_;
};
......
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