Commit 2dbec241 authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWriter - presentation comments

parent f3c66cab
...@@ -96,7 +96,7 @@ void odf_comment_context::start_comment(office_element_ptr &elm, int oox_id) ...@@ -96,7 +96,7 @@ void odf_comment_context::start_comment(office_element_ptr &elm, int oox_id)
impl_->comments_.push_back(state); impl_->comments_.push_back(state);
impl_->comments_.back().elements_.push_back(elm);//"0" - root comment eleemnt impl_->comments_.back().elements_.push_back(elm);//"0" - root comment eleemnt
impl_->comments_.back().oox_id = oox_id; impl_->comments_.back().oox_id = oox_id < 0 ? impl_->comments_.back().elements_.size() : oox_id;
impl_->comments_.back().odf_name = L"comment_" + boost::lexical_cast<std::wstring>(oox_id); impl_->comments_.back().odf_name = L"comment_" + boost::lexical_cast<std::wstring>(oox_id);
impl_->comments_.back().is_started = false; impl_->comments_.back().is_started = false;
...@@ -159,14 +159,14 @@ std::wstring odf_comment_context::find_name_by_id(int oox_id) ...@@ -159,14 +159,14 @@ std::wstring odf_comment_context::find_name_by_id(int oox_id)
} }
bool odf_comment_context::is_started() bool odf_comment_context::is_started()
{ {
if (impl_->comments_.size()>0) if (!impl_->comments_.empty())
return impl_->comments_.back().is_started; return impl_->comments_.back().is_started;
else return false; else return false;
} }
void odf_comment_context::set_author(std::wstring author) void odf_comment_context::set_author(std::wstring author)
{ {
if ((impl_->comments_.size()<1) || !is_started()) return; if ((impl_->comments_.empty()) || !is_started()) return;
office_element_ptr elm; office_element_ptr elm;
create_element(L"dc", L"creator", elm, impl_->odf_context_); create_element(L"dc", L"creator", elm, impl_->odf_context_);
...@@ -178,11 +178,15 @@ void odf_comment_context::set_author(std::wstring author) ...@@ -178,11 +178,15 @@ void odf_comment_context::set_author(std::wstring author)
impl_->comments_.back().elements_[0]->add_child_element(elm); impl_->comments_.back().elements_[0]->add_child_element(elm);
impl_->comments_.back().elements_.push_back(elm); impl_->comments_.back().elements_.push_back(elm);
}
void odf_comment_context::set_initials(std::wstring initials)
{
if ((impl_->comments_.empty()) || !is_started()) return;
} }
void odf_comment_context::set_date(std::wstring _date) void odf_comment_context::set_date(std::wstring _date)
{ {
if ((impl_->comments_.size()<1) || !is_started()) return; if ((impl_->comments_.empty()) || !is_started()) return;
office_element_ptr elm; office_element_ptr elm;
create_element(L"dc", L"date", elm, impl_->odf_context_); create_element(L"dc", L"date", elm, impl_->odf_context_);
...@@ -195,5 +199,18 @@ void odf_comment_context::set_date(std::wstring _date) ...@@ -195,5 +199,18 @@ void odf_comment_context::set_date(std::wstring _date)
impl_->comments_.back().elements_[0]->add_child_element(elm); impl_->comments_.back().elements_[0]->add_child_element(elm);
impl_->comments_.back().elements_.push_back(elm); impl_->comments_.back().elements_.push_back(elm);
} }
void odf_comment_context::set_position (double x, double y)
{
if ((impl_->comments_.empty()) || !is_started()) return;
office_annotation* comm = dynamic_cast<office_annotation*>(impl_->comments_.back().elements_.back().get());
if (comm)
{
comm->office_annotation_attr_.svg_x_ = odf_types::length(x, odf_types::length::pt);
comm->office_annotation_attr_.svg_y_ = odf_types::length(y, odf_types::length::pt);
}
}
} }
} }
\ No newline at end of file
...@@ -66,8 +66,11 @@ public: ...@@ -66,8 +66,11 @@ public:
void start_comment_content (); void start_comment_content ();
void end_comment_content (); void end_comment_content ();
void set_author (std::wstring author); void set_author (std::wstring author);
void set_date (std::wstring author); void set_initials (std::wstring author);
void set_date (std::wstring author);
void set_position (double x, double y);
private: private:
std::wstring find_name_by_id(int oox_id); std::wstring find_name_by_id(int oox_id);
......
...@@ -938,7 +938,7 @@ void odf_drawing_context::end_shape() ...@@ -938,7 +938,7 @@ void odf_drawing_context::end_shape()
enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = shape_define->glue_points; enhanced->draw_enhanced_geometry_attlist_.draw_glue_points_ = shape_define->glue_points;
enhanced->draw_enhanced_geometry_attlist_.draw_sub_view_size_ = shape_define->sub_view_size; enhanced->draw_enhanced_geometry_attlist_.draw_sub_view_size_ = shape_define->sub_view_size;
if (!impl_->current_drawing_state_.oox_shape_->modifiers.empty()) if (impl_->current_drawing_state_.oox_shape_ && !impl_->current_drawing_state_.oox_shape_->modifiers.empty())
{ {
enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers; enhanced->draw_enhanced_geometry_attlist_.draw_modifiers_ = impl_->current_drawing_state_.oox_shape_->modifiers;
} }
......
...@@ -136,5 +136,40 @@ void odp_conversion_context::start_image(const std::wstring & image_file_name) ...@@ -136,5 +136,40 @@ void odp_conversion_context::start_image(const std::wstring & image_file_name)
current_slide().drawing_context()->start_image(odf_ref_name); current_slide().drawing_context()->start_image(odf_ref_name);
} }
void odp_conversion_context::start_comment(int oox_comm_id)
{
office_element_ptr comm_elm;
create_element(L"office", L"annotation", comm_elm, this);
current_slide().comment_context()->start_comment(comm_elm, oox_comm_id);
current_slide().drawing_context()->start_drawing();
current_slide().drawing_context()->start_element(comm_elm);
}
void odp_conversion_context::start_comment_content()
{
current_slide().comment_context()->start_comment_content();
office_element_ptr & root_comm_element = current_slide().drawing_context()->get_current_element();
start_text_context();
text_context()->start_element(root_comm_element);
text_context()->start_paragraph();
}
void odp_conversion_context::end_comment_content()
{
text_context()->end_paragraph();
current_slide().comment_context()->end_comment_content();
text_context()->end_element();
end_text_context();
}
void odp_conversion_context::end_comment()
{
current_slide().drawing_context()->end_element();
current_slide().drawing_context()->end_drawing();
}
} }
} }
...@@ -67,12 +67,18 @@ public: ...@@ -67,12 +67,18 @@ public:
virtual odf_drawing_context * drawing_context() {return current_slide().drawing_context();} virtual odf_drawing_context * drawing_context() {return current_slide().drawing_context();}
virtual odf_text_context * text_context() {return text_context_; } virtual odf_text_context * text_context() {return text_context_; }
odp_slide_context * slide_context() {return &slide_context_;} odp_slide_context * slide_context() {return &slide_context_;}
odf_comment_context * comment_context() {return current_slide().comment_context();}
void start_drawings(); void start_drawings();
void end_drawings(); void end_drawings();
virtual void start_image(const std::wstring & image_file_name); virtual void start_image(const std::wstring & image_file_name);
void start_comment (int oox_comment_id);
void end_comment ();
void start_comment_content ();
void end_comment_content ();
private: private:
odp_slide_context slide_context_; odp_slide_context slide_context_;
......
...@@ -58,7 +58,7 @@ namespace odf_writer { ...@@ -58,7 +58,7 @@ namespace odf_writer {
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
odp_page_state::odp_page_state(odf_conversion_context * Context, office_element_ptr & elm) odp_page_state::odp_page_state(odf_conversion_context * Context, office_element_ptr & elm)
: context_(Context), drawing_context_(Context) : context_(Context), drawing_context_(Context), comment_context_(Context)
{ {
page_elm_ = elm; page_elm_ = elm;
......
...@@ -40,11 +40,11 @@ ...@@ -40,11 +40,11 @@
#include"../../../Common/DocxFormat/Source/XML/Utils.h" #include"../../../Common/DocxFormat/Source/XML/Utils.h"
#include "odf_drawing_context.h" #include "odf_drawing_context.h"
#include "odf_comment_context.h"
#include "office_elements_create.h" #include "office_elements_create.h"
namespace cpdoccore { namespace cpdoccore {
namespace odf_types namespace odf_types
...@@ -57,7 +57,6 @@ namespace odf_writer { ...@@ -57,7 +57,6 @@ namespace odf_writer {
class odp_conversion_context; class odp_conversion_context;
class odf_text_context; class odf_text_context;
//class table_table;
class style; class style;
...@@ -85,6 +84,7 @@ public: ...@@ -85,6 +84,7 @@ public:
/////////////////////////////// ///////////////////////////////
odf_drawing_context * drawing_context(){return &drawing_context_;} odf_drawing_context * drawing_context(){return &drawing_context_;}
odf_comment_context * comment_context(){return &comment_context_;}
std::wstring office_page_name_; std::wstring office_page_name_;
office_element_ptr page_elm_; office_element_ptr page_elm_;
...@@ -94,6 +94,7 @@ private: ...@@ -94,6 +94,7 @@ private:
odf_conversion_context * context_; odf_conversion_context * context_;
odf_drawing_context drawing_context_; odf_drawing_context drawing_context_;
odf_comment_context comment_context_;
friend class odp_slide_context; friend class odp_slide_context;
......
...@@ -58,7 +58,6 @@ public: ...@@ -58,7 +58,6 @@ public:
odp_page_state & state(); odp_page_state & state();
odf_comment_context * comment_context();
odf_table_context * table_context(); odf_table_context * table_context();
void start_table (); void start_table ();
......
...@@ -3392,7 +3392,7 @@ void DocxConverter::convert(OOX::Logic::CCommentRangeStart* oox_comm_start) ...@@ -3392,7 +3392,7 @@ void DocxConverter::convert(OOX::Logic::CCommentRangeStart* oox_comm_start)
bool added = odt_context->start_comment(oox_comm_id); bool added = odt_context->start_comment(oox_comm_id);
if (added==false) if (added == false)
{ {
convert_comment(oox_comm_id); convert_comment(oox_comm_id);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "../../../ASCOfficePPTXFile/PPTXFormat/Folder.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Folder.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Presentation.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Presentation.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Slide.h"
#include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/Table.h" #include "../../../ASCOfficePPTXFile/PPTXFormat/Logic/Table/Table.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
...@@ -369,16 +370,14 @@ void PptxConverter::convert_slides() ...@@ -369,16 +370,14 @@ void PptxConverter::convert_slides()
//nullable_bool showMasterPhAnim; //nullable_bool showMasterPhAnim;
//nullable_bool showMasterSp; //nullable_bool showMasterSp;
convert_slide(slide->cSld.GetPointer(), true); convert_slide (slide->cSld.GetPointer(), true);
convert (slide->transition.GetPointer());
convert (slide->comments.operator->());
//nullable<Logic::Transition> transition;
//nullable<Logic::Timing> timing; //nullable<Logic::Timing> timing;
//smart_ptr<NotesSlide> Note; //smart_ptr<NotesSlide> Note;
//smart_ptr<PPTX::Comments> comments;
odp_context->end_slide(); odp_context->end_slide();
} }
} }
...@@ -394,7 +393,47 @@ void PptxConverter::convert(OOX::WritingElement *oox_unknown) ...@@ -394,7 +393,47 @@ void PptxConverter::convert(OOX::WritingElement *oox_unknown)
}break; }break;
} }
} }
void PptxConverter::convert(PPTX::Comments *oox_comments)
{
if (!oox_comments) return;
for (size_t i = 0; i < oox_comments->m_arComments.size(); i++)
{
PPTX::Logic::Comment & oox_comment = oox_comments->m_arComments[i];
odp_context->start_comment(oox_comment.idx.get_value_or(-1));
odp_context->start_comment_content();
if (oox_comment.pos_x.IsInit() && oox_comment.pos_y.IsInit())
odp_context->comment_context()->set_position (*oox_comment.pos_x / 10., *oox_comment.pos_y / 10.); //pt
if (oox_comment.authorId.IsInit() && presentation->commentAuthors.IsInit())
{
for (size_t a = 0; a < presentation->commentAuthors->m_arAuthors.size(); a++)
{
PPTX::Logic::CommentAuthor & autor = presentation->commentAuthors->m_arAuthors[a];
if (autor.id.IsInit() && autor.id.get() == oox_comment.authorId.get())
{
odp_context->comment_context()->set_author(autor.name.get_value_or(L""));
odp_context->comment_context()->set_initials(autor.initials.get_value_or(L""));
break;
}
}
}
if (oox_comment.dt.IsInit()) odp_context->comment_context()->set_date(*oox_comment.dt);
if (oox_comment.text.IsInit()) odp_context->text_context()->add_text_content(*oox_comment.text);
odp_context->end_comment_content();
odp_context->end_comment();
}
}
void PptxConverter::convert(PPTX::Logic::Transition *oox_transition)
{
if (!oox_transition) return;
}
void PptxConverter::convert(PPTX::Logic::TableProperties *oox_table_pr) void PptxConverter::convert(PPTX::Logic::TableProperties *oox_table_pr)
{ {
if (!oox_table_pr) return; if (!oox_table_pr) return;
......
...@@ -48,6 +48,7 @@ namespace PPTX ...@@ -48,6 +48,7 @@ namespace PPTX
{ {
class TableStyles; class TableStyles;
class Presentation; class Presentation;
class Comments;
class Folder; class Folder;
namespace Logic namespace Logic
...@@ -105,8 +106,10 @@ namespace Oox2Odf ...@@ -105,8 +106,10 @@ namespace Oox2Odf
void convert_slide (PPTX::Logic::CSld *oox_slide, bool bPlaceholders = true); void convert_slide (PPTX::Logic::CSld *oox_slide, bool bPlaceholders = true);
void convert_layout (PPTX::Logic::CSld *oox_slide); void convert_layout (PPTX::Logic::CSld *oox_slide);
void convert (PPTX::Comments *oox_comments);
void convert(PPTX::Logic::Bg *oox_background); void convert(PPTX::Logic::Bg *oox_background);
void convert(PPTX::Logic::Transition *oox_transition);
void convert(PPTX::Logic::Table *oox_table); void convert(PPTX::Logic::Table *oox_table);
void convert(PPTX::Logic::TableRow *oox_table_row); void convert(PPTX::Logic::TableRow *oox_table_row);
......
...@@ -44,7 +44,7 @@ namespace PPTX ...@@ -44,7 +44,7 @@ namespace PPTX
{ {
public: public:
PPTX_LOGIC_BASE(CommentAuthor) PPTX_LOGIC_BASE(CommentAuthor)
private:
nullable_int id; nullable_int id;
nullable_int last_idx; nullable_int last_idx;
nullable_int clr_idx; nullable_int clr_idx;
...@@ -52,8 +52,6 @@ namespace PPTX ...@@ -52,8 +52,6 @@ namespace PPTX
nullable_string name; nullable_string name;
nullable_string initials; nullable_string initials;
public:
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
node.ReadAttributeBase(L"id", id); node.ReadAttributeBase(L"id", id);
...@@ -138,10 +136,9 @@ namespace PPTX ...@@ -138,10 +136,9 @@ namespace PPTX
class Authors : public WrapperFile class Authors : public WrapperFile
{ {
private: public:
std::vector<PPTX::Logic::CommentAuthor> m_arAuthors; std::vector<PPTX::Logic::CommentAuthor> m_arAuthors;
public:
Authors() Authors()
{ {
} }
...@@ -152,8 +149,6 @@ namespace PPTX ...@@ -152,8 +149,6 @@ namespace PPTX
virtual ~Authors() virtual ~Authors()
{ {
} }
public:
virtual void read(const OOX::CPath& filename, FileMap& map) virtual void read(const OOX::CPath& filename, FileMap& map)
{ {
XmlUtils::CXmlNode oNode; XmlUtils::CXmlNode oNode;
...@@ -177,8 +172,6 @@ namespace PPTX ...@@ -177,8 +172,6 @@ namespace PPTX
{ {
WrapperFile::write(filename, directory, content); WrapperFile::write(filename, directory, content);
} }
public:
virtual const OOX::FileType type() const virtual const OOX::FileType type() const
{ {
return OOX::Presentation::FileTypes::CommentAuthors; return OOX::Presentation::FileTypes::CommentAuthors;
...@@ -191,8 +184,6 @@ namespace PPTX ...@@ -191,8 +184,6 @@ namespace PPTX
{ {
return type().DefaultFileName(); return type().DefaultFileName();
} }
public:
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{ {
pWriter->WriteRecordArray(0, 0, m_arAuthors); pWriter->WriteRecordArray(0, 0, m_arAuthors);
......
...@@ -44,7 +44,7 @@ namespace PPTX ...@@ -44,7 +44,7 @@ namespace PPTX
{ {
public: public:
PPTX_LOGIC_BASE(Comment) PPTX_LOGIC_BASE(Comment)
private:
nullable_int authorId; nullable_int authorId;
nullable_int idx; nullable_int idx;
nullable_string dt; nullable_string dt;
...@@ -59,8 +59,6 @@ namespace PPTX ...@@ -59,8 +59,6 @@ namespace PPTX
nullable_string additional_data; // teamlab editor information!!! nullable_string additional_data; // teamlab editor information!!!
public:
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
node.ReadAttributeBase(L"authorId", authorId); node.ReadAttributeBase(L"authorId", authorId);
...@@ -276,10 +274,9 @@ namespace PPTX ...@@ -276,10 +274,9 @@ namespace PPTX
class Comments : public WrapperFile class Comments : public WrapperFile
{ {
private: public:
std::vector<PPTX::Logic::Comment> m_arComments; std::vector<PPTX::Logic::Comment> m_arComments;
public:
Comments() Comments()
{ {
} }
...@@ -291,7 +288,6 @@ namespace PPTX ...@@ -291,7 +288,6 @@ namespace PPTX
{ {
} }
public:
virtual void read(const OOX::CPath& filename, FileMap& map) virtual void read(const OOX::CPath& filename, FileMap& map)
{ {
XmlUtils::CXmlNode oNode; XmlUtils::CXmlNode oNode;
...@@ -315,7 +311,6 @@ namespace PPTX ...@@ -315,7 +311,6 @@ namespace PPTX
WrapperFile::write(filename, directory, content); WrapperFile::write(filename, directory, content);
} }
public:
virtual const OOX::FileType type() const virtual const OOX::FileType type() const
{ {
return OOX::Presentation::FileTypes::SlideComments; return OOX::Presentation::FileTypes::SlideComments;
...@@ -328,8 +323,6 @@ namespace PPTX ...@@ -328,8 +323,6 @@ namespace PPTX
{ {
return type().DefaultFileName(); return type().DefaultFileName();
} }
public:
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const
{ {
pWriter->WriteRecordArray(0, 0, m_arComments); pWriter->WriteRecordArray(0, 0, m_arComments);
......
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