Commit ef8e5cab authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat ...

parent 028e58ad
......@@ -54,5 +54,21 @@ void SXDtr::readFields(CFRecord& record)
record >> yr >> mon >> dom >> hr >> min >> sec;
}
int SXDtr::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"d")
{
std::wstringstream s;
s << yr << L"-" << mon << L"-" << dom << L"T" << hr << L":" << min << L":" << sec;
CP_XML_ATTR(L"v", s.str());
}
}
return 0;
}
} // namespace XLS
......@@ -32,7 +32,6 @@
#pragma once
#include "BiffRecord.h"
//#include "../Biff_structures/CellRangeRef.h"
namespace XLS
{
......@@ -49,6 +48,8 @@ public:
void readFields(CFRecord& record);
int serialize(std::wostream & strm);
static const ElementType type = typeSXDtr;
unsigned short yr;
......
......@@ -39,7 +39,6 @@ SXNum::SXNum()
{
}
SXNum::~SXNum()
{
}
......@@ -54,5 +53,17 @@ void SXNum::readFields(CFRecord& record)
record >> num;
}
int SXNum::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"n")
{
CP_XML_ATTR(L"v", num.data.value);
}
}
return 0;
}
} // namespace XLS
......@@ -49,6 +49,8 @@ public:
void readFields(CFRecord& record);
int serialize(std::wostream & strm);
static const ElementType type = typeSXNum;
Xnum num;
......
......@@ -61,6 +61,17 @@ void SXString::readFields(CFRecord& record)
record >> segment;
}
}
int SXString::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"s")
{
CP_XML_ATTR(L"v", segment.value());
}
}
return 0;
}
} // namespace XLS
......@@ -49,6 +49,8 @@ public:
void readFields(CFRecord& record);
int serialize(std::wostream & strm);
static const ElementType type = typeSXString;
unsigned short cch;
......
......@@ -39,7 +39,6 @@ SxNil::SxNil()
{
}
SxNil::~SxNil()
{
}
......@@ -53,5 +52,14 @@ void SxNil::readFields(CFRecord& record)
{
}
int SxNil::serialize(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"m");
}
return 0;
}
} // namespace XLS
......@@ -48,6 +48,8 @@ public:
void readFields(CFRecord& record);
int serialize(std::wostream & strm);
static const ElementType type = typeSxNil;
};
......
......@@ -43,18 +43,15 @@ DREF::DREF()
{
}
DREF::~DREF()
{
}
BaseObjectPtr DREF::clone()
{
return BaseObjectPtr(new DREF(*this));
}
// DREF = DConName / DConBin / DConRef
const bool DREF::loadContent(BinProcessor& proc)
{
......@@ -68,8 +65,42 @@ const bool DREF::loadContent(BinProcessor& proc)
}
}
}
m_DCon = elements_.back();
elements_.pop_back();
return true;
}
int DREF::serialize(std::wostream & strm)
{
if (!m_DCon)return 0;
DConName* name = dynamic_cast<DConName*>(m_DCon.get());
DConBin* bin = dynamic_cast<DConBin*>(m_DCon.get());
DConRef* ref = dynamic_cast<DConRef*>(m_DCon.get());
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"cacheSource")
{
if (name)
{
CP_XML_ATTR(L"type", L"worksheet");
CP_XML_NODE(L"worksheetSource")
{
CP_XML_ATTR(L"name", name->stName.value());
}
}
else if(bin)
{
}
else if(ref)
{
}
}
}
return 0;
}
} // namespace XLS
......@@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of DREF union of records
class DREF: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(DREF)
......@@ -49,7 +47,11 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeDREF;
int serialize(std::wostream & stream);
static const ElementType type = typeDREF;
BaseObjectPtr m_DCon;
};
} // namespace XLS
......
......@@ -47,6 +47,10 @@ class Parenthesis_FDB: public ABNFParenthesis
{
BASE_OBJECT_DEFINE_CLASS_NAME(Parenthesis_FDB)
public:
Parenthesis_FDB(int count = 0)
{
m_count = count;
}
BaseObjectPtr clone()
{
return BaseObjectPtr(new Parenthesis_FDB(*this));
......@@ -54,7 +58,9 @@ public:
const bool loadContent(BinProcessor& proc)
{
int count = proc.repeated<SXOPER>(0, 0);
if (m_count < 1) return false;
int count = proc.repeated<SXOPER>(0, m_count);
if (!proc.optional<SXRANGE>())
{
......@@ -62,6 +68,8 @@ public:
}
return true;
};
private:
int m_count;
};
FDB::FDB()
......@@ -91,6 +99,8 @@ const bool FDB::loadContent(BinProcessor& proc)
}
m_SXFDB = elements_.back();
elements_.pop_back();
SXFDB* fdb = dynamic_cast<SXFDB*>(m_SXFDB.get());
if(proc.mandatory<SXFDBType>())
{
......@@ -103,31 +113,36 @@ const bool FDB::loadContent(BinProcessor& proc)
m_SXFMLA = elements_.back();
elements_.pop_back();
}
else if(proc.optional<Parenthesis_FDB>())
else
{
int count = elements_.size();
while(count > 0)
Parenthesis_FDB parenthesis_FDB(fdb->csxoper);
if (proc.optional(parenthesis_FDB))
{
SXOPER * oper = dynamic_cast<SXOPER*> (elements_.front().get());
if (oper)
{
m_arGRPSXOPER.push_back(elements_.front());
}
else
int count = elements_.size();
while(count > 0)
{
SXRANGE *range = dynamic_cast<SXRANGE*> (elements_.front().get());
if (range)
m_SXRANGE = elements_.front();
SXOPER * oper = dynamic_cast<SXOPER*> (elements_.front().get());
if (oper)
{
m_arGRPSXOPER.push_back(elements_.front());
}
else
{
SxIsxoper * isOper = dynamic_cast<SxIsxoper*> (elements_.front().get());
if (isOper)
m_arSxIsxoper.push_back(elements_.front());
SXRANGE *range = dynamic_cast<SXRANGE*> (elements_.front().get());
if (range)
m_SXRANGE = elements_.front();
else
{
SxIsxoper * isOper = dynamic_cast<SxIsxoper*> (elements_.front().get());
if (isOper)
m_arSxIsxoper.push_back(elements_.front());
}
}
elements_.pop_front();
count--;
}
elements_.pop_front();
count--;
}
}
......@@ -140,5 +155,98 @@ const bool FDB::loadContent(BinProcessor& proc)
return true;
}
int FDB::serialize(std::wostream & strm)
{
SXFDB* fdb = dynamic_cast<SXFDB*>(m_SXFDB.get());
SXFDBType* fdb_type = dynamic_cast<SXFDBType*>(m_SXFDBType.get());
if (!fdb || !fdb_type) return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"cacheField")
{
CP_XML_ATTR(L"name", fdb->stFieldName.value());
CP_XML_ATTR(L"numFmtId", fdb_type->wTypeSql);
switch(fdb_type->wTypeSql)//format code
{
case 0x0000:
case 0x0001:
case 0x0003:
case 0x0004:
case 0x0005:
case 0x0006:
case 0x0007:
case 0x0008:
case 0x000B:
case 0x000C:
case 0xFFF9:
case 0xFFFE:
break;
}
if(m_SXFMLA)
{
//{formula
}
//caption, databaseFields, ..
if (m_arSRCSXOPER.empty() == false)
{
CP_XML_NODE(L"sharedItems")
{
//CP_XML_ATTR(L"containsSemiMixedTypes", 0);
CP_XML_ATTR(L"containsNonDate", fdb->fNonDates);
CP_XML_ATTR(L"containsDate", fdb->fDateInField);
CP_XML_ATTR(L"containsNumber", fdb->fNumField);
CP_XML_ATTR(L"containsBlank", fdb->fTextEtcField);
//CP_XML_ATTR(L"containsString", 0);
if (fdb->fnumMinMaxValid)
{
if (fdb->fDateInField)
{
CP_XML_ATTR(L"minDate", 0); // "2007-11-18T00:00:00"
CP_XML_ATTR(L"maxDate", 0); // "2007-12-25T00:00:00"
}
else if (fdb->fNumField)
{
CP_XML_ATTR(L"minValue", 0);
CP_XML_ATTR(L"maxValue", 0);
}
}
CP_XML_ATTR(L"count", fdb->catm);
for (size_t i = 0; i < m_arSRCSXOPER.size(); i++)
{
m_arSRCSXOPER[i]->serialize(CP_XML_STREAM());
}
}
}
if (m_arGRPSXOPER.empty() == false)
{
CP_XML_NODE(L"fieldGroup")
{
if (fdb->ifdbParent > 0)
CP_XML_ATTR(L"par", fdb->ifdbParent);
if (m_SXRANGE)
m_SXRANGE->serialize(CP_XML_STREAM());
CP_XML_NODE(L"groupItems")
{
CP_XML_ATTR(L"count", m_arGRPSXOPER.size());
for (size_t i = 0; i < m_arGRPSXOPER.size(); i++)
{
m_arGRPSXOPER[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
}
return 0;
}
} // namespace XLS
......@@ -47,6 +47,8 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & strm);
static const ElementType type = typeFDB;
BaseObjectPtr m_SXFDB;
......
......@@ -36,8 +36,6 @@
namespace XLS
{
// Logical representation of GLOBALS union of records
class GLOBALS: public CompositeObject
{
BASE_OBJECT_DEFINE_CLASS_NAME(GLOBALS)
......@@ -49,7 +47,7 @@ public:
virtual const bool loadContent (BinProcessor& proc);
static const ElementType type = typeGLOBALS;
static const ElementType type = typeGLOBALS;
int serialize(std::wostream & stream);
......
......@@ -47,7 +47,6 @@ PIVOTCACHE::PIVOTCACHE()
{
}
PIVOTCACHE::~PIVOTCACHE()
{
}
......
......@@ -31,10 +31,14 @@
*/
#include "PIVOTCACHEDEFINITION.h"
#include <Logic/Biff_records/SXStreamID.h>
#include <Logic/Biff_records/SXVS.h>
#include <Logic/Biff_unions/SXSRC.h>
#include <Logic/Biff_unions/SXADDLCACHE.h>
#include "PIVOTCACHE.h"
#include "SXSRC.h"
#include "SXADDLCACHE.h"
#include "../Biff_records/SXStreamID.h"
#include "../Biff_records/SXVS.h"
#include "../Biff_records/SXDB.h"
#include "../Biff_records/SXDBEx.h"
namespace XLS
{
......@@ -59,6 +63,8 @@ BaseObjectPtr PIVOTCACHEDEFINITION::clone()
// PIVOTCACHEDEFINITION = SXStreamID SXVS [SXSRC] [SXADDLCACHE]
const bool PIVOTCACHEDEFINITION::loadContent(BinProcessor& proc)
{
global_info_ = proc.getGlobalWorkbookInfo();
if(!proc.mandatory<SXStreamID>())
{
return false;
......@@ -83,6 +89,93 @@ const bool PIVOTCACHEDEFINITION::loadContent(BinProcessor& proc)
}
return true;
}
int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
{
SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get());
if (!streamId) return 0;
std::map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm);
if (pFind == global_info_->mapPivotCache.end()) return 0;
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
SXDB* db = dynamic_cast<SXDB*>(pivot_cache->m_SXDB.get());
SXDBEx* db_ex = dynamic_cast<SXDBEx*>(pivot_cache->m_SXDBEx.get());
if (!db || !db_ex)return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheDefinition")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
if (pivot_cache->m_arDBB.empty() == false)
{
CP_XML_ATTR(L"r:id", L"rId1" );
}
CP_XML_ATTR(L"recordCount", db->crdbUsed);
CP_XML_ATTR(L"refreshedBy", db->rgb.value());
CP_XML_ATTR(L"refreshedDate", db_ex->numDate.data.value);
//createdVersion="1"
//refreshedVersion="2"
//upgradeOnRefresh="1">
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
if (src)
src->serialize(CP_XML_STREAM());
if (pivot_cache->m_arFDB.empty() == false)
{
CP_XML_NODE(L"cacheFields")
{
CP_XML_ATTR(L"count", pivot_cache->m_arFDB.size());
for (size_t i = 0; i < pivot_cache->m_arFDB.size(); i++)
{
pivot_cache->m_arFDB[i]->serialize(CP_XML_STREAM());
}
}
}
}
}
return 0;
}
int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm)
{
SXStreamID* streamId = dynamic_cast<SXStreamID*>(m_SXStreamID.get());
if (!streamId) return 0;
std::map<int, BaseObjectPtr>::iterator pFind = global_info_->mapPivotCache.find(streamId->idStm);
if (pFind == global_info_->mapPivotCache.end()) return 0;
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
if (pivot_cache->m_arDBB.empty()) return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheRecords")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"count", pivot_cache->m_arDBB.size());
for (size_t i = 0; i < pivot_cache->m_arDBB.size(); i++)
{
pivot_cache->m_arDBB[i]->serialize(CP_XML_STREAM());
}
}
}
return 0;
}
} // namespace XLS
......@@ -48,6 +48,9 @@ public:
BaseObjectPtr clone();
virtual const bool loadContent(BinProcessor& proc);
int serialize_definitions(std::wostream & stream);
int serialize_records(std::wostream & stream);
static const ElementType type = typePIVOTCACHEDEFINITION;
......@@ -55,6 +58,8 @@ public:
BaseObjectPtr m_SXVS;
BaseObjectPtr m_SXSRC;
BaseObjectPtr m_SXADDLCACHE;
GlobalWorkbookInfoPtr global_info_;
};
} // namespace XLS
......
......@@ -45,7 +45,6 @@ SXOPER::SXOPER()
{
}
SXOPER::~SXOPER()
{
}
......@@ -79,8 +78,17 @@ const bool SXOPER::loadContent(BinProcessor& proc)
else
return false;
m_element = elements_.back();
elements_.pop_back();
return true;
}
int SXOPER::serialize(std::wostream & strm)
{
if (!m_element) return 0;
m_element->serialize(strm);
return 0;
}
} // namespace XLS
......@@ -47,9 +47,11 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeSXOPER;
int serialize(std::wostream & strm);
BaseObjectPtr m_SXOPER;
static const ElementType type = typeSXOPER;
BaseObjectPtr m_element;
};
} // namespace XLS
......
......@@ -92,10 +92,69 @@ const bool SXRANGE::loadContent(BinProcessor& proc)
if(proc.optional<Parenthesis_SXRANGE>())
{
while(elements_.empty() == false)
{
SXNum* num = dynamic_cast<SXNum*>(elements_.front().get());
if (num)
{
m_arSXNum.push_back(elements_.front());
}
else
{
SXDtr* dtr = dynamic_cast<SXDtr*>(elements_.front().get());
if (dtr)
{
m_arSXDtr.push_back(elements_.front());
}
}
elements_.pop_front();
}
}
return true;
}
int SXRANGE::serialize(std::wostream & strm)
{
SXRng* rng = dynamic_cast<SXRng*>(m_SXRng.get());
if (!rng) return 0;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"rangePr")
{
switch(rng->iByType)
{
case 0: CP_XML_ATTR(L"groupBy", L"range"); break;
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;
}
if (m_arSXDtr.size() == 2)
{
SXDtr* startDate = dynamic_cast<SXDtr*>(m_arSXDtr[0].get());
SXDtr* endDate = dynamic_cast<SXDtr*>(m_arSXDtr[1].get());
std::wstringstream s_start, s_end;
s_start << startDate->yr << L"-" << startDate->mon << L"-" << startDate->dom << L"T" << startDate->hr << L":" << startDate->min << L":" << startDate->sec;
s_end << endDate->yr << L"-" << endDate->mon << L"-" << endDate->dom << L"T" << endDate->hr << L":" << endDate->min << L":" << endDate->sec;
CP_XML_ATTR(L"startDate", s_start.str());
CP_XML_ATTR(L"endDate", s_end.str());
}
if (m_arSXNum.size() == 3)
{
}
}
}
return 0;
}
} // namespace XLS
......@@ -47,9 +47,13 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeSXRANGE;
int serialize(std::wostream & strm);
BaseObjectPtr m_SXRng;
static const ElementType type = typeSXRANGE;
BaseObjectPtr m_SXRng;
std::vector<BaseObjectPtr> m_arSXNum;
std::vector<BaseObjectPtr> m_arSXDtr;
};
} // namespace XLS
......
......@@ -73,5 +73,13 @@ const bool SXSRC::loadContent(BinProcessor& proc)
return true;
}
int SXSRC::serialize(std::wostream & stream)
{
if (m_source)
m_source->serialize(stream);
return 0;
}
} // namespace XLS
......@@ -47,7 +47,9 @@ public:
virtual const bool loadContent(BinProcessor& proc);
static const ElementType type = typeSXSRC;
int serialize(std::wostream & stream);
static const ElementType type = typeSXSRC;
BaseObjectPtr m_source;
};
......
......@@ -1922,16 +1922,10 @@ void XlsConverter::convert(XLS::PIVOTCACHEDEFINITION * pivot_cached)
{
if (pivot_cached == NULL) return;
xlsx_context->start_pivot_cache();
pivot_cached->serialize(xlsx_context->current_pivot_cache().definitions());
//if (pivot_cached->is_records())//??
{
xlsx_context->current_pivot_cache().isRecordsPresent = true;
//pivot_cached->serialize_records(xlsx_context->current_pivot_cache().records());
}
std::wstringstream strmD, strmR;
pivot_cached->serialize_definitions(strmD);
pivot_cached->serialize_records(strmR);
xlsx_context->end_pivot_cache();
xlsx_context->get_pivots_context().add_cache(strmD.str(), strmR.str());
}
\ No newline at end of file
......@@ -84,17 +84,7 @@ xlsx_xml_worksheet & xlsx_conversion_context::current_sheet()
throw std::runtime_error("internal error");
}
}
xlsx_pivot_cache_context & xlsx_conversion_context::current_pivot_cache()
{
if (!pivot_caches_.empty())
{
return *pivot_caches_.back().get();
}
else
{
throw std::runtime_error("internal error");
}
}
oox_chart_context & xlsx_conversion_context::current_chart()
{
if (!charts_.empty())
......@@ -133,15 +123,6 @@ void xlsx_conversion_context::end_chart()
{
}
void xlsx_conversion_context::start_pivot_cache()
{
pivot_caches_.push_back(xlsx_pivot_cache_context::create());
}
void xlsx_conversion_context::end_pivot_cache()
{
}
void xlsx_conversion_context::end_table()
{
get_table_context().serialize_hyperlinks(current_sheet().hyperlinks());
......@@ -246,6 +227,7 @@ void xlsx_conversion_context::end_document()
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_NODE(L"bookViews")
{
......@@ -271,11 +253,12 @@ void xlsx_conversion_context::end_document()
CP_XML_STREAM() << str_;
}
}
if (!pivot_caches_.empty())
int pivot_cache_count = xlsx_pivots_context_.get_cache_count();
if (pivot_cache_count > 0)
{
CP_XML_NODE(L"pivotCaches")
{
for (size_t i = 0; i < pivot_caches_.size(); i++)
for (int i = 0; i < pivot_cache_count; i++)
{
std::wstring rId = L"pcId" + std::to_wstring(i+1);
static const std::wstring sType = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition";
......@@ -289,14 +272,10 @@ void xlsx_conversion_context::end_document()
CP_XML_ATTR(L"r:id", rId);
}
pivot_caches_[i]->dump_rels(content->get_rels());
pivot_caches_[i]->write_to(content->definitions());
if (pivot_caches_[i]->isRecordsPresent)
{
pivot_caches_[i]->write_records_to(content->records());
xlsx_pivots_context_.dump_rels(i, content->get_rels());
xlsx_pivots_context_.write_definitions_to(i, content->definitions());
xlsx_pivots_context_.write_records_to(i, content->records());
}
output_document_->get_xl_files().add_pivot_cache(content);
}
}
......
......@@ -41,7 +41,7 @@
#include "xlsx_drawing_context.h"
#include "xlsx_chart_context.h"
#include "xlsx_comments_context.h"
#include "xlsx_pivot_cache_context.h"
#include "xlsx_pivots_context.h"
#include "xlsx_output_xml.h"
......@@ -71,9 +71,6 @@ public:
void start_chart();
void end_chart();
void start_pivot_cache();
void end_pivot_cache();
std::wostream & shared_strings() { return xlsx_shared_strings_; }
std::wostream & defined_names() { return xlsx_defined_names_; }
std::wostream & workbook_views() { return xlsx_workbook_views_; }
......@@ -84,8 +81,8 @@ public:
xlsx_xml_worksheet & current_sheet();
oox_chart_context & current_chart();
xlsx_pivot_cache_context & current_pivot_cache();
xlsx_pivots_context & get_pivots_context() {return xlsx_pivots_context_;}
xlsx_drawing_context & get_drawing_context();
xlsx_drawing_context_handle & get_drawing_context_handle();
xlsx_comments_context & get_comments_context();
......@@ -102,7 +99,6 @@ private:
std::vector<xlsx_xml_worksheet_ptr> sheets_;
std::vector<oox_chart_context_ptr> charts_;
std::vector<xlsx_pivot_cache_context_ptr> pivot_caches_;
//std::wstringstream defaultOutput_;
//std::pair<float,float> maxDigitSize_;
......@@ -111,6 +107,7 @@ private:
size_t next_vml_file_id_; //используется для footer/header & comments
xlsx_pivots_context xlsx_pivots_context_;
xlsx_table_context xlsx_table_context_;
xlsx_text_context xlsx_text_context_;
......
......@@ -29,124 +29,64 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "xlsx_pivot_cache_context.h"
#include "xlsx_pivots_context.h"
#include "oox_rels.h"
#include "mediaitems_utils.h"
#include <boost/make_shared.hpp>
#include <simple_xml_writer.h>
namespace oox {
class xlsx_pivot_cache_context::Impl
{
// struct rel_
// {
// rel_(bool is_internal, std::wstring const & rid, std::wstring const & target, external_items::Type type) :
// is_internal_(is_internal),
// rid_(rid),
//target_(target),
// type_(type)
// {}
// bool is_internal_;
// std::wstring rid_;
// std::wstring target_;
// external_items::Type type_;
// };
class xlsx_pivots_context::Impl
{
public:
struct _pivot_cache
{
std::wstring definitionsData_;
std::wstring recordsData_;
};
Impl() {}
std::wstringstream definitionsData_;
std::wstringstream recordsData_;
//rels rels_;
std::vector<_pivot_cache> caches_;
};
xlsx_pivot_cache_context_ptr xlsx_pivot_cache_context::create()
xlsx_pivots_context::xlsx_pivots_context() : impl_(new xlsx_pivots_context::Impl())
{
return boost::make_shared<xlsx_pivot_cache_context>();
}
int countPivotCaches = 0;
xlsx_pivot_cache_context::xlsx_pivot_cache_context() : impl_(new xlsx_pivot_cache_context::Impl()), isRecordsPresent(false)
void xlsx_pivots_context::add_cache(std::wstring definitions, std::wstring records)
{
index = ++countPivotCaches;
Impl::_pivot_cache c = {definitions, records};
impl_->caches_.push_back(c);
}
std::wostream & xlsx_pivot_cache_context::definitions()
{
return impl_->definitionsData_;
}
std::wostream & xlsx_pivot_cache_context::records()
int xlsx_pivots_context::get_cache_count()
{
return impl_->recordsData_;
return (int)impl_->caches_.size();
}
//void xlsx_pivot_cache_context::add_rels(
// bool isInternal,
// std::wstring const & rid,
// std::wstring const & target,
// external_items::Type type)
//{
// impl_->add_rels(isInternal, rid, target, type);
//}
void xlsx_pivot_cache_context::dump_rels(rels & Rels)
void xlsx_pivots_context::dump_rels(int index, rels & Rels)
{
if (isRecordsPresent)
if (!impl_->caches_[index].recordsData_.empty())
{
Rels.add(relationship(L"rId1",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
L"pivotCacheRecords" + std::to_wstring(index) + L".xml", L""));
}
}
void xlsx_pivot_cache_context::write_to(std::wostream & strm)
void xlsx_pivots_context::write_definitions_to(int index, std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheDefinition")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
if (isRecordsPresent)
{
CP_XML_ATTR(L"r:id", L"rId1" );
}
CP_XML_ATTR(L"recordCount", 0);
//refreshedBy="Debra S Dalgleish"
//refreshedDate="39449.496381365738"
//createdVersion="1"
//refreshedVersion="2"
//recordCount="11"
//upgradeOnRefresh="1">
CP_XML_STREAM() << impl_->definitionsData_.str();
}
}
strm << impl_->caches_[index].definitionsData_;
}
void xlsx_pivot_cache_context::write_records_to(std::wostream & strm)
void xlsx_pivots_context::write_records_to(int index, std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"pivotCacheRecords")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"count", 0);
CP_XML_STREAM() << impl_->recordsData_.str();
}
}
strm << impl_->caches_[index].recordsData_;
}
xlsx_pivot_cache_context::~xlsx_pivot_cache_context()
xlsx_pivots_context::~xlsx_pivots_context()
{
}
......
......@@ -37,28 +37,19 @@ namespace oox {
class xlsx_pivot_cache_context;
typedef _CP_PTR(xlsx_pivot_cache_context) xlsx_pivot_cache_context_ptr;
class xlsx_pivot_cache_context
class xlsx_pivots_context
{
public:
xlsx_pivot_cache_context();
~xlsx_pivot_cache_context();
xlsx_pivots_context();
~xlsx_pivots_context();
std::wostream & definitions();
std::wostream & records();
void add_cache(std::wstring definitions, std::wstring records);
int get_cache_count();
void write_to(std::wostream & strm);
void write_records_to(std::wostream & strm);
void write_definitions_to (int index, std::wostream & strm);
void write_records_to (int index, std::wostream & strm);
void dump_rels(rels & Rels);
static xlsx_pivot_cache_context_ptr create();
//void add_rels( bool isInternal,
// std::wstring const & rid,
// std::wstring const & target,
// external_items::Type type);
bool isRecordsPresent;
int index;
void dump_rels(int index, rels & Rels);
private:
class Impl;
_CP_PTR(Impl) impl_;
......
......@@ -840,7 +840,7 @@ SOURCES += \
../XlsXlsxConverter/xlsx_tablecontext.cpp \
../XlsXlsxConverter/xlsx_textcontext.cpp \
../XlsXlsxConverter/xlsx_chart_context.cpp \
../XlsXlsxConverter/xlsx_pivot_cache_context.cpp \
../XlsXlsxConverter/xlsx_pivots_context.cpp \
../XlsXlsxConverter/xlsx_comments.cpp \
../XlsXlsxConverter/xlsx_comments_context.cpp \
......@@ -1598,7 +1598,7 @@ HEADERS += \
../XlsXlsxConverter/xlsx_conversion_context.h \
../XlsXlsxConverter/xlsx_drawing_context.h \
../XlsXlsxConverter/xlsx_drawings.h \
../XlsXlsxConverter/xlsx_pivot_cache_context.cpp \
../XlsXlsxConverter/xlsx_pivots_context.cpp \
../XlsXlsxConverter/xlsx_hyperlinks.h \
../XlsXlsxConverter/xlsx_output_xml.h \
../XlsXlsxConverter/xlsx_package.h \
......
......@@ -417,11 +417,11 @@
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_pivot_cache_context.cpp"
RelativePath="..\XlsXlsxConverter\xlsx_pivots_context.cpp"
>
</File>
<File
RelativePath="..\XlsXlsxConverter\xlsx_pivot_cache_context.h"
RelativePath="..\XlsXlsxConverter\xlsx_pivots_context.h"
>
</File>
<File
......
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