Compare commits

..

23 Commits

Author SHA1 Message Date
e0630979c5 . 2018-12-06 13:09:12 +03:00
8bc8b7cf58 . 2018-12-05 15:43:01 +03:00
14f4364962 . 2018-12-05 14:38:22 +03:00
9de3cb016f . 2018-12-03 16:56:41 +03:00
f12cd8ff8f [ios][x2t] fixed build 2018-12-03 16:25:12 +03:00
436015b5d2 DocFormatReader - write strict writeProtection; DocxFormatReader - read ecma & strict writeProtection 2018-12-03 16:05:36 +03:00
c078df93c9 . 2018-12-03 13:17:35 +03:00
e5e8e01490 Xls/XlsxFormat - protection verify 2018-12-02 14:19:47 +03:00
4fcc3b4f41 DocFormatReader - convert writeProtect 2018-12-02 12:57:41 +03:00
ce44e50d0e OdfFormatReader - protection sheets 2018-11-29 19:01:54 +03:00
143590f17b XlsxFormat - sheet protection, ... 2018-11-29 11:25:22 +03:00
abb7a85337 [android][x2t] fix build script 2018-11-28 15:37:24 +03:00
f0fe00aa3e Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-27 15:27:12 +03:00
98a568177d . 2018-11-27 15:26:08 +03:00
e58f1929e1 x2t - version up - 2.5.556 2018-11-27 14:57:53 +03:00
2143869e69 OdfFormatReader - .. 2018-11-27 14:28:21 +03:00
ac6a1a19da Merge remote-tracking branch 'origin/hotfix/v5.2.4' into develop 2018-11-26 14:43:12 +03:00
fb574f1994 [android][pe] utils 2018-11-23 17:50:54 +03:00
f9af786d5a . 2018-11-23 12:19:38 +03:00
3cde3a4444 OdfFormatReader - fix after testing 2018-11-22 19:27:58 +03:00
eb2221f006 Fix previous commit 2018-11-22 11:30:02 +03:00
394d1e7b38 Remove preload libcef library 2018-11-22 11:24:18 +03:00
45ba99b9bf Up cef version on linux 2018-11-21 16:20:33 +03:00
54 changed files with 1581 additions and 455 deletions

View File

@ -32,9 +32,38 @@
#include "SettingsMapping.h"
#include "../../OfficeCryptReader/source/CryptTransform.h"
namespace DocFileFormat
{
std::string DecodeBase64(const std::string & value)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
std::wstring EncodeBase64(const std::string & value)
{
int nLength = 0;
char *pData = NULL;
std::string result;
NSFile::CBase64Converter::Encode((BYTE*)value.c_str(), value.length(), pData, nLength, NSBase64::B64_BASE64_FLAG_NOCRLF);
if (pData)
{
result = std::string(pData, nLength);
delete []pData; pData = NULL;
}
return std::wstring(result.begin(), result.end());
}
SettingsMapping::SettingsMapping (ConversionContext* ctx): PropertiesMapping(&m_oXmlWriter)
{
_ctx = ctx;
@ -49,11 +78,39 @@ namespace DocFileFormat
//start w:settings
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
//write namespaces
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( L"", TRUE, FALSE );
if (_ctx->_doc->FIB->m_FibBase.fWriteReservation)
{
m_oXmlWriter.WriteNodeBegin( L"w:writeProtection", TRUE );
WideString* passw = static_cast<WideString*>(_ctx->_doc->AssocNames->operator[]( 17 ));
if (passw && false == passw->empty())
{
CRYPT::_ecmaWriteProtectData data;
CRYPT::ECMAWriteProtect protect;
protect.SetCryptData(data);
protect.SetPassword(*passw);
protect.Generate();
protect.GetCryptData(data);
//m_oXmlWriter.WriteAttribute ( L"w:cryptProviderType", L"rsaAES");
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmSid", 14); //sha-512
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmType", L"typeAny");
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmClass", L"hash");
//m_oXmlWriter.WriteAttribute ( L"w:cryptSpinCount", data.spinCount);
//m_oXmlWriter.WriteAttribute ( L"w:hash", EncodeBase64(data.hashValue));
//m_oXmlWriter.WriteAttribute ( L"w:salt", EncodeBase64(data.saltValue));
m_oXmlWriter.WriteAttribute ( L"w:algorithmName", L"SHA-512");
m_oXmlWriter.WriteAttribute ( L"w:spinCount", data.spinCount);
m_oXmlWriter.WriteAttribute ( L"w:hashValue", EncodeBase64(data.hashValue));
m_oXmlWriter.WriteAttribute ( L"w:saltValue", EncodeBase64(data.saltValue));
}
m_oXmlWriter.WriteNodeEnd( L"", TRUE, TRUE );
}
//zoom
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved > 0 ? dop->wScaleSaved : 100 ) );

View File

@ -88,6 +88,7 @@ namespace DocFileFormat
friend class VMLPictureMapping;
friend class OpenXmlPackage;
friend class TextboxMapping;
friend class SettingsMapping;
public:

View File

