Commit 9e96fb6e authored by ElenaSubbotina's avatar ElenaSubbotina

OdfFormatWrites - footnotes & endnotes

parent dc4f7e64
......@@ -349,6 +349,30 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\FileDownloader\FileDownloader_win.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\Common\3dParty\pole\pole.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
......
......@@ -53,6 +53,7 @@ SOURCES += \
../source/OdfFormat/object_package.cpp \
../source/OdfFormat/odf_chart_context.cpp \
../source/OdfFormat/odf_comment_context.cpp \
../source/OdfFormat/odf_notes_context.cpp \
../source/OdfFormat/odf_conversion_context.cpp \
../source/OdfFormat/odf_drawing_context.cpp \
../source/OdfFormat/odf_lists_styles_context.cpp \
......@@ -116,6 +117,7 @@ HEADERS += \
../source/OdfFormat/object_package.h \
../source/OdfFormat/odf_chart_context.h \
../source/OdfFormat/odf_comment_context.h \
../source/OdfFormat/odf_notes_context.h \
../source/OdfFormat/odf_conversion_context.h \
../source/OdfFormat/odf_drawing_context.h \
../source/OdfFormat/odf_lists_styles_context.h \
......
......@@ -51,7 +51,7 @@ using xml::xml_char_wc;
const wchar_t * text_number::ns = L"text";
const wchar_t * text_number::name = L"number";
void text_number::serialize(::std::wostream & _Wostream)
void text_number::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -72,7 +72,7 @@ void text_number::add_text(const std::wstring & Text)
const wchar_t * text_list_item::ns = L"text";
const wchar_t * text_list_item::name = L"list-item";
void text_list_item::serialize(::std::wostream & _Wostream)
void text_list_item::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -89,7 +89,7 @@ void text_list_item::serialize(::std::wostream & _Wostream)
}
void text_list_item::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_list_item::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"number")
{
......@@ -119,7 +119,7 @@ const wchar_t * text_list_header::ns = L"text";
const wchar_t * text_list_header::name = L"list-header";
void text_list_header::serialize(::std::wostream & _Wostream)
void text_list_header::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -135,7 +135,7 @@ void text_list_header::serialize(::std::wostream & _Wostream)
}
}
void text_list_header::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_list_header::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"number")
{
......
......@@ -60,14 +60,14 @@ public:
bool is_started();// for content
void start_comment(office_element_ptr &elm, int oox_id);
void end_comment(office_element_ptr & elm, int oox_id);
void start_comment (office_element_ptr & elm, int oox_id);
void end_comment (office_element_ptr & elm, int oox_id);
void start_comment_content();
void end_comment_content();
void start_comment_content ();
void end_comment_content ();
void set_author(std::wstring author);
void set_date(std::wstring author);
void set_author (std::wstring author);
void set_date (std::wstring author);
private:
std::wstring find_name_by_id(int oox_id);
......
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "logging.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
#include "odf_conversion_context.h"
#include "odf_notes_context.h"
#include "styles.h"
#include "paragraph_elements.h"
namespace cpdoccore
{
using namespace odf_types;
namespace odf_writer
{
struct odf_note_state
{
office_element_ptr element;
int oox_id;
std::wstring odf_name;
int type;
bool is_started;
int state;
};
class odf_notes_context::Impl
{
public:
Impl(odf_conversion_context *odf_context) :odf_context_(odf_context)
{
//styles_context_ = odf_context_->styles_context();
}
std::vector<odf_note_state> notes_;
odf_conversion_context *odf_context_;
};
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
odf_notes_context::odf_notes_context(odf_conversion_context *odf_context)
: impl_(new odf_notes_context::Impl(odf_context))
{
}
odf_notes_context::~odf_notes_context()
{
}
void odf_notes_context::start_note(office_element_ptr &elm, int oox_id, int type)
{
odf_note_state state;
impl_->notes_.push_back(state);
impl_->notes_.back().element = elm;
impl_->notes_.back().oox_id = oox_id;
impl_->notes_.back().odf_name = L"note_" + boost::lexical_cast<std::wstring>(oox_id);
impl_->notes_.back().is_started = false;
impl_->notes_.back().state = 1;
impl_->notes_.back().type = type;
text_note* note = dynamic_cast<text_note*>(elm.get());
if (!note)return;
if (type == 1) note->text_note_class_ = odf_types::noteclass::Footnote;
if (type == 2) note->text_note_class_ = odf_types::noteclass::Endnote;
note->text_id_ = impl_->notes_.back().odf_name;
note->create_child_element(L"text", L"note-citation");
text_note_citation* note_citation = dynamic_cast<text_note_citation*>(note->text_note_citation_.get());
if (note_citation)
note_citation->add_text(boost::lexical_cast<std::wstring>(oox_id));
}
void odf_notes_context::end_note()
{
impl_->notes_.back().state = 2;//stoped
}
void odf_notes_context::start_note_content()
{
impl_->notes_.back().is_started = true;
impl_->notes_.back().element->create_child_element(L"text", L"note-body");
}
office_element_ptr odf_notes_context::get_note_content()
{
text_note* note = dynamic_cast<text_note*>(impl_->notes_.back().element.get());
if (!note) return office_element_ptr();
return note->text_note_body_;
}
void odf_notes_context::end_note_content()
{
impl_->notes_.back().is_started = false;
}
int odf_notes_context::find_by_id(int oox_id, int type)
{
for (int i=0; i < impl_->notes_.size(); i++)
{
if (impl_->notes_[i].oox_id == oox_id &&
impl_->notes_[i].type == type)
{
return impl_->notes_[i].state;
}
}
return 0;
}
std::wstring odf_notes_context::find_name_by_id(int oox_id, int type)
{
for (int i=0; i < impl_->notes_.size(); i++)
{
if (impl_->notes_[i].oox_id == oox_id &&
impl_->notes_[i].type == type)
{
return impl_->notes_[i].odf_name;
}
}
return L"";
}
bool odf_notes_context::is_started()
{
if (impl_->notes_.size() > 0)
return impl_->notes_.back().is_started;
else return false;
}
}
}
\ No newline at end of file
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include <string>
#include <vector>
#include <cpdoccore/CPOptional.h>
#include "office_elements_create.h"
namespace cpdoccore {
using namespace odf_types;
namespace odf_writer
{
class odf_conversion_context;
class odf_style_context;
class odf_notes_context
{
public:
odf_notes_context(odf_conversion_context *odf_context);
~odf_notes_context();
void set_styles_context(odf_style_context* styles_context);
int find_by_id(int oox_id, int type);
bool is_started();// for content
void start_note (office_element_ptr & elm, int oox_id, int type);
void end_note ();
void start_note_content ();
office_element_ptr get_note_content ();
void end_note_content ();
private:
std::wstring find_name_by_id(int oox_id, int type);
class Impl;
_CP_PTR(Impl) impl_;
};
}
}
\ No newline at end of file
......@@ -73,7 +73,7 @@ double calculate_size_font_symbols(std::wstring str_test, std::wstring font_name
}
odt_conversion_context::odt_conversion_context(package::odf_document * outputDocument)
: odf_conversion_context (TextDocument, outputDocument),
comment_context_(this), main_text_context_(NULL),table_context_(this)
comment_context_(this), notes_context_(this), main_text_context_(NULL), table_context_(this)
{
current_field_.enabled = false;
current_field_.started = false;
......@@ -677,6 +677,7 @@ void odt_conversion_context::end_run()
current_field_.started = true;
}
}
//--------------------------------------------------------------------------------------------------------
bool odt_conversion_context::start_comment(int oox_comm_id)
{
int comm_state = comment_context_.find_by_id(oox_comm_id);
......@@ -684,7 +685,7 @@ bool odt_conversion_context::start_comment(int oox_comm_id)
if (comm_state == 0)
{
office_element_ptr comm_elm;
create_element(L"office", L"annotation",comm_elm,this);
create_element(L"office", L"annotation", comm_elm, this);
comment_context_.start_comment(comm_elm, oox_comm_id);
......@@ -725,7 +726,7 @@ void odt_conversion_context::end_comment(int oox_comm_id)
if (added == true)
{
office_element_ptr comm_elm;
create_element(L"office", L"annotation-end",comm_elm,this);
create_element(L"office", L"annotation-end", comm_elm, this);
comment_context_.end_comment(comm_elm, oox_comm_id);
......@@ -733,6 +734,48 @@ void odt_conversion_context::end_comment(int oox_comm_id)
text_context()->current_level_.back().elm->add_child_element(comm_elm);
}
}
//--------------------------------------------------------------------------------------------------------
void odt_conversion_context::start_note(int oox_ref_id, int type)
{
office_element_ptr note_elm;
create_element(L"text", L"note", note_elm, this);
notes_context_.start_note(note_elm, oox_ref_id, type);
if (text_context()->current_level_.size() > 0)
text_context()->current_level_.back().elm->add_child_element(note_elm);
odf_element_state state = {note_elm, L"", office_element_ptr(), (int)text_context()->current_level_.size()};
text_context()->current_level_.push_back(state);
}
void odt_conversion_context::start_note_content()
{
notes_context_.start_note_content();
office_element_ptr & note_content_element = notes_context_.get_note_content();
odf_element_state state = {note_content_element, L"", office_element_ptr(), (int)text_context()->current_level_.size()};
text_context()->current_level_.push_back(state);
start_text_context();
text_context()->start_element(note_content_element);
}
void odt_conversion_context::end_note_content()
{
notes_context_.end_note_content();
text_context()->end_element();
end_text_context();
text_context()->current_level_.pop_back();
}
void odt_conversion_context::end_note()
{
notes_context_.end_note();
text_context()->current_level_.pop_back();
}
//--------------------------------------------------------------------------------------------------------
void odt_conversion_context::start_image(const std::wstring & image_file_name)
{
std::wstring odf_ref_name ;
......
......@@ -34,6 +34,7 @@
#include "odf_conversion_context.h"
#include "odf_comment_context.h"
#include "odf_notes_context.h"
#include "odf_table_context.h"
namespace cpdoccore {
......@@ -112,11 +113,15 @@ public:
void set_drop_cap_margin(bool val);
void end_drop_cap();
bool start_comment(int oox_comment_id);
void end_comment(int oox_comment_id);
bool start_comment (int oox_comment_id);
void end_comment (int oox_comment_id);
void start_comment_content ();
void end_comment_content ();
void start_comment_content();
void end_comment_content();
void start_note (int oox_ref_id, int type);
void start_note_content ();
void end_note_content ();
void end_note ();
void start_table(bool styled = false);
void start_table_columns();
......@@ -154,6 +159,7 @@ private:
odf_table_context table_context_;
odf_comment_context comment_context_;
odf_notes_context notes_context_;
bool is_header_;
bool is_footer_;
......
......@@ -258,7 +258,7 @@ void text_span::serialize(std::wostream & _Wostream)
}
}
void text_span::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_span::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(paragraph_content_);
}
......@@ -306,16 +306,15 @@ void text_a::serialize(std::wostream & _Wostream)
CP_XML_ATTR_OPT(L"text:style-name", text_style_name_);
CP_XML_ATTR_OPT(L"text:visited-style-name", text_visited_style_name_);
BOOST_FOREACH(const office_element_ptr & element, paragraph_content_)
for (int i = 0; i < paragraph_content_.size(); i++)
{
element->serialize(CP_XML_STREAM());
paragraph_content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
void text_a::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_a::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(paragraph_content_);
}
......@@ -330,6 +329,70 @@ void text_a::add_text(const std::wstring & Text)
office_element_ptr elm = text_text::create(Text) ;
paragraph_content_.push_back( elm );
}
// text:note-citation
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * text_note_citation::ns = L"text";
const wchar_t * text_note_citation::name = L"note-citation";
void text_note_citation::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void text_note_citation::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void text_note_citation::add_text(const std::wstring & Text)
{
office_element_ptr elm = text_text::create(Text) ;
content_.push_back( elm );
}
void text_note_citation::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR_OPT(L"text:label", text_label_);
for (int i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
// text:note-body
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * text_note_body::ns = L"text";
const wchar_t * text_note_body::name = L"note-body";
void text_note_body::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(content_);
}
void text_note_body::add_child_element( const office_element_ptr & child_element)
{
content_.push_back(child_element);
}
void text_note_body::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
for (int i = 0; i < content_.size(); i++)
{
content_[i]->serialize(CP_XML_STREAM());
}
}
}
}
// text:note
//////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -357,7 +420,7 @@ void text_note::serialize(std::wostream & _Wostream)
}
}
void text_note::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_note::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"note-citation")
{
......@@ -409,7 +472,7 @@ void text_ruby::serialize(std::wostream & _Wostream)
}
}
void text_ruby::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_ruby::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"ruby-base")
{
......@@ -454,7 +517,7 @@ void text_title::serialize(std::wostream & _Wostream)
}
void text_title::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_title::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
}
......@@ -488,7 +551,7 @@ void text_placeholder::serialize(std::wostream & _Wostream)
}
}
void text_placeholder::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_placeholder::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
}
......@@ -529,7 +592,7 @@ void text_page_number::serialize(std::wostream & _Wostream)
}
}
void text_page_number::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_page_number::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
......@@ -565,7 +628,7 @@ void text_page_count::serialize(std::wostream & _Wostream)
}
}
}
void text_page_count::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_page_count::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
......@@ -602,7 +665,7 @@ void text_date::serialize(std::wostream & _Wostream)
}
}
}
void text_date::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_date::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
......@@ -643,7 +706,7 @@ void text_time::serialize(std::wostream & _Wostream)
}
void text_time::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_time::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
......@@ -682,7 +745,7 @@ void text_file_name::serialize(std::wostream & _Wostream)
}
void text_file_name::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_file_name::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
......@@ -717,7 +780,7 @@ void text_sequence::serialize(std::wostream & _Wostream)
}
}
void text_sequence::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_sequence::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(text_);
}
......@@ -737,7 +800,7 @@ void text_sequence::add_text(const std::wstring & Text)
const wchar_t * text_sheet_name::ns = L"text";
const wchar_t * text_sheet_name::name = L"sheet-name";
void text_sheet_name::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_sheet_name::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
......
......@@ -61,7 +61,7 @@ using xml::xml_char_wc;
const wchar_t * text_h::ns = L"text";
const wchar_t * text_h::name = L"h";
void paragraph::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name, odf_conversion_context * Context)
void paragraph::create_child_element( const std::wstring & Ns, const std::wstring & Name, odf_conversion_context * Context)
{
CP_CREATE_ELEMENT_SIMPLE(paragraph_content_);
}
......@@ -126,7 +126,7 @@ void text_h::serialize(std::wostream & _Wostream)
}
}
//
void text_h::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_h::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
paragraph_.create_child_element(Ns, Name, getContext());
}
......@@ -144,7 +144,7 @@ void text_h::add_child_element( const office_element_ptr & child_element)
const wchar_t * text_p::ns = L"text";
const wchar_t * text_p::name = L"p";
void text_p::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_p::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
paragraph_.create_child_element( Ns, Name, getContext());
}
......@@ -194,7 +194,7 @@ void text_list::serialize(std::wostream & _Wostream)
}
}
void text_list::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_list::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"list-header")
{
......@@ -219,7 +219,7 @@ void text_list::add_child_element( const office_element_ptr & child_element)
const wchar_t * text_soft_page_break::ns = L"text";
const wchar_t * text_soft_page_break::name = L"soft-page-break";
void text_soft_page_break::serialize(::std::wostream & _Wostream)
void text_soft_page_break::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -245,7 +245,7 @@ void text_section_attr::serialize(CP_ATTR_NODE)
const wchar_t * text_section::ns = L"text";
const wchar_t * text_section::name = L"section";
void text_section::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_section::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
if (L"text" == Ns && L"section-source" == Name)
{
......@@ -301,7 +301,7 @@ void text_section_source_attr::serialize(CP_ATTR_NODE)
const wchar_t * text_section_source::ns = L"text";
const wchar_t * text_section_source::name = L"section-source";
void text_section_source::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_section_source::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
CP_NOT_APPLICABLE_ELM();
}
......@@ -320,7 +320,7 @@ void text_section_source::serialize(std::wostream & _Wostream)
const wchar_t * text_index_body::ns = L"text";
const wchar_t * text_index_body::name = L"index-body";
void text_index_body::serialize(::std::wostream & _Wostream)
void text_index_body::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -334,7 +334,7 @@ void text_index_body::serialize(::std::wostream & _Wostream)
}
}
void text_index_body::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_index_body::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(index_content_main_);
}
......@@ -349,7 +349,7 @@ void text_index_body::add_child_element( const office_element_ptr & child_elemen
const wchar_t * text_index_title::ns = L"text";
const wchar_t * text_index_title::name = L"index-title";
void text_index_title::serialize(::std::wostream & _Wostream)
void text_index_title::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -362,7 +362,7 @@ void text_index_title::serialize(::std::wostream & _Wostream)
}
}
}
void text_index_title::create_child_element(const ::std::wstring & Ns, const ::std::wstring & Name)
void text_index_title::create_child_element(const std::wstring & Ns, const std::wstring & Name)
{
CP_CREATE_ELEMENT(index_content_main_);
}
......@@ -376,7 +376,7 @@ void text_index_title::add_child_element( const office_element_ptr & child_eleme
const wchar_t * text_table_of_content::ns = L"text";
const wchar_t * text_table_of_content::name = L"table-of-content";
void text_table_of_content::serialize(::std::wostream & _Wostream)
void text_table_of_content::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
......@@ -388,7 +388,7 @@ void text_table_of_content::serialize(::std::wostream & _Wostream)
}
}
}
void text_table_of_content::create_child_element( const ::std::wstring & Ns, const ::std::wstring & Name)
void text_table_of_content::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
if CP_CHECK_NAME(L"text", L"index-body")
{
......
......@@ -323,6 +323,16 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown)
OOX::Logic::CCommentReference* pCommRef = static_cast<OOX::Logic::CCommentReference*>(oox_unknown);
convert(pCommRef); //если нет Start - означает начало с предыдущего Run
}break;
case OOX::et_w_footnoteReference:
{
OOX::Logic::CFootnoteReference* pRef= static_cast<OOX::Logic::CFootnoteReference*>(oox_unknown);
convert(pRef);
}break;
case OOX::et_w_endnoteReference:
{
OOX::Logic::CEndnoteReference* pRef= static_cast<OOX::Logic::CEndnoteReference*>(oox_unknown);
convert(pRef);
}break;
case OOX::et_w_tbl:
{
OOX::Logic::CTbl* pTable= static_cast<OOX::Logic::CTbl*>(oox_unknown);
......@@ -563,11 +573,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
}break;
//annotationRef
//endnoteRef
//endnoteReference
//footnoteRef
//footnoteReference
//commentReference
//separator
//contentPart
//cr
//dayLong, dayShort, monthLong, monthShort, yearLong, yearShort
......@@ -3266,7 +3272,7 @@ void DocxConverter::convert(OOX::Logic::CCommentRangeEnd* oox_comm_end)
}
void DocxConverter::convert(OOX::Logic::CCommentReference* oox_comm_ref)
{
if(oox_comm_ref == NULL)return;
if (oox_comm_ref == NULL) return;
if (oox_comm_ref->m_oId.IsInit() == false) return;
int oox_comm_id = oox_comm_ref->m_oId->GetValue();
......@@ -3278,16 +3284,34 @@ void DocxConverter::convert(OOX::Logic::CCommentReference* oox_comm_ref)
//значит старт тута а не по RangeStart
convert_comment(oox_comm_id);
}
}
void DocxConverter::convert(OOX::Logic::CFootnoteReference* oox_ref)
{
if (oox_ref == NULL) return;
if (oox_ref->m_oId.IsInit() == false) return;
int oox_ref_id = oox_ref->m_oId->GetValue();
convert_footnote(oox_ref_id);
}
void DocxConverter::convert(OOX::Logic::CEndnoteReference* oox_ref)
{
if (oox_ref == NULL) return;
if (oox_ref->m_oId.IsInit() == false) return;
int oox_ref_id = oox_ref->m_oId->GetValue();
convert_endnote(oox_ref_id);
}
void DocxConverter::convert_comment(int oox_comm_id)
{
OOX::CComments * docx_comments = docx_document->GetComments();
if (!docx_comments)return;
for (unsigned int comm =0 ; comm < docx_comments->m_arrComments.size(); comm++)
for (unsigned int comm = 0 ; comm < docx_comments->m_arrComments.size(); comm++)
{
OOX::CComment* oox_comment = docx_comments->m_arrComments[comm];
if (oox_comment == NULL) continue;
if (oox_comment->m_oId.IsInit() == false) continue;
......@@ -3295,11 +3319,11 @@ void DocxConverter::convert_comment(int oox_comm_id)
{
odt_context->start_comment_content();
{
if (oox_comment->m_oAuthor.IsInit())odt_context->comment_context()->set_author (string2std_string(*oox_comment->m_oAuthor));
if (oox_comment->m_oAuthor.IsInit()) odt_context->comment_context()->set_author (string2std_string(*oox_comment->m_oAuthor));
if (oox_comment->m_oDate.IsInit()) odt_context->comment_context()->set_date (string2std_string(oox_comment->m_oDate->GetValue()));
if (oox_comment->m_oInitials.IsInit()){}
if (oox_comment->m_oInitials.IsInit()) {}
for (unsigned int i=0; i <oox_comment->m_arrItems.size(); i++)
for (unsigned int i = 0; i <oox_comment->m_arrItems.size(); i++)
{
convert(oox_comment->m_arrItems[i]);
}
......@@ -3308,6 +3332,62 @@ void DocxConverter::convert_comment(int oox_comm_id)
}
}
}
void DocxConverter::convert_footnote(int oox_ref_id)
{
OOX::CFootnotes * footnotes = docx_document->GetFootnotes();
if (!footnotes)return;
odt_context->start_note(oox_ref_id, 1);
for (unsigned int n = 0 ; n < footnotes->m_arrFootnote.size(); n++)
{
OOX::CFtnEdn* oox_note = footnotes->m_arrFootnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;
if (oox_note->m_oId->GetValue() == oox_ref_id)
{
odt_context->start_note_content();
{
for (unsigned int i = 0; i < oox_note->m_arrItems.size(); i++)
{
convert(oox_note->m_arrItems[i]);
}
}
odt_context->end_note_content();
}
}
odt_context->end_note();
}
void DocxConverter::convert_endnote(int oox_ref_id)
{
OOX::CEndnotes * endnotes = docx_document->GetEndnotes();
if (!endnotes)return;
odt_context->start_note(oox_ref_id, 2);
for (unsigned int n = 0 ; n < endnotes->m_arrEndnote.size(); n++)
{
OOX::CFtnEdn* oox_note = endnotes->m_arrEndnote[n];
if (oox_note == NULL) continue;
if (oox_note->m_oId.IsInit() == false) continue;
if (oox_note->m_oId->GetValue() == oox_ref_id)
{
odt_context->start_note_content();
{
for (unsigned int i = 0; i < oox_note->m_arrItems.size(); i++)
{
convert(oox_note->m_arrItems[i]);
}
}
odt_context->end_note_content();
}
}
odt_context->end_note();
}
void DocxConverter::convert_hdr_ftr (CString sId)
{
OOX::CHdrFtr * oox_hdr_ftr = docx_document->GetHeaderOrFooter(sId);
......
......@@ -71,6 +71,8 @@ namespace OOX
class CCommentRangeStart;
class CCommentRangeEnd;
class CCommentReference;
class CFootnoteReference;
class CEndnoteReference;
class CTbl;
class CTblGrid;
class CTr;
......@@ -146,11 +148,13 @@ namespace Oox2Odf
void apply_from(OOX::Logic::CSectionProperty *props, OOX::Logic::CSectionProperty *other);
void convert_document();
void convert_styles();
void convert_lists_styles();
void convert_settings();
void convert_document ();
void convert_styles ();
void convert_lists_styles ();
void convert_settings ();
void convert_footnote (int oox_ref_id);
void convert_endnote (int oox_ref_id);
void convert_comment (int oox_comm_id);
void convert_hdr_ftr (CString sId);
......@@ -214,6 +218,9 @@ namespace Oox2Odf
void convert(OOX::Logic::CCommentRangeEnd *oox_comm_end);
void convert(OOX::Logic::CCommentReference *oox_comm_ref);
void convert(OOX::Logic::CFootnoteReference *oox_note_ref);
void convert(OOX::Logic::CEndnoteReference *oox_note_ref);
void convert(OOX::Logic::CTbl *oox_table);
void convert(OOX::Logic::CTblGrid *oox_table_grid);
void convert(OOX::Logic::CTr *oox_table_row);
......
......@@ -733,6 +733,14 @@
RelativePath="..\OdfFormat\odf_drawing_context.h"
>
</File>
<File
RelativePath="..\OdfFormat\odf_notes_context.cpp"
>
</File>
<File
RelativePath="..\OdfFormat\odf_notes_context.h"
>
</File>
<File
RelativePath="..\OdfFormat\odf_settings_context.cpp"
>
......
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