mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-01 00:31:50 +08:00
Compare commits
14 Commits
core-win-6
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| 9991195d56 | |||
| 51f579a682 | |||
| 45e0459434 | |||
| 2f194ebd97 | |||
| 5e4ce83dc1 | |||
| 50d4f451b9 | |||
| d464aa659a | |||
| db2d001110 | |||
| b883cfcbd4 | |||
| bb8add215a | |||
| ff7d7a908c | |||
| 958e213f9b | |||
| 3d3baa50b5 | |||
| ee987f8713 |
@ -369,42 +369,51 @@ void docx_conversion_context::start_index_content()
|
||||
|
||||
std::wstring sInstrText;
|
||||
|
||||
switch(table_content_context_.type_table_content)
|
||||
if (table_content_context_.type_table_content == 3)
|
||||
{
|
||||
case 1: sInstrText += L" TOC \\f \\h \\u"; break;
|
||||
case 2:
|
||||
case 4:
|
||||
case 6:
|
||||
case 7: sInstrText += L" TOC \\h \\z"; break;
|
||||
case 5: sInstrText += L" INDEX \\z"; break;
|
||||
case 3: sInstrText += L" BIBLIOGRAPHY"; break;
|
||||
sInstrText = L" BIBLIOGRAPHY ";
|
||||
}
|
||||
if (table_content_context_.min_outline_level > 0)
|
||||
else if (table_content_context_.type_table_content == 5)
|
||||
{
|
||||
if (table_content_context_.max_outline_level > 9)
|
||||
table_content_context_.max_outline_level = 9;
|
||||
|
||||
sInstrText += L" \\o \"" + std::to_wstring(table_content_context_.min_outline_level) + L"-" +
|
||||
std::to_wstring(table_content_context_.max_outline_level) + L"\"";
|
||||
sInstrText = L" INDEX";
|
||||
if (table_content_context_.bSeparators)
|
||||
sInstrText += L" \\h \"A\"";
|
||||
}
|
||||
if (false == table_content_context_.outline_level_styles.empty())
|
||||
else
|
||||
{
|
||||
sInstrText += L"\\t \"";
|
||||
sInstrText += L" TOC \\h";
|
||||
|
||||
for (std::map<int, std::wstring>::iterator it = table_content_context_.outline_level_styles.begin();
|
||||
it != table_content_context_.outline_level_styles.end(); ++it)
|
||||
if (table_content_context_.type_table_content == 1)
|
||||
sInstrText += L" \\f \\u";
|
||||
else
|
||||
sInstrText += L" \\z";
|
||||
|
||||
if (table_content_context_.min_outline_level > 0)
|
||||
{
|
||||
sInstrText += it->second + L";" + std::to_wstring(it->first) + L";";
|
||||
if (table_content_context_.max_outline_level > 9)
|
||||
table_content_context_.max_outline_level = 9;
|
||||
|
||||
sInstrText += L" \\o \"" + std::to_wstring(table_content_context_.min_outline_level) + L"-" +
|
||||
std::to_wstring(table_content_context_.max_outline_level) + L"\"";
|
||||
}
|
||||
if (false == table_content_context_.outline_level_styles.empty())
|
||||
{
|
||||
sInstrText += L" \\t \"";
|
||||
|
||||
for (std::map<int, std::wstring>::iterator it = table_content_context_.outline_level_styles.begin();
|
||||
it != table_content_context_.outline_level_styles.end(); ++it)
|
||||
{
|
||||
sInstrText += it->second + L";" + std::to_wstring(it->first) + L";";
|
||||
}
|
||||
|
||||
sInstrText += L"\"";
|
||||
}
|
||||
|
||||
sInstrText += L"\"";
|
||||
if (!table_content_context_.caption_sequence_name.empty())
|
||||
{
|
||||
sInstrText += L" \\c \"" + table_content_context_.caption_sequence_name + L"\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (!table_content_context_.caption_sequence_name.empty())
|
||||
{
|
||||
sInstrText += L" \\c \"" + table_content_context_.caption_sequence_name + L"\"";
|
||||
}
|
||||
|
||||
output_stream() << L"<w:r>";
|
||||
output_stream() << L"<w:fldChar w:fldCharType=\"begin\"/>";
|
||||
output_stream() << L"</w:r>";
|
||||
|
||||
@ -693,7 +693,8 @@ public:
|
||||
{
|
||||
current_content_template_.clear();
|
||||
}
|
||||
current_content_template_ = pFind->second.content;
|
||||
else
|
||||
current_content_template_ = pFind->second.content;
|
||||
current_content_template_index_ = 0;
|
||||
}
|
||||
|
||||
@ -730,6 +731,7 @@ public:
|
||||
min_outline_level = -1;
|
||||
max_outline_level = -1;
|
||||
outline_level_styles.clear();
|
||||
bSeparators = false;
|
||||
}
|
||||
void add_sequence(const std::wstring & name, int outline_level)
|
||||
{
|
||||
@ -754,6 +756,7 @@ public:
|
||||
int min_outline_level;
|
||||
int max_outline_level;
|
||||
std::map<int, std::wstring> outline_level_styles;
|
||||
bool bSeparators;
|
||||
|
||||
private:
|
||||
std::vector<int> current_content_template_;
|
||||
|
||||
@ -1278,7 +1278,7 @@ void sequence::docx_convert(oox::docx_conversion_context & Context)
|
||||
}
|
||||
}
|
||||
|
||||
Context.output_stream() << L"<w:fldSimple w:instr=\" SEQ " << sequence << L" \\* " << num_format << L" \">";
|
||||
Context.output_stream() << L"<w:fldSimple w:instr=\" SEQ " << XmlUtils::EncodeXmlString(sequence) << L" \\* " << num_format << L" \">";
|
||||
Context.add_new_run();
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
{
|
||||
@ -1846,12 +1846,22 @@ void alphabetical_index_mark::add_attributes( const xml::attributes_wc_ptr & Att
|
||||
}
|
||||
void alphabetical_index_mark::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (!string_value_) return;
|
||||
std::wstring value;
|
||||
if (string_value_ && false == string_value_->empty())
|
||||
{
|
||||
if (*string_value_ != L" ")
|
||||
value = *string_value_;
|
||||
}
|
||||
if (value.empty() && key1_)
|
||||
{
|
||||
value = *key1_;
|
||||
}
|
||||
if (value.empty()) return;
|
||||
|
||||
Context.finish_run();
|
||||
|
||||
Context.output_stream() << L"<w:r><w:fldChar w:fldCharType=\"begin\"/></w:r>";
|
||||
Context.output_stream() << L"<w:r><w:instrText> XE \"" << *string_value_ << L"\"</w:instrText></w:r><w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
Context.output_stream() << L"<w:r><w:instrText> XE \"" << XmlUtils::EncodeXmlString(value) << L"\"</w:instrText></w:r><w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// text:alphabetical-index-mark-start
|
||||
|
||||
@ -1273,7 +1273,9 @@ const wchar_t * alphabetical_index_source::name = L"alphabetical-index-source";
|
||||
|
||||
void alphabetical_index_source::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"text:index-scope", index_scope_); // chapter or document
|
||||
CP_APPLY_ATTR(L"text:index-scope", index_scope_); // chapter or document
|
||||
CP_APPLY_ATTR(L"text:alphabetical-separators", alphabetical_separators_);
|
||||
CP_APPLY_ATTR(L"text:ignore-case", ignore_case_);
|
||||
|
||||
}
|
||||
void alphabetical_index_source::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -1286,6 +1288,11 @@ void alphabetical_index_source::add_child_element( xml::sax * Reader, const std:
|
||||
}
|
||||
void alphabetical_index_source::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (alphabetical_separators_)
|
||||
{
|
||||
Context.get_table_content_context().bSeparators = alphabetical_separators_->get();
|
||||
}
|
||||
|
||||
Context.get_table_content_context().start_template(5);
|
||||
for (size_t i = 0; i < entry_templates_.size(); i++)
|
||||
{
|
||||
|
||||
@ -1283,7 +1283,9 @@ 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);
|
||||
|
||||
_CP_OPT(std::wstring) index_scope_; // chapter or document:
|
||||
_CP_OPT(std::wstring) index_scope_; // chapter or document:
|
||||
_CP_OPT(odf_types::Bool) alphabetical_separators_;
|
||||
_CP_OPT(odf_types::Bool) ignore_case_;
|
||||
|
||||
//fo:country
|
||||
//fo:language
|
||||
@ -1295,7 +1297,6 @@ private:
|
||||
//text:combine-entries-with-dash
|
||||
//text:combine-entries-with-pp
|
||||
//text:comma-separated
|
||||
//text:ignore-case
|
||||
//text:main-entry-style-name
|
||||
//text:relative-tab-stop-position
|
||||
//text:sort-algorithm
|
||||
|
||||
@ -96,10 +96,10 @@ HRESULT convert_single(std::wstring srcFileName)
|
||||
|
||||
Oox2Odf::Converter converter(srcTempPath, type, L"C:\\Windows\\Fonts", NULL);
|
||||
|
||||
std::wstring sPassword = L"password";
|
||||
std::wstring sPassword = L"";//password";
|
||||
|
||||
converter.convert();
|
||||
converter.write(dstTempPath, srcTempPath, sPassword);
|
||||
converter.write(dstTempPath, srcTempPath, sPassword, L"hiuh56f56tfy7g");
|
||||
|
||||
NSDirectory::DeleteDirectory(srcTempPath);
|
||||
|
||||
|
||||
@ -124,6 +124,15 @@ namespace odf_writer
|
||||
{
|
||||
type_ = t;
|
||||
}
|
||||
documentID_file::documentID_file(std::wstring v)
|
||||
{
|
||||
value_ = v;
|
||||
}
|
||||
void documentID_file::write(const std::wstring & RootPath, bool add_padding)
|
||||
{
|
||||
simple_element elm(L"documentID", value_, false);
|
||||
elm.write(RootPath, false);
|
||||
}
|
||||
mimetype_file::mimetype_file(std::wstring t)
|
||||
{
|
||||
type_ = t;
|
||||
@ -291,6 +300,14 @@ namespace odf_writer
|
||||
{
|
||||
dynamic_cast<manifect_file*>(manifest_.get())->add_rels(r);
|
||||
}
|
||||
void odf_document::set_documentID(const std::wstring &value)
|
||||
{
|
||||
add_object(element_ptr(new documentID_file(value)));
|
||||
|
||||
rels rels_;
|
||||
rels_.add(relationship(std::wstring(L"application/binary"), L"documentID"));
|
||||
set_rels(rels_);
|
||||
}
|
||||
|
||||
odf_document::odf_document(std::wstring type)
|
||||
{
|
||||
|
||||
@ -159,6 +159,17 @@ namespace odf_writer
|
||||
rels rels_;
|
||||
std::wstring type_;
|
||||
|
||||
};
|
||||
class documentID_file : public element
|
||||
{
|
||||
public:
|
||||
documentID_file(std::wstring value);
|
||||
|
||||
virtual void write(const std::wstring & RootPath, bool add_padding = false);
|
||||
|
||||
private:
|
||||
std::wstring value_;
|
||||
|
||||
};
|
||||
class mimetype_file : public element
|
||||
{
|
||||
@ -219,11 +230,12 @@ namespace odf_writer
|
||||
void set_rels(rels & r);
|
||||
|
||||
virtual void write(const std::wstring & RootPath, bool add_padding = false);
|
||||
|
||||
void write_manifest(const std::wstring & RootPath);
|
||||
|
||||
manifect_file* get_manifest() {return dynamic_cast<manifect_file*>(manifest_.get());}
|
||||
|
||||
void set_documentID(const std::wstring &value);
|
||||
|
||||
private:
|
||||
element_ptr base_;
|
||||
std::vector<element_ptr> objects_;
|
||||
|
||||
@ -284,8 +284,8 @@ private:
|
||||
|
||||
class Impl;
|
||||
_CP_PTR(Impl) impl_;
|
||||
|
||||
};
|
||||
typedef shared_ptr<odf_drawing_context>::Type odf_drawing_context_ptr;
|
||||
|
||||
}
|
||||
}
|
||||
@ -462,13 +462,14 @@ void odf_text_context::end_list()
|
||||
|
||||
list_state_.levels.pop_back();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////// LIST
|
||||
void odf_text_context::start_field(int type)
|
||||
//------------------------------------------------------------------------------------------ LIST
|
||||
|
||||
bool odf_text_context::start_field(int type)
|
||||
{
|
||||
if (single_paragraph_ == true) return;
|
||||
if (single_paragraph_ == true) return false;
|
||||
|
||||
office_element_ptr elm;
|
||||
if (type == 2)
|
||||
if (type == fieldPage)
|
||||
{
|
||||
create_element(L"text", L"page-number", elm, odf_context_);
|
||||
text_page_number *page_numb = dynamic_cast<text_page_number*>(elm.get());
|
||||
@ -485,19 +486,23 @@ void odf_text_context::start_field(int type)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == 3)
|
||||
if (type == fieldNumPages)
|
||||
{
|
||||
create_element(L"text", L"page-count", elm, odf_context_);
|
||||
}
|
||||
if (type == 4)
|
||||
if (type == fieldTime)
|
||||
{
|
||||
create_element(L"text", L"date", elm, odf_context_);
|
||||
}
|
||||
|
||||
if (elm)
|
||||
{
|
||||
in_field_ = true;
|
||||
start_element(elm);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void odf_text_context::end_field()
|
||||
|
||||
@ -43,7 +43,22 @@
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer
|
||||
{
|
||||
enum _typeField
|
||||
{
|
||||
fieldUnknown = 0,
|
||||
fieldHyperlink,
|
||||
fieldPage,
|
||||
fieldNumPages,
|
||||
fieldTime,
|
||||
fieldPageRef,
|
||||
fieldSeq,
|
||||
|
||||
fieldBibliography = 0xff + 1,
|
||||
fieldIndex,
|
||||
fieldIllustration,
|
||||
fieldTable,
|
||||
fieldToc
|
||||
};
|
||||
class odf_conversion_context;
|
||||
class odf_style_context;
|
||||
class paragraph;
|
||||
@ -80,7 +95,7 @@ public:
|
||||
void start_element (office_element_ptr & elm, office_element_ptr style_elm = office_element_ptr(),std::wstring style_name = L"");
|
||||
void end_element ();
|
||||
|
||||
void start_field (int type);
|
||||
bool start_field (int type);
|
||||
void end_field ();
|
||||
|
||||
void start_span (bool styled = false);
|
||||
@ -139,6 +154,7 @@ private:
|
||||
std::wstring parent_span_style_;
|
||||
std::wstring parent_paragraph_style_;
|
||||
};
|
||||
typedef shared_ptr<odf_text_context>::Type odf_text_context_ptr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,11 +32,11 @@
|
||||
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "../utils.h"
|
||||
|
||||
#include "odt_conversion_context.h"
|
||||
#include "odf_text_context.h"
|
||||
|
||||
#include "styles.h"
|
||||
|
||||
@ -78,10 +78,6 @@ odt_conversion_context::odt_conversion_context(package::odf_document * outputDoc
|
||||
comment_context_(this), notes_context_(this), main_text_context_(NULL), table_context_(this)
|
||||
{
|
||||
|
||||
current_field_.enabled = false;
|
||||
current_field_.started = false;
|
||||
current_field_.in_span = false;
|
||||
|
||||
is_hyperlink_ = false;
|
||||
|
||||
is_header_ = false;
|
||||
@ -117,6 +113,27 @@ void odt_conversion_context::start_document()
|
||||
|
||||
void odt_conversion_context::end_document()
|
||||
{
|
||||
if (false == mapSequenceDecls.empty())
|
||||
{
|
||||
office_element_ptr seq_decls;
|
||||
create_element(L"text", L"sequence-decls", seq_decls, this);
|
||||
|
||||
for (std::map<std::wstring, int>::iterator it = mapSequenceDecls.begin(); it != mapSequenceDecls.end(); ++it)
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"sequence-decl", elm, this);
|
||||
|
||||
text_sequence_decl* decl = dynamic_cast<text_sequence_decl*>(elm.get());
|
||||
if (decl)
|
||||
{
|
||||
decl->name_ = it->first;
|
||||
decl->display_outline_level_ = 0;
|
||||
}
|
||||
seq_decls->add_child_element(elm);
|
||||
}
|
||||
root_document_->add_child_element(seq_decls);
|
||||
}
|
||||
|
||||
//add sections to root
|
||||
for (size_t i = 0; i < sections_.size(); i++)
|
||||
{
|
||||
@ -286,8 +303,19 @@ void odt_conversion_context::end_drawings()
|
||||
}
|
||||
void odt_conversion_context::start_paragraph(bool styled)
|
||||
{
|
||||
if (current_field_.enabled && !current_field_.result) return; //Стандартное_составное_письмо.docx
|
||||
|
||||
if (!current_fields.empty() && current_fields.back().status == 1 && !current_fields.back().in_span)
|
||||
{
|
||||
current_fields.back().status = 2;
|
||||
//if (!current_fields.empty() && !current_fields.back().result) return; //Стандартное_составное_письмо.docx
|
||||
switch (current_fields.back().type)
|
||||
{
|
||||
case fieldBibliography: start_bibliography(); break;
|
||||
case fieldIndex: start_alphabetical_index(); break;
|
||||
case fieldIllustration: start_illustration_index(); break;
|
||||
case fieldTable: start_table_index(); break;
|
||||
case fieldToc: start_table_of_content(); break;
|
||||
}
|
||||
}
|
||||
if (is_paragraph_in_current_section_ && !styled)
|
||||
{
|
||||
styles_context()->create_style(L"", odf_types::style_family::Paragraph, true, false, -1);
|
||||
@ -345,45 +373,266 @@ void odt_conversion_context::add_paragraph_break(int type)
|
||||
//}
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::start_table_of_content()
|
||||
{
|
||||
office_element_ptr elm;
|
||||
|
||||
create_element(L"text", L"table-of-content", elm, this);
|
||||
text_context()->start_element(elm);
|
||||
|
||||
add_to_root();
|
||||
|
||||
start_index_field();
|
||||
}
|
||||
|
||||
void odt_conversion_context::end_table_of_content()
|
||||
{
|
||||
text_context()->end_element();
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"table-of-content-source", elm, this);
|
||||
text_table_of_content_source* source = dynamic_cast<text_table_of_content_source*>(elm.get());
|
||||
|
||||
if (source)
|
||||
{
|
||||
if (false == current_fields.back().arStyleLevels.empty())
|
||||
{
|
||||
source->outline_level_ = (int) current_fields.back().arStyleLevels.size();
|
||||
source->use_index_source_styles_ = true;
|
||||
}
|
||||
else if (current_fields.back().outline_levels > 0)
|
||||
{
|
||||
source->outline_level_ = current_fields.back().outline_levels;
|
||||
}
|
||||
}
|
||||
|
||||
text_context()->start_element(elm);
|
||||
//template
|
||||
text_context()->end_element();
|
||||
text_context()->end_element();
|
||||
}
|
||||
|
||||
void odt_conversion_context::start_alphabetical_index()
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"alphabetical-index", elm, this);
|
||||
text_context()->start_element(elm);
|
||||
|
||||
add_to_root();
|
||||
|
||||
start_index_field();
|
||||
}
|
||||
void odt_conversion_context::end_alphabetical_index()
|
||||
{
|
||||
text_context()->end_element();
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"alphabetical-index-source", elm, this);
|
||||
|
||||
text_context()->start_element(elm);
|
||||
//tempalte
|
||||
text_context()->end_element();
|
||||
text_context()->end_element();
|
||||
}
|
||||
void odt_conversion_context::start_illustration_index()
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"illustration-index", elm, this);
|
||||
text_context()->start_element(elm);
|
||||
|
||||
add_to_root();
|
||||
|
||||
start_index_field();
|
||||
}
|
||||
void odt_conversion_context::end_illustration_index()
|
||||
{
|
||||
text_context()->end_element();
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"illustration-index-source", elm, this);
|
||||
text_illustration_index_source* index_source = dynamic_cast<text_illustration_index_source*>(elm.get());
|
||||
if (index_source)
|
||||
{
|
||||
if (false == current_fields.back().captionSEQ.empty())
|
||||
{
|
||||
index_source->caption_sequence_name_ = current_fields.back().captionSEQ;
|
||||
index_source->caption_sequence_format_ = L"text";
|
||||
}
|
||||
}
|
||||
|
||||
text_context()->start_element(elm);
|
||||
//template
|
||||
text_context()->end_element();
|
||||
text_context()->end_element();
|
||||
}
|
||||
|
||||
void odt_conversion_context::start_bibliography()
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"bibliography", elm, this);
|
||||
text_context()->start_element(elm);
|
||||
|
||||
add_to_root();
|
||||
|
||||
start_index_field();
|
||||
}
|
||||
void odt_conversion_context::end_bibliography()
|
||||
{
|
||||
text_context()->end_element();
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"bibliography-source", elm, this);
|
||||
|
||||
text_context()->start_element(elm);
|
||||
//template
|
||||
text_context()->end_element();
|
||||
text_context()->end_element();
|
||||
}
|
||||
void odt_conversion_context::start_table_index()
|
||||
{
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"table-index", elm, this);
|
||||
text_context()->start_element(elm);
|
||||
|
||||
add_to_root();
|
||||
|
||||
start_index_field();
|
||||
}
|
||||
void odt_conversion_context::end_table_index()
|
||||
{
|
||||
text_context()->end_element();
|
||||
|
||||
office_element_ptr elm;
|
||||
create_element(L"text", L"table-index-source", elm, this);
|
||||
|
||||
text_context()->start_element(elm);
|
||||
//template
|
||||
text_context()->end_element();
|
||||
text_context()->end_element();
|
||||
}
|
||||
void odt_conversion_context::start_index_field()
|
||||
{
|
||||
if (current_fields.empty()) return;
|
||||
|
||||
office_element_ptr elm1, elm2;
|
||||
create_element(L"text", L"index-body", elm1, this);
|
||||
text_context()->start_element(elm1);
|
||||
|
||||
if (false == current_fields.back().title.empty())
|
||||
{
|
||||
create_element(L"text", L"index-title", elm2, this);
|
||||
text_context()->start_element(elm2);
|
||||
text_context()->end_element();
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::end_index_field()
|
||||
{
|
||||
text_context()->end_element();
|
||||
text_context()->end_element();
|
||||
}
|
||||
|
||||
void odt_conversion_context::start_hyperlink(std::wstring ref)
|
||||
{
|
||||
office_element_ptr hyperlink_elm;
|
||||
create_element(L"text", L"a", hyperlink_elm, this);
|
||||
|
||||
text_a* hyperlink = dynamic_cast<text_a*>(hyperlink_elm.get());
|
||||
if (!hyperlink)return;
|
||||
if (hyperlink)
|
||||
{
|
||||
hyperlink->common_xlink_attlist_.href_ = ref;
|
||||
hyperlink->common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
|
||||
text_context()->start_element(hyperlink_elm);
|
||||
|
||||
////////////////////////////
|
||||
|
||||
hyperlink->common_xlink_attlist_.href_ = ref;
|
||||
hyperlink->common_xlink_attlist_.type_ = xlink_type::Simple;
|
||||
|
||||
//current_level_.back()->add_child_element(hyperlink_elm);
|
||||
//current_level_.push_back(hyperlink_elm);
|
||||
|
||||
text_context()->start_element(hyperlink_elm);
|
||||
|
||||
is_hyperlink_ = true;
|
||||
is_hyperlink_ = true;
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::end_hyperlink()
|
||||
{
|
||||
if (!is_hyperlink_) return;
|
||||
|
||||
//current_level_.pop_back();
|
||||
text_context()->end_element();
|
||||
|
||||
is_hyperlink_ = false; //метка .. для гиперлинков в объектах - там не будет span
|
||||
}
|
||||
void odt_conversion_context::start_sequence()
|
||||
{
|
||||
std::map<std::wstring, int>::iterator pFind = mapSequenceDecls.find(current_fields.back().value);
|
||||
|
||||
int index = 0;
|
||||
if (pFind == mapSequenceDecls.end())
|
||||
{
|
||||
mapSequenceDecls.insert(std::make_pair(current_fields.back().value, index));
|
||||
}
|
||||
else
|
||||
{
|
||||
index = ++pFind->second;
|
||||
}
|
||||
office_element_ptr seq_elm;
|
||||
create_element(L"text", L"sequence", seq_elm, this);
|
||||
|
||||
text_sequence* sequence = dynamic_cast<text_sequence*>(seq_elm.get());
|
||||
if (sequence)
|
||||
{
|
||||
sequence->name_ = current_fields.back().value;
|
||||
sequence->ref_name_ = L"ref" + current_fields.back().value + std::to_wstring(index);
|
||||
sequence->formula_ = L"ooow:" + current_fields.back().value + L"+1";
|
||||
sequence->style_num_format_ = style_numformat(style_numformat::arabic);
|
||||
|
||||
text_context()->start_element(seq_elm);
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::end_sequence()
|
||||
{
|
||||
text_context()->end_element();
|
||||
}
|
||||
std::map<std::wstring, std::wstring> odt_conversion_context::parse_instr_options(const std::wstring& value)
|
||||
{
|
||||
std::map<std::wstring, std::wstring> result;
|
||||
|
||||
std::vector<std::wstring> arOptions;
|
||||
boost::algorithm::split(arOptions, value, boost::algorithm::is_any_of(L"\\"), boost::algorithm::token_compress_on);
|
||||
|
||||
for (size_t i = 0; i < arOptions.size(); i++)
|
||||
{
|
||||
std::wstring key = arOptions[i].substr(0, 1);
|
||||
std::wstring value;
|
||||
if (arOptions[i].length() > 2)
|
||||
{
|
||||
size_t pos = arOptions[i].find(L"\"");
|
||||
if (std::wstring::npos != pos)
|
||||
{
|
||||
value = arOptions[i].substr(pos + 1, arOptions[i].length() - pos - 1);
|
||||
|
||||
pos = value.rfind(L"\"");
|
||||
if (std::wstring::npos != pos)
|
||||
{
|
||||
value = value.substr(0, pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = arOptions[i].substr(1);
|
||||
}
|
||||
}
|
||||
result.insert(std::make_pair(key, value));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void odt_conversion_context::set_field_instr(std::wstring instr)
|
||||
{
|
||||
if (current_field_.enabled == false) return;
|
||||
if (current_fields.empty()) return;
|
||||
|
||||
current_fields.back().status = 1; //prepare
|
||||
|
||||
current_field_.type = 0; //users field
|
||||
size_t res1 = instr.find(L"HYPERLINK");
|
||||
if (std::wstring::npos != res1) //это не поле - это hyperlink
|
||||
if (std::wstring::npos != res1)
|
||||
{
|
||||
current_field_.type = 1;
|
||||
current_fields.back().type = fieldHyperlink;
|
||||
current_fields.back().in_span = false;
|
||||
|
||||
std::wstring ref;
|
||||
boost::match_results<std::wstring::const_iterator> res;
|
||||
@ -391,66 +640,145 @@ void odt_conversion_context::set_field_instr(std::wstring instr)
|
||||
if (boost::regex_search(instr, res, r2))
|
||||
{
|
||||
ref = res[1].str();
|
||||
current_field_.value = ref.substr(1, ref.length()-2);
|
||||
current_fields.back().value = ref.substr(1, ref.length() - 2);
|
||||
|
||||
}
|
||||
}
|
||||
res1 = instr.find(L"NUMPAGES");
|
||||
if (std::wstring::npos != res1 && current_field_.type == 0)
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_field_.type = 3;
|
||||
current_fields.back().type = fieldNumPages;
|
||||
}
|
||||
res1 = instr.find(L"PAGEREF");
|
||||
if (std::wstring::npos != res1 && current_field_.type == 0 ) //это не поле - это bookmark
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0 )
|
||||
{
|
||||
current_field_.type = 5;
|
||||
current_fields.back().type = fieldPageRef;
|
||||
if (instr.length() > 9)
|
||||
current_field_.value = instr.substr(9, instr.length()-5);
|
||||
current_fields.back().value = instr.substr(9, instr.length() - 5);
|
||||
}
|
||||
res1 = instr.find(L"PAGE");
|
||||
if (std::wstring::npos != res1 && current_field_.type == 0)
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_field_.type = 2;
|
||||
current_fields.back().type = fieldPage;
|
||||
}
|
||||
res1 = instr.find(L"TIME");
|
||||
if (std::wstring::npos != res1 && current_field_.type == 0)
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_field_.type = 4;
|
||||
current_fields.back().type = fieldTime;
|
||||
}
|
||||
res1 = instr.find(L"SEQ");
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_fields.back().type = fieldSeq;
|
||||
std::map<std::wstring, std::wstring> options = parse_instr_options(instr.substr(4));
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator it = options.begin(); it != options.end(); ++it)
|
||||
{
|
||||
if (it->first == L" ")
|
||||
{
|
||||
current_fields.back().value = it->second.substr(0, it->second.length() - 1);
|
||||
}
|
||||
else if (it->first == L"*")
|
||||
{
|
||||
current_fields.back().format = it->second.substr(0, it->second.length() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
res1 = instr.find(L"BIBLIOGRAPHY");
|
||||
if (std::wstring::npos != res1 && current_field_.type == 0)
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_field_.type = 6;
|
||||
current_fields.back().type = fieldBibliography;
|
||||
current_fields.back().in_span = false;
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
res1 = instr.find(L"INDEX");
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_fields.back().type = fieldIndex;
|
||||
current_fields.back().in_span = false;
|
||||
}
|
||||
res1 = instr.find(L"TOC");
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_fields.back().type = fieldIllustration;
|
||||
current_fields.back().in_span = false;
|
||||
std::map<std::wstring, std::wstring> options = parse_instr_options(instr.substr(res1 + 3));
|
||||
|
||||
std::map<std::wstring, std::wstring>::iterator pFind = options.find(L"c");
|
||||
if ( pFind != options.end())
|
||||
{
|
||||
current_fields.back().captionSEQ = pFind->second;
|
||||
}
|
||||
pFind = options.find(L"h");
|
||||
if ( pFind != options.end())
|
||||
{
|
||||
current_fields.back().bHyperlinks = true;
|
||||
}
|
||||
pFind = options.find(L"u"); //paragraph outline level
|
||||
if ( pFind != options.end())
|
||||
{
|
||||
current_fields.back().type = fieldToc; //table of content
|
||||
}
|
||||
pFind = options.find(L"o");
|
||||
if ( pFind != options.end())//table of content outline levels style
|
||||
{
|
||||
std::vector<std::wstring> arLevels;
|
||||
boost::algorithm::split(arLevels, pFind->second, boost::algorithm::is_any_of(L"-"), boost::algorithm::token_compress_on);
|
||||
if (arLevels.size() > 1)
|
||||
{
|
||||
current_fields.back().type = fieldToc;
|
||||
current_fields.back().outline_levels = XmlUtils::GetInteger(arLevels[1]);
|
||||
}
|
||||
}
|
||||
pFind = options.find(L"t");
|
||||
if ( pFind != options.end())//content styles name
|
||||
{
|
||||
std::vector<std::wstring> arStyles;
|
||||
boost::algorithm::split(arStyles, pFind->second, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
|
||||
|
||||
for (size_t i = 0; i < arStyles.size() - 1; i += 2)
|
||||
{
|
||||
int level = XmlUtils::GetInteger(arStyles[i + 1]);
|
||||
if (level < 1) continue;
|
||||
|
||||
while(current_fields.back().arStyleLevels.size() + 1 < level )
|
||||
{
|
||||
current_fields.back().arStyleLevels.push_back(L"");
|
||||
}
|
||||
current_fields.back().arStyleLevels.push_back(arStyles[i]);
|
||||
}
|
||||
}
|
||||
pFind = options.find(L"z");
|
||||
if ( pFind != options.end())//table of content outline levels style
|
||||
{
|
||||
current_fields.back().bHidePageNumbers = true;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////
|
||||
res1 = instr.find(L"@");
|
||||
if (std::wstring::npos != res1)
|
||||
{
|
||||
current_field_.format = instr.substr(res1 + 1, instr.length());
|
||||
current_fields.back().format = instr.substr(res1 + 1, instr.length());
|
||||
}
|
||||
|
||||
if (current_field_.type == 0)
|
||||
if (current_fields.back().type == 0)
|
||||
{
|
||||
res1 = instr.find(L" ");
|
||||
if (std::wstring::npos != res1)
|
||||
{
|
||||
current_field_.name = instr.substr(0, res1);
|
||||
current_fields.back().name = instr.substr(0, res1);
|
||||
}
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::start_field(bool in_span)
|
||||
{
|
||||
current_field_.enabled = true;
|
||||
|
||||
current_field_.result = false;
|
||||
current_field_.in_span = in_span;
|
||||
current_field_.value.clear();
|
||||
current_field_.name.clear();
|
||||
current_field_.type = 0; // users field
|
||||
_field_state field;
|
||||
current_fields.push_back(field);
|
||||
}
|
||||
void odt_conversion_context::separate_field()
|
||||
{
|
||||
current_field_.result = true;
|
||||
if (current_fields.empty()) return;
|
||||
|
||||
current_fields.back().result = true;
|
||||
}
|
||||
void odt_conversion_context::set_master_page_name(std::wstring master_name)
|
||||
{
|
||||
@ -587,26 +915,40 @@ void odt_conversion_context::add_section_column(std::vector<std::pair<double, do
|
||||
}
|
||||
void odt_conversion_context::end_field()
|
||||
{
|
||||
if (current_field_.enabled && current_field_.started)
|
||||
{
|
||||
if (current_field_.type == 1) end_hyperlink();
|
||||
else text_context()->end_field();
|
||||
}
|
||||
current_field_.value = L"";
|
||||
current_field_.format = L"";
|
||||
current_field_.name = L"";
|
||||
if (current_fields.empty()) return;
|
||||
|
||||
current_field_.result = false;
|
||||
current_field_.enabled = false;
|
||||
current_field_.started = false;
|
||||
current_field_.in_span = false;
|
||||
if (current_fields.back().status == 2)
|
||||
{
|
||||
current_fields.back().status = 3;//prepare for delete
|
||||
|
||||
if (current_fields.back().type < 0xff)
|
||||
{
|
||||
if (current_fields.back().type == fieldHyperlink) end_hyperlink();
|
||||
else if (current_fields.back().type == fieldSeq) end_sequence();
|
||||
else text_context()->end_field();
|
||||
|
||||
current_fields.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::end_paragraph()
|
||||
{
|
||||
if (current_field_.enabled && !current_field_.result) return; //Стандартное_составное_письмо.docx
|
||||
|
||||
//if (!current_fields.empty() && !current_fields.back().result) return; //Стандартное_составное_письмо.docx
|
||||
text_context()->end_paragraph();
|
||||
|
||||
if (false == current_fields.empty() && current_fields.back().status == 3) //prepare for delete
|
||||
{
|
||||
switch(current_fields.back().type)
|
||||
{
|
||||
case fieldBibliography: end_bibliography(); break;
|
||||
case fieldIndex: end_alphabetical_index(); break;
|
||||
case fieldIllustration: end_illustration_index(); break;
|
||||
case fieldTable: end_table_index(); break;
|
||||
case fieldToc: end_table_of_content(); break;
|
||||
}
|
||||
current_fields.pop_back();
|
||||
}
|
||||
|
||||
flush_section();
|
||||
}
|
||||
|
||||
@ -706,11 +1048,13 @@ void odt_conversion_context::start_run(bool styled)
|
||||
{
|
||||
if (is_hyperlink_ && text_context_.size() > 0) return;
|
||||
|
||||
|
||||
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && !current_field_.in_span)
|
||||
if (!current_fields.empty() && current_fields.back().status == 1 && !current_fields.back().in_span && current_fields.back().type < 0xff)
|
||||
{
|
||||
text_context()->start_field(current_field_.type);
|
||||
current_field_.started = true;
|
||||
current_fields.back().status = 2;
|
||||
|
||||
if (current_fields.back().type == fieldHyperlink) start_hyperlink(current_fields.back().value);
|
||||
else if (current_fields.back().type == fieldSeq) start_sequence();
|
||||
else text_context()->start_field(current_fields.back().type);
|
||||
}
|
||||
|
||||
text_context()->start_span(styled);
|
||||
@ -722,25 +1066,28 @@ void odt_conversion_context::start_run(bool styled)
|
||||
props->apply_from(dynamic_cast<style_text_properties*>(drop_cap_state_.text_properties.get()));
|
||||
|
||||
}
|
||||
if (current_field_.started == false && current_field_.type > 1 && current_field_.enabled == true && current_field_.in_span)//поле стартуется в span - нужно для сохранения стиля
|
||||
if (!current_fields.empty() && current_fields.back().status == 1 && current_fields.back().in_span)//поле стартуется в span - нужно для сохранения стиля
|
||||
{
|
||||
text_context()->start_field(current_field_.type);
|
||||
current_field_.started = true;
|
||||
current_fields.back().status = 2;
|
||||
text_context()->start_field(current_fields.back().type);
|
||||
}
|
||||
}
|
||||
void odt_conversion_context::end_run()
|
||||
{
|
||||
if (is_hyperlink_ && text_context_.size() > 0) return;
|
||||
|
||||
if (current_field_.in_span && current_field_.started== true && current_field_.enabled ==true) end_field();
|
||||
if (!current_fields.empty() && current_fields.back().status == 1 && current_fields.back().in_span)
|
||||
{
|
||||
end_field();
|
||||
}
|
||||
|
||||
text_context()->end_span();
|
||||
|
||||
if (current_field_.started== false && current_field_.type == 1 && current_field_.enabled ==true)
|
||||
{
|
||||
start_hyperlink(current_field_.value);
|
||||
current_field_.started = true;
|
||||
}
|
||||
//if (current_field_.enabled == true && current_field_.started== false && current_field_.type == 1)
|
||||
//{
|
||||
// start_hyperlink(current_field_.value);
|
||||
// current_field_.started = true;
|
||||
//}
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool odt_conversion_context::start_comment(int oox_comm_id)
|
||||
|
||||
@ -36,17 +36,14 @@
|
||||
#include "odf_comment_context.h"
|
||||
#include "odf_notes_context.h"
|
||||
#include "odf_table_context.h"
|
||||
#include "odf_text_context.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_writer {
|
||||
|
||||
namespace cpdoccore
|
||||
{
|
||||
namespace odf_writer
|
||||
{
|
||||
class office_text;
|
||||
|
||||
class odf_text_context;
|
||||
|
||||
typedef shared_ptr<odf_text_context>::Type odf_text_context_ptr;
|
||||
typedef shared_ptr<odf_drawing_context>::Type odf_drawing_context_ptr;
|
||||
|
||||
struct odt_section_state
|
||||
{
|
||||
office_element_ptr elm;
|
||||
@ -93,11 +90,33 @@ public:
|
||||
void start_hyperlink (std::wstring ref);
|
||||
void end_hyperlink ();
|
||||
|
||||
void start_sequence ();
|
||||
void end_sequence ();
|
||||
|
||||
void start_table_of_content ();
|
||||
void end_table_of_content ();
|
||||
|
||||
void start_bibliography ();
|
||||
void end_bibliography ();
|
||||
|
||||
void start_alphabetical_index ();
|
||||
void end_alphabetical_index ();
|
||||
|
||||
void start_illustration_index ();
|
||||
void end_illustration_index ();
|
||||
|
||||
void start_table_index ();
|
||||
void end_table_index ();
|
||||
|
||||
void start_index_field();
|
||||
void end_index_field();
|
||||
|
||||
void start_field (bool in_span);
|
||||
void end_field ();
|
||||
void separate_field ();
|
||||
void set_field_instr (std::wstring instr);
|
||||
|
||||
std::map<std::wstring, std::wstring> parse_instr_options(const std::wstring& value);
|
||||
|
||||
void start_run (bool styled = false);
|
||||
void end_run ();
|
||||
|
||||
@ -182,19 +201,32 @@ private:
|
||||
std::vector<odf_element_state> current_root_elements_; // for section, if needed
|
||||
std::vector<odt_section_state> sections_;
|
||||
|
||||
std::map<std::wstring, int> mapSequenceDecls;
|
||||
|
||||
void add_to_root();
|
||||
|
||||
struct _field_state
|
||||
{
|
||||
_typeField type = fieldUnknown;
|
||||
|
||||
std::wstring name;
|
||||
bool enabled;
|
||||
int type;
|
||||
std::wstring value;
|
||||
|
||||
std::wstring format;
|
||||
bool started;
|
||||
bool in_span;
|
||||
bool result;
|
||||
}current_field_;
|
||||
short status = 0;//0, 1, 2, 3 - init, prapare, start, finish
|
||||
bool in_span = false;
|
||||
bool result = false; //after separate
|
||||
bool bHyperlinks = false;
|
||||
bool bHidePageNumbers = false;
|
||||
std::wstring captionSEQ;
|
||||
std::wstring title;
|
||||
std::vector<std::wstring> arStyleLevels;
|
||||
int outline_levels = 0;
|
||||
std::vector<int> arTemplateTypes;//text, link, tab ....
|
||||
int tabLeader = 0;//dot
|
||||
};
|
||||
|
||||
std::vector<_field_state> current_fields;
|
||||
|
||||
struct _text_changes_state
|
||||
{
|
||||
|
||||
@ -89,14 +89,34 @@ void office_text_attlist::serialize(CP_ATTR_NODE)
|
||||
}
|
||||
void office_text::create_child_element( const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (is_text_content(Ns, Name))
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
if CP_CHECK_NAME(L"office", L"forms")
|
||||
{
|
||||
CP_CREATE_ELEMENT(forms_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"text", L"tracked-changes")
|
||||
{
|
||||
CP_CREATE_ELEMENT(tracked_changes_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"table", L"content-validations")
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_content_validations_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"text", L"user-field-decls")
|
||||
{
|
||||
CP_CREATE_ELEMENT(user_fields_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"text", L"sequence-decls")
|
||||
{
|
||||
CP_CREATE_ELEMENT(sequences_);
|
||||
}
|
||||
else if CP_CHECK_NAME(L"text", L"variable-decls")
|
||||
{
|
||||
CP_CREATE_ELEMENT(variables_);
|
||||
}
|
||||
else if (is_text_content(Ns, Name))
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
else
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
@ -107,6 +127,10 @@ void office_text::add_child_element( const office_element_ptr & child_element)
|
||||
|
||||
switch(child_element->get_type())
|
||||
{
|
||||
case typeTextSequenceDecls:
|
||||
{
|
||||
sequences_ = child_element;
|
||||
}break;
|
||||
case typeTextTrackedChanges:
|
||||
{
|
||||
tracked_changes_ = child_element;
|
||||
@ -130,6 +154,9 @@ void office_text::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
office_text_attlist_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
if (sequences_)
|
||||
sequences_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (tracked_changes_)
|
||||
tracked_changes_->serialize(CP_XML_STREAM());
|
||||
|
||||
|
||||
@ -71,7 +71,13 @@ public:
|
||||
|
||||
private:
|
||||
office_element_ptr tracked_changes_;
|
||||
office_element_ptr_array content_;
|
||||
office_element_ptr table_content_validations_;
|
||||
office_element_ptr user_fields_;
|
||||
office_element_ptr variables_;
|
||||
office_element_ptr sequences_;
|
||||
office_element_ptr forms_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
// TODO: office-text-content-prelude:
|
||||
// TODO: office-forms
|
||||
|
||||
@ -71,6 +71,13 @@ using xml::xml_char_wc;
|
||||
const wchar_t * text_text::ns = L"";
|
||||
const wchar_t * text_text::name = L"";
|
||||
|
||||
std::wostream & text_text::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
_Wostream << xml::utils::replace_text_to_xml( text_ );
|
||||
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void text_text::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
_Wostream << xml::utils::replace_text_to_xml( text_ );
|
||||
@ -236,6 +243,14 @@ void text_reference_mark_end::serialize(std::wostream & _Wostream)
|
||||
const wchar_t * text_span::ns = L"text";
|
||||
const wchar_t * text_span::name = L"span";
|
||||
|
||||
std::wostream & text_span::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
for (size_t i = 0; i < paragraph_content_.size(); i++)
|
||||
{
|
||||
paragraph_content_[i]->text_to_stream(_Wostream);
|
||||
}
|
||||
return _Wostream;
|
||||
}
|
||||
void text_span::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
@ -772,9 +787,15 @@ void text_sequence::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"text:name", name_);
|
||||
CP_XML_ATTR_OPT(L"text:ref-name", ref_name_);
|
||||
CP_XML_ATTR_OPT(L"style:num-format", style_num_format_);
|
||||
CP_XML_ATTR_OPT(L"style:num-letter-syn", style_num_letter_sync_);
|
||||
CP_XML_ATTR_OPT(L"text:formula", formula_);
|
||||
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
{
|
||||
text_[i]->serialize(CP_XML_STREAM());
|
||||
text_[i]->text_to_stream(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,8 @@ public:
|
||||
virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element( const office_element_ptr & child_element){}
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
text_text(const std::wstring & Text) : text_(Text) {}
|
||||
text_text() {}
|
||||
@ -316,6 +317,7 @@ public:
|
||||
virtual void add_child_element( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
text_span() {}
|
||||
|
||||
@ -678,7 +680,14 @@ public:
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
|
||||
office_element_ptr_array text_;
|
||||
_CP_OPT(odf_types::style_numformat) style_num_format_;
|
||||
_CP_OPT(std::wstring) style_num_letter_sync_;
|
||||
_CP_OPT(std::wstring) formula_;
|
||||
_CP_OPT(std::wstring) name_;
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
|
||||
_CP_OPT(std::wstring) template_;
|
||||
office_element_ptr_array text_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_sequence);
|
||||
|
||||
@ -379,25 +379,30 @@ void text_table_of_content::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
text_section_attr_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
if (text_index_body_)
|
||||
text_index_body_->serialize(CP_XML_STREAM());
|
||||
if (table_of_content_source_)
|
||||
table_of_content_source_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (text_table_of_content_source_)
|
||||
text_table_of_content_source_->serialize(CP_XML_STREAM());
|
||||
if (index_body_)
|
||||
index_body_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
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")
|
||||
{
|
||||
CP_CREATE_ELEMENT(text_index_body_);
|
||||
}
|
||||
if (L"text" == Ns && L"table-of-content-source" == Name) CP_CREATE_ELEMENT(table_of_content_source_);
|
||||
else if CP_CHECK_NAME(L"text", L"index-body") CP_CREATE_ELEMENT(index_body_);
|
||||
}
|
||||
|
||||
void text_table_of_content::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
text_index_body_ = child_element;
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextTableOfContentSource)
|
||||
table_of_content_source_= child_element;
|
||||
else if (type == typeTextIndexBody)
|
||||
index_body_ = child_element;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -616,7 +621,7 @@ const wchar_t * text_table_index::name = L"table-index";
|
||||
|
||||
void text_table_index::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (L"text" == Ns && L"index-body_" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
if (L"text" == Ns && L"index-body" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
else if (L"text" == Ns && L"table-index-source" == Name)CP_CREATE_ELEMENT(table_index_source_);
|
||||
}
|
||||
|
||||
@ -654,7 +659,7 @@ const wchar_t * text_illustration_index::name = L"illustration-index";
|
||||
|
||||
void text_illustration_index::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (L"text" == Ns && L"index-body_" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
if (L"text" == Ns && L"index-body" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
else if (L"text" == Ns && L"illustration-index-source" == Name) CP_CREATE_ELEMENT(illustration_index_source_);
|
||||
}
|
||||
|
||||
@ -687,12 +692,50 @@ void text_illustration_index::serialize(std::wostream & _Wostream)
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------
|
||||
const wchar_t * text_user_index::ns = L"text";
|
||||
const wchar_t * text_user_index::name = L"user-index";
|
||||
|
||||
void text_user_index::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (L"text" == Ns && L"index-body" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
else if (L"text" == Ns && L"user-index-source" == Name) CP_CREATE_ELEMENT(user_index_source_);
|
||||
}
|
||||
|
||||
void text_user_index::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextUserIndexSource)
|
||||
user_index_source_= child_element;
|
||||
else if (type == typeTextIndexBody)
|
||||
index_body_= child_element;
|
||||
}
|
||||
|
||||
void text_user_index::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
section_attr_.serialize(CP_GET_XML_NODE());
|
||||
|
||||
if (user_index_source_)
|
||||
user_index_source_->serialize(CP_XML_STREAM());
|
||||
|
||||
if (index_body_)
|
||||
index_body_->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------
|
||||
const wchar_t * text_alphabetical_index::ns = L"text";
|
||||
const wchar_t * text_alphabetical_index::name = L"alphabetical-index";
|
||||
|
||||
void text_alphabetical_index::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (L"text" == Ns && L"index-body_" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
if (L"text" == Ns && L"index-body" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
else if (L"text" == Ns && L"alphabetical-index-source" == Name) CP_CREATE_ELEMENT(alphabetical_index_source_);
|
||||
}
|
||||
|
||||
@ -730,7 +773,7 @@ const wchar_t * text_bibliography::name = L"bibliography";
|
||||
|
||||
void text_bibliography::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (L"text" == Ns && L"index-body_" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
if (L"text" == Ns && L"index-body" == Name) CP_CREATE_ELEMENT(index_body_);
|
||||
else if (L"text" == Ns && L"bibliography-source" == Name) CP_CREATE_ELEMENT(bibliography_source_);
|
||||
}
|
||||
|
||||
@ -898,6 +941,62 @@ void text_illustration_index_source::serialize(std::wostream & _Wostream)
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_user_index_source::ns = L"text";
|
||||
const wchar_t * text_user_index_source::name = L"user-index-source";
|
||||
|
||||
void text_user_index_source::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
if (L"text" == Ns && L"index-title-template" == Name) CP_CREATE_ELEMENT(index_title_template_);
|
||||
else CP_CREATE_ELEMENT(entry_templates_);
|
||||
}
|
||||
|
||||
void text_user_index_source::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
if (!child_element) return;
|
||||
|
||||
ElementType type = child_element->get_type();
|
||||
|
||||
if (type == typeTextIndexTitleTemplate)
|
||||
index_title_template_ = child_element;
|
||||
else
|
||||
entry_templates_.push_back(child_element);
|
||||
}
|
||||
|
||||
void text_user_index_source::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"text:index-name", index_name_);
|
||||
CP_XML_ATTR_OPT(L"text:copy-outline-levels", copy_outline_levels_);
|
||||
|
||||
CP_XML_ATTR_OPT(L"text:use-chart-objects", use_chart_objects_);
|
||||
CP_XML_ATTR_OPT(L"text:use-draw-objects", use_draw_objects_);
|
||||
CP_XML_ATTR_OPT(L"text:use-graphics", use_graphics_);
|
||||
CP_XML_ATTR_OPT(L"text:use-floating-frames", use_floating_frames_);
|
||||
CP_XML_ATTR_OPT(L"text:use-index-marks", use_index_marks_);
|
||||
CP_XML_ATTR_OPT(L"text:use-index_source_styles", use_index_source_styles_);
|
||||
CP_XML_ATTR_OPT(L"text:use-objects", use_objects_);
|
||||
CP_XML_ATTR_OPT(L"text:use-tables", use_tables_);
|
||||
CP_XML_ATTR_OPT(L"text:relative_tab-stop-position", relative_tab_stop_position_);
|
||||
CP_XML_ATTR_OPT(L"text:index-scope", index_scope_); // chapter or document
|
||||
|
||||
if (index_title_template_)
|
||||
index_title_template_->serialize(CP_XML_STREAM());
|
||||
|
||||
for (size_t i = 0 ; i < index_source_styles_.size(); i++)
|
||||
{
|
||||
index_source_styles_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
for (size_t i = 0 ; i < entry_templates_.size(); i++)
|
||||
{
|
||||
entry_templates_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * alphabetical_index_source::ns = L"text";
|
||||
const wchar_t * alphabetical_index_source::name = L"alphabetical-index-source";
|
||||
|
||||
@ -995,6 +1094,9 @@ const wchar_t * text_table_index_entry_template::name = L"table-index-entry-te
|
||||
const wchar_t * text_table_of_content_entry_template::ns = L"text";
|
||||
const wchar_t * text_table_of_content_entry_template::name = L"table-of-content-entry-template";
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_user_index_entry_template::ns = L"text";
|
||||
const wchar_t * text_user_index_entry_template::name = L"user-index-entry-template";
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_bibliography_entry_template::ns = L"text";
|
||||
const wchar_t * text_bibliography_entry_template::name = L"bibliography-entry-template";
|
||||
|
||||
@ -1153,5 +1255,46 @@ void text_index_entry_text::serialize(std::wostream & _Wostream)
|
||||
CP_XML_NODE_SIMPLE();
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_sequence_decl::ns = L"text";
|
||||
const wchar_t * text_sequence_decl::name = L"sequence-decl";
|
||||
|
||||
void text_sequence_decl::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT(L"text:name", name_);
|
||||
CP_XML_ATTR_OPT(L"text:separation-character", separation_character_);
|
||||
CP_XML_ATTR_OPT(L"text:display-outline-level", display_outline_level_);
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_sequence_decls::ns = L"text";
|
||||
const wchar_t * text_sequence_decls::name = L"sequence-decls";
|
||||
|
||||
void text_sequence_decls::create_child_element(const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void text_sequence_decls::add_child_element( const office_element_ptr & child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void text_sequence_decls::serialize(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
for (size_t i = 0 ; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,8 +272,8 @@ public:
|
||||
|
||||
text_section_attr text_section_attr_;
|
||||
|
||||
office_element_ptr text_table_of_content_source_;
|
||||
office_element_ptr text_index_body_;
|
||||
office_element_ptr table_of_content_source_;
|
||||
office_element_ptr index_body_;
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_table_of_content);
|
||||
@ -555,6 +555,30 @@ public:
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_alphabetical_index);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
// text:user-index
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_user_index : public office_element_impl<text_user_index>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextUserIndex;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element ( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
odf_types::section_attlists section_attr_;
|
||||
office_element_ptr user_index_source_;
|
||||
office_element_ptr index_body_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_user_index);
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
// text:bibliography
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
@ -654,48 +678,48 @@ public:
|
||||
_CP_OPT(std::wstring) content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_index_title_template);
|
||||
////---------------------------------------------------------------------------------------------------
|
||||
////text:sequence-decl
|
||||
////---------------------------------------------------------------------------------------------------
|
||||
//class text_sequence_decl : public office_element_impl<text_sequence_decl>
|
||||
//{
|
||||
//public:
|
||||
// static const wchar_t * ns;
|
||||
// static const wchar_t * name;
|
||||
// static const xml::NodeType xml_type = xml::typeElement;
|
||||
// static const ElementType type = typeTextSequenceDecl;
|
||||
// CPDOCCORE_DEFINE_VISITABLE()
|
||||
//
|
||||
// virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name);
|
||||
// virtual void add_child_element ( const office_element_ptr & child_element);
|
||||
//
|
||||
// virtual void serialize(std::wostream & _Wostream);
|
||||
//
|
||||
// _CP_OPT(std::wstring) separation_character_; //one char
|
||||
// _CP_OPT(unsigned int) display_outline_level_;
|
||||
// _CP_OPT(std::wstring) name_;
|
||||
//};
|
||||
//CP_REGISTER_OFFICE_ELEMENT2(text_sequence_decl);
|
||||
////---------------------------------------------------------------------------------------------------
|
||||
////text:sequence-decls
|
||||
////---------------------------------------------------------------------------------------------------
|
||||
//class text_sequence_decls : public office_element_impl<text_sequence_decls>
|
||||
//{
|
||||
//public:
|
||||
// static const wchar_t * ns;
|
||||
// static const wchar_t * name;
|
||||
// static const xml::NodeType xml_type = xml::typeElement;
|
||||
// static const ElementType type = typeTextSequenceDecls;
|
||||
// CPDOCCORE_DEFINE_VISITABLE()
|
||||
//
|
||||
// virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name);
|
||||
// virtual void add_child_element ( const office_element_ptr & child_element);
|
||||
//
|
||||
// virtual void serialize(std::wostream & _Wostream);
|
||||
//
|
||||
// office_element_ptr_array content_;
|
||||
//};
|
||||
//CP_REGISTER_OFFICE_ELEMENT2(text_sequence_decls);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:sequence-decl
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_sequence_decl : public office_element_impl<text_sequence_decl>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextSequenceDecl;
|
||||
CPDOCCORE_DEFINE_VISITABLE()
|
||||
|
||||
virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element ( const office_element_ptr & child_element){}
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) separation_character_; //one char
|
||||
_CP_OPT(unsigned int) display_outline_level_;
|
||||
_CP_OPT(std::wstring) name_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_sequence_decl);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:sequence-decls
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_sequence_decls : public office_element_impl<text_sequence_decls>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextSequenceDecls;
|
||||
CPDOCCORE_DEFINE_VISITABLE()
|
||||
|
||||
virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element ( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_sequence_decls);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:table-of-content-source
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
@ -928,6 +952,54 @@ public:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_illustration_index_entry_template);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:user-index-source
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_user_index_source: public office_element_impl<text_user_index_source>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextUserIndexSource;
|
||||
CPDOCCORE_DEFINE_VISITABLE()
|
||||
|
||||
virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name);
|
||||
virtual void add_child_element ( const office_element_ptr & child_element);
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) index_name_;
|
||||
_CP_OPT(odf_types::Bool) copy_outline_levels_;
|
||||
_CP_OPT(odf_types::Bool) relative_tab_stop_position_;
|
||||
_CP_OPT(odf_types::Bool) use_chart_objects_;
|
||||
_CP_OPT(odf_types::Bool) use_draw_objects_;
|
||||
_CP_OPT(odf_types::Bool) use_graphics_;
|
||||
_CP_OPT(odf_types::Bool) use_floating_frames_;
|
||||
_CP_OPT(odf_types::Bool) use_index_marks_;
|
||||
_CP_OPT(odf_types::Bool) use_index_source_styles_;
|
||||
_CP_OPT(odf_types::Bool) use_objects_;
|
||||
_CP_OPT(odf_types::Bool) use_tables_;
|
||||
_CP_OPT(std::wstring) index_scope_; // chapter or document:
|
||||
|
||||
office_element_ptr index_title_template_;
|
||||
office_element_ptr_array entry_templates_;
|
||||
office_element_ptr_array index_source_styles_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_user_index_source);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:user-index-entry-template
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_user_index_entry_template : public common_entry_template
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextUserIndexEntryTemplate;
|
||||
CPDOCCORE_DEFINE_VISITABLE()
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_user_index_entry_template);
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
//text:alphabetical-index-source
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class alphabetical_index_source : public office_element_impl<alphabetical_index_source>
|
||||
|
||||
@ -623,9 +623,9 @@ void OoxConverter::convert(PPTX::Logic::Shape *oox_shape)
|
||||
|
||||
//docx_converter->convert(oox_shape->oTextBoxShape.GetPointer());
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_shape->oTextBoxShape->m_arrItems.begin(); it != oox_shape->oTextBoxShape->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_shape->oTextBoxShape->m_arrItems.size(); i++)
|
||||
{
|
||||
docx_converter->convert(*it);
|
||||
docx_converter->convert(oox_shape->oTextBoxShape->m_arrItems[i]);
|
||||
|
||||
convert(oox_shape->oTextBoxBodyPr.GetPointer());
|
||||
|
||||
|
||||
@ -101,13 +101,13 @@ namespace Oox2Odf
|
||||
|
||||
impl_->convertDocument();
|
||||
}
|
||||
void Converter::write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password) const
|
||||
void Converter::write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password, const std::wstring & documentID) const
|
||||
{
|
||||
if (!impl_)return;
|
||||
|
||||
if (impl_->bUserStopConvert) return;
|
||||
|
||||
return impl_->write(out_path, temp_path, password);
|
||||
return impl_->write(out_path, temp_path, password, documentID);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -126,10 +126,15 @@ bool OoxConverter::UpdateProgress(long nComplete)
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
void OoxConverter::write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password)
|
||||
void OoxConverter::write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password, const std::wstring & documentID)
|
||||
{
|
||||
if (!output_document)return;
|
||||
|
||||
if (false == documentID.empty())
|
||||
{
|
||||
output_document->set_documentID(documentID);
|
||||
}
|
||||
|
||||
if (password.empty())
|
||||
{
|
||||
output_document->write(out_path);
|
||||
|
||||
@ -343,7 +343,7 @@ namespace Oox2Odf
|
||||
public:
|
||||
virtual void convertDocument() = 0;
|
||||
|
||||
void write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password);
|
||||
void write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password, const std::wstring & documentID);
|
||||
|
||||
OoxConverter(const ProgressCallback* CallBack = NULL){
|
||||
oox_current_child_document = NULL;
|
||||
|
||||
@ -412,9 +412,9 @@ void DocxConverter::convert(OOX::Logic::CSdtContent *oox_sdt)
|
||||
{
|
||||
if (oox_sdt == NULL) return;
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_sdt->m_arrItems.begin(); it != oox_sdt->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_sdt->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_sdt->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
@ -607,9 +607,9 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
{//rapcomnat12.docx - стр 185
|
||||
bool empty_para = true;
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_paragraph->m_arrItems.begin(); it != oox_paragraph->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_paragraph->m_arrItems.size(); ++i)
|
||||
{
|
||||
switch((*it)->getType())
|
||||
switch(oox_paragraph->m_arrItems[i]->getType())
|
||||
{
|
||||
case OOX::et_w_pPr: break;
|
||||
default:
|
||||
@ -631,17 +631,17 @@ void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_paragraph->m_arrItems.begin(); it != oox_paragraph->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_paragraph->m_arrItems.size(); ++i)
|
||||
{
|
||||
//те элементы которые тока для Paragraph - здесь - остальные в общей куче
|
||||
switch((*it)->getType())
|
||||
switch(oox_paragraph->m_arrItems[i]->getType())
|
||||
{
|
||||
case OOX::et_w_pPr:
|
||||
{
|
||||
// пропускаем ..
|
||||
}break;
|
||||
default:
|
||||
convert(*it);
|
||||
convert(oox_paragraph->m_arrItems[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -691,24 +691,24 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
|
||||
|
||||
odt_context->start_run(styled);
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_run->m_arrItems.begin(); it != oox_run->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_run->m_arrItems.size(); ++i)
|
||||
{
|
||||
//те элементы которые тока для Run - здесь - остальные в общей куче
|
||||
switch((*it)->getType())
|
||||
switch(oox_run->m_arrItems[i]->getType())
|
||||
{
|
||||
case OOX::et_w_fldChar:
|
||||
{
|
||||
OOX::Logic::CFldChar* pFldChar= dynamic_cast<OOX::Logic::CFldChar*>(*it);
|
||||
OOX::Logic::CFldChar* pFldChar= dynamic_cast<OOX::Logic::CFldChar*>(oox_run->m_arrItems[i]);
|
||||
convert(pFldChar);
|
||||
}break;
|
||||
case OOX::et_w_instrText:
|
||||
{
|
||||
OOX::Logic::CInstrText* pInstrText= dynamic_cast<OOX::Logic::CInstrText*>(*it);
|
||||
OOX::Logic::CInstrText* pInstrText= dynamic_cast<OOX::Logic::CInstrText*>(oox_run->m_arrItems[i]);
|
||||
convert(pInstrText);
|
||||
}break;
|
||||
case OOX::et_w_delText:
|
||||
{
|
||||
OOX::Logic::CDelText* pDelText= dynamic_cast<OOX::Logic::CDelText*>(*it);
|
||||
OOX::Logic::CDelText* pDelText= dynamic_cast<OOX::Logic::CDelText*>(oox_run->m_arrItems[i]);
|
||||
convert(pDelText);
|
||||
}break;
|
||||
case OOX::et_w_rPr: // пропускаем ..
|
||||
@ -719,7 +719,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
|
||||
}break;
|
||||
case OOX::et_w_br:
|
||||
{
|
||||
OOX::Logic::CBr* pBr= dynamic_cast<OOX::Logic::CBr*>(*it);
|
||||
OOX::Logic::CBr* pBr= dynamic_cast<OOX::Logic::CBr*>(oox_run->m_arrItems[i]);
|
||||
if (pBr)
|
||||
{
|
||||
int type = pBr->m_oType.GetValue();
|
||||
@ -732,17 +732,17 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
|
||||
}break;
|
||||
case OOX::et_w_t:
|
||||
{
|
||||
OOX::Logic::CText* pText= dynamic_cast<OOX::Logic::CText*>(*it);
|
||||
OOX::Logic::CText* pText= dynamic_cast<OOX::Logic::CText*>(oox_run->m_arrItems[i]);
|
||||
convert(pText);
|
||||
}break;
|
||||
case OOX::et_w_sym:
|
||||
{
|
||||
OOX::Logic::CSym* pSym= dynamic_cast<OOX::Logic::CSym*>(*it);
|
||||
OOX::Logic::CSym* pSym= dynamic_cast<OOX::Logic::CSym*>(oox_run->m_arrItems[i]);
|
||||
convert(pSym);
|
||||
}break;
|
||||
case OOX::et_w_tab:
|
||||
{
|
||||
OOX::Logic::CTab* pTab= dynamic_cast<OOX::Logic::CTab*>(*it);
|
||||
OOX::Logic::CTab* pTab= dynamic_cast<OOX::Logic::CTab*>(oox_run->m_arrItems[i]);
|
||||
odt_context->text_context()->add_tab();
|
||||
}break;
|
||||
|
||||
@ -759,7 +759,7 @@ void DocxConverter::convert(OOX::Logic::CRun *oox_run)//wordprocessing 22.1.2.87
|
||||
//softHyphen
|
||||
//delInstrText
|
||||
default:
|
||||
convert(*it);
|
||||
convert(oox_run->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_run();
|
||||
@ -861,9 +861,9 @@ void DocxConverter::convert(OOX::Logic::CFldSimple *oox_fld)
|
||||
if (oox_fld->m_sInstr.IsInit())
|
||||
odt_context->set_field_instr(oox_fld->m_sInstr.get2());
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_fld->m_arrItems.begin(); it != oox_fld->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_fld->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_fld->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_field();
|
||||
@ -898,9 +898,9 @@ void DocxConverter::convert(OOX::Logic::CIns *oox_ins)
|
||||
|
||||
bool start_change = odt_context->start_change(id, 1, author, userId, date);
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_ins->m_arrItems.begin(); it != oox_ins->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_ins->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_ins->m_arrItems[i]);
|
||||
}
|
||||
|
||||
if (start_change)
|
||||
@ -1103,9 +1103,9 @@ void DocxConverter::convert(OOX::Logic::CDel *oox_del)
|
||||
|
||||
bool res_change = odt_context->start_change(id, 2, author, userId, date);
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_del->m_arrItems.begin(); it != oox_del->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_del->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_del->m_arrItems[i]);
|
||||
}
|
||||
if (res_change)
|
||||
odt_context->end_change(id, 2);
|
||||
@ -1114,9 +1114,9 @@ void DocxConverter::convert(OOX::Logic::CSmartTag *oox_tag)
|
||||
{
|
||||
if (oox_tag == NULL) return;
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_tag->m_arrItems.begin(); it != oox_tag->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_tag->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_tag->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
void DocxConverter::convert(OOX::Logic::CParagraphProperty *oox_paragraph_pr, cpdoccore::odf_writer::style_paragraph_properties * paragraph_properties)
|
||||
@ -3036,27 +3036,34 @@ void DocxConverter::convert_styles()
|
||||
void DocxConverter::convert(OOX::Logic::CHyperlink *oox_hyperlink)
|
||||
{
|
||||
if (oox_hyperlink == NULL)return;
|
||||
|
||||
std::wstring ref;
|
||||
|
||||
if (oox_hyperlink->m_oId.IsInit()) //гиперлинк
|
||||
{
|
||||
std::wstring ref = find_link_by_id(oox_hyperlink->m_oId->GetValue(),2);
|
||||
|
||||
ref = find_link_by_id(oox_hyperlink->m_oId->GetValue(),2);
|
||||
}
|
||||
else if (oox_hyperlink->m_sAnchor.IsInit())
|
||||
{
|
||||
ref = L"#" + *oox_hyperlink->m_sAnchor;
|
||||
}
|
||||
if (false == ref.empty())
|
||||
{
|
||||
odt_context->start_hyperlink(ref);
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_hyperlink->m_arrItems.begin(); it != oox_hyperlink->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_hyperlink->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_hyperlink->m_arrItems[i]);
|
||||
}
|
||||
odt_context->end_hyperlink();
|
||||
}
|
||||
else
|
||||
{//ссылка внутри дока
|
||||
//anchor todooo
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_hyperlink->m_arrItems.begin(); it != oox_hyperlink->m_arrItems.end(); ++it)
|
||||
{
|
||||
for (size_t i = 0; i < oox_hyperlink->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_hyperlink->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
//nullable<std::wstring > m_sAnchor;
|
||||
//nullable<std::wstring > m_sDocLocation;
|
||||
//nullable<SimpleTypes::COnOff<SimpleTypes::onoffFalse> > m_oHistory;
|
||||
//nullable<std::wstring > m_sTgtFrame;
|
||||
@ -3606,9 +3613,9 @@ void DocxConverter::convert_comment(int oox_comm_id)
|
||||
if (oox_comment->m_oDate.IsInit()) odt_context->comment_context()->set_date (oox_comment->m_oDate->GetValue());
|
||||
if (oox_comment->m_oInitials.IsInit()) {}
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_comment->m_arrItems.begin(); it != oox_comment->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_comment->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_comment->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_comment_content();
|
||||
@ -3631,9 +3638,9 @@ void DocxConverter::convert_footnote(int oox_ref_id)
|
||||
{
|
||||
odt_context->start_note_content();
|
||||
{
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_note->m_arrItems.begin(); it != oox_note->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_note->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_note->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_note_content();
|
||||
@ -3658,9 +3665,9 @@ void DocxConverter::convert_endnote(int oox_ref_id)
|
||||
{
|
||||
odt_context->start_note_content();
|
||||
{
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_note->m_arrItems.begin(); it != oox_note->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_note->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_note->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_note_content();
|
||||
@ -3675,9 +3682,9 @@ void DocxConverter::convert_hdr_ftr (std::wstring sId)
|
||||
|
||||
oox_current_child_document = dynamic_cast<OOX::IFileContainer*>(oox_hdr_ftr);
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_hdr_ftr->m_arrItems.begin(); it != oox_hdr_ftr->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_hdr_ftr->m_arrItems.size(); ++i)
|
||||
{
|
||||
convert(*it);
|
||||
convert(oox_hdr_ftr->m_arrItems[i]);
|
||||
}
|
||||
oox_current_child_document = NULL;
|
||||
}
|
||||
@ -3854,16 +3861,16 @@ void DocxConverter::convert(OOX::Logic::CTbl *oox_table)
|
||||
convert(oox_table->m_oTblGrid.GetPointer());
|
||||
|
||||
//------ строки
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_table->m_arrItems.begin(); it != oox_table->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_table->m_arrItems.size(); ++i)
|
||||
{
|
||||
switch((*it)->getType())
|
||||
switch(oox_table->m_arrItems[i]->getType())
|
||||
{
|
||||
case OOX::et_w_tblPr:
|
||||
{
|
||||
//skip
|
||||
}break;
|
||||
default:
|
||||
convert(*it);
|
||||
convert(oox_table->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
if (in_frame)
|
||||
@ -3970,16 +3977,16 @@ void DocxConverter::convert(OOX::Logic::CTr *oox_table_row)
|
||||
|
||||
convert(oox_table_row->m_pTableRowProperties);
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_table_row->m_arrItems.begin(); it != oox_table_row->m_arrItems.end(); ++it)
|
||||
for (size_t i =0; i < oox_table_row->m_arrItems.size(); ++i)
|
||||
{
|
||||
switch((*it)->getType())
|
||||
switch(oox_table_row->m_arrItems[i]->getType())
|
||||
{
|
||||
case OOX::et_w_trPr:
|
||||
{
|
||||
//skip
|
||||
}break;
|
||||
default:
|
||||
convert(*it);
|
||||
convert(oox_table_row->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_table_row();
|
||||
@ -4030,16 +4037,16 @@ void DocxConverter::convert(OOX::Logic::CTc *oox_table_cell)
|
||||
odt_context->table_context()->set_cell_column_span(oox_table_cell->m_pTableCellProperties->m_oGridSpan->m_oVal->GetValue());
|
||||
}
|
||||
|
||||
for (std::vector<OOX::WritingElement*>::iterator it = oox_table_cell->m_arrItems.begin(); it != oox_table_cell->m_arrItems.end(); ++it)
|
||||
for (size_t i = 0; i < oox_table_cell->m_arrItems.size(); ++i)
|
||||
{
|
||||
switch((*it)->getType())
|
||||
switch(oox_table_cell->m_arrItems[i]->getType())
|
||||
{
|
||||
case OOX::et_w_tcPr:
|
||||
{
|
||||
//skip
|
||||
}break;
|
||||
default:
|
||||
convert(*it);
|
||||
convert(oox_table_cell->m_arrItems[i]);
|
||||
}
|
||||
}
|
||||
odt_context->end_table_cell();
|
||||
|
||||
@ -46,7 +46,7 @@ namespace Oox2Odf
|
||||
|
||||
void convert();
|
||||
|
||||
void write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password) const;
|
||||
void write(const std::wstring & out_path, const std::wstring & temp_path, const std::wstring & password, const std::wstring & documentID) const;
|
||||
|
||||
OoxConverter * get_ooxConverter() { return impl_; }
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT=$(readlink -n "$0" || grealpath "$0")
|
||||
SCRIPT=$(readlink -f "$0" || grealpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
os=$(uname -s)
|
||||
|
||||
@ -59,6 +59,13 @@ else
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-$ICU_MAJOR_VER-$ICU_MINOR_VER/icu4c ./icu
|
||||
fi
|
||||
|
||||
# Workaround for building icu older than 60.0 on Archlinux
|
||||
# See https://bugs.archlinux.org/task/55246
|
||||
if [ -f "/etc/arch-release" ]; then
|
||||
echo "Arch Linux detected. Applying 'xlocale.h' error patch"
|
||||
sed -i 's/xlocale/locale/' ./icu/source/i18n/digitlst.cpp
|
||||
fi
|
||||
|
||||
cd ./icu/source/
|
||||
|
||||
if [ ! -f "./Makefile" ]
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SCRIPT=$(readlink -f "$0" || grealpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
@ -3403,9 +3403,10 @@ namespace SimpleTypes
|
||||
std::wstring result;
|
||||
for (size_t i = 0 ; i < sText.length(); i++)
|
||||
{
|
||||
if (XmlUtils::IsUnicodeSymbol(sText[i]) == true)
|
||||
WCHAR wChar = sText[i];
|
||||
if (XmlUtils::IsUnicodeSymbol(wChar) == true && wChar > 0x20)
|
||||
{
|
||||
result += sText[i];
|
||||
result += wChar;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
static int GetFormatByExtension(const std::wstring& ext);
|
||||
|
||||
bool isOOXFormatFile (const std::wstring & fileName);
|
||||
bool isOpenOfficeFormatFile (const std::wstring & fileName);
|
||||
bool isOpenOfficeFormatFile (const std::wstring & fileName, std::wstring & documentID);
|
||||
bool isOnlyOfficeFormatFile (const std::wstring & fileName);
|
||||
|
||||
bool isDocFormatFile (POLE::Storage *storage);
|
||||
@ -74,11 +74,13 @@ public:
|
||||
bool isMS_OFFCRYPTOFormatFile (POLE::Storage * storage, std::wstring & documentID);
|
||||
bool isMS_OFFCRYPTOFormatFile (const std::wstring & fileName, std::wstring & documentID);
|
||||
|
||||
bool isDocFlatFormatFile (unsigned char* pBuffer,int dwBytes);
|
||||
std::wstring getDocumentID (const std::wstring & fileName);
|
||||
|
||||
bool isDocFlatFormatFile(unsigned char* pBuffer,int dwBytes);
|
||||
|
||||
bool isRtfFormatFile (unsigned char* pBuffer,int dwBytes);
|
||||
bool isHtmlFormatFile (unsigned char* pBuffer,int dwBytes, bool testCloseTag);
|
||||
bool isPdfFormatFile (unsigned char* pBuffer,int dwBytes);
|
||||
bool isPdfFormatFile (unsigned char* pBuffer,int dwBytes, std::wstring & documentID);
|
||||
bool isOpenOfficeFlatFormatFile(unsigned char* pBuffer,int dwBytes);
|
||||
|
||||
bool isBinaryDoctFormatFile (unsigned char* pBuffer,int dwBytes);
|
||||
|
||||
@ -117,24 +117,34 @@ bool COfficeFileFormatChecker::isBinaryPpttFormatFile (unsigned char* pBuffer,in
|
||||
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isPdfFormatFile (unsigned char* pBuffer,int dwBytes)
|
||||
bool COfficeFileFormatChecker::isPdfFormatFile (unsigned char* pBuffer,int dwBytes, std::wstring & documentID)
|
||||
{
|
||||
if (pBuffer == NULL) return false;
|
||||
|
||||
int nTempBufferSize = dwBytes < 20 ? dwBytes : 20;
|
||||
if (nTempBufferSize < 1)
|
||||
documentID.clear();
|
||||
|
||||
if (dwBytes < 1)
|
||||
return false;
|
||||
|
||||
char* pTempBuffer = new char[nTempBufferSize];
|
||||
pBuffer[dwBytes - 1] = '\0';
|
||||
|
||||
memcpy ( pTempBuffer, pBuffer, nTempBufferSize );
|
||||
pTempBuffer[nTempBufferSize - 1] = '\0';
|
||||
|
||||
char* pFirst = strstr( (char*)pTempBuffer, "%PDF-" );
|
||||
delete [] pTempBuffer;
|
||||
char* pFirst = strstr( (char*)pBuffer, "%PDF-" );
|
||||
|
||||
if( NULL != pFirst )
|
||||
{
|
||||
pFirst = strstr( (char*)pBuffer, "%DocumentID " );
|
||||
if( NULL != pFirst )
|
||||
{
|
||||
pFirst += 12;
|
||||
char* pLast = strstr( pFirst, " ");
|
||||
if( NULL != pLast )
|
||||
{
|
||||
std::string s(pFirst, pLast - pFirst);
|
||||
documentID = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)s.c_str(), s.length());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -232,6 +242,49 @@ bool COfficeFileFormatChecker::isPptFormatFile (POLE::Storage * storage)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring COfficeFileFormatChecker::getDocumentID (const std::wstring & _fileName )
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
std::wstring fileName = CorrectPathW(_fileName);
|
||||
#else
|
||||
std::wstring fileName = _fileName;
|
||||
#endif
|
||||
std::wstring documentID;
|
||||
|
||||
POLE::Storage storage(fileName.c_str());
|
||||
if (storage.open())
|
||||
{
|
||||
if ( isMS_OFFCRYPTOFormatFile(&storage, documentID) )
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_MS_OFFCRYPTO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( false == isOpenOfficeFormatFile(fileName, sDocumentID))
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (!file.OpenFile(fileName))
|
||||
return documentID;
|
||||
|
||||
unsigned char* buffer = new unsigned char[4096]; //enaf !!
|
||||
if (!buffer){file.CloseFile();return documentID;}
|
||||
|
||||
DWORD dwReadBytes = 0;
|
||||
file.ReadFile(buffer, MIN_SIZE_BUFFER, dwReadBytes);
|
||||
file.CloseFile();
|
||||
|
||||
if (isPdfFormatFile(buffer, (int)dwReadBytes, sDocumentID) )
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return documentID;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (const std::wstring & _fileName, std::wstring & documentID)
|
||||
{
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(_WIN64)
|
||||
@ -256,6 +309,8 @@ bool COfficeFileFormatChecker::isMS_OFFCRYPTOFormatFile (POLE::Storage * storage
|
||||
{
|
||||
if (storage == NULL) return false;
|
||||
|
||||
documentID.clear();
|
||||
|
||||
bool result = false;
|
||||
std::list<std::wstring> entries = storage->entries(L"DataSpaces");
|
||||
if (entries.size() > 0)
|
||||
@ -331,10 +386,10 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
if (OfficeUtils.IsArchive(fileName) == S_OK)
|
||||
{
|
||||
if ( isOOXFormatFile(fileName) ) return true;
|
||||
else if ( isOpenOfficeFormatFile(fileName) ) return true;
|
||||
else if ( isOnlyOfficeFormatFile(fileName) ) return true;
|
||||
else if ( isXpsFile(fileName) ) return true;
|
||||
if ( isOOXFormatFile(fileName) ) return true;
|
||||
else if ( isOpenOfficeFormatFile(fileName, sDocumentID) ) return true;
|
||||
else if ( isOnlyOfficeFormatFile(fileName) ) return true;
|
||||
else if ( isXpsFile(fileName) ) return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// others
|
||||
@ -366,7 +421,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring & _fileName)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PRESENTATION;
|
||||
}
|
||||
else if (isPdfFormatFile(buffer,sizeRead) )
|
||||
else if (isPdfFormatFile(buffer,sizeRead, sDocumentID) )
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
}
|
||||
@ -569,8 +624,10 @@ bool COfficeFileFormatChecker::isOnlyOfficeFormatFile(const std::wstring & fileN
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring & fileName)
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring & fileName, std::wstring & documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
|
||||
const char *odtFormatLine = "application/vnd.oasis.opendocument.text";
|
||||
const char *odsFormatLine = "application/vnd.oasis.opendocument.spreadsheet";
|
||||
const char *odpFormatLine = "application/vnd.oasis.opendocument.presentation";
|
||||
@ -584,7 +641,17 @@ bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring & fileN
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE *pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"mimetype", &pBuffer, nBufferSize);
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"documentID", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
documentID = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(pBuffer, nBufferSize);
|
||||
|
||||
delete []pBuffer;
|
||||
pBuffer = NULL;
|
||||
}
|
||||
|
||||
nBufferSize = 0;
|
||||
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"mimetype", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if ( NULL != strstr((char*)pBuffer, ottFormatLine) )
|
||||
@ -620,10 +687,12 @@ bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring & fileN
|
||||
pBuffer = NULL;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN) return true;
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
//если не записан тип смотрим манифест
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"META-INF/manifest.xml", &pBuffer, nBufferSize);
|
||||
nBufferSize = 0;
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"META-INF/manifest.xml", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
std::string xml_string((char*)pBuffer, nBufferSize);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2018
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -981,6 +981,88 @@ namespace NSEditorApi
|
||||
|
||||
LINK_PROPERTY_INT_JS(InsertPageNum)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CAscSlideTiming : public IMenuEventDataBase
|
||||
{
|
||||
private:
|
||||
js_wrapper<int> m_nTransitionType;
|
||||
js_wrapper<int> m_nTransitionOption;
|
||||
js_wrapper<int> m_nTransitionDuration;
|
||||
|
||||
js_wrapper<bool> m_bSlideAdvanceOnMouseClick;
|
||||
js_wrapper<bool> m_bSlideAdvanceAfter;
|
||||
js_wrapper<bool> m_bSlideAdvanceDuration;
|
||||
js_wrapper<bool> m_bShowLoop;
|
||||
|
||||
public:
|
||||
CAscSlideTiming()
|
||||
{
|
||||
}
|
||||
virtual ~CAscSlideTiming()
|
||||
{
|
||||
}
|
||||
LINK_PROPERTY_INT_JS(TransitionType)
|
||||
LINK_PROPERTY_INT_JS(TransitionOption)
|
||||
LINK_PROPERTY_INT_JS(TransitionDuration)
|
||||
|
||||
LINK_PROPERTY_BOOL_JS(SlideAdvanceOnMouseClick)
|
||||
LINK_PROPERTY_BOOL_JS(SlideAdvanceAfter)
|
||||
LINK_PROPERTY_BOOL_JS(SlideAdvanceDuration)
|
||||
LINK_PROPERTY_BOOL_JS(ShowLoop)
|
||||
};
|
||||
|
||||
class CAscTransitions : public IMenuEventDataBase
|
||||
{
|
||||
public:
|
||||
std::vector<CAscSlideTiming> m_arTransitions;
|
||||
public:
|
||||
|
||||
CAscTransitions()
|
||||
{}
|
||||
|
||||
virtual ~CAscTransitions()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CAscSlideProp : public IMenuEventDataBase
|
||||
{
|
||||
js_wrapper<CAscFill> m_oBackground;
|
||||
js_wrapper<CAscSlideTiming> m_oTiming;
|
||||
|
||||
js_wrapper<int> m_nLayoutIndex;
|
||||
js_wrapper<bool> m_bIsHidden;
|
||||
js_wrapper<bool> m_bLockBackground;
|
||||
js_wrapper<bool> m_bLockDelete;
|
||||
js_wrapper<bool> m_bLockLayout;
|
||||
js_wrapper<bool> m_bLockRemove;
|
||||
js_wrapper<bool> m_bLockTiming;
|
||||
js_wrapper<bool> m_bLockTransition;
|
||||
|
||||
public:
|
||||
CAscSlideProp()
|
||||
{
|
||||
}
|
||||
virtual ~CAscSlideProp()
|
||||
{
|
||||
}
|
||||
LINK_PROPERTY_OBJECT_JS(CAscFill, Background)
|
||||
LINK_PROPERTY_OBJECT_JS(CAscSlideTiming, Timing)
|
||||
|
||||
LINK_PROPERTY_INT_JS(LayoutIndex)
|
||||
LINK_PROPERTY_BOOL_JS(IsHidden)
|
||||
LINK_PROPERTY_BOOL_JS(LockBackground)
|
||||
LINK_PROPERTY_BOOL_JS(LockDelete)
|
||||
LINK_PROPERTY_BOOL_JS(LockLayout)
|
||||
LINK_PROPERTY_BOOL_JS(LockRemove)
|
||||
LINK_PROPERTY_BOOL_JS(LockTiming)
|
||||
LINK_PROPERTY_BOOL_JS(LockTransition)
|
||||
|
||||
};
|
||||
|
||||
class CAscImagePosition
|
||||
{
|
||||
|
||||
@ -688,6 +688,8 @@
|
||||
#define ASC_MENU_EVENT_TYPE_TABLEMERGECELLS 15
|
||||
#define ASC_MENU_EVENT_TYPE_TABLESPLITCELLS 16
|
||||
#define ASC_MENU_EVENT_TYPE_SECTION 17
|
||||
#define ASC_MENU_EVENT_TYPE_SHAPE 18
|
||||
#define ASC_MENU_EVENT_TYPE_SLIDE 20
|
||||
|
||||
// insert commands
|
||||
#define ASC_MENU_EVENT_TYPE_INSERT_IMAGE 50
|
||||
|
||||
@ -44,11 +44,8 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
|
||||
COfficeFileFormatChecker fileChecker;
|
||||
|
||||
std::wstring sDocumentID;
|
||||
std::wstring sDocumentID = fileChecker.getDocumentID(L"d:/test/_pdf/Test3-pdfa-my.pdf");
|
||||
|
||||
if (fileChecker.isMS_OFFCRYPTOFormatFile(dstFileName, sDocumentID))
|
||||
{
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,10 @@ LIBS += -lCryptoPPLib
|
||||
|
||||
DEFINES += NOMINMAX
|
||||
|
||||
core_linux {
|
||||
QMAKE_CXXFLAGS += -Wno-narrowing
|
||||
}
|
||||
|
||||
core_windows {
|
||||
DEFINES -= UNICODE
|
||||
DEFINES -= _UNICODE
|
||||
|
||||
@ -1890,18 +1890,19 @@ namespace NExtractTools
|
||||
std::wstring sTempUnpackedODP = sTemp + FILE_SEPARATOR_STR + _T("odp_unpacked");
|
||||
NSDirectory::CreateDirectory(sTempUnpackedODP);
|
||||
|
||||
std::wstring password = params.getSavePassword();
|
||||
|
||||
Oox2Odf::Converter converter(sPptxDir, _T("presentation"), params.getFontPath(), NULL);
|
||||
|
||||
int nRes = 0;
|
||||
try
|
||||
{
|
||||
converter.convert();
|
||||
converter.write(sTempUnpackedODP, sTemp, password);
|
||||
std::wstring password = params.getSavePassword();
|
||||
std::wstring documentID = params.getDocumentID();
|
||||
|
||||
converter.convert();
|
||||
converter.write(sTempUnpackedODP, sTemp, password, documentID);
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedODP, sTo, false, password.empty() ? Z_DEFLATED : 0)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedODP, sTo, false, password.empty() ? Z_DEFLATED : 0)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
}catch(...)
|
||||
{
|
||||
nRes = AVS_FILEUTILS_ERROR_CONVERT;
|
||||
@ -2465,10 +2466,11 @@ namespace NExtractTools
|
||||
int nRes = 0;
|
||||
try
|
||||
{
|
||||
std::wstring password = params.getSavePassword();
|
||||
|
||||
std::wstring password = params.getSavePassword();
|
||||
std::wstring documentID = params.getDocumentID();
|
||||
|
||||
converter.convert();
|
||||
converter.write(sTempUnpackedODT, sTemp, password);
|
||||
converter.write(sTempUnpackedODT, sTemp, password, documentID);
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedODT, sTo, false, password.empty() ? Z_DEFLATED : 0)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
@ -2502,10 +2504,11 @@ namespace NExtractTools
|
||||
{
|
||||
Oox2Odf::Converter converter(sXlsxDir, L"spreadsheet", params.getFontPath(), NULL);
|
||||
|
||||
std::wstring password = params.getSavePassword();
|
||||
std::wstring password = params.getSavePassword();
|
||||
std::wstring documentID = params.getDocumentID();
|
||||
|
||||
converter.convert();
|
||||
converter.write(sTempUnpackedODS, sTemp, password);
|
||||
converter.write(sTempUnpackedODS, sTemp, password, documentID);
|
||||
|
||||
COfficeUtils oCOfficeUtils(NULL);
|
||||
int nRes = (S_OK == oCOfficeUtils.CompressFileOrDirectory(sTempUnpackedODS, sTo, false, password.empty() ? Z_DEFLATED : 0)) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
|
||||
|
||||
Reference in New Issue
Block a user