Commit f575947c authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - fix 3d chart, fix empty chart, ..

parent 765677d9
......@@ -99,10 +99,16 @@ HRESULT convert_directory(std::wstring pathName)
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = convert_single(argv[1]);
//HRESULT hr = convert_directory(argv[1]);
HRESULT hr = -1;
if (NSFile::CFileBinary::Exists(argv[1]))
{
hr = convert_single(argv[1]);
}
else if (NSDirectory::Exists(argv[1]))
{
hr = convert_directory(argv[1]);
}
return hr;
}
\ No newline at end of file
......@@ -54,14 +54,17 @@ BaseObjectPtr Chart3d::clone()
void Chart3d::readFields(CFRecord& record)
{
unsigned short flags;
unsigned short pcHeight_raw;
record >> anRot >> anElev >> pcDist >> pcHeight_raw >> pcDepth >> pcGap >> flags;
record >> anRot >> anElev >> pcDist >> pcHeightPie >> pcDepth >> pcGap >> flags;
fPerspective = GETBIT(flags, 0);
fCluster = GETBIT(flags, 1);
f3DScaling = GETBIT(flags, 2);
fNotPieChart = GETBIT(flags, 4);
fWalls2D = GETBIT(flags, 5);
pcHeight = fNotPieChart ? static_cast<short>(pcHeight_raw) : pcHeight_raw;
if (fNotPieChart)
{
pcHeight3D = static_cast<short>(pcHeightPie);
}
}
} // namespace XLS
......
......@@ -48,7 +48,6 @@ public:
BaseObjectPtr clone();
void readFields(CFRecord& record);
static const ElementType type = typeChart3d;
......@@ -57,7 +56,8 @@ public:
_INT16 anRot;
_INT16 anElev;
_INT16 pcDist;
_UINT32 pcHeight;
_UINT16 pcHeightPie;
short pcHeight3D;
_INT16 pcDepth;
_UINT16 pcGap;
......
......@@ -122,7 +122,7 @@ void DConRef::check_external()
{
bool bFound = false;
for (size_t i = 0; i < global_info_->sheets_names.size(); i++) // todooo отдельно???
for (size_t i = 0; !bFilePath && i < global_info_->sheets_names.size(); i++)
{
if (global_info_->sheets_names[i] == sheet_name)
{
......
......@@ -116,7 +116,7 @@ const bool AUTOFILTER::loadContent(BinProcessor& proc)
std::vector<BaseObjectPtr> ar;
ar.push_back(elements_.back());
m_mapFilters12.insert(std::pair<int, std::vector<BaseObjectPtr>>(ind, ar));
m_mapFilters12.insert(std::make_pair(ind, ar));
}
}
}
......
......@@ -78,7 +78,7 @@ public:
{
if (row->miyRw > 0 && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.001)
{
sheet_info.customRowsHeight.insert(std::pair<int, double>(row->rw, row->miyRw / 20.));
sheet_info.customRowsHeight.insert(std::make_pair(row->rw, row->miyRw / 20.));
}
}
m_rows.push_back(elements_.front());
......@@ -102,7 +102,7 @@ public:
{
std::list<BaseObjectPtr> c;
c.push_back(elements_.front());
m_cells.insert(std::pair<int, std::list<BaseObjectPtr>>(cell->RowNumber, c));
m_cells.insert(std::make_pair(cell->RowNumber, c));
}
else
{
......
......@@ -77,10 +77,10 @@ const bool COLUMNS::loadContent(BinProcessor& proc)
for (int i = column_info->colFirst; i <= column_info->colLast; i++)
{
global_info_->sheet_size_info.back().customColumnsWidth.insert(std::pair<int, double>(i, column_info->coldx / 256.));
global_info_->sheet_size_info.back().customColumnsWidth.insert(std::make_pair(i, column_info->coldx / 256.));
//else if (def_ok)
//{
// global_info_->sheet_size_info.back().customColumnsWidth.insert(std::pair<int, double>(i, global_info_->sheet_size_info.back().defaultColumnWidth));
// global_info_->sheet_size_info.back().customColumnsWidth.insert(std::make_pair(i, global_info_->sheet_size_info.back().defaultColumnWidth));
//}
}
......
......@@ -175,7 +175,7 @@ const bool FDB::loadContent(BinProcessor& proc)
return true;
}
int FDB::serialize(std::wostream & strm, bool bSql)
int FDB::serialize(std::wostream & strm, bool bSql, bool bDBB)
{
SXFDB* fdb = dynamic_cast<SXFDB*>(m_SXFDB.get());
SXFDBType* fdb_type = dynamic_cast<SXFDBType*>(m_SXFDBType.get());
......@@ -227,7 +227,7 @@ int FDB::serialize(std::wostream & strm, bool bSql)
Formula->serialize_attr(CP_GET_XML_NODE());
}
if (m_arSRCSXOPER.empty() == false)
if (!m_arSRCSXOPER.empty() && (bDBB || (!bDBB && bSql)) )
{
CP_XML_NODE(L"sharedItems")
{
......@@ -250,20 +250,26 @@ int FDB::serialize(std::wostream & strm, bool bSql)
// }
//}
if ((bDate & bNumber) || (bNumber & bString & !bEmpty))
if ((bDate & bNumber)/* || (bNumber & bString & !bEmpty & !bInteger)*/)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 1);
}
else if ((bDate & bString) || ((bEmpty || !bNumber) & bInteger & bString))
else if ((bString && bDate) ||
(bString && (bNumber || bInteger)) ||
(!bString && bDate && bEmpty && (bNumber || bInteger)))
{
CP_XML_ATTR(L"containsMixedTypes", 1);
if (bInteger) bNumber = true;
else if (bEmpty && bNumber) bInteger = false;
if (bString && !bNumber && bInteger) bNumber = true;
else if (bString && bNumber && bInteger) bInteger = false;
}
else if (!bEmpty && !bString && !bBool)
{
CP_XML_ATTR(L"containsSemiMixedTypes", 0);
if (bDate)
{
CP_XML_ATTR(L"containsMixedTypes", 1);
}
}
if (bDate && ! (bNumber || bInteger || bString || bEmpty ))
{
......@@ -344,5 +350,25 @@ int FDB::serialize(std::wostream & strm, bool bSql)
return 0;
}
int FDB::serialize_record(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"r")
{
for (size_t i = 0; i < m_arSRCSXOPER.size(); i++)
{
SXOPER* oper = dynamic_cast<SXOPER*>(m_arSRCSXOPER[i].get());
oper->serialize_record(CP_XML_STREAM());
}
}
}
}
} // namespace XLS
......@@ -47,7 +47,8 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & strm, bool bSql);
int serialize(std::wostream & strm, bool bSql, bool bDBB);
int serialize_record(std::wostream & strm);
static const ElementType type = typeFDB;
......
......@@ -122,7 +122,7 @@ const bool LBL::loadContent(BinProcessor& proc)
ar[ind_sheet] = value;
//ar.push_back(value);
global_info_->mapDefineNames.insert(std::pair<std::wstring, std::vector<std::wstring>>(name, ar));
global_info_->mapDefineNames.insert(std::make_pair(name, ar));
}
isSerialize = true;
}
......
......@@ -118,7 +118,8 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
}
global_info_->mapPivotCacheIndex.insert(std::make_pair(global_info_->idPivotCache, global_info_->mapPivotCacheIndex.size()));
bool bSql = false;
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
bool bSql = src ? src->bSql : false;
CP_XML_WRITER(strm)
{
......@@ -127,23 +128,21 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
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())
if (pivot_cache->m_arDBB.empty() && bSql)
{
CP_XML_ATTR(L"r:id", L"rId1" );
CP_XML_ATTR(L"saveData", 0);
}
else
{
CP_XML_ATTR(L"saveData", 0);
CP_XML_ATTR(L"r:id", L"rId1" );
}
CP_XML_ATTR(L"enableRefresh", 1);
CP_XML_ATTR(L"refreshedBy", db->rgb.value());
CP_XML_ATTR(L"refreshedDate", db_ex->numDate.data.value);
CP_XML_ATTR(L"recordCount", db->crdbdb);
//upgradeOnRefresh="1"
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
if (src)
{
bSql = src->bSql;
src->serialize(CP_XML_STREAM());
}
......@@ -158,7 +157,7 @@ int PIVOTCACHEDEFINITION::serialize_definitions(std::wostream & strm)
FDB *field = dynamic_cast<FDB *>(pivot_cache->m_arFDB[i].get());
if (!field) continue;
field->serialize(CP_XML_STREAM(), bSql);
field->serialize(CP_XML_STREAM(), bSql, !pivot_cache->m_arDBB.empty());
}
}
}
......@@ -191,7 +190,10 @@ int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm)
PIVOTCACHE* pivot_cache = dynamic_cast<PIVOTCACHE*>(pFind->second.get());
if (!pivot_cache) return 0;
if (pivot_cache->m_arDBB.empty()) return 0;
SXSRC* src = dynamic_cast<SXSRC*>(m_SXSRC.get());
bool bSql = src ? src->bSql : false;
if (pivot_cache->m_arDBB.empty() && bSql) return 0;
CP_XML_WRITER(strm)
{
......@@ -200,11 +202,22 @@ int PIVOTCACHEDEFINITION::serialize_records(std::wostream & strm)
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++)
if (!pivot_cache->m_arDBB.empty())
{
pivot_cache->m_arDBB[i]->serialize(CP_XML_STREAM());
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());
}
}
else
{
CP_XML_ATTR(L"count", pivot_cache->m_arFDB.size());
for (size_t i = 0; i < pivot_cache->m_arFDB.size(); i++)
{
FDB* fdb = dynamic_cast<FDB*>(pivot_cache->m_arFDB[i].get());
fdb->serialize_record(CP_XML_STREAM());
}
}
}
}
......
......@@ -166,7 +166,7 @@ int PIVOTVIEW::serialize(std::wostream & strm)
CP_XML_ATTR(L"compact", view_ex12->fCompactData);
CP_XML_ATTR(L"compactData", view_ex12->fCompactData);
CP_XML_ATTR(L"gridDropZones", view_ex12->fNewDropZones);
CP_XML_ATTR(L"gridDropZones", !view_ex12->fNewDropZones);
CP_XML_ATTR(L"showDrill", !view_ex12->fHideDrillIndicators);
CP_XML_ATTR(L"printDrill", view_ex12->fPrintDrillIndicators);
}
......
......@@ -155,5 +155,20 @@ int SXOPER::serialize(std::wostream & strm)
return 0;
}
int SXOPER::serialize_record(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(node)
{
if (!value.empty() || bString)
{
CP_XML_ATTR(L"v", value);
}
}
}
return 0;
}
} // namespace XLS
......@@ -48,6 +48,7 @@ public:
virtual const bool loadContent(BinProcessor& proc);
int serialize(std::wostream & strm);
int serialize_record(std::wostream & strm);
static const ElementType type = typeSXOPER;
......
......@@ -324,6 +324,13 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
int iCrt = -1;
if (charts->m_arSERIESFORMAT.empty() && !parent0->m_arCRT.empty())
{
std::vector<int> ser;
m_mapTypeChart.insert(std::make_pair(0, ser));
return;
}
for (size_t i = 0 ; i < charts->m_arSERIESFORMAT.size(); i++)
{
SERIESFORMAT * series = dynamic_cast<SERIESFORMAT *>(charts->m_arSERIESFORMAT[i].get());
......@@ -334,7 +341,7 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
if ( serCrt == NULL)
{
//для доп линий может и не существовать - брать предыдущий - и объеденить!!!
std::map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
std::unordered_map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
if (it != m_mapTypeChart.end())
{
SERIESFORMAT * series_prev = dynamic_cast<SERIESFORMAT *>(charts->m_arSERIESFORMAT[it->second.back()].get());
......@@ -359,12 +366,12 @@ void ChartSheetSubstream::recalc(CHARTFORMATS* charts)
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[iCrt].get());
std::map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
std::unordered_map<int,std::vector<int>>::iterator it = m_mapTypeChart.find(iCrt);
if (it == m_mapTypeChart.end())
{
std::vector<int> ser;
ser.push_back(i);
m_mapTypeChart.insert(std::pair<int, std::vector<int>>(iCrt, ser));
m_mapTypeChart.insert(std::make_pair(iCrt, ser));
}
else
{
......@@ -545,11 +552,11 @@ int ChartSheetSubstream::serialize_3D (std::wostream & _stream)
CP_XML_ATTR (L"val" , chart3D->anElev);
}
}
if (chart3D->pcHeight != 100)
if (chart3D->pcHeight3D != 100 && chart3D->pcHeight3D >= 5 && chart3D->pcHeight3D <= 500)
{
CP_XML_NODE(L"c:hPercent")
{
CP_XML_ATTR (L"val" , chart3D->pcHeight);
CP_XML_ATTR (L"val" , chart3D->pcHeight3D);
}
}
if (chart3D->anRot != 0)
......@@ -662,7 +669,7 @@ int ChartSheetSubstream::serialize_legend (std::wostream & _stream, const std::w
//}
//todooo разобраться с разными типами в одном чарте .. считать количество серий??
std::map< int, std::vector<int>>::iterator it = m_mapTypeChart.begin();
std::unordered_map< int, std::vector<int>>::iterator it = m_mapTypeChart.begin();
if (it != m_mapTypeChart.end())
{
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[it->first].get());
......@@ -746,7 +753,7 @@ int ChartSheetSubstream::serialize_plot_area (std::wostream & _stream)
PlotAreaPos->serialize(CP_XML_STREAM());
}
for (std::map<int, std::vector<int>>::iterator it = m_mapTypeChart.begin(); it != m_mapTypeChart.end(); it++)
for (std::unordered_map<int, std::vector<int>>::iterator it = m_mapTypeChart.begin(); it != m_mapTypeChart.end(); it++)
{
CRT * crt = dynamic_cast<CRT*>(parent0->m_arCRT[it->first].get());
......@@ -962,7 +969,7 @@ int ChartSheetSubstream::serialize_dPt(std::wostream & _stream, int id, CRT *crt
CP_XML_ATTR(L"val", series_data_format->xi);
if (format->fVaried)
present_idx.insert(std::pair<int, bool>(series_data_format->xi, true));
present_idx.insert(std::make_pair(series_data_format->xi, true));
}
series_ss->serialize (CP_XML_STREAM(), crt->m_iChartType, series_data_format->xi);
series_ss->serialize2 (CP_XML_STREAM(), crt->m_iChartType);
......
......@@ -32,6 +32,7 @@
#pragma once
#include <Logic/CompositeObject.h>
#include <unordered_map>
namespace XLS
{;
......@@ -86,7 +87,7 @@ private:
void recalc(CHARTFORMATS* charts);
void recalc(SERIESDATA* data);
std::map<int, std::vector<int>> m_mapTypeChart;//тут нужен несортированый .. пока оставим этот
std::unordered_map<int, std::vector<int>> m_mapTypeChart;
GlobalWorkbookInfoPtr pGlobalWorkbookInfo;
};
......
......@@ -165,12 +165,12 @@ const size_t GlobalWorkbookInfo::RegisterFillId(const FillInfo& fill)
void GlobalWorkbookInfo::RegisterFontColorId (int id, const FillInfoExt & font_color)
{
fonts_color_ext.insert(std::pair<int, FillInfoExt>(id, font_color));
fonts_color_ext.insert(std::make_pair(id, font_color));
}
void GlobalWorkbookInfo::RegisterPaletteColor(int id, const std::wstring & rgb)
{
colors_palette.insert(std::pair<int, std::wstring>(id, rgb));
colors_palette.insert(std::make_pair(id, rgb));
}
unsigned int GlobalWorkbookInfo::GenerateAXESId()
......
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