Compare commits

...

8 Commits

Author SHA1 Message Date
b883cfcbd4 Add workaround for building icu on ArchLinux
See https://bugs.archlinux.org/task/55246
2018-07-12 16:51:17 +03:00
bb8add215a Fail on any error in subscripts
Without this command any errors are just ignored and script continues
2018-07-12 16:24:32 +03:00
ff7d7a908c [ios][pe] events 2018-07-12 11:15:40 +03:00
958e213f9b [x2t] Fix RemoveWhiteSpaces 2018-07-11 19:40:27 +03:00
3d3baa50b5 . 2018-07-11 18:15:28 +03:00
ee987f8713 OdfFormatWriter - add documentID, add table of content, table of indexes 2018-07-11 17:20:51 +03:00
e98f4ae7b4 PdfWriter - add documentID 2018-07-11 12:30:37 +03:00
6900c0a640 [x2t] Remove LvlRestart stubs 2018-07-10 20:28:09 +03:00
30 changed files with 673 additions and 190 deletions

View File

@ -1417,7 +1417,7 @@ public:
oWriter.WriteString(L"<w:numFmt w:val=\"" + sFormat + L"\"/>");
}
}
if(bRestart && 0 == Restart)
if(bRestart)
{
oWriter.WriteString(L"<w:lvlRestart w:val=\"" + std::to_wstring(Restart) + L"\"/>");
}

View File

@ -2915,12 +2915,9 @@ namespace BinDocxRW
const ComplexTypes::Word::CDecimalNumber& oVal = lvl.m_oLvlRestart.get();
if(oVal.m_oVal.IsInit())
{
int nVal = oVal.m_oVal.get().GetValue();
if(0 != nVal)
nVal = -1;
m_oBcw.m_oStream.WriteBYTE(c_oSerNumTypes::lvl_Restart);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(nVal);
m_oBcw.m_oStream.WriteLONG(oVal.m_oVal.get().GetValue());
}
}
//Start

View File

@ -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);

View File

@ -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)
{

View File

@ -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_;

View File

@ -462,10 +462,11 @@ 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)
@ -493,11 +494,15 @@ void odf_text_context::start_field(int type)
{
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()

View File

@ -80,7 +80,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);

View File

