Commit be65f18a authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatReader - presentation master notes

parent 60f61109
......@@ -199,9 +199,9 @@ void pptx_conversion_context::process_theme(std::wstring name)
}
start_theme(name);
//
pptx_serialize_clrScheme(current_theme().clrSchemeData());
pptx_serialize_fmtScheme(current_theme().fmtSchemeData());
pptx_serialize_fontScheme(current_theme().fontSchemeData());
pptx_serialize_clrScheme (current_theme().clrSchemeData());
pptx_serialize_fmtScheme (current_theme().fmtSchemeData());
pptx_serialize_fontScheme (current_theme().fontSchemeData());
//
end_theme();
......@@ -222,8 +222,6 @@ void pptx_conversion_context::start_document()
void pptx_conversion_context::end_document()
{
unsigned int count = 1;
for (size_t i = 0; i < slideMasters_.size(); i++)
{
pptx_xml_slideMaster_ptr& slideM = slideMasters_[i];
......@@ -243,10 +241,11 @@ void pptx_conversion_context::end_document()
CP_XML_ATTR(L"r:id", slideM->rId());
}
}
count++;
}
if (!slideMasters_.empty())
presentation_.slidesProperties() << slideMasters_[0]->Sizes().str();
////////////////////////////////////////////////////////////////////////////////////////////////////
count=0;
for (size_t i = 0; i < slides_.size(); i++)
{
pptx_xml_slide_ptr& slide = slides_[i];
......@@ -262,11 +261,10 @@ void pptx_conversion_context::end_document()
{
CP_XML_NODE(L"p:sldId")
{
CP_XML_ATTR(L"id", 0x100 + count);
CP_XML_ATTR(L"id", 0x100 + i);
CP_XML_ATTR(L"r:id", slide->rId());
}
}
count++;
}
//----------------------------------------------------------------------------------
for (size_t i = 0; i < slideLayouts_.size(); i++)
......@@ -300,31 +298,22 @@ void pptx_conversion_context::end_document()
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::page_layout_container & pageLayouts = context.pageLayoutContainer();
if ((pageLayouts.master_pages().size() > 0) && (pageLayouts.master_pages()[0]->attlist_.style_name_))//default
CP_XML_WRITER(presentation_.slideNotesMastersData())//presentation.xml
{
const std::wstring masterStyleName = pageLayouts.master_pages()[0]->attlist_.style_name_.get();
const std::wstring pageProperties = root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterStyleName);
odf_reader::page_layout_instance *pages_layouts = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties);
if (pages_layouts)pages_layouts->pptx_convert(*this);
CP_XML_NODE(L"p:notesMasterId")
{
CP_XML_ATTR(L"r:id", slideNotesMaster_->rId());
}
/////////////////////////////////////////////////////////////////////////////////////////////
pptx_serialize_size(current_presentation().notesSlidesSize(),6858000,9144000,L"p:notesSz");
}
}
//else
pptx_serialize_size(current_presentation().slidesNotesProperties(), 6858000, 9144000, L"p:notesSz");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//добавляем диаграммы
count = 0;
for (size_t i = 0; i < charts_.size(); i++)
{
count++;
package::chart_content_ptr content = package::chart_content::create();
charts_[i]->serialize(content->content());
......@@ -334,7 +323,6 @@ void pptx_conversion_context::end_document()
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//добавляем темы
for (size_t i=0; i < themes_.size(); i++)
{
output_document_->get_ppt_files().add_theme(themes_[i]);
......@@ -569,6 +557,14 @@ bool pptx_conversion_context::start_master(int master_index)
current_master().add_layout(masters.content[master_index].layouts[i].Id, masters.content[master_index].layouts[i].rId, 0x80000000 + last_uniq_big_id++);
}
//----------------------------------------------------------------------------------
//размеры страниц в презентации
const std::wstring pageProperties = root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masters.content[master_index].master_name);
odf_reader::page_layout_instance *pages_layouts = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties);
if (pages_layouts)
pages_layouts->pptx_serialize(current_master().Sizes(), *this);
return true;
}
......@@ -597,10 +593,14 @@ bool pptx_conversion_context::start_page_notes()
{
create_new_slideNotes( );
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"));
current_slide().Rels().add(relationship(notes_.back()->rId(), L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
L"../notesSlides/notesSlide" + std::to_wstring(notes_.size()) + L".xml"));
get_slide_context().start_slide();
current_notes().Rels().add(relationship(L"nId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
L"../slides/slide" + std::to_wstring(slides_.size()) + L".xml"));
return true;
}
......@@ -617,8 +617,10 @@ bool pptx_conversion_context::start_master_notes()
{
create_new_slideNotesMaster( );
//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().start_slide();
process_theme(L"");//add default theme - одинаковые но под разными именами
current_notesMaster().add_theme(current_theme().id(), L"tId1");
get_slide_context().start_slide();
return true;
......@@ -632,6 +634,13 @@ void pptx_conversion_context::end_master_notes()
get_slide_context().dump_rels(current_notesMaster().Rels());//hyperlinks, mediaitems, ...
get_slide_context().end_slide();
for (size_t i = 0; i < notes_.size(); i++)
{
notes_[i]->Rels().add(relationship(L"nmId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
L"../notesMasters/notesMaster1.xml"));
}
}
void pptx_conversion_context::end_layout()
{
......
......@@ -68,15 +68,15 @@ pptx_xml_slide::~pptx_xml_slide()
}
std::wostream & pptx_xml_slide::Data()
{
return slideData_;
return strmData_;
}
std::wostream & pptx_xml_slide::Background()
{
return slideBackground_;
return strmBackground_;
}
std::wostream & pptx_xml_slide::Timing()
{
return slideTiming_;
return strmTiming_;
}
rels & pptx_xml_slide::Rels()
{
......@@ -100,14 +100,14 @@ void pptx_xml_slide::write_to(std::wostream & strm)
{
CP_XML_ATTR(L"name", name());
CP_XML_STREAM() << slideBackground_.str();
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideData_.str();
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_STREAM() << slideTiming_.str();
CP_XML_STREAM() << strmTiming_.str();
CP_XML_NODE(L"p:clrMapOvr")
{
CP_XML_NODE(L"a:masterClrMapping");
......@@ -137,7 +137,7 @@ pptx_xml_slideLayout::~pptx_xml_slideLayout()
}
std::wostream & pptx_xml_slideLayout::Data()
{
return slideLayoutData_;
return strmData_;
}
rels & pptx_xml_slideLayout::Rels()
{
......@@ -166,7 +166,7 @@ void pptx_xml_slideLayout::write_to(std::wostream & strm)
{
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideLayoutData_.str();
CP_XML_STREAM() << strmData_.str();
//в slideLayoutData_
//contentPart (Content Part) §19.3.1.14
......@@ -212,15 +212,19 @@ pptx_xml_slideMaster::~pptx_xml_slideMaster()
}
std::wostream & pptx_xml_slideMaster::Data()
{
return slideMasterData_;
return strmData_;
}
std::wostream & pptx_xml_slideMaster::DataExtra()
{
return slideMasterDataExtra_;
return strmDataExtra_;
}
std::wostream & pptx_xml_slideMaster::Background()
{
return slideMasterBackground_;
return strmBackground_;
}
std::wstringstream & pptx_xml_slideMaster::Sizes()
{
return strmSizes_;
}
rels & pptx_xml_slideMaster::Rels()
{
......@@ -255,11 +259,11 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << slideMasterBackground_.str();
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideMasterData_.str();
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_NODE(L"p:clrMap")
......@@ -288,7 +292,7 @@ void pptx_xml_slideMaster::write_to(std::wostream & strm)
}
}
}
CP_XML_STREAM() << slideMasterDataExtra_.str();
CP_XML_STREAM() << strmDataExtra_.str();
CP_XML_NODE(L"p:txStyles")
{
CP_XML_NODE(L"p:titleStyle");
......@@ -415,6 +419,10 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
CP_XML_NODE(L"p:sldMasterIdLst")
{
CP_XML_STREAM() << slideMastersData_.str();
}
CP_XML_NODE(L"p:notesMasterIdLst")
{
CP_XML_STREAM() << slideNotesMastersData_.str();
}
CP_XML_NODE(L"p:sldIdLst")
{
......@@ -422,7 +430,7 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
}
CP_XML_STREAM() << slidesProperties_.str();
CP_XML_STREAM() << notesSlidesSize_.str();
CP_XML_STREAM() << slidesNotesProperties_.str();
CP_XML_NODE(L"p:defaultTextStyle")//??
{
......@@ -453,11 +461,11 @@ pptx_xml_slideNotes::~pptx_xml_slideNotes()
}
std::wostream & pptx_xml_slideNotes::Data()
{
return slideData_;
return strmData_;
}
std::wostream & pptx_xml_slideNotes::Background()
{
return slideBackground_;
return strmBackground_;
}
rels & pptx_xml_slideNotes::Rels()
......@@ -480,11 +488,11 @@ void pptx_xml_slideNotes::write_to(std::wostream & strm)
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << slideBackground_.str();
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideData_.str();
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_NODE(L"p:clrMapOvr")
......@@ -517,12 +525,15 @@ pptx_xml_slideNotesMaster::~pptx_xml_slideNotesMaster()
}
std::wostream & pptx_xml_slideNotesMaster::Data()
{
return slideMasterData_;
return strmData_;
}
std::wostream & pptx_xml_slideNotesMaster::Background()
{
return slideMasterBackground_;
return strmBackground_;
}
std::wostream & pptx_xml_slideNotesMaster::Sizes()
{
return strmSizes_;
}
rels & pptx_xml_slideNotesMaster::Rels()
{
......@@ -549,11 +560,11 @@ void pptx_xml_slideNotesMaster::write_to(std::wostream & strm)
CP_XML_NODE(L"p:cSld")
{
CP_XML_STREAM() << slideMasterBackground_.str();
CP_XML_STREAM() << strmBackground_.str();
CP_XML_NODE(L"p:spTree")
{
CP_XML_STREAM() << slideMasterData_.str();
CP_XML_STREAM() << strmData_.str();
}
}
CP_XML_NODE(L"p:clrMap")
......
......@@ -65,9 +65,9 @@ public:
private:
std::wstring name_;
std::wstringstream slideData_;
std::wstringstream slideBackground_;
std::wstringstream slideTiming_;
std::wstringstream strmData_;
std::wstringstream strmBackground_;
std::wstringstream strmTiming_;
std::wstring rId_;
rels rels_;
......@@ -94,8 +94,8 @@ public:
static pptx_xml_slideNotes_ptr create(int id);
private:
std::wstringstream slideData_;
std::wstringstream slideBackground_;
std::wstringstream strmData_;
std::wstringstream strmBackground_;
std::wstring rId_;
rels rels_;
......@@ -109,21 +109,21 @@ public:
std::wstringstream & slidesData() {return slidesData_;}
std::wstringstream & slideMastersData() {return slideMastersData_;}
std::wstringstream & notesSlidesData() {return notesSlidesData_;}
std::wstringstream & slideNotesMastersData() {return slideNotesMastersData_;}
std::wstringstream & slidesProperties() {return slidesProperties_;}
std::wstringstream & notesSlidesSize() {return notesSlidesSize_;}
std::wstringstream & slidesNotesProperties() {return slidesNotesProperties_;}
void write_to(std::wostream & strm);
private:
std::wstringstream slidesProperties_;
std::wstringstream notesSlidesSize_;
std::wstringstream slidesNotesProperties_;
std::wstringstream slidesData_;
std::wstringstream slideMastersData_;
std::wstringstream notesSlidesData_;
std::wstringstream handoutMasterData_;
std::wstringstream slideNotesMastersData_;
std::wstringstream slideHandoutMasterData_;
};
//------------------------------------------------------------------------------------
......@@ -148,7 +148,7 @@ public:
static pptx_xml_slideLayout_ptr create(int id);
private:
std::wstringstream slideLayoutData_;
std::wstringstream strmData_;
std::wstring rId_;
rels rels_;
......@@ -168,6 +168,7 @@ public:
std::wostream & Data();
std::wostream & DataExtra();
std::wostream & Background();
std::wstringstream & Sizes();
rels & Rels();
void add_layout(int id, const std::wstring & rId, const unsigned int & uniqId);
......@@ -178,9 +179,10 @@ public:
static pptx_xml_slideMaster_ptr create(int id);
private:
std::wstringstream slideMasterData_;
std::wstringstream slideMasterDataExtra_;
std::wstringstream slideMasterBackground_;
std::wstringstream strmData_;
std::wstringstream strmDataExtra_;
std::wstringstream strmBackground_;
std::wstringstream strmSizes_;
std::vector<std::pair<std::wstring, unsigned int>> layoutsId_;
std::wstring rId_;
......@@ -204,6 +206,7 @@ public:
std::wostream & Data();
std::wostream & Background();
std::wostream & Sizes();
rels & Rels();
void add_theme(int id, const std::wstring & tId);
......@@ -213,8 +216,9 @@ public:
static pptx_xml_slideNotesMaster_ptr create();
private:
std::wstringstream slideMasterData_;
std::wstringstream slideMasterBackground_;
std::wstringstream strmData_;
std::wstringstream strmBackground_;
std::wstringstream strmSizes_;
std::wstring rId_;
int id_;
......
......@@ -262,46 +262,46 @@ void presentation_notes::add_attributes( const xml::attributes_wc_ptr & Attribut
attlist_.add_attributes(Attributes);
}
//void presentation_notes::pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, presentation_class::type PresentationClass)
//{
// office_element_ptr elm = Context.root()->odf_context().drawStyles().find_by_style_name(styleName);
// //todooo если это элемент datatime -нужно вытащить формат поля
//
// if (!elm)return;
//
// int index=-1;
//
// const std::wstring masterName = attlist_.master_page_name_.get_value_or(L"");
// style_master_page * master = Context.root()->odf_context().pageLayoutContainer().master_page_by_name(masterName);
//
// //if (master)
// // index = master->find_placeHolderIndex(PresentationClass, Context.last_idx_placeHolder);
//
//
// Context.get_slide_context().start_shape(1);
// Context.get_slide_context().set_placeHolder_type(presentation_class(PresentationClass).get_type_ms());
// Context.get_slide_context().set_placeHolder_idx(index);
//
// Context.get_text_context().start_object();
//
// if (PresentationClass == presentation_class::date_time)
// {
// Context.get_text_context().start_field(oox::datetime, L"");
// }
//
// elm->pptx_convert(Context);
//
// std::wstring text_content_ = Context.get_text_context().end_object();
//
// if (text_content_.length()>0)
// {
// Context.get_slide_context().set_property(_property(L"text-content",text_content_));
// }
// Context.get_slide_context().set_property(_property(L"no_rect",true));
// Context.get_slide_context().end_shape();
//
//}
//
void presentation_notes::pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, presentation_class::type PresentationClass)
{
office_element_ptr elm = Context.root()->odf_context().drawStyles().find_by_style_name(styleName);
//todooo если это элемент datatime -нужно вытащить формат поля
if (!elm)return;
int index=-1;
const std::wstring masterName = attlist_.master_page_name_.get_value_or(L"");
style_master_page * master = Context.root()->odf_context().pageLayoutContainer().master_page_by_name(masterName);
//if (master)
// index = master->find_placeHolderIndex(PresentationClass, Context.last_idx_placeHolder);
Context.get_slide_context().start_shape(1);
Context.get_slide_context().set_placeHolder_type(presentation_class(PresentationClass).get_type_ms());
Context.get_slide_context().set_placeHolder_idx(index);
Context.get_text_context().start_object();
if (PresentationClass == presentation_class::date_time)
{
Context.get_text_context().start_field(oox::datetime, L"");
}
elm->pptx_convert(Context);
std::wstring text_content_ = Context.get_text_context().end_object();
if (text_content_.length()>0)
{
Context.get_slide_context().set_property(_property(L"text-content",text_content_));
}
Context.get_slide_context().set_property(_property(L"no_rect",true));
Context.get_slide_context().end_shape();
}
void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context)
{
const std::wstring pageStyleName = attlist_.draw_style_name_.get_value_or(L"");
......@@ -312,7 +312,7 @@ void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context)
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, Context.process_masters_);
if ((style_inst) && (style_inst->content()))
{
......@@ -347,16 +347,16 @@ void presentation_notes::pptx_convert(oox::pptx_conversion_context & Context)
content_[i]->pptx_convert(Context);
}
//if (attlist_.use_footer_name_)//from master_page
//{
// std::wstring name = L"footer:" + *attlist_.use_footer_name_;
// pptx_convert_placeHolder(Context, name, presentation_class::footer);
//}
//if (attlist_.use_date_time_name_)//from master_page
//{
// std::wstring name = L"datetime:" + *attlist_.use_date_time_name_;
// pptx_convert_placeHolder(Context, name, presentation_class::date_time);
//}
if (attlist_.use_footer_name_)//from master_page_notes
{
std::wstring name = L"footer:" + *attlist_.use_footer_name_;
pptx_convert_placeHolder(Context, name, presentation_class::footer);
}
if (attlist_.use_date_time_name_)//from master_page_notes
{
std::wstring name = L"datetime:" + *attlist_.use_date_time_name_;
pptx_convert_placeHolder(Context, name, presentation_class::date_time);
}
}
......
......@@ -150,14 +150,14 @@ public:
static const ElementType type = typePresentationNotes;
CPDOCCORE_DEFINE_VISITABLE();
virtual void pptx_convert(oox::pptx_conversion_context & Context);
private:
void pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, odf_types::presentation_class::type PresentationClass);
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
office_element_ptr_array content_;
draw_page_attr attlist_;
};
......
......@@ -360,11 +360,11 @@ void page_layout_instance::docx_convert_serialize(std::wostream & strm, oox::doc
if (props)
props->docx_convert_serialize(strm, Context);
}
void page_layout_instance::pptx_convert(oox::pptx_conversion_context & Context)
void page_layout_instance::pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context)
{
style_page_layout_properties * props = properties();
if (props)
props->pptx_convert(Context);
props->pptx_serialize(strm, Context);
}
void page_layout_container::add_page_layout(const style_page_layout * StylePageLayout)
......
......@@ -195,7 +195,7 @@ public:
void docx_convert_serialize (std::wostream & strm, oox::docx_conversion_context & Context);
void xlsx_serialize (std::wostream & strm, oox::xlsx_conversion_context & Context);
void pptx_convert (oox::pptx_conversion_context & Context);
void pptx_serialize (std::wostream & strm, oox::pptx_conversion_context & Context);
const style_page_layout * style_page_layout_;
......
......@@ -1378,6 +1378,50 @@ void style_page_layout_properties::pptx_convert(oox::pptx_conversion_context & C
attlist_.pptx_convert(Context);
}
void style_page_layout_properties::pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context)
{
if (attlist_.fo_page_width_ || attlist_.fo_page_height_ || attlist_.style_print_orientation_)
{
std::wstring w_w, w_h;
_INT64 h = 0, w = 0;
if (attlist_.fo_page_width_)
{
w = attlist_.fo_page_width_->get_value_unit(length::emu);
if (w < 914400) w = 914400;
w_w = boost::lexical_cast<std::wstring>(w);
}
if (attlist_.fo_page_height_)
{
h = attlist_.fo_page_height_->get_value_unit(length::emu);
if (h < 914400) h = 914400;
w_h = std::to_wstring(h);
}
std::wstring w_orient = L"custom";
//if (w && h)
//{
// double ratio = (double)w/(double)h;
// if (abs(ratio - 16./9.)<0.01) w_orient = L"screen16x9";
// if (abs(ratio - 4./3.)<0.01) w_orient = L"screen4x3";
//}
strm << L"<p:sldSz ";
if (!w_h.empty())
strm << L"cy=\"" << w_h << L"\" ";
if (!w_w.empty())
strm << L"cx=\"" << w_w << L"\" ";
strm << L"type=\"" << w_orient << L"\" ";
strm << L"/>";
}
}
// style-page-layout-properties-elements
//////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -980,6 +980,7 @@ public:
bool docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id);
void xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context);
void pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context);
style_page_layout_properties() { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment