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

(1.0.1.179): ASCOfficeOdfFile

1. подправлена геометрия Коннекторов
2. Вытащены оригинальные названия тем (были сгенеренные)
3. подправлены шаблоны полей ввода (SlideNum, Date/Time, Footer)
4. Отображение полей ввода OpenOffice которых нет в MS как текста

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54031 954022d7-b5bf-4e40-9824-e11837661b57
parent d4a0f6d1
......@@ -2,6 +2,6 @@
//1
//0
//1
//177
#define INTVER 1,0,1,177
#define STRVER "1,0,1,177\0"
//179
#define INTVER 1,0,1,179
#define STRVER "1,0,1,179\0"
......@@ -79,7 +79,7 @@ void oox_serialize_ln(std::wostream & strm, const std::vector<odf::_property> &
else dash_style = _ooxDashStyle[iVal.get()];
}
if (dVal)
if ((dVal) && (dVal.get()> 0))
{
CP_XML_ATTR(L"w",static_cast<size_t>(dVal.get() * 12700));//in emu (1 pt = 12700)
if (color.length()<1)color = L"729FCF";
......@@ -317,10 +317,16 @@ void oox_serialize_xfrm(std::wostream & strm, _oox_drawing const & val, std::wst
CP_XML_ATTR(L"y", static_cast<size_t>(val.y));
}
CP_XML_NODE(L"a:ext")
if (val.cx >0 && val.cy >0)
{
CP_XML_ATTR(L"cx", static_cast<size_t>(val.cx));
CP_XML_ATTR(L"cy", static_cast<size_t>(val.cy));
CP_XML_NODE(L"a:ext")
{
CP_XML_ATTR(L"cx", static_cast<size_t>(val.cx));
CP_XML_ATTR(L"cy", static_cast<size_t>(val.cy));
}
}else
{
_CP_LOG(info) << L"[error!!!] not set size object\n";
}
}
}
......
......@@ -38,6 +38,7 @@ pptx_conversion_context(::cpdoccore::oox::package::pptx_document * outputDocumen
,pptx_table_context_(*this)
,pptx_comments_context_(comments_context_handle_)
,pptx_slide_context_(*this/*, pptx_text_context_*/)
,last_idx_placeHolder(1)
{
}
//
......@@ -59,6 +60,9 @@ pptx_conversion_context(::cpdoccore::oox::package::pptx_document * outputDocumen
void pptx_conversion_context::process_layouts()
{
odf::presentation_layouts_instance & layouts = root()->odf_context().styleContainer().presentation_layouts();
get_text_context().set_process_layouts(true);
//áåðåì òîëüêî àêòóàëüíûå
for (int layout_index =0; layout_index < layouts.content.size(); layout_index++)
{
......@@ -82,25 +86,34 @@ void pptx_conversion_context::process_layouts()
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))
if ((frame) && (frame->common_presentation_attlist_.presentation_class_))
{
elm->pptx_convert(*this);
odf::presentation_class::type type = frame->common_presentation_attlist_.presentation_class_->get_type();
if (type==odf::presentation_class::footer ||
type==odf::presentation_class::date_time ||
type==odf::presentation_class::header ||
type==odf::presentation_class::page_number)
{
if (frame->idx_in_owner <0)frame->idx_in_owner = last_idx_placeHolder++;
frame->pptx_convert_placeHolder(*this);
}
}
}
}
}
end_layout();
}
get_text_context().set_process_layouts(false);
}
void pptx_conversion_context::process_master_pages()
{
odf::presentation_masters_instance & masters = root()->odf_context().styleContainer().presentation_masters();
process_masters_ = true;
get_text_context().set_process_layouts(true);
//áåðåì òîëüêî àêòóàëüíûå
for (int master_index =0; master_index < masters.content.size();master_index++)
......@@ -118,22 +131,28 @@ void pptx_conversion_context::process_master_pages()
end_master();
}
process_masters_ = false;
get_text_context().set_process_layouts(false);
}
void pptx_conversion_context::process_styles()
{
}
void pptx_conversion_context::process_theme()
void pptx_conversion_context::process_theme(std::wstring name)
{
std::wstring name = L"Users Theme";
int current = themes_.size() + 1;
if (name.length()<1)
{
name = L"User Theme: " + boost::lexical_cast<std::wstring>(current);
}
start_theme(name);
//
pptx_serialize_clrScheme(current_theme().clrSchemeData());
pptx_serialize_fmtScheme(current_theme().fmtSchemeData());
pptx_serialize_fontScheme(current_theme().fontSchemeData());
//
current_theme();
end_theme();
}
......@@ -234,14 +253,19 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().add_charts(content);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//äîáàâëÿåì òåìû
for (int i=0; i < themes_.size();i++)
{
output_document_->get_ppt_files().add_theme(themes_[i]);
}
package::ppt_comments_files_ptr comments = package::ppt_comments_files::create(comments_context_handle_.content());
output_document_->get_ppt_files().set_comments(comments);
output_document_->get_ppt_files().set_presentation(presentation_);
output_document_->get_ppt_files().set_themes(theme_);
output_document_->get_ppt_files().set_media(get_mediaitems());
output_document_->get_ppt_files().set_authors_comments(authors_comments_);
......@@ -279,9 +303,9 @@ pptx_xml_slideLayout & pptx_conversion_context::current_layout()
}
pptx_xml_theme & pptx_conversion_context::current_theme()
{
if (theme_)
if (!themes_.empty())
{
return *theme_;
return *themes_.back().get();
}
else
{
......@@ -371,7 +395,7 @@ bool pptx_conversion_context::start_layout(int layout_index)
root()->odf_context().styleContainer().presentation_masters().add_layout_to(layouts.content[layout_index].master_name,layouts.content[layout_index]);
current_layout().Rels().add(relationship(master_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
current_layout().Rels().add(relationship(L"smId1"/*master_id.second*/, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
std::wstring(L"../slideMasters/slideMaster") + boost::lexical_cast<std::wstring>(master_id.first) + L".xml"));
//layout type
......@@ -426,8 +450,8 @@ bool pptx_conversion_context::start_master(int master_index)
current_master_page_name_ = L"";
current_layout_page_name_ = L"";
//add default theme (âðåìåííî !!!!)
current_master().add_theme(1, L"tId1"); //std::pair<int,std::wstring> thema_id = std::pair<int,std::wstring>(1,L"tmId1");//thema
process_theme(masters.content[master_index].master_name);//add default theme - îäèíàêîâûå íî ïîä ðàçíûìè èìåíàìè
current_master().add_theme(current_theme().id(), L"tId1");
for (long i=0;i<masters.content[master_index].layouts.size();i++)
{
......@@ -490,7 +514,7 @@ void pptx_conversion_context::end_master()
}
void pptx_conversion_context::start_theme(std::wstring & name)
{
theme_ = pptx_xml_theme::create(name,1);
themes_.push_back(pptx_xml_theme::create(name,themes_.size()+1));
}
void pptx_conversion_context::end_theme()
{
......
......@@ -89,11 +89,13 @@ public:
//void end_hyperlink(std::wstring const & href);
bool process_masters_;
void process_master_pages();
void process_layouts();
void process_styles();
void process_theme();
void process_master_pages();
void process_theme(std::wstring name);
int last_idx_placeHolder;
private:
void create_new_slide(std::wstring const & name);
......@@ -114,9 +116,9 @@ private:
std::vector<pptx_xml_slide_ptr> slides_;
std::vector<pptx_xml_slideMaster_ptr> slideMasters_;
std::vector<pptx_xml_slideLayout_ptr> slideLayouts_;
std::vector<pptx_xml_theme_ptr> themes_;
pptx_xml_authors_comments_ptr authors_comments_;
pptx_xml_theme_ptr theme_;
pptx_xml_presentation presentation_;
std::wstring current_master_page_name_;
......
......@@ -84,7 +84,10 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing const & val)
}
oox_serialize_ln(CP_XML_STREAM(),val.additional);
}
pptx_serialize_text(CP_XML_STREAM(),val.additional);
//_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent);
//pptx_serialize_text(CP_XML_STREAM(),val.additional);
// ... -
}
}
}
......@@ -122,9 +125,9 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing const & val)
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");
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"); }
}
}
}
......
......@@ -73,10 +73,10 @@ void pptx_xml_slide::write_to(std::wostream & strm)
}
}
CP_XML_STREAM() << slideTiming_.str();
//CP_XML_NODE(L"p:clrMapOvr")
//{
// CP_XML_NODE(L"a:masterClrMapping");
//}
CP_XML_NODE(L"p:clrMapOvr")
{
CP_XML_NODE(L"a:masterClrMapping");
}
}
}
}
......@@ -115,10 +115,10 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm)
{
CP_XML_NODE(L"p:sldLayout")
{
if (slideLayoutData_.str().length()<0)
CP_XML_ATTR(L"type",L"cust");//---------------------------!!!!!!!!!!!!
else
CP_XML_ATTR(L"type",L"cust");
//if (slideLayoutData_.str().length()<0)
// CP_XML_ATTR(L"type",L"cust");//---------------------------!!!!!!!!!!!!
//else
// CP_XML_ATTR(L"type",L"cust");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
......@@ -159,12 +159,13 @@ std::wstring pptx_xml_slideMaster::rId() const
pptx_xml_slideMaster_ptr pptx_xml_slideMaster::create(int id)
{
const std::wstring rId = std::wstring(L"smId") + boost::lexical_cast<std::wstring>(id);
return boost::make_shared<pptx_xml_slideMaster>(rId);
return boost::make_shared<pptx_xml_slideMaster>(rId,id);
}
pptx_xml_slideMaster::pptx_xml_slideMaster(std::wstring const & id)
pptx_xml_slideMaster::pptx_xml_slideMaster(std::wstring const & rId, int id)
{
rId_ = id;
rId_ = rId;
id_ = id;
}
pptx_xml_slideMaster::~pptx_xml_slideMaster()
......@@ -242,7 +243,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
CP_XML_NODE(L"p:sldLayoutId")
{
CP_XML_ATTR(L"r:id",q);
CP_XML_ATTR(L"id",0x80000000 + (++count));
CP_XML_ATTR(L"id",0x80000000 + (++count) + (id_-1)*20); // ..
}
}
count++;
......
......@@ -102,7 +102,7 @@ typedef _CP_PTR(pptx_xml_slideMaster) pptx_xml_slideMaster_ptr;
class pptx_xml_slideMaster: noncopyable
{
public:
pptx_xml_slideMaster(std::wstring const & id);
pptx_xml_slideMaster(std::wstring const & rId, int id);
~pptx_xml_slideMaster();
public:
std::wstring rId() const;
......@@ -126,6 +126,7 @@ private:
std::vector<std::wstring> layoutsId_;
std::wstring rId_;
int id_;
std::wstring themeId_;
......
......@@ -211,25 +211,7 @@ void slideLayouts_files::write(const std::wstring & RootPath)
}
}
}
///////////////////////////////////////////////////////////////////////////////////////
theme_elements::theme_elements(pptx_xml_theme_ptr & theme) : theme_(theme)
{
}
void theme_elements::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"theme" ;
fs::create_directory(path);
const std::wstring file_name = std::wstring(L"theme") + boost::lexical_cast<std::wstring>(theme_->id()) + L".xml";
std::wstringstream content_theme;
theme_->write_to(content_theme);
simple_element(file_name, content_theme.str()).write(BOOST_STRING_PATH(path));
if (get_main_document())
get_main_document()->content_type().get_content_type().add_override(std::wstring(L"/ppt/theme/") + file_name, L"application/vnd.openxmlformats-officedocument.theme+xml");
}
///////////////////////////////////////////////////////////////////////////////////////
authors_comments_element::authors_comments_element(pptx_xml_authors_comments_ptr & authors_comments) : authors_comments_(authors_comments)
{
......@@ -280,6 +262,35 @@ void ppt_charts_files::write(const std::wstring & RootPath)
}
}
}
///////////////////////////////////
void ppt_themes_files::add_theme(pptx_xml_theme_ptr theme)
{
themes_.push_back(theme);
}
void ppt_themes_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath) / L"theme" ;
fs::create_directory(path);
size_t count = 0;
BOOST_FOREACH(const pptx_xml_theme_ptr & item, themes_)
{
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"theme") + boost::lexical_cast<std::wstring>(count) + L".xml";
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
contentTypes.add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
std::wstringstream content;
item->write_to(content);
package::simple_element(fileName, content.str()).write(BOOST_STRING_PATH(path));
}
}
}
//////////////////////////////
ppt_comments_files_ptr ppt_comments_files::create(const std::vector<pptx_comment_elm> & elms)
{
......@@ -339,12 +350,6 @@ void ppt_files::write(const std::wstring & RootPath)
presentation_->write(BOOST_STRING_PATH(path));
}
if (theme_)
{
rels_files_.add( relationship( L"tId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", L"theme/theme1.xml" ) );
theme_->write(BOOST_STRING_PATH(path));
}
if (media_)
{
media_->set_main_document(get_main_document());
......@@ -355,6 +360,10 @@ void ppt_files::write(const std::wstring & RootPath)
charts_files_.write(BOOST_STRING_PATH(path));
}
{
themes_files_.set_main_document(get_main_document());
themes_files_.write(BOOST_STRING_PATH(path));
}
{
comments_->set_main_document(get_main_document());
comments_->write(BOOST_STRING_PATH(path));
}
......@@ -384,12 +393,7 @@ void ppt_files::set_styles(element_ptr Element)
{
tableStyles_ = Element;
}
void ppt_files::set_themes(pptx_xml_theme_ptr & theme) //
{
theme_elements * elm = new theme_elements(theme);
elm->set_main_document( this->get_main_document() );
theme_ = element_ptr( elm );
}
void ppt_files::add_slide(slide_content_ptr slide)
{
slides_files_.add_slide(slide);
......@@ -420,7 +424,10 @@ void ppt_files::add_charts(chart_content_ptr chart)
{
charts_files_.add_chart(chart);
}
void ppt_files::add_theme(pptx_xml_theme_ptr theme)
{
themes_files_.add_theme(theme);
}
}
}
}
......@@ -76,18 +76,7 @@ public:
public:
std::vector<slide_content_ptr> slides_;
};
///////////////////////////////////////////////////////////////////////////////
class theme_elements : public element
{
public:
theme_elements(pptx_xml_theme_ptr & theme);//ïîòîì äî âåêòîðà
virtual void write(const std::wstring & RootPath);
private:
pptx_xml_theme_ptr & theme_;
};
///////////////////////////////////////////////////////////////////////////////
class authors_comments_element : public element
......@@ -155,6 +144,19 @@ public:
std::vector<chart_content_ptr> charts_;
};
//////////////////////////////////////////////////////////////////////////////
/// \class ppt_theme_files
class ppt_themes_files : public element
{
public:
ppt_themes_files(){}
void add_theme(pptx_xml_theme_ptr chart);
virtual void write(const std::wstring & RootPath);
std::vector<pptx_xml_theme_ptr> themes_;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////
class ppt_files : public element
......@@ -166,7 +168,6 @@ public:
virtual void write(const std::wstring & RootPath);
void set_presentation(pptx_xml_presentation & presentation);
void set_themes(pptx_xml_theme_ptr & theme);
void set_styles(element_ptr Element);
void set_comments(element_ptr Element);
......@@ -177,6 +178,7 @@ public:
void set_media(mediaitems & _Mediaitems);
void add_charts(chart_content_ptr chart);
void add_theme (pptx_xml_theme_ptr theme);
void set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments);
......@@ -187,14 +189,15 @@ private:
slideLayouts_files slideLayouts_files_;
slideMasters_files slideMasters_files_;
ppt_themes_files themes_files_;
ppt_charts_files charts_files_;
//slides_files notesSlides_files_;
//slides_files notesMasters_files_;
//slides_files handoutMasters_files_;
element_ptr authors_comments_;
element_ptr theme_;
element_ptr presentation_;
element_ptr tableStyles_;
......
......@@ -62,12 +62,14 @@ public:
std::wstring end_comment();
bool in_list_;
bool process_layouts_;
private:
styles_context styles_context_;
odf::odf_read_context & odf_context_ ;
std::wstring hyperlink_hId;
bool in_span;
bool in_paragraph;
......@@ -121,6 +123,7 @@ pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversi
{
new_list_style_number_=0;
local_styles_ptr_ = NULL;
process_layouts_ = false;
}
void pptx_text_context::Impl::add_text(const std::wstring & text)
......@@ -395,18 +398,22 @@ std::wstring pptx_text_context::Impl::dump_paragraph(/*bool last*/)
{
write_pPr(CP_XML_STREAM());
CP_XML_STREAM() << run_.str();
//if (last)
//{
// CP_XML_NODE(L"a:endParaRPr");//- /
//}
if (str_run.length() > 0)
{
CP_XML_STREAM() << run_.str();
}
else
{
CP_XML_NODE(L"a:endParaRPr");
}
}
}
run_.str(std::wstring());
}
return paragraph_.str();
}
#include <Objbase.h>
void pptx_text_context::Impl::dump_field()
{
if (field_type_ == none) return;
......@@ -416,44 +423,57 @@ void pptx_text_context::Impl::dump_field()
CP_XML_NODE(L"a:fld")
{
std::wstring content = xml::utils::replace_text_to_xml(field_value_.str());
std::wstring string_id;
std::wstring string_type;
GUID new_id;
CoCreateGuid(&new_id);
wchar_t str[100]={};
StringFromGUID2(new_id,str,100);
string_id = str;
switch (field_type_)
{
case page_number:
{
CP_XML_ATTR(L"type", L"slidenum");
CP_XML_ATTR(L"id", L"{5CC2A059-B141-45A7-B910-B096D6D06820}");
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"<#>");
string_type = L"slidenum";
// string_id = L"{5CC2A059-B141-45A7-B910-B096D6D06820}";
// content = L"#";
}
break;
case date:
{
CP_XML_ATTR(L"type", L"datetime1");
CP_XML_ATTR(L"id", L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}");
string_type = L"datetime1";
// string_id = L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}";
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"01.01.2000");
}
break;
case time:
{
CP_XML_ATTR(L"type", L"datetime11");
CP_XML_ATTR(L"id", L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}");
string_type = L"datetime11";
// string_id = L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}";
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"00:00:00");
}
break;
case datetime:
{
CP_XML_ATTR(L"type", L"datetime1");
CP_XML_ATTR(L"id", L"{A9EA0FE8-FEF9-4B2F-BC9D-19DDCDB4AB9B}");
string_type = L"datetime1";
// string_id = L"{A9EA0FE8-FEF9-4B2F-BC9D-19DDCDB4AB9B}";
}
}
CP_XML_NODE(L"a:t")
if (string_type.length()>0)
{
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
CP_XML_ATTR(L"id", string_id);
CP_XML_ATTR(L"type", string_type);
CP_XML_NODE(L"a:t")
{
CP_XML_STREAM() << content;
}
}
else
{
//
text_ << content;
}
}
}
......@@ -466,6 +486,8 @@ void pptx_text_context::Impl::dump_run()
dump_field();
if (process_layouts_) return;
const std::wstring content = xml::utils::replace_text_to_xml(text_.str());
if (content.length() <1 && span_style_name_.length()<1) return ;
......@@ -477,7 +499,7 @@ void pptx_text_context::Impl::dump_run()
CP_XML_NODE(L"a:t")
{
CP_XML_ATTR(L"xml:space", L"preserve");
//CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
......@@ -788,5 +810,10 @@ std::wstring pptx_text_context::end_comment_content()
return impl_->end_comment();
}
void pptx_text_context::set_process_layouts(bool val)
{
impl_->process_layouts_ = val;
}
}
}
......@@ -74,6 +74,8 @@ public:
styles_context & get_styles_context();
void set_process_layouts(bool val);
private:
class Impl;
......
......@@ -121,6 +121,7 @@ public:
virtual void docx_convert(oox::docx_conversion_context & Context);
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
virtual void pptx_convert(oox::pptx_conversion_context & Context);
virtual void pptx_convert_placeHolder(oox::pptx_conversion_context & Context);
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......
......@@ -50,6 +50,11 @@ void draw_g::pptx_convert(oox::pptx_conversion_context & Context)
i++;
}
}
void draw_frame::pptx_convert_placeHolder(oox::pptx_conversion_context & Context)
{
Context.get_slide_context().set_property(_property(L"no_rect",true));
pptx_convert(Context);
}
void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
{
common_draw_shape_with_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_draw_shape_with_styles_attlist_;
......@@ -144,8 +149,9 @@ 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);
Context.get_slide_context().set_placeHolder_idx(idx_in_owner);
}
if (office_event_listeners_)office_event_listeners_->pptx_convert(Context);
......
......@@ -66,7 +66,7 @@ void draw_page::pptx_convert_placeHolder(oox::pptx_conversion_context & Context,
style_master_page * master = Context.root()->odf_context().pageLayoutContainer().master_page_by_name(masterName);
if (master)
index = master->find_placeHolderIndex(PresentationClass);
index = master->find_placeHolderIndex(PresentationClass, Context.last_idx_placeHolder);
Context.get_slide_context().start_shape(1);
......
......@@ -445,9 +445,10 @@ const wchar_t * draw_connector::name = L"connector";
void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
draw_connector_attlist_.add_attributes(Attributes);
draw_line_attlist_.add_attributes(Attributes);
draw_shape::add_attributes(Attributes);
sub_type_ = 6;
sub_type_ = 5; // - , ( ) -
}
void draw_connector::reset_svg_path()
......@@ -458,6 +459,9 @@ void draw_connector::reset_svg_path()
std::vector<svg_path::_polyline> o_Polyline_cm;
bool res = svg_path::parseSvgD(o_Polyline_cm,draw_connector_attlist_.svg_d_.get(),false);
double x1=common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::emu);
double y1=common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::emu);
BOOST_FOREACH(svg_path::_polyline & poly, o_Polyline_cm)
{
......@@ -465,17 +469,18 @@ void draw_connector::reset_svg_path()
{
if (poly.points[i].x)
{
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::pt).get_value_unit(length::emu);
poly.points[i].x = length(poly.points[i].x.get()/1000.,length::cm).get_value_unit(length::emu)-x1;
}
if (poly.points[i].y)
{
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::pt).get_value_unit(length::emu);
poly.points[i].y = length(poly.points[i].y.get()/1000.,length::cm).get_value_unit(length::emu)-y1;
}
}
o_Polyline_pt.push_back(poly);
}
if (o_Polyline_pt.size()>0)
{
sub_type_ = 6;
// xml-oox ... drawing .. ..
std::wstringstream output_;
svg_path::oox_serialize(output_, o_Polyline_pt);
......
......@@ -460,8 +460,10 @@ public:
virtual void pptx_convert(oox::pptx_conversion_context & Context);
draw_connector_attlist draw_connector_attlist_;
draw_line_attlist draw_line_attlist_;
void reset_svg_path();
void reset_svg_attributes();
};
CP_REGISTER_OFFICE_ELEMENT2(draw_connector);
......
......@@ -202,19 +202,48 @@ void draw_caption::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().end_shape();
}
void draw_connector::reset_svg_attributes()
{
double x1=draw_line_attlist_.svg_x1_.get_value_or(length(0)).get_value_unit(length::pt);
double y1=draw_line_attlist_.svg_y1_.get_value_or(length(0)).get_value_unit(length::pt);
double x2=draw_line_attlist_.svg_x2_.get_value_or(length(0)).get_value_unit(length::pt);
double y2=draw_line_attlist_.svg_y2_.get_value_or(length(0)).get_value_unit(length::pt);
if (x1 > x2)
{
common_draw_attlists_.position_.svg_x_ = draw_line_attlist_.svg_x2_;
common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(x1-x2, length::pt);
}else
{
common_draw_attlists_.position_.svg_x_ = draw_line_attlist_.svg_x1_;
common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ = length(x2-x1, length::pt);
}
if (y1 > y2)
{
common_draw_attlists_.position_.svg_y_ = draw_line_attlist_.svg_y2_;
common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(y1-y2, length::pt);
}else
{
common_draw_attlists_.position_.svg_y_ = draw_line_attlist_.svg_y1_;
common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_ = length(y2-y1, length::pt);
}
}
void draw_connector::pptx_convert(oox::pptx_conversion_context & Context)
{
reset_svg_attributes();
reset_svg_path();
///////////////////////////////////////////////////////////////////////
int type=sub_type_;
//if (draw_connector_attlist_.draw_type_)
//{
// if (*draw_connector_attlist_.draw_type_ == L"curve") type = 6;
// if (*draw_connector_attlist_.draw_type_ == L"line") type = 5;
//}
Context.get_slide_context().start_shape(type);
Context.get_slide_context().start_shape(sub_type_);
common_pptx_convert(Context);
// ..
oox::_oox_fill fill;
fill.type = 0;
Context.get_slide_context().set_fill(fill);
Context.get_slide_context().end_shape();
}
......
......@@ -601,7 +601,6 @@ void odf_document::Impl::pptx_convert(oox::pptx_conversion_context & Context)
Context.process_layouts();
Context.process_master_pages();
Context.process_theme();
Context.end_document();
}
......
......@@ -15,6 +15,17 @@ namespace odf {
using xml::xml_char_wc;
std::wstring delete_apostroph_in_name(std::wstring value)
{
if (value.length()<1)return value;
if (value[0] == 0x27 && value[value.length()-1] == 0x27)
{
return value.substr(1,value.length()-2);
}
return value;
}
void text_format_properties_content::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
// 15.4.1
......@@ -481,18 +492,21 @@ void text_format_properties_content::pptx_convert(oox::pptx_conversion_context &
{
std::wstring w_font = (fo_font_family_ ? *fo_font_family_: L"");
std::wstring w_ascii = (style_font_name_ ? *style_font_name_: w_font);
if (w_ascii.length()>0) CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface",w_ascii);}
if (w_ascii.length()>0)
{
CP_XML_NODE(L"a:latin"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_ascii));}
}
if (style_font_name_asian_)
{
std::wstring w_eastAsia = *style_font_name_asian_;
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface",w_eastAsia);}
CP_XML_NODE(L"a:ea"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_eastAsia));}
}
if (style_font_name_complex_)
{
std::wstring w_cs = *style_font_name_complex_;
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface",w_cs);}
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface",delete_apostroph_in_name(w_cs));}
}
}
......
......@@ -1179,7 +1179,7 @@ void style_master_page::add_child_element( xml::sax * Reader, const ::std::wstri
}
}
int style_master_page::find_placeHolderIndex(presentation_class::type placeHolder)
int style_master_page::find_placeHolderIndex(presentation_class::type placeHolder,int & last_idx)
{
int idx = -1;
......@@ -1193,7 +1193,7 @@ int style_master_page::find_placeHolderIndex(presentation_class::type placeHolde
{
draw_frame* frame = dynamic_cast<draw_frame *>(content_[i].get());
if (frame->idx_in_owner<0) frame->idx_in_owner = i+1;
if (frame->idx_in_owner<0)frame->idx_in_owner = last_idx++;
if ((frame) && (frame->common_presentation_attlist_.presentation_class_) &&
(frame->common_presentation_attlist_.presentation_class_->get_type()== placeHolder))
......
......@@ -447,7 +447,7 @@ private:
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
public:
int find_placeHolderIndex(presentation_class::type placeHolder);
int find_placeHolderIndex(presentation_class::type placeHolder,int & last_idx);
style_master_page_attlist style_master_page_attlist_;
......
......@@ -263,7 +263,7 @@ namespace svg_path
bRelative = true;
// FALLTHROUGH intended
}
case 'H' :
case 'H' ://
{
aCurrPoly.command=L"a:lnTo";
nPos++;
......@@ -296,9 +296,9 @@ namespace svg_path
bRelative = true;
// FALLTHROUGH intended
}
case 'V' :
case 'V' ://
{
aCurrPoly.command =L"a:v";
aCurrPoly.command =L"a:lnTo";
nPos++;
skipSpaces(nPos, rSvgDStatement, nLen);
......
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