Commit 578327ba authored by ElenaSubbotina's avatar ElenaSubbotina

XlsFormat - split sheets by type (ala original file)

parent 52908908
...@@ -513,7 +513,23 @@ const std::wstring tab2sheet_name(const short tabid, std::vector<std::wstring>& ...@@ -513,7 +513,23 @@ const std::wstring tab2sheet_name(const short tabid, std::vector<std::wstring>&
} }
return L"#REF"; return L"#REF";
} }
const std::wstring name2sheet_name(std::wstring name, const std::wstring prefix)
{
static boost::wregex correct_sheet_name(L"^\\'.+?\\'$");
static boost::wregex test_sheet_name(L"[\\s)(\\'&:-]+"); //.??? 6442946.xls
std::wstring sheet_first = prefix + name;
if(!boost::regex_search(sheet_first.begin(), sheet_first.end(), correct_sheet_name))
{
if(boost::regex_search(sheet_first.begin(), sheet_first.end(), test_sheet_name))
{
sheet_first = boost::algorithm::replace_all_copy(sheet_first, L"'", L"''");
sheet_first = std::wstring(L"'") + sheet_first + std::wstring(L"'");
}
}
return sheet_first;
}
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix) const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix)
{ {
if(-1 == tabFirst) if(-1 == tabFirst)
...@@ -538,7 +554,7 @@ const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabL ...@@ -538,7 +554,7 @@ const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabL
std::wstring sheet_last; std::wstring sheet_last;
if (tabLast != tabFirst) if (tabLast != tabFirst)
{ {
sheet_last = prefix + tab2sheet_name(tabLast, names); sheet_last = std::wstring(L":") + prefix + tab2sheet_name(tabLast, names);
if(!boost::regex_search(sheet_last.begin(), sheet_last.end(), correct_sheet_name)) if(!boost::regex_search(sheet_last.begin(), sheet_last.end(), correct_sheet_name))
{ {
...@@ -548,7 +564,6 @@ const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabL ...@@ -548,7 +564,6 @@ const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabL
sheet_last = std::wstring(L"\'") + sheet_last + std::wstring(L"\'"); sheet_last = std::wstring(L"\'") + sheet_last + std::wstring(L"\'");
} }
} }
sheet_last = std::wstring(L":") + sheet_last;
} }
return sheet_first + sheet_last; return sheet_first + sheet_last;
......
...@@ -95,6 +95,7 @@ namespace STR ...@@ -95,6 +95,7 @@ namespace STR
namespace XMLSTUFF namespace XMLSTUFF
{; {;
const std::wstring name2sheet_name(std::wstring name, const std::wstring prefix);
const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix = L""); const std::wstring xti_indexes2sheet_name(const short tabFirst, const short tabLast, std::vector<std::wstring>& names, const std::wstring prefix = L"");
} }
......
...@@ -79,7 +79,7 @@ void BoundSheet8::readFields(CFRecord& record) ...@@ -79,7 +79,7 @@ void BoundSheet8::readFields(CFRecord& record)
hsState = std::wstring (L"hidden"); hsState = std::wstring (L"hidden");
break; break;
case 2: case 2:
hsState = std::wstring (L"hidden");//(L"veryHidden"); hsState = std::wstring (L"veryHidden");
break; break;
} }
if (name_.length() > 31) if (name_.length() > 31)
...@@ -92,8 +92,10 @@ void BoundSheet8::readFields(CFRecord& record) ...@@ -92,8 +92,10 @@ void BoundSheet8::readFields(CFRecord& record)
name_ = L"Sheet_" + boost::lexical_cast<std::wstring>(record.getGlobalWorkbookInfo()->current_sheet + 1); name_ = L"Sheet_" + boost::lexical_cast<std::wstring>(record.getGlobalWorkbookInfo()->current_sheet + 1);
} }
record.getGlobalWorkbookInfo()->sheets_names.push_back(name_); GlobalWorkbookInfo::_sheet_info sheet_info;
record.getGlobalWorkbookInfo()->sheets_state.push_back(hsState); sheet_info.state = hsState;
sheet_info.name = name_;
record.getGlobalWorkbookInfo()->sheets_info.push_back(sheet_info);
dt = GETBITS(flags, 8, 15); dt = GETBITS(flags, 8, 15);
} }
......
...@@ -122,9 +122,9 @@ void DConRef::check_external() ...@@ -122,9 +122,9 @@ void DConRef::check_external()
{ {
bool bFound = false; bool bFound = false;
for (size_t i = 0; !bFilePath && i < global_info_->sheets_names.size(); i++) for (size_t i = 0; !bFilePath && i < global_info_->sheets_info.size(); i++)
{ {
if (global_info_->sheets_names[i] == sheet_name) if (global_info_->sheets_info[i].name == sheet_name)
{ {
bFound = true; bFound = true;
break; break;
......
...@@ -55,9 +55,9 @@ void DefColWidth::readFields(CFRecord& record) ...@@ -55,9 +55,9 @@ void DefColWidth::readFields(CFRecord& record)
GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo(); GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo();
record >> cchdefColWidth; record >> cchdefColWidth;
if (!global_info->sheet_size_info.empty()) if (!global_info->sheets_info.empty())
{ {
global_info->sheet_size_info.back().defaultColumnWidth = cchdefColWidth ; global_info->sheets_info.back().defaultColumnWidth = cchdefColWidth ;
} }
} }
......
...@@ -65,9 +65,9 @@ void DefaultRowHeight::readFields(CFRecord& record) ...@@ -65,9 +65,9 @@ void DefaultRowHeight::readFields(CFRecord& record)
record >> miyRw; record >> miyRw;
if (!global_info->sheet_size_info.empty()) if (!global_info->sheets_info.empty())
{ {
global_info->sheet_size_info.back().defaultRowHeight = miyRw / 20.; global_info->sheets_info.back().defaultRowHeight = miyRw / 20.;
} }
} }
......
...@@ -35,17 +35,14 @@ ...@@ -35,17 +35,14 @@
namespace XLS namespace XLS
{ {
WsBool::WsBool(const bool is_dialog_sheet) WsBool::WsBool(bool & is_dialog_sheet) : fDialog(is_dialog_sheet)
: fDialog(is_dialog_sheet)
{ {
} }
WsBool::~WsBool() WsBool::~WsBool()
{ {
} }
BaseObjectPtr WsBool::clone() BaseObjectPtr WsBool::clone()
{ {
return BaseObjectPtr(new WsBool(*this)); return BaseObjectPtr(new WsBool(*this));
...@@ -56,6 +53,7 @@ void WsBool::readFields(CFRecord& record) ...@@ -56,6 +53,7 @@ void WsBool::readFields(CFRecord& record)
{ {
unsigned short flags; unsigned short flags;
record >> flags; record >> flags;
fShowAutoBreaks = GETBIT(flags, 0); fShowAutoBreaks = GETBIT(flags, 0);
fDialog = GETBIT(flags, 4); fDialog = GETBIT(flags, 4);
fApplyStyles = GETBIT(flags, 5); fApplyStyles = GETBIT(flags, 5);
......
...@@ -36,14 +36,12 @@ ...@@ -36,14 +36,12 @@
namespace XLS namespace XLS
{ {
// Logical representation of WsBool record in BIFF8
class WsBool: public BiffRecord class WsBool: public BiffRecord
{ {
BIFF_RECORD_DEFINE_TYPE_INFO(WsBool) BIFF_RECORD_DEFINE_TYPE_INFO(WsBool)
BASE_OBJECT_DEFINE_CLASS_NAME(WsBool) BASE_OBJECT_DEFINE_CLASS_NAME(WsBool)
public: public:
WsBool(const bool is_dialog_sheet); WsBool(bool & is_dialog_sheet);
~WsBool(); ~WsBool();
BaseObjectPtr clone(); BaseObjectPtr clone();
...@@ -54,7 +52,7 @@ public: ...@@ -54,7 +52,7 @@ public:
//----------------------------- //-----------------------------
bool fShowAutoBreaks; bool fShowAutoBreaks;
bool fDialog; bool& fDialog;
bool fApplyStyles; bool fApplyStyles;
bool fRowSumsBelow; bool fRowSumsBelow;
bool fColSumsRight; bool fColSumsRight;
......
...@@ -88,9 +88,9 @@ void NoteSh::load(CFRecord& record) ...@@ -88,9 +88,9 @@ void NoteSh::load(CFRecord& record)
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
void NoteSh::calculate() void NoteSh::calculate()
{ {
XLS::GlobalWorkbookInfo::_sheet_size_info zero; XLS::GlobalWorkbookInfo::_sheet_info zero;
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info->current_sheet >= 0 ? XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info->current_sheet >= 0 ?
global_info->sheet_size_info[global_info->current_sheet - 1] : zero; global_info->sheets_info[global_info->current_sheet - 1] : zero;
ref_ = CellRef(row, col, true, true).toString(); ref_ = CellRef(row, col, true, true).toString();
......
...@@ -79,9 +79,9 @@ void OfficeArtClientAnchorSheet::calculate() ...@@ -79,9 +79,9 @@ void OfficeArtClientAnchorSheet::calculate()
{ {
global_info->GetDigitFontSizePixels(); global_info->GetDigitFontSizePixels();
XLS::GlobalWorkbookInfo::_sheet_size_info zero; XLS::GlobalWorkbookInfo::_sheet_info zero;
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info->current_sheet >= 0 ? XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info->current_sheet >= 0 ?
global_info->sheet_size_info[global_info->current_sheet - 1] : zero; global_info->sheets_info[global_info->current_sheet - 1] : zero;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
//1 inch = 72 point //1 inch = 72 point
...@@ -134,9 +134,9 @@ void OfficeArtClientAnchorSheet::calculate_1() ...@@ -134,9 +134,9 @@ void OfficeArtClientAnchorSheet::calculate_1()
{ {
global_info->GetDigitFontSizePixels(); global_info->GetDigitFontSizePixels();
XLS::GlobalWorkbookInfo::_sheet_size_info zero; XLS::GlobalWorkbookInfo::_sheet_info zero;
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info->current_sheet >= 0 ? XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info->current_sheet >= 0 ?
global_info->sheet_size_info[global_info->current_sheet - 1] : zero; global_info->sheets_info[global_info->current_sheet - 1] : zero;
double kfRow = ( 360000 * 2.54 / 72) / 256. ; double kfRow = ( 360000 * 2.54 / 72) / 256. ;
double Digit_Width = global_info->defaultDigitFontSize.first; double Digit_Width = global_info->defaultDigitFontSize.first;
......
...@@ -114,10 +114,22 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f ...@@ -114,10 +114,22 @@ void PtgArea3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool f
ixti = ixals; ixti = ixals;
if (ixals == 0xffff) if (ixals == 0xffff)
{ {
std::wstring prefix = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, global_info->sheets_names); std::wstring strRange;
if (!prefix.empty()) prefix += L"!"; if(-1 == itabFirst)
{
strRange = L"#REF";
}
else
{
strRange = XMLSTUFF::name2sheet_name(global_info->sheets_info[itabFirst].name, L"");
if (itabFirst != itabLast)
{
strRange += std::wstring(L":") + XMLSTUFF::name2sheet_name(global_info->sheets_info[itabLast].name, L"");
}
}
if (!strRange.empty()) strRange += L"!";
ptg_stack.push(prefix + range_ref); ptg_stack.push(strRange + range_ref);
} }
} }
if (ixti != 0xffff) if (ixti != 0xffff)
......
...@@ -109,10 +109,22 @@ void PtgRef3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu ...@@ -109,10 +109,22 @@ void PtgRef3d::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool fu
ixti = ixals; ixti = ixals;
if (ixals == 0xffff) if (ixals == 0xffff)
{ {
std::wstring prefix = XMLSTUFF::xti_indexes2sheet_name(itabFirst, itabLast, global_info->sheets_names); std::wstring strRange;
if (!prefix.empty()) prefix += L"!"; if(-1 == itabFirst)
{
strRange = L"#REF";
}
else
{
strRange = XMLSTUFF::name2sheet_name(global_info->sheets_info[itabFirst].name, L"");
if (itabFirst != itabLast)
{
strRange += std::wstring(L":") + XMLSTUFF::name2sheet_name(global_info->sheets_info[itabLast].name, L"");
}
}
if (!strRange.empty()) strRange += L"!";
ptg_stack.push(prefix + cell_ref); ptg_stack.push(strRange + cell_ref);
} }
} }
if (ixti != 0xffff) if (ixti != 0xffff)
......
...@@ -145,6 +145,7 @@ int AUTOFILTER::serialize(std::wostream & stream) ...@@ -145,6 +145,7 @@ int AUTOFILTER::serialize(std::wostream & stream)
if (it == pGlobalWorkbookInfoPtr->mapDefineNames.end()) return 0; if (it == pGlobalWorkbookInfoPtr->mapDefineNames.end()) return 0;
int count_columns = info->cEntries; int count_columns = info->cEntries;
size_t ind = pGlobalWorkbookInfoPtr->current_sheet; size_t ind = pGlobalWorkbookInfoPtr->current_sheet;
std::wstring ref; std::wstring ref;
...@@ -159,7 +160,7 @@ int AUTOFILTER::serialize(std::wostream & stream) ...@@ -159,7 +160,7 @@ int AUTOFILTER::serialize(std::wostream & stream)
} }
if (ref.empty()) return 0; if (ref.empty()) return 0;
std::wstring sheet_name = ind <= pGlobalWorkbookInfoPtr->sheets_names.size() ? pGlobalWorkbookInfoPtr->sheets_names[ind-1] : L""; std::wstring sheet_name = ind <= pGlobalWorkbookInfoPtr->sheets_info.size() ? pGlobalWorkbookInfoPtr->sheets_info[ind-1].name : L"";
if (!sheet_name.empty()) if (!sheet_name.empty())
{ {
int pos = ref.find(sheet_name); int pos = ref.find(sheet_name);
......
...@@ -61,9 +61,9 @@ public: ...@@ -61,9 +61,9 @@ public:
{ {
global_info_ = proc.getGlobalWorkbookInfo(); global_info_ = proc.getGlobalWorkbookInfo();
XLS::GlobalWorkbookInfo::_sheet_size_info zero; XLS::GlobalWorkbookInfo::_sheet_info zero;
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info_->current_sheet >=0 ? XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->current_sheet >=0 ?
global_info_->sheet_size_info[global_info_->current_sheet - 1] : zero; global_info_->sheets_info[global_info_->current_sheet - 1] : zero;
int count, count_row = 0; int count, count_row = 0;
...@@ -175,9 +175,9 @@ struct _CompareColumnCell ...@@ -175,9 +175,9 @@ struct _CompareColumnCell
int CELL_GROUP::serialize(std::wostream & stream) int CELL_GROUP::serialize(std::wostream & stream)
{ {
XLS::GlobalWorkbookInfo::_sheet_size_info zero; XLS::GlobalWorkbookInfo::_sheet_info zero;
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info_->current_sheet >=0 ? XLS::GlobalWorkbookInfo::_sheet_info & sheet_info = global_info_->current_sheet >=0 ?
global_info_->sheet_size_info[global_info_->current_sheet - 1] : zero; global_info_->sheets_info[global_info_->current_sheet - 1] : zero;
CP_XML_WRITER(stream) CP_XML_WRITER(stream)
{ {
......
...@@ -56,7 +56,8 @@ const bool CHART::loadContent(BinProcessor& proc) ...@@ -56,7 +56,8 @@ const bool CHART::loadContent(BinProcessor& proc)
{ {
return false; return false;
} }
if(!proc.mandatory<ChartSheetSubstream>()) ChartSheetSubstream chart_sheet(-1);
if(!proc.mandatory(chart_sheet))
{ {
return false; return false;
} }
......
...@@ -77,10 +77,10 @@ const bool COLUMNS::loadContent(BinProcessor& proc) ...@@ -77,10 +77,10 @@ const bool COLUMNS::loadContent(BinProcessor& proc)
for (int i = column_info->colFirst; i <= column_info->colLast; i++) for (int i = column_info->colFirst; i <= column_info->colLast; i++)
{ {
global_info_->sheet_size_info.back().customColumnsWidth.insert(std::make_pair(i, column_info->coldx / 256.)); global_info_->sheets_info.back().customColumnsWidth.insert(std::make_pair(i, column_info->coldx / 256.));
//else if (def_ok) //else if (def_ok)
//{ //{
// global_info_->sheet_size_info.back().customColumnsWidth.insert(std::make_pair(i, global_info_->sheet_size_info.back().defaultColumnWidth)); // global_info_->sheets_info.back().customColumnsWidth.insert(std::make_pair(i, global_info_->sheets_info.back().defaultColumnWidth));
//} //}
} }
......
...@@ -31,34 +31,33 @@ ...@@ -31,34 +31,33 @@
*/ */
#include "GLOBALS.h" #include "GLOBALS.h"
#include <Logic/Biff_records/DefColWidth.h>
#include <Logic/Biff_records/DxGCol.h> #include "../Biff_records/DefColWidth.h"
#include "../Biff_records/DxGCol.h"
#include <Logic/Biff_records/Protect.h> #include "../Biff_records/Protect.h"
#include <Logic/Biff_records/CalcMode.h> #include "../Biff_records/CalcMode.h"
#include <Logic/Biff_records/CalcCount.h> #include "../Biff_records/CalcCount.h"
#include <Logic/Biff_records/CalcRefMode.h> #include "../Biff_records/CalcRefMode.h"
#include <Logic/Biff_records/CalcIter.h> #include "../Biff_records/CalcIter.h"
#include <Logic/Biff_records/CalcDelta.h> #include "../Biff_records/CalcDelta.h"
#include <Logic/Biff_records/CalcSaveRecalc.h> #include "../Biff_records/CalcSaveRecalc.h"
#include <Logic/Biff_records/PrintRowCol.h> #include "../Biff_records/PrintRowCol.h"
#include <Logic/Biff_records/PrintGrid.h> #include "../Biff_records/PrintGrid.h"
#include <Logic/Biff_records/GridSet.h> #include "../Biff_records/GridSet.h"
#include <Logic/Biff_records/Guts.h> #include "../Biff_records/Guts.h"
#include <Logic/Biff_records/DefaultRowHeight.h> #include "../Biff_records/DefaultRowHeight.h"
#include <Logic/Biff_records/WsBool.h> #include "../Biff_records/WsBool.h"
#include <Logic/Biff_records/Sync.h> #include "../Biff_records/Sync.h"
#include <Logic/Biff_records/LPr.h> #include "../Biff_records/LPr.h"
#include <Logic/Biff_records/HorizontalPageBreaks.h> #include "../Biff_records/HorizontalPageBreaks.h"
#include <Logic/Biff_records/VerticalPageBreaks.h> #include "../Biff_records/VerticalPageBreaks.h"
#include <Logic/Biff_records/Country.h> #include "../Biff_records/Country.h"
namespace XLS namespace XLS
{ {
GLOBALS::GLOBALS(const bool is_dialog_sheet) GLOBALS::GLOBALS() : is_dialog(false)
: is_dialog(is_dialog_sheet)
{ {
} }
......
...@@ -40,7 +40,7 @@ class GLOBALS: public CompositeObject ...@@ -40,7 +40,7 @@ class GLOBALS: public CompositeObject
{ {
BASE_OBJECT_DEFINE_CLASS_NAME(GLOBALS) BASE_OBJECT_DEFINE_CLASS_NAME(GLOBALS)
public: public:
GLOBALS(const bool is_dialog_sheet); GLOBALS();
~GLOBALS(); ~GLOBALS();
BaseObjectPtr clone(); BaseObjectPtr clone();
......
...@@ -101,7 +101,7 @@ namespace XLS ...@@ -101,7 +101,7 @@ namespace XLS
{; {;
ChartSheetSubstream::ChartSheetSubstream() ChartSheetSubstream::ChartSheetSubstream(const size_t ws_index) : ws_index_(ws_index)
{ {
} }
...@@ -126,7 +126,7 @@ CHARTSHEETCONTENT = [WriteProtect] [SheetExt] [WebPub] *HFPicture PAGESETUP Prin ...@@ -126,7 +126,7 @@ CHARTSHEETCONTENT = [WriteProtect] [SheetExt] [WebPub] *HFPicture PAGESETUP Prin
*/ */
const bool ChartSheetSubstream::loadContent(BinProcessor& proc) const bool ChartSheetSubstream::loadContent(BinProcessor& proc)
{ {
pGlobalWorkbookInfo = proc.getGlobalWorkbookInfo(); global_info_ = proc.getGlobalWorkbookInfo();
int count = 0 ; int count = 0 ;
...@@ -507,7 +507,7 @@ int ChartSheetSubstream::serialize(std::wostream & _stream) ...@@ -507,7 +507,7 @@ int ChartSheetSubstream::serialize(std::wostream & _stream)
if (chart_rect) if (chart_rect)
{ {
pGlobalWorkbookInfo->xls_converter->xlsx_context->get_drawing_context().set_absolute_anchor( global_info_->xls_converter->xlsx_context->get_drawing_context().set_absolute_anchor(
0, 0, chart_rect->dx.dVal, chart_rect->dy.dVal); 0, 0, chart_rect->dx.dVal, chart_rect->dy.dVal);
} }
......
...@@ -44,12 +44,11 @@ class CRT; ...@@ -44,12 +44,11 @@ class CRT;
class ChartSheetSubstream; class ChartSheetSubstream;
typedef boost::shared_ptr<ChartSheetSubstream> ChartSheetSubstreamPtr; typedef boost::shared_ptr<ChartSheetSubstream> ChartSheetSubstreamPtr;
// Logical representation of ChartSheetSubstream union of records
class ChartSheetSubstream: public CompositeObject class ChartSheetSubstream: public CompositeObject
{ {
BASE_OBJECT_DEFINE_CLASS_NAME(ChartSheetSubstream) BASE_OBJECT_DEFINE_CLASS_NAME(ChartSheetSubstream)
public: public:
ChartSheetSubstream(); ChartSheetSubstream(const size_t ws_index);
~ChartSheetSubstream(); ~ChartSheetSubstream();
BaseObjectPtr clone(); BaseObjectPtr clone();
...@@ -69,6 +68,10 @@ public: ...@@ -69,6 +68,10 @@ public:
static const ElementType type = typeChartSheetSubstream; static const ElementType type = typeChartSheetSubstream;
GlobalWorkbookInfoPtr global_info_;
size_t ws_index_;
BaseObjectPtr m_BACKGROUND; BaseObjectPtr m_BACKGROUND;
std::vector<BaseObjectPtr> m_arFbi; std::vector<BaseObjectPtr> m_arFbi;
BaseObjectPtr m_CHARTFORMATS; BaseObjectPtr m_CHARTFORMATS;
...@@ -90,8 +93,6 @@ private: ...@@ -90,8 +93,6 @@ private:
void recalc(SERIESDATA* data); void recalc(SERIESDATA* data);
std::unordered_map<int, std::vector<int>> m_mapTypeChart; std::unordered_map<int, std::vector<int>> m_mapTypeChart;
GlobalWorkbookInfoPtr pGlobalWorkbookInfo;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -221,8 +221,8 @@ void GlobalWorkbookInfo::GetDigitFontSizePixels() ...@@ -221,8 +221,8 @@ void GlobalWorkbookInfo::GetDigitFontSizePixels()
void GlobalWorkbookInfo::CalculateAnchor(int colL, int colR, int rwT, int rwB, _UINT32 & x, _UINT32 &y, _UINT32 &cx, _UINT32 & cy) void GlobalWorkbookInfo::CalculateAnchor(int colL, int colR, int rwT, int rwB, _UINT32 & x, _UINT32 &y, _UINT32 &cx, _UINT32 & cy)
{ {
_sheet_size_info zero; _sheet_info zero;
_sheet_size_info & sheet_info = current_sheet >= 0 ? sheet_size_info[current_sheet - 1] : zero; _sheet_info & sheet_info = current_sheet >= 0 ? sheets_info[current_sheet - 1] : zero;
GetDigitFontSizePixels(); GetDigitFontSizePixels();
......
...@@ -89,9 +89,6 @@ public: ...@@ -89,9 +89,6 @@ public:
CRYPT::DecryptorPtr decryptor; CRYPT::DecryptorPtr decryptor;
std::wstring password; std::wstring password;
std::vector<std::wstring> sheets_state;
std::vector<std::wstring> sheets_names;
boost::unordered_map<BorderInfo, int> border_x_ids; boost::unordered_map<BorderInfo, int> border_x_ids;
boost::unordered_map<FillInfo, int> fill_x_ids; boost::unordered_map<FillInfo, int> fill_x_ids;
...@@ -141,18 +138,18 @@ public: ...@@ -141,18 +138,18 @@ public:
unsigned int startAddedSharedStrings; unsigned int startAddedSharedStrings;
std::vector<std::wstring> arAddedSharedStrings; std::vector<std::wstring> arAddedSharedStrings;
struct _sheet_info
struct _sheet_size_info
{ {
std::wstring state;
std::wstring name;
std::map<int, double> customColumnsWidth; std::map<int, double> customColumnsWidth;
std::map<int, double> customRowsHeight; std::map<int, double> customRowsHeight;
double defaultColumnWidth = 8.0; double defaultColumnWidth = 8.0;
double defaultRowHeight = 14.4; double defaultRowHeight = 14.4;
bool bMacrosSheet = false;
}; };
std::vector<_sheet_size_info> sheet_size_info; std::vector<_sheet_info> sheets_info;
std::pair<float, float> defaultDigitFontSize; std::pair<float, float> defaultDigitFontSize;
CApplicationFonts *applicationFonts; CApplicationFonts *applicationFonts;
......
...@@ -140,8 +140,7 @@ static const int aCodePages[][2] = { ...@@ -140,8 +140,7 @@ static const int aCodePages[][2] = {
255, 850//OEM 255, 850//OEM
}; };
GlobalsSubstream::GlobalsSubstream(const unsigned short code_page) GlobalsSubstream::GlobalsSubstream(const unsigned short code_page) : code_page_(code_page)
: code_page_(code_page)
{ {
} }
...@@ -653,7 +652,20 @@ void GlobalsSubstream::UpdateXti() ...@@ -653,7 +652,20 @@ void GlobalsSubstream::UpdateXti()
{ {
if (info->rgst.empty() && index_book->nExternIndex < 0) if (info->rgst.empty() && index_book->nExternIndex < 0)
{ {
val.link = XMLSTUFF::xti_indexes2sheet_name(xti->itabFirst, xti->itabLast, global_info_->sheets_names); std::wstring strRange;
if(-1 == xti->itabFirst)
{
strRange = L"#REF";
}
else
{
strRange = XMLSTUFF::name2sheet_name(global_info_->sheets_info[xti->itabFirst].name, L"");
if (xti->itabFirst != xti->itabLast)
{
strRange += std::wstring(L":") + XMLSTUFF::name2sheet_name(global_info_->sheets_info[xti->itabLast].name, L"");
}
}
val.link = strRange;
} }
else else
{ {
......
...@@ -31,42 +31,43 @@ ...@@ -31,42 +31,43 @@
*/ */
#include "MacroSheetSubstream.h" #include "MacroSheetSubstream.h"
#include <Logic/Biff_records/BOF.h>
#include <Logic/Biff_records/Uncalced.h> #include "Biff_records/BOF.h"
#include <Logic/Biff_records/Index.h> #include "Biff_records/Uncalced.h"
#include <Logic/Biff_records/Intl.h> #include "Biff_records/Index.h"
#include <Logic/Biff_records/HeaderFooter.h> #include "Biff_records/Intl.h"
#include <Logic/Biff_records/Dimensions.h> #include "Biff_records/HeaderFooter.h"
#include <Logic/Biff_records/HFPicture.h> #include "Biff_records/Dimensions.h"
#include <Logic/Biff_records/Note.h> #include "Biff_records/HFPicture.h"
#include <Logic/Biff_records/DxGCol.h> #include "Biff_records/Note.h"
#include <Logic/Biff_records/CodeName.h> #include "Biff_records/DxGCol.h"
#include <Logic/Biff_records/CellWatch.h> #include "Biff_records/CodeName.h"
#include <Logic/Biff_records/SheetExt.h> #include "Biff_records/CellWatch.h"
#include <Logic/Biff_records/EOF.h> #include "Biff_records/SheetExt.h"
#include "Biff_records/EOF.h"
#include <Logic/Biff_unions/MACROSORTANDFILTER.h>
#include <Logic/Biff_unions/GLOBALS.h> #include "Biff_unions/MACROSORTANDFILTER.h"
#include <Logic/Biff_unions/PAGESETUP.h> #include "Biff_unions/GLOBALS.h"
#include <Logic/Biff_unions/BACKGROUND.h> #include "Biff_unions/PAGESETUP.h"
#include <Logic/Biff_unions/BIGNAME.h> #include "Biff_unions/BACKGROUND.h"
#include <Logic/Biff_unions/PROTECTION_COMMON.h> #include "Biff_unions/BIGNAME.h"
#include <Logic/Biff_unions/COLUMNS.h> #include "Biff_unions/PROTECTION_COMMON.h"
#include <Logic/Biff_unions/CELLTABLE.h> #include "Biff_unions/COLUMNS.h"
#include <Logic/Biff_unions/OBJECTS.h> #include "Biff_unions/CELLTABLE.h"
#include <Logic/Biff_unions/DCON.h> #include "Biff_unions/OBJECTS.h"
#include <Logic/Biff_unions/WINDOW.h> #include "Biff_unions/DCON.h"
#include <Logic/Biff_unions/CUSTOMVIEW.h> #include "Biff_unions/WINDOW.h"
#include <Logic/Biff_unions/SORT.h> #include "Biff_unions/CUSTOMVIEW.h"
#include <Logic/Biff_unions/PHONETICINFO.h> #include "Biff_unions/SORT.h"
#include <Logic/Biff_unions/FEAT.h> #include "Biff_unions/PHONETICINFO.h"
#include <Logic/Biff_unions/RECORD12.h> #include "Biff_unions/FEAT.h"
#include "Biff_unions/RECORD12.h"
namespace XLS namespace XLS
{; {;
MacroSheetSubstream::MacroSheetSubstream() MacroSheetSubstream::MacroSheetSubstream(const size_t ws_index) : ws_index_(ws_index)
{ {
} }
...@@ -98,38 +99,58 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc) ...@@ -98,38 +99,58 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
} }
global_info_ = proc.getGlobalWorkbookInfo(); global_info_ = proc.getGlobalWorkbookInfo();
GlobalWorkbookInfo::_sheet_size_info sheet_size_info; global_info_->current_sheet = global_info_->sheets_info.size();
global_info_->sheet_size_info.push_back(sheet_size_info);
global_info_->current_sheet = global_info_->sheet_size_info.size();
global_info_->sheet_size_info.back().bMacrosSheet = true;
proc.optional<Uncalced>(); proc.optional<Uncalced>();
proc.mandatory<Index>(); proc.mandatory<Index>();
proc.optional<Intl>(); proc.optional<Intl>();
GLOBALS globals(false); if (proc.mandatory<GLOBALS>())
if (proc.mandatory(globals)) // not dialog
{ {
m_GLOBALS = elements_.back(); m_GLOBALS = elements_.back();
elements_.pop_back(); elements_.pop_back();
} }
int count = 0; int count = 0;
proc.mandatory<PAGESETUP>(); if (proc.mandatory<PAGESETUP>())
{
m_PAGESETUP = elements_.back();
elements_.pop_back();
}
proc.optional<HeaderFooter>(); proc.optional<HeaderFooter>();
proc.optional<BACKGROUND>();
if (proc.optional<BACKGROUND>())
{
m_BACKGROUND = elements_.back();
elements_.pop_back();
}
proc.repeated<BIGNAME>(0, 0); proc.repeated<BIGNAME>(0, 0);
proc.optional<PROTECTION_COMMON>(); proc.optional<PROTECTION_COMMON>();
proc.mandatory<COLUMNS>();
proc.mandatory<MACROSORTANDFILTER>(); if (proc.mandatory<COLUMNS>())
proc.mandatory<Dimensions>(); {
m_COLUMNS = elements_.back();
elements_.pop_back();
}
if (proc.mandatory<MACROSORTANDFILTER>())
{
m_MACROSORTANDFILTER = elements_.back();
elements_.pop_back();
}
if (proc.mandatory<Dimensions>())
{
m_Dimensions = elements_.back();
elements_.pop_back();
}
std::vector<CellRangeRef> shared_formulas_locations; std::vector<CellRangeRef> shared_formulas_locations;
CELLTABLE cell_table(shared_formulas_locations); CELLTABLE cell_table(shared_formulas_locations);
proc.optional(cell_table); if (proc.optional(cell_table))
{
m_CELLTABLE = elements_.back();
elements_.pop_back();
}
OBJECTS objects(false); OBJECTS objects(false);
if (proc.mandatory(objects)) if (proc.mandatory(objects))
...@@ -138,10 +159,34 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc) ...@@ -138,10 +159,34 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
elements_.pop_back(); elements_.pop_back();
} }
proc.repeated<HFPicture>(0, 0); count = proc.repeated<HFPicture>(0, 0);
proc.repeated<Note>(0, 0); while(count > 0)
proc.optional<DCON>(); {
proc.repeated<WINDOW>(1, 0); m_arHFPicture.insert(m_arHFPicture.begin(), elements_.back());
elements_.pop_back();
count--;
}
count = proc.repeated<Note>(0, 0);
while(count > 0)
{
m_arNote.insert(m_arNote.begin(), elements_.back());
elements_.pop_back();
count--;
}
if (proc.optional<DCON>())
{
m_DCON = elements_.back();
elements_.pop_back();
}
count = proc.repeated<WINDOW>(0, 0);
while(count > 0)
{
m_arWINDOW.insert(m_arWINDOW.begin(), elements_.back());
elements_.pop_back();
count--;
}
count = proc.repeated<CUSTOMVIEW>(0, 0); count = proc.repeated<CUSTOMVIEW>(0, 0);
while(count > 0) while(count > 0)
...@@ -150,9 +195,24 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc) ...@@ -150,9 +195,24 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
elements_.pop_back(); elements_.pop_back();
count--; count--;
} }
proc.repeated<SORT>(0, 2); count = proc.repeated<SORT>(0, 2);
proc.optional<DxGCol>(); while(count > 0)
{
m_arSORT.insert(m_arSORT.begin(), elements_.back());
elements_.pop_back();
count--;
}
if (proc.optional<DxGCol>())
{
m_DxGCol = elements_.back();
elements_.pop_back();
DxGCol* dx = dynamic_cast<DxGCol*>(m_DxGCol.get());
global_info_->sheets_info.back().defaultColumnWidth = dx->dxgCol / 256.;
}
proc.optional<PHONETICINFO>(); proc.optional<PHONETICINFO>();
if (proc.optional<CodeName>()) if (proc.optional<CodeName>())
{ {
m_CodeName = elements_.back(); m_CodeName = elements_.back();
...@@ -164,8 +224,20 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc) ...@@ -164,8 +224,20 @@ const bool MacroSheetSubstream::loadContent(BinProcessor& proc)
m_SheetExt = elements_.back(); m_SheetExt = elements_.back();
elements_.pop_back(); elements_.pop_back();
} }
proc.repeated<FEAT>(0, 0); count = proc.repeated<FEAT> (0, 0);
proc.repeated<RECORD12>(0, 0); while(count > 0)
{
m_arFEAT.insert(m_arFEAT.begin(), elements_.back());
elements_.pop_back();
count--;
}
count = proc.repeated<RECORD12> (0, 0);
while(count > 0)
{
m_arRECORD12.insert(m_arRECORD12.begin(), elements_.back());
elements_.pop_back();
count--;
}
proc.mandatory<EOF_T>(); proc.mandatory<EOF_T>();
return true; return true;
......
...@@ -43,7 +43,7 @@ class MacroSheetSubstream: public CompositeObject ...@@ -43,7 +43,7 @@ class MacroSheetSubstream: public CompositeObject
{ {
BASE_OBJECT_DEFINE_CLASS_NAME(MacroSheetSubstream) BASE_OBJECT_DEFINE_CLASS_NAME(MacroSheetSubstream)
public: public:
MacroSheetSubstream(); MacroSheetSubstream(const size_t ws_index);
~MacroSheetSubstream(); ~MacroSheetSubstream();
BaseObjectPtr clone(); BaseObjectPtr clone();
...@@ -52,16 +52,29 @@ public: ...@@ -52,16 +52,29 @@ public:
static const ElementType type = typeMacroSheetSubstream; static const ElementType type = typeMacroSheetSubstream;
GlobalWorkbookInfoPtr global_info_;
size_t ws_index_;
BaseObjectPtr m_PAGESETUP;
BaseObjectPtr m_BACKGROUND;
BaseObjectPtr m_GLOBALS; BaseObjectPtr m_GLOBALS;
BaseObjectPtr m_OBJECTS; BaseObjectPtr m_OBJECTS;
std::vector<BaseObjectPtr> m_arCUSTOMVIEW;
BaseObjectPtr m_SheetExt; BaseObjectPtr m_SheetExt;
BaseObjectPtr m_CodeName; BaseObjectPtr m_CodeName;
BaseObjectPtr m_DxGCol;
BaseObjectPtr m_DCON;
BaseObjectPtr m_Dimensions;
BaseObjectPtr m_CELLTABLE;
BaseObjectPtr m_COLUMNS;
BaseObjectPtr m_MACROSORTANDFILTER;
GlobalWorkbookInfoPtr global_info_; std::vector<BaseObjectPtr> m_arWINDOW;
std::vector<BaseObjectPtr> m_arCUSTOMVIEW;
std::vector<BaseObjectPtr> m_arFEAT;
std::vector<BaseObjectPtr> m_arSORT;
std::vector<BaseObjectPtr> m_arHFPicture;
std::vector<BaseObjectPtr> m_arRECORD12;
std::vector<BaseObjectPtr> m_arNote;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -46,14 +46,12 @@ ...@@ -46,14 +46,12 @@
namespace XLS namespace XLS
{; {;
WorkbookStreamObject::WorkbookStreamObject() WorkbookStreamObject::WorkbookStreamObject() : code_page_(DefaultCodePage)
: code_page_(DefaultCodePage)
{ {
} }
WorkbookStreamObject::WorkbookStreamObject(const unsigned short code_page) WorkbookStreamObject::WorkbookStreamObject(const unsigned short code_page) : code_page_(code_page)
: code_page_(code_page)
{ {
} }
...@@ -76,16 +74,22 @@ BaseObjectPtr WorkbookStreamObject::clone() ...@@ -76,16 +74,22 @@ BaseObjectPtr WorkbookStreamObject::clone()
const bool WorkbookStreamObject::loadContent(BinProcessor& proc) const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
{ {
bool to_continue = true; GlobalWorkbookInfoPtr global_info_ = proc.getGlobalWorkbookInfo();
bool GlobalsSubstream_found = false; bool GlobalsSubstream_found = false;
bool WorksheetSubstream_found = false; bool WorksheetSubstream_found = false;
size_t ws_index = 0; size_t ws_index = 0;
while(to_continue) GlobalWorkbookInfo::_sheet_info sheet_info;
sheet_info.state = L"visible";
while(true)
{ {
unsigned short substream_type = 0; unsigned short substream_type = 0;
to_continue = proc.getNextSubstreamType(substream_type);
if (!proc.getNextSubstreamType(substream_type))
break;
switch(substream_type) switch(substream_type)
{ {
...@@ -115,6 +119,10 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -115,6 +119,10 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false; return false;
} }
Log::event("Worksheet or Dialog substream detected"); Log::event("Worksheet or Dialog substream detected");
if (ws_index >= global_info_->sheets_info.size())
global_info_->sheets_info.push_back(sheet_info);
WorksheetSubstream worksheet_substream(ws_index++); WorksheetSubstream worksheet_substream(ws_index++);
if ((proc.mandatory(worksheet_substream)) && (elements_.size() > 0)) if ((proc.mandatory(worksheet_substream)) && (elements_.size() > 0))
{ {
...@@ -132,11 +140,16 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -132,11 +140,16 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false; return false;
} }
Log::event("Chart substream detected"); Log::event("Chart substream detected");
if ((proc.mandatory<ChartSheetSubstream>()) && (elements_.size() > 0))
if (ws_index >= global_info_->sheets_info.size())
global_info_->sheets_info.push_back(sheet_info);
ChartSheetSubstream chartsheet_substream(ws_index++);
if ((proc.mandatory(chartsheet_substream)) && (elements_.size() > 0))
{ {
WorksheetSubstream_found = true; WorksheetSubstream_found = true;
m_arWorksheetSubstream.push_back(elements_.back()); elements_.pop_back(); m_arChartSheetSubstream.push_back(elements_.back()); elements_.pop_back();
} }
} }
break; break;
...@@ -148,7 +161,12 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc) ...@@ -148,7 +161,12 @@ const bool WorkbookStreamObject::loadContent(BinProcessor& proc)
return false; return false;
} }
Log::event("Macro substream detected"); Log::event("Macro substream detected");
if ((proc.mandatory<MacroSheetSubstream>()) && (elements_.size() > 0))
if (ws_index >= global_info_->sheets_info.size())
global_info_->sheets_info.push_back(sheet_info);
MacroSheetSubstream macrosheet_substream(ws_index++);
if ((proc.mandatory(macrosheet_substream)) && (elements_.size() > 0))
{ {
WorksheetSubstream_found = true; WorksheetSubstream_found = true;
......
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
std::vector<BaseObjectPtr> m_arWorksheetSubstream; std::vector<BaseObjectPtr> m_arWorksheetSubstream;
std::vector<BaseObjectPtr> m_arMacroSheetSubstream; std::vector<BaseObjectPtr> m_arMacroSheetSubstream;
std::vector<BaseObjectPtr> m_arChartSheetSubstream;
unsigned short code_page_; unsigned short code_page_;
}; };
......
...@@ -81,8 +81,7 @@ namespace XLS ...@@ -81,8 +81,7 @@ namespace XLS
{; {;
WorksheetSubstream::WorksheetSubstream(const size_t ws_index) WorksheetSubstream::WorksheetSubstream(const size_t ws_index) : ws_index_(ws_index)
: ws_index_(ws_index)
{ {
} }
...@@ -110,10 +109,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -110,10 +109,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
{ {
global_info_ = proc.getGlobalWorkbookInfo(); global_info_ = proc.getGlobalWorkbookInfo();
GlobalWorkbookInfo::_sheet_size_info sheet_size_info; global_info_->current_sheet = global_info_->sheets_info.size();
global_info_->sheet_size_info.push_back(sheet_size_info);
global_info_->current_sheet = global_info_->sheet_size_info.size();
global_info_->cmt_rules = 0; global_info_->cmt_rules = 0;
...@@ -145,8 +141,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -145,8 +141,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
case rt_CalcMode: case rt_CalcMode:
case rt_PrintRowCol: case rt_PrintRowCol:
{ {
GLOBALS globals(false); if (proc.mandatory<GLOBALS>())
if (proc.mandatory(globals))
{ {
m_GLOBALS = elements_.back(); m_GLOBALS = elements_.back();
elements_.pop_back(); elements_.pop_back();
...@@ -336,7 +331,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -336,7 +331,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
elements_.pop_back(); elements_.pop_back();
DxGCol* dx = dynamic_cast<DxGCol*>(m_DxGCol.get()); DxGCol* dx = dynamic_cast<DxGCol*>(m_DxGCol.get());
global_info_->sheet_size_info.back().defaultColumnWidth = dx->dxgCol / 256.; global_info_->sheets_info.back().defaultColumnWidth = dx->dxgCol / 256.;
} }
}break; }break;
case rt_MergeCells: case rt_MergeCells:
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "../XlsFormat/Logic/WorksheetSubstream.h" #include "../XlsFormat/Logic/WorksheetSubstream.h"
#include "../XlsFormat/Logic/GlobalsSubstream.h" #include "../XlsFormat/Logic/GlobalsSubstream.h"
#include "../XlsFormat/Logic/ChartSheetSubstream.h" #include "../XlsFormat/Logic/ChartSheetSubstream.h"
#include "../XlsFormat/Logic/MacroSheetSubstream.h"
#include "../XlsFormat/Logic/BinProcessor.h" #include "../XlsFormat/Logic/BinProcessor.h"
#include "../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h" #include "../XlsFormat/Logic/SummaryInformationStream/SummaryInformation.h"
...@@ -71,6 +72,7 @@ ...@@ -71,6 +72,7 @@
#include "../XlsFormat/Logic/Biff_records/TxO.h" #include "../XlsFormat/Logic/Biff_records/TxO.h"
#include "../XlsFormat/Logic/Biff_records/IMDATA.h" #include "../XlsFormat/Logic/Biff_records/IMDATA.h"
#include "../XlsFormat/Logic/Biff_records/Note.h" #include "../XlsFormat/Logic/Biff_records/Note.h"
#include "../XlsFormat/Logic/Biff_records/WsBool.h"
#include "../XlsFormat/Logic/Biff_structures/URLMoniker.h" #include "../XlsFormat/Logic/Biff_structures/URLMoniker.h"
#include "../XlsFormat/Logic/Biff_structures/FileMoniker.h" #include "../XlsFormat/Logic/Biff_structures/FileMoniker.h"
...@@ -382,7 +384,7 @@ void XlsConverter::convert(XLS::BaseObject *xls_unknown) ...@@ -382,7 +384,7 @@ void XlsConverter::convert(XLS::BaseObject *xls_unknown)
case XLS::typeOBJECTS: case XLS::typeOBJECTS:
{ {
XLS::OBJECTS * obj = dynamic_cast<XLS::OBJECTS*>(xls_unknown); XLS::OBJECTS * obj = dynamic_cast<XLS::OBJECTS*>(xls_unknown);
convert(obj); convert(obj, NULL);
}break; }break;
case XLS::typeTxO: case XLS::typeTxO:
{ {
...@@ -412,34 +414,25 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook) ...@@ -412,34 +414,25 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook)
convert(dynamic_cast<XLS::GlobalsSubstream*>(woorkbook->m_GlobalsSubstream.get())); convert(dynamic_cast<XLS::GlobalsSubstream*>(woorkbook->m_GlobalsSubstream.get()));
int count_sheets = 0, count_chart_sheets = 0;
for (size_t i = 0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++) for (size_t i = 0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++)
{ {
if (woorkbook->m_arWorksheetSubstream[i]->get_type() == XLS::typeWorksheetSubstream) xlsx_context->start_table();
{
count_sheets++;
xls_global_info->current_sheet = count_sheets;
xlsx_context->start_table(xls_global_info->sheets_names.size() > i ? xls_global_info->sheets_names[i] : L"Sheet_" + std::to_wstring(count_sheets));
xlsx_context->set_state(xls_global_info->sheets_state.size() > i ? xls_global_info->sheets_state[i] : L"visible");
convert(dynamic_cast<XLS::WorksheetSubstream*>(woorkbook->m_arWorksheetSubstream[i].get())); convert(dynamic_cast<XLS::WorksheetSubstream*>(woorkbook->m_arWorksheetSubstream[i].get()));
xlsx_context->end_table();
} }
else if (woorkbook->m_arWorksheetSubstream[i]->get_type() == XLS::typeChartSheetSubstream) for (size_t i = 0 ; i < woorkbook->m_arChartSheetSubstream.size(); i++)
{ {
count_chart_sheets++; xlsx_context->start_table();
xls_global_info->current_sheet = -1; convert_chart_sheet(dynamic_cast<XLS::ChartSheetSubstream*>(woorkbook->m_arChartSheetSubstream[i].get()));
xlsx_context->start_table(xls_global_info->sheets_names.size() > i ? xls_global_info->sheets_names[i] : L"ChartSheet_" + std::to_wstring(count_chart_sheets)); xlsx_context->end_table();
xlsx_context->set_chart_view();
XLS::ChartSheetSubstream* chart = dynamic_cast<XLS::ChartSheetSubstream*>(woorkbook->m_arWorksheetSubstream[i].get());
convert_chart_sheet(chart);
} }
for (size_t i = 0 ; i < woorkbook->m_arMacroSheetSubstream.size(); i++)
{
xlsx_context->start_table();
convert(dynamic_cast<XLS::MacroSheetSubstream*>(woorkbook->m_arMacroSheetSubstream[i].get()));
xlsx_context->end_table(); xlsx_context->end_table();
} }
for (std::list<XLS::BaseObjectPtr>::iterator it = woorkbook->elements_.begin(); it != woorkbook->elements_.end(); it++) for (std::list<XLS::BaseObjectPtr>::iterator it = woorkbook->elements_.begin(); it != woorkbook->elements_.end(); it++)
{ {
convert(it->get()); convert(it->get());
...@@ -452,6 +445,17 @@ void XlsConverter::convert (XLS::WorksheetSubstream* sheet) ...@@ -452,6 +445,17 @@ void XlsConverter::convert (XLS::WorksheetSubstream* sheet)
{ {
if (sheet == NULL) return; if (sheet == NULL) return;
xls_global_info->current_sheet = sheet->ws_index_ + 1;
std::wstring name = xls_global_info->sheets_info[sheet->ws_index_].name;
if (name.empty())
name = L"Sheet_" + std::to_wstring(sheet->ws_index_ + 1);
xlsx_context->set_table_type(1);
xlsx_context->set_table_name(name) ;
xlsx_context->set_table_id(sheet->ws_index_ + 1);
xlsx_context->set_table_state(xls_global_info->sheets_info[sheet->ws_index_].state);
if (!sheet->m_arWINDOW.empty()) if (!sheet->m_arWINDOW.empty())
{ {
sheet->m_arWINDOW[0]->serialize(xlsx_context->current_sheet().sheetViews()); sheet->m_arWINDOW[0]->serialize(xlsx_context->current_sheet().sheetViews());
...@@ -475,6 +479,9 @@ void XlsConverter::convert (XLS::WorksheetSubstream* sheet) ...@@ -475,6 +479,9 @@ void XlsConverter::convert (XLS::WorksheetSubstream* sheet)
globals->m_DxGCol = sheet->m_DxGCol; globals->m_DxGCol = sheet->m_DxGCol;
sheet->m_GLOBALS->serialize(xlsx_context->current_sheet().sheetFormat()); sheet->m_GLOBALS->serialize(xlsx_context->current_sheet().sheetFormat());
if (globals->is_dialog)
xlsx_context->set_table_type(2);
} }
if (sheet->m_COLUMNS) if (sheet->m_COLUMNS)
{ {
...@@ -575,6 +582,102 @@ void XlsConverter::convert (XLS::WorksheetSubstream* sheet) ...@@ -575,6 +582,102 @@ void XlsConverter::convert (XLS::WorksheetSubstream* sheet)
} }
} }
void XlsConverter::convert (XLS::MacroSheetSubstream* sheet)
{
if (sheet == NULL) return;
xls_global_info->current_sheet = sheet->ws_index_ + 1;
std::wstring name = xls_global_info->sheets_info[sheet->ws_index_].name;
if (name.empty())
name = L"MacroSheet_" + std::to_wstring(sheet->ws_index_ + 1);
xlsx_context->set_table_type(4);
xlsx_context->set_table_name(name) ;
xlsx_context->set_table_id(sheet->ws_index_ + 1);
xlsx_context->set_table_state(xls_global_info->sheets_info[sheet->ws_index_].state);
if (!sheet->m_arWINDOW.empty())
{
sheet->m_arWINDOW[0]->serialize(xlsx_context->current_sheet().sheetViews());
}
if (sheet->m_Dimensions)
{
sheet->m_Dimensions->serialize(xlsx_context->current_sheet().dimension());
}
//sheet->serialize_format(xlsx_context->current_sheet().sheetProperties());
if (sheet->m_GLOBALS)
{
XLS::GLOBALS * globals = dynamic_cast<XLS::GLOBALS *>(sheet->m_GLOBALS.get());
XLS::COLUMNS * columns = dynamic_cast<XLS::COLUMNS *>(sheet->m_COLUMNS.get());
if (columns)
{
globals->m_DefColWidth = columns->m_DefColWidth;
}
globals->m_DxGCol = sheet->m_DxGCol;
sheet->m_GLOBALS->serialize(xlsx_context->current_sheet().sheetFormat());
}
if (sheet->m_COLUMNS)
{
sheet->m_COLUMNS->serialize(xlsx_context->current_sheet().cols());
}
if (sheet->m_CELLTABLE)
{
sheet->m_CELLTABLE->serialize(xlsx_context->current_sheet().sheetData());
}
convert((XLS::OBJECTS*)sheet->m_OBJECTS.get(), NULL);
if (!sheet->m_arNote.empty() && xls_global_info->Version < 0x0600)
{
xlsx_context->get_drawing_context().start_drawing(0);
for (size_t i = 0 ; i < sheet->m_arNote.size(); i++)
{
xlsx_context->get_drawing_context().start_drawing(0x0019);
convert(dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get()));
xlsx_context->get_drawing_context().end_drawing();
}
xlsx_context->get_drawing_context().end_group();
}
if (sheet->m_PAGESETUP)
{
sheet->m_PAGESETUP->serialize(xlsx_context->current_sheet().pageProperties());
}
//for (size_t i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
//{
// //convert(dynamic_cast<XLS::Note*>(sheet->sheet->m_arHFPictureDrawing[i].get(),
//}
if (sheet->m_arCUSTOMVIEW.size() > 0)
{
CP_XML_WRITER(xlsx_context->current_sheet().customViews())
{
CP_XML_NODE(L"customSheetViews")
{
for (size_t i = 0 ; i < sheet->m_arCUSTOMVIEW.size(); i++)
{
sheet->m_arCUSTOMVIEW[i]->serialize(CP_XML_STREAM());
}
}
}
}
if (sheet->m_BACKGROUND)
{
convert(dynamic_cast<XLS::BACKGROUND*>(sheet->m_BACKGROUND.get()));
}
//for (size_t i = 0 ; i < sheet->m_arHFPictureDrawing.size(); i++)
//{
// convert((ODRAW::OfficeArtDgContainer*)sheet->m_arHFPictureDrawing[i].get());
//}
}
void XlsConverter::convert(XLS::GlobalsSubstream* globals) void XlsConverter::convert(XLS::GlobalsSubstream* globals)
{ {
if (globals == NULL) return; if (globals == NULL) return;
...@@ -1112,7 +1215,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee ...@@ -1112,7 +1215,7 @@ void XlsConverter::convert(XLS::OBJECTS* objects, XLS::WorksheetSubstream * shee
{ {
text_obj->preserve_enabled = true; text_obj->preserve_enabled = true;
for (size_t i = 0 ; i < sheet->m_arNote.size(); i++) for (size_t i = 0 ; sheet && i < sheet->m_arNote.size(); i++)
{ {
XLS::Note* note = dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get()); XLS::Note* note = dynamic_cast<XLS::Note*>(sheet->m_arNote[i].get());
if ((note) && (note->note_sh.idObj == obj->cmo.id)) if ((note) && (note->note_sh.idObj == obj->cmo.id))
...@@ -2104,14 +2207,25 @@ void XlsConverter::convert(XLS::Obj * obj) ...@@ -2104,14 +2207,25 @@ void XlsConverter::convert(XLS::Obj * obj)
} }
} }
void XlsConverter::convert_chart_sheet(XLS::ChartSheetSubstream* chart) void XlsConverter::convert_chart_sheet(XLS::ChartSheetSubstream* chartsheet)
{ {
if (chart == NULL) return; if (chartsheet == NULL) return;
xls_global_info->current_sheet = chartsheet->ws_index_ + 1;
std::wstring name = xls_global_info->sheets_info[chartsheet->ws_index_].name;
if (name.empty())
name = L"ChartSheet_" + std::to_wstring(chartsheet->ws_index_ + 1);
xlsx_context->set_table_type(3);
xlsx_context->set_table_name(name) ;
xlsx_context->set_table_id(chartsheet->ws_index_ + 1);
xlsx_context->set_table_state(xls_global_info->sheets_info[chartsheet->ws_index_].state);
if (xlsx_context->get_drawing_context().start_drawing(0x0005)) if (xlsx_context->get_drawing_context().start_drawing(0x0005))
{ {
xlsx_context->get_drawing_context().set_id(1); xlsx_context->get_drawing_context().set_id(1);
convert(chart); convert(chartsheet);
xlsx_context->get_drawing_context().end_drawing(); xlsx_context->get_drawing_context().end_drawing();
} }
......
...@@ -63,6 +63,7 @@ namespace XLS ...@@ -63,6 +63,7 @@ namespace XLS
class WorksheetSubstream; class WorksheetSubstream;
class GlobalsSubstream; class GlobalsSubstream;
class ChartSheetSubstream; class ChartSheetSubstream;
class MacroSheetSubstream;
class BACKGROUND; class BACKGROUND;
class FORMATTING; class FORMATTING;
...@@ -113,6 +114,7 @@ public: ...@@ -113,6 +114,7 @@ public:
void convert(XLS::WorksheetSubstream * sheet); void convert(XLS::WorksheetSubstream * sheet);
void convert(XLS::ChartSheetSubstream * chart); void convert(XLS::ChartSheetSubstream * chart);
void convert(XLS::GlobalsSubstream * elem); void convert(XLS::GlobalsSubstream * elem);
void convert(XLS::MacroSheetSubstream * chart);
void convert(XLS::FORMATTING * formating); void convert(XLS::FORMATTING * formating);
void convert(XLS::THEME * theme); void convert(XLS::THEME * theme);
......
...@@ -64,7 +64,6 @@ public: ...@@ -64,7 +64,6 @@ public:
void set_main_document(document * _document) { document_ = _document; } void set_main_document(document * _document) { document_ = _document; }
document * get_main_document() { return document_; } document * get_main_document() { return document_; }
public:
virtual void write(const std::wstring & RootPath) = 0; virtual void write(const std::wstring & RootPath) = 0;
private: private:
......
...@@ -118,28 +118,42 @@ oox_activeX_context & xlsx_conversion_context::current_activeX() ...@@ -118,28 +118,42 @@ oox_activeX_context & xlsx_conversion_context::current_activeX()
throw std::runtime_error("internal error"); throw std::runtime_error("internal error");
} }
} }
bool xlsx_conversion_context::start_table(const std::wstring & name) bool xlsx_conversion_context::start_table()
{ {
sheets_.push_back(xlsx_xml_worksheet::create(name)); sheets_.push_back(xlsx_xml_worksheet::create());
get_table_context().start_table(name); get_table_context().start_table();
return true; return true;
} }
void xlsx_conversion_context::set_chart_view() void xlsx_conversion_context::set_table_type(int type)
{ {
if (sheets_.empty()) return; if (sheets_.empty()) return;
sheets_.back()->type = type;
if (type == 3)
{
get_table_context().set_chart_view(); get_table_context().set_chart_view();
}
} }
void xlsx_conversion_context::set_table_name(const std::wstring & name)
{
if (name.empty()) return;
void xlsx_conversion_context::set_state(const std::wstring & state) sheets_.back()->name = name;
}
void xlsx_conversion_context::set_table_state(const std::wstring & state)
{ {
if (state.empty()) return; if (state.empty()) return;
sheets_.back()->set_state(state); sheets_.back()->state = state;
}
void xlsx_conversion_context::set_table_id(int id)
{
if (id < 0) return;
sheets_.back()->id = id;
} }
void xlsx_conversion_context::start_chart() void xlsx_conversion_context::start_chart()
{ {
charts_.push_back(oox_chart_context::create()); charts_.push_back(oox_chart_context::create());
...@@ -215,17 +229,15 @@ void xlsx_conversion_context::end_document() ...@@ -215,17 +229,15 @@ void xlsx_conversion_context::end_document()
{ {
std::wstringstream workbook_content; std::wstringstream workbook_content;
unsigned int count = 0;
for (size_t i = 0; i < sheets_.size(); i++) for (size_t i = 0; i < sheets_.size(); i++)
{ {
xlsx_xml_worksheet_ptr & sheet = sheets_[i];
count++;
const std::wstring slideRId = std::wstring(L"sId") + std::to_wstring(count);
package::sheet_content_ptr content = package::sheet_content::create(); package::sheet_content_ptr content = package::sheet_content::create();
const std::wstring slideRId = std::wstring(L"sId") + std::to_wstring(i + 1);
content->set_rId(slideRId);
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
const std::pair<std::wstring, std::wstring> p1 = sheet->get_drawing_link(); const std::pair<std::wstring, std::wstring> p1 = sheets_[i]->get_drawing_link();
if (!p1.first.empty()) if (!p1.first.empty())
{ {
...@@ -235,9 +247,9 @@ void xlsx_conversion_context::end_document() ...@@ -235,9 +247,9 @@ void xlsx_conversion_context::end_document()
content->add_rel(relationship(dId, kType, dName)); content->add_rel(relationship(dId, kType, dName));
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
content->add_rels(sheet->sheet_rels()); content->add_rels(sheets_[i]->sheet_rels());
///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
const std::pair<std::wstring, std::wstring> p2 = sheet->get_comments_link(); const std::pair<std::wstring, std::wstring> p2 = sheets_[i]->get_comments_link();
if (!p2.first.empty()) if (!p2.first.empty())
{ {
const std::wstring dId = p2.second; const std::wstring dId = p2.second;
...@@ -246,7 +258,7 @@ void xlsx_conversion_context::end_document() ...@@ -246,7 +258,7 @@ void xlsx_conversion_context::end_document()
content->add_rel(relationship(dId, kType, dName)); content->add_rel(relationship(dId, kType, dName));
} }
const std::pair<std::wstring, std::wstring> p3 = sheet->get_vml_drawing_link(); const std::pair<std::wstring, std::wstring> p3 = sheets_[i]->get_vml_drawing_link();
if (!p3.first.empty()) if (!p3.first.empty())
{ {
const std::wstring dId = p3.second; const std::wstring dId = p3.second;
...@@ -255,7 +267,7 @@ void xlsx_conversion_context::end_document() ...@@ -255,7 +267,7 @@ void xlsx_conversion_context::end_document()
content->add_rel(relationship(dId, kType, dName)); content->add_rel(relationship(dId, kType, dName));
} }
const std::pair<std::wstring, std::wstring> p4 = sheet->get_vml_drawing_HF_link(); const std::pair<std::wstring, std::wstring> p4 = sheets_[i]->get_vml_drawing_HF_link();
if (!p4.first.empty()) if (!p4.first.empty())
{ {
const std::wstring dId = p4.second; const std::wstring dId = p4.second;
...@@ -264,22 +276,24 @@ void xlsx_conversion_context::end_document() ...@@ -264,22 +276,24 @@ void xlsx_conversion_context::end_document()
content->add_rel(relationship(dId, kType, dName)); content->add_rel(relationship(dId, kType, dName));
} }
///////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////
sheet->write_to(content->content()); sheets_[i]->write_to(content->content());
output_document_->get_xl_files().add_sheet(content);
output_document_->get_xl_files().add_sheet(sheets_[i]->type, content);
///////////////////////////////////////////// /////////////////////////////////////////////
CP_XML_WRITER(workbook_content) CP_XML_WRITER(workbook_content)
{ {
CP_XML_NODE(L"sheet") CP_XML_NODE(L"sheet")
{ {
CP_XML_ATTR(L"name", sheet->name()); CP_XML_ATTR(L"name", sheets_[i]->name);
CP_XML_ATTR(L"sheetId", count); CP_XML_ATTR(L"sheetId", sheets_[i]->id);
CP_XML_ATTR(L"state", sheet->state() ); CP_XML_ATTR(L"state", sheets_[i]->state);
CP_XML_ATTR(L"r:id", slideRId); CP_XML_ATTR(L"r:id", slideRId);
} }
} }
} }
unsigned int count = 0;
for (size_t i = 0; i < activeXs_.size(); i++) for (size_t i = 0; i < activeXs_.size(); i++)
{ {
package::activeX_content_ptr content = package::activeX_content::create(); package::activeX_content_ptr content = package::activeX_content::create();
......
...@@ -66,9 +66,11 @@ public: ...@@ -66,9 +66,11 @@ public:
void start_document(); void start_document();
void end_document(); void end_document();
bool start_table(const std::wstring & name); bool start_table();
void set_state(const std::wstring & state); void set_table_state(const std::wstring & state);
void set_chart_view(); void set_table_type(int type);
void set_table_name(const std::wstring & name);
void set_table_id(int id);
void end_table(); void end_table();
void start_chart(); void start_chart();
......
...@@ -37,18 +37,14 @@ ...@@ -37,18 +37,14 @@
namespace oox { namespace oox {
/// \class xlsx_xml_worksheet::Impl
class xlsx_xml_worksheet::Impl class xlsx_xml_worksheet::Impl
{ {
public: public:
Impl(std::wstring const & name) : name_(name) Impl()
{ {
state_ = L"visible";
} }
std::wstring name_;
std::wstring state_;
std::wstringstream cols_; std::wstringstream cols_;
std::wstringstream sheetPr_; std::wstringstream sheetPr_;
std::wstringstream sheetFormatPr_; std::wstringstream sheetFormatPr_;
...@@ -83,21 +79,12 @@ public: ...@@ -83,21 +79,12 @@ public:
std::wstring vml_HF_drawingId_; std::wstring vml_HF_drawingId_;
}; };
std::wstring xlsx_xml_worksheet::name() const xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create()
{
return impl_->name_;
}
std::wstring xlsx_xml_worksheet::state() const
{ {
return impl_->state_; return boost::make_shared<xlsx_xml_worksheet>();
}
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name)
{
return boost::make_shared<xlsx_xml_worksheet>(name);
} }
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name) xlsx_xml_worksheet::xlsx_xml_worksheet() : impl_(new xlsx_xml_worksheet::Impl()), type(1), id(0)
: impl_(new xlsx_xml_worksheet::Impl(name))
{ {
} }
...@@ -186,12 +173,25 @@ rels & xlsx_xml_worksheet::sheet_rels() ...@@ -186,12 +173,25 @@ rels & xlsx_xml_worksheet::sheet_rels()
} }
void xlsx_xml_worksheet::write_to(std::wostream & strm) void xlsx_xml_worksheet::write_to(std::wostream & strm)
{ {
std::wstring node_name;
switch(type)
{
case 2: node_name = L"dialogsheet"; break;
case 3: node_name = L"chartsheet"; break;
case 4: node_name = L"xm:macrosheet"; break;
case 1:
default: node_name = L"worksheet"; break;
}
CP_XML_WRITER(strm) CP_XML_WRITER(strm)
{ {
CP_XML_NODE(L"worksheet") CP_XML_NODE(node_name)
{ {
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main"); 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:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
if (type == 4)
{
CP_XML_ATTR(L"xmlns:xm", L"http://schemas.microsoft.com/office/excel/2006/main");
}
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006"); CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
CP_XML_ATTR(L"xmlns:x14", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"); CP_XML_ATTR(L"xmlns:x14", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
...@@ -266,10 +266,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm) ...@@ -266,10 +266,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
} }
} }
} }
void xlsx_xml_worksheet::set_state (std::wstring const & state)
{
impl_->state_ = state;
}
void xlsx_xml_worksheet::set_drawing_link(std::wstring const & fileName, std::wstring const & id) void xlsx_xml_worksheet::set_drawing_link(std::wstring const & fileName, std::wstring const & id)
{ {
impl_->drawingName_ = fileName; impl_->drawingName_ = fileName;
......
...@@ -45,11 +45,13 @@ typedef boost::shared_ptr<xlsx_xml_worksheet> xlsx_xml_worksheet_ptr; ...@@ -45,11 +45,13 @@ typedef boost::shared_ptr<xlsx_xml_worksheet> xlsx_xml_worksheet_ptr;
class xlsx_xml_worksheet: boost::noncopyable class xlsx_xml_worksheet: boost::noncopyable
{ {
public: public:
xlsx_xml_worksheet(std::wstring const & name); xlsx_xml_worksheet();
~xlsx_xml_worksheet(); ~xlsx_xml_worksheet();
public:
std::wstring name() const; std::wstring name;
std::wstring state() const; std::wstring state;
int type;
int id;
std::wostream & dimension(); std::wostream & dimension();
std::wostream & sheetViews(); std::wostream & sheetViews();
...@@ -77,7 +79,6 @@ public: ...@@ -77,7 +79,6 @@ public:
void set_drawing_link (std::wstring const & fileName, std::wstring const & id); void set_drawing_link (std::wstring const & fileName, std::wstring const & id);
void set_vml_drawing_link (std::wstring const & fileName, std::wstring const & id); void set_vml_drawing_link (std::wstring const & fileName, std::wstring const & id);
void set_comments_link (std::wstring const & fileName, std::wstring const & id); void set_comments_link (std::wstring const & fileName, std::wstring const & id);
void set_state (std::wstring const & state);
void set_vml_HF_drawing_link(std::wstring const & fileName, std::wstring const & id); void set_vml_HF_drawing_link(std::wstring const & fileName, std::wstring const & id);
std::pair<std::wstring, std::wstring> get_drawing_link() const; std::pair<std::wstring, std::wstring> get_drawing_link() const;
...@@ -85,7 +86,7 @@ public: ...@@ -85,7 +86,7 @@ public:
std::pair<std::wstring, std::wstring> get_vml_drawing_HF_link() const; std::pair<std::wstring, std::wstring> get_vml_drawing_HF_link() const;
std::pair<std::wstring, std::wstring> get_comments_link() const; std::pair<std::wstring, std::wstring> get_comments_link() const;
static xlsx_xml_worksheet_ptr create(std::wstring const & name); static xlsx_xml_worksheet_ptr create();
private: private:
class Impl; class Impl;
......
...@@ -162,32 +162,62 @@ void sheet_content::add_rels(rels & r) ...@@ -162,32 +162,62 @@ void sheet_content::add_rels(rels & r)
sheets_files::sheets_files() sheets_files::sheets_files()
{} {}
void sheets_files::add_sheet(sheet_content_ptr sheet) void sheets_files::add_sheet(int type, sheet_content_ptr sheet)
{ {
sheets_.push_back(sheet); switch(type)
{
case 2: dialogsheets_.push_back(sheet); break;
case 3: chartsheets_.push_back(sheet); break;
case 4: macrosheets_.push_back(sheet); break;
case 1:
default: worksheets_.push_back(sheet); break;
}
} }
void sheets_files::write(const std::wstring & RootPath) void sheets_files::write(const std::wstring & RootPath)
{ {
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"worksheets"; int id = 0;
write_(worksheets_, id, RootPath, L"worksheet", L"sheet",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
L"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml");
write_(dialogsheets_,id, RootPath, L"dialogsheet", L"sheet",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet",
L"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml");
write_(chartsheets_, id, RootPath, L"chartsheet", L"sheet",
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",
L"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml");
write_(macrosheets_, id, RootPath, L"macrosheet", L"intlsheet",
L"http://schemas.microsoft.com/office/2006/relationships/xlIntlMacrosheet",
L"application/vnd.ms-excel.intlmacrosheet+xml");
}
void sheets_files::write_(std::vector<sheet_content_ptr> & sheets_, int & id,
const std::wstring & RootPath, const std::wstring & local, const std::wstring & name,
const std::wstring & rels_type, const std::wstring & content_type)
{
if (sheets_.empty()) return;
std::wstring path = RootPath + FILE_SEPARATOR_STR + local + L"s";
NSDirectory::CreateDirectory(path.c_str()); NSDirectory::CreateDirectory(path.c_str());
for (size_t i = 0; i < sheets_.size(); i++) oox::content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
for (size_t i = 0; i < sheets_.size(); i++, id++)
{ {
if (!sheets_[i]) continue; if (!sheets_[i]) continue;
const std::wstring fileName = std::wstring(L"sheet") + std::to_wstring(i + 1) + L".xml"; const std::wstring fileName = name + std::to_wstring(i + 1) + L".xml";
content_type & contentTypes = this->get_main_document()->content_type().get_content_type();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"; contentTypes.add_override(L"/xl/" + local + L"s/" + fileName, content_type);
contentTypes.add_override(std::wstring(L"/xl/worksheets/") + fileName, kWSConType);
if (rels_) if (rels_)
{ {
const std::wstring id = std::wstring(L"sId") + std::to_wstring(i + 1); std::wstring fileRef = local + L"s/" + fileName;
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"; rels_->add(sheets_[i]->get_rId(), rels_type, fileRef);
const std::wstring fileRef = std::wstring(L"worksheets/") + fileName;
rels_->add(id, kWSRel, fileRef);
} }
sheets_[i]->get_rel_file()->set_file_name(fileName + L".rels"); sheets_[i]->get_rel_file()->set_file_name(fileName + L".rels");
...@@ -346,9 +376,9 @@ void xl_files::set_connections(element_ptr Element) ...@@ -346,9 +376,9 @@ void xl_files::set_connections(element_ptr Element)
connections_ = Element; connections_ = Element;
} }
void xl_files::add_sheet(sheet_content_ptr sheet) void xl_files::add_sheet(int type, sheet_content_ptr sheet)
{ {
sheets_files_.add_sheet(sheet); sheets_files_.add_sheet(type, sheet);
} }
void xl_files::set_media(external_items & _Mediaitems) void xl_files::set_media(external_items & _Mediaitems)
......
...@@ -50,15 +50,22 @@ public: ...@@ -50,15 +50,22 @@ public:
class sheet_content : boost::noncopyable class sheet_content : boost::noncopyable
{ {
public: public:
static _CP_PTR(sheet_content) create();
sheet_content(); sheet_content();
std::wostream & content() { return content_; }
void add_rel(relationship const & r); void add_rel(relationship const & r);
void add_rels(rels & r); void add_rels(rels & r);
rels_file_ptr get_rel_file() { return rels_; } rels_file_ptr get_rel_file() { return rels_; }
std::wostream & content() { return content_; }
std::wstring str() { return content_.str(); } std::wstring str() { return content_.str(); }
static _CP_PTR(sheet_content) create();
void set_rId(std::wstring rid) {rId_ = rid;}
std::wstring get_rId() {return rId_;}
private: private:
std::wstring rId_;
std::wstringstream content_; std::wstringstream content_;
rels_file_ptr rels_; rels_file_ptr rels_;
}; };
...@@ -126,7 +133,7 @@ class sheets_files : public element ...@@ -126,7 +133,7 @@ class sheets_files : public element
public: public:
sheets_files(); sheets_files();
void add_sheet(sheet_content_ptr sheet); void add_sheet(int type, sheet_content_ptr sheet);
void set_rels(rels_files * rels) void set_rels(rels_files * rels)
{ {
...@@ -135,7 +142,15 @@ public: ...@@ -135,7 +142,15 @@ public:
virtual void write(const std::wstring & RootPath); virtual void write(const std::wstring & RootPath);
std::vector<sheet_content_ptr> sheets_; std::vector<sheet_content_ptr> worksheets_;
std::vector<sheet_content_ptr> dialogsheets_;
std::vector<sheet_content_ptr> macrosheets_;
std::vector<sheet_content_ptr> chartsheets_;
private:
void write_(std::vector<sheet_content_ptr> & sheets_, int & id,
const std::wstring & RootPath, const std::wstring & local, const std::wstring & name,
const std::wstring & rels_type, const std::wstring & content_type);
rels_files * rels_; rels_files * rels_;
}; };
...@@ -295,7 +310,7 @@ public: ...@@ -295,7 +310,7 @@ public:
void set_styles (element_ptr Element); void set_styles (element_ptr Element);
void set_sharedStrings (element_ptr Element); void set_sharedStrings (element_ptr Element);
void set_connections (element_ptr Element); void set_connections (element_ptr Element);
void add_sheet (sheet_content_ptr sheet); void add_sheet (int type, sheet_content_ptr sheet);
void set_media (external_items & _Mediaitems); void set_media (external_items & _Mediaitems);
void set_drawings (element_ptr Element); void set_drawings (element_ptr Element);
void set_vml_drawings (element_ptr Element); void set_vml_drawings (element_ptr Element);
......
...@@ -55,7 +55,7 @@ xlsx_table_context::xlsx_table_context(xlsx_conversion_context & Context) : cont ...@@ -55,7 +55,7 @@ xlsx_table_context::xlsx_table_context(xlsx_conversion_context & Context) : cont
{ {
} }
void xlsx_table_context::start_table(const std::wstring & name) void xlsx_table_context::start_table()
{ {
tables_state_.push_back( table_state_ptr(new table_state(context_))); tables_state_.push_back( table_state_ptr(new table_state(context_)));
} }
......
...@@ -58,8 +58,7 @@ class xlsx_table_context ...@@ -58,8 +58,7 @@ class xlsx_table_context
public: public:
xlsx_table_context(xlsx_conversion_context & Context); xlsx_table_context(xlsx_conversion_context & Context);
public: void start_table();
void start_table(const std::wstring & name);
void set_chart_view(); void set_chart_view();
void end_table(); void end_table();
......
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