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

(1.0.0.160): ASCOfficeOdfFile

Колонтитулы (footers & headers). Fields. Fields в колонтитулах (в слайдах, в разметке, мастер-слайдах).

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53435 954022d7-b5bf-4e40-9824-e11837661b57
parent 68da21f8
......@@ -2,6 +2,6 @@
//1
//0
//0
//158
#define INTVER 1,0,0,158
#define STRVER "1,0,0,158\0"
//160
#define INTVER 1,0,0,160
#define STRVER "1,0,0,160\0"
......@@ -1716,10 +1716,6 @@
RelativePath=".\src\odf\draw_page.h"
>
</File>
<File
RelativePath=".\src\odf\draw_page_pptx.cpp"
>
</File>
<File
RelativePath=".\src\odf\draw_shapes.cpp"
>
......
......@@ -271,7 +271,7 @@ void oox_serialize_shape(std::wostream & strm, _oox_drawing const & val)
void oox_serialize_xfrm(std::wostream & strm, _oox_drawing const & val, std::wstring name_space)
{
CP_XML_WRITER(strm)
CP_XML_WRITER(strm)
{
std::wstring xfrm = name_space + L":xfrm";
......
#include "precompiled_cpodf.h"
#include "pptx_conversion_context.h"
#include "measuredigits.h"
#include "pptx_package.h"
#include <cpdoccore/odf/odf_document.h>
......@@ -12,6 +11,7 @@
#include "../odf/calcs_styles.h"
#include "../odf/odfcontext.h"
#include "../odf/draw_frame.h"
#include "pptx_default_serializes.h"
......@@ -70,7 +70,28 @@ void pptx_conversion_context::process_layouts()
{
layout->pptx_convert(*this);
}
//íóæíî âûòàùèòü footers
odf::style_master_page * master =
root()->odf_context().pageLayoutContainer().master_page_by_name(layouts.content[layout_index].master_name);
if (master)
{
BOOST_FOREACH(odf::office_element_ptr elm, master->content_)
{
if (elm->get_type() == odf::typeDrawFrame)
{
odf::draw_frame* frame = dynamic_cast<odf::draw_frame *>(elm.get());
if ((frame) && (frame->common_presentation_attlist_.presentation_class_) &&
(frame->common_presentation_attlist_.presentation_class_->get_type()==odf::presentation_class::footer ||
frame->common_presentation_attlist_.presentation_class_->get_type()==odf::presentation_class::date_time ||
frame->common_presentation_attlist_.presentation_class_->get_type()==odf::presentation_class::header ||
frame->common_presentation_attlist_.presentation_class_->get_type()==odf::presentation_class::page_number))
{
elm->pptx_convert(*this);
}
}
}
}
end_layout();
}
}
......@@ -426,7 +447,10 @@ void pptx_conversion_context::end_layout()
void pptx_conversion_context::end_master()
{
get_slide_context().serialize_background(current_master().Background(),true);
get_slide_context().serialize(current_master().Data());
get_slide_context().serialize_HeaderFooter(current_master().DataExtra());
get_slide_context().dump_rels(current_master().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
......
......@@ -91,6 +91,7 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing const & val)
void pptx_serialize_shape(std::wostream & strm, _pptx_drawing const & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:sp")
......@@ -100,7 +101,7 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing const & val)
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"id", val.id);// val.rId
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"name", val.name);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
}
......@@ -114,19 +115,35 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing const & val)
}
CP_XML_NODE(L"p:nvPr")
{
if (val.place_holder_type_.length()>0)CP_XML_NODE(L"p:ph"){ CP_XML_ATTR(L"type",val.place_holder_type_);}
if (val.place_holder_type_.length()>0)
{
CP_XML_NODE(L"p:ph")
{
CP_XML_ATTR(L"type",val.place_holder_type_);
if (val.place_holder_idx_ > 0) CP_XML_ATTR(L"idx", val.place_holder_idx_);
if (val.place_holder_type_ == L"dt") CP_XML_ATTR(L"sz", L"half");
if (val.place_holder_type_ == L"ftr") CP_XML_ATTR(L"sz", L"quarter");
if (val.place_holder_type_ == L"sldNum") CP_XML_ATTR(L"sz", L"quarter");
}
}
}
}
CP_XML_NODE(L"p:spPr")
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
{
_CP_OPT(bool) bNoRect;
odf::GetProperty(val.additional,L"no_rect",bNoRect);
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(),val.additional);
}
if (!bNoRect)
{
oox_serialize_xfrm(CP_XML_STREAM(),val);
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(),val.additional);
}
}
pptx_serialize_text(CP_XML_STREAM(),val.additional);
}
}
} // CP_XML_WRITER
}
......
......@@ -14,7 +14,9 @@ namespace oox {
struct _pptx_drawing : _oox_drawing
{
_pptx_drawing(): place_holder_idx_(-1){}
std::wstring place_holder_type_;
int place_holder_idx_;
friend void pptx_serialize(std::wostream & _Wostream, _pptx_drawing const & val);
};
......
......@@ -169,6 +169,10 @@ std::wostream & pptx_xml_slideMaster::Data()
{
return slideMasterData_;
}
std::wostream & pptx_xml_slideMaster::DataExtra()
{
return slideMasterDataExtra_;
}
std::wostream & pptx_xml_slideMaster::Background()
{
return slideMasterBackground_;
......@@ -238,6 +242,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
}
count++;
}
CP_XML_STREAM() << slideMasterDataExtra_.str();
CP_XML_NODE(L"p:txStyles")
{
CP_XML_NODE(L"p:titleStyle");
......
......@@ -107,7 +107,8 @@ public:
std::wstring rId() const;
std::wostream & Data();
std::wostream & Background();
std::wostream & DataExtra();
std::wostream & Background();
rels & Rels();
void add_layout(int id, const std::wstring & rId);
......@@ -119,6 +120,7 @@ public:
private:
std::wstringstream slideMasterData_;
std::wstringstream slideMasterDataExtra_;
std::wstringstream slideMasterBackground_;
std::vector<std::wstring> layoutsId_;
......
......@@ -24,8 +24,10 @@ typedef _CP_PTR(pptx_drawings) pptx_drawings_ptr;
class pptx_slide_context::Impl
{
public:
Impl(const std::wstring & odfPacket) : pptx_drawings_(pptx_drawings::create()), mediaitems_(odfPacket),rId_(1),odfPacket_(odfPacket)
{}
Impl(const std::wstring & odfPacket) : mediaitems_(odfPacket),odfPacket_(odfPacket)
{
clear();
}
drawing_object_description object_description_;
......@@ -36,6 +38,8 @@ public:
_CP_OPT(_oox_fill) background_fill_;
bool header, footer, date_time, slideNum;
void add_drawing(_pptx_drawing const & d,
bool isInternal,
std::wstring const & rid,
......@@ -67,6 +71,11 @@ public:
tables_.clear();
background_fill_ = boost::none;
header=false;
footer=false;
date_time=false;
slideNum=false;
rId_ = 1;
......@@ -83,6 +92,7 @@ public:
return pptx_drawings_;
}
std::wstring odfPacket_;
private:
size_t rId_;
mediaitems mediaitems_;
......@@ -124,9 +134,17 @@ void pptx_slide_context::default_set()
void pptx_slide_context::set_placeHolder_type(std::wstring typeHolder)
{
if (typeHolder == L"ftr") impl_->footer= true;
if (typeHolder == L"hdr") impl_->header= true;
if (typeHolder == L"dt") impl_->date_time= true;
if (typeHolder == L"sldNum")impl_->slideNum= true;
impl_->object_description_.additional_.push_back(odf::_property(L"PlaceHolderType",typeHolder));
}
void pptx_slide_context::set_placeHolder_idx(int idx)
{
impl_->object_description_.additional_.push_back(odf::_property(L"PlaceHolderIdx",idx));
}
void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt)
{
_rect r = {width_pt,height_pt,x_pt,y_pt};
......@@ -232,6 +250,7 @@ void pptx_slide_context::start_table()
{
impl_->object_description_.type_ = 0; //frame
}
void pptx_slide_context::start_chart(std::wstring const & path)
{
impl_->object_description_.xlink_href_ = path;
......@@ -242,6 +261,7 @@ void pptx_slide_context::end_shape()
impl_->shapes_.push_back(impl_->object_description_);
default_set();
}
void pptx_slide_context::end_image()
{
impl_->images_.push_back(impl_->object_description_);
......@@ -361,10 +381,10 @@ void pptx_slide_context::process_common_properties(drawing_object_description &
{
if (pic.svg_rect_)
{
drawing.x = odf::length(pic.svg_rect_.get().x_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.y = odf::length(pic.svg_rect_.get().y_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.cx = odf::length(pic.svg_rect_.get().width_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.cy = odf::length(pic.svg_rect_.get().height_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.x = (int)(0.5 + odf::length(pic.svg_rect_.get().x_, odf::length::pt).get_value_unit(odf::length::emu));
drawing.y = (int)(0.5 + odf::length(pic.svg_rect_.get().y_, odf::length::pt).get_value_unit(odf::length::emu));
drawing.cx = (int)(0.5 + odf::length(pic.svg_rect_.get().width_, odf::length::pt).get_value_unit(odf::length::emu));
drawing.cy = (int)(0.5 + odf::length(pic.svg_rect_.get().height_, odf::length::pt).get_value_unit(odf::length::emu));
}
drawing.additional = pic.additional_;
......@@ -375,6 +395,7 @@ void pptx_slide_context::process_common_properties(drawing_object_description &
}
void pptx_slide_context::process_shapes()
{
int PlaceHolderIndex = 1;
BOOST_FOREACH(drawing_object_description & pic, impl_->shapes_)
{
_pptx_drawing drawing=_pptx_drawing();
......@@ -399,7 +420,14 @@ void pptx_slide_context::process_shapes()
////////////////////////////////////////////////////////////////
_CP_OPT(std::wstring) sPlaceHolderType;
GetProperty(pic.additional_,L"PlaceHolderType",sPlaceHolderType);
if (sPlaceHolderType)drawing.place_holder_type_ = *sPlaceHolderType;
if (sPlaceHolderType)
{
drawing.place_holder_type_ = *sPlaceHolderType;
_CP_OPT(int) iPlaceHolderIdx;
GetProperty(pic.additional_,L"PlaceHolderIdx",iPlaceHolderIdx);
if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx;
}
drawing.sub_type = pic.type_;
......@@ -443,6 +471,21 @@ void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
}
}
}
void pptx_slide_context::serialize_HeaderFooter(std::wostream & strm)
{
if (!impl_->header && !impl_->footer && !impl_->date_time && !impl_->slideNum)return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:hf")
{
if(impl_->footer) CP_XML_ATTR(L"ftr",0);
if(impl_->header) CP_XML_ATTR(L"hdr",0);
if(impl_->date_time) CP_XML_ATTR(L"dt",0);
if(impl_->slideNum) CP_XML_ATTR(L"sldNum",0);
}
}
}
void pptx_slide_context::serialize(std::wostream & strm)
{
int next_id = impl_->next_rId();
......
......@@ -34,7 +34,9 @@ public:
std::vector<odf::_property> & get_properties();
void set_clipping(std::wstring & str );
void set_fill(_oox_fill & fill);
void set_placeHolder_type(std::wstring typeHolder);
void set_placeHolder_idx(int idx);
std::wstring add_hyperlink(std::wstring const & ref, bool object);
......@@ -53,6 +55,7 @@ public:
bool empty() const;
//////////////////////////////////////////////////////////////////////////////////////////////
void serialize(std::wostream & strm);
void serialize_HeaderFooter(std::wostream & strm);
void serialize_background(std::wostream & strm, bool always=false);
void dump_rels(rels & Rels);
......
......@@ -55,6 +55,9 @@ public:
void start_list_item(bool restart = false);
void end_list_item();
void start_field(field_type type, const std::wstring & styleName);
void end_field();
bool in_list_;
private:
......@@ -70,9 +73,11 @@ private:
void write_rPr(std::wostream & strm);
void write_pPr(std::wostream & strm);
void write_t(std::wostream & strm);
std::wstring dump_paragraph();
void dump_run();
void dump_field();
size_t paragraphs_cout_; //???? ?
......@@ -99,13 +104,16 @@ private:
std::wstring current_list_style();
///////////////////////////
field_type field_type_;
std::wstringstream field_value_;
pptx_conversion_context & pptx_context_;
};
pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversion_context & pptx_contxt_):
odf_context_(odf_contxt_), pptx_context_(pptx_contxt_),
paragraphs_cout_(0),in_paragraph(false),in_span(false)
paragraphs_cout_(0),in_paragraph(false),in_span(false),field_type_(none)
{
new_list_style_number_=0;
local_styles_ptr_ = NULL;
......@@ -113,7 +121,10 @@ pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversi
void pptx_text_context::Impl::add_text(const std::wstring & text)
{
text_ << text;
if (field_type_)
field_value_ << text;
else
text_ << text;
}
void pptx_text_context::Impl::set_local_styles_container(odf::styles_container * local_styles_)
......@@ -135,6 +146,7 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
}else
{
text_.str(std::wstring());
field_value_.str(std::wstring());
}
paragraph_style_name_ = styleName;
in_paragraph = true;
......@@ -333,6 +345,10 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
strm << L"</a:pPr>";
}
void pptx_text_context::Impl::write_t(std::wostream & strm)
{
}
void pptx_text_context::Impl::write_rPr(std::wostream & strm)
{
if (paragraph_style_name_.length()<1 && span_style_name_.length()<1 && !(hyperlink_hId.length()>0) && base_style_name_.length()<1)return;
......@@ -382,28 +398,75 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
}
return paragraph_.str();
}
void pptx_text_context::Impl::dump_field()
{
if (field_type_ == none) return;
CP_XML_WRITER(run_)
{
CP_XML_NODE(L"a:fld")
{
switch (field_type_)
{
case page_number:
{
CP_XML_ATTR(L"type", L"slidenum");
CP_XML_ATTR(L"id", L"{5CC2A059-B141-45A7-B910-B096D6D06820}");
}
break;
case date:
{
CP_XML_ATTR(L"type", L"datetime1");
CP_XML_ATTR(L"id", L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}");
}
break;
case time:
{
CP_XML_ATTR(L"type", L"datetime11");
CP_XML_ATTR(L"id", L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}");
}
break;
}
//CP_XML_NODE(L"a:r")
{
const std::wstring content = xml::utils::replace_text_to_xml(field_value_.str());
//write_rPr(CP_XML_STREAM());
CP_XML_NODE(L"a:t")
{
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
}
}
field_value_.str(std::wstring());
field_type_ = none;
}
void pptx_text_context::Impl::dump_run()
{
dump_field();
const std::wstring content = xml::utils::replace_text_to_xml(text_.str());
if (content.length()<1 && span_style_name_.length()<1) return ;
if (content.length() <1 && span_style_name_.length()<1) return ;
CP_XML_WRITER(run_)
{
if (!content.empty())
{
if (content.length()>0)
{
CP_XML_NODE(L"a:r")
{
write_rPr(CP_XML_STREAM());
write_rPr(CP_XML_STREAM());
CP_XML_NODE(L"a:t")
{
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
}
text_.str(std::wstring());
text_.str(std::wstring());
}
}
hyperlink_hId =L"";
......@@ -428,6 +491,7 @@ void pptx_text_context::Impl::start_object()
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
field_value_.str(std::wstring());
paragraph_style_name_ = L"";
span_style_name_ = L"";
......@@ -453,6 +517,7 @@ std::wstring pptx_text_context::Impl::end_object()
run_.str(std::wstring());
paragraph_.str(std::wstring());
text_.str(std::wstring());
field_value_.str(std::wstring());
paragraph_style_name_ = L"";
span_style_name_=L"";
......@@ -536,22 +601,17 @@ 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::start_field(field_type type, const std::wstring & styleName)
{
field_type_ = type;
}
void pptx_text_context::Impl::end_field()
{
dump_run();
field_type_ = none;
}
void pptx_text_context::Impl::write_list_styles(std::wostream & strm)//defaults style paragraph & lists
{
odf::list_style_container & list_styles = odf_context_.listStyleContainer();
......@@ -681,14 +741,13 @@ styles_context & pptx_text_context::get_styles_context()
{
return impl_->get_styles_context() ;
}
void pptx_text_context::start_field(int type, const std::wstring & styleName)
void pptx_text_context::start_field(field_type type, const std::wstring & styleName)
{
//todooo
//1 - datetime, 2 -pagecount, 3 - pagenumber - <a:fld><a:t></a:fld>
impl_->start_field(type, styleName);
}
void pptx_text_context::end_field()
{
impl_->end_field();
}
}
......
......@@ -21,8 +21,18 @@ namespace oox {
class pptx_conversion_context;
enum field_type
{
none,
page_number,
date,
time
};
class pptx_text_context: boost::noncopyable
{
public:
pptx_text_context(odf::odf_read_context & odf_context_, pptx_conversion_context & pptx_contxt_);
~pptx_text_context();
......@@ -50,7 +60,7 @@ public:
void start_hyperlink();
void end_hyperlink(std::wstring hId);
void start_field(int type, const std::wstring & styleName);//1 - datetime, 2 -pagecount, 3 - pagenumber - <a:fld><a:t></a:fld>
void start_field(field_type type, const std::wstring & styleName);//1 - datetime, 2 -pagecount, 3 - pagenumber - <a:fld><a:t></a:fld>
void end_field();
bool in_list();
......
......@@ -372,10 +372,10 @@ void xlsx_drawing_context::process_common_properties(drawing_object_description
if (pic.svg_rect_)
{
drawing.x = odf::length(pic.svg_rect_.get().x_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.y = odf::length(pic.svg_rect_.get().y_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.cx = odf::length(pic.svg_rect_.get().width_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.cy = odf::length(pic.svg_rect_.get().height_, odf::length::pt).get_value_unit(odf::length::emu);
drawing.x = (int)(0.5 + odf::length(pic.svg_rect_.get().x_, odf::length::pt).get_value_unit(odf::length::emu));
drawing.y = (int)(0.5 + odf::length(pic.svg_rect_.get().y_, odf::length::pt).get_value_unit(odf::length::emu));
drawing.cx = (int)(0.5 + odf::length(pic.svg_rect_.get().width_, odf::length::pt).get_value_unit(odf::length::emu));
drawing.cy = (int)(0.5 + odf::length(pic.svg_rect_.get().height_, odf::length::pt).get_value_unit(odf::length::emu));
}
drawing.additional=pic.additional_;
......
......@@ -458,9 +458,9 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
font_name = L"Arial";
if ((textFormatProperties.fo_font_size_) && (textFormatProperties.fo_font_size_->get_type() == odf::font_size::Length))
font_size = textFormatProperties.fo_font_size_->get_length().get_value_unit(odf::length::pt);
font_size = (int)(0.5 + textFormatProperties.fo_font_size_->get_length().get_value_unit(odf::length::pt));
else
font_size =10.;
font_size =10;
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, getDefaultDpi());
}
......
......@@ -189,7 +189,7 @@ void Compute_HatchFill(draw_hatch * image_style,oox::oox_hatch_fill_ptr fill)
int style =0;
if (image_style->draw_style_)style = image_style->draw_style_->get_type();
int angle = *image_style->draw_rotation_/10.;
int angle = (int)(0.5 + *image_style->draw_rotation_/10.);
if (image_style->draw_color_)fill->color_ref = image_style->draw_color_->get_hex_value();
......
......@@ -35,7 +35,7 @@ void draw_image_attlist::add_attributes( const xml::attributes_wc_ptr & Attribut
/// draw-frame-attlist
void draw_frame_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"draw:copy-of", draw_copy_of_);
CP_APPLY_ATTR(L"draw:copy-of", draw_copy_of_);
}
/// draw-gframe-attlist
void draw_g_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
......@@ -76,10 +76,6 @@ void draw_image::add_child_element( xml::sax * Reader, const ::std::wstring & Ns
}
}
void draw_image::add_text(const std::wstring & Text)
{
}
// draw:chart
////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_chart::ns = L"draw";
......@@ -108,9 +104,7 @@ void draw_chart::add_child_element( xml::sax * Reader, const ::std::wstring & Ns
//}
}
void draw_chart::add_text(const std::wstring & Text)
{
}
// draw:g
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_g::ns = L"draw";
......@@ -140,6 +134,8 @@ const wchar_t * draw_frame::name = L"frame";
void draw_frame::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
idx_in_owner = -1;
common_presentation_attlist_.add_attributes(Attributes);
common_draw_attlists_.shape_with_text_and_styles_.add_attributes(Attributes);
common_draw_attlists_.position_.add_attributes(Attributes);
......@@ -187,10 +183,6 @@ void draw_frame::add_child_element( xml::sax * Reader, const ::std::wstring & Ns
}
}
void draw_frame::add_text(const std::wstring & Text)
{
}
///////////////////////
......
......@@ -42,7 +42,6 @@ public:
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
draw_image_attlist draw_image_attlist_;
......@@ -85,7 +84,6 @@ public:
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
private:
draw_chart_attlist draw_chart_attlist_;
......@@ -130,9 +128,9 @@ public:
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
public:
int idx_in_owner ;
common_presentation_attlist common_presentation_attlist_;
union_common_draw_attlists common_draw_attlists_;
......
......@@ -860,10 +860,10 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, const unio
_CP_OPT(double) dVal;
GetProperty(drawing.additional,L"svg:scale_x",dVal);
if (dVal)drawing.cx*=dVal.get();
if (dVal)drawing.cx = (int)(0.5 + drawing.cx * dVal.get());
GetProperty(drawing.additional,L"svg:scale_y",dVal);
if (dVal)drawing.cy*=dVal.get();
if (dVal)drawing.cy = (int)(0.5 + drawing.cy * dVal.get());
GetProperty(drawing.additional,L"svg:translate_x",dVal);
if (dVal)drawing.x+=get_value_emu(dVal.get());
......
......@@ -140,6 +140,8 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
if (common_presentation_attlist_.presentation_class_)
{
Context.get_slide_context().set_placeHolder_type(common_presentation_attlist_.presentation_class_->get_type_ms());
if (idx_in_owner >=0)
Context.get_slide_context().set_placeHolder_idx(idx_in_owner);
}
if (office_event_listeners_)office_event_listeners_->pptx_convert(Context);
......
......@@ -6,10 +6,17 @@
#include <cpdoccore/xml/serialize.h>
#include <cpdoccore/xml/attributes.h>
#include <boost/lexical_cast.hpp>
#include "serialize_elements.h"
#include "odfcontext.h"
#include <cpdoccore/odf/odf_document.h>
#include "calcs_styles.h"
#include "draw_common.h"
#include <cpdoccore/xml/simple_xml_writer.h>
namespace cpdoccore {
namespace odf {
......@@ -27,7 +34,6 @@ void draw_page_attr::add_attributes( const xml::attributes_wc_ptr & Attributes )
}
// office:annotation
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_page::ns = L"draw";
const wchar_t * draw_page::name = L"page";
......@@ -42,6 +48,121 @@ void draw_page::add_attributes( const xml::attributes_wc_ptr & Attributes )
draw_page_attr_.add_attributes(Attributes);
}
void draw_page::pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, presentation_class::type PresentationClass)
{
office_element_ptr elm = Context.root()->odf_context().drawStyles().find_by_style_name(styleName);
if (!elm)return;
int index=0;
const std::wstring masterName = draw_page_attr_.master_page_name_.get_value_or(L"");
style_master_page * master = Context.root()->odf_context().pageLayoutContainer().master_page_by_name(masterName);
if (master)
index = master->find_placeHolderIndex(PresentationClass);
Context.get_slide_context().start_shape(1);
Context.get_slide_context().set_placeHolder_type(presentation_class(PresentationClass).get_type_ms());
Context.get_slide_context().set_placeHolder_idx(index);
Context.get_text_context().start_object();
elm->pptx_convert(Context);
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
{
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
}
Context.get_slide_context().set_property(_property(L"no_rect",true));
Context.get_slide_context().end_shape();
}
void draw_page::pptx_convert(oox::pptx_conversion_context & Context)
{
const std::wstring pageStyleName = draw_page_attr_.draw_style_name_.get_value_or(L"");
const std::wstring pageName = draw_page_attr_.draw_name_.get_value_or(L"");
const std::wstring layoutName = draw_page_attr_.page_layout_name_.get_value_or(L"");
const std::wstring masterName = draw_page_attr_.master_page_name_.get_value_or(L"");
_CP_LOG(info) << L"[info][xlsx] process page(slide) \"" << pageName /*L"" */<< L"\"" << std::endl;
Context.start_page(pageName, pageStyleName, layoutName,masterName);
if (draw_page_attr_.draw_style_name_)
{
style_instance * style_inst = Context.root()->odf_context().styleContainer().style_by_name(pageStyleName,style_family::DrawingPage,false);
if ((style_inst) && (style_inst->content()))
{
const style_drawing_page_properties * properties = style_inst->content()->get_style_drawing_page_properties();
if (properties)
{
oox::_oox_fill fill;
Compute_GraphicFill(properties->content().common_draw_fill_attlist_, Context.root()->odf_context().drawStyles() ,fill);
Context.get_slide_context().add_background(fill);
}
}
}
BOOST_FOREACH(const office_element_ptr& elm, content_)
{
elm->pptx_convert(Context);
}
if (draw_page_attr_.use_footer_name_)//from master_page
{
std::wstring name = L"footer:" + *draw_page_attr_.use_footer_name_;
pptx_convert_placeHolder(Context, name, presentation_class::footer);
}
if (draw_page_attr_.use_date_time_name_)//from master_page
{
std::wstring name = L"datetime:" + *draw_page_attr_.use_date_time_name_;
pptx_convert_placeHolder(Context, name, presentation_class::date_time);
}
Context.end_page();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * presentation_footer_decl::ns = L"presentation";
const wchar_t * presentation_footer_decl::name = L"footer-decl";
void presentation_footer_decl::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"presentation:name", presentation_name_);
}
void presentation_footer_decl::add_text(const std::wstring & text)
{
text_ = text;
}
void presentation_footer_decl::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().add_text(text_);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * presentation_date_time_decl::ns = L"presentation";
const wchar_t * presentation_date_time_decl::name = L"date-time-decl";
void presentation_date_time_decl::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"presentation:name", presentation_name_);
CP_APPLY_ATTR(L"presentation:source", presentation_source_);
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
}
void presentation_date_time_decl::add_text(const std::wstring & text)
{
text_ = text;
}
void presentation_date_time_decl::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().add_text(text_);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
......@@ -6,8 +6,8 @@
#include "office_elements.h"
#include "office_elements_create.h"
#include "presentationclass.h"
#include "style_ref.h"
namespace cpdoccore {
namespace odf {
......@@ -29,7 +29,6 @@ public:
_CP_OPT(std::wstring) use_date_time_name_;
};
/// \class draw_page
/// \brief draw:page
class draw_page : public office_element_impl<draw_page>
{
public:
......@@ -42,6 +41,8 @@ public:
virtual void pptx_convert(oox::pptx_conversion_context & Context);
private:
void pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, presentation_class::type PresentationClass);
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
......@@ -51,6 +52,56 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(draw_page);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//presentation:footer-decl
class presentation_footer_decl : public office_element_impl<presentation_footer_decl>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationFooterDecl;
CPDOCCORE_DEFINE_VISITABLE();
virtual void pptx_convert(oox::pptx_conversion_context & Context);
_CP_OPT(std::wstring) presentation_name_;
std::wstring text_;
private:
virtual void add_text(const std::wstring & Text);
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_footer_decl);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//presentation:date-time-decl
class presentation_date_time_decl : public office_element_impl<presentation_date_time_decl>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationDateTimeDecl;
CPDOCCORE_DEFINE_VISITABLE();
_CP_OPT(std::wstring) presentation_name_;
_CP_OPT(std::wstring) presentation_source_;
_CP_OPT(std::wstring) style_data_style_name_;
std::wstring text_;
virtual void pptx_convert(oox::pptx_conversion_context & Context);
private:
virtual void add_text(const std::wstring & Text);
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_date_time_decl);
}
}
......@@ -39,7 +39,7 @@ void office_body::add_attributes( const xml::attributes_wc_ptr & Attributes )
void office_body::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
CP_CREATE_ELEMENT(content_);
}
void office_body::add_text(const std::wstring & Text)
......
......@@ -45,7 +45,6 @@ private:
public:
office_element_ptr content_;
};
CP_REGISTER_OFFICE_ELEMENT2(office_body);
......
......@@ -38,6 +38,9 @@ enum ElementType
typeTextSequence,
typeTextSheetName,
typePresentationFooter,
typePresentationDateTime,
typeDcCreator,
typeDcDate,
......@@ -193,6 +196,8 @@ enum ElementType
typeDrawEquation,
typeDrawPage,
typePresentationFooterDecl,
typePresentationDateTimeDecl,
typeStyleGraphicPropertis,
typeStyleDrawGradient,
......
#include "precompiled_cpodf.h"
#include "office_presentation.h"
#include "draw_page.h"
#include <boost/foreach.hpp>
......@@ -8,6 +9,9 @@
#include <cpdoccore/xml/serialize.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/odf/odf_document.h>
#include "odfcontext.h"
#include "serialize_elements.h"
namespace cpdoccore {
......@@ -23,9 +27,9 @@ void office_presentation::add_child_element( xml::sax * Reader, const ::std::wst
if CP_CHECK_NAME(L"draw", L"page")
CP_CREATE_ELEMENT(pages_);
else if CP_CHECK_NAME(L"presentation", L"footer-decl")
CP_CREATE_ELEMENT(footer_decl_);
CP_CREATE_ELEMENT(footer_decls_);
else if CP_CHECK_NAME(L"presentation", L"date-time-decl")
CP_CREATE_ELEMENT(date_time_decl_);
CP_CREATE_ELEMENT(date_time_decls_);
}
......@@ -65,6 +69,27 @@ void office_presentation::pptx_convert(oox::pptx_conversion_context & Context)
Context.start_office_presentation();
_CP_LOG(info) << L"[info][pptx] process pages(" << pages_.size() << L" elmements)" << std::endl;
BOOST_FOREACH(const office_element_ptr & elm, footer_decls_)
{
presentation_footer_decl * style = dynamic_cast<presentation_footer_decl *>(elm.get());
if (!style)
continue;
std::wstring style_name_ = L"footer:" + style->presentation_name_.get_value_or(L"");
Context.root()->odf_context().drawStyles().add(style_name_, elm);
}
BOOST_FOREACH(const office_element_ptr & elm, date_time_decls_)
{
presentation_date_time_decl * style = dynamic_cast<presentation_date_time_decl *>(elm.get());
if (!style)
continue;
std::wstring style_name_ = L"datetime:" + style->presentation_name_.get_value_or(L"");
Context.root()->odf_context().drawStyles().add(style_name_, elm);
}
BOOST_FOREACH(const office_element_ptr & elm, pages_)
{
elm->pptx_convert(Context);
......
......@@ -32,8 +32,8 @@ private:
public:
office_element_ptr_array date_time_decl_;
office_element_ptr_array footer_decl_;
office_element_ptr_array date_time_decls_;
office_element_ptr_array footer_decls_;
office_element_ptr_array pages_;
......
......@@ -553,7 +553,10 @@ void note::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, cons
void note::add_text(const std::wstring & Text)
{
}
void note::pptx_convert(oox::pptx_conversion_context & Context)
{
// presentation:notes
}
void note::docx_convert(oox::docx_conversion_context & Context)
{
bool addNewRun = false;
......@@ -739,7 +742,11 @@ const wchar_t * text_page_number::name = L"page-number";
void text_page_number::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
// TODO
//text:select-page
//common-field-num-format-attlist"/> ---- //style:num-format="1"/>
//common-field-fixed-attlist"/>
//text:page-adjust="1"
}
void text_page_number::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
......@@ -769,7 +776,7 @@ void text_page_number::docx_convert(oox::docx_conversion_context & Context)
}
void text_page_number::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_field(3, L"");
Context.get_text_context().start_field(oox::page_number, L"");
BOOST_FOREACH(const office_element_ptr & elm, text_)
{
elm->pptx_convert(Context);
......@@ -820,13 +827,11 @@ void text_page_count::docx_convert(oox::docx_conversion_context & Context)
}
void text_page_count::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_field(2, L"");
// ms -
BOOST_FOREACH(const office_element_ptr & elm, text_)
{
elm->pptx_convert(Context);
}
Context.get_text_context().end_field();
}
// text:date
......@@ -869,7 +874,7 @@ void text_date::docx_convert(oox::docx_conversion_context & Context)
}
void text_date::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_field(1,style_data_style_name_.get_value_or(L""));
Context.get_text_context().start_field(oox::date,style_data_style_name_.get_value_or(L""));
BOOST_FOREACH(const office_element_ptr & elm, text_)
{
elm->pptx_convert(Context);
......@@ -917,7 +922,7 @@ void text_time::docx_convert(oox::docx_conversion_context & Context)
}
void text_time::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_field(1, style_data_style_name_.get_value_or(L""));
Context.get_text_context().start_field(oox::time, style_data_style_name_.get_value_or(L""));
BOOST_FOREACH(const office_element_ptr & elm, text_)
{
elm->pptx_convert(Context);
......@@ -961,7 +966,15 @@ void text_file_name::docx_convert(oox::docx_conversion_context & Context)
}
Context.finish_run();
}
void text_file_name::pptx_convert(oox::pptx_conversion_context & Context)
{
//Context.get_text_context().start_field(oox::file_name, style_data_style_name_.get_value_or(L""));
BOOST_FOREACH(const office_element_ptr & elm, text_)
{
elm->pptx_convert(Context);
}
Context.get_text_context().end_field();
}
// text:sequence
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * sequence::ns = L"text";
......@@ -995,6 +1008,13 @@ void sequence::docx_convert(oox::docx_conversion_context & Context)
elm->docx_convert(Context);
}
}
void sequence::pptx_convert(oox::pptx_conversion_context & Context)
{
BOOST_FOREACH(const office_element_ptr & elm, text_)
{
elm->pptx_convert(Context);
}
}
// text:sequesheet-namence
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -1015,8 +1035,23 @@ void sheet_name::add_text(const std::wstring & Text)
office_element_ptr elm = text::create(Text) ;
text_.push_back( elm );
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// presentation:footer
const wchar_t * presentation_footer::ns = L"presentation";
const wchar_t * presentation_footer::name = L"footer";
void presentation_footer::pptx_convert(oox::pptx_conversion_context & Context)
{
//Context.get_slide_context.set_footer_enabled();
}
const wchar_t * presentation_date_time::ns = L"presentation";
const wchar_t * presentation_date_time::name = L"date-time";
void presentation_date_time::pptx_convert(oox::pptx_conversion_context & Context)
{
Context.get_text_context().start_field(oox::date, L"");
}
}
}
}
......@@ -379,7 +379,8 @@ public:
span() {}
office_element_ptr_array paragraph_content_;
style_ref text_style_name_;
style_ref text_style_name_;
style_ref_array text_class_names_;
private:
......@@ -446,6 +447,7 @@ public:
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;
......@@ -698,6 +700,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
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;
......@@ -727,6 +730,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
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;
......@@ -767,7 +771,47 @@ private:
CP_REGISTER_OFFICE_ELEMENT2(sheet_name);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//presentation:footer
class presentation_footer : public paragraph_content_element<presentation_footer>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationFooter;
CPDOCCORE_DEFINE_VISITABLE();
//void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_footer);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//presentation:date-time
class presentation_date_time: public paragraph_content_element<presentation_date_time>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typePresentationDateTime;
CPDOCCORE_DEFINE_VISITABLE();
//void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ){}
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name){}
};
CP_REGISTER_OFFICE_ELEMENT2(presentation_date_time);
} // namespace text
} // namespace odf
} // namespace cpdoccore
......@@ -1166,8 +1166,33 @@ void style_master_page::add_child_element( xml::sax * Reader, const ::std::wstri
}
}
void style_master_page::add_text(const std::wstring & Text)
{}
int style_master_page::find_placeHolderIndex(presentation_class::type placeHolder)
{
int idx = -1;
int i=0;
int size = content_.size();
while(true)
{
if (i>=size)break;
if (content_[i]->get_type() == odf::typeDrawFrame)
{
draw_frame* frame = dynamic_cast<draw_frame *>(content_[i].get());
if (frame->idx_in_owner<0) frame->idx_in_owner = i+1;
if ((frame) && (frame->common_presentation_attlist_.presentation_class_) &&
(frame->common_presentation_attlist_.presentation_class_->get_type()== placeHolder))
{
idx = frame->idx_in_owner;
break;
}
}
i++;
}
return idx;
}
void style_master_page::pptx_convert(oox::pptx_conversion_context & Context)
{
......
......@@ -445,10 +445,11 @@ public:
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
virtual void add_text(const std::wstring & Text);
public:
style_master_page_attlist style_master_page_attlist_;
int find_placeHolderIndex(presentation_class::type placeHolder);
style_master_page_attlist style_master_page_attlist_;
office_element_ptr style_header_;
office_element_ptr style_header_left_;
......
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