@ -32,6 +32,7 @@
#include <boost/regex.hpp>
#include <boost/algorithm/string.hpp>
#include "../utils.h"
@ -78,10 +79,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;
@ -286,8 +283,18 @@ 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().started == false && !current_fields.back().in_span)
{
//if (!current_fields.empty() && !current_fields.back().result) return; //Стандартное_составное_письмо.docx
switch (current_fields.back().type)
{
case 6: current_fields.back().started = start_bibliography(); break;
case 7: current_fields.back().started = start_alphabetical_index(); break;
case 8: //current_fields.back().started = start_table_index(); break;
case 9: current_fields.back().started = start_illustration_index(); break;
case 10:current_fields.back().started = 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,13 +352,119 @@ void odt_conversion_context::add_paragraph_break(int type)
//}
}
}
void odt_conversion_context::start_hyperlink(std::wstring ref)
bool odt_conversion_context::start_table_of_content()
{
office_element_ptr elm1, elm2;
create_element(L"text", L"table-of-content", elm1, this);
text_context()->start_element(elm1);
add_to_root();
create_element(L"text", L"table-of-content-source", elm2, this);
text_context()->start_element(elm2);
text_context()->end_element();
start_index_field();
return true;
}
bool odt_conversion_context::start_alphabetical_index()
{
office_element_ptr elm1, elm2;
create_element(L"text", L"alphabetical-index", elm1, this);
text_context()->start_element(elm1);
add_to_root();
create_element(L"text", L"alphabetical-index-source", elm2, this);
text_context()->start_element(elm2);
text_context()->end_element();
start_index_field();
return true;
}
bool odt_conversion_context::start_illustration_index()
{
office_element_ptr elm1, elm2;
create_element(L"text", L"illustration-index", elm1, this);
text_context()->start_element(elm1);
add_to_root();
create_element(L"text", L"illustration-index-source", elm2, this);
text_context()->start_element(elm2);
text_context()->end_element();
start_index_field();
return true;
}
bool 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();
create_element(L"text", L"bibliography-source", elm, this);
text_context()->start_element(elm);
text_context()->end_element();
start_index_field();
return true;
}
bool odt_conversion_context::start_table_index()
{
end_paragraph();
office_element_ptr elm;
create_element(L"text", L"table-index", elm, this);
text_context()->start_element(elm);
add_to_root();
create_element(L"text", L"table-index-source", elm, this);
text_context()->start_element(elm);
text_context()->end_element();
start_index_field();
start_paragraph();
return true;
}
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();
}
bool 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)return false;
////////////////////////////
@ -364,26 +477,48 @@ void odt_conversion_context::start_hyperlink(std::wstring ref)
text_context()->start_element(hyperlink_elm);
is_hyperlink_ = true;
return true;
}
void odt_conversion_context::end_hyperlink()
{
if (!is_hyperlink_) return;
//current_level_.pop_back();
text_context()->end_element();
is_hyperlink_ = false; //метка .. для гиперлинков в объектах - там не будет span
}
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() > 1)
{
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_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 = 1;
current_fields.back().in_span = false;
std::wstring ref;
boost::match_results<std::wstring::const_iterator> res;
@ -391,66 +526,103 @@ 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 = 3;
}
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 = 5;
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 = 2;
}
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 = 4;
}
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 = 6;
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 = 7;
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 = 8;
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 = 10; //table of content
}
pFind = options.find(L"o");
if ( pFind != options.end())//table of content outline levels style
{
current_fields.back().type = 10;
}
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,23 +759,27 @@ 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().started)
{
switch(current_fields.back().type)
{
case 1: end_hyperlink(); break;
case 6:
case 7:
case 8:
case 9:
case 10: end_index_field(); break;
default:
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();
@ -706,11 +882,10 @@ 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().started == false && !current_fields.back().in_span)
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
if (current_fields.back().type == 1) current_fields.back().started = start_hyperlink(current_fields.back().value);
else if (current_fields.back().type < 6) current_fields.back().started = text_context()->start_field(current_fields.back().type);
}
text_context()->start_span(styled);
@ -722,25 +897,27 @@ 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().started == false && current_fields.back().in_span)//поле стартуется в span - нужно для сохранения стиля
{
text_context()->start_field(current_field_.type);
current_field_.started = true;
current_fields.back().started = 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().started == true && 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)

View File

@ -90,14 +90,24 @@ public:
void add_paragraph_break(int type);
void start_hyperlink (std::wstring ref);
bool start_hyperlink (std::wstring ref);
void end_hyperlink ();
bool start_table_of_content ();
bool start_bibliography ();
bool start_alphabetical_index ();
bool start_illustration_index ();
bool start_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 ();
@ -186,15 +196,22 @@ private:
struct _field_state
{
int type = 0;
std::wstring name;
bool enabled;
int type;
std::wstring value;
std::wstring format;
bool started;
bool in_span;
bool started = false;
bool in_span = false;
bool result;
}current_field_;
bool bHyperlinks = false;
bool bHidePageNumbers = false;
std::wstring captionSEQ;
std::wstring title;
};
std::vector<_field_state> current_fields;
struct _text_changes_state
{

View File

@ -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";

View File

@ -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
//------------------------------------------------------------------------------------------------------------
@ -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>

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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_; }

View File

@ -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" ]

View File

@ -1,4 +1,5 @@
#!/bin/bash
set -e
SCRIPT=$(readlink -f "$0" || grealpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")

View File

@ -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;

View File

@ -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);

View File

@ -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 false;
unsigned char* buffer = new unsigned char[4096]; //enaf !!
if (!buffer){file.CloseFile();return false;}
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,15 @@ 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;
}
hresult = OfficeUtils.LoadFileFromArchive(fileName, L"mimetype", &pBuffer, nBufferSize);
if (hresult == S_OK && pBuffer != NULL)
{
if ( NULL != strstr((char*)pBuffer, ottFormatLine) )
@ -620,7 +685,8 @@ 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);

View File

@ -688,6 +688,7 @@
#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
// insert commands
#define ASC_MENU_EVENT_TYPE_INSERT_IMAGE 50

View File

@ -4,6 +4,21 @@
#include "../source/ECMACryptFile.h"
#include "../../Common/OfficeFileFormatChecker.h"
#if defined(_WIN64)
#pragma comment(lib, "../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#if defined(_DEBUG)
//#pragma comment(lib, "../../build/lib/win_32/DEBUG/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/kernel.lib")
#pragma comment(lib, "../../build/lib/win_32/DEBUG/UnicodeConverter.lib")
#else
//#pragma comment(lib, "../../build/lib/win_32/graphics.lib")
#pragma comment(lib, "../../build/lib/win_32/kernel.lib")
#endif
#pragma comment(lib, "../../build/bin/icu/win_32/icuuc.lib")
#endif
int _tmain(int argc, _TCHAR* argv[])
{
std::wstring srcFileName = L"D:\\test\\_crypted\\test-111.docx";
@ -29,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;
}

View File

@ -3,22 +3,16 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{BE4AA52B-8AF0-48DD-8240-CCBA6F84D7A2}"
ProjectSection(ProjectDependencies) = postProject
{F8274B05-168E-4D6E-B843-AA7510725363} = {F8274B05-168E-4D6E-B843-AA7510725363}
{C27E9A9F-3A17-4482-9C5F-BF15C01E747C} = {C27E9A9F-3A17-4482-9C5F-BF15C01E747C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeFileCrypt", "..\win32\ECMACryptReader.vcproj", "{C27E9A9F-3A17-4482-9C5F-BF15C01E747C}"
ProjectSection(ProjectDependencies) = postProject
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF} = {3423EC9A-52E4-4A4D-9753-EDEBC38785EF}
{21663823-DE45-479B-91D0-B4FEF4916EF0} = {21663823-DE45-479B-91D0-B4FEF4916EF0}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cryptlib", "..\..\Common\3dParty\cryptopp\cryptlib.vcproj", "{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml2", "..\..\DesktopEditor\xml\build\vs2005\libxml2.vcproj", "{21663823-DE45-479B-91D0-B4FEF4916EF0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OfficeUtilsLib", "..\..\OfficeUtils\win32\OfficeUtilsLib.vcproj", "{F8274B05-168E-4D6E-B843-AA7510725363}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -75,38 +69,6 @@ Global
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|Win32.Build.0 = Release|Win32
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|x64.ActiveCfg = Release|x64
{3423EC9A-52E4-4A4D-9753-EDEBC38785EF}.Release|x64.Build.0 = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.ActiveCfg = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|Win32.Build.0 = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|x64.ActiveCfg = Debug|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Debug|x64.Build.0 = Debug|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Debug|Win32.Build.0 = Debug|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Debug|x64.ActiveCfg = Debug|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Debug|x64.Build.0 = Debug|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Release|Win32.ActiveCfg = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Release|Win32.Build.0 = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Release|x64.ActiveCfg = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.DLL-Import Release|x64.Build.0 = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.ActiveCfg = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|Win32.Build.0 = Release|Win32
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|x64.ActiveCfg = Release|x64
{21663823-DE45-479B-91D0-B4FEF4916EF0}.Release|x64.Build.0 = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|Win32.ActiveCfg = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|Win32.Build.0 = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|x64.ActiveCfg = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Debug|x64.Build.0 = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|Win32.ActiveCfg = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|Win32.Build.0 = Debug|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|x64.ActiveCfg = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Debug|x64.Build.0 = Debug|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|Win32.ActiveCfg = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|Win32.Build.0 = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|x64.ActiveCfg = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.DLL-Import Release|x64.Build.0 = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|Win32.ActiveCfg = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|Win32.Build.0 = Release|Win32
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|x64.ActiveCfg = Release|x64
{F8274B05-168E-4D6E-B843-AA7510725363}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -189,14 +189,6 @@
RelativePath="..\..\Common\DocxFormat\Source\Base\unicode_util.cpp"
>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmldom.cpp"
>
</File>
<File
RelativePath="..\..\DesktopEditor\xml\src\xmllight.cpp"
>
</File>
</Filter>
<File
RelativePath=".\Test.cpp"

View File

@ -536,6 +536,14 @@ void CPdfRenderer::SetPassword(const std::wstring& wsPassword)
m_pDocument->SetPasswords(wsPassword, wsPassword);
}
void CPdfRenderer::SetDocumentID(const std::wstring& wsDocumentID)
{
if (!IsValid())
return;
m_pDocument->SetDocumentID(wsDocumentID);
}
void CPdfRenderer::SaveToFile(const std::wstring& wsPath)
{
if (!IsValid())

View File

@ -73,6 +73,7 @@ public:
~CPdfRenderer();
void SaveToFile(const std::wstring& wsPath);
void SetPassword(const std::wstring& wsPassword);
void SetDocumentID(const std::wstring& wsDocumentID);
void SetTempFolder(const std::wstring& wsPath);
std::wstring GetTempFile();
void SetThemesPlace(const std::wstring& wsThemesPlace);

View File

@ -296,9 +296,11 @@ void TestDocument3()
pPage->ClosePath();
pPage->FillStroke();
oPdf.SetDocumentID(L"23193r09jscladjalj");
oPdf.SetPasswords(L"123", L"qwe");
oPdf.SetPDFAConformanceMode(true);
oPdf.SaveToFile(L"D:/test/_pdf/Test3.pdf");
oPdf.SaveToFile(L"D:/test/_pdf/Test3-pdfa-my.pdf");
oPdf.Close();
}
void TestDocument4()
@ -798,7 +800,7 @@ void ConvertFolder(std::wstring wsFolderPath)
int _tmain(int argc, _TCHAR* argv[])
{
TestDocument1();
TestDocument3();
return S_OK;

View File

@ -198,6 +198,12 @@ namespace PdfWriter
pStream->WriteStr(c_sPdfAHeader);
else
pStream->WriteStr(c_sPdfHeader);
if (false == m_wsDocumentID.empty())
{
std::string sDocumentID = "%DocumentID " + NSFile::CUtf8Converter::GetUtf8StringFromUnicode(m_wsDocumentID);
pStream->WriteStr(sDocumentID.c_str());
}
// Добавляем в Trailer необходимые элементы
m_pTrailer->Add("Root", m_pCatalog);
@ -265,6 +271,11 @@ namespace PdfWriter
m_nCurPageNum++;
return pPage;
}
void CDocument::SetDocumentID(const std::wstring & documentID)
{
m_wsDocumentID = documentID;
}
void CDocument::SetPermission(unsigned int unPermission)
{
if (!m_bEncrypt)

View File

@ -93,6 +93,7 @@ namespace PdfWriter
void SetPasswords(const std::wstring & wsOwnerPassword, const std::wstring & wsUserPassword);
void SetPermission(unsigned int unPermission);
void SetCompressionMode(unsigned int unMode);
void SetDocumentID(const std::wstring & wsDocumentID);
void SetPDFAConformanceMode(bool isPDFA);
bool IsPDFA() const;
@ -174,6 +175,7 @@ namespace PdfWriter
std::vector<CFontCidTrueType*> m_vFreeTypeFonts;
FT_Library m_pFreeTypeLibrary;
bool m_bPDFAConformance;
std::wstring m_wsDocumentID;
friend class CFontCidTrueType;
};

View File

@ -1133,6 +1133,10 @@ namespace NExtractTools
pdfWriter.SetTempFolder(sTemp);
pdfWriter.SetThemesPlace(sThemeDir);
std::wstring documentID = params.getDocumentID();
if (false == documentID.empty())
pdfWriter.SetDocumentID(documentID);
std::wstring password = params.getSavePassword();
if (false == password.empty())
pdfWriter.SetPassword(password);
@ -1273,6 +1277,10 @@ namespace NExtractTools
pdfWriter.SetTempFolder(sTemp);
pdfWriter.SetThemesPlace(sThemeDir);
std::wstring documentID = params.getDocumentID();
if (false == documentID.empty())
pdfWriter.SetDocumentID(documentID);
std::wstring password = params.getSavePassword();
if (false == password.empty())
pdfWriter.SetPassword(password);
@ -1882,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;
@ -2457,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;
@ -2494,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;