@ -508,10 +508,8 @@ namespace formulasconvert {
void odf2oox_converter::Impl::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
{
std::wstring workstr = expr;
boost::regex_replace(
workstr,
std::wstring workstr = boost::regex_replace(
expr,
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);
@ -529,10 +527,8 @@ namespace formulasconvert {
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
{
std::wstring workstr = is_forbidden(expr);
boost::regex_replace(
workstr,
std::wstring workstr = boost::regex_replace(
is_forbidden(expr),
boost::wregex(L"('.*?')|(\".*?\")"),
&convert_scobci, boost::match_default | boost::format_all);

View File

@ -332,6 +332,7 @@ enum ElementType
typeTableTableRowGroup,
typeTableTableRowNoGroup,
typeTableTableSource,
typeTableTableProtection,
typeTableDataPilotTables,
typeTableDataPilotTable,

View File

@ -245,12 +245,16 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
{
names.push_back(L"adj1");
}
else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
std::wstring::npos != shapeGeomPreset.find(L"decagon"))
{
values.clear();
}
//else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
//{
// names.push_back(L"vf");
//}
//else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
// std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
//else if (std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
//{
// names.push_back(L"hf");
// names.push_back(L"vf");

View File

@ -46,7 +46,6 @@ namespace oox {
xlsx_defined_names();
~xlsx_defined_names();
public:
void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId);
void xlsx_serialize(std::wostream & _Wostream);

View File

@ -60,6 +60,7 @@ public:
std::wstringstream ole_objects_;
std::wstringstream page_props_;
std::wstringstream controls_;
std::wstringstream protection_;
rels sheet_rels_;
@ -156,6 +157,10 @@ std::wostream & xlsx_xml_worksheet::dataValidations()
{
return impl_->dataValidations_;
}
std::wostream & xlsx_xml_worksheet::protection()
{
return impl_->protection_;
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::sheet_rels()
{
@ -203,6 +208,10 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->hyperlinks_.str();
}
}
if (!impl_->protection_.str().empty())
{
CP_XML_STREAM() << impl_->protection_.str();
}
if (!impl_->page_props_.str().empty())
{
@ -218,13 +227,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
}
}
if (!impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{
CP_XML_STREAM() << impl_->tableParts_.str();
}
}
if (!impl_->ole_objects_.str().empty())
{
CP_XML_NODE(L"oleObjects")
@ -239,6 +241,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_STREAM() << impl_->controls_.str();
}
}
if (!impl_->tableParts_.str().empty())
{
CP_XML_NODE(L"tableParts")
{
CP_XML_STREAM() << impl_->tableParts_.str();
}
}
CP_XML_STREAM() << impl_->picture_background_.str();
//CP_XML_NODE(L"headerFooter){}

View File

@ -68,6 +68,7 @@ public:
std::wostream & ole_objects();
std::wostream & page_properties();
std::wostream & controls();
std::wostream & protection();
rels & sheet_rels(); //hyperlink, background image, external, media ...

View File

@ -302,12 +302,24 @@ void xlsx_pivots_context::Impl::calc_headers()
std::map<size_t, size_t>::iterator pFind;
//current_.bAxisCol = false;
//current_.bAxisRow = false;
size_t min_col = 0xffffff, min_row = 0xffffff;
size_t prev_col, prev_row;
for (size_t i = 0; i < current_.headers.size(); i++)//("F18","F19","F23","G21","H21")
{
size_t row = 0, col = 0;
oox::getCellAddressInv(current_.headers[i], col, row);
//if (i > 0)
//{
// if (col != prev_col)current_.bAxisCol = true;
// if (row != prev_row)current_.bAxisRow = true;
//}
prev_col = col;
prev_row = row;
if (col < min_col) min_col = col;
if (row < min_row) min_row = row;
@ -578,11 +590,17 @@ void xlsx_pivots_context::Impl::sort_fields()
i--;
}
}
if ((bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol))/* && bShowEmptyCol*/) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
bool data_col_repeate = false;
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow)) && (current_.grand_total == 1 || current_.grand_total == 3 || current_.data_on_row))/* && bShowEmptyRow*/
{
current_.row_fields.push_back(-2);
data_col_repeate = true;
}
if (!data_col_repeate && (bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol)) && (current_.grand_total == 1 || current_.grand_total == 2 || current_.data_fields.size() > 1 ))/* && bShowEmptyCol*/ ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
current_.col_fields.push_back(-2);
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))/* && bShowEmptyRow*/)
current_.row_fields.push_back(-2);
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{

View File

@ -44,6 +44,7 @@
#include "../formulasconvert/formulasconvert.h"
#include "../../../OfficeCryptReader/source/CryptTransform.h"
namespace cpdoccore {
namespace oox {
@ -81,8 +82,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
std::wstring ref1, ref2;
size_t col_1, row_1, col_2, row_2;
int pos = ref.find(L":");
if (pos >= 0)
size_t pos = ref.find(L":");
if (pos != std::wstring::npos)
{
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
@ -134,9 +135,8 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
xlsx_comments_context_ (Context->get_comments_context_handle()),
table_column_last_width_(0.0),
in_cell(false),
bEndTable_(false),
bRTL_(false)
bEndTable(false),
bRTL(false)
{
odf_reader::style_table_properties * table_prop = NULL;
odf_reader::style_instance * tableStyle = context_->root()->odf_context().styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
@ -147,7 +147,7 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
if ((table_prop) && (table_prop->content().common_writing_mode_attlist_.style_writing_mode_))
{
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
bRTL_ = true;
bRTL = true;
}
}
@ -162,7 +162,27 @@ void xlsx_table_state::start_column(unsigned int repeated, const std::wstring &
void xlsx_table_state::set_rtl(bool val)
{
bRTL_ = val;
bRTL = val;
}
void xlsx_table_state::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
bProtected = val;
protect_key = key;
size_t pos = algorithm.find(L"#");
if (pos != std::wstring::npos)
{
protect_key_algorithm = algorithm.substr(pos + 1);
}
//test
//CRYPT::odfWriteProtect protect;
//protect.SetProtectKey(DecodeBase64(protect_key));
//protect.SetPassword(L"123");
//bool res = protect.Verify();
}
unsigned int xlsx_table_state::columns_count() const
@ -389,6 +409,19 @@ void xlsx_table_state::serialize_background (std::wostream & strm)
}
}
}
void xlsx_table_state::serialize_protection (std::wostream & strm)
{
if (!bProtected) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"sheetProtection")
{
CP_XML_ATTR(L"sheet", 1);
//convert protection odf->ooxml impossible without password !!!
}
}
}
void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
@ -437,7 +470,7 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
{
CP_XML_ATTR(L"workbookViewId", 0);
if (bRTL_)
if (bRTL)
CP_XML_ATTR(L"rightToLeft", 1);
std::wstring s_col, s_row;

View File

@ -32,6 +32,7 @@
#pragma once
#include <vector>
#include <map>
#include "xlsx_row_spanned.h"
#include "xlsx_merge_cells.h"
@ -53,49 +54,20 @@ typedef _CP_PTR(xlsx_table_state) xlsx_table_state_ptr;
class xlsx_data_range;
typedef _CP_PTR(xlsx_data_range) xlsx_data_range_ptr;
class xlsx_data_range_values;
typedef _CP_PTR(xlsx_data_range_values) xlsx_data_range_values_ptr;
class xlsx_data_range_values
{
public:
xlsx_data_range_values(size_t row, size_t col1, size_t col2) : withHeader(false), filter(false), row_header(row), start_column(col1), end_column(col2)
{
for (size_t i = start_column; i <= end_column; i++)
values.push_back(L"");
}
size_t row_header;
size_t start_column;
size_t end_column;
bool withHeader;
bool filter;
std::vector<std::wstring> values;
void set_value(size_t col, size_t row, const std::wstring& value)
{
while (col - start_column + 1 >= values.size())
values.push_back(L"");
values[col - start_column] = value;
}
bool in_range(size_t col, size_t row) {return (row_header == row && (col >= start_column && col <= end_column));}
};
class xlsx_data_range
{
public:
xlsx_data_range() : byRow(true), filter(false), withHeader(false), cell_start(0,0), cell_end(0,0) {}
xlsx_data_range() : byRow(true), filter(false), bTablePart(true), withHeader(false), cell_start(0,0), cell_end(0,0) {}
std::wstring table_name;
std::wstring name;
std::wstring ref;
std::pair<int, int> cell_start;
std::pair<int, int> cell_end;
bool bTablePart;
bool byRow;
bool filter;
bool withHeader;
@ -104,6 +76,46 @@ public:
void serialize_sort (std::wostream & _Wostream);
void serialize_autofilter (std::wostream & _Wostream);
std::vector<std::wstring> header_values;
void set_header(size_t row, size_t col1, size_t col2)
{
row_header = row;
start_column_header = col1;
end_column_header = col2;
for (size_t i = start_column_header; i <= end_column_header; i++)
header_values.push_back(L"");
}
void set_header_value(size_t col, size_t row, const std::wstring& value)
{
while (col - start_column_header + 1 >= header_values.size())
header_values.push_back(L"");
std::map<std::wstring, int>::iterator pFind = map_unique_header_values.find(value);
if (pFind == map_unique_header_values.end())
{
map_unique_header_values.insert(std::make_pair(value, 1));
header_values[col - start_column_header] = value;
}
else
{
pFind->second++;
header_values[col - start_column_header] = value + std::to_wstring(pFind->second);
}
}
bool in_header(size_t col, size_t row)
{
return (row_header == row && (col >= start_column_header && col <= end_column_header));
}
private:
size_t row_header;
size_t start_column_header;
size_t end_column_header;
std::map<std::wstring, int> map_unique_header_values;
};
class xlsx_table_state
@ -114,7 +126,8 @@ public:
std::wstring current_style() const { return table_style_; }
void set_rtl(bool val);
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
@ -124,8 +137,8 @@ public:
void add_empty_row(int count);
void set_end_table(){ bEndTable_ = true; }
bool get_end_table(){ return bEndTable_; }
void set_end_table(){ bEndTable = true; }
bool get_end_table(){ return bEndTable; }
std::wstring current_row_style () const;
std::wstring default_row_cell_style () const;
@ -170,6 +183,7 @@ public:
void serialize_ole_objects (std::wostream & _Wostream);
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
@ -189,10 +203,14 @@ public:
friend class xlsx_table_context;
private:
bool bRTL_;
bool bEndTable_;
xlsx_conversion_context * context_;
bool bProtected;
std::wstring protect_key;
std::wstring protect_key_algorithm;
bool bRTL;
bool bEndTable;
std::wstring tableName_;
int tableId_;
std::wstring tableBackground_;

View File

@ -60,23 +60,20 @@ xlsx_table_state_ptr xlsx_table_context::state()
return xlsx_table_state_ptr();
}
void xlsx_table_context::start_database_range(std::wstring tableName, std::wstring ref)
bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref)
{
formulasconvert::odf2oox_converter convert;
ref = convert.convert_named_ref(ref);
std::wstring oox_ref = convert.convert_named_ref(ref);
std::wstring ref1, ref2;
size_t pos = ref.find(L":");
size_t pos = oox_ref.find(L":");
std::wstring xlsx_table_name;
if (pos != std::wstring::npos)
{
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
xlsx_data_ranges_.back()->table_name = tableName;
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
ref1 = oox_ref.substr(0, pos );
ref2 = oox_ref.substr(pos + 1);
pos = ref1.find(L"!");
if (pos > 0)
@ -88,25 +85,33 @@ void xlsx_table_context::start_database_range(std::wstring tableName, std::wstri
pos = ref2.find(L"!");
if (pos > 0) ref2 = ref2.substr(pos + 1);
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
size_t col1, col2, row1, row2;
getCellAddressInv(ref1, col1, row1);
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col1, row1);
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
getCellAddressInv(ref1, col1, row1);
getCellAddressInv(ref2, col2, row2);
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2)
{//check range in pivots
xlsx_data_ranges_.back()->bTablePart = false;
}
xlsx_data_ranges_.back()->name = name;
xlsx_data_ranges_.back()->table_name = xlsx_table_name;
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col1, row1);
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col2, row2);
xlsx_data_ranges_values_.push_back(xlsx_data_range_values_ptr(new xlsx_data_range_values(row1, col1, col2)));
xlsx_data_ranges_.back()->set_header(row1, col1, col2);
}
if (!xlsx_table_name.empty())
{
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
xlsx_data_ranges_map_.insert(std::pair<std::wstring, int> (xlsx_table_name, xlsx_data_ranges_.size() - 1));
}
return true;
}
void xlsx_table_context::set_database_orientation (bool val)
{
@ -119,14 +124,12 @@ void xlsx_table_context::set_database_header (bool val)
if (xlsx_data_ranges_.empty()) return;
xlsx_data_ranges_.back()->withHeader = val;
xlsx_data_ranges_values_.back()->withHeader = val;
}
void xlsx_table_context::set_database_filter (bool val)
{
if (xlsx_data_ranges_.empty()) return;
xlsx_data_ranges_.back()->filter = val;
xlsx_data_ranges_values_.back()->filter = val;
}
void xlsx_table_context::end_database_range()
{
@ -134,21 +137,55 @@ void xlsx_table_context::end_database_range()
void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
{
if (index < 0 || index > xlsx_data_ranges_.size()) return;
size_t col = state()->current_column();
size_t row = state()->current_row();
xlsx_data_ranges_values_[index]->set_value(col, row, value);
xlsx_data_ranges_[index]->set_header_value(col, row, value);
}
void xlsx_table_context::check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref)
{
std::wstring ref1, ref2;
size_t col_1, row_1, col_2, row_2;
size_t pos = ref.find(L":");
if (pos != std::wstring::npos)
{
ref1 = ref.substr(0, pos );
ref2 = ref.substr(pos + 1);
}
getCellAddressInv(ref1, col_1, row_1);
getCellAddressInv(ref2, col_2, row_2);
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
{
if (xlsx_data_ranges_[i]->table_name != table_name) continue;
//if ( xlsx_data_ranges_[i]->cell_start.second < row_2 || xlsx_data_ranges_[i]->cell_end.second > row_1
// || xlsx_data_ranges_[i]->cell_end.first < col_1 || xlsx_data_ranges_[i]->cell_start.first > col_2 )
if (((col_1 <= xlsx_data_ranges_[i]->cell_start.first && xlsx_data_ranges_[i]->cell_start.first <= col_2) ||
(xlsx_data_ranges_[i]->cell_start.first <= col_1 && col_1 <= xlsx_data_ranges_[i]->cell_end.first))
&&
(( row_1 <= xlsx_data_ranges_[i]->cell_start.second && xlsx_data_ranges_[i]->cell_start.second <= row_2) ||
(xlsx_data_ranges_[i]->cell_start.second <= row_1 && row_1 <= xlsx_data_ranges_[i]->cell_end.second )))
{
xlsx_data_ranges_[i]->bTablePart = false;
}
}
}
int xlsx_table_context::in_database_range()
{
int col = state()->current_column();
int row = state()->current_row();
for (size_t i = 0; i < xlsx_data_ranges_values_.size(); i++)
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
{
if ((xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)
&& xlsx_data_ranges_values_[i]->in_range(col, row))
if (xlsx_data_ranges_[i]->table_name != state()->get_table_name()) continue;
if (/*(xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)&& */
xlsx_data_ranges_[i]->in_header(col, row))
{
return (int)i;
}
@ -167,17 +204,19 @@ xlsx_text_context_(textContext)
{
}
void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName, int id)
void xlsx_table_context::start_table(const std::wstring & tableName, const std::wstring & tableStyleName, int id)
{
xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName, id);
xlsx_table_states_.push_back( state);
}
void xlsx_table_context::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
{
xlsx_table_states_.back()->set_protection(val, key, algorithm);
}
void xlsx_table_context::end_table()
{
//xlsx_table_states_.pop_back();
}
}
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
{
state()->start_cell(columnsSpanned, rowsSpanned);
@ -282,6 +321,8 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
}
}
@ -291,10 +332,12 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
std::pair<std::multimap<std::wstring, int>::iterator, std::multimap<std::wstring, int>::iterator> range;
range = xlsx_data_ranges_map_.equal_range(state()->tableName_);
range = xlsx_data_ranges_map_.equal_range(state()->get_table_name());
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
std::wstring rId = L"tprtId" + std::to_wstring(id);
@ -317,15 +360,15 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"id", id);
CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->table_name);
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->table_name);
CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->name);
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->name);
CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
if (xlsx_data_ranges_[it->second]->withHeader == false &&
xlsx_data_ranges_[it->second]->filter == false)
CP_XML_ATTR(L"headerRowCount", 0);
CP_XML_ATTR(L"totalsRowCount", 0);
//CP_XML_ATTR(L"totalsRowCount", 0);
CP_XML_ATTR(L"totalsRowShown", 0);
xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
@ -340,7 +383,7 @@ void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels &
{
CP_XML_NODE(L"tableColumn")
{
std::wstring column_name = xlsx_data_ranges_values_[it->second]->values[id];
std::wstring column_name = xlsx_data_ranges_[it->second]->header_values[id];
if (column_name.empty())
{
column_name = L"Column_" + std::to_wstring(id + 1);
@ -377,6 +420,8 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
{
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
if (xlsx_data_ranges_[it->second]->filter)
{
if (cell_start.first < 0 || xlsx_data_ranges_[it->second]->cell_start.first < cell_start.first )
@ -402,12 +447,16 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
{
CP_XML_NODE(L"autoFilter")
{
//в автофильтре тока простые диапазоны .. для сложных нужно выделять tablePart - todooo
//в автофильтре тока простые диапазоны .. для сложных - tablePart
CP_XML_ATTR(L"ref", getCellAddress(cell_start.first, cell_start.second) + L":" + getCellAddress(cell_end.first, cell_end.second));
//CP_XML_ATTR(L"ref", ref);
}
}
}
void xlsx_table_context::serialize_protection(std::wostream & _Wostream)
{
return state()->serialize_protection(_Wostream);
}
void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
{
return state()->serialize_conditionalFormatting(_Wostream);

View File

@ -48,7 +48,8 @@ class xlsx_table_context
public:
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
void start_table(const std::wstring &tableName, const std::wstring & tableStyleName, int id);
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
void end_table();
void start_cell(const std::wstring & formula,
@ -94,6 +95,7 @@ public:
void serialize_page_properties (std::wostream & _Wostream);
void serialize_background (std::wostream & _Wostream);
void serialize_data_validation (std::wostream & _Wostream);
void serialize_protection (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();
@ -112,23 +114,23 @@ public:
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
void start_database_range(std::wstring table_name, std::wstring ref);
bool start_database_range(const std::wstring &table_name, const std::wstring &ref);
void set_database_orientation (bool val);
void set_database_header (bool val);
void set_database_filter (bool val);
void add_database_sort (int field_number, int order);
void add_database_sort (int field_number, int order);
void end_database_range();
int in_database_range();
void set_database_range_value(int index, const std::wstring& value);
void check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref);
private:
xlsx_conversion_context *xlsx_conversion_context_;
xlsx_text_context &xlsx_text_context_;
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
std::vector<xlsx_data_range_values_ptr> xlsx_data_ranges_values_;
std::multimap<std::wstring, int> xlsx_data_ranges_map_;

View File

@ -477,11 +477,12 @@ void xlsx_conversion_context::end_table()
get_table_context().serialize_page_properties (current_sheet().page_properties());
get_table_context().serialize_conditionalFormatting (current_sheet().conditionalFormatting());
get_table_context().serialize_tableParts (current_sheet().tableParts(), current_sheet().sheet_rels());
//get_table_context().serialize_autofilter (current_sheet().autofilter());
//get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_autofilter (current_sheet().autofilter());
get_table_context().serialize_sort (current_sheet().sort());
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
get_table_context().serialize_data_validation (current_sheet().dataValidations());
get_table_context().serialize_protection (current_sheet().protection());
get_drawing_context().set_odf_packet_path (root()->get_folder());
get_drawing_context().process_objects (get_table_metrics());

View File

@ -201,6 +201,7 @@ public:
mediaitems & get_mediaitems() { return mediaitems_; }
static std::unordered_map<std::wstring, int> mapExternalLink_;
std::map<std::wstring, int> mapUsedNames_;
private:
void create_new_sheet (std::wstring const & name);

View File

@ -332,22 +332,6 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
}
return result;
}
std::string DecodeBase64(const std::wstring & value1)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
std::string value(value1.begin(), value1.end());
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
bool odf_document::Impl::decrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, office_element_ptr element, int file_size )
{
manifest_encryption_data* encryption_data = dynamic_cast<manifest_encryption_data*>(element.get());

View File

@ -35,7 +35,23 @@
namespace cpdoccore {
using namespace odf_types;
std::string DecodeBase64(const std::wstring & value1)
{
int nLength = 0;
unsigned char *pData = NULL;
std::string result;
std::string value(value1.begin(), value1.end());
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
if (pData)
{
result = std::string((char*)pData, nLength);
delete []pData; pData = NULL;
}
return result;
}
namespace odf_reader {
style_instance::style_instance(

View File

@ -44,6 +44,9 @@
#include <iosfwd>
namespace cpdoccore {
std::string DecodeBase64(const std::wstring & value);
namespace odf_reader {
class styles_container;

View File

@ -284,6 +284,7 @@ void form_button::docx_convert(oox::docx_conversion_context & Context)
void form_button::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_forms_context().start_element(1);
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
form_element::xlsx_convert(Context);
}

View File

@ -169,7 +169,7 @@ public:
virtual void visit(const table_table& val)
{
if (visit_table(val.table_table_attlist_.table_name_.get_value_or(L"")))
if (visit_table(val.attlist_.table_name_.get_value_or(L"")))
{
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_, stop_);
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_, stop_);

View File

@ -57,6 +57,8 @@ void table_table_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
CP_APPLY_ATTR(L"table:protected", table_protected_, false);
CP_APPLY_ATTR(L"table:protection-key", table_protection_key_);
CP_APPLY_ATTR(L"table:protection-key-digest-algorithm", table_protection_key_digest_algorithm_);
CP_APPLY_ATTR(L"table:print", table_print_, true);
CP_APPLY_ATTR(L"table:print-ranges", table_print_ranges_);
@ -134,7 +136,23 @@ void table_table_source::add_child_element( xml::sax * Reader, const std::wstrin
{
CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:table-protection
const wchar_t * table_table_protection::ns = L"loext"; //?? table odf 1.3
const wchar_t * table_table_protection::name = L"table-protection";
void table_table_protection::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"loext:select-protected-cells", select_protected_cells);
CP_APPLY_ATTR(L"loext:select-unprotected-cells",select_unprotected_cells);
CP_APPLY_ATTR(L"loext:insert-columns", insert_columns);
CP_APPLY_ATTR(L"loext:insert-rows", insert_rows);
CP_APPLY_ATTR(L"loext:delete-columns", delete_columns);
CP_APPLY_ATTR(L"loext:delete-rows", delete_rows);
//CP_APPLY_ATTR(L"loext:format-columns", format_columns);
//CP_APPLY_ATTR(L"loext:format-rows", format_rows);
//CP_APPLY_ATTR(L"loext:format-cells", format_cells);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// table:table
const wchar_t * table_table::ns = L"table";
@ -144,7 +162,7 @@ void table_table::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"table:style-name", element_style_name);
table_table_attlist_.add_attributes(Attributes);
attlist_.add_attributes(Attributes);
}
void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -172,9 +190,13 @@ void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns,
else if CP_CHECK_NAME(L"table", L"shapes")
{
CP_CREATE_ELEMENT(table_shapes_);
}
else if ( L"table-protection" == Name) //ns = loext or table
{
CP_CREATE_ELEMENT(table_protection_);
}
else if ( CP_CHECK_NAME(L"table", L"named-expressions") ||
CP_CHECK_NAME(L"table", L"named-range") ) //???
CP_CHECK_NAME(L"table", L"named-range") )
{
CP_CREATE_ELEMENT(table_named_);
}

View File

@ -61,15 +61,17 @@ public:
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
bool table_protected_; // default false
bool table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
bool table_print_; // default true
_CP_OPT(std::wstring) table_protection_key_digest_algorithm_;
bool table_print_; // default true
_CP_OPT(std::wstring) table_print_ranges_;
bool table_use_first_row_styles_; // default false;
bool table_use_banding_rows_styles_; //defualt false;
bool table_use_first_column_styles_; //defualt false;
bool table_use_banding_columns_styles_; //defualt false;
bool table_use_banding_rows_styles_; // defualt false;
bool table_use_first_column_styles_; // defualt false;
bool table_use_banding_columns_styles_; // defualt false;
friend class table_table;
};
@ -617,6 +619,38 @@ public:
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_row_group);
class table_table_protection : public office_element_impl<table_table_protection>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableTableProtection;
CPDOCCORE_DEFINE_VISITABLE();
virtual void docx_convert(oox::docx_conversion_context & Context) {}
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
virtual void pptx_convert(oox::pptx_conversion_context & Context) {}
private:
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
public:
_CP_OPT(bool) select_protected_cells;
_CP_OPT(bool) select_unprotected_cells;
_CP_OPT(bool) insert_columns;
_CP_OPT(bool) insert_rows;
_CP_OPT(bool) delete_columns;
_CP_OPT(bool) delete_rows;
//_CP_OPT(bool) format_columns; //???
//_CP_OPT(bool) format_rows;
//_CP_OPT(bool) format_cells;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_protection);
class table_table : public office_element_impl<table_table>
{
public:
@ -636,7 +670,9 @@ private:
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
public:
table_table_attlist table_table_attlist_;
table_table_attlist attlist_;
office_element_ptr table_protection_;
table_columns_and_groups table_columns_and_groups_;
table_rows_and_groups table_rows_and_groups_;

View File

@ -87,6 +87,7 @@ void table_data_pilot_table::add_child_element( xml::sax * Reader, const std::ws
CP_CREATE_ELEMENT (source_);
}
void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (!source_) return;
@ -105,6 +106,8 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
std::wstring ref = formulas_converter.convert_named_ref(*table_target_range_address_, false);
sheet_name = formulas_converter.get_table_name();
Context.get_table_context().check_database_range_intersection(sheet_name, ref);
Context.get_pivots_context().set_view_target_range(ref);
Context.get_pivots_context().set_view_target_table_name(sheet_name);
}

View File

@ -88,24 +88,43 @@ void table_database_range::add_child_element( xml::sax * Reader, const std::wstr
void table_database_range::xlsx_convert(oox::xlsx_conversion_context & Context)
{
if (!table_target_range_address_) return;
if (!table_name_) return;
Context.get_table_context().start_database_range(table_name_.get_value_or(L""), *table_target_range_address_);
if (table_display_filter_buttons_)
Context.get_table_context().set_database_filter(table_display_filter_buttons_->get());
std::wstring name = table_name_.get();
if (table_orientation_)
Context.get_table_context().set_database_orientation(table_orientation_->get_type() == table_orientation::row ? true : false);
if (table_contains_header_)
Context.get_table_context().set_database_header(table_contains_header_->get());
for (size_t i = 0; i < content_.size(); i++)
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
if (pFind == Context.mapUsedNames_.end())
{
content_[i]->xlsx_convert(Context);
Context.mapUsedNames_.insert(std::make_pair(name, 1));
}
else
{
name += L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
if (Context.get_table_context().start_database_range(name, *table_target_range_address_))
{
if (table_display_filter_buttons_)
Context.get_table_context().set_database_filter(table_display_filter_buttons_->get());
Context.get_table_context().end_database_range();
if (table_orientation_)
Context.get_table_context().set_database_orientation(table_orientation_->get_type() == table_orientation::row ? true : false);
if (table_contains_header_)
Context.get_table_context().set_database_header(table_contains_header_->get());
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.get_table_context().end_database_range();
}
else
{
Context.get_xlsx_defined_names().add(name, table_target_range_address_.get(), false, -1);
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -171,10 +171,10 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
}
}
bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false);
bool sub_table = attlist_.table_is_sub_table_.get_value_or(false);
//todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло)
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
_Wostream << L"<w:tbl>";

View File

@ -94,8 +94,19 @@ void table_named_range::xlsx_convert(oox::xlsx_conversion_context & Context)
{
tableId = Context.get_table_context().state()->get_table_id();
}
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
ctx.add(table_name_.get(), table_cell_range_address_.get(), false, tableId);
std::wstring name = table_name_.get();
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
if (pFind == Context.mapUsedNames_.end())
{
Context.mapUsedNames_.insert(std::make_pair(name, 1));
}
else
{
name += L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
Context.get_xlsx_defined_names().add(name, table_cell_range_address_.get(), false, tableId);
}
}
@ -130,8 +141,18 @@ void table_named_expression::xlsx_convert(oox::xlsx_conversion_context & Context
{
tableId = Context.get_table_context().state()->get_table_id();
}
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
ctx.add(table_name_.get(), table_expression_.get(), true, tableId);
std::wstring name = table_name_.get();
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
if (pFind == Context.mapUsedNames_.end())
{
Context.mapUsedNames_.insert(std::make_pair(name, 1));
}
else
{
name += L"_" + std::to_wstring(pFind->second);
pFind->second++;
}
Context.get_xlsx_defined_names().add(name, table_expression_.get(), true, tableId);
}
}

View File

@ -159,13 +159,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
Context.get_slide_context().start_table();
//////////////////////////////////////////////////////////////////
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
Context.get_table_context().start_table(tableStyleName);
if (table_table_attlist_.table_template_name_)
if (attlist_.table_template_name_)
{
std::wstring name = L"table:" + table_table_attlist_.table_template_name_.get() ;
std::wstring name = L"table:" + attlist_.table_template_name_.get() ;
if (office_element_ptr style = Context.root()->odf_context().Templates().find_by_style_name(name))
{
if (table_table_template* template_ = dynamic_cast<table_table_template *>(style.get()))
@ -184,13 +184,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
_Wostream << L"<a:tbl>";
_Wostream << L"<a:tblPr";
if (table_table_attlist_.table_use_banding_rows_styles_)
if (attlist_.table_use_banding_rows_styles_)
_Wostream << L" bandRow=\"1\"";
if (table_table_attlist_.table_use_first_row_styles_)
if (attlist_.table_use_first_row_styles_)
_Wostream << L" firstRow=\"1\"";
if (table_table_attlist_.table_use_banding_columns_styles_)
if (attlist_.table_use_banding_columns_styles_)
_Wostream << L" bandCol=\"1\"";
if (table_table_attlist_.table_use_first_column_styles_)
if (attlist_.table_use_first_column_styles_)
_Wostream << L" firstCol=\"1\"";
_Wostream << ">";

View File

@ -73,18 +73,6 @@ int table_table_cell_content::xlsx_convert(oox::xlsx_conversion_context & Contex
const int sharedStrId = Context.get_table_context().end_cell_content();
int index = Context.get_table_context().in_database_range();
if (index >= 0)
{
std::wstringstream strm;
for (size_t i = 0 ; i < elements_.size(); i++)
{
elements_[i]->text_to_stream(strm);
}
Context.get_table_context().set_database_range_value(index, strm.str());
}
return sharedStrId;
}
@ -331,8 +319,8 @@ void table_table_row_group::xlsx_convert(oox::xlsx_conversion_context & Context)
void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
{
const std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = table_table_attlist_.table_name_.get_value_or(L"");
const std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
const std::wstring tableName = attlist_.table_name_.get_value_or(L"");
_CP_LOG << L"[info][xlsx] process table \"" << tableName << L"\"\n" << std::endl;
@ -352,6 +340,16 @@ void table_table::xlsx_convert(oox::xlsx_conversion_context & Context)
}
Context.start_table(tableName, tableStyleName);
if (attlist_.table_protected_)
{
Context.get_table_context().set_protection(true, attlist_.table_protection_key_.get_value_or(L""),
attlist_.table_protection_key_digest_algorithm_.get_value_or(L""));
table_table_protection* prot = dynamic_cast<table_table_protection*>( table_protection_.get() );
if (prot)
{
}
}
table_columns_and_groups_.xlsx_convert(Context);
// check last rows for equal style and empties - collapsed
@ -853,9 +851,31 @@ void table_table_cell::xlsx_convert(oox::xlsx_conversion_context & Context)
const int sharedStringId = content_.xlsx_convert(Context, &textFormatProperties);
if (t_val == oox::XlsxCellType::str && sharedStringId >= 0)
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
//---------------------------------------------------------------------------------------------------------
if (t_val == oox::XlsxCellType::str || t_val == oox::XlsxCellType::inlineStr)
{
int index = Context.get_table_context().in_database_range();
if (index >= 0)
{
if (sharedStringId >= 0)
{
std::wstringstream strm;
content_.text_to_stream(strm);
Context.get_table_context().set_database_range_value(index, strm.str());
}
else if (str_val)
{
Context.get_table_context().set_database_range_value(index, str_val.get());
}
}
}
if (t_val == oox::XlsxCellType::str && sharedStringId >= 0)
{
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
}
//---------------------------------------------------------------------------------------------------------
if (skip_next_cell)break;
// пустые ячейки пропускаем.
@ -1138,7 +1158,7 @@ void table_covered_table_cell::xlsx_convert(oox::xlsx_conversion_context & Conte
const int sharedStringId = content_.xlsx_convert(Context, &textFormatProperties);
if (t_val == oox::XlsxCellType::str && sharedStringId >=0)
if (t_val == oox::XlsxCellType::str && sharedStringId >= 0)
t_val = oox::XlsxCellType::s;//в случае текста, если он есть берем кэшированное значение
if (skip_next_cell)break;

View File

@ -174,7 +174,7 @@ void odf_table_context::start_table(office_element_ptr &elm, bool styled)
state.table.style_elm = style_state->get_office_element();
state.table.style_name = style_state->get_name();
table->table_table_attlist_.table_style_name_ = state.table.style_name;
table->attlist_.table_style_name_ = state.table.style_name;
}
}
impl_->default_cell_properties = L"";
@ -226,11 +226,11 @@ void odf_table_context::start_row(office_element_ptr &elm, bool styled)
state.style_elm = style_state->get_office_element();
state.style_name = style_state->get_name();
row->table_table_row_attlist_.table_style_name_ = state.style_name;
row->attlist_.table_style_name_ = state.style_name;
}
}
if (!impl_->current_table().default_cell_properties.empty())
row->table_table_row_attlist_.table_default_cell_style_name_ = impl_->current_table().default_cell_properties;
row->attlist_.table_default_cell_style_name_ = impl_->current_table().default_cell_properties;
impl_->current_table().rows.push_back(state);
@ -277,7 +277,7 @@ void odf_table_context::add_column(office_element_ptr &elm, bool styled)
{
state.style_elm = style_state->get_office_element();
state.style_name = style_state->get_name();
column->table_table_column_attlist_.table_style_name_ = state.style_name;
column->attlist_.table_style_name_ = state.style_name;
}
}
@ -466,7 +466,7 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
state.style_elm = style_state->get_office_element();
state.style_name = style_state->get_name();
cell->table_table_cell_attlist_.table_style_name_ = state.style_name;
cell->attlist_.table_style_name_ = state.style_name;
}
if (!impl_->current_table().default_cell_properties.empty())
@ -498,7 +498,7 @@ void odf_table_context::start_cell(office_element_ptr &elm, bool styled)
table_table_cell * cell = dynamic_cast<table_table_cell *>(state_row.spanned_column_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = (unsigned int)state_row.spanned_column_cell.size();
cell->attlist_extra_.table_number_columns_spanned_ = (unsigned int)state_row.spanned_column_cell.size();
state_row.spanned_column_cell.clear();
}
@ -517,7 +517,7 @@ void odf_table_context::set_cell_column_span_restart()
table_table_cell * cell = dynamic_cast<table_table_cell *>(state.spanned_column_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = sz;
cell->attlist_extra_.table_number_columns_spanned_ = sz;
}
state.spanned_column_cell.clear();
}
@ -530,7 +530,7 @@ void odf_table_context::set_cell_column_span(int spanned)
{
table_table_cell * cell = dynamic_cast<table_table_cell *>(impl_->current_table().cells.back().elm.get());
if (cell)
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned;
cell->attlist_extra_.table_number_columns_spanned_ = spanned;
}
else
{
@ -551,7 +551,7 @@ void odf_table_context::set_cell_row_span(int spanned)
{
table_table_cell * cell = dynamic_cast<table_table_cell *>(impl_->current_table().cells.back().elm.get());
if (cell)
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned;
cell->attlist_extra_.table_number_rows_spanned_ = spanned;
}
else
{
@ -574,7 +574,7 @@ void odf_table_context::set_cell_row_span_restart()
table_table_cell * cell = dynamic_cast<table_table_cell *>(state.spanned_row_cell[0].get());
if (!cell)return;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = sz;
cell->attlist_extra_.table_number_rows_spanned_ = sz;
}
state.spanned_row_cell.clear();

View File

@ -169,7 +169,7 @@ void ods_table_state::set_table_name(std::wstring name)
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->table_table_attlist_.table_name_ = name;
table->attlist_.table_name_ = name;
}
void ods_table_state::set_table_master_page(std::wstring name)
@ -178,7 +178,74 @@ void ods_table_state::set_table_master_page(std::wstring name)
office_table_style_->style_master_page_name_ = name;
}
void ods_table_state::set_table_protection(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->attlist_.table_protected_ = true;
create_element(L"loext", L"table-protection", table->table_protection_, context_);
}
void ods_table_state::set_table_protection_insert_columns(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->insert_columns = Val;
}
void ods_table_state::set_table_protection_insert_rows(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->insert_rows = Val;
}
void ods_table_state::set_table_protection_delete_columns(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->delete_columns = Val;
}
void ods_table_state::set_table_protection_delete_rows(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->delete_rows = Val;
}
void ods_table_state::set_table_protection_protected_cells(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->select_protected_cells = Val;
}
void ods_table_state::set_table_protection_unprotected_cells(bool Val)
{
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table_table_protection *prot = dynamic_cast<table_table_protection*>(table->table_protection_.get());
if (!prot) return;
prot->select_unprotected_cells = Val;
}
void ods_table_state::set_table_hidden(bool Val)
{
if (!office_table_style_)return;
@ -205,7 +272,7 @@ void ods_table_state::set_print_range(std::wstring range)
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->table_table_attlist_.table_print_ranges_ = range;
table->attlist_.table_print_ranges_ = range;
}
void ods_table_state::set_table_tab_color(_CP_OPT(color) & _color)
@ -227,7 +294,7 @@ void ods_table_state::set_table_style(office_element_ptr & elm)
table_table* table = dynamic_cast<table_table*>(office_table_.get());
if (table == NULL)return;
table->table_table_attlist_.table_style_name_ = office_table_style_->style_name_;
table->attlist_.table_style_name_ = office_table_style_->style_name_;
//потом в принципе и по имени можно будет связать(найти)
@ -273,8 +340,8 @@ void ods_table_state::add_column(office_element_ptr & elm, unsigned int repeated
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
if (style_name.length()>0) column->table_table_column_attlist_.table_style_name_ = style_name;
column->table_table_column_attlist_.table_number_columns_repeated_ = repeated;
if (style_name.length()>0) column->attlist_.table_style_name_ = style_name;
column->attlist_.table_number_columns_repeated_ = repeated;
}
void ods_table_state::set_column_default_cell_style(std::wstring & style_name)
@ -284,7 +351,7 @@ void ods_table_state::set_column_default_cell_style(std::wstring & style_name)
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
column->table_table_column_attlist_.table_default_cell_style_name_ = style_name;
column->attlist_.table_default_cell_style_name_ = style_name;
columns_.back().cell_style_name = style_name;
}
@ -330,7 +397,7 @@ void ods_table_state::set_column_hidden(bool val)
table_table_column* column = dynamic_cast<table_table_column*>(columns_.back().elm.get());
if (column == NULL)return;
column->table_table_column_attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
column->attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
}
void ods_table_state::set_table_dimension(int col, int row)
{
@ -370,8 +437,8 @@ void ods_table_state::add_row(office_element_ptr & elm, unsigned int repeated, o
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
if (row == NULL)return;
if (style_name.length()>0) row->table_table_row_attlist_.table_style_name_ = style_name;
row->table_table_row_attlist_.table_number_rows_repeated_ = repeated;
if (style_name.length()>0) row->attlist_.table_style_name_ = style_name;
row->attlist_.table_number_rows_repeated_ = repeated;
row_default_cell_style_name_ = L"";
@ -394,14 +461,14 @@ void ods_table_state::add_row_repeated()
i--;
}
}
row->table_table_row_attlist_.table_number_rows_repeated_ = rows_.back().repeated;
row->attlist_.table_number_rows_repeated_ = rows_.back().repeated;
}
void ods_table_state::set_row_hidden(bool Val)
{
table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
if (row == NULL)return;
row->table_table_row_attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
row->attlist_.table_visibility_ = table_visibility(table_visibility::Collapse);
}
void ods_table_state::set_row_optimal_height(bool val)
{
@ -496,7 +563,7 @@ void ods_table_state::set_row_default_cell_style(std::wstring & style_name)
//table_table_row* row = dynamic_cast<table_table_row*>(rows_.back().elm.get());
//if (row == NULL)return;
//row->table_table_row_attlist_.table_default_cell_style_name_ = style_name;
//row->attlist_.table_default_cell_style_name_ = style_name;
}
office_element_ptr & ods_table_state::current_row_element()
@ -536,12 +603,12 @@ void ods_table_state::start_cell(office_element_ptr & elm, office_element_ptr &
table_table_cell* cell = dynamic_cast<table_table_cell*>(elm.get());
if (cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
{
cell->table_table_cell_attlist_.table_style_name_ = style_name;
cell->attlist_.table_style_name_ = style_name;
}
table_covered_table_cell* covered_cell = dynamic_cast<table_covered_table_cell*>(elm.get());
if (covered_cell && !style_name.empty() && style_name != get_column_default_cell_style(current_column()))
{
covered_cell->table_table_cell_attlist_.table_style_name_ = style_name;
covered_cell->attlist_.table_style_name_ = style_name;
}
ods_cell_state state;
@ -571,7 +638,7 @@ void ods_table_state::set_cell_format_value(office_value_type::type value_type)
common_value_and_type_attlist cell_type;
cell_type.office_value_type_ = office_value_type(value_type);
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = cell_type;
cell->attlist_.common_value_and_type_attlist_ = cell_type;
}
void ods_table_state::set_cell_type(int type)
@ -599,11 +666,11 @@ void ods_table_state::set_cell_type(int type)
}
if (cell_type)
{
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
if (!cell->attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
}
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
}
void ods_table_state::add_definded_expression(office_element_ptr & elm)
@ -693,8 +760,8 @@ void ods_table_state::check_spanned_cells()
table_table_cell* cell_elm = dynamic_cast<table_table_cell*>(cells_[i].elm.get());
if (cell_elm == NULL)break;
cell_elm->table_table_cell_attlist_extra_.table_number_columns_spanned_ = jt->second.spanned_cols;
cell_elm->table_table_cell_attlist_extra_.table_number_rows_spanned_ = jt->second.spanned_rows;
cell_elm->attlist_extra_.table_number_columns_spanned_ = jt->second.spanned_cols;
cell_elm->attlist_extra_.table_number_rows_spanned_ = jt->second.spanned_rows;
break;
}
@ -794,8 +861,8 @@ void ods_table_state::set_cell_spanned(int spanned_cols, int spanned_rows)
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
cell->attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->attlist_extra_.table_number_rows_spanned_ = spanned_rows;
}
void ods_table_state::set_cell_formula(std::wstring & formula)
{
@ -866,7 +933,7 @@ void ods_table_state::set_cell_formula(std::wstring & formula)
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_.table_formula_ = odfFormula;
cell->attlist_.table_formula_ = odfFormula;
cells_.back().empty = false;
}
@ -939,7 +1006,7 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
shared_formulas_.push_back(state);
cell->table_table_cell_attlist_.table_formula_ = odf_formula;
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
else
@ -975,7 +1042,7 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
boost::match_default | boost::format_all);
odf_formula = res;
}
cell->table_table_cell_attlist_.table_formula_ = odf_formula;
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
}
@ -1016,8 +1083,8 @@ void ods_table_state::set_cell_array_formula(std::wstring & formula, std::wstrin
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
cell->table_table_cell_attlist_extra_.table_number_matrix_columns_spanned_ = col_span;
cell->table_table_cell_attlist_extra_.table_number_matrix_rows_spanned_ = row_span;
cell->attlist_extra_.table_number_matrix_columns_spanned_ = col_span;
cell->attlist_extra_.table_number_matrix_rows_spanned_ = row_span;
}
}
@ -1100,11 +1167,11 @@ void ods_table_state::set_cell_text(odf_text_context* text_context, bool cash_va
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell)
{
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
if (!cell->attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
}
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = cell_type;
}
cells_.back().empty = false;
@ -1127,35 +1194,35 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell == NULL)return;
if (!cell->table_table_cell_attlist_.common_value_and_type_attlist_)
if (!cell->attlist_.common_value_and_type_attlist_)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::Float);
cell->attlist_.common_value_and_type_attlist_ = common_value_and_type_attlist();
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::Float);
//временно... пока нет определялки типов
}
cells_.back().empty = false;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_)
{
switch(cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type())
switch(cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type())
{
case office_value_type::String:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_string_value_ = value;
cell->attlist_.common_value_and_type_attlist_->office_string_value_ = value;
break;
case office_value_type::Boolean:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_boolean_value_ = value;
cell->attlist_.common_value_and_type_attlist_->office_boolean_value_ = value;
break;
case office_value_type::Date:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_date_value_ = utils::convert_date(value);
cell->attlist_.common_value_and_type_attlist_->office_date_value_ = utils::convert_date(value);
break;
case office_value_type::Time:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_time_value_ = utils::convert_time(value);
cell->attlist_.common_value_and_type_attlist_->office_time_value_ = utils::convert_time(value);
break;
case office_value_type::Currency:
case office_value_type::Percentage:
case office_value_type::Float:
default:
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_ = value;
cell->attlist_.common_value_and_type_attlist_->office_value_ = value;
}
}
else
@ -1168,11 +1235,11 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
{
bool need_test_cach = false;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_)
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_)
{
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Float) need_test_cach = true;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Currency) need_test_cach = true;
if (cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Percentage) need_test_cach = true;
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Float) need_test_cach = true;
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Currency) need_test_cach = true;
if (cell->attlist_.common_value_and_type_attlist_->office_value_type_->get_type() == office_value_type::Percentage) need_test_cach = true;
}
try
{
@ -1186,8 +1253,8 @@ void ods_table_state::set_cell_value(const std::wstring & value, bool need_cash)
{
if (need_cash)
{
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_ = boost::none;
cell->table_table_cell_attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::String);
cell->attlist_.common_value_and_type_attlist_->office_value_ = boost::none;
cell->attlist_.common_value_and_type_attlist_->office_value_type_ = office_value_type(office_value_type::String);
}
}
if (need_cash)
@ -1216,7 +1283,7 @@ void ods_table_state::end_cell()
if (cells_.back().empty)
{
table_table_cell* cell = dynamic_cast<table_table_cell*>(cells_.back().elm.get());
if (cell)cell->table_table_cell_attlist_.common_value_and_type_attlist_ = boost::none;
if (cell)cell->attlist_.common_value_and_type_attlist_ = boost::none;
}
}
@ -1315,8 +1382,8 @@ void ods_table_state::add_default_cell( unsigned int repeated)
int spanned_rows = 0, spanned_cols = 0;
if (cell && isSpannedCell(current_table_column_, current_table_row_, spanned_cols, spanned_rows))
{
cell->table_table_cell_attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->table_table_cell_attlist_extra_.table_number_rows_spanned_ = spanned_rows;
cell->attlist_extra_.table_number_columns_spanned_ = spanned_cols;
cell->attlist_extra_.table_number_rows_spanned_ = spanned_rows;
}
}
@ -1338,17 +1405,17 @@ void ods_table_state::add_default_cell( unsigned int repeated)
if (cell)
{
cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
cell->attlist_.table_number_columns_repeated_ = repeated;
if (!row_default_cell_style_name_.empty())
cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
cell->attlist_.table_style_name_ = row_default_cell_style_name_;
}
if (covered_cell)
{
covered_cell->table_table_cell_attlist_.table_number_columns_repeated_ = repeated;
covered_cell->attlist_.table_number_columns_repeated_ = repeated;
if (!row_default_cell_style_name_.empty())
covered_cell->table_table_cell_attlist_.table_style_name_ = row_default_cell_style_name_;
covered_cell->attlist_.table_style_name_ = row_default_cell_style_name_;
current_covered_cols_ -= repeated;
}

View File

@ -253,6 +253,14 @@ public:
void set_table_tab_color(_CP_OPT(odf_types::color) & _color);
void set_table_dimension(int col, int row);
void set_print_range(std::wstring range);
void set_table_protection(bool Val);
void set_table_protection_insert_columns(bool Val);
void set_table_protection_insert_rows(bool Val);
void set_table_protection_delete_columns(bool Val);
void set_table_protection_delete_rows(bool Val);
void set_table_protection_unprotected_cells(bool Val);
void set_table_protection_protected_cells(bool Val);
void add_column(office_element_ptr & elm, unsigned int repeated ,office_element_ptr & style);
void set_column_width(double width);

View File

@ -50,13 +50,17 @@ using xml::xml_char_wc;
void table_table_attlist::serialize(CP_ATTR_NODE)
{
CP_XML_ATTR_OPT( L"table:name", table_name_);
CP_XML_ATTR_OPT( L"table:style-name", table_style_name_);
CP_XML_ATTR_OPT( L"table:template-name", table_template_name_);
CP_XML_ATTR_OPT( L"table:name", table_name_);
CP_XML_ATTR_OPT( L"table:style-name", table_style_name_);
CP_XML_ATTR_OPT( L"table:template-name", table_template_name_);
if (table_protected_ && table_protected_->get())
{
CP_XML_ATTR_OPT( L"table:protected", table_protected_);
CP_XML_ATTR_OPT( L"table:protection-key", table_protection_key_);
CP_XML_ATTR_OPT( L"table:protection-digest-algorithm", table_protection_key_digest_algorithm_);
}
if (table_protected_)
CP_XML_ATTR_OPT( L"table:protection-key", table_protection_key_);
if (table_print_)
CP_XML_ATTR_OPT( L"table:print-ranges", table_print_ranges_);
}
@ -120,6 +124,28 @@ void table_table_column_attlist::serialize(CP_ATTR_NODE)
////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_table_protection::ns = L"loext"; //table ???
const wchar_t * table_table_protection::name = L"table-protection";
void table_table_protection::serialize(std::wostream & _Wostream)
{
CP_XML_WRITER(_Wostream)
{
CP_XML_NODE_SIMPLE()
{
CP_XML_ATTR(L"loext:select-protected-cells", select_protected_cells);
CP_XML_ATTR(L"loext:select-unprotected-cells", select_unprotected_cells);
CP_XML_ATTR_OPT(L"loext:insert-columns", insert_columns);
CP_XML_ATTR_OPT(L"loext:insert-rows", insert_rows);
CP_XML_ATTR_OPT(L"loext:delete-columns", delete_columns);
CP_XML_ATTR_OPT(L"loext:delete-rows", delete_rows);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * table_table_source::ns = L"table";
const wchar_t * table_table_source::name = L"table-source";
@ -225,7 +251,9 @@ void table_table::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
if (table_protection_)table_protection_->serialize(CP_XML_STREAM());
if (table_shapes_)table_shapes_->serialize(CP_XML_STREAM());
@ -257,7 +285,7 @@ void table_table_column::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_column_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
}
}
}
@ -553,12 +581,12 @@ const wchar_t * table_table_cell::name = L"table-cell";
void table_table_cell::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
table_table_cell_content_.create_child_element(Ns, Name, getContext());
content_.create_child_element(Ns, Name, getContext());
}
void table_table_cell::add_child_element( const office_element_ptr & child_element)
{
table_table_cell_content_.add_child_element(child_element);
content_.add_child_element(child_element);
}
void table_table_cell::serialize(std::wostream & _Wostream)
{
@ -566,10 +594,10 @@ void table_table_cell::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_cell_attlist_.serialize(CP_GET_XML_NODE());
table_table_cell_attlist_extra_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
attlist_extra_.serialize(CP_GET_XML_NODE());
table_table_cell_content_.serialize(CP_XML_STREAM());
content_.serialize(CP_XML_STREAM());
}
}
}
@ -582,12 +610,12 @@ const wchar_t * table_covered_table_cell::name = L"covered-table-cell";
void table_covered_table_cell::create_child_element( const std::wstring & Ns, const std::wstring & Name)
{
empty_ = false;
table_table_cell_content_.create_child_element( Ns, Name, getContext());
content_.create_child_element( Ns, Name, getContext());
}
void table_covered_table_cell::add_child_element( const office_element_ptr & child_element)
{
empty_ = false;
table_table_cell_content_.add_child_element(child_element);
content_.add_child_element(child_element);
}
void table_covered_table_cell::serialize(std::wostream & _Wostream)
{
@ -595,9 +623,9 @@ void table_covered_table_cell::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_cell_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
table_table_cell_content_.serialize(CP_XML_STREAM());
content_.serialize(CP_XML_STREAM());
}
}
}
@ -632,7 +660,7 @@ void table_table_row::serialize(std::wostream & _Wostream)
{
CP_XML_NODE_SIMPLE()
{
table_table_row_attlist_.serialize(CP_GET_XML_NODE());
attlist_.serialize(CP_GET_XML_NODE());
for (size_t i = 0; i < content_.size(); i++)
{

View File

@ -66,10 +66,11 @@ public:
_CP_OPT(std::wstring) table_style_name_;
_CP_OPT(std::wstring) table_template_name_;
_CP_OPT(std::wstring) table_protection_key_;
_CP_OPT(std::wstring) table_print_ranges_;
_CP_OPT(odf_types::Bool) table_protected_; // default false
_CP_OPT(odf_types::Bool) table_protected_; // default false
_CP_OPT(std::wstring) table_protection_key_;
_CP_OPT(std::wstring) table_protection_key_digest_algorithm_;
bool table_print_; // default true
@ -152,7 +153,37 @@ public:
void serialize(CP_ATTR_NODE);
};
//-----------------------------------------------------------------------------------------------------
class table_table_protection : public office_element_impl<table_table_protection>
{
public:
static const wchar_t * ns;
static const wchar_t * name;
static const xml::NodeType xml_type = xml::typeElement;
static const ElementType type = typeTableTableProtection;
CPDOCCORE_DEFINE_VISITABLE();
table_table_protection() : select_protected_cells(true), select_unprotected_cells(true) {}
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::Bool select_protected_cells;
odf_types::Bool select_unprotected_cells;
_CP_OPT(odf_types::Bool) insert_columns;
_CP_OPT(odf_types::Bool) insert_rows;
_CP_OPT(odf_types::Bool) delete_columns;
_CP_OPT(odf_types::Bool) delete_rows;
//_CP_OPT(bool) format_columns; //???
//_CP_OPT(bool) format_rows;
//_CP_OPT(bool) format_cells;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table_protection);
//-----------------------------------------------------------------------------------------------------
class table_table_source : public office_element_impl<table_table_source>
{
@ -274,7 +305,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
public:
table_table_column_attlist table_table_column_attlist_;
table_table_column_attlist attlist_;
};
@ -378,7 +409,7 @@ public:
virtual void serialize(std::wostream & _Wostream);
table_table_row_attlist table_table_row_attlist_;
table_table_row_attlist attlist_;
office_element_ptr_array content_; // table-table-cell, table-covered-table-cell
};
@ -418,9 +449,9 @@ public:
virtual void serialize(std::wostream & _Wostream);
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_attlist_extra table_table_cell_attlist_extra_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist attlist_;
table_table_cell_attlist_extra attlist_extra_;
table_table_cell_content content_;
};
@ -445,8 +476,8 @@ public:
virtual void serialize(std::wostream & _Wostream);
bool empty_;
table_table_cell_attlist table_table_cell_attlist_;
table_table_cell_content table_table_cell_content_;
table_table_cell_attlist attlist_;
table_table_cell_content content_;
};
@ -616,17 +647,20 @@ public:
virtual void serialize(std::wostream & _Wostream);
table_table_attlist table_table_attlist_;
office_element_ptr table_table_source_;//table-table-source
table_table_attlist attlist_;
office_element_ptr table_table_source_;//table-table-source
office_element_ptr table_protection_;
office_element_ptr table_named_expressions_;
office_element_ptr table_conditional_formats_;
office_element_ptr table_shapes_;
table_columns_and_groups table_columns_and_groups_;//table-columns-and-groups
table_rows_and_groups table_rows_and_groups_;
//office-dde-source
//table-scenario
//office-forms
office_element_ptr table_named_expressions_;
office_element_ptr table_conditional_formats_;
office_element_ptr table_shapes_;
table_columns_and_groups table_columns_and_groups_;//table-columns-and-groups
table_rows_and_groups table_rows_and_groups_;
};
CP_REGISTER_OFFICE_ELEMENT2(table_table);

View File

@ -374,11 +374,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CWorksheet *oox_sheet)
}
/////////////////////////////////////////////////////////////////////////
convert(oox_sheet->m_oDataValidations.GetPointer());
convert(oox_sheet->m_oSheetViews.GetPointer());
convert(oox_sheet->m_oHeaderFooter.GetPointer());
convert(oox_sheet->m_oPageSetup.GetPointer());
convert(oox_sheet->m_oPageMargins.GetPointer());
convert(oox_sheet->m_oPicture.GetPointer());
convert(oox_sheet->m_oSheetProtection.GetPointer());
OoxConverter::convert(oox_sheet->m_oExtLst.GetPointer());
@ -389,6 +391,51 @@ void XlsxConverter::convert(OOX::Spreadsheet::CHeaderFooter * oox_header_footer)
if (!oox_header_footer) return;
}
void XlsxConverter::convert(OOX::Spreadsheet::CSheetProtection *oox_prot)
{
if (!oox_prot) return;
ods_context->current_table().set_table_protection(true);
if (oox_prot->m_oInsertColumns.IsInit())
{
ods_context->current_table().set_table_protection_insert_columns(oox_prot->m_oInsertColumns->ToBool());
}
if (oox_prot->m_oInsertRows.IsInit())
{
ods_context->current_table().set_table_protection_insert_rows(oox_prot->m_oInsertRows->ToBool());
}
if (oox_prot->m_oDeleteColumns.IsInit())
{
ods_context->current_table().set_table_protection_delete_columns(oox_prot->m_oDeleteColumns->ToBool());
}
if (oox_prot->m_oDeleteRows.IsInit())
{
ods_context->current_table().set_table_protection_delete_rows(oox_prot->m_oDeleteRows->ToBool());
}
if (oox_prot->m_oSelectLockedCells.IsInit())
{
ods_context->current_table().set_table_protection_protected_cells(oox_prot->m_oSelectLockedCells->ToBool());
}
if (oox_prot->m_oSelectUnlockedCell.IsInit())
{
ods_context->current_table().set_table_protection_unprotected_cells(oox_prot->m_oSelectUnlockedCell->ToBool());
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CDataValidations *oox_validations)
{
if (!oox_validations) return;
for (size_t i = 0; i < oox_validations->m_arrItems.size(); i++)
{
convert(oox_validations->m_arrItems[i]);
}
}
void XlsxConverter::convert(OOX::Spreadsheet::CDataValidation *oox_validation)
{
if (!oox_validation) return;
}
void XlsxConverter::convert(OOX::Spreadsheet::CPictureWorksheet *oox_background)
{
if (!oox_background) return;

View File

@ -94,6 +94,9 @@ namespace OOX
class CSparklineGroups;
class CAltTextTable;
class CExternalLink;
class CDataValidations;
class CSheetProtection;
class CDataValidation;
}
}
@ -201,6 +204,9 @@ namespace Oox2Odf
void convert(OOX::Spreadsheet::CFromTo *oox_from_to, oox_table_position *pos);
void convert(OOX::Spreadsheet::CSheetProtection *oox_prot);
void convert(OOX::Spreadsheet::CDataValidations *oox_validations);
void convert(OOX::Spreadsheet::CDataValidation *oox_validation);
void convert(OOX::Spreadsheet::CConditionalFormatting *oox_cond_fmt);
void convert(OOX::Spreadsheet::CConditionalFormattingRule *oox_cond_rule);
void convert(OOX::Spreadsheet::CAutofilter *oox_filter);

