Compare commits

...

5 Commits

Author SHA1 Message Date
dfd54ff53f _MSC_VER >= 1900 build 2017-10-11 16:30:37 +03:00
6ec7d77e19 speed logger 2017-10-09 15:21:16 +03:00
356ccba104 fixed bug#35998 2017-10-06 14:09:56 +03:00
3044d1122a OdfFormatReader - fix pilot tables (groups & references) 2017-10-06 11:36:00 +03:00
fb00ba7ecb fix users file 2017-10-06 11:35:03 +03:00
14 changed files with 573 additions and 154 deletions

View File

@ -70,9 +70,22 @@ public:
std::wstring sVal;
std::wstring sNode;
};
struct _reference
{
std::wstring name;
int type = -1;
std::wstring member_name;
int member_type = -1;
};
struct _group
{
std::wstring name;
std::vector<_field_value> caches;
};
struct _field
{
std::wstring name;
std::wstring display_name;
int type = -1;
int hierarchy = -1;
int function = -1;
@ -80,13 +93,20 @@ public:
bool data_layout = false;
bool show_empty = false;
bool repeat_item_labels = true;
int type_groups = 0;
int sort = 0;
std::wstring source_groups;
std::vector<int> subtotals;
std::vector<_field_value> caches;
std::vector<_reference> references;
int references_field = -1;
bool used_in_referenes = false;
int type_groups = 0;
int base_group = -1;
std::wstring source_groups;
std::vector<_group> groups;
std::vector<int> groups_discrete;
bool bDataFieldEnabled = false;
bool bString = false;
@ -142,8 +162,10 @@ public:
bool identify_categories = false;
bool drill_enabled = true;
bool ignore_empty_rows = false;
bool data_on_row = false;
bool in_group = false;
}current_;
void sort_fields();
@ -259,17 +281,162 @@ xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl
}
void xlsx_pivots_context::Impl::sort_fields()
{
for (size_t i = 0; i < current_.fields.size(); i++)
size_t count_skip = 0;
for (size_t i = 0; i < current_.fields.size() - count_skip; i++)
{
if (current_.fields[i].type == 7)
continue;
if (!current_.fields[i].source_groups.empty() && i != current_.fields.size() -1)
if (!current_.fields[i].source_groups.empty() && i != current_.fields.size() - count_skip)
{
current_.fields.push_back(current_.fields[i]);
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
i--;
count_skip++;
}
}
count_skip = 0;
for (size_t i = 0; i < current_.fields.size() - count_skip; i++)
{
if (current_.fields[i].name.empty() && i != current_.fields.size() - count_skip)
{
current_.fields.push_back(current_.fields[i]);
current_.fields.erase(current_.fields.begin() + i , current_.fields.begin() + i + 1);
i--;
count_skip++;
}
}
bool bEmptyRowCache = false, bAddRepeateCol = false;
bool bEmptyColCache = false, bAddRepeateRow = false;
int index_current = 0;
for (size_t i = 0; i < current_.fields.size(); i++, index_current++)
{
if ( current_.fields[i].type_groups > 0 )
{
current_.fields[i].base_group = 0;
int index_group = 0;
for (size_t k = 0; k < current_.fields.size(); k++)
{
if (current_.fields[k].type == 7) continue;
if (current_.fields[k].name == current_.fields[i].source_groups && !current_.fields[i].source_groups.empty())
{
if (current_.fields[k].type_groups == 0)
current_.fields[k].base_group = index_current; //опорный (если он и базовый - не писать)
current_.fields[i].base_group = index_group;
for (size_t c = 0; !current_.fields[i].groups.empty() && c < current_.fields[k].caches.size(); c++)
{
for (size_t g = 0; g < current_.fields[i].groups.size(); g++)
{
for (size_t h = 0; h < current_.fields[i].groups[g].caches.size(); h++)
{
if (current_.fields[i].groups[g].caches[h].sVal == current_.fields[k].caches[c].sVal)
current_.fields[i].groups_discrete.push_back(g);
}
}
}
break;
}
index_group++;
}
}
if ( current_.fields[i].name.empty() &&
!current_.fields[i].data_layout)
continue;
switch(current_.fields[i].type)
{
case 0: // column
{
if (!current_.fields[i].name.empty())
current_.col_fields.push_back(i);
if (current_.fields[i].data_layout)
{
if ((current_.fields[i].name.empty() && (!current_.identify_categories || current_.fields[i].hierarchy >= 0)) ||
current_.fields[i].used_in_referenes )
{
if ((current_.col_fields.empty()) || (current_.col_fields.back() != -2))
{
bAddRepeateCol = true;
}
}
}
if (current_.fields[i].caches.empty())
bEmptyColCache = true;
}break;
case 1: // data
{
int index_field = -1;
for (size_t j = 0; j < i/*current_.fields.size()*/; j++)
{
if ( current_.fields[j].name == current_.fields[i].name )
{
current_.fields[j].bDataFieldEnabled = true;
index_field = j;
break;
}
}
if (index_field >= 0)
{
if (current_.fields[i].caches.empty())
{
current_.fields[i].type = 7; //skip
current_.fields_count--;
index_current--;
}
current_.fields[i].references_field = index_field;
}
index_field = i;
current_.fields[i].bDataFieldEnabled = true;
current_.data_fields.push_back(index_field);
}break;
case 2: // hidden
{
}break;
case 3: // page
{
current_.page_fields.push_back(i);
}break;
case 4: // row
{
if (!current_.fields[i].name.empty())
current_.row_fields.push_back(i);
if (current_.fields[i].data_layout)
{
current_.data_on_row = true;
if ((current_.fields[i].name.empty() && (!current_.identify_categories || current_.fields[i].hierarchy >= 0)) ||
current_.fields[i].used_in_referenes )
{
bAddRepeateRow = true;
}
}
if (current_.fields[i].caches.empty())
bEmptyRowCache = true;
}break;
}
if (current_.fields[i].name.empty())
{
current_.fields.erase(current_.fields.begin() + i, current_.fields.begin() + i + 1);
current_.fields_count--;
i--;
}
}
if (bAddRepeateCol || bEmptyColCache)
current_.col_fields.push_back(-2);
if (bAddRepeateRow)
current_.row_fields.push_back(-2);
}
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
{
@ -468,22 +635,38 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
}
CP_XML_ATTR(L"defaultSubtotal", 0);
if (!current_.fields[i].caches.empty() && current_.fields[i].type != 2)
if (current_.fields[i].type != 2)
{
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
if (!current_.fields[i].groups.empty())
{
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].groups.size());
for (size_t j = 0; j < current_.fields[i].groups.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
}
}
}
}
else if (!current_.fields[i].caches.empty())
{
CP_XML_NODE(L"items")
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(L"item")
{
CP_XML_ATTR(L"x", j);
}
}
}
}
}
}
//CP_XML_STREAM() << fields_[i].view_;
}
}
if (!current_.row_fields.empty())
@ -537,35 +720,85 @@ void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
CP_XML_ATTR(L"count", current_.data_fields.size());
for (size_t i = 0; i < current_.data_fields.size(); i++)
{
CP_XML_NODE(L"dataField")
{
CP_XML_ATTR(L"fld", current_.data_fields[i]);
CP_XML_ATTR(L"baseField", current_.data_fields[i]);
//CP_XML_ATTR(L"baseItem", -1);
//CP_XML_ATTR(L"name", L"");
int ind_field_dirty = current_.data_fields[i];
int ind_field = current_.data_fields[i];
if (ind_field >= 0 && ind_field < current_.fields.size())
CP_XML_NODE(L"dataField")
{
int fld = 0, ind_fld = current_.fields[ind_field_dirty].references_field < 0 ? ind_field_dirty :
current_.fields[ind_field_dirty].references_field;
for (size_t k = 0; k < ind_fld; k++)
{
switch(current_.fields[ind_field].function)
if (current_.fields[k].type != 7 ) fld++;
}
CP_XML_ATTR(L"fld", fld);
if (current_.fields[ind_field_dirty].references.empty())
{
CP_XML_ATTR(L"baseField", fld);
}
else
{
size_t base_field = 0, base_item = 0;
for (size_t k = 0; k < current_.fields.size(); k++)
{
case 1: CP_XML_ATTR(L"subtotal", L"average"); break;
case 2: CP_XML_ATTR(L"subtotal", L"count"); break;
case 3: CP_XML_ATTR(L"subtotal", L"countNums"); break;
case 4: CP_XML_ATTR(L"subtotal", L"max"); break;
case 5: CP_XML_ATTR(L"subtotal", L"min"); break;
case 6: CP_XML_ATTR(L"subtotal", L"product"); break;
case 7: CP_XML_ATTR(L"subtotal", L"stdDev"); break;
case 8: CP_XML_ATTR(L"subtotal", L"stdDevp"); break;
case 9: CP_XML_ATTR(L"subtotal", L"sum"); break;
case 10: CP_XML_ATTR(L"subtotal", L"var"); break;
case 11: CP_XML_ATTR(L"subtotal", L"varp"); break;
if (current_.fields[k].type == 7 ) continue;
if (current_.fields[k].name == current_.fields[ind_field_dirty].references[0].name)
{
for (size_t j = 0; j < current_.fields[k].caches.size(); j++)
{
if (current_.fields[k].caches[j].sVal == current_.fields[ind_field_dirty].references[0].member_name)
{
base_item = j;
break;
}
}
break;
}
base_field++;
}
CP_XML_ATTR(L"baseField", base_field);
CP_XML_ATTR(L"baseItem", base_item);
switch(current_.fields[ind_field_dirty].references[0].type)
{
case 1: CP_XML_ATTR(L"showDataAs", L"difference"); break;
case 2: CP_XML_ATTR(L"showDataAs", L"percent"); break;
case 3: CP_XML_ATTR(L"showDataAs", L"percentDiff"); break;
}
}
std::wstring name;
if (ind_field_dirty >= 0 && ind_field_dirty < current_.fields.size())
{
switch(current_.fields[ind_field_dirty].function)
{
case 1: CP_XML_ATTR(L"subtotal", L"average"); name = L"average "; break;
case 2: CP_XML_ATTR(L"subtotal", L"count"); name = L"count "; break;
case 3: CP_XML_ATTR(L"subtotal", L"countNums"); name = L"countNums "; break;
case 4: CP_XML_ATTR(L"subtotal", L"max"); name = L"max "; break;
case 5: CP_XML_ATTR(L"subtotal", L"min"); name = L"min "; break;
case 6: CP_XML_ATTR(L"subtotal", L"product"); name = L"product "; break;
case 7: CP_XML_ATTR(L"subtotal", L"stdDev"); name = L"stdDev Dev "; break;
case 8: CP_XML_ATTR(L"subtotal", L"stdDevp"); name = L"stdDevp "; break;
case 9: CP_XML_ATTR(L"subtotal", L"sum"); name = L"sum by "; break;
case 10: CP_XML_ATTR(L"subtotal", L"var"); name = L"var "; break;
case 11: CP_XML_ATTR(L"subtotal", L"varp"); name = L"varp "; break;
case 12:
{
CP_XML_ATTR(L"subtotal", current_.fields[current_.data_fields[i]].user_function);
}break;
default: break;
}
if (current_.fields[ind_field_dirty].display_name.empty())
{
name += current_.fields[ind_field_dirty].name;
}
else
{
name = current_.fields[ind_field_dirty].display_name;
}
CP_XML_ATTR(L"name", name);
}
}
}
@ -708,6 +941,7 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
}
}
}
int index_current = 0;
if (current_.fields.empty() == false)
{
@ -744,11 +978,12 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
}
else
{
else if (current_.fields[i].type_groups < 8)
{//group by date
current_.fields[i].bDate = true;
current_.fields[i].bString = false;
}
//else group by fields
serialize_type_field(CP_GET_XML_NODE(), current_.fields[i]);
if ( current_.fields[i].type_groups == 0 )
@ -766,37 +1001,78 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
}
}
}
if ( current_.fields[i].type_groups != 0 )
if (current_.fields[i].base_group >= 0)
{
CP_XML_NODE(L"fieldGroup")
{
CP_XML_ATTR(L"base", 0);
CP_XML_NODE(L"rangePr")
{
if ( current_.fields[i].type_groups > 0)
{
switch(current_.fields[i].type_groups)
{
case 1: CP_XML_ATTR(L"groupBy", L"seconds"); break;
case 2: CP_XML_ATTR(L"groupBy", L"minutes"); break;
case 3: CP_XML_ATTR(L"groupBy", L"hours"); break;
case 4: CP_XML_ATTR(L"groupBy", L"days"); break;
case 5: CP_XML_ATTR(L"groupBy", L"months"); break;
case 6: CP_XML_ATTR(L"groupBy", L"quarters"); break;
case 7: CP_XML_ATTR(L"groupBy", L"years"); break;
}
CP_XML_ATTR(L"startDate", L"1899-12-31T00:00:00");
CP_XML_ATTR(L"endDate", L"1899-12-31T00:00:00");
CP_XML_ATTR(L"base", current_.fields[i].base_group);
}
CP_XML_NODE(L"groupItems")
else
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
CP_XML_ATTR(L"par", current_.fields[i].base_group);
}
if (current_.fields[i].type_groups > 0)
{
if (current_.fields[i].type_groups < 8)
{
CP_XML_NODE(current_.fields[i].caches[j].sNode)
CP_XML_NODE(L"rangePr")
{
if (current_.fields[i].caches[j].sVal.empty() == false)
switch(current_.fields[i].type_groups)
{
CP_XML_ATTR(L"v", current_.fields[i].caches[j].sVal);
case 1: CP_XML_ATTR(L"groupBy", L"seconds"); break;
case 2: CP_XML_ATTR(L"groupBy", L"minutes"); break;
case 3: CP_XML_ATTR(L"groupBy", L"hours"); break;
case 4: CP_XML_ATTR(L"groupBy", L"days"); break;
case 5: CP_XML_ATTR(L"groupBy", L"months"); break;
case 6: CP_XML_ATTR(L"groupBy", L"quarters"); break;
case 7: CP_XML_ATTR(L"groupBy", L"years"); break;
}
CP_XML_ATTR(L"startDate", L"1899-12-31T00:00:00");
CP_XML_ATTR(L"endDate", L"1899-12-31T00:00:00");
}
}
if (!current_.fields[i].groups_discrete.empty())
{
CP_XML_NODE(L"discretePr")
{
CP_XML_ATTR(L"count", current_.fields[i].groups_discrete.size());
for (size_t j = 0; j < current_.fields[i].groups_discrete.size(); j++)
{
CP_XML_NODE(L"x")
{
CP_XML_ATTR(L"v", current_.fields[i].groups_discrete[j]);
}
}
}
}
CP_XML_NODE(L"groupItems")
{
if (!current_.fields[i].groups.empty())
{
CP_XML_ATTR(L"count", current_.fields[i].groups.size());
for (size_t j = 0; j < current_.fields[i].groups.size(); j++)
{
CP_XML_NODE(L"s")
{
CP_XML_ATTR(L"v", current_.fields[i].groups[j].name);
}
}
}
else
{
CP_XML_ATTR(L"count", current_.fields[i].caches.size());
for (size_t j = 0; j < current_.fields[i].caches.size(); j++)
{
CP_XML_NODE(current_.fields[i].caches[j].sNode)
{
if (current_.fields[i].caches[j].sVal.empty() == false)
{
CP_XML_ATTR(L"v", current_.fields[i].caches[j].sVal);
}
}
}
}
}
@ -804,6 +1080,8 @@ void xlsx_pivots_context::Impl::serialize_cache(std::wostream & strm)
}
}
}
index_current++;
}
}
}
@ -940,6 +1218,10 @@ void xlsx_pivots_context::set_identify_categories(bool val)
{
impl_->current_.identify_categories = val;
}
void xlsx_pivots_context::set_ignore_empty_rows(bool val)
{
impl_->current_.ignore_empty_rows = val;
}
void xlsx_pivots_context::set_drill(bool val)
{
impl_->current_.drill_enabled = val;
@ -955,75 +1237,86 @@ void xlsx_pivots_context::set_field_name(std::wstring name)
{
impl_->current_.fields.back().name = name;
}
void xlsx_pivots_context::set_field_display(std::wstring name)
{
impl_->current_.fields.back().display_name = name;
}
void xlsx_pivots_context::set_field_type(int type, int hierarchy)
{
impl_->current_.fields.back().type = type;
impl_->current_.fields.back().hierarchy = hierarchy;
if ( impl_->current_.fields.back().name.empty() &&
!impl_->current_.fields.back().data_layout)
return;
//if ( impl_->current_.fields.back().name.empty() &&
// !impl_->current_.fields.back().data_layout)
// return;
switch(type)
{
case 0: // column
{
if (impl_->current_.fields.back().data_layout)
{
if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
//impl_->current_.fields.back().repeat_item_labels )) //????
impl_->current_.col_fields.push_back(-2);
}
else
impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1);
}break;
case 1: // data
{
int index_field = -1;
for (size_t i = 0; i < impl_->current_.fields.size(); i++)
{
if (impl_->current_.fields[i].name == impl_->current_.fields.back().name &&
impl_->current_.fields[i].type != 1)
{
impl_->current_.fields[i].bDataFieldEnabled = true;
index_field = i;
break;
}
}
if (index_field >= 0)
{
impl_->current_.fields.back().type = 7;
impl_->current_.fields_count--;
impl_->current_.data_fields.push_back(index_field);
}
else
{
index_field = impl_->current_.fields.size() - 1;
impl_->current_.fields.back().bDataFieldEnabled = true;
impl_->current_.data_fields.push_back(index_field);
}
}break;
case 2: // hidden
break;
case 3: // page
impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1);
break;
case 4: // row
if (impl_->current_.fields.back().data_layout)
{
impl_->current_.data_on_row = true;
//switch(type)
//{
// case 0: // column
// {
// if (impl_->current_.fields.back().data_layout)
// {
// if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
// //impl_->current_.fields.back().repeat_item_labels )) //????
// impl_->current_.col_fields.push_back(-2);
// }
// else
// impl_->current_.col_fields.push_back(impl_->current_.fields.size() - 1);
// }break;
// case 1: // data
// {
// int index_field = -1;
//
// for (size_t i = 0; i < impl_->current_.fields.size() - 1; i++)
// {
// if (impl_->current_.fields[i].name == impl_->current_.fields.back().name &&
// (impl_->current_.fields[i].type != 1 || !impl_->current_.fields.back().references.empty()))
// {
// impl_->current_.fields[i].bDataFieldEnabled = true;
// index_field = i;
// break;
// }
// }
// if (index_field >= 0)
// {
// impl_->current_.fields.back().type = 7; //skip
// impl_->current_.fields_count--;
//
// if (!impl_->current_.fields.back().references.empty())
// {
// impl_->current_.fields.back().references_field = index_field;
// impl_->current_.fields.back().bDataFieldEnabled = true;
//
// index_field = impl_->current_.fields.size() - 1;
// }
// }
// else
// {
// index_field = impl_->current_.fields.size() - 1;
// impl_->current_.fields.back().bDataFieldEnabled = true;
// }
// impl_->current_.data_fields.push_back(index_field);
// }break;
// case 2: // hidden
// break;
// case 3: // page
// impl_->current_.page_fields.push_back(impl_->current_.fields.size() - 1);
// break;
// case 4: // row
// if (impl_->current_.fields.back().data_layout)
// {
// impl_->current_.data_on_row = true;
if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
//(impl_->current_.fields.back().repeat_item_labels ||
// !impl_->current_.identify_categories ))
impl_->current_.row_fields.push_back(-2);
// if (impl_->current_.fields.back().name.empty() && (!impl_->current_.identify_categories || hierarchy >= 0))
// //(impl_->current_.fields.back().repeat_item_labels ||
// // !impl_->current_.identify_categories ))
// impl_->current_.row_fields.push_back(-2);
}
else
impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1);
break;
}
// }
// else
// impl_->current_.row_fields.push_back(impl_->current_.fields.size() - 1);
// break;
//}
}
void xlsx_pivots_context::set_field_function(int type)
{
@ -1058,10 +1351,56 @@ void xlsx_pivots_context::set_field_groups_source(std::wstring name)
{
impl_->current_.fields.back().source_groups = name;
}
void xlsx_pivots_context::start_field_group()
{
impl_->current_.in_group = true;
Impl::_group group;
impl_->current_.fields.back().groups.push_back(group);
}
void xlsx_pivots_context::set_field_group_name (std::wstring name)
{
impl_->current_.fields.back().groups.back().name = name;
}
void xlsx_pivots_context::end_field_group()
{
impl_->current_.in_group = false;
}
void xlsx_pivots_context::set_field_sort(int type)
{
impl_->current_.fields.back().sort = type + 1;
}
void xlsx_pivots_context::start_field_reference()
{
Impl::_reference ref;
impl_->current_.fields.back().references.push_back(ref);
}
void xlsx_pivots_context::end_field_reference()
{
}
void xlsx_pivots_context::set_field_ref_name(std::wstring name)
{
impl_->current_.fields.back().references.back().name = name;
for (size_t i = 0; i < impl_->current_.fields.size(); i++)
{
if (impl_->current_.fields[i].name == name)
{
impl_->current_.fields[i].used_in_referenes = true;
}
}
}
void xlsx_pivots_context::set_field_ref_type (int type)
{
impl_->current_.fields.back().references.back().type = type;
}
void xlsx_pivots_context::set_field_ref_member_name(std::wstring name)
{
impl_->current_.fields.back().references.back().member_name = name;
}
void xlsx_pivots_context::set_field_ref_member_type(int type)
{
impl_->current_.fields.back().references.back().member_type = type;
}
void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
{
if (index < 0)
@ -1131,14 +1470,20 @@ void xlsx_pivots_context::add_field_cache(int index, std::wstring value)
}
}
impl_->current_.fields.back().caches.push_back(Impl::_field_value(value, node_name));
if (impl_->current_.in_group)
{
impl_->current_.fields.back().groups.back().caches.push_back(impl_->current_.fields.back().caches.back());
}
}
void xlsx_pivots_context::end_field()
{
if (impl_->current_.fields.back().name.empty())
{
impl_->current_.fields_count--;
impl_->current_.fields.pop_back();
}
//if (impl_->current_.fields.back().name.empty())
//{
// impl_->current_.fields_count--;
// impl_->current_.fields.pop_back();
//}
}
void xlsx_pivots_context::set_source_range(std::wstring table_name, std::wstring ref)
{

View File

@ -51,6 +51,7 @@ public:
void start_field ();
void set_field_name (std::wstring name);
void set_field_display (std::wstring name);
void set_field_type (int type, int hierarchy);
void set_field_function (int type);
void set_field_user_function (std::wstring f);
@ -59,9 +60,22 @@ public:
void set_field_show_empty (bool val);
void set_field_data_layout (bool val);
void set_field_sort (int type);
void set_repeat_item_labels(bool val);
void set_field_groups (int type);
void set_field_groups_source(std::wstring name);
void set_repeat_item_labels(bool val);
void start_field_group();
void set_field_group_name (std::wstring name);
void end_field_group();
void start_field_reference();
void set_field_ref_name(std::wstring name);
void set_field_ref_type (int type);
void set_field_ref_member_name(std::wstring name);
void set_field_ref_member_type(int type);
void end_field_reference();
void end_field();
int get_count();
@ -73,6 +87,7 @@ public:
void add_button_header(std::wstring ref);
void set_identify_categories(bool val);
void set_ignore_empty_rows(bool val);
void set_drill(bool val);
void set_source_range(std::wstring table_name, std::wstring ref);
@ -98,7 +113,6 @@ public:
private:
class Impl;
_CP_PTR(Impl) impl_;
};
}

View File

@ -123,6 +123,9 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
if (table_identify_categories_)
Context.get_pivots_context().set_identify_categories(table_identify_categories_->get());
if (table_ignore_empty_rows_)
Context.get_pivots_context().set_ignore_empty_rows(table_ignore_empty_rows_->get());
if (table_drill_down_ondouble_click_)
Context.get_pivots_context().set_drill(table_drill_down_ondouble_click_->get());
@ -155,6 +158,7 @@ void table_data_pilot_field::add_attributes( const xml::attributes_wc_ptr & Attr
CP_APPLY_ATTR(L"loext:ignore-selected-page" , loext_ignore_selected_page_);
CP_APPLY_ATTR(L"table:selected-page" , table_selected_page_);
CP_APPLY_ATTR(L"table:is-data-layout-field" , table_is_data_layout_field_);
CP_APPLY_ATTR(L"tableooo:display-name" , table_display_name_);
}
void table_data_pilot_field::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
@ -175,6 +179,9 @@ void table_data_pilot_field::xlsx_convert(oox::xlsx_conversion_context & Context
Context.get_pivots_context().set_field_name(table_source_field_name_.get_value_or(L""));
if (table_display_name_)
Context.get_pivots_context().set_field_display(*table_display_name_);
if (table_is_data_layout_field_)
Context.get_pivots_context().set_field_data_layout(table_is_data_layout_field_->get());
@ -217,7 +224,24 @@ void table_data_pilot_field_reference::add_attributes( const xml::attributes_wc_
void table_data_pilot_field_reference::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_pivots_context().start_field_reference();
if (table_field_name_)
{
Context.get_pivots_context().set_field_ref_name(*table_field_name_);
}
if (table_type_)
{
Context.get_pivots_context().set_field_ref_type(table_type_->get_type());
}
if (table_member_name_)
{
Context.get_pivots_context().set_field_ref_member_name(*table_member_name_);
}
if (table_member_type_)
{
Context.get_pivots_context().set_field_ref_member_type(table_member_type_->get_type());
}
Context.get_pivots_context().end_field_reference();
}
//-------------------------------------------------------------------------------------------------
const wchar_t * table_database_source_table::ns = L"table";
@ -405,6 +429,8 @@ void table_data_pilot_groups::xlsx_convert(oox::xlsx_conversion_context & Contex
{
if (table_grouped_by_)
Context.get_pivots_context().set_field_groups(table_grouped_by_->get_type());
else
Context.get_pivots_context().set_field_groups(7);
if (table_source_field_name_)
Context.get_pivots_context().set_field_groups_source(*table_source_field_name_);
@ -429,10 +455,16 @@ void table_data_pilot_group::add_child_element( xml::sax * Reader, const std::ws
}
void table_data_pilot_group::xlsx_convert(oox::xlsx_conversion_context & Context)
{
for (size_t i = 0; i < content_.size(); i++)
Context.get_pivots_context().start_field_group();
if (table_name_)
Context.get_pivots_context().set_field_group_name (*table_name_);
for (size_t i = 0; i < content_.size(); i++)
{
content_[i]->xlsx_convert(Context);
}
Context.get_pivots_context().end_field_group();
}
//-------------------------------------------------------------------------------------------------
const wchar_t * table_data_pilot_members::ns = L"table";
@ -470,12 +502,12 @@ const wchar_t * table_data_pilot_group_member::name = L"data-pilot-group-member"
void table_data_pilot_group_member::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
CP_APPLY_ATTR(L"table:name", table_name_);
CP_APPLY_ATTR(L"table:name", table_name_);
}
void table_data_pilot_group_member::xlsx_convert(oox::xlsx_conversion_context & Context)
{
Context.get_pivots_context().add_field_cache(-1, table_name_.get_value_or(L""));
}
//-------------------------------------------------------------------------------------------------
const wchar_t * table_data_pilot_subtotals::ns = L"table";

View File

@ -130,6 +130,7 @@ public:
_CP_OPT(odf_types::Bool) loext_ignore_selected_page_;
_CP_OPT(std::wstring) table_selected_page_;
_CP_OPT(odf_types::Bool) table_is_data_layout_field_;
_CP_OPT(std::wstring) table_display_name_;
office_element_ptr reference_;
office_element_ptr level_;

View File

@ -108,37 +108,37 @@ BaseObjectPtr SERIESDATA::clone()
// SERIESDATA = Dimensions 3(SIIndex *(Number / BoolErr / Blank / Label))
const bool SERIESDATA::loadContent(BinProcessor& proc)
{
if(!proc.optional<Dimensions>())
{
return false;
}
if (elements_.size() > 0)
bool result = false;
if(proc.optional<Dimensions>())
{
m_Dimensions = elements_.back();
elements_.pop_back();
result = true;
}
int count = proc.repeated<Parenthesis_SERIESDATA_1>(3, 3);
int count1= elements_.size();
while(count1 > 0)
if (count > 0)
{
if ("SIIndex" == elements_.front()->getClassName())
result = true;
int count1= elements_.size();
while(count1 > 0)
{
m_arSIIndex.push_back(elements_.front()); count--;
if ("SIIndex" == elements_.front()->getClassName())
{
m_arSIIndex.push_back(elements_.front()); count--;
}
else
{
SIIndex * si_in = dynamic_cast<SIIndex *>(m_arSIIndex.back().get());
if (si_in)
si_in->m_arData.push_back(elements_.front());
}
elements_.pop_front(); count1--;
}
else
{
SIIndex * si_in = dynamic_cast<SIIndex *>(m_arSIIndex.back().get());
if (si_in)
si_in->m_arData.push_back(elements_.front());
}
elements_.pop_front(); count1--;
}
return true;
return result;
}
} // namespace XLS

View File

@ -1237,6 +1237,7 @@
EXECUTABLE_PREFIX = lib;
GCC_ENABLE_CPP_EXCEPTIONS = YES;
GCC_ENABLE_CPP_RTTI = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
UNICODE,
_UNICODE,

View File

@ -63,7 +63,9 @@
#include <sys/utime.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
typedef __int64 INT64;

View File

@ -68,7 +68,9 @@
#include <sys/utime.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
#define strcasecmp stricmp
#define strncasecmp strnicmp
typedef __int64 INT64;

View File

@ -113,7 +113,9 @@ static dcr_stream_ops dcr_stream_fileops = {
#include <sys/utime.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
typedef __int64 INT64;

View File

@ -599,6 +599,8 @@ namespace NSDoctRenderer
bool ExecuteScript(const std::string& strScript, const std::wstring& sCachePath, std::wstring& strError, std::wstring& strReturnParams)
{
LOGGER_SPEED_START
bool bIsBreak = false;
v8::Isolate* isolate = CV8Worker::getInitializer()->CreateNew();
if (true)
@ -619,6 +621,8 @@ namespace NSDoctRenderer
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, strScript.c_str());
v8::Local<v8::Script> script;
LOGGER_SPEED_LAP("pre_compile")
CCacheDataScript oCachedScript(sCachePath);
if (sCachePath.empty())
script = v8::Script::Compile(source);
@ -627,6 +631,8 @@ namespace NSDoctRenderer
script = oCachedScript.Compile(context, source);
}
LOGGER_SPEED_LAP("compile")
// COMPILE
if (try_catch.HasCaught())
{
@ -658,6 +664,8 @@ namespace NSDoctRenderer
}
}
LOGGER_SPEED_LAP("run")
if (!bIsBreak && m_oParams.m_bIsRetina)
{
v8::Local<v8::String> sourceParams = v8::String::NewFromUtf8(isolate,
@ -761,6 +769,8 @@ namespace NSDoctRenderer
}
}
LOGGER_SPEED_LAP("open")
// CHANGES
if (!bIsBreak)
{
@ -823,6 +833,8 @@ namespace NSDoctRenderer
}
}
LOGGER_SPEED_LAP("changes")
bool bIsMailMerge = false;
if (!m_oParams.m_strMailMergeDatabasePath.empty() &&
m_oParams.m_nMailMergeIndexEnd >= m_oParams.m_nMailMergeIndexStart &&
@ -997,6 +1009,8 @@ namespace NSDoctRenderer
{
bIsBreak = Doct_renderer_SaveFile(&m_oParams, pNative, isolate, global_js, args, try_catch, strError);
}
LOGGER_SPEED_LAP("save")
}
isolate->Dispose();

View File

@ -269,7 +269,7 @@ enum {
/*------------------------------------------------------------------------*
* snprintf() renamed in MSVC *
*------------------------------------------------------------------------*/
#ifdef _MSC_VER
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif

View File

@ -129,7 +129,9 @@ int isnan (double d) {
#if defined(_MSC_VER)
#define mkdir(p,m) _mkdir(p)
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#if _MSC_VER < 1500
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#endif

View File

@ -127,7 +127,9 @@ static int isnan (double d) {
#if defined(_MSC_VER)
#define mkdir(p,m) _mkdir(p)
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#if _MSC_VER < 1500
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#endif

View File

@ -43,7 +43,9 @@ char *strerror(int errnum);
Macro'ed inexistant funtion names
*/
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#define perror(_t) MessageBox(NULL, _T("_t"), _T("Error/Warning"), MB_OK)