Commit 60f61109 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - presentation slide notes

parent 4201bcec
...@@ -49,6 +49,8 @@ struct _rect ...@@ -49,6 +49,8 @@ struct _rect
struct drawing_object_description struct drawing_object_description
{ {
bool bNotes_;
oox::RelsType type_; oox::RelsType type_;
std::wstring name_; std::wstring name_;
......
...@@ -153,7 +153,9 @@ void pptx_conversion_context::process_master_pages() ...@@ -153,7 +153,9 @@ void pptx_conversion_context::process_master_pages()
get_text_context().set_process_layouts(true); get_text_context().set_process_layouts(true);
//берем только актуальные //берем только актуальные
for (size_t master_index =0; master_index < masters.content.size();master_index++) odf_reader::office_element_ptr master_notes_;
for (size_t master_index = 0; master_index < masters.content.size(); master_index++)
{ {
start_master(master_index); start_master(master_index);
...@@ -163,10 +165,21 @@ void pptx_conversion_context::process_master_pages() ...@@ -163,10 +165,21 @@ void pptx_conversion_context::process_master_pages()
if (master) if (master)
{ {
master->pptx_convert(*this); master->pptx_convert(*this);
if (!master_notes_ && master->presentation_notes_)
master_notes_ = master->presentation_notes_;
} }
end_master(); end_master();
} }
if (master_notes_)
{
start_master_notes();
master_notes_->pptx_convert(*this);
end_master_notes();
}
process_masters_ = false; process_masters_ = false;
get_text_context().set_process_layouts(false); get_text_context().set_process_layouts(false);
...@@ -180,7 +193,7 @@ void pptx_conversion_context::process_theme(std::wstring name) ...@@ -180,7 +193,7 @@ void pptx_conversion_context::process_theme(std::wstring name)
{ {
int current = themes_.size() + 1; int current = themes_.size() + 1;
if (name.length()<1) if (name.empty())
{ {
name = L"User Theme: " + boost::lexical_cast<std::wstring>(current); name = L"User Theme: " + boost::lexical_cast<std::wstring>(current);
} }
...@@ -255,7 +268,7 @@ void pptx_conversion_context::end_document() ...@@ -255,7 +268,7 @@ void pptx_conversion_context::end_document()
} }
count++; count++;
} }
/////////////////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------------
for (size_t i = 0; i < slideLayouts_.size(); i++) for (size_t i = 0; i < slideLayouts_.size(); i++)
{ {
pptx_xml_slideLayout_ptr& slideL = slideLayouts_[i]; pptx_xml_slideLayout_ptr& slideL = slideLayouts_[i];
...@@ -267,10 +280,31 @@ void pptx_conversion_context::end_document() ...@@ -267,10 +280,31 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().add_slideLayout(content);//slideMaster.xml output_document_->get_ppt_files().add_slideLayout(content);//slideMaster.xml
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------------
for (size_t i = 0; i < notes_.size(); i++)
{
pptx_xml_slideNotes_ptr& slideN = notes_[i];
package::slide_content_ptr content = package::slide_content::create();
slideN->write_to(content->content());
content->add_rels(slideN->Rels());//media & links rels
output_document_->get_ppt_files().add_notes(content);
}
if (slideNotesMaster_)
{
package::slide_content_ptr content = package::slide_content::create();
slideNotesMaster_->write_to(content->content());
content->add_rels(slideNotesMaster_->Rels());//media & links rels
output_document_->get_ppt_files().add_notesMaster(content);
}
//----------------------------------------------------------------------------------
//размеры страниц в презентации //размеры страниц в презентации
odf_reader::odf_read_context & context = root()->odf_context(); odf_reader::odf_read_context & context = root()->odf_context();
odf_reader::page_layout_container & pageLayouts = context.pageLayoutContainer(); odf_reader::page_layout_container & pageLayouts = context.pageLayoutContainer();
if ((pageLayouts.master_pages().size() > 0) && (pageLayouts.master_pages()[0]->attlist_.style_name_))//default if ((pageLayouts.master_pages().size() > 0) && (pageLayouts.master_pages()[0]->attlist_.style_name_))//default
{ {
...@@ -308,10 +342,10 @@ void pptx_conversion_context::end_document() ...@@ -308,10 +342,10 @@ void pptx_conversion_context::end_document()
} }
package::ppt_comments_files_ptr comments = package::ppt_comments_files::create(comments_context_handle_.content()); package::ppt_comments_files_ptr comments = package::ppt_comments_files::create(comments_context_handle_.content());
output_document_->get_ppt_files().set_presentation(presentation_); output_document_->get_ppt_files().set_presentation (presentation_);
output_document_->get_ppt_files().set_comments(comments); output_document_->get_ppt_files().set_comments (comments);
output_document_->get_ppt_files().set_authors_comments(authors_comments_); output_document_->get_ppt_files().set_authors_comments (authors_comments_);
output_document_->get_ppt_files().set_media(get_mediaitems(), applicationFonts_); output_document_->get_ppt_files().set_media (get_mediaitems(), applicationFonts_);
output_document_->get_content_types_file().set_media(get_mediaitems()); output_document_->get_content_types_file().set_media(get_mediaitems());
} }
...@@ -321,7 +355,28 @@ void pptx_conversion_context::start_body() ...@@ -321,7 +355,28 @@ void pptx_conversion_context::start_body()
void pptx_conversion_context::end_body() void pptx_conversion_context::end_body()
{} {}
pptx_xml_slideNotesMaster & pptx_conversion_context::current_notesMaster()
{
if (slideNotesMaster_)
{
return *slideNotesMaster_;
}
else
{
throw std::runtime_error("internal error");
}
}
pptx_xml_slideNotes & pptx_conversion_context::current_notes()
{
if (!notes_.empty())
{
return *notes_.back().get();
}
else
{
throw std::runtime_error("internal error");
}
}
pptx_xml_slide & pptx_conversion_context::current_slide() pptx_xml_slide & pptx_conversion_context::current_slide()
{ {
if (!slides_.empty()) if (!slides_.empty())
...@@ -384,9 +439,18 @@ pptx_xml_slideMaster & pptx_conversion_context::current_master() ...@@ -384,9 +439,18 @@ pptx_xml_slideMaster & pptx_conversion_context::current_master()
} }
void pptx_conversion_context::create_new_slide(std::wstring const & name) void pptx_conversion_context::create_new_slide(std::wstring const & name)
{ {
pptx_xml_slide_ptr s = pptx_xml_slide::create(name,slides_.size()+1); pptx_xml_slide_ptr s = pptx_xml_slide::create(name,slides_.size() + 1);
slides_.push_back(s); slides_.push_back(s);
} }
void pptx_conversion_context::create_new_slideNotes()
{
pptx_xml_slideNotes_ptr s = pptx_xml_slideNotes::create( notes_.size() + 1);
notes_.push_back(s);
}
void pptx_conversion_context::create_new_slideNotesMaster()
{
slideNotesMaster_ = pptx_xml_slideNotesMaster::create();
}
void pptx_conversion_context::create_new_slideLayout(int id) void pptx_conversion_context::create_new_slideLayout(int id)
{ {
pptx_xml_slideLayout_ptr s = pptx_xml_slideLayout::create(id); pptx_xml_slideLayout_ptr s = pptx_xml_slideLayout::create(id);
...@@ -397,7 +461,6 @@ void pptx_conversion_context::create_new_slideMaster(int id) ...@@ -397,7 +461,6 @@ void pptx_conversion_context::create_new_slideMaster(int id)
pptx_xml_slideMaster_ptr s = pptx_xml_slideMaster::create(id); pptx_xml_slideMaster_ptr s = pptx_xml_slideMaster::create(id);
slideMasters_.push_back(s); slideMasters_.push_back(s);
} }
bool pptx_conversion_context::start_page(const std::wstring & pageName, const std::wstring & pageStyleName, bool pptx_conversion_context::start_page(const std::wstring & pageName, const std::wstring & pageStyleName,
const std::wstring & pageLayoutName, const std::wstring & pageLayoutName,
const std::wstring & pageMasterName) const std::wstring & pageMasterName)
...@@ -414,7 +477,7 @@ bool pptx_conversion_context::start_page(const std::wstring & pageName, const st ...@@ -414,7 +477,7 @@ bool pptx_conversion_context::start_page(const std::wstring & pageName, const st
root()->odf_context().styleContainer().presentation_layouts().add_or_find(pageLayoutName,pageMasterName); root()->odf_context().styleContainer().presentation_layouts().add_or_find(pageLayoutName,pageMasterName);
current_slide().Rels().add(relationship(layout_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout", current_slide().Rels().add(relationship(layout_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
std::wstring(L"../slideLayouts/slideLayout") + boost::lexical_cast<std::wstring>(layout_id.first) + L".xml")); std::wstring(L"../slideLayouts/slideLayout") + std::to_wstring(layout_id.first) + L".xml"));
return true; return true;
} }
...@@ -530,47 +593,45 @@ void pptx_conversion_context::end_page() ...@@ -530,47 +593,45 @@ void pptx_conversion_context::end_page()
get_slide_context().end_slide(); get_slide_context().end_slide();
} }
bool pptx_conversion_context::start_note(const std::wstring & pageName, const std::wstring & pageStyleName, bool pptx_conversion_context::start_page_notes()
const std::wstring & pageLayoutName,
const std::wstring & pageMasterName)
{ {
// create_new_slide(pageName); create_new_slideNotes( );
//get_slide_context().start_note();//pageName, pageStyleName);
//current_master_page_name_ = pageMasterName; current_slide().Rels().add(relationship(current_notes().rId(), L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
//current_layout_page_name_ = pageLayoutName; std::wstring(L"../notesSlides/notesSlide") + std::to_wstring(notes_.size()) + L".xml"));
//
////const std::wstring masterPageNameLayout = root()->odf_context().pageLayoutContainer().page_layout_name_by_style(current_master_page_name_); get_slide_context().start_slide();
return true;
}
//std::pair<int,std::wstring> layout_id = void pptx_conversion_context::end_page_notes()
// root()->odf_context().styleContainer().presentation_layouts().add_or_find(pageLayoutName,pageMasterName); {
get_slide_context().serialize_background(current_notes().Background());
get_slide_context().serialize_objects(current_notes().Data());
//current_slide().Rels().add(relationship(layout_id.second, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout", get_slide_context().dump_rels(current_notes().Rels());//hyperlinks, mediaitems, ...
// std::wstring(L"../slideLayouts/slideLayout") + boost::lexical_cast<std::wstring>(layout_id.first) + L".xml"));
return true; get_slide_context().end_slide();
} }
bool pptx_conversion_context::start_master_notes()
void pptx_conversion_context::end_note()
{ {
//if (!get_comments_context().empty()) create_new_slideNotesMaster( );
// {
// std::wstringstream strm;
// get_comments_context().serialize(strm);
//
// const std::pair<std::wstring, std::wstring> commentsName =
// comments_context_handle_.add_comments_xml(strm.str(), get_comments_context().get_comments() );
// get_slide_context().add_rels(false, commentsName.second, L"../comments/" + commentsName.first, typeComment); //current_slide().Rels().add(relationship(current_notes().rId(), L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
// } // std::wstring(L"../notesSlides/notesSlide") + std::to_wstring(notes_.size()) + L".xml"));
//get_slide_context().serialize_background(current_slide().Background()); get_slide_context().start_slide();
//get_slide_context().serialize_objects (current_slide().Data()); return true;
//get_slide_context().serialize_animations(current_slide().Timing()); }
//
//get_slide_context().dump_rels(current_slide().Rels());//hyperlinks, mediaitems, ...
//get_slide_context().end_slide(); void pptx_conversion_context::end_master_notes()
{
get_slide_context().serialize_background(current_notesMaster().Background());
get_slide_context().serialize_objects(current_notesMaster().Data());
get_slide_context().dump_rels(current_notesMaster().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
} }
void pptx_conversion_context::end_layout() void pptx_conversion_context::end_layout()
{ {
......
...@@ -88,11 +88,11 @@ public: ...@@ -88,11 +88,11 @@ public:
const std::wstring & pageMasterName); const std::wstring & pageMasterName);
void end_page(); void end_page();
bool start_note(const std::wstring & pageName, bool start_page_notes();
const std::wstring & pageStyleName, void end_page_notes();
const std::wstring & pageLayoutName,
const std::wstring & pageMasterName); bool start_master_notes();
void end_note(); void end_master_notes();
bool start_layout( int layout_index); bool start_layout( int layout_index);
void end_layout(); void end_layout();
...@@ -113,10 +113,13 @@ public: ...@@ -113,10 +113,13 @@ public:
return odf_document_; return odf_document_;
} }
pptx_xml_slide & current_slide(); pptx_xml_slide & current_slide();
pptx_xml_slideLayout & current_layout(); pptx_xml_slideLayout & current_layout();
pptx_xml_slideMaster & current_master(); pptx_xml_slideMaster & current_master();
pptx_xml_theme & current_theme(); pptx_xml_theme & current_theme();
pptx_xml_slideNotes & current_notes();
pptx_xml_slideNotesMaster & current_notesMaster();
pptx_xml_presentation & current_presentation();//собственно она одна pptx_xml_presentation & current_presentation();//собственно она одна
oox_chart_context & current_chart(); oox_chart_context & current_chart();
...@@ -144,6 +147,8 @@ private: ...@@ -144,6 +147,8 @@ private:
void create_new_slide(std::wstring const & name); void create_new_slide(std::wstring const & name);
void create_new_slideLayout(int id); void create_new_slideLayout(int id);
void create_new_slideMaster(int id); void create_new_slideMaster(int id);
void create_new_slideNotes();
void create_new_slideNotesMaster();
package::pptx_document * output_document_; package::pptx_document * output_document_;
odf_reader::odf_document * odf_document_; odf_reader::odf_document * odf_document_;
...@@ -158,10 +163,12 @@ private: ...@@ -158,10 +163,12 @@ private:
std::vector<oox_chart_context_ptr> charts_; std::vector<oox_chart_context_ptr> charts_;
std::vector<pptx_xml_slide_ptr> slides_; std::vector<pptx_xml_slide_ptr> slides_;
std::vector<pptx_xml_slideNotes_ptr> notes_;
std::vector<pptx_xml_slideMaster_ptr> slideMasters_; std::vector<pptx_xml_slideMaster_ptr> slideMasters_;
std::vector<pptx_xml_slideLayout_ptr> slideLayouts_; std::vector<pptx_xml_slideLayout_ptr> slideLayouts_;
std::vector<pptx_xml_theme_ptr> themes_; std::vector<pptx_xml_theme_ptr> themes_;
pptx_xml_slideNotesMaster_ptr slideNotesMaster_;
pptx_xml_authors_comments_ptr authors_comments_; pptx_xml_authors_comments_ptr authors_comments_;
pptx_xml_presentation presentation_; pptx_xml_presentation presentation_;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
namespace cpdoccore { namespace cpdoccore {
namespace oox { namespace oox {
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slide::name() const std::wstring pptx_xml_slide::name() const
{ {
return name_; return name_;
...@@ -53,7 +53,7 @@ std::wstring pptx_xml_slide::rId() const ...@@ -53,7 +53,7 @@ std::wstring pptx_xml_slide::rId() const
pptx_xml_slide_ptr pptx_xml_slide::create(std::wstring const & name,int id) pptx_xml_slide_ptr pptx_xml_slide::create(std::wstring const & name,int id)
{ {
const std::wstring rId = std::wstring(L"sId") + boost::lexical_cast<std::wstring>(id); const std::wstring rId = std::wstring(L"sId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slide>(name,rId); return boost::make_shared<pptx_xml_slide>(name,rId);
} }
...@@ -115,7 +115,7 @@ void pptx_xml_slide::write_to(std::wostream & strm) ...@@ -115,7 +115,7 @@ void pptx_xml_slide::write_to(std::wostream & strm)
} }
} }
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideLayout::rId() const std::wstring pptx_xml_slideLayout::rId() const
{ {
return rId_; return rId_;
...@@ -123,7 +123,7 @@ std::wstring pptx_xml_slideLayout::rId() const ...@@ -123,7 +123,7 @@ std::wstring pptx_xml_slideLayout::rId() const
pptx_xml_slideLayout_ptr pptx_xml_slideLayout::create(int id) pptx_xml_slideLayout_ptr pptx_xml_slideLayout::create(int id)
{ {
const std::wstring rId = std::wstring(L"lrId") + boost::lexical_cast<std::wstring>(id); const std::wstring rId = std::wstring(L"lrId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slideLayout>(rId); return boost::make_shared<pptx_xml_slideLayout>(rId);
} }
...@@ -189,7 +189,7 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm) ...@@ -189,7 +189,7 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm)
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideMaster::rId() const std::wstring pptx_xml_slideMaster::rId() const
{ {
return rId_; return rId_;
...@@ -197,7 +197,7 @@ std::wstring pptx_xml_slideMaster::rId() const ...@@ -197,7 +197,7 @@ std::wstring pptx_xml_slideMaster::rId() const
pptx_xml_slideMaster_ptr pptx_xml_slideMaster::create(int id) pptx_xml_slideMaster_ptr pptx_xml_slideMaster::create(int id)
{ {
const std::wstring rId = std::wstring(L"smId") + boost::lexical_cast<std::wstring>(id); const std::wstring rId = std::wstring(L"smId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slideMaster>(rId,id); return boost::make_shared<pptx_xml_slideMaster>(rId,id);
} }
...@@ -229,7 +229,7 @@ rels & pptx_xml_slideMaster::Rels() ...@@ -229,7 +229,7 @@ rels & pptx_xml_slideMaster::Rels()
void pptx_xml_slideMaster::add_theme(int id, const std::wstring & tId) void pptx_xml_slideMaster::add_theme(int id, const std::wstring & tId)
{ {
rels_.add(relationship( tId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", rels_.add(relationship( tId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
std::wstring(L"../theme/theme") + boost::lexical_cast<std::wstring>(id) + L".xml")); std::wstring(L"../theme/theme") + std::to_wstring(id) + L".xml"));
} }
void pptx_xml_slideMaster::add_layout(int id, const std::wstring & rId, const unsigned int & uniqId) void pptx_xml_slideMaster::add_layout(int id, const std::wstring & rId, const unsigned int & uniqId)
...@@ -237,7 +237,7 @@ void pptx_xml_slideMaster::add_layout(int id, const std::wstring & rId, const un ...@@ -237,7 +237,7 @@ void pptx_xml_slideMaster::add_layout(int id, const std::wstring & rId, const un
layoutsId_.push_back(std::pair<std::wstring, unsigned int>(rId, uniqId)); layoutsId_.push_back(std::pair<std::wstring, unsigned int>(rId, uniqId));
rels_.add(relationship( rId,L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout", rels_.add(relationship( rId,L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
std::wstring(L"../slideLayouts/slideLayout") + boost::lexical_cast<std::wstring>(id) + L".xml")); std::wstring(L"../slideLayouts/slideLayout") + std::to_wstring(id) + L".xml"));
} }
void pptx_xml_slideMaster::write_to(std::wostream & strm) void pptx_xml_slideMaster::write_to(std::wostream & strm)
...@@ -299,6 +299,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm) ...@@ -299,6 +299,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
} }
} }
//---------------------------------------------------------------------------------------------------------
pptx_xml_theme_ptr pptx_xml_theme::create(std::wstring const & name,int id) pptx_xml_theme_ptr pptx_xml_theme::create(std::wstring const & name,int id)
{ {
return boost::make_shared<pptx_xml_theme>(name,id); return boost::make_shared<pptx_xml_theme>(name,id);
...@@ -336,6 +337,7 @@ void pptx_xml_theme::write_to(std::wostream & strm) ...@@ -336,6 +337,7 @@ void pptx_xml_theme::write_to(std::wostream & strm)
} }
} }
} }
//---------------------------------------------------------------------------------------------------------
pptx_xml_authors_comments_ptr pptx_xml_authors_comments::create() pptx_xml_authors_comments_ptr pptx_xml_authors_comments::create()
{ {
return boost::make_shared<pptx_xml_authors_comments>(); return boost::make_shared<pptx_xml_authors_comments>();
...@@ -399,6 +401,7 @@ void pptx_xml_authors_comments::write_to(std::wostream & strm) ...@@ -399,6 +401,7 @@ void pptx_xml_authors_comments::write_to(std::wostream & strm)
} }
} }
//---------------------------------------------------------------------------------------------------------
void pptx_xml_presentation::write_to(std::wostream & strm) void pptx_xml_presentation::write_to(std::wostream & strm)
{ {
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
...@@ -428,5 +431,152 @@ void pptx_xml_presentation::write_to(std::wostream & strm) ...@@ -428,5 +431,152 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
} }
} }
} }
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideNotes::rId() const
{
return rId_;
}
pptx_xml_slideNotes_ptr pptx_xml_slideNotes::create(int id)
{
const std::wstring rId = std::wstring(L"nId") + std::to_wstring(id);
return boost::make_shared<pptx_xml_slideNotes>(rId);
}
pptx_xml_slideNotes::pptx_xml_slideNotes(std::wstring const & id)
{
rId_ = id;
}
pptx_xml_slideNotes::~pptx_xml_slideNotes()
{
}
std::wostream & pptx_xml_slideNotes::Data()
{
return slideData_;
}
std::wostream & pptx_xml_slideNotes::Background()
{
return slideBackground_;
}
rels & pptx_xml_slideNotes::Rels()
{
return rels_;
}
void pptx_xml_slideNotes::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:notes")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
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:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << slideBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideData_.str();
}
}
CP_XML_NODE(L"p:clrMapOvr")
{
CP_XML_NODE(L"a:masterClrMapping");
}
}
}
}
//---------------------------------------------------------------------------------------------------------
std::wstring pptx_xml_slideNotesMaster::rId() const
{
return rId_;
}
pptx_xml_slideNotesMaster_ptr pptx_xml_slideNotesMaster::create()
{
const std::wstring rId = std::wstring(L"nmId1");
return boost::make_shared<pptx_xml_slideNotesMaster>(rId, 1);
}
pptx_xml_slideNotesMaster::pptx_xml_slideNotesMaster(std::wstring const & rId, int id)
{
rId_ = rId;
id_ = id;
}
pptx_xml_slideNotesMaster::~pptx_xml_slideNotesMaster()
{
}
std::wostream & pptx_xml_slideNotesMaster::Data()
{
return slideMasterData_;
}
std::wostream & pptx_xml_slideNotesMaster::Background()
{
return slideMasterBackground_;
}
rels & pptx_xml_slideNotesMaster::Rels()
{
return rels_;
}
void pptx_xml_slideNotesMaster::add_theme(int id, const std::wstring & tId)
{
rels_.add(relationship( tId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
std::wstring(L"../theme/theme") + std::to_wstring(id) + L".xml"));
}
void pptx_xml_slideNotesMaster::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:notesMaster")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
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:p14", L"http://schemas.microsoft.com/office/powerpoint/2010/main");
CP_XML_ATTR(L"xmlns:p15", L"http://schemas.microsoft.com/office/powerpoint/2012/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << slideMasterBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideMasterData_.str();
}
}
CP_XML_NODE(L"p:clrMap")
{
CP_XML_ATTR(L"folHlink",L"folHlink");
CP_XML_ATTR(L"hlink",L"hlink");
CP_XML_ATTR(L"accent6",L"accent6");
CP_XML_ATTR(L"accent5",L"accent5");
CP_XML_ATTR(L"accent4",L"accent4");
CP_XML_ATTR(L"accent3",L"accent5");
CP_XML_ATTR(L"accent2",L"accent2");
CP_XML_ATTR(L"accent1",L"accent1");
CP_XML_ATTR(L"tx2",L"dk2");
CP_XML_ATTR(L"tx1",L"dk1");
CP_XML_ATTR(L"bg2",L"lt2");
CP_XML_ATTR(L"bg1",L"lt1");
}
CP_XML_NODE(L"p:notesStyle")
{
}
}
}
}
//---------------------------------------------------------------------------------------------------------
} }
} }
...@@ -49,7 +49,7 @@ class pptx_xml_slide: noncopyable ...@@ -49,7 +49,7 @@ class pptx_xml_slide: noncopyable
public: public:
pptx_xml_slide(std::wstring const & name,std::wstring const & id); pptx_xml_slide(std::wstring const & name,std::wstring const & id);
~pptx_xml_slide(); ~pptx_xml_slide();
public:
std::wstring name() const; std::wstring name() const;
std::wstring rId() const; std::wstring rId() const;
...@@ -72,19 +72,47 @@ private: ...@@ -72,19 +72,47 @@ private:
rels rels_; rels rels_;
}; };
//////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------
class pptx_xml_slideNotes;
typedef _CP_PTR(pptx_xml_slideNotes) pptx_xml_slideNotes_ptr;
class pptx_xml_slideNotes: noncopyable
{
public:
pptx_xml_slideNotes(std::wstring const & id);
~pptx_xml_slideNotes();
std::wstring rId() const;
std::wostream & Data();
std::wostream & Background();
rels & Rels();
void write_to(std::wostream & strm);
static pptx_xml_slideNotes_ptr create(int id);
private:
std::wstringstream slideData_;
std::wstringstream slideBackground_;
std::wstring rId_;
rels rels_;
};
//------------------------------------------------------------------------------------
class pptx_xml_presentation: noncopyable class pptx_xml_presentation: noncopyable
{ {
public: public:
pptx_xml_presentation(){} pptx_xml_presentation(){}
~pptx_xml_presentation(){} ~pptx_xml_presentation(){}
std::wstringstream & slidesData(){return slidesData_;} std::wstringstream & slidesData() {return slidesData_;}
std::wstringstream & slideMastersData(){return slideMastersData_;} std::wstringstream & slideMastersData() {return slideMastersData_;}
std::wstringstream & notesSlidesData(){return notesSlidesData_;} std::wstringstream & notesSlidesData() {return notesSlidesData_;}
std::wstringstream & slidesProperties(){return slidesProperties_;} std::wstringstream & slidesProperties() {return slidesProperties_;}
std::wstringstream & notesSlidesSize(){return notesSlidesSize_;} std::wstringstream & notesSlidesSize() {return notesSlidesSize_;}
void write_to(std::wostream & strm); void write_to(std::wostream & strm);
...@@ -92,14 +120,13 @@ private: ...@@ -92,14 +120,13 @@ private:
std::wstringstream slidesProperties_; std::wstringstream slidesProperties_;
std::wstringstream notesSlidesSize_; std::wstringstream notesSlidesSize_;
std::wstringstream slidesData_; std::wstringstream slidesData_;
std::wstringstream slideMastersData_; std::wstringstream slideMastersData_;
std::wstringstream notesSlidesData_; std::wstringstream notesSlidesData_;
std::wstringstream handoutMasterData_; std::wstringstream handoutMasterData_;
}; };
////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------
class pptx_xml_slideLayout; class pptx_xml_slideLayout;
typedef _CP_PTR(pptx_xml_slideLayout) pptx_xml_slideLayout_ptr; typedef _CP_PTR(pptx_xml_slideLayout) pptx_xml_slideLayout_ptr;
...@@ -126,7 +153,7 @@ private: ...@@ -126,7 +153,7 @@ private:
rels rels_; rels rels_;
}; };
/////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------
class pptx_xml_slideMaster; class pptx_xml_slideMaster;
typedef _CP_PTR(pptx_xml_slideMaster) pptx_xml_slideMaster_ptr; typedef _CP_PTR(pptx_xml_slideMaster) pptx_xml_slideMaster_ptr;
...@@ -135,7 +162,7 @@ class pptx_xml_slideMaster: noncopyable ...@@ -135,7 +162,7 @@ class pptx_xml_slideMaster: noncopyable
public: public:
pptx_xml_slideMaster(std::wstring const & rId, int id); pptx_xml_slideMaster(std::wstring const & rId, int id);
~pptx_xml_slideMaster(); ~pptx_xml_slideMaster();
public:
std::wstring rId() const; std::wstring rId() const;
std::wostream & Data(); std::wostream & Data();
...@@ -163,7 +190,40 @@ private: ...@@ -163,7 +190,40 @@ private:
rels rels_; rels rels_;
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------
class pptx_xml_slideNotesMaster;
typedef _CP_PTR(pptx_xml_slideNotesMaster) pptx_xml_slideNotesMaster_ptr;
class pptx_xml_slideNotesMaster: noncopyable
{
public:
pptx_xml_slideNotesMaster(std::wstring const & rId, int id);
~pptx_xml_slideNotesMaster();
std::wstring rId() const;
std::wostream & Data();
std::wostream & Background();
rels & Rels();
void add_theme(int id, const std::wstring & tId);
void write_to(std::wostream & strm);
static pptx_xml_slideNotesMaster_ptr create();
private:
std::wstringstream slideMasterData_;
std::wstringstream slideMasterBackground_;
std::wstring rId_;
int id_;
std::wstring themeId_;
rels rels_;
};
//------------------------------------------------------------------------------------
class pptx_xml_theme; class pptx_xml_theme;
typedef _CP_PTR(pptx_xml_theme) pptx_xml_theme_ptr; typedef _CP_PTR(pptx_xml_theme) pptx_xml_theme_ptr;
...@@ -192,7 +252,7 @@ private: ...@@ -192,7 +252,7 @@ private:
std::wstring name_; std::wstring name_;
int id_; int id_;
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------
class pptx_xml_authors_comments; class pptx_xml_authors_comments;
typedef _CP_PTR(pptx_xml_authors_comments) pptx_xml_authors_comments_ptr; typedef _CP_PTR(pptx_xml_authors_comments) pptx_xml_authors_comments_ptr;
......
...@@ -105,10 +105,11 @@ void slide_content::add_rels(rels & _r) ...@@ -105,10 +105,11 @@ void slide_content::add_rels(rels & _r)
rels_->get_rels().add(r[i]); rels_->get_rels().add(r[i]);
} }
} }
//////////// //---------------------------------------------------------------------------
slides_files::slides_files() slides_files::slides_files()
{} {
rels_ = NULL;
}
void slides_files::add_slide(slide_content_ptr slide) void slides_files::add_slide(slide_content_ptr slide)
{ {
...@@ -127,13 +128,13 @@ void slides_files::write(const std::wstring & RootPath) ...@@ -127,13 +128,13 @@ void slides_files::write(const std::wstring & RootPath)
{ {
if (!slides_[i]) continue; if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slide") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml"; const std::wstring fileName = std::wstring(L"slide") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType); contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType);
if (rels_) if (rels_)
{ {
const std::wstring id = std::wstring(L"sId") + boost::lexical_cast<std::wstring>( i + 1); const std::wstring id = std::wstring(L"sId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"; static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
const std::wstring fileRef = std::wstring(L"slides/") + fileName; const std::wstring fileRef = std::wstring(L"slides/") + fileName;
rels_->add(id, kWSRel, fileRef); rels_->add(id, kWSRel, fileRef);
...@@ -149,7 +150,42 @@ void slides_files::write(const std::wstring & RootPath) ...@@ -149,7 +150,42 @@ void slides_files::write(const std::wstring & RootPath)
} }
} }
//////////////////////////////////////////// //---------------------------------------------------------------------------
void notes_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"notesSlides" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
for (int i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"notesSlide") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/notesSlides/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"nId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
const std::wstring fileRef = std::wstring(L"notesSlides/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
}
}
//---------------------------------------------------------------------------
slideMasters_files::slideMasters_files() slideMasters_files::slideMasters_files()
{} {}
...@@ -170,12 +206,12 @@ void slideMasters_files::write(const std::wstring & RootPath) ...@@ -170,12 +206,12 @@ void slideMasters_files::write(const std::wstring & RootPath)
{ {
if (!slides_[i]) continue; if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slideMaster") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml"; const std::wstring fileName = std::wstring(L"slideMaster") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType); contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType);
if (rels_) if (rels_)
{ {
const std::wstring id = std::wstring(L"smId") + boost::lexical_cast<std::wstring>( i + 1); const std::wstring id = std::wstring(L"smId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster"; static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName; const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName;
rels_->add(id, kWSRel, fileRef); rels_->add(id, kWSRel, fileRef);
...@@ -191,7 +227,41 @@ void slideMasters_files::write(const std::wstring & RootPath) ...@@ -191,7 +227,41 @@ void slideMasters_files::write(const std::wstring & RootPath)
} }
} }
//////////////////////////////////////////// //---------------------------------------------------------------------------
void notesMaster_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"notesMasters" ;
NSDirectory::CreateDirectory(path.c_str());
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
for (int i = 0; i < slides_.size(); i++)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"notesMaster") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/notesMasters/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"nmId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster";
const std::wstring fileRef = std::wstring(L"notesMasters/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
}
}
slideLayouts_files::slideLayouts_files() slideLayouts_files::slideLayouts_files()
{} {}
...@@ -209,7 +279,7 @@ void slideLayouts_files::write(const std::wstring & RootPath) ...@@ -209,7 +279,7 @@ void slideLayouts_files::write(const std::wstring & RootPath)
{ {
if (!slides_[i]) continue; if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slideLayout") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml"; const std::wstring fileName = std::wstring(L"slideLayout") + std::to_wstring( i + 1 ) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"; const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content(); content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
...@@ -225,7 +295,7 @@ void slideLayouts_files::write(const std::wstring & RootPath) ...@@ -225,7 +295,7 @@ void slideLayouts_files::write(const std::wstring & RootPath)
} }
} }
/////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------
authors_comments_element::authors_comments_element(pptx_xml_authors_comments_ptr & authors_comments) : authors_comments_(authors_comments) authors_comments_element::authors_comments_element(pptx_xml_authors_comments_ptr & authors_comments) : authors_comments_(authors_comments)
{ {
} }
...@@ -261,7 +331,7 @@ void ppt_charts_files::write(const std::wstring & RootPath) ...@@ -261,7 +331,7 @@ void ppt_charts_files::write(const std::wstring & RootPath)
{ {
if (!charts_[i]) continue; if (!charts_[i]) continue;
const std::wstring fileName = std::wstring(L"chart") + boost::lexical_cast<std::wstring>( i + 1 ) + L".xml"; const std::wstring fileName = std::wstring(L"chart") + std::to_wstring( i + 1 ) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content(); content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"; static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
...@@ -291,7 +361,7 @@ void ppt_themes_files::write(const std::wstring & RootPath) ...@@ -291,7 +361,7 @@ void ppt_themes_files::write(const std::wstring & RootPath)
{ {
if (!themes_[i]) continue; if (!themes_[i]) continue;
const std::wstring fileName = std::wstring(L"theme") + boost::lexical_cast<std::wstring>( i + 1) + L".xml"; const std::wstring fileName = std::wstring(L"theme") + std::to_wstring( i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml"; const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content(); content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
...@@ -345,6 +415,12 @@ void ppt_files::write(const std::wstring & RootPath) ...@@ -345,6 +415,12 @@ void ppt_files::write(const std::wstring & RootPath)
slideMasters_files_.set_main_document( this->get_main_document() ); slideMasters_files_.set_main_document( this->get_main_document() );
slideMasters_files_.write(path); slideMasters_files_.write(path);
notes_files_.set_main_document( this->get_main_document() );
notes_files_.write(path);
notesMaster_files_.set_rels(&rels_files_);
notesMaster_files_.set_main_document( this->get_main_document() );
notesMaster_files_.write(path);
//rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"ppt/presentation.xml" ) ); //rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"ppt/presentation.xml" ) );
...@@ -412,6 +488,10 @@ void ppt_files::add_slide(slide_content_ptr slide) ...@@ -412,6 +488,10 @@ void ppt_files::add_slide(slide_content_ptr slide)
{ {
slides_files_.add_slide(slide); slides_files_.add_slide(slide);
} }
void ppt_files::add_notes(slide_content_ptr slide)
{
notes_files_.add_slide(slide);
}
void ppt_files::add_slideLayout(slide_content_ptr slide) void ppt_files::add_slideLayout(slide_content_ptr slide)
{ {
slideLayouts_files_.add_slide(slide); slideLayouts_files_.add_slide(slide);
...@@ -420,7 +500,10 @@ void ppt_files::add_slideMaster(slide_content_ptr slide) ...@@ -420,7 +500,10 @@ void ppt_files::add_slideMaster(slide_content_ptr slide)
{ {
slideMasters_files_.add_slide(slide); slideMasters_files_.add_slide(slide);
} }
void ppt_files::add_notesMaster(slide_content_ptr slide)
{
notesMaster_files_.add_slide(slide);
}
void ppt_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts) void ppt_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{ {
if (_Mediaitems.count_image + _Mediaitems.count_media > 0) if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
......
...@@ -41,8 +41,10 @@ namespace cpdoccore { ...@@ -41,8 +41,10 @@ namespace cpdoccore {
namespace oox { namespace oox {
class pptx_xml_presentation; class pptx_xml_presentation;
class pptx_xml_theme; class pptx_xml_theme;
typedef _CP_PTR(pptx_xml_theme) pptx_xml_theme_ptr; typedef _CP_PTR(pptx_xml_theme) pptx_xml_theme_ptr;
class pptx_xml_authors_comments; class pptx_xml_authors_comments;
typedef _CP_PTR(pptx_xml_authors_comments) pptx_xml_authors_comments_ptr; typedef _CP_PTR(pptx_xml_authors_comments) pptx_xml_authors_comments_ptr;
...@@ -55,7 +57,7 @@ public: ...@@ -55,7 +57,7 @@ public:
}; };
/////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------
class slide_content; class slide_content;
typedef _CP_PTR(slide_content) slide_content_ptr; typedef _CP_PTR(slide_content) slide_content_ptr;
...@@ -72,11 +74,10 @@ public: ...@@ -72,11 +74,10 @@ public:
static _CP_PTR(slide_content) create(); static _CP_PTR(slide_content) create();
private: private:
std::wstringstream content_; std::wstringstream content_;
rels_file_ptr rels_; rels_file_ptr rels_;
}; };
//------------------------------------------------------------------------------
// slides_files
class slides_files : public element class slides_files : public element
{ {
public: public:
...@@ -92,12 +93,18 @@ public: ...@@ -92,12 +93,18 @@ public:
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
void set_slide_ref(const std::wstring & ref_file_path,const std::wstring & ref_file_name); void set_slide_ref(const std::wstring & ref_file_path,const std::wstring & ref_file_name);
public:
std::vector<slide_content_ptr> slides_; std::vector<slide_content_ptr> slides_;
rels_files * rels_; rels_files * rels_;
}; };
// slideLayouts_files //------------------------------------------------------------------------------
class notes_files : public slides_files
{
public:
virtual void write(const std::wstring & RootPath);
};
//------------------------------------------------------------------------------
class slideLayouts_files : public element class slideLayouts_files : public element
{ {
public: public:
...@@ -107,12 +114,9 @@ public: ...@@ -107,12 +114,9 @@ public:
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
public:
std::vector<slide_content_ptr> slides_; std::vector<slide_content_ptr> slides_;
}; };
//------------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
class authors_comments_element : public element class authors_comments_element : public element
{ {
public: public:
...@@ -123,9 +127,7 @@ private: ...@@ -123,9 +127,7 @@ private:
pptx_xml_authors_comments_ptr & authors_comments_; pptx_xml_authors_comments_ptr & authors_comments_;
}; };
///////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------
// slideMasters_files
class slideMasters_files : public element class slideMasters_files : public element
{ {
public: public:
...@@ -140,16 +142,19 @@ public: ...@@ -140,16 +142,19 @@ public:
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
public:
std::vector<slide_content_ptr> slides_; std::vector<slide_content_ptr> slides_;
rels_files * rels_; rels_files * rels_;
}; };
/////////////////////////////////////////////////////////// //------------------------------------------------------------------------------
class notesMaster_files : public slideMasters_files
{
public:
virtual void write(const std::wstring & RootPath);
};
//------------------------------------------------------------------------------
class ppt_comments_files; class ppt_comments_files;
typedef _CP_PTR(ppt_comments_files) ppt_comments_files_ptr; typedef _CP_PTR(ppt_comments_files) ppt_comments_files_ptr;
// ppt_comments
class ppt_comments_files: public element class ppt_comments_files: public element
{ {
public: public:
...@@ -165,9 +170,7 @@ private: ...@@ -165,9 +170,7 @@ private:
const std::vector<pptx_comment_elm> & comments_; const std::vector<pptx_comment_elm> & comments_;
}; };
//------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////
// ppt_charts_files
class ppt_charts_files : public element class ppt_charts_files : public element
{ {
public: public:
...@@ -179,8 +182,8 @@ public: ...@@ -179,8 +182,8 @@ public:
std::vector<chart_content_ptr> charts_; std::vector<chart_content_ptr> charts_;
}; };
////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------
// ppt_theme_files
class ppt_themes_files : public element class ppt_themes_files : public element
{ {
public: public:
...@@ -192,13 +195,12 @@ public: ...@@ -192,13 +195,12 @@ public:
std::vector<pptx_xml_theme_ptr> themes_; std::vector<pptx_xml_theme_ptr> themes_;
}; };
/////////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------
class ppt_files : public element class ppt_files : public element
{ {
public: public:
ppt_files(); ppt_files();
public:
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
void set_presentation(pptx_xml_presentation & presentation); void set_presentation(pptx_xml_presentation & presentation);
...@@ -206,9 +208,11 @@ public: ...@@ -206,9 +208,11 @@ public:
void set_styles(element_ptr Element); void set_styles(element_ptr Element);
void set_comments(element_ptr Element); void set_comments(element_ptr Element);
void add_slide(slide_content_ptr sheet); void add_slide (slide_content_ptr sheet);
void add_slideLayout(slide_content_ptr sheet); void add_slideLayout(slide_content_ptr sheet);
void add_slideMaster(slide_content_ptr sheet); void add_slideMaster(slide_content_ptr sheet);
void add_notes (slide_content_ptr sheet);
void add_notesMaster(slide_content_ptr sheet);
void set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts); void set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts);
void add_charts(chart_content_ptr chart); void add_charts(chart_content_ptr chart);
...@@ -217,25 +221,21 @@ public: ...@@ -217,25 +221,21 @@ public:
void set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments); void set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments);
private: private:
rels_files rels_files_; rels_files rels_files_;
slides_files slides_files_; slides_files slides_files_;
slideLayouts_files slideLayouts_files_; slideLayouts_files slideLayouts_files_;
slideMasters_files slideMasters_files_; slideMasters_files slideMasters_files_;
notes_files notes_files_;
notesMaster_files notesMaster_files_;
//slides_files handoutMasters_files_;
ppt_themes_files themes_files_; ppt_themes_files themes_files_;
ppt_charts_files charts_files_; ppt_charts_files charts_files_;
//slides_files notesSlides_files_; element_ptr authors_comments_;
//slides_files notesMasters_files_;
//slides_files handoutMasters_files_;
element_ptr authors_comments_;
element_ptr presentation_; element_ptr presentation_;
element_ptr tableStyles_; element_ptr tableStyles_;
element_ptr comments_; element_ptr comments_;
element_ptr media_; element_ptr media_;
element_ptr embeddings_; element_ptr embeddings_;
...@@ -247,7 +247,6 @@ class pptx_document : public document ...@@ -247,7 +247,6 @@ class pptx_document : public document
public: public:
pptx_document(); pptx_document();
public:
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
virtual content_types_file & get_content_types_file() { return content_type_file_; } virtual content_types_file & get_content_types_file() { return content_type_file_; }
......
...@@ -89,16 +89,19 @@ public: ...@@ -89,16 +89,19 @@ public:
void end_table(); void end_table();
void start_shape(int type); void start_shape(int type);
void end_shape(); void end_shape ();
void set_use_image_replacement(); void set_use_image_replacement();
bool empty() const; bool empty() const;
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void serialize_objects(std::wostream & strm);
void serialize_HeaderFooter(std::wostream & strm); void serialize_HeaderFooter (std::wostream & strm);
void serialize_background(std::wostream & strm, bool always=false); void serialize_animations (std::wostream & strm);
void serialize_animations(std::wostream & strm);
void serialize_objects (std::wostream & strm);
void serialize_background (std::wostream & strm, bool always = false);
void dump_rels(rels & Rels); void dump_rels(rels & Rels);
...@@ -106,7 +109,7 @@ public: ...@@ -106,7 +109,7 @@ public:
mediaitems & get_mediaitems(); mediaitems & get_mediaitems();
void add_background(_oox_fill & fill); void add_background (_oox_fill & fill);
void add_rels( bool isInternal, void add_rels( bool isInternal,
std::wstring const & rid, std::wstring const & rid,
......
...@@ -74,6 +74,8 @@ void draw_page::add_child_element( xml::sax * Reader, const std::wstring & Ns, c ...@@ -74,6 +74,8 @@ void draw_page::add_child_element( xml::sax * Reader, const std::wstring & Ns, c
{ {
if CP_CHECK_NAME(L"anim", L"par") if CP_CHECK_NAME(L"anim", L"par")
CP_CREATE_ELEMENT(animation_); CP_CREATE_ELEMENT(animation_);
else if (L"presentation" == Ns && L"notes" == Name)
CP_CREATE_ELEMENT(presentation_notes_);
else else
CP_CREATE_ELEMENT(content_); CP_CREATE_ELEMENT(content_);
} }
...@@ -202,8 +204,15 @@ void draw_page::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -202,8 +204,15 @@ void draw_page::pptx_convert(oox::pptx_conversion_context & Context)
std::wstring name = L"datetime:" + *attlist_.use_date_time_name_; std::wstring name = L"datetime:" + *attlist_.use_date_time_name_;
pptx_convert_placeHolder(Context, name, presentation_class::date_time); pptx_convert_placeHolder(Context, name, presentation_class::date_time);
} }
Context.end_page();
Context.end_page(); if (presentation_notes_)
{
Context.start_page_notes();
presentation_notes_->pptx_convert(Context);
Context.end_page_notes();
}
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * presentation_footer_decl::ns = L"presentation"; const wchar_t * presentation_footer_decl::ns = L"presentation";
...@@ -296,14 +305,11 @@ void presentation_notes::add_attributes( const xml::attributes_wc_ptr & Attribut ...@@ -296,14 +305,11 @@ void presentation_notes::add_attributes( const xml::attributes_wc_ptr & Attribut
void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context) void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context)
{ {
const std::wstring pageStyleName = attlist_.draw_style_name_.get_value_or(L""); const std::wstring pageStyleName = attlist_.draw_style_name_.get_value_or(L"");
const std::wstring pageName = attlist_.draw_name_.get_value_or(L"");
const std::wstring layoutName = attlist_.page_layout_name_.get_value_or(L""); const std::wstring layoutName = attlist_.page_layout_name_.get_value_or(L"");
const std::wstring masterName = attlist_.master_page_name_.get_value_or(L""); const std::wstring masterName = attlist_.master_page_name_.get_value_or(L"");
_CP_LOG << L"[info][pptx] process note slide" << std::endl; _CP_LOG << L"[info][pptx] process note slide" << std::endl;
Context.start_note(pageName, pageStyleName, layoutName, masterName);
if (attlist_.draw_style_name_) if (attlist_.draw_style_name_)
{ {
style_instance * style_inst = Context.root()->odf_context().styleContainer().style_by_name(pageStyleName,style_family::DrawingPage, false); style_instance * style_inst = Context.root()->odf_context().styleContainer().style_by_name(pageStyleName,style_family::DrawingPage, false);
...@@ -352,7 +358,6 @@ void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -352,7 +358,6 @@ void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context)
// pptx_convert_placeHolder(Context, name, presentation_class::date_time); // pptx_convert_placeHolder(Context, name, presentation_class::date_time);
//} //}
Context.end_note();
} }
} }
......
...@@ -81,6 +81,7 @@ private: ...@@ -81,6 +81,7 @@ private:
office_element_ptr_array content_; office_element_ptr_array content_;
office_element_ptr animation_; office_element_ptr animation_;
office_element_ptr presentation_notes_;
draw_page_attr attlist_; draw_page_attr attlist_;
}; };
......
...@@ -1519,10 +1519,11 @@ void style_master_page::pptx_convert(oox::pptx_conversion_context & Context) ...@@ -1519,10 +1519,11 @@ void style_master_page::pptx_convert(oox::pptx_conversion_context & Context)
} }
} }
BOOST_FOREACH(office_element_ptr elm, content_) for (size_t i = 0; i < content_.size(); i++)
{ {
elm->pptx_convert(Context); content_[i]->pptx_convert(Context);
} }
} }
//////////////// ////////////////
...@@ -1698,9 +1699,9 @@ void style_presentation_page_layout::add_child_element( xml::sax * Reader, const ...@@ -1698,9 +1699,9 @@ void style_presentation_page_layout::add_child_element( xml::sax * Reader, const
} }
void style_presentation_page_layout::pptx_convert(oox::pptx_conversion_context & Context) void style_presentation_page_layout::pptx_convert(oox::pptx_conversion_context & Context)
{ {
BOOST_FOREACH(office_element_ptr elm, content_) for (size_t i = 0; i < content_.size(); i++)
{ {
elm->pptx_convert(Context); content_[i]->pptx_convert(Context);
} }
} }
......
 
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005 # Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OdfFormatWriterLib", "..\source\win32\OdfFormat.vcproj", "{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}"
ProjectSection(ProjectDependencies) = postProject
{C739151F-5384-41DF-A1A6-F089E2C1AD56} = {C739151F-5384-41DF-A1A6-F089E2C1AD56}
{609ED938-3CA8-4BED-B363-25096D4C4812} = {609ED938-3CA8-4BED-B363-25096D4C4812}
{9CAA294E-58C3-4CEB-ABA0-CB9786CA5540} = {9CAA294E-58C3-4CEB-ABA0-CB9786CA5540}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oox2OdfConverter", "..\source\win32\Oox2OdfConverter.vcproj", "{BEE01B53-244A-44E6-8947-ED9342D9247E}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Oox2OdfConverter", "..\source\win32\Oox2OdfConverter.vcproj", "{BEE01B53-244A-44E6-8947-ED9342D9247E}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0} {21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
{A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0} {A100103A-353E-45E8-A9B8-90B87CC5C0B0} = {A100103A-353E-45E8-A9B8-90B87CC5C0B0}
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD} = {E5A67556-44DA-4481-8F87-0A3AEDBD20DD}
{94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A} {94954A67-A853-43B1-A727-6EF2774C5A6A} = {94954A67-A853-43B1-A727-6EF2774C5A6A}
{36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302} {36636678-AE25-4BE6-9A34-2561D1BCF302} = {36636678-AE25-4BE6-9A34-2561D1BCF302}
EndProjectSection EndProjectSection
...@@ -98,14 +89,6 @@ Global ...@@ -98,14 +89,6 @@ Global
Release|x64 = Release|x64 Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Debug|Win32.ActiveCfg = Debug|Win32
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Debug|Win32.Build.0 = Debug|Win32
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Debug|x64.ActiveCfg = Debug|x64
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Debug|x64.Build.0 = Debug|x64
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Release|Win32.ActiveCfg = Release|Win32
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Release|Win32.Build.0 = Release|Win32
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Release|x64.ActiveCfg = Release|x64
{E5A67556-44DA-4481-8F87-0A3AEDBD20DD}.Release|x64.Build.0 = Release|x64
{BEE01B53-244A-44E6-8947-ED9342D9247E}.Debug|Win32.ActiveCfg = Debug|Win32 {BEE01B53-244A-44E6-8947-ED9342D9247E}.Debug|Win32.ActiveCfg = Debug|Win32
{BEE01B53-244A-44E6-8947-ED9342D9247E}.Debug|Win32.Build.0 = Debug|Win32 {BEE01B53-244A-44E6-8947-ED9342D9247E}.Debug|Win32.Build.0 = Debug|Win32
{BEE01B53-244A-44E6-8947-ED9342D9247E}.Debug|x64.ActiveCfg = Debug|x64 {BEE01B53-244A-44E6-8947-ED9342D9247E}.Debug|x64.ActiveCfg = Debug|x64
......
...@@ -2627,15 +2627,15 @@ void odf_drawing_context::set_gradient_angle(double angle) ...@@ -2627,15 +2627,15 @@ void odf_drawing_context::set_gradient_angle(double angle)
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state(style_family::Gradient)->get_office_element().get()); draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state(style_family::Gradient)->get_office_element().get());
if (!gradient) return; if (!gradient) return;
gradient->draw_angle_ = (270- angle) * 10;//(int)((360 - angle)/180. * 3.14159265358979323846); gradient->draw_angle_ = (270 - angle) * 10;//(int)((360 - angle)/180. * 3.14159265358979323846);
} }
void odf_drawing_context::set_gradient_rect(double l, double t, double r,double b) void odf_drawing_context::set_gradient_rect(double l, double t, double r, double b)
{ {
draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state(style_family::Gradient)->get_office_element().get()); draw_gradient * gradient = dynamic_cast<draw_gradient *>(impl_->styles_context_->last_state(style_family::Gradient)->get_office_element().get());
if (!gradient) return; if (!gradient) return;
gradient->draw_cy_ = percent((b-t)/2. + 50.); gradient->draw_cy_ = percent((b - t)/2. + 50.);
gradient->draw_cx_ = percent((r-l)/2. + 50.); gradient->draw_cx_ = percent((r - l)/2. + 50.);
} }
void odf_drawing_context::set_gradient_center(double cx, double cy) void odf_drawing_context::set_gradient_center(double cx, double cy)
{ {
......
...@@ -854,10 +854,10 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB) ...@@ -854,10 +854,10 @@ void OoxConverter::convert(PPTX::Logic::GradFill *oox_grad_fill, DWORD nARGB)
} }
if (oox_grad_fill->path->rect.IsInit()) if (oox_grad_fill->path->rect.IsInit())
{ {
odf_context()->drawing_context()->set_gradient_rect( XmlUtils::GetInteger(oox_grad_fill->path->rect->l.get_value_or(L"")), odf_context()->drawing_context()->set_gradient_rect( XmlUtils::GetInteger(oox_grad_fill->path->rect->l.get_value_or(L"")) / 1000.,
XmlUtils::GetInteger(oox_grad_fill->path->rect->t.get_value_or(L"")), XmlUtils::GetInteger(oox_grad_fill->path->rect->t.get_value_or(L"")) / 1000.,
XmlUtils::GetInteger(oox_grad_fill->path->rect->r.get_value_or(L"")), XmlUtils::GetInteger(oox_grad_fill->path->rect->r.get_value_or(L"")) / 1000.,
XmlUtils::GetInteger(oox_grad_fill->path->rect->b.get_value_or(L""))); XmlUtils::GetInteger(oox_grad_fill->path->rect->b.get_value_or(L"")) / 1000.);
} }
} }
odf_context()->drawing_context()->set_gradient_type(grad_style); odf_context()->drawing_context()->set_gradient_type(grad_style);
......
...@@ -423,8 +423,13 @@ void PptxConverter::convert(PPTX::NotesMaster *oox_notes) ...@@ -423,8 +423,13 @@ void PptxConverter::convert(PPTX::NotesMaster *oox_notes)
odp_context->start_note(true); odp_context->start_note(true);
current_slide = dynamic_cast<OOX::IFileContainer*>(oox_notes); PPTX::Theme* old_theme = current_theme;
PPTX::Logic::ClrMap* old_clrMap = current_clrMap;
current_theme = oox_notes->theme_.operator->();
current_clrMap = &oox_notes->clrMap; current_clrMap = &oox_notes->clrMap;
current_slide = dynamic_cast<OOX::IFileContainer*>(oox_notes);
//PPTX::Logic::TxStyles* current_txStyles = oox_notes->notesStyle.GetPointer(); //PPTX::Logic::TxStyles* current_txStyles = oox_notes->notesStyle.GetPointer();
if (presentation->notesSz.IsInit()) if (presentation->notesSz.IsInit())
...@@ -433,35 +438,46 @@ void PptxConverter::convert(PPTX::NotesMaster *oox_notes) ...@@ -433,35 +438,46 @@ void PptxConverter::convert(PPTX::NotesMaster *oox_notes)
_CP_OPT(odf_types::length) height = odf_types::length(presentation->notesSz->cy / 12700., odf_types::length::pt); _CP_OPT(odf_types::length) height = odf_types::length(presentation->notesSz->cy / 12700., odf_types::length::pt);
odf_context()->page_layout_context()->set_page_size(width, height); odf_context()->page_layout_context()->set_page_size(width, height);
//if (presentation->notesSz->type.IsInit())
//{
// switch(presentation->notesSz->type->GetBYTECode())
// {
// default:
// break;
// }
// odf_context()->page_layout_context()->set_page_orientation
//}
} }
convert_slide(&oox_notes->cSld, NULL, true, true); convert_slide(&oox_notes->cSld, NULL, true, true);
odp_context->end_note(); odp_context->end_note();
current_clrMap = old_clrMap;
current_theme = old_theme;
} }
void PptxConverter::convert(PPTX::NotesSlide *oox_notes) void PptxConverter::convert(PPTX::NotesSlide *oox_notes)
{ {
if (!oox_notes) return; if (!oox_notes) return;
PPTX::Theme* old_theme = current_theme;
PPTX::Logic::ClrMap* old_clrMap = current_clrMap;
smart_ptr<PPTX::NotesMaster> notes_master;
if (!presentation->notesMasterIdLst.empty())
{
std::wstring rId = presentation->notesMasterIdLst[0].rid.get();
notes_master = ((*presentation)[rId]).smart_dynamic_cast<PPTX::NotesMaster>();
}
odp_context->start_note(); odp_context->start_note();
current_slide = dynamic_cast<OOX::IFileContainer*>(oox_notes); if (notes_master.IsInit())
{
current_theme = notes_master->theme_.operator->();
current_clrMap = &notes_master->clrMap;
}
current_slide = dynamic_cast<OOX::IFileContainer*>(oox_notes);
if (oox_notes->clrMapOvr.IsInit() && oox_notes->clrMapOvr->overrideClrMapping.IsInit()) if (oox_notes->clrMapOvr.IsInit() && oox_notes->clrMapOvr->overrideClrMapping.IsInit())
current_clrMap = oox_notes->clrMapOvr->overrideClrMapping.GetPointer(); current_clrMap = oox_notes->clrMapOvr->overrideClrMapping.GetPointer();
//current_txStyles = oox_notes->Master->txStyles.GetPointer();
convert_slide(&oox_notes->cSld, NULL, true, true); convert_slide(&oox_notes->cSld, NULL, true, true);
odp_context->end_note(); odp_context->end_note();
current_clrMap = old_clrMap;
current_theme = old_theme;
} }
void PptxConverter::convert(OOX::WritingElement *oox_unknown) void PptxConverter::convert(OOX::WritingElement *oox_unknown)
......
<?xml version="1.0" encoding="windows-1251"?> <?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8,00" Version="8.00"
Name="Oox2OdfConverter" Name="Oox2OdfConverter"
ProjectGUID="{BEE01B53-244A-44E6-8947-ED9342D9247E}" ProjectGUID="{BEE01B53-244A-44E6-8947-ED9342D9247E}"
RootNamespace="Oox2OdfConverter" RootNamespace="Oox2OdfConverter"
......
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