Commit 4b260663 authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat pivots .. fix after testing

parent 8742163d
......@@ -501,6 +501,8 @@ public:
_UINT32 dwItem;
};
//class SXAddl_SXCView_SXDVer10Info : public SXAddl {};
//class SXAddl_SXCView_SXDVer12Info : public SXAddl {};
//class SXAddl_SXCCacheItem_SXDItmMpMapCount : public SXAddl {};
//class SXAddl_SXCCacheItem_SXDItmMpropMap : public SXAddl {};
......@@ -601,8 +603,6 @@ public:
// SXAddl_SXCView_SXDSXPIIvmb(CFRecord& record);
//};
//class SXAddl_SXCView_SXDVer10Info : public SXAddl {};
//class SXAddl_SXCView_SXDVer12Info : public SXAddl {};
//class SXAddl_SXCView_SXDVerUpdInv : public SXAddl {};
} // namespace XLS
......
......@@ -53,7 +53,10 @@ BaseObjectPtr SXStreamID::clone()
void SXStreamID::readFields(CFRecord& record)
{
GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo();
record >> idStm;
global_info->arPivotCacheStream.push_back(idStm);
}
} // namespace XLS
......
......@@ -73,13 +73,14 @@ int SXVI::serialize(std::wostream & strm)
{
CP_XML_NODE(L"item")
{
if (fHidden) CP_XML_ATTR(L"h", 1);
if (fMissing) CP_XML_ATTR(L"m", 1);
if (fHideDetail)CP_XML_ATTR(L"sd", 0);
if (fFormula) CP_XML_ATTR(L"f", 1);
if (itmType == 0)
{
if (fHidden) CP_XML_ATTR(L"h", 1);
CP_XML_ATTR(L"x", iCache);
}
switch(itmType)
......
......@@ -77,8 +77,8 @@ void PtgSxName::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
SXPair *pair = dynamic_cast<SXPair*>(global_info->arPivotSxNames[sxIndex].pair[0].get());
if (pair)
{
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info->mapPivotCache.find(global_info->idPivotCache);
if (pFind != global_info->mapPivotCache.end())
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info->mapPivotCacheStream.find(global_info->idPivotCache);
if (pFind != global_info->mapPivotCacheStream.end())
{
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (pivot_cache)
......
......@@ -254,8 +254,10 @@ int FDB::serialize(std::wostream & strm, bool bSql)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 1);
}
else if (bDate & bString)
else if ((bDate & bString) || (bEmpty & bInteger & bString))
{
if (bEmpty && bInteger)
bNumber = true;
CP_XML_ATTR(L"containsMixedTypes", 1);
}
else if (!bEmpty && !bString && !bBool)
......
......@@ -98,11 +98,13 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get());
if (!streamId) return 0;
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm);
if (pFind == global_info_->mapPivotCache.end()) return 0;
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCacheStream.find(streamId->idStm);
if (pFind == global_info_->mapPivotCacheStream.end()) return 0;
global_info_->idPivotCache = streamId->idStm;
global_info_->mapPivotCacheIndex.insert(std::make_pair(global_info_->idPivotCache, global_info_->mapPivotCacheIndex.size()));
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
......@@ -169,7 +171,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
}
}
}
return global_info_->idPivotCache;
return 0;
}
......@@ -178,8 +180,8 @@ int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm)
SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get());
if (!streamId) return 0;
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm);
if (pFind == global_info_->mapPivotCache.end()) return 0;
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCacheStream.find(streamId->idStm);
if (pFind == global_info_->mapPivotCacheStream.end()) return 0;
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
......
......@@ -31,9 +31,10 @@
*/
#include "PIVOTEX.h"
#include <Logic/Biff_records/SXEx.h>
#include <Logic/Biff_unions/PIVOTSELECT.h>
#include <Logic/Biff_unions/PIVOTFORMAT.h>
#include "PIVOTSELECT.h"
#include "PIVOTFORMAT.h"
#include "../Biff_records/SXEx.h"
namespace XLS
{
......@@ -54,7 +55,6 @@ BaseObjectPtr PIVOTEX::clone()
return BaseObjectPtr(new PIVOTEX(*this));
}
// PIVOTEX = SXEx *PIVOTSELECT *PIVOTFORMAT
const bool PIVOTEX::loadContent(BinProcessor& proc)
{
......@@ -62,9 +62,21 @@ const bool PIVOTEX::loadContent(BinProcessor& proc)
{
return false;
}
m_SXEx = elements_.back();
elements_.pop_back();
int count = 0;
count = proc.repeated<PIVOTSELECT>(0, 0);
while(count--)
{
m_arPIVOTSELECT.push_back(elements_.front()); elements_.pop_front();
}
count = proc.repeated<PIVOTFORMAT>(0, 0);
while(count--)
{
m_arPIVOTFORMAT.push_back(elements_.front()); elements_.pop_front();
}
return true;
}
......
......@@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of PIVOTEX union of records
class PIVOTEX: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(PIVOTEX)
......@@ -49,7 +47,12 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typePIVOTEX;
static const ElementType type = typePIVOTEX;
BaseObjectPtr m_SXEx;
std::vector<BaseObjectPtr> m_arPIVOTSELECT;
std::vector<BaseObjectPtr> m_arPIVOTFORMAT;
};
} // namespace XLS
......
......@@ -31,9 +31,10 @@
*/
#include "PIVOTFORMAT.h"
#include <Logic/Biff_records/SxFormat.h>
#include <Logic/Biff_unions/PIVOTRULE.h>
#include <Logic/Biff_records/SxDXF.h>
#include "PIVOTRULE.h"
#include "../Biff_records/SxFormat.h"
#include "../Biff_records/SxDXF.h"
namespace XLS
{
......@@ -54,7 +55,6 @@ BaseObjectPtr PIVOTFORMAT::clone()
return BaseObjectPtr(new PIVOTFORMAT(*this));
}
// PIVOTFORMAT = SxFormat PIVOTRULE [SxDXF]
const bool PIVOTFORMAT::loadContent(BinProcessor& proc)
{
......@@ -62,11 +62,18 @@ const bool PIVOTFORMAT::loadContent(BinProcessor& proc)
{
return false;
}
m_SxFormat = elements_.back();
elements_.pop_back();
if (proc.mandatory<PIVOTRULE>())
{
m_PIVOTRULE = elements_.back();
elements_.pop_back();
}
if (proc.optional<SxDXF>())
{
m_SxDXF = elements_.back();
elements_.pop_back();
}
return true;
......
......@@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of PIVOTFORMAT union of records
class PIVOTFORMAT: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(PIVOTFORMAT)
......@@ -49,7 +47,11 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typePIVOTFORMAT;
static const ElementType type = typePIVOTFORMAT;
BaseObjectPtr m_SxFormat;
BaseObjectPtr m_PIVOTRULE;
BaseObjectPtr m_SxDXF;
};
} // namespace XLS
......
......@@ -39,17 +39,22 @@
#include "PIVOTLI.h"
#include "PIVOTEX.h"
#include "PIVOTADDL.h"
#include "PIVOTFORMAT.h"
#include "../Biff_records/SXDI.h"
#include "../Biff_records/SxView.h"
#include "../Biff_records/SXAddl.h"
#include "../Biff_records/SXEx.h"
#include "../Biff_records/SxFormat.h"
#include "../Biff_records/SxDXF.h"
namespace XLS
{
PIVOTVIEW::PIVOTVIEW()
{
index= -1;
indexStream = -1;
indexCache = -1;
}
PIVOTVIEW::~PIVOTVIEW()
......@@ -99,15 +104,19 @@ int PIVOTVIEW::serialize(std::wostream & strm)
if (!view) return 0;
PIVOTFRT* frt = dynamic_cast<PIVOTFRT*>(m_PIVOTFRT.get());
PIVOTEX* pivot_ex = dynamic_cast<PIVOTEX*>(core->m_PIVOTEX.get());
PIVOTADDL* addls = frt ? dynamic_cast<PIVOTADDL*>(frt->m_PIVOTADDL.get()) : NULL;
PIVOTFRT9* frt9 = frt ? dynamic_cast<PIVOTADDL*>(frt->m_PIVOTFRT9.get()) : NULL;
std::unordered_map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.begin();
for (int i = 0; i < view->iCache; i++)
pFind++;
SXEx *view_ex = pivot_ex ? dynamic_cast<SXEx*>(pivot_ex->m_SXEx.get()) : NULL;
SXViewEx9 *view_ex9 = pivot_ex ? dynamic_cast<SXEx*>(frt9->m_SXViewEx9.get()) : NULL;
index = pFind->first;
indexStream = global_info_->arPivotCacheStream[view->iCache];
std::map<int, int>::iterator pFindIndex = global_info_->mapPivotCacheIndex.find(indexStream);
indexCache = pFindIndex->second;
CP_XML_WRITER(strm)
{
......@@ -116,8 +125,11 @@ int PIVOTVIEW::serialize(std::wostream & strm)
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"name", view->stTable.value());
CP_XML_ATTR(L"cacheId", view->iCache);
CP_XML_ATTR(L"dataOnRows", view->sxaxis4Data.bRw);
CP_XML_ATTR(L"cacheId", indexCache);
if (view->sxaxis4Data.bRw)
{
CP_XML_ATTR(L"dataOnRows", view->sxaxis4Data.bRw);
}
CP_XML_ATTR(L"applyNumberFormats", view->fAtrNum);
CP_XML_ATTR(L"applyBorderFormats", view->fAtrBdr);
CP_XML_ATTR(L"applyFontFormats", view->fAtrFnt);
......@@ -128,15 +140,30 @@ int PIVOTVIEW::serialize(std::wostream & strm)
{
CP_XML_ATTR(L"dataCaption", view->stData.value());
}
CP_XML_ATTR(L"asteriskTotals", 1);
//CP_XML_ATTR(L"asteriskTotals", 1);
CP_XML_ATTR(L"showMemberPropertyTips", 0);
CP_XML_ATTR(L"useAutoFormatting", view->fAutoFormat);
CP_XML_ATTR(L"autoFormatId", view->itblAutoFmt);
CP_XML_ATTR(L"itemPrintTitles", 1);
if (view_ex9)
{
CP_XML_ATTR(L"itemPrintTitles", view_ex9->fPrintTitles);
CP_XML_ATTR(L"outline", view_ex9->fLineMode);
CP_XML_ATTR(L"outlineData", view_ex9->fLineMode);
}
CP_XML_ATTR(L"indent", 0);
CP_XML_ATTR(L"compact", 0);
CP_XML_ATTR(L"compactData", 0);
CP_XML_ATTR(L"gridDropZones", 1);
//CP_XML_ATTR(L"gridDropZones", 1); //makc1985_1 (2).xls
if (view_ex)
{
if (!view_ex->fEnableWizard) CP_XML_ATTR(L"enableWizard", 0);
if (!view_ex->fEnableDrilldown) CP_XML_ATTR(L"enableDrill", 0);
//CP_XML_ATTR(L"disableFieldList", !view_ex->fEnableFieldDialog);//enableFieldPropert
if (!view_ex->stError.value().empty())
CP_XML_ATTR(L"errorCaption", view_ex->stError.value());
}
CP_XML_NODE(L"location")
{
......@@ -144,8 +171,12 @@ int PIVOTVIEW::serialize(std::wostream & strm)
CP_XML_ATTR(L"firstHeaderRow", view->rwFirstHead - 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"rowPageCount", view->cDimPg > 0 ? view->cDimPg : 1);
CP_XML_ATTR(L"colPageCount", 1);
if (view->cDimPg > 0)
{
CP_XML_ATTR(L"rowPageCount", view->cDimPg);
CP_XML_ATTR(L"colPageCount", 1);
}
}
CP_XML_NODE(L"pivotFields")
{
......
......@@ -54,7 +54,8 @@ public:
BaseObjectPtr m_PIVOTCORE;
BaseObjectPtr m_PIVOTFRT;
//----------------------------------
int index;
int indexStream;
int indexCache;
std::wstring name;
GlobalWorkbookInfoPtr global_info_;
......
......@@ -107,7 +107,9 @@ public:
const static unsigned int initial_AXES_id = 0x2000000;
short idPivotCache;
std::unordered_map<int, BaseObjectPtr> mapPivotCache;
std::map<int, int> mapPivotCacheIndex; //streamIdCache, write index order
std::unordered_map<int, BaseObjectPtr> mapPivotCacheStream;//streamIdCache, object
std::vector<int> arPivotCacheStream; //order streamIdCache = iCache
std::vector<bool> arPivotCacheFields;
std::vector<bool> arPivotCacheFieldShortSize;
......
......@@ -217,7 +217,7 @@ XlsConverter::XlsConverter(const std::wstring & xls_file, const std::wstring & _
{
}
xls_global_info->mapPivotCache.insert(std::make_pair(index, pivot_cache));
xls_global_info->mapPivotCacheStream.insert(std::make_pair(index, pivot_cache));
}
}
if (bMacros && cfile.storage_->isDirectory("_VBA_PROJECT_CUR"))
......@@ -1948,7 +1948,7 @@ void XlsConverter::convert(XLS::PIVOTVIEW * pivot_view)
pivot_view->serialize(strm);
int index_view = xlsx_context->get_pivots_context().add_view(strm.str(), pivot_view->index);
int index_view = xlsx_context->get_pivots_context().add_view(strm.str(), pivot_view->indexCache);
if (index_view > 0)
{
......@@ -1964,8 +1964,8 @@ void XlsConverter::convert(XLS::PIVOTCACHEDEFINITION * pivot_cached)
std::wstringstream strmD, strmR;
int index = pivot_cached->serialize_definitions(strmD);
pivot_cached->serialize_definitions(strmD);
pivot_cached->serialize_records(strmR);
xlsx_context->get_pivots_context().add_cache(strmD.str(), strmR.str(), index);
xlsx_context->get_pivots_context().add_cache(strmD.str(), strmR.str());
}
\ No newline at end of file
......@@ -57,20 +57,16 @@ public:
std::vector<_pivot_cache> caches_;
std::vector<_pivot_view> views_;
std::wstring connections_;
std::map<int, int> mapIndex_;
};
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
{
}
void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records, int indexCache)
void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records)
{
Impl::_pivot_cache c = {definitions, records};
impl_->caches_.push_back(c);
impl_->mapIndex_.insert(std::make_pair(indexCache, impl_->caches_.size()));
}
int xlsx_pivots_context::get_cache_count()
......@@ -128,9 +124,7 @@ int xlsx_pivots_context::add_view(std::wstring table_view, int indexCache)
{
if (table_view.empty()) return 0;
std::map<int, int>::iterator pFind = impl_->mapIndex_.find(indexCache);
Impl::_pivot_view v = {table_view, pFind->second};
Impl::_pivot_view v = {table_view, indexCache + 1};
impl_->views_.push_back(v);
return (int)impl_->views_.size();
......
......@@ -46,7 +46,7 @@ public:
int add_view(std::wstring table_view, int indexCache);
int get_view_count();
void add_cache(std::wstring definitions, std::wstring records, int indexCache);
void add_cache(std::wstring definitions, std::wstring records);
int get_cache_count();
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