Commit b2184f71 authored by ElenaSubbotina's avatar ElenaSubbotina

fix bug after testing

parent 3a10eabf
...@@ -77,7 +77,7 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f ...@@ -77,7 +77,7 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
SXPair *pair = dynamic_cast<SXPair*>(global_info->arPivotSxNames[sxIndex].pair[0].get()); SXPair *pair = dynamic_cast<SXPair*>(global_info->arPivotSxNames[sxIndex].pair[0].get());
if (pair) if (pair)
{ {
std::map<int, BaseObjectPtr>::iterator pFind = global_info->mapPivotCache.find(global_info->idPivotCache); std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info->mapPivotCache.find(global_info->idPivotCache);
if (pFind != global_info->mapPivotCache.end()) if (pFind != global_info->mapPivotCache.end())
{ {
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get()); PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
......
...@@ -98,7 +98,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm) ...@@ -98,7 +98,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get()); SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get());
if (!streamId) return 0; if (!streamId) return 0;
std::map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm); std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm);
if (pFind == global_info_->mapPivotCache.end()) return 0; if (pFind == global_info_->mapPivotCache.end()) return 0;
global_info_->idPivotCache = streamId->idStm; global_info_->idPivotCache = streamId->idStm;
...@@ -124,13 +124,15 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm) ...@@ -124,13 +124,15 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
{ {
CP_XML_ATTR(L"r:id", L"rId1" ); CP_XML_ATTR(L"r:id", L"rId1" );
} }
else
{
CP_XML_ATTR(L"saveData", 0);
}
CP_XML_ATTR(L"enableRefresh", 1); CP_XML_ATTR(L"enableRefresh", 1);
CP_XML_ATTR(L"refreshedBy", db->rgb.value()); CP_XML_ATTR(L"refreshedBy", db->rgb.value());
CP_XML_ATTR(L"refreshedDate", db_ex->numDate.data.value); CP_XML_ATTR(L"refreshedDate", db_ex->numDate.data.value);
CP_XML_ATTR(L"recordCount", db->crdbdb); CP_XML_ATTR(L"recordCount", db->crdbdb);
//createdVersion="1" //upgradeOnRefresh="1"
//refreshedVersion="2"
//upgradeOnRefresh="1">
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get()); SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
if (src) if (src)
{ {
...@@ -167,7 +169,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm) ...@@ -167,7 +169,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
} }
} }
} }
return 0; return global_info_->idPivotCache;
} }
...@@ -176,7 +178,7 @@ int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm) ...@@ -176,7 +178,7 @@ int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm)
SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get()); SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get());
if (!streamId) return 0; if (!streamId) return 0;
std::map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm); std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm);
if (pFind == global_info_->mapPivotCache.end()) return 0; if (pFind == global_info_->mapPivotCache.end()) return 0;
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get()); PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
......
...@@ -99,7 +99,7 @@ int PIVOTVD::serialize(std::wostream & strm) ...@@ -99,7 +99,7 @@ int PIVOTVD::serialize(std::wostream & strm)
if (vd_ex->ifmt > 0) if (vd_ex->ifmt > 0)
{ {
CP_XML_ATTR(L"numFmtId", vd_ex->ifmt); CP_XML_ATTR(L"numFmtId", vd_ex->ifmt != 44 ? vd_ex->ifmt : 0);
} }
if (vd->stName.value().empty() == false) if (vd->stName.value().empty() == false)
......
...@@ -49,7 +49,7 @@ namespace XLS ...@@ -49,7 +49,7 @@ namespace XLS
PIVOTVIEW::PIVOTVIEW() PIVOTVIEW::PIVOTVIEW()
{ {
indexCache = -1; index= -1;
} }
PIVOTVIEW::~PIVOTVIEW() PIVOTVIEW::~PIVOTVIEW()
...@@ -64,6 +64,8 @@ BaseObjectPtr PIVOTVIEW::clone() ...@@ -64,6 +64,8 @@ BaseObjectPtr PIVOTVIEW::clone()
// PIVOTVIEW = PIVOTCORE [PIVOTFRT] // PIVOTVIEW = PIVOTCORE [PIVOTFRT]
const bool PIVOTVIEW::loadContent(BinProcessor& proc) const bool PIVOTVIEW::loadContent(BinProcessor& proc)
{ {
global_info_ = proc.getGlobalWorkbookInfo();
if(!proc.mandatory<PIVOTCORE>()) if(!proc.mandatory<PIVOTCORE>())
{ {
return false; return false;
...@@ -100,7 +102,12 @@ int PIVOTVIEW::serialize(std::wostream & strm) ...@@ -100,7 +102,12 @@ int PIVOTVIEW::serialize(std::wostream & strm)
PIVOTADDL* addls = frt ? dynamic_cast<PIVOTADDL*>(frt->m_PIVOTADDL.get()) : NULL; PIVOTADDL* addls = frt ? dynamic_cast<PIVOTADDL*>(frt->m_PIVOTADDL.get()) : NULL;
indexCache = view->iCache; std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.begin();
for (int i = 0; i < view->iCache; i++)
pFind++;
index = pFind->first;
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
...@@ -137,7 +144,7 @@ int PIVOTVIEW::serialize(std::wostream & strm) ...@@ -137,7 +144,7 @@ int PIVOTVIEW::serialize(std::wostream & strm)
CP_XML_ATTR(L"firstHeaderRow", view->rwFirstHead - view->ref.rowFirst ); CP_XML_ATTR(L"firstHeaderRow", view->rwFirstHead - view->ref.rowFirst );
CP_XML_ATTR(L"firstDataRow", view->rwFirstData - view->ref.rowFirst); CP_XML_ATTR(L"firstDataRow", view->rwFirstData - view->ref.rowFirst);
CP_XML_ATTR(L"firstDataCol", view->colFirstData - view->ref.columnFirst); CP_XML_ATTR(L"firstDataCol", view->colFirstData - view->ref.columnFirst);
CP_XML_ATTR(L"rowPageCount", 1); CP_XML_ATTR(L"rowPageCount", view->cDimPg > 0 ? view->cDimPg : 1);
CP_XML_ATTR(L"colPageCount", 1); CP_XML_ATTR(L"colPageCount", 1);
} }
CP_XML_NODE(L"pivotFields") CP_XML_NODE(L"pivotFields")
...@@ -215,7 +222,9 @@ int PIVOTVIEW::serialize(std::wostream & strm) ...@@ -215,7 +222,9 @@ int PIVOTVIEW::serialize(std::wostream & strm)
SXAddl_SXCView_SXDTableStyleClient* table_style = dynamic_cast<SXAddl_SXCView_SXDTableStyleClient*>(addls->m_SXAddl_SXCView_SXDTableStyleClient.get()); SXAddl_SXCView_SXDTableStyleClient* table_style = dynamic_cast<SXAddl_SXCView_SXDTableStyleClient*>(addls->m_SXAddl_SXCView_SXDTableStyleClient.get());
CP_XML_NODE(L"pivotTableStyleInfo") CP_XML_NODE(L"pivotTableStyleInfo")
{ {
CP_XML_ATTR(L"name", table_style->stName.value()); if (!table_style->stName.value().empty())
CP_XML_ATTR(L"name", table_style->stName.value());
CP_XML_ATTR(L"showRowHeaders", table_style->fRowHeaders); CP_XML_ATTR(L"showRowHeaders", table_style->fRowHeaders);
CP_XML_ATTR(L"showColHeaders", table_style->fColumnHeaders); CP_XML_ATTR(L"showColHeaders", table_style->fColumnHeaders);
CP_XML_ATTR(L"showRowStripes", table_style->fRowStrips); CP_XML_ATTR(L"showRowStripes", table_style->fRowStrips);
......
...@@ -54,8 +54,10 @@ public: ...@@ -54,8 +54,10 @@ public:
BaseObjectPtr m_PIVOTCORE; BaseObjectPtr m_PIVOTCORE;
BaseObjectPtr m_PIVOTFRT; BaseObjectPtr m_PIVOTFRT;
//---------------------------------- //----------------------------------
int indexCache; int index;
std::wstring name; std::wstring name;
GlobalWorkbookInfoPtr global_info_;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <boost/smart_ptr/shared_array.hpp> #include <boost/smart_ptr/shared_array.hpp>
#include <vector> #include <vector>
#include <map> #include <map>
#include <unordered_map>
#include "Biff_structures/BorderFillInfo.h" #include "Biff_structures/BorderFillInfo.h"
...@@ -106,7 +107,8 @@ public: ...@@ -106,7 +107,8 @@ public:
const static unsigned int initial_AXES_id = 0x2000000; const static unsigned int initial_AXES_id = 0x2000000;
short idPivotCache; short idPivotCache;
std::map<int, BaseObjectPtr> mapPivotCache; std::unordered_map<int, BaseObjectPtr> mapPivotCache;
std::vector<bool> arPivotCacheFields; std::vector<bool> arPivotCacheFields;
std::vector<bool> arPivotCacheFieldShortSize; std::vector<bool> arPivotCacheFieldShortSize;
......
...@@ -1924,7 +1924,8 @@ void XlsConverter::convert(XLS::PIVOTVIEW * pivot_view) ...@@ -1924,7 +1924,8 @@ void XlsConverter::convert(XLS::PIVOTVIEW * pivot_view)
pivot_view->serialize(strm); pivot_view->serialize(strm);
int index_view = xlsx_context->get_pivots_context().add_view(strm.str(), pivot_view->indexCache);
int index_view = xlsx_context->get_pivots_context().add_view(strm.str(), pivot_view->index);
if (index_view > 0) if (index_view > 0)
{ {
...@@ -1940,8 +1941,8 @@ void XlsConverter::convert(XLS::PIVOTCACHEDEFINITION * pivot_cached) ...@@ -1940,8 +1941,8 @@ void XlsConverter::convert(XLS::PIVOTCACHEDEFINITION * pivot_cached)
std::wstringstream strmD, strmR; std::wstringstream strmD, strmR;
pivot_cached->serialize_definitions(strmD); int index = pivot_cached->serialize_definitions(strmD);
pivot_cached->serialize_records(strmR); pivot_cached->serialize_records(strmR);
xlsx_context->get_pivots_context().add_cache(strmD.str(), strmR.str()); xlsx_context->get_pivots_context().add_cache(strmD.str(), strmR.str(), index);
} }
\ No newline at end of file
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <boost/make_shared.hpp> #include <boost/make_shared.hpp>
#include <simple_xml_writer.h> #include <simple_xml_writer.h>
#include <map>
namespace oox { namespace oox {
class xlsx_pivots_context::Impl class xlsx_pivots_context::Impl
...@@ -55,16 +57,20 @@ public: ...@@ -55,16 +57,20 @@ public:
std::vector<_pivot_cache> caches_; std::vector<_pivot_cache> caches_;
std::vector<_pivot_view> views_; std::vector<_pivot_view> views_;
std::wstring connections_; std::wstring connections_;
std::map<int, int> mapIndex_;
}; };
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl()) xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
{ {
} }
void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records) void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records, int indexCache)
{ {
Impl::_pivot_cache c = {definitions, records}; Impl::_pivot_cache c = {definitions, records};
impl_->caches_.push_back(c); impl_->caches_.push_back(c);
impl_->mapIndex_.insert(std::make_pair(indexCache, impl_->caches_.size()));
} }
int xlsx_pivots_context::get_cache_count() int xlsx_pivots_context::get_cache_count()
...@@ -86,11 +92,11 @@ void xlsx_pivots_context::dump_rels_cache(int index, rels & Rels) ...@@ -86,11 +92,11 @@ void xlsx_pivots_context::dump_rels_cache(int index, rels & Rels)
} }
void xlsx_pivots_context::dump_rels_view(int index, rels & Rels) void xlsx_pivots_context::dump_rels_view(int index, rels & Rels)
{ {
if (impl_->views_[index].indexCache_ >= 0) if (impl_->views_[index].indexCache_ > 0)
{ {
Rels.add(relationship(L"rId1", Rels.add(relationship(L"rId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
L"../pivotCache/pivotCacheDefinition" + std::to_wstring(impl_->views_[index].indexCache_ + 1) + L".xml", L"")); L"../pivotCache/pivotCacheDefinition" + std::to_wstring( impl_->views_[index].indexCache_ ) + L".xml", L""));
} }
} }
void xlsx_pivots_context::write_cache_definitions_to(int index, std::wostream & strm) void xlsx_pivots_context::write_cache_definitions_to(int index, std::wostream & strm)
...@@ -122,7 +128,9 @@ int xlsx_pivots_context::add_view(std::wstring table_view, int indexCache) ...@@ -122,7 +128,9 @@ int xlsx_pivots_context::add_view(std::wstring table_view, int indexCache)
{ {
if (table_view.empty()) return 0; if (table_view.empty()) return 0;
Impl::_pivot_view v = {table_view, indexCache}; std::map<int, int>::iterator pFind = impl_->mapIndex_.find(indexCache);
Impl::_pivot_view v = {table_view, pFind->second};
impl_->views_.push_back(v); impl_->views_.push_back(v);
return (int)impl_->views_.size(); return (int)impl_->views_.size();
......
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
int add_view(std::wstring table_view, int indexCache); int add_view(std::wstring table_view, int indexCache);
int get_view_count(); int get_view_count();
void add_cache(std::wstring definitions, std::wstring records); void add_cache(std::wstring definitions, std::wstring records, int indexCache);
int get_cache_count(); int get_cache_count();
void write_cache_definitions_to (int index, std::wostream & strm); void write_cache_definitions_to (int index, std::wostream & strm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment