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

(1.0.0.161): ASCOfficeOdfFile

комментарии
Презентации можно считать сделанными .. версия для тестирования
(остались сноски, action и переходы)

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@53454 954022d7-b5bf-4e40-9824-e11837661b57
parent bf584f95
......@@ -2,6 +2,6 @@
//1
//0
//0
//160
#define INTVER 1,0,0,160
#define STRVER "1,0,0,160\0"
//162
#define INTVER 1,0,0,162
#define STRVER "1,0,0,162\0"
......@@ -1582,6 +1582,22 @@
<Filter
Name="pptx"
>
<File
RelativePath=".\src\docx\pptx_comments.cpp"
>
</File>
<File
RelativePath=".\src\docx\pptx_comments.h"
>
</File>
<File
RelativePath=".\src\docx\pptx_comments_context.cpp"
>
</File>
<File
RelativePath=".\src\docx\pptx_comments_context.h"
>
</File>
<File
RelativePath=".\src\docx\pptx_conversion_context.cpp"
>
......
......@@ -11,7 +11,7 @@ class rels;
class mediaitems
{
public:
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink};
enum Type { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment};
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
{
......
#include "precompiled_cpodf.h"
#include "pptx_comments.h"
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "docx_rels.h"
namespace cpdoccore {
namespace oox {
//unsigned int hex_string_to_int(std::wstring str)
//{
// unsigned int x;
// std::wstringstream ss;
// ss << std::hex << str;
// ss >> x;
// return x;
//}
//
class pptx_comments::Impl
{
public:
void serialize_authors(std::wostream & strm) const
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:cmAuthorLst")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
////<p:cmAuthor id="0" name="" initials="" lastIdx="4" clrIdx="0"/>
////<p:cmAuthor id="1" name="Elen Subbotina" initials="ES" lastIdx="2" clrIdx="1"/>
// int i=0;
// int size = author_list_.size();
// while(true)
// {
// if (i>=size)break;
// CP_XML_NODE(L"p:cmAuthor")
// {
// CP_XML_ATTR(L"id", i);
// CP_XML_STREAM() << author_list_[i];//
// }
// i++;
// }
}
}
}
void serialize(std::wostream & strm) const
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:cmLst")
{
CP_XML_ATTR(L"xmlns:a", L"http://schemas.openxmlformats.org/drawingml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:p", L"http://schemas.openxmlformats.org/presentationml/2006/main");
BOOST_FOREACH(_pptx_comment const & c, pptx_comment_)
{
CP_XML_NODE(L"p:cm")
{
CP_XML_ATTR(L"authorId", c.author_);
CP_XML_NODE(L"p:pos")
{
CP_XML_ATTR(L"y", c.top_);
CP_XML_ATTR(L"x", c.left_);
}
CP_XML_NODE(L"p:text")
{
CP_XML_STREAM() << c.content_;
}
}
}
}
}
}
bool empty() const
{
return ( pptx_comment_.empty());
}
void add(_pptx_comment & c)
{
bool find = false;
for (long i=0;i<author_list_.size();i++)
{
if (c.author_ == author_list_[i])
{
find=true;
c.author_ = boost::lexical_cast<std::wstring>(i);
break;
}
}
if (!find)
{
author_list_.push_back(c.author_);
c.author_ = boost::lexical_cast<std::wstring>(author_list_.size()-1);
}
pptx_comment_.push_back(c);
}
private:
std::vector<std::wstring> author_list_;
std::vector<_pptx_comment> pptx_comment_;
};
pptx_comments::pptx_comments() : impl_( new pptx_comments::Impl() )
{
}
pptx_comments::~pptx_comments()
{
}
void pptx_comments::add(_pptx_comment & c)
{
impl_->add(c);
}
bool pptx_comments::empty() const
{
return impl_->empty();
}
void pptx_serialize(std::wostream & _Wostream, pptx_comments const & val)
{
val.impl_->serialize(_Wostream);
}
void pptx_serialize_authors(std::wostream & _Wostream, pptx_comments const & val)
{
val.impl_->serialize_authors(_Wostream);
}
pptx_comments_ptr pptx_comments::create()
{
return boost::make_shared<pptx_comments>();
}
}
}
\ No newline at end of file
#pragma once
#include <iosfwd>
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/xml/attributes.h>
#include "mediaitems.h"
namespace cpdoccore {
namespace oox {
struct _pptx_comment
{
size_t left_, top_;
size_t width_, height_;
bool visibly_;
std::vector<odf::_property> graphicProperties_;
std::wstring author_;
std::wstring content_;
};
//class rels;
class pptx_comments;
typedef _CP_PTR(pptx_comments) pptx_comments_ptr;
struct pptx_comment_elm
{
pptx_comment_elm(std::wstring const & _filename, std::wstring const & _content, pptx_comments_ptr _comments)
: filename(_filename), content(_content), comments(_comments)
{}
pptx_comments_ptr comments;
std::wstring filename;
std::wstring content;
};
class pptx_comments
{
public:
pptx_comments();
~pptx_comments();
static pptx_comments_ptr create();
public:
void add(_pptx_comment & d);
bool empty() const;
friend void pptx_serialize(std::wostream & _Wostream, pptx_comments const & val);
friend void pptx_serialize_authors(std::wostream & _Wostream, pptx_comments const & val);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;
};
}
}
\ No newline at end of file
#include "precompiled_cpodf.h"
#include "pptx_comments_context.h"
#include <boost/foreach.hpp>
#include <iostream>
#include "../odf/length.h"
#include "xlsx_utils.h"
//#include <cpdoccore/formulasconvert.h>
namespace cpdoccore {
namespace oox {
class pptx_comments;
typedef _CP_PTR(pptx_comments) pptx_comments_ptr;
class pptx_comments_context_handle::Impl
{
public:
Impl()
: next_comments_id_(1) ,next_file_id_(1)
{
}
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content,pptx_comments_ptr comments)
{
const std::wstring file_id = boost::lexical_cast<std::wstring>(next_file_id_++);
const std::wstring fileName = std::wstring(L"comments") + file_id + L".xml";
comments_.push_back(pptx_comment_elm(fileName, content, comments));
const std::wstring id = boost::lexical_cast<std::wstring>(next_comments_id_++);
const std::wstring rId = std::wstring(L"comId") + id;
return std::pair<std::wstring, std::wstring>(fileName, rId);
}
const std::vector<pptx_comment_elm> & content() const
{
return comments_;
}
private:
std::vector<pptx_comment_elm> comments_;
size_t next_comments_id_;
size_t next_file_id_;
};
pptx_comments_context_handle::pptx_comments_context_handle()
: impl_(new pptx_comments_context_handle::Impl())
{
}
pptx_comments_context_handle::~pptx_comments_context_handle()
{
}
std::pair<std::wstring, std::wstring> pptx_comments_context_handle::add_comments_xml(std::wstring const & content, pptx_comments_ptr comments)
{
return impl_->add_comments_xml(content,comments);
}
const std::vector<pptx_comment_elm> & pptx_comments_context_handle::content() const
{
return impl_->content();
}
class pptx_comments_context::Impl
{
public:
Impl(pptx_comments_context_handle & handle) : pptx_comments_(pptx_comments::create()),
handle_(handle)
{}
pptx_comments_context_handle & handle_;
_pptx_comment current_;
void add_comment(_pptx_comment & d)
{
pptx_comments_->add(d);
}
void write_comments(std::wostream & strm)
{
pptx_serialize(strm, *pptx_comments_);
}
bool empty() const
{
return pptx_comments_->empty();
}
pptx_comments_ptr get_comments()
{
return pptx_comments_;
}
private:
pptx_comments_ptr pptx_comments_;
};
pptx_comments_context::pptx_comments_context(pptx_comments_context_handle & h)
: impl_(new pptx_comments_context::Impl(h))
{
}
pptx_comments_context::~pptx_comments_context()
{
}
void pptx_comments_context::start_comment (double width_pt, double height_pt, double x_pt, double y_pt)
{
impl_->current_.width_ = width_pt;
impl_->current_.height_ = height_pt;
impl_->current_.left_ = x_pt;
impl_->current_.top_ = y_pt;
impl_->current_.visibly_ = false;
}
void pptx_comments_context::add_content(std::wstring content)
{
impl_->current_.content_ = content;
}
void pptx_comments_context::add_author(std::wstring author)
{
impl_->current_.author_ = author;
}
void pptx_comments_context::set_visibly(bool Val)
{
impl_->current_.visibly_ = Val;
}
std::vector<odf::_property> & pptx_comments_context::get_draw_properties()
{
return impl_->current_.graphicProperties_;
}
void pptx_comments_context::end_comment()
{
impl_->add_comment(impl_->current_);
}
bool pptx_comments_context::empty() const
{
return impl_->empty();
}
void pptx_comments_context::write_comments(std::wostream & strm)
{
impl_->write_comments(strm);
}
pptx_comments_ptr pptx_comments_context::get_comments()
{
return impl_->get_comments();
}
}
}
#pragma once
#include <string>
#include <boost/noncopyable.hpp>
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPSharedPtr.h>
#include "pptx_comments.h"
namespace cpdoccore { namespace oox {
class pptx_table_metrics;
class pptx_comments;
typedef _CP_PTR(pptx_comments) pptx_comments_ptr;
class pptx_comments_context_handle
{
public:
pptx_comments_context_handle();
~pptx_comments_context_handle();
std::pair<std::wstring, std::wstring> add_comments_xml(std::wstring const & content, pptx_comments_ptr comments);
const std::vector<pptx_comment_elm> & content() const;
friend class pptx_comments_context;
private:
class Impl;
_CP_PTR(Impl) impl_;
};
class pptx_comments;
typedef _CP_PTR(pptx_comments) pptx_comments_ptr;
class pptx_comments_context
{
public:
pptx_comments_context(pptx_comments_context_handle & h);
~pptx_comments_context();
void start_comment(double width_pt, double height_pt, double x_pt, double y_pt);
void add_content(std::wstring content);
void add_author(std::wstring author);
std::vector<odf::_property> & get_draw_properties();
void set_visibly(bool Val);
void end_comment();
bool empty() const;
void write_comments(std::wostream & strm);
pptx_comments_ptr get_comments();
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}
}
......@@ -36,6 +36,7 @@ pptx_conversion_context(::cpdoccore::oox::package::pptx_document * outputDocumen
,odf_document_(odfDocument)
,pptx_text_context_(odf_document_->odf_context(),*this)
,pptx_table_context_(*this)
,pptx_comments_context_(comments_context_handle_)
,pptx_slide_context_(*this/*, pptx_text_context_*/)
{
}
......@@ -214,7 +215,7 @@ void pptx_conversion_context::end_document()
if (pages_layouts)pages_layouts->pptx_convert(*this);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
pptx_serialize_size(current_presentation().notesSlidesSize(),6858000,9144000,L"p:notesSz");
////////////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -231,6 +232,9 @@ void pptx_conversion_context::end_document()
output_document_->get_ppt_files().add_charts(content);
}
package::ppt_comments_files_ptr comments = package::ppt_comments_files::create(comments_context_handle_.content());
output_document_->get_ppt_files().set_comments(comments);
output_document_->get_ppt_files().set_presentation(presentation_);
output_document_->get_ppt_files().set_themes(theme_);
......@@ -430,6 +434,17 @@ bool pptx_conversion_context::start_master(int master_index)
}
void pptx_conversion_context::end_page()
{
if (!get_comments_context().empty())
{
std::wstringstream strm;
get_comments_context().write_comments(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,mediaitems::typeComment);
}
get_slide_context().serialize_background(current_slide().Background());
get_slide_context().serialize(current_slide().Data());
get_slide_context().dump_rels(current_slide().Rels());//hyperlinks, mediaitems, ...
......
......@@ -6,14 +6,8 @@
#include "pptx_text_context.h"
#include "pptx_slide_context.h"
//#include "xlsx_sharedstrings.h"
//#include "xlsx_styles.h"
#include "pptx_output_xml.h"
//#include "xlsx_num_format_context.h"
//#include "xlsx_drawing_context.h"
//#include "xlsx_comments_context.h"
//#include "xlsx_defined_names.h"
//#include "xlsx_table_metrics.h"
#include "pptx_comments_context.h"
#include "oox_chart_context.h"
#include "pptx_table_context.h"
......@@ -75,6 +69,7 @@ public:
void end_theme();
pptx_slide_context & get_slide_context() { return pptx_slide_context_; }
pptx_comments_context & get_comments_context() { return pptx_comments_context_; }
odf::odf_document * root()
{
......@@ -127,6 +122,7 @@ private:
pptx_slide_context pptx_slide_context_;
pptx_text_context pptx_text_context_;
pptx_table_context pptx_table_context_;
pptx_comments_context pptx_comments_context_;
std::vector<oox_chart_context_ptr> charts_;
......@@ -140,6 +136,9 @@ private:
std::wstring current_master_page_name_;
std::wstring current_layout_page_name_;
pptx_comments_context_handle comments_context_handle_;
};
}
......
......@@ -111,8 +111,7 @@ public:
)
);
}
//typeShape -
else if (r.type_ == mediaitems::typeHyperlink)// ... ... ..
else if (r.type_ == mediaitems::typeHyperlink)
{
Rels.add(relationship(
r.rid_,
......@@ -121,6 +120,15 @@ public:
L"External")
);
}
else if (r.type_ == mediaitems::typeComment)
{
Rels.add(relationship(
r.rid_,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
r.ref_,
L"External")
);
}
}
}
......
......@@ -258,6 +258,29 @@ void ppt_charts_files::write(const std::wstring & RootPath)
}
}
}
//////////////////////////////
ppt_comments_files_ptr ppt_comments_files::create(const std::vector<pptx_comment_elm> & elms)
{
return boost::make_shared<ppt_comments_files>(boost::ref(elms));
}
void ppt_comments_files::write(const std::wstring & RootPath)
{
fs::wpath path = fs::wpath(RootPath);
fs::wpath comm_path = fs::wpath(RootPath) / L"comments";
fs::create_directory(comm_path);
BOOST_FOREACH(pptx_comment_elm const & e, comments_)
{
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
contentTypes.add_override(std::wstring(L"/ppt/comments/") + e.filename, kWSConType);
package::simple_element(e.filename, e.content).write(BOOST_STRING_PATH(comm_path));
}
}
////////////////////////////////////////////
ppt_files::ppt_files()
{
......@@ -309,7 +332,10 @@ void ppt_files::write(const std::wstring & RootPath)
charts_files_.set_main_document(get_main_document());
charts_files_.write(BOOST_STRING_PATH(path));
}
{
comments_->set_main_document(get_main_document());
comments_->write(BOOST_STRING_PATH(path));
}
rels_files_.write(BOOST_STRING_PATH(path));
}
......@@ -323,7 +349,10 @@ void ppt_files::set_presentation(pptx_xml_presentation & presentation)
elm->set_main_document( this->get_main_document() );
presentation_ = elm;
}
void ppt_files::set_comments(element_ptr Element)
{
comments_ = Element;
}
void ppt_files::set_styles(element_ptr Element)
{
tableStyles_ = Element;
......
......@@ -2,6 +2,7 @@
#include "oox_package.h"
#include <cpdoccore/CPNoncopyable.h>
#include "pptx_comments.h"
namespace cpdoccore {
namespace oox {
......@@ -107,7 +108,28 @@ public:
std::vector<slide_content_ptr> slides_;
rels_files * rels_;
};
/// \class xl_charts_files
///////////////////////////////////////////////////////////
class ppt_comments_files;
typedef _CP_PTR(ppt_comments_files) ppt_comments_files_ptr;
/// \class ppt_comments
class ppt_comments_files: public element
{
public:
virtual void write(const std::wstring & RootPath);
ppt_comments_files(const std::vector<pptx_comment_elm> & elms) : comments_ ( elms )
{
}
static ppt_comments_files_ptr create(const std::vector<pptx_comment_elm> & elms);
private:
const std::vector<pptx_comment_elm> & comments_;
};
/// \class ppt_charts_files
class ppt_charts_files : public element
{
public:
......@@ -132,6 +154,7 @@ public:
void set_themes(pptx_xml_theme_ptr & theme);
void set_styles(element_ptr Element);
void set_comments(element_ptr Element);
void add_slide(slide_content_ptr sheet);
void add_slideLayout(slide_content_ptr sheet);
......@@ -158,6 +181,7 @@ private:
element_ptr tableStyles_;
element_ptr comments_;
element_ptr media_;
};
......
......@@ -48,7 +48,7 @@ public:
{
pptx_drawings_->add(d, isInternal, rid, ref, type);
}
void add_drawing(/**/
void add_additional_rels(
bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
......@@ -412,7 +412,7 @@ void pptx_slide_context::process_shapes()
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, mediaitems::typeImage, isMediaInternal, ref);
impl_->add_drawing(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);// , ref
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, mediaitems::typeImage);
}
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", mediaitems::typeShape, isMediaInternal, ref);
......@@ -445,7 +445,7 @@ mediaitems & pptx_slide_context::get_mediaitems()
void pptx_slide_context::add_rels( bool isInternal, std::wstring const & rid, std::wstring const & ref, mediaitems::Type type)
{
impl_->add_drawing(isInternal, rid, ref, type);
impl_->add_additional_rels(isInternal, rid, ref, type);
}
void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
......
......@@ -68,6 +68,7 @@ private:
bool in_span;
bool in_paragraph;
bool in_comment;
odf::styles_container * local_styles_ptr_;
......@@ -113,7 +114,7 @@ private:
pptx_text_context::Impl::Impl(odf::odf_read_context & odf_contxt_, pptx_conversion_context & pptx_contxt_):
odf_context_(odf_contxt_), pptx_context_(pptx_contxt_),
paragraphs_cout_(0),in_paragraph(false),in_span(false),field_type_(none)
paragraphs_cout_(0),in_paragraph(false),in_span(false),in_comment(false),field_type_(none)
{
new_list_style_number_=0;
local_styles_ptr_ = NULL;
......@@ -140,9 +141,12 @@ void pptx_text_context::Impl::start_paragraph(const std::wstring & styleName)
{
dump_paragraph();
}
else if (in_list_ == false)
{
//
//text_ << L"&#10;";
//text_ << L"\n";
text_ << L"\n";
}
}else
{
text_.str(std::wstring());
......@@ -406,38 +410,45 @@ void pptx_text_context::Impl::dump_field()
{
CP_XML_NODE(L"a:fld")
{
std::wstring content = xml::utils::replace_text_to_xml(field_value_.str());
switch (field_type_)
{
case page_number:
{
CP_XML_ATTR(L"type", L"slidenum");
CP_XML_ATTR(L"id", L"{5CC2A059-B141-45A7-B910-B096D6D06820}");
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"<#>");
}
break;
case date:
{
CP_XML_ATTR(L"type", L"datetime1");
CP_XML_ATTR(L"id", L"{1D1B89AE-8D35-4BB5-B492-6D9BE4F23A39}");
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"01.01.2000");
}
break;
case time:
{
CP_XML_ATTR(L"type", L"datetime11");
CP_XML_ATTR(L"id", L"{03DA74A9-E3F2-4F30-AAF9-CC1A83980D5E}");
if (content.length()<1)content = xml::utils::replace_text_to_xml(L"00:00:00");
}
break;
}
//CP_XML_NODE(L"a:r")
{
const std::wstring content = xml::utils::replace_text_to_xml(field_value_.str());
//write_rPr(CP_XML_STREAM());
CP_XML_NODE(L"a:t")
case datetime:
{
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
CP_XML_ATTR(L"type", L"datetime1");
CP_XML_ATTR(L"id", L"{A9EA0FE8-FEF9-4B2F-BC9D-19DDCDB4AB9B}");
}
}
CP_XML_NODE(L"a:t")
{
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
}
......@@ -453,21 +464,17 @@ void pptx_text_context::Impl::dump_run()
CP_XML_WRITER(run_)
{
CP_XML_NODE(L"a:r")
{
write_rPr(CP_XML_STREAM());
if (content.length()>0)
{
CP_XML_NODE(L"a:r")
CP_XML_NODE(L"a:t")
{
write_rPr(CP_XML_STREAM());
CP_XML_NODE(L"a:t")
{
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
text_.str(std::wstring());
}
// CP_XML_ATTR(L"xml:space", L"preserve");
CP_XML_STREAM() << content;
}
}
text_.str(std::wstring());
}
hyperlink_hId =L"";
}
......@@ -749,6 +756,14 @@ void pptx_text_context::end_field()
{
impl_->end_field();
}
void pptx_text_context::start_comment_content()
{
impl_->start_object();
}
std::wstring pptx_text_context::end_comment_content()
{
return impl_->end_object();
}
}
}
......@@ -26,7 +26,8 @@ enum field_type
none,
page_number,
date,
time
time,
datetime
};
class pptx_text_context: boost::noncopyable
......
#ifndef _CPDOCCORE_XLSX_FORMULA_H_
#define _CPDOCCORE_XLSX_FORMULA_H_
#ifdef _MSC_VER
#pragma once
#endif
......@@ -16,4 +13,3 @@ namespace oox {
}
}
#endif
......@@ -51,10 +51,11 @@ void draw_page::add_attributes( const xml::attributes_wc_ptr & Attributes )
void draw_page::pptx_convert_placeHolder(oox::pptx_conversion_context & Context, std::wstring styleName, presentation_class::type PresentationClass)
{
office_element_ptr elm = Context.root()->odf_context().drawStyles().find_by_style_name(styleName);
//todooo åñëè ýòî ýëåìåíò datatime -íóæíî âûòàùèòü ôîðìàò ïîëÿ
if (!elm)return;
int index=0;
int index=-1;
const std::wstring masterName = draw_page_attr_.master_page_name_.get_value_or(L"");
style_master_page * master = Context.root()->odf_context().pageLayoutContainer().master_page_by_name(masterName);
......@@ -69,6 +70,11 @@ void draw_page::pptx_convert_placeHolder(oox::pptx_conversion_context & Context,
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();
......
......@@ -182,6 +182,92 @@ void office_annotation::xlsx_convert(oox::xlsx_conversion_context & Context)
std::wstring ref = Context.current_cell_address();
Context.get_comments_context().end_comment(ref,Context.current_table_column(), Context.current_table_row());
}
// officeooo:annotation
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * officeooo_annotation::ns = L"officeooo";
const wchar_t * officeooo_annotation::name = L"annotation";
void officeooo_annotation::add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name)
{
if (Ns==L"dc" && Name == L"date")
{
CP_CREATE_ELEMENT(dc_date_);
}
else if (Ns==L"dc" && Name == L"creator")
{
CP_CREATE_ELEMENT(dc_creator_);
}
else
{
CP_CREATE_ELEMENT(content_);
}
}
void officeooo_annotation::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
office_annotation_attr_.add_attributes(Attributes);
}
void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
{
const _CP_OPT(length) svg_widthVal = office_annotation_attr_.svg_width_;
const double width_cm = svg_widthVal.get_value_or(length(0)).get_value_unit(length::cm);
const double width_pt = svg_widthVal.get_value_or(length(0)).get_value_unit(length::pt);
const _CP_OPT(length) svg_heightVal =office_annotation_attr_.svg_height_;
const double height_cm = svg_heightVal.get_value_or(length(0)).get_value_unit(length::cm);
const double height_pt = svg_heightVal.get_value_or(length(0)).get_value_unit(length::pt);
const double x_pt = office_annotation_attr_.svg_x_.get_value_or(length(0)).get_value_unit(length::pt);
const double y_pt = office_annotation_attr_.svg_y_.get_value_or(length(0)).get_value_unit(length::pt);
/////////////////////////////////
std::wstring date;
std::wstring author;
if (dc_date_)
{
date = xml::utils::replace_text_to_xml(dynamic_cast<dc_date * >(dc_date_.get())->content_);
}
if (dc_creator_)
{
author = xml::utils::replace_text_to_xml(dynamic_cast<dc_creator * >(dc_creator_.get())->content_);
}
////////////////////////////////////////
Context.get_comments_context().start_comment(width_pt, height_pt, x_pt, y_pt);
if (office_annotation_attr_.display_)
{
Context.get_comments_context().set_visibly(office_annotation_attr_.display_.get());
}
Context.get_text_context().start_comment_content();
BOOST_FOREACH(office_element_ptr const & elm, content_)//òåêñò + òåêñòîâûé ñòèëü
{
elm->pptx_convert(Context);
}
Context.get_comments_context().add_author(author);
Context.get_comments_context().add_content(Context.get_text_context().end_comment_content());
//////////////////////////////////////////////////////////////////
/// Îáðàáàòûâàåì ñòèëü draw
std::vector<const odf::style_instance *> instances;
style_instance* styleInst = Context.root()->odf_context().styleContainer().style_by_name(
office_annotation_attr_.draw_style_name_.get_value_or(style_ref(L"")).style_name(), odf::style_family::Graphic,false/*Context.process_headers_footers_*/);
if (styleInst)
{
style_instance * defaultStyle = Context.root()->odf_context().styleContainer().style_default_by_type(odf::style_family::Graphic);
if (defaultStyle)instances.push_back(defaultStyle);
instances.push_back(styleInst);
}
graphic_format_properties graphicProperties = calc_graphic_properties_content(instances);
graphicProperties.apply_to(Context.get_comments_context().get_draw_properties());
const std::wstring textStyleName = office_annotation_attr_.draw_text_style_name_.get_value_or(style_ref(L"")).style_name();
Context.get_comments_context().end_comment();
}
}
}
......@@ -76,7 +76,6 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(dc_creator);
/// \class office_annotation
/// \brief office:annotation
class office_annotation : public office_element_impl<office_annotation>
{
......@@ -103,8 +102,33 @@ private:
};
CP_REGISTER_OFFICE_ELEMENT2(office_annotation);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//officeooo:annotation
class officeooo_annotation : public office_element_impl<officeooo_annotation>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeOfficeAnnotation;
CPDOCCORE_DEFINE_VISITABLE();
virtual void pptx_convert(oox::pptx_conversion_context & Context);
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const ::std::wstring & Ns, const ::std::wstring & Name);
private:
office_element_ptr_array content_;
office_annotation_attr office_annotation_attr_;
office_element_ptr dc_date_;
office_element_ptr dc_creator_;
};
CP_REGISTER_OFFICE_ELEMENT2(officeooo_annotation);
}
}
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