View File

@ -37,6 +37,8 @@
#include "../Biff_records/ObjProtect.h"
#include "../Biff_records/Password.h"
#include "../../../../../OfficeCryptReader/source/CryptTransform.h"
namespace XLS
{
@ -76,6 +78,18 @@ const bool PROTECTION_COMMON::loadContent(BinProcessor& proc)
{
m_Password = elements_.back();
elements_.pop_back();
////test
//Password* passw = dynamic_cast<Password*>(m_Password.get());
//CRYPT::_ecmaWriteProtectData data;
//data.hashValue = std::string(passw->wPassword.begin(), passw->wPassword.end());
//CRYPT::ECMAWriteProtect protect;
//protect.SetCryptData(data);
//protect.SetPassword(L"123");
//bool res = protect.VerifyWrike();
}
return m_Protect || m_ScenarioProtect || m_ObjProtect || m_Password;

View File

@ -37,7 +37,14 @@ mkdir "build"
fi
cef_binary=cef_binary
cef_arch=$cef_binary.7z
cef_url=http://d2ettrnqo7v976.cloudfront.net/cef/3163/$platform$arch/$cef_arch
cef_version="3163"
if [[ "$platform" == *"linux"* ]]
then
cef_version="3202"
fi
cef_url=http://d2ettrnqo7v976.cloudfront.net/cef/$cef_version/$platform$arch/$cef_arch
if [[ "$platform" == *"linux"* ]]
then

View File

@ -6778,22 +6778,23 @@ namespace SimpleTypes
virtual ECryptAlgoritmName FromString(std::wstring &sValue)
{
if ( (L"MD2") == sValue ) this->m_eValue = cryptalgoritmnameMD2;
else if ( (L"MD4") == sValue ) this->m_eValue = cryptalgoritmnameMD4;
else if ( (L"MD5") == sValue ) this->m_eValue = cryptalgoritmnameMD5;
else if ( (L"RIPEMD-128") == sValue ) this->m_eValue = cryptalgoritmnameRIPEMD128;
else if ( (L"RIPEMD-160") == sValue ) this->m_eValue = cryptalgoritmnameRIPEMD160;
else if ( (L"SHA-1") == sValue ) this->m_eValue = cryptalgoritmnameSHA1;
else if ( (L"SHA-256") == sValue ) this->m_eValue = cryptalgoritmnameSHA256;
else if ( (L"SHA-384") == sValue ) this->m_eValue = cryptalgoritmnameSHA384;
else if ( (L"SHA-512") == sValue ) this->m_eValue = cryptalgoritmnameSHA512;
else if ( (L"WHIRLPOOL") == sValue ) this->m_eValue = cryptalgoritmnameWHIRLPOOL;
else this->m_eValue = eDefValue;
if ( L"MD2" == sValue || L"1" == sValue ) this->m_eValue = cryptalgoritmnameMD2;
else if ( L"MD4" == sValue || L"2" == sValue ) this->m_eValue = cryptalgoritmnameMD4;
else if ( L"MD5" == sValue || L"3" == sValue ) this->m_eValue = cryptalgoritmnameMD5;
else if ( L"RIPEMD-128" == sValue || L"6" == sValue ) this->m_eValue = cryptalgoritmnameRIPEMD128;
else if ( L"RIPEMD-160" == sValue || L"7" == sValue ) this->m_eValue = cryptalgoritmnameRIPEMD160;
else if ( L"SHA-1" == sValue || L"4" == sValue ) this->m_eValue = cryptalgoritmnameSHA1;
else if ( L"SHA-256" == sValue || L"12" == sValue ) this->m_eValue = cryptalgoritmnameSHA256;
else if ( L"SHA-384" == sValue || L"13" == sValue ) this->m_eValue = cryptalgoritmnameSHA384;
else if ( L"SHA-512" == sValue || L"14" == sValue ) this->m_eValue = cryptalgoritmnameSHA512;
else if ( L"WHIRLPOOL" == sValue ) this->m_eValue = cryptalgoritmnameWHIRLPOOL;
else
this->m_eValue = eDefValue;
return this->m_eValue;
}
virtual std::wstring ToString () const
virtual std::wstring ToString() const
{
switch(this->m_eValue)
{
@ -6810,7 +6811,6 @@ namespace SimpleTypes
default : return (L"");
}
}
SimpleType_FromString (ECryptAlgoritmName)
SimpleType_Operator_Equal (CCryptAlgoritmName)
};

View File

@ -2134,20 +2134,28 @@ namespace OOX
switch ( wsChar2 )
{
case 'a':
if ( _T("w:algorithmName") == wsName ) m_oAlgorithmName = oReader.GetText();
if ( L"w:algorithmName" == wsName ) m_oAlgorithmName = oReader.GetText();
break;
case 'c':
if ( L"w:cryptProviderType" == wsName ) m_oCryptProviderType = oReader.GetText();
else if ( L"w:cryptAlgorithmSid" == wsName ) m_oAlgorithmName = oReader.GetText();
else if ( L"w:cryptAlgorithmType" == wsName ) m_oCryptAlgorithmType = oReader.GetText();
else if ( L"w:cryptAlgorithmClass" == wsName ) m_oCryptAlgorithmClass = oReader.GetText();
else if ( L"w:cryptSpinCount" == wsName ) m_oSpinCount = oReader.GetText();
break;
case 'h':
if ( _T("w:hashValue") == wsName ) m_sHashValue = oReader.GetText();
if ( L"w:hashValue" == wsName ) m_sHashValue = oReader.GetText();
else if ( L"w:hash" == wsName ) m_sHashValue = oReader.GetText();
break;
case 'r':
if ( _T("w:recommended") == wsName ) m_oRecommended = oReader.GetText();
if ( L"w:recommended" == wsName ) m_oRecommended = oReader.GetText();
break;
case 's':
if ( _T("w:saltValue") == wsName ) m_sSaltValue = oReader.GetText();
else if ( _T("w:spinCount") == wsName ) m_oSpinCount = oReader.GetText();
if ( L"w:saltValue" == wsName ) m_sSaltValue = oReader.GetText();
else if ( L"w:salt" == wsName ) m_sSaltValue = oReader.GetText();
else if ( L"w:spinCount" == wsName ) m_oSpinCount = oReader.GetText();
break;
}
}
if ( !oReader.MoveToNextAttribute() )
@ -2161,14 +2169,14 @@ namespace OOX
}
public:
nullable<std::wstring> m_oCryptProviderType;
nullable<std::wstring> m_oCryptAlgorithmType;
nullable<std::wstring> m_oCryptAlgorithmClass;
// TO DO: Добавить атрибуты из 9.7.2.5 Part4
// Attributes
nullable<SimpleTypes::CCryptAlgoritmName<>> m_oAlgorithmName;
nullable<std::wstring> m_sHashValue;
nullable<std::wstring> m_sHashValue;
nullable<SimpleTypes::COnOff<>> m_oRecommended;
nullable<std::wstring> m_sSaltValue;
nullable<std::wstring> m_sSaltValue;
nullable<SimpleTypes::CDecimalNumber<>> m_oSpinCount;
};
//--------------------------------------------------------------------------------

View File

@ -1125,6 +1125,12 @@ namespace OOX
et_x_HeaderFooterElementWorksheet,
et_x_Break,
et_x_RowColBreaks,
et_x_SheetProtection,
et_x_DataValidations,
et_x_DataValidation,
et_x_DataConsolidate,
et_x_DataRefs,
et_x_DataRef,
et_x_SparklineGroups,
et_x_SparklineGroup,

View File

@ -37,6 +37,7 @@
#include <algorithm>
#include <sstream>
#include <stdio.h>
#ifndef _USE_NULLABLE_PROPERTY_
using namespace NSCommon;
@ -231,6 +232,8 @@ namespace XmlUtils
double d = 0;
#if defined (_WIN32) || defined (_WIN64)
swscanf_s(string.c_str(), L"%lf", &d);
#elif defined(_IOS) || defined(__ANDROID__)
swscanf(string.c_str(), L"%lf", &d);
#else
_stscanf(string.c_str(), L"%lf", &d);
#endif
@ -243,6 +246,8 @@ namespace XmlUtils
float f = 0;
#if defined (_WIN32) || defined (_WIN64)
swscanf_s(string.c_str(), L"%f", &f);
#elif defined(_IOS) || defined(__ANDROID__)
swscanf(string.c_str(), L"%f", &f);
#else
_stscanf(string.c_str(), L"%f", &f);
#endif

View File

@ -157,6 +157,12 @@ namespace OOX
m_oRowBreaks = oReader;
else if (_T("colBreaks") == sName)
m_oColBreaks = oReader;
else if (_T("sheetProtection") == sName)
m_oSheetProtection = oReader;
else if (_T("dataValidations") == sName)
m_oDataValidations = oReader;
else if (_T("dataConsolidate") == sName)
m_oDataConsolidate = oReader;
}
}
if(m_oLegacyDrawing.IsInit() && m_oLegacyDrawing->m_oId.IsInit())
@ -393,10 +399,16 @@ namespace OOX
m_oPicture->toXML(sXml);
if(m_oOleObjects.IsInit())
m_oOleObjects->toXML(sXml);
if (m_oControls.IsInit())
if(m_oControls.IsInit())
m_oControls->toXML(sXml);
if(m_oSheetProtection.IsInit())
m_oSheetProtection->toXML(sXml);
if(m_oDataValidations.IsInit())
m_oDataValidations->toXML(sXml);
if(m_oTableParts.IsInit())
m_oTableParts->toXML(sXml);
if(m_oDataConsolidate.IsInit())
m_oDataConsolidate->toXML(sXml);
if(m_oExtLst.IsInit())
{
sXml.WriteString(m_oExtLst->toXMLWithNS(_T("")));

View File

@ -59,17 +59,12 @@ namespace OOX
class CLegacyDrawingWorksheet;
//необработанные child:
//<cellWatches>
//<colBreaks>
//<customProperties>
//<dataConsolidate>
//<dataValidations>
//<extLst>
//<phoneticPr>
//<protectedRanges>
//<rowBreaks>
//<scenarios>
//<sheetCalcPr>
//<sheetProtection>
//<smartTags>
//<sortState>
//<webPublishItems>
@ -140,6 +135,9 @@ namespace OOX
nullable<OOX::Spreadsheet::CPictureWorksheet> m_oPicture;
nullable<OOX::Spreadsheet::CRowColBreaks> m_oRowBreaks;
nullable<OOX::Spreadsheet::CRowColBreaks> m_oColBreaks;
nullable<OOX::Spreadsheet::CSheetProtection> m_oSheetProtection;
nullable<OOX::Spreadsheet::CDataValidations> m_oDataValidations;
nullable<OOX::Spreadsheet::CDataConsolidate> m_oDataConsolidate;
nullable<OOX::Drawing::COfficeArtExtensionList> m_oExtLst;

View File

@ -88,12 +88,12 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("left"), m_oLeft)
WritingElement_ReadAttributes_Read_if ( oReader, _T("top"), m_oTop)
WritingElement_ReadAttributes_Read_if ( oReader, _T("right"), m_oRight)
WritingElement_ReadAttributes_Read_if ( oReader, _T("bottom"), m_oBottom)
WritingElement_ReadAttributes_Read_if ( oReader, _T("header"), m_oHeader)
WritingElement_ReadAttributes_Read_if ( oReader, _T("footer"), m_oFooter)
WritingElement_ReadAttributes_Read_if ( oReader, _T("left"), m_oLeft)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("top"), m_oTop)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("right"), m_oRight)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("bottom"), m_oBottom)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("header"), m_oHeader)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("footer"), m_oFooter)
WritingElement_ReadAttributes_End( oReader )
}
@ -157,12 +157,12 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("orientation"), m_oOrientation)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperSize"), m_oPaperSize)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperUnits"), m_oPaperUnits)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperWidth"), m_oPaperWidth)
WritingElement_ReadAttributes_Read_if ( oReader, _T("paperHeight"), m_oPaperHeight)
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oRId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("orientation"), m_oOrientation)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("paperSize"), m_oPaperSize)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("paperUnits"), m_oPaperUnits)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("paperWidth"), m_oPaperWidth)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("paperHeight"), m_oPaperHeight)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("r:id"), m_oRId)
WritingElement_ReadAttributes_End( oReader )
}
nullable<SimpleTypes::CRelationshipId> m_oRId;
@ -218,11 +218,11 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("gridLines"), m_oGridLines)
WritingElement_ReadAttributes_Read_if ( oReader, _T("gridLinesSet"), m_oGridLinesSet)
WritingElement_ReadAttributes_Read_if ( oReader, _T("headings"), m_oHeadings)
WritingElement_ReadAttributes_Read_if ( oReader, _T("horizontalCentered"), m_oHorizontalCentered)
WritingElement_ReadAttributes_Read_if ( oReader, _T("verticalCentered"), m_oVerticalCentered)
WritingElement_ReadAttributes_Read_if ( oReader, _T("gridLines"), m_oGridLines)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("gridLinesSet"), m_oGridLinesSet)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("headings"), m_oHeadings)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("horizontalCentered"), m_oHorizontalCentered)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("verticalCentered"), m_oVerticalCentered)
WritingElement_ReadAttributes_End( oReader )
}
@ -271,7 +271,7 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("ref"), m_oRef)
WritingElement_ReadAttributes_ReadSingle( oReader, _T("ref"), m_oRef)
WritingElement_ReadAttributes_End( oReader )
}
@ -328,15 +328,15 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("baseColWidth"), m_oBaseColWidth) // ToDo Excel не воспринимает значения не uint (мы приводим к uint)
WritingElement_ReadAttributes_Read_if ( oReader, _T("customHeight"), m_oCustomHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultColWidth"), m_oDefaultColWidth )
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultRowHeight"), m_oDefaultRowHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outlineLevelCol"), m_oOutlineLevelCol )
WritingElement_ReadAttributes_Read_if ( oReader, _T("outlineLevelRow"), m_oOutlineLevelRow )
WritingElement_ReadAttributes_Read_if ( oReader, _T("thickBottom"), m_oThickBottom )
WritingElement_ReadAttributes_Read_if ( oReader, _T("thickTop"), m_oThickTop )
WritingElement_ReadAttributes_Read_if ( oReader, _T("zeroHeight"), m_oZeroHeight )
WritingElement_ReadAttributes_Read_if ( oReader, _T("baseColWidth"), m_oBaseColWidth) // ToDo Excel не воспринимает значения не uint (мы приводим к uint)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("customHeight"), m_oCustomHeight )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("defaultColWidth"), m_oDefaultColWidth )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("defaultRowHeight"), m_oDefaultRowHeight )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("outlineLevelCol"), m_oOutlineLevelCol )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("outlineLevelRow"), m_oOutlineLevelRow )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("thickBottom"), m_oThickBottom )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("thickTop"), m_oThickTop )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zeroHeight"), m_oZeroHeight )
WritingElement_ReadAttributes_End( oReader )
}
@ -395,11 +395,11 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("activePane") , m_oActivePane)
WritingElement_ReadAttributes_Read_if ( oReader, _T("state") , m_oState)
WritingElement_ReadAttributes_Read_if ( oReader, _T("topLeftCell") , m_oTopLeftCell)
WritingElement_ReadAttributes_Read_if ( oReader, _T("xSplit") , m_oXSplit)
WritingElement_ReadAttributes_Read_if ( oReader, _T("ySplit") , m_oYSplit)
WritingElement_ReadAttributes_Read_if ( oReader, _T("activePane") , m_oActivePane)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("state") , m_oState)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("topLeftCell") , m_oTopLeftCell)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("xSplit") , m_oXSplit)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("ySplit") , m_oYSplit)
WritingElement_ReadAttributes_End( oReader )
}
@ -454,10 +454,10 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("activeCell") , m_oActiveCell)
WritingElement_ReadAttributes_Read_if ( oReader, _T("activeCellId") , m_oActiveCellId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("sqref") , m_oSqref)
WritingElement_ReadAttributes_Read_if ( oReader, _T("pane") , m_oPane)
WritingElement_ReadAttributes_Read_if ( oReader, _T("activeCell") , m_oActiveCell)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("activeCellId") , m_oActiveCellId)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sqref") , m_oSqref)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("pane") , m_oPane)
WritingElement_ReadAttributes_End( oReader )
}
@ -556,25 +556,25 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("colorId"), m_oColorId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("defaultGridColor"), m_oDefaultGridColor)
WritingElement_ReadAttributes_Read_if ( oReader, _T("rightToLeft"), m_oRightToLeft)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showFormulas"), m_oShowFormulas)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showGridLines"), m_oShowGridLines)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showOutlineSymbols"), m_oShowOutlineSymbols)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showRowColHeaders"), m_oShowRowColHeaders)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showRuler"), m_oShowRuler)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showWhiteSpace"), m_oShowWhiteSpace)
WritingElement_ReadAttributes_Read_if ( oReader, _T("showZeros"), m_oShowZeros)
WritingElement_ReadAttributes_Read_if ( oReader, _T("tabSelected"), m_oTabSelected)
WritingElement_ReadAttributes_Read_if ( oReader, _T("topLeftCell"), m_oTopLeftCell)
WritingElement_ReadAttributes_Read_if ( oReader, _T("view"), m_oView)
WritingElement_ReadAttributes_Read_if ( oReader, _T("windowProtection"), m_oWindowProtection)
WritingElement_ReadAttributes_Read_if ( oReader, _T("workbookViewId"), m_oWorkbookViewId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScale"), m_oZoomScale)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScaleNormal"), m_oZoomScaleNormal)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScalePageLayoutView"), m_oZoomScalePageLayoutView)
WritingElement_ReadAttributes_Read_if ( oReader, _T("zoomScaleSheetLayoutView"), m_oZoomScaleSheetLayoutView)
WritingElement_ReadAttributes_Read_if ( oReader, _T("colorId"), m_oColorId)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("defaultGridColor"), m_oDefaultGridColor)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rightToLeft"), m_oRightToLeft)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showFormulas"), m_oShowFormulas)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showGridLines"), m_oShowGridLines)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showOutlineSymbols"), m_oShowOutlineSymbols)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showRowColHeaders"), m_oShowRowColHeaders)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showRuler"), m_oShowRuler)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showWhiteSpace"), m_oShowWhiteSpace)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showZeros"), m_oShowZeros)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("tabSelected"), m_oTabSelected)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("topLeftCell"), m_oTopLeftCell)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("view"), m_oView)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("windowProtection"), m_oWindowProtection)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("workbookViewId"), m_oWorkbookViewId)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zoomScale"), m_oZoomScale)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zoomScaleNormal"), m_oZoomScaleNormal)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zoomScalePageLayoutView"), m_oZoomScalePageLayoutView)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("zoomScaleSheetLayoutView"), m_oZoomScaleSheetLayoutView)
WritingElement_ReadAttributes_End( oReader )
}
@ -768,7 +768,7 @@ namespace OOX
}
void toXML2(NSStringUtils::CStringBuilder& writer, const std::wstring& sName) const
{
if (m_sText.empty()) return;
if (m_sText.empty()) return;
writer.WriteString(_T("<"));
writer.WriteString(sName);
@ -892,9 +892,9 @@ namespace OOX
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("alignWithMargins"), m_oAlignWithMargins)
WritingElement_ReadAttributes_Read_if ( oReader, _T("differentFirst"), m_oDifferentFirst)
WritingElement_ReadAttributes_Read_if ( oReader, _T("differentOddEven"), m_oDifferentOddEven)
WritingElement_ReadAttributes_Read_if ( oReader, _T("scaleWithDoc"), m_oScaleWithDoc)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("differentFirst"), m_oDifferentFirst)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("differentOddEven"), m_oDifferentOddEven)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("scaleWithDoc"), m_oScaleWithDoc)
WritingElement_ReadAttributes_End( oReader )
}
@ -974,27 +974,25 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oId )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cfe"), m_oCfe )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cff"), m_oCff )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cfo"), m_oCfo )
WritingElement_ReadAttributes_Read_if ( oReader, _T("che"), m_oChe )
WritingElement_ReadAttributes_Read_if ( oReader, _T("chf"), m_oChf )
WritingElement_ReadAttributes_Read_if ( oReader, _T("cho"), m_oCho )
WritingElement_ReadAttributes_Read_if ( oReader, _T("lfe"), m_oLfe )
WritingElement_ReadAttributes_Read_if ( oReader, _T("lff"), m_oLff )
WritingElement_ReadAttributes_Read_if ( oReader, _T("lfo"), m_oLfo )
WritingElement_ReadAttributes_Read_if ( oReader, _T("lhe"), m_oLhe )
WritingElement_ReadAttributes_Read_if ( oReader, _T("lhf"), m_oLhf )
WritingElement_ReadAttributes_Read_if ( oReader, _T("lho"), m_oLho )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rfe"), m_oRfe )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rff"), m_oRff )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rfo"), m_oRfo )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rhe"), m_oRhe )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rhf"), m_oRhf )
WritingElement_ReadAttributes_Read_if ( oReader, _T("rho"), m_oRho )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oId )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("cfe"), m_oCfe )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("cff"), m_oCff )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("cfo"), m_oCfo )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("che"), m_oChe )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("chf"), m_oChf )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("cho"), m_oCho )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lfe"), m_oLfe )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lff"), m_oLff )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lfo"), m_oLfo )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lhe"), m_oLhe )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lhf"), m_oLhf )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("lho"), m_oLho )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rfe"), m_oRfe )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rff"), m_oRff )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rfo"), m_oRfo )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rhe"), m_oRhe )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rhf"), m_oRhf )
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("rho"), m_oRho )
WritingElement_ReadAttributes_End( oReader )
}
public:
@ -1063,7 +1061,7 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oId )
WritingElement_ReadAttributes_ReadSingle( oReader, _T("r:id"), m_oId )
WritingElement_ReadAttributes_End( oReader )
}
public:
@ -1114,10 +1112,10 @@ namespace OOX
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("id"), m_oId)
WritingElement_ReadAttributes_Read_if ( oReader, _T("man"), m_oMan)
WritingElement_ReadAttributes_Read_if ( oReader, _T("max"), m_oMax)
WritingElement_ReadAttributes_Read_if ( oReader, _T("min"), m_oMin)
WritingElement_ReadAttributes_Read_if ( oReader, _T("pt"), m_oPt)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("man"), m_oMan)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("max"), m_oMax)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("min"), m_oMin)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("pt"), m_oPt)
WritingElement_ReadAttributes_End( oReader )
}
@ -1144,7 +1142,7 @@ namespace OOX
}
virtual std::wstring toXML() const
{
return _T("");
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
@ -1152,11 +1150,11 @@ namespace OOX
}
virtual void toXML2(NSStringUtils::CStringBuilder& writer, const std::wstring& sName) const
{
writer.WriteString(_T("<"));
writer.WriteString(L"<");
writer.WriteString(sName);
WritingStringNullableAttrInt(L"count", m_oCount, m_oCount->GetValue());
WritingStringNullableAttrInt(L"manualBreakCount", m_oManualBreakCount, m_oManualBreakCount->GetValue());
writer.WriteString(_T(">"));
writer.WriteString(L">");
for ( size_t i = 0; i < m_arrItems.size(); ++i)
{
if ( m_arrItems[i] )
@ -1164,9 +1162,9 @@ namespace OOX
m_arrItems[i]->toXML(writer);
}
}
writer.WriteString(_T("</"));
writer.WriteString(L"</");
writer.WriteString(sName);
writer.WriteString(_T(">"));
writer.WriteString(L">");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
@ -1180,7 +1178,7 @@ namespace OOX
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( _T("brk") == sName )
if ( L"brk" == sName )
m_arrItems.push_back( new CBreak( oReader ));
}
}
@ -1193,8 +1191,8 @@ namespace OOX
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("count"), m_oCount)
WritingElement_ReadAttributes_Read_if ( oReader, _T("manualBreakCount"), m_oManualBreakCount)
WritingElement_ReadAttributes_Read_if ( oReader, L"count", m_oCount)
WritingElement_ReadAttributes_Read_else_if ( oReader, L"manualBreakCount", m_oManualBreakCount)
WritingElement_ReadAttributes_End( oReader )
}
@ -1202,6 +1200,448 @@ namespace OOX
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oManualBreakCount;
};
class CSheetProtection : public WritingElement
{
public:
WritingElement_AdditionConstructors(CSheetProtection)
CSheetProtection()
{
}
virtual ~CSheetProtection()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<sheetProtection");
WritingStringNullableAttrString(L"password", m_oPassword, m_oPassword.get());
WritingStringNullableAttrString(L"algorithmName",m_oAlgorithmName, m_oAlgorithmName->ToString());
WritingStringNullableAttrString(L"hashValue", m_oHashValue, m_oHashValue.get());
WritingStringNullableAttrString(L"saltValue", m_oSaltValue, m_oSaltValue.get());
WritingStringNullableAttrInt(L"spinCount", m_oSpinCount, m_oSpinCount->GetValue());
WritingStringNullableAttrInt(L"autoFilter", m_oAutoFilter, m_oAutoFilter->GetValue());
WritingStringNullableAttrInt(L"content", m_oContent, m_oContent->GetValue());
WritingStringNullableAttrInt(L"deleteColumns", m_oDeleteColumns, m_oDeleteColumns->GetValue());
WritingStringNullableAttrInt(L"deleteRows", m_oDeleteRows, m_oDeleteRows->GetValue());
WritingStringNullableAttrInt(L"formatCells", m_oFormatCells, m_oFormatCells->GetValue());
WritingStringNullableAttrInt(L"formatColumns", m_oFormatColumns, m_oFormatColumns->GetValue());
WritingStringNullableAttrInt(L"formatRows", m_oFormatRows, m_oFormatRows->GetValue());
WritingStringNullableAttrInt(L"insertColumns", m_oInsertColumns, m_oInsertColumns->GetValue());
WritingStringNullableAttrInt(L"insertHyperlinks", m_oInsertHyperlinks, m_oInsertHyperlinks->GetValue());
WritingStringNullableAttrInt(L"insertRows", m_oInsertRows, m_oInsertRows->GetValue());
WritingStringNullableAttrInt(L"objects", m_oObjects, m_oObjects->GetValue());
WritingStringNullableAttrInt(L"pivotTables", m_oPivotTables, m_oPivotTables->GetValue());
WritingStringNullableAttrInt(L"scenarios", m_oScenarios, m_oScenarios->GetValue());
WritingStringNullableAttrInt(L"selectLockedCells", m_oSelectLockedCells, m_oSelectLockedCells->GetValue());
WritingStringNullableAttrInt(L"selectUnlockedCell", m_oSelectUnlockedCell, m_oSelectUnlockedCell->GetValue());
WritingStringNullableAttrInt(L"sheet", m_oSheet, m_oSheet->GetValue());
WritingStringNullableAttrInt(L"sort", m_oSort, m_oSort->GetValue());
writer.WriteString(L"/>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_x_SheetProtection;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("password"), m_oPassword)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("algorithmName"), m_oAlgorithmName)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("hashValue"), m_oHashValue)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("saltValue"), m_oSaltValue)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("spinCount"), m_oSpinCount)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("autoFilter"), m_oAutoFilter)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("content"), m_oContent)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("deleteColumns"), m_oDeleteColumns)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("deleteRows"), m_oDeleteRows)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("formatCells"), m_oFormatCells)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("formatColumns"), m_oFormatColumns)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("formatRows"), m_oFormatRows)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("insertColumns"), m_oInsertColumns)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("insertHyperlinks"),m_oInsertHyperlinks)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("insertRows"), m_oInsertRows)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("objects"), m_oObjects)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("pivotTables"), m_oPivotTables)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("scenarios"), m_oScenarios)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("selectLockedCells"),m_oSelectLockedCells)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("selectUnlockedCell"),m_oSelectUnlockedCell)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sheet"), m_oSheet)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sort"), m_oSort)
WritingElement_ReadAttributes_End( oReader )
}
nullable<SimpleTypes::CCryptAlgoritmName<>> m_oAlgorithmName;
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSpinCount;
nullable_string m_oHashValue;
nullable_string m_oSaltValue;
nullable_string m_oPassword; //for old wrike protection
nullable<SimpleTypes::COnOff<>> m_oAutoFilter;
nullable<SimpleTypes::COnOff<>> m_oContent;
nullable<SimpleTypes::COnOff<>> m_oDeleteColumns;
nullable<SimpleTypes::COnOff<>> m_oDeleteRows;
nullable<SimpleTypes::COnOff<>> m_oFormatCells;
nullable<SimpleTypes::COnOff<>> m_oFormatColumns;
nullable<SimpleTypes::COnOff<>> m_oFormatRows;
nullable<SimpleTypes::COnOff<>> m_oInsertColumns;
nullable<SimpleTypes::COnOff<>> m_oInsertHyperlinks;
nullable<SimpleTypes::COnOff<>> m_oInsertRows;
nullable<SimpleTypes::COnOff<>> m_oObjects;
nullable<SimpleTypes::COnOff<>> m_oPivotTables;
nullable<SimpleTypes::COnOff<>> m_oScenarios;
nullable<SimpleTypes::COnOff<>> m_oSelectLockedCells;
nullable<SimpleTypes::COnOff<>> m_oSelectUnlockedCell;
nullable<SimpleTypes::COnOff<>> m_oSheet;
nullable<SimpleTypes::COnOff<>> m_oSort;
};
class CDataRef : public WritingElement
{
public:
WritingElement_AdditionConstructors(CDataRef)
CDataRef()
{
}
virtual ~CDataRef()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<sheetProtection");
WritingStringAttrString(L"r:id", m_oId->ToString());
WritingStringNullableAttrString(L"name", m_oName, m_oName.get());
WritingStringNullableAttrString(L"ref", m_oRef, m_oRef.get());
WritingStringNullableAttrString(L"sheet", m_oSheet, m_oSheet.get());
writer.WriteString(L"/>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_x_DataRef;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("r:id"), m_oId)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("name"), m_oName)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("ref"), m_oRef)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sheet"), m_oSheet)
WritingElement_ReadAttributes_End( oReader )
}
nullable<SimpleTypes::CRelationshipId> m_oId;
nullable_string m_oName;
nullable_string m_oRef;
nullable_string m_oSheet;
};
class CDataRefs : public WritingElementWithChilds<CDataRef>
{
public:
WritingElement_AdditionConstructors(CDataRefs)
CDataRefs()
{
}
virtual ~CDataRefs()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return _T("");
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<dataRefs");
WritingStringNullableAttrInt(L"count", m_oCount, m_oCount->GetValue());
writer.WriteString(L">");
for ( size_t i = 0; i < m_arrItems.size(); ++i)
{
if ( m_arrItems[i] )
{
m_arrItems[i]->toXML(writer);
}
}
writer.WriteString(L"</dataRefs>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"dataRef" == sName )
m_arrItems.push_back( new CDataRef( oReader ));
}
}
virtual EElementType getType () const
{
return et_x_DataRefs;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_ReadSingle( oReader, L"count", m_oCount)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
};
class CDataConsolidate : public WritingElement
{
public:
WritingElement_AdditionConstructors(CDataConsolidate)
CDataConsolidate()
{
}
virtual ~CDataConsolidate()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<dataConsolidate");
WritingStringNullableAttrString(L"function", m_oFunction, m_oFunction.get());
WritingStringNullableAttrInt(L"link", m_oLink, m_oLink->GetValue());
WritingStringNullableAttrInt(L"startLabels", m_oStartLabels, m_oStartLabels->GetValue());
WritingStringNullableAttrInt(L"topLabels", m_oTopLabels, m_oTopLabels->GetValue());
writer.WriteString(L">");
writer.WriteString(L"</dataConsolidate>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"dataRefs" == sName )
m_oDataRefs = oReader;
}
}
virtual EElementType getType () const
{
return et_x_DataConsolidate;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("function"), m_oFunction)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("link"), m_oLink)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("startLabels"), m_oStartLabels)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("topLabels"), m_oTopLabels)
WritingElement_ReadAttributes_End( oReader )
}
nullable_string m_oFunction; //ST_DataConsolidateFunction
nullable<SimpleTypes::COnOff<>> m_oLink;
nullable<SimpleTypes::COnOff<>> m_oStartLabels;
nullable<SimpleTypes::COnOff<>> m_oTopLabels;
nullable<CDataRefs> m_oDataRefs;
};
class CDataValidation : public WritingElement
{
public:
WritingElement_AdditionConstructors(CDataValidation)
CDataValidation()
{
}
virtual ~CDataValidation()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<dataValidation");
WritingStringNullableAttrInt (L"allowBlank", m_oAllowBlank, m_oAllowBlank->GetValue());
WritingStringNullableAttrString (L"error", m_oError, m_oError.get());
WritingStringNullableAttrString (L"errorStyle", m_oErrorStyle, m_oErrorStyle.get());
WritingStringNullableAttrString (L"errorTitle", m_oErrorTitle, m_oErrorTitle.get());
WritingStringNullableAttrString (L"imeMode", m_oImeMode, m_oImeMode.get());
WritingStringNullableAttrString (L"operator", m_oOperator, m_oOperator.get());
WritingStringNullableAttrString (L"promt", m_oPromt, m_oPromt.get());
WritingStringNullableAttrString (L"promptTitle", m_oPromptTitle, m_oPromptTitle.get());
WritingStringNullableAttrInt (L"showDropDown", m_oShowDropDown, m_oShowDropDown->GetValue());
WritingStringNullableAttrInt (L"showErrorMessage",m_oShowErrorMessage,m_oShowErrorMessage->GetValue());
WritingStringNullableAttrInt (L"showInputMessage",m_oShowInputMessage,m_oShowInputMessage->GetValue());
WritingStringNullableAttrString (L"sqref", m_oSqref, m_oSqref.get());
WritingStringNullableAttrString (L"type", m_oType, m_oType.get());
writer.WriteString(L"/>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( !oReader.IsEmptyNode() )
oReader.ReadTillEnd();
}
virtual EElementType getType () const
{
return et_x_DataValidation;
}
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, _T("allowBlank"), m_oAllowBlank)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("error"), m_oError)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("errorStyle"), m_oErrorStyle)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("errorTitle"), m_oErrorTitle)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("imeMode"), m_oImeMode)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("operator"), m_oOperator)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("promt"), m_oPromt)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("promptTitle"), m_oPromptTitle)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showDropDown"), m_oShowDropDown)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showErrorMessage"),m_oShowErrorMessage)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("showInputMessage"),m_oShowInputMessage)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("sqref"), m_oSqref)
WritingElement_ReadAttributes_Read_else_if ( oReader, _T("type"), m_oType)
WritingElement_ReadAttributes_End( oReader )
}
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oSpinCount;
nullable<SimpleTypes::COnOff<>> m_oAllowBlank;
nullable_string m_oError;
nullable_string m_oErrorStyle; //ST_DataValidationErrorStyle
nullable_string m_oErrorTitle;
nullable_string m_oImeMode; //ST_DataValidationImeMode
nullable_string m_oOperator; //ST_DataValidationOperator
nullable_string m_oPromt;
nullable_string m_oPromptTitle;
nullable<SimpleTypes::COnOff<>> m_oShowDropDown;
nullable<SimpleTypes::COnOff<>> m_oShowErrorMessage;
nullable<SimpleTypes::COnOff<>> m_oShowInputMessage;
nullable_string m_oSqref; //ST_Sqref
nullable_string m_oType; //ST_DataValidationType
};
class CDataValidations : public WritingElementWithChilds<CDataValidation>
{
public:
WritingElement_AdditionConstructors(CDataValidations)
CDataValidations()
{
}
virtual ~CDataValidations()
{
}
virtual void fromXML(XmlUtils::CXmlNode& node)
{
}
virtual std::wstring toXML() const
{
return L"";
}
virtual void toXML(NSStringUtils::CStringBuilder& writer) const
{
writer.WriteString(L"<dataValidations");
WritingStringNullableAttrInt(L"count", m_oCount, m_oCount->GetValue());
WritingStringNullableAttrInt(L"disablePrompts", m_oDisablePrompts, m_oDisablePrompts->GetValue());
WritingStringNullableAttrInt(L"xWindow", m_oXWindow, m_oXWindow->GetValue());
WritingStringNullableAttrInt(L"yWindow", m_oYWindow, m_oYWindow->GetValue());
writer.WriteString(L">");
for ( size_t i = 0; i < m_arrItems.size(); ++i)
{
if ( m_arrItems[i] )
{
m_arrItems[i]->toXML(writer);
}
}
writer.WriteString(L"</dataValidations>");
}
virtual void fromXML(XmlUtils::CXmlLiteReader& oReader)
{
ReadAttributes( oReader );
if ( oReader.IsEmptyNode() )
return;
int nCurDepth = oReader.GetDepth();
while( oReader.ReadNextSiblingNode( nCurDepth ) )
{
std::wstring sName = XmlUtils::GetNameNoNS(oReader.GetName());
if ( L"dataValidation" == sName )
m_arrItems.push_back( new CDataValidation( oReader ));
}
}
virtual EElementType getType () const
{
return et_x_DataValidations;
}
private:
void ReadAttributes(XmlUtils::CXmlLiteReader& oReader)
{
WritingElement_ReadAttributes_Start( oReader )
WritingElement_ReadAttributes_Read_if ( oReader, L"count", m_oCount)
WritingElement_ReadAttributes_Read_else_if ( oReader, L"disablePrompts",m_oDisablePrompts)
WritingElement_ReadAttributes_Read_else_if ( oReader, L"xWindow", m_oXWindow)
WritingElement_ReadAttributes_Read_else_if ( oReader, L"yWindow", m_oYWindow)
WritingElement_ReadAttributes_End( oReader )
}
public:
nullable<SimpleTypes::CUnsignedDecimalNumber<>> m_oCount;
nullable<SimpleTypes::COnOff<>> m_oDisablePrompts;
nullable<SimpleTypes::CDecimalNumber<>> m_oXWindow;
nullable<SimpleTypes::CDecimalNumber<>> m_oYWindow;
};
} //Spreadsheet
} // namespace OOX

View File

@ -1 +1 @@
2.4.556.0
2.5.556.0

View File

@ -255,12 +255,12 @@ public:
double bottom;
public:
CDoubleRect()
CDoubleRect(double dLeft = 0.0, double dTop = 0.0, double dRight = 0.0, double dBottom = 0.0)
{
left = 0;
top = 0;
right = 0;
bottom = 0;
left = dLeft;
top = dTop;
right = dRight;
bottom = dBottom;
}
CDoubleRect& operator=(const CDoubleRect& oSrc)
{
@ -303,6 +303,11 @@ public:
return (top + bottom) / 2.0;
}
inline CDoublePoint GetCenter() const
{
return CDoublePoint((left + right) / 2.0, (top + bottom) / 2.0);
}
inline INT IsPointInside(const CDoublePoint& oPoint)
{
return IsPointInside(oPoint.x, oPoint.y);

View File

@ -408,7 +408,7 @@ static const struct ActionNamesEmf
m_oStream.Skip(ulHeaderSize + lBitsOffset);
BYTE* pBitsBuffer = m_oStream.GetCurPtr();
unsigned int ulBitsSizeSkip = std::ceil(ulBitsSize / 4 + 0.5) * 4;
unsigned int ulBitsSizeSkip = 0 == ulBitsSize ? 0 : ((int)(((double)ulBitsSize - 0.5) / 4) + 1) * 4;
m_oStream.Skip(ulBitsSizeSkip);
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight);

View File

@ -398,9 +398,9 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
const char* nenv[4];
nenv[0] = sLibraryDir.c_str();
nenv[1] = "LD_PRELOAD=./libcef.so";
nenv[2] = "DISPLAY=:0";
nenv[3] = NULL;
nenv[1] = "DISPLAY=:0";
nenv[2] = NULL;
nenv[3] = NULL;
execve(sProgramm.c_str(),
(char * const *)nargs,
@ -419,9 +419,8 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
const char* nenv[4];
nenv[0] = sLibraryDir.c_str();
nenv[1] = "LD_PRELOAD=./libcef.so";
nenv[2] = NULL;//"DISPLAY=:99";
nenv[3] = NULL;
nenv[1] = NULL;//"DISPLAY=:99";
nenv[2] = NULL;
execve("/usr/bin/xvfb-run", (char * const *)nargs, (char * const *)nenv);
exit(EXIT_SUCCESS);

View File

@ -16,6 +16,11 @@ CONFIG -= debug_and_release debug_and_release_target
DEFINES += HTMLFILE_USE_DYNAMIC_LIBRARY
DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY
CORE_ROOT_DIR = $$PWD/../..
PWD_ROOT_DIR = $$PWD
include($$CORE_ROOT_DIR/Common/base.pri)
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/Debug
} else {
@ -25,41 +30,10 @@ CONFIG(debug, debug|release) {
CONFIG += c++11
TEMPLATE = app
############### destination path ###############
DESTINATION_SDK_PATH = $$PWD/../../build/lib
# WINDOWS
win32:contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64/DEBUG
} else {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_64
}
}
win32:!contains(QMAKE_TARGET.arch, x86_64):{
CONFIG(debug, debug|release) {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32/DEBUG
} else {
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/win_32
}
}
linux-g++:contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_64
}
linux-g++:!contains(QMAKE_HOST.arch, x86_64):{
DESTINATION_SDK_PATH = $$DESTINATION_SDK_PATH/linux_32
}
LIBS += -L$$DESTINATION_SDK_PATH -lHtmlFile
LIBS += -L$$DESTINATION_SDK_PATH -lUnicodeConverter
LIBS += -L$$DESTINATION_SDK_PATH -lgraphics
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter -lkernel -lgraphics -lHtmlFile
linux-g++ | linux-g++-64 | linux-g++-32 {
QMAKE_LFLAGS += -Wl,--rpath=./
LIBS += $$PWD/../../build/bin/icu/linux_64/libicuuc.so.55
LIBS += $$PWD/../../build/bin/icu/linux_64/libicudata.so.55
message(linux)
}
@ -67,9 +41,6 @@ win32 {
LIBS += -ladvapi32 \
-luser32 \
-lshell32
LIBS += -L$$PWD/../../build/bin/icu/win_64/ -licudt
LIBS += -L$$PWD/../../build/bin/icu/win_64/ -licuuc
}
SOURCES += main.cpp

View File

@ -53,9 +53,9 @@
#include "../../Common/DocxFormat/Source/Base/unicode_util.h"
#include "../../Common/DocxFormat/Source/Base/Types_32.h"
#include "../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../DesktopEditor/common/File.h"
static const unsigned char encrVerifierHashInputBlockKey[8] = { 0xfe, 0xa7, 0xd2, 0x76, 0x3b, 0x4b, 0x9e, 0x79 };
static const unsigned char encrVerifierHashValueBlockKey[8] = { 0xd7, 0xaa, 0x0f, 0x6d, 0x30, 0x61, 0x34, 0x4e };
static const unsigned char encrKeyValueBlockKey[8] = { 0x14, 0x6e, 0x0b, 0xe7, 0xab, 0xac, 0xd0, 0xd6 };
@ -810,7 +810,114 @@ void ECMADecryptor::Decrypt(unsigned char* data_inp, int size, unsigned char*&
DecryptCipher(hashKey, empty, pInp, pOut, cryptData.cipherAlgorithm);
}
}
//-----------------------------------------------------------------------------------------------------------
void odfWriteProtect::SetPassword (const std::wstring &password_)
{
password = password_;
}
void odfWriteProtect::SetProtectKey (const std::string &key)
{
protect_key = key;
}
void odfWriteProtect::SetProtectAlgorithm (const CRYPT_METHOD::_hashAlgorithm &alg)
{
hash = alg;
}
void odfWriteProtect::Generate()
{
_buf pPassword (password);
_buf empty (NULL, 0, false);
_buf pHashTest = HashAppend(empty, pPassword, hash);
protect_key = std::string((char*)pHashTest.ptr, pHashTest.size);
}
bool odfWriteProtect::Verify()
{
_buf pPassword (password);
_buf empty (NULL, 0, false);
_buf pHash (protect_key);
_buf pHashTest = HashAppend(empty, pPassword, hash);
return (pHashTest == pHash);
}
//----------------------------------------------------------------------------------------------------------
void ECMAWriteProtect::SetPassword (const std::wstring &password_)
{
password = password_;
}
void ECMAWriteProtect::SetCryptData(_ecmaWriteProtectData &_data)
{
data = _data;
}
void ECMAWriteProtect::GetCryptData(_ecmaWriteProtectData &_data)
{
_data = data;
}
void ECMAWriteProtect::Generate()
{
//сгенерить соль
RandomPool prng;
SecByteBlock seed_salt(16);
OS_GenerateRandomBlock(false, seed_salt, seed_salt.size());
prng.IncorporateEntropy(seed_salt, seed_salt.size());
_buf pPassword (password);
_buf empty (NULL, 0, false);
_buf pSalt (seed_salt.data(), seed_salt.size());
_buf pHashBuf = HashAppend(pSalt, pPassword, data.hashAlgorithm);
for (int i = 0; i < data.spinCount; i++)
{
_buf iterator((unsigned char*)&i, 4, false);
pHashBuf = HashAppend(pHashBuf, iterator, data.hashAlgorithm);
}
data.saltValue = std::string((char*)pSalt.ptr, pSalt.size);
data.hashValue = std::string((char*)pHashBuf.ptr, pHashBuf.size);
}
bool ECMAWriteProtect::VerifyWrike()
{
std::string p = std::string(password.begin(), password.end());
unsigned int wPasswordHash = 0;
const char* pch = p.c_str() + p.length();
while (pch-- != p.c_str())
{
wPasswordHash = ((wPasswordHash >> 14) & 0x01) |
((wPasswordHash << 1) & 0x7fff);
wPasswordHash ^= *pch;
}
wPasswordHash = ((wPasswordHash >> 14) & 0x01) |
((wPasswordHash << 1) & 0x7fff);
wPasswordHash ^= (0x8000 | ('N' << 8) | 'K');
wPasswordHash ^= p.length();
std::string sPasswordHash = XmlUtils::IntToString(wPasswordHash, "%4.4X");
return data.hashValue == sPasswordHash;
}
bool ECMAWriteProtect::Verify()
{
_buf pPassword (password);
_buf empty (NULL, 0, false);
_buf pSalt (data.saltValue);
_buf pHash (data.hashValue);
_buf pHashTest = HashAppend(pSalt, pPassword, data.hashAlgorithm);
for (int i = 0; i < data.spinCount; i++)
{
_buf iterator((unsigned char*)&i, 4, false);
pHashTest = HashAppend(pHashTest, iterator, data.hashAlgorithm);
}
return (pHashTest == pHash);
}
//-----------------------------------------------------------------------------------------------------------
ECMAEncryptor::ECMAEncryptor()
{

View File

@ -74,6 +74,13 @@ class Decryptor
};
typedef boost::shared_ptr<Decryptor> DecryptorPtr;
struct _ecmaWriteProtectData
{
CRYPT_METHOD::_hashAlgorithm hashAlgorithm = CRYPT_METHOD::SHA512;
int spinCount = 100000;
std::string saltValue;
std::string hashValue;
};
struct _ecmaCryptData
{
//default ms2010
@ -126,6 +133,44 @@ struct _odfCryptData
CRYPT_METHOD::_hashAlgorithm checksum_hashAlgorithm = CRYPT_METHOD::SHA1;
};
//---------------------------------------------------------------------------------------------------
class ECMAWriteProtect
{
public:
ECMAWriteProtect(){}
virtual ~ECMAWriteProtect(){}
void SetPassword (const std::wstring &password);
void SetCryptData(_ecmaWriteProtectData &data);
void GetCryptData(_ecmaWriteProtectData &data);
void Generate();
bool Verify();
bool VerifyWrike();
private:
std::wstring password;
_ecmaWriteProtectData data;
};
//---------------------------------------------------------------------------------------------------
class odfWriteProtect
{
public:
odfWriteProtect() : hash(CRYPT_METHOD::SHA1) {}
void SetPassword (const std::wstring & password);
void SetProtectKey (const std::string & protect_key);
void SetProtectAlgorithm (const CRYPT_METHOD::_hashAlgorithm & hash);
void Generate();
bool Verify();
private:
std::wstring password;
CRYPT_METHOD::_hashAlgorithm hash;
std::string protect_key;
};
//---------------------------------------------------------------------------------------------------
class ECMAEncryptor
{
public:

View File

@ -11,7 +11,7 @@ apply from: "$rootProject.projectDir/extra-builds/gradle/common.gradle"
// Common native libs path
def TOOLCHAIN_VERSION = 4.9
def NDK_VERSION = "android-ndk-r17c"
def HOST_PLATFORM = getHostName()
def HOST_PLATFORM = getHostNameFull()
def PATH_NDK = "${project.rootDir.path}/${NDK_VERSION}"
def PATH_TOOLCHAIN = "$PATH_NDK/toolchains/\$1/prebuilt/$HOST_PLATFORM/bin"
def PATH_STANDALONE_SCRIPT = "$PATH_NDK/build/tools"
@ -43,7 +43,7 @@ def ICONV_LIBS_PATH = "$project.ext.PATH_TO_NATIVE_LIBS/iconv"
def ICONV_LIBS_INSTALL = "$ICONV_LIBS_PATH/install"
// Icu
def ICU_SRC = "$PATH_3PARTY/icu/" + getDirName("$PATH_3PARTY/icu")
def ICU_SRC = "$PATH_3PARTY/icu/" + findDirName("$PATH_3PARTY/icu", getHostName())
def ICU_BUILD = "$ICU_SRC/build"
def ICU_SRC_ROOT = "$ICU_SRC/icu/source"
def ICU_LIBS_PATH = "$project.ext.PATH_TO_NATIVE_LIBS/icu"

View File

@ -28,7 +28,8 @@ endif()
if (NOT DEFINED ARG_LIBS)
message(FATAL_ERROR "You must set argument \"ARG_LIBS\" with path to 3d-party library...")
elseif (NOT EXISTS ${ARG_LIBS})
message(FATAL_ERROR "3d party libraries path doesn't exist!")
file(MAKE_DIRECTORY ${ARG_LIBS})
message(STATUS "3d party libraries path doesn't exist! Created!")
endif()
# ---------- Libs names ----------

View File

@ -89,13 +89,15 @@ def getBackSlashExt(String str) {
return str.replaceAll("\\\\", "/")
}
def getDirNameExt(String path) {
def findDirNameExt(String path, String name) {
def countFolders = 0
def nameFolder = ''
file(path).listFiles().each { it ->
if (it.isDirectory()) {
nameFolder = it.getName()
++countFolders
if (it.getName().contains(name)) {
nameFolder = it.getName()
++countFolders
}
}
}
@ -144,7 +146,7 @@ ext {
// Extra path
// Args for cmake
project.ext.SRC_CORE = "$rootProject.rootDir/../../../"
project.ext.SRC_CORE = "$rootProject.rootDir/../../.."
project.ext.PATH_TO_NATIVE_BUILDS = getBackSlashExt("$rootProject.projectDir/extra-builds/native")
project.ext.PATH_TO_NATIVE_LIBS = "$project.ext.PATH_TO_NATIVE_BUILDS/libs"
project.ext.PATH_TO_NATIVE_ARCHS = "$project.ext.PATH_TO_NATIVE_BUILDS/libs.tar"
@ -171,7 +173,8 @@ ext {
getPathEnv = this.&getPathEnvOs
isFolderNotEmpty = this.&isFolderNotEmptyCheck
getBackSlash = this.&getBackSlashExt
getDirName = this.&getDirNameExt
getHostName = this.&getHostNameFullExt
findDirName = this.&findDirNameExt
getHostNameFull = this.&getHostNameFullExt
getHostName = this.&getHostNameExt
}