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

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52803 954022d7-b5bf-4e40-9824-e11837661b57
parent e419c839
......@@ -33,7 +33,7 @@ pptx_conversion_context::
pptx_conversion_context(::cpdoccore::oox::package::pptx_document * outputDocument,
::cpdoccore::odf::odf_document * odfDocument): output_document_(outputDocument),
odf_document_(odfDocument),
pptx_text_context_(odf_document_->odf_context().styleContainer())
pptx_text_context_(odf_document_->odf_context())
,pptx_slide_context_(*this/*, pptx_text_context_*/)
{
}
......@@ -118,6 +118,7 @@ void pptx_conversion_context::start_document()
odf::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
odf::paragraph_format_properties parFormatProperties = calc_paragraph_properties_content(instances);
}
void pptx_conversion_context::end_document()
......@@ -174,7 +175,22 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().add_slideLayout(content);//slideMaster.xml
}
/////////////////////////////////////////////////////////////////////////////////
odf::odf_read_context & context = root()->odf_context();
odf::page_layout_container & pageLayouts = context.pageLayoutContainer();
if ((pageLayouts.master_pages().size()>0) && (pageLayouts.master_pages()[0]->style_master_page_attlist_.style_name_))//default
{
const std::wstring masterStyleName = pageLayouts.master_pages()[0]->style_master_page_attlist_.style_name_->style_name();
const std::wstring pageProperties = root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterStyleName);
odf::page_layout_instance *pages_layouts = root()->odf_context().pageLayoutContainer().page_layout_by_name(pageProperties);
if (pages_layouts)pages_layouts->pptx_convert(*this);
}
pptx_serialize_size(current_presentation().notesSlidesSize(),6858000,9144000,L"p:notesSz");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
output_document_->get_ppt_files().set_presentation(presentation_);
output_document_->get_ppt_files().set_themes(theme_);
......@@ -224,6 +240,11 @@ pptx_xml_theme & pptx_conversion_context::current_theme()
throw std::runtime_error("internal error");
}
}
pptx_xml_presentation & pptx_conversion_context::current_presentation()
{
return presentation_;
}
oox_chart_context & pptx_conversion_context::current_chart()
{
if (!charts_.empty())
......
......@@ -86,6 +86,7 @@ public:
pptx_xml_slideLayout & current_layout();
pptx_xml_slideMaster & current_master();
pptx_xml_theme & current_theme();
pptx_xml_presentation & current_presentation();//
oox_chart_context & current_chart();
pptx_text_context & get_text_context() { return pptx_text_context_; }
......@@ -135,7 +136,7 @@ private:
std::wstring current_master_page_name_;
std::wstring current_layout_page_name_;
};
}
......
......@@ -5,7 +5,17 @@
namespace cpdoccore {
namespace oox {
static void pptx_serialize_size(std::wostream & strm, int cx, int cy,std::wstring node)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(node)
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
}
}
}
static void pptx_serialize_clrScheme(std::wstringstream & strm)
{
CP_XML_WRITER(strm)
......
......@@ -23,36 +23,22 @@ static const std::wstring _docxShapeType[]=
void pptx_serialize_text(std::wostream & strm, const std::vector<odf::_property> & properties)
{
CP_XML_WRITER(strm)
_CP_OPT(std::wstring) strTextContent;
odf::GetProperty(properties,L"text-content",strTextContent);
if (!strTextContent)return;
CP_XML_WRITER(strm)
{
_CP_OPT(std::wstring) strTextContent;
odf::GetProperty(properties,L"text-content",strTextContent);
//if (strTextContent)//???
{
CP_XML_NODE(L"p:txBody")
{
CP_XML_NODE(L"a:bodyPr");//???
//{
// CP_XML_ATTR(L"wrap", L"none");
// CP_XML_ATTR(L"tIns", 0);
// CP_XML_ATTR(L"rIns", 0);
// CP_XML_ATTR(L"lIns", 0);
// CP_XML_ATTR(L"bIns", 0);
// CP_XML_ATTR(L"anchor", L"ctr");
//}
CP_XML_NODE(L"a:lstStyle");
CP_XML_NODE(L"a:p")
{
CP_XML_NODE(L"a:pPr")
{
CP_XML_ATTR(L"algn",L"ctr");
}
if (strTextContent)
{
std::wstring strTest = strTextContent.get();
CP_XML_STREAM() << strTextContent.get();
}
}
CP_XML_NODE(L"p:txBody")
{
CP_XML_NODE(L"a:bodyPr");
CP_XML_NODE(L"a:lstStyle");
if (strTextContent)
{
CP_XML_STREAM() << strTextContent.get();
}
}
}
......@@ -152,6 +138,10 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing const & val)
CP_XML_NODE(L"p:cNvSpPr")//non visual properies ( 1 )
{
if (val.sub_type==1 || val.sub_type==2)CP_XML_ATTR(L"txBox", 1);
CP_XML_NODE(L"a:spLocks")
{
CP_XML_ATTR(L"noGrp", 1);
}
}
CP_XML_NODE(L"p:nvPr")
{
......
......@@ -306,17 +306,10 @@ void pptx_xml_presentation::write_to(std::wostream & strm)
{
CP_XML_STREAM() << slidesData_.str();
}
CP_XML_NODE(L"p:sldSz")
{
CP_XML_ATTR(L"cx",9144000);
CP_XML_ATTR(L"cy",6858000);
CP_XML_ATTR(L"type",L"screen4x3");
}
CP_XML_NODE(L"p:notesSz")
{
CP_XML_ATTR(L"cx",6858000);
CP_XML_ATTR(L"cy",9144000);
}
CP_XML_STREAM() << slidesProperties_.str();
CP_XML_STREAM() << notesSlidesSize_.str();
CP_XML_NODE(L"p:defaultTextStyle")
{
CP_XML_NODE(L"a:defPPr");
......
......@@ -49,9 +49,16 @@ public:
std::wstringstream & slideMastersData(){return slideMastersData_;}
std::wstringstream & notesSlidesData(){return notesSlidesData_;}
std::wstringstream & slidesProperties(){return slidesProperties_;}
std::wstringstream & notesSlidesSize(){return notesSlidesSize_;}
void write_to(std::wostream & strm);
private:
std::wstringstream slidesProperties_;
std::wstringstream notesSlidesSize_;
std::wstringstream slidesData_;
std::wstringstream slideMastersData_;
std::wstringstream notesSlidesData_;
......
......@@ -12,6 +12,7 @@ namespace cpdoccore {
namespace odf
{
class styles_container;
class odf_read_context;
typedef boost::shared_ptr<styles_container> styles_container_ptr;
};
namespace oox {
......@@ -21,7 +22,7 @@ class pptx_conversion_context;
class pptx_text_context: boost::noncopyable
{
public:
pptx_text_context(odf::styles_container & styles_);
pptx_text_context(odf::odf_read_context & odf_context_);
~pptx_text_context();
void set_local_styles_container(odf::styles_container* local_styles_);
......@@ -46,6 +47,12 @@ public:
bool is_drawing_context();
void start_list(const std::wstring & StyleName, bool Continue = false);
void end_list();
void start_list_item(bool restart = false);
void end_list_item();
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
......
......@@ -81,7 +81,25 @@ void list_item::docx_convert(oox::docx_conversion_context & Context)
Context.end_list_item();
}
void list_item::pptx_convert(oox::pptx_conversion_context & Context)
{
bool restart = false;
// TODO - 1
if (text_start_value_)
{
restart = true;
}
Context.get_text_context().start_list_item(restart);
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->pptx_convert(Context);
}
Context.get_text_context().end_list_item();
}
// text:list-header
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * list_header::ns = L"text";
......@@ -101,6 +119,21 @@ void list_header::docx_convert(oox::docx_conversion_context & Context)
//Context.end_list_item();
}
void list_header::pptx_convert(oox::pptx_conversion_context & Context)
{
bool restart = false;
//Context.start_list_item(restart);
//
BOOST_FOREACH(const office_element_ptr & elm, content_)
{
elm->pptx_convert(Context);
}
//Context.end_list_item();
}
::std::wostream & list_header::text_to_stream(::std::wostream & _Wostream) const
{
......
......@@ -57,6 +57,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......@@ -94,6 +95,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......
......@@ -308,6 +308,10 @@ void page_layout_instance::docx_convert(oox::docx_conversion_context & Context)
properties()->docx_convert(Context);
}
void page_layout_instance::pptx_convert(oox::pptx_conversion_context & Context)
{
properties()->pptx_convert(Context);
}
void page_layout_container::add_page_layout(const style_page_layout * StylePageLayout)
{
......
......@@ -154,8 +154,10 @@ public:
page_layout_instance(const style_page_layout * StylePageLayout);
const std::wstring & name() const;
style_page_layout_properties * properties() const;
void docx_convert(oox::docx_conversion_context & Context);
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
const style_page_layout * style_page_layout_;
};
......
#include "precompiled_cpodf.h"
#include "styles.h"
#include <cpdoccore/xml/xmlchar.h>
#include <cpdoccore/xml/serialize.h>
#include <cpdoccore/xml/attributes.h>
#include <cpdoccore/xml/simple_xml_writer.h>
#include <iostream>
#include <boost/foreach.hpp>
......@@ -19,6 +21,8 @@
#include <cpdoccore/odf/odf_document.h>
#include "odfcontext.h"
namespace cpdoccore {
namespace odf {
......@@ -835,6 +839,51 @@ void style_page_layout_properties_attlist::docx_convert(oox::docx_conversion_con
}
}
void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_context & Context)
{
std::wostream & strm = Context.current_presentation().slidesProperties();
if (fo_page_width_ || fo_page_height_ || style_print_orientation_)
{
std::wstring w_w = L"",w_h = L"";
int h=0,w=0;
if (fo_page_width_)
{
w = fo_page_width_->get_value_unit(length::emu);
w_w = boost::lexical_cast<std::wstring>(w);
}
if (fo_page_height_)
{
h = fo_page_height_->get_value_unit(length::emu);
w_h = boost::lexical_cast<std::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-footnote-sep-attlist
void style_footnote_sep_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
......@@ -876,7 +925,6 @@ void style_page_layout_properties::add_child_element( xml::sax * Reader, const :
{
style_page_layout_properties_elements_.add_child_element(Reader, Ns, Name, getContext());
}
void style_page_layout_properties::docx_convert(oox::docx_conversion_context & Context)
{
if (Context.get_drawing_context().get_current_level()>0) return;
......@@ -940,6 +988,10 @@ void style_page_layout_properties::docx_convert(oox::docx_conversion_context & C
}
void style_page_layout_properties::pptx_convert(oox::pptx_conversion_context & Context)
{
style_page_layout_properties_attlist_.pptx_convert(Context);
}
// style-page-layout-properties-elements
......
......@@ -793,6 +793,7 @@ public:
void add_attributes( const xml::attributes_wc_ptr & Attributes );
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
public:
_CP_OPT(length) fo_page_width_; // +
......@@ -934,6 +935,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context);
const style_page_layout_properties_attlist & get_style_page_layout_properties_attlist() const
{
......
......@@ -105,7 +105,6 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
std::wostream & _Wostream = Context.output_stream();
if (!Attr.text_style_name_.empty())
{
if (style_instance * styleInst
= Context.root()->odf_context().styleContainer().style_by_name(Attr.text_style_name_.style_name(), style_family::Paragraph,Context.process_headers_footers_)
)
......@@ -119,8 +118,10 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
if (const style_instance * parentStyleContent = styleInst->parent())
id = Context.get_style_map().get( parentStyleContent->name(), parentStyleContent->type() );
Context.start_automatic_style(id);
styleContent->docx_convert(Context);
Context.end_automatic_style();
styleContent->docx_convert(Context);
Context.end_automatic_style();
Context.push_text_properties(styleContent->get_style_text_properties());
return 1;
}
......@@ -129,9 +130,9 @@ int process_paragraph_attr(const paragraph_attrs & Attr, oox::docx_conversion_co
{
const std::wstring id = Context.get_style_map().get( styleInst->name(), styleInst->type() );
_Wostream << L"<w:pPr>";
Context.process_page_properties();
_Wostream << L"<w:pStyle w:val=\"" << id << L"\" />";
Context.write_list_properties();
Context.process_page_properties();
_Wostream << L"<w:pStyle w:val=\"" << id << L"\" />";
Context.write_list_properties();
_Wostream << L"</w:pPr>";
return 2;
}
......@@ -517,7 +518,21 @@ void list::docx_convert(oox::docx_conversion_context & Context)
Context.end_list();
}
void list::pptx_convert(oox::pptx_conversion_context & Context)
{
bool continue_ = text_continue_numbering_.get_value_or(false);
Context.get_text_context().start_list(text_style_name_.style_name(), continue_);
if (text_list_header_)
text_list_header_->pptx_convert(Context);
BOOST_FOREACH(const office_element_ptr & elm, text_list_items_)
{
elm->pptx_convert(Context);
}
Context.get_text_context().end_list();
}
// text:soft-page-break
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * soft_page_break::ns = L"text";
......@@ -668,7 +683,13 @@ void text_index_body::docx_convert(oox::docx_conversion_context & Context)
elm->docx_convert(Context);
}
}
void text_index_body::pptx_convert(oox::pptx_conversion_context & Context)
{
BOOST_FOREACH(const office_element_ptr & elm, index_content_main_)
{
elm->pptx_convert(Context);
}
}
// text:index-title
// text-index-title
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -682,7 +703,13 @@ void text_index_title::docx_convert(oox::docx_conversion_context & Context)
elm->docx_convert(Context);
}
}
void text_index_title::pptx_convert(oox::pptx_conversion_context & Context)
{
BOOST_FOREACH(office_element_ptr & elm, index_content_main_)
{
elm->pptx_convert(Context);
}
}
::std::wostream & text_index_title::text_to_stream(::std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(index_content_main_);
......@@ -711,6 +738,13 @@ void text_table_of_content::docx_convert(oox::docx_conversion_context & Context)
text_index_body_->docx_convert(Context);
}
void text_table_of_content::pptx_convert(oox::pptx_conversion_context & Context)
{
if (text_index_body_)
text_index_body_->pptx_convert(Context);
}
::std::wostream & text_table_of_content::text_to_stream(::std::wostream & _Wostream) const
{
CP_SERIALIZE_TEXT(text_index_body_);
......
......@@ -157,6 +157,7 @@ public:
public:
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
......@@ -223,6 +224,7 @@ public:
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
//void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......@@ -290,8 +292,11 @@ public:
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextTableOfContent;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......@@ -319,7 +324,9 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextIndexBody;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......@@ -346,7 +353,9 @@ public:
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTextIndexTitle;
CPDOCCORE_DEFINE_VISITABLE();
void docx_convert(oox::docx_conversion_context & Context);
void pptx_convert(oox::pptx_conversion_context & Context) ;
void docx_convert(oox::docx_conversion_context & Context);
public:
virtual ::std::wostream & text_to_stream(::std::wostream & _Wostream) const;
......
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