Commit f1b663c3 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFormat - #31849, уточнение размеров и положения графики на листе

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@68877 954022d7-b5bf-4e40-9824-e11837661b57
parent 30ad98d3
...@@ -641,21 +641,36 @@ const std::wstring xti_indexes2sheet_name(const short itabFirst, const short ita ...@@ -641,21 +641,36 @@ const std::wstring xti_indexes2sheet_name(const short itabFirst, const short ita
{ {
return L"#REF!"; return L"#REF!";
} }
std::wstring sheets_prefix = tab2sheet_name(itabFirst, sheets_names) + ((itabLast == itabFirst) ? L"" : L':' + tab2sheet_name(itabLast, sheets_names)); static boost::wregex correct_sheet_name(L"^\\'.+?\\'$");
static boost::wregex test_sheet_name(L"[\\s\\':.]+");
std::wstring escaped_prefix(boost::algorithm::replace_all_copy(sheets_prefix, L"'", L"''"));
std::wstring sheet_first = tab2sheet_name(itabFirst, sheets_names);
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"\'");
}
}
static boost::wregex correct_sheet_name(L"^\\w[\\w\\d.]*(:\\w[\\w\\d.]*)?$"); std::wstring sheet_last;
if(!boost::regex_search(escaped_prefix.begin(), escaped_prefix.end(), correct_sheet_name)) if (itabLast != itabFirst)
{ {
//int res_1 = escaped_prefix.find(L"\''"); sheet_last = tab2sheet_name(itabLast, sheets_names);
//int res_2 = escaped_prefix.rfind(L"\''");
//if (res_1 != 0 || res_2 !=escaped_prefix.length() - 1) if(!boost::regex_search(sheet_last.begin(), sheet_last.end(), correct_sheet_name))
{ {
return L'\'' + escaped_prefix + L'\''; if(boost::regex_search(sheet_last.begin(), sheet_last.end(), test_sheet_name))
{
sheet_last = boost::algorithm::replace_all_copy(sheet_last, L"'", L"''");
sheet_last = std::wstring(L"\'") + sheet_last + std::wstring(L"\'");
}
} }
sheet_last = std::wstring(L":") + sheet_last;
} }
return escaped_prefix;
return sheet_first + sheet_last;
} }
const std::wstring make3dRef(const unsigned short ixti, const std::wstring cell_ref, std::vector<std::wstring>& xti_parsed) const std::wstring make3dRef(const unsigned short ixti, const std::wstring cell_ref, std::vector<std::wstring>& xti_parsed)
......
...@@ -32,7 +32,7 @@ void DefColWidth::readFields(CFRecord& record) ...@@ -32,7 +32,7 @@ void DefColWidth::readFields(CFRecord& record)
GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo(); GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo();
record >> cchdefColWidth; record >> cchdefColWidth;
global_info->defaultColumnWidth = cchdefColWidth ; global_info->sheet_size_info.back().defaultColumnWidth = cchdefColWidth ;
} }
} // namespace XLS } // namespace XLS
......
...@@ -49,7 +49,7 @@ void DefaultRowHeight::readFields(CFRecord& record) ...@@ -49,7 +49,7 @@ void DefaultRowHeight::readFields(CFRecord& record)
record >> miyRw; record >> miyRw;
global_info->defaultRowHeight = miyRw / 20.; global_info->sheet_size_info.back().defaultRowHeight = miyRw / 20.;
} }
......
...@@ -36,7 +36,7 @@ void NoteSh::store(CFRecord& record) ...@@ -36,7 +36,7 @@ void NoteSh::store(CFRecord& record)
void NoteSh::load(CFRecord& record) void NoteSh::load(CFRecord& record)
{ {
XLS::GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo(); global_info = record.getGlobalWorkbookInfo();
unsigned short flags; unsigned short flags;
record >> row >> col >> flags; record >> row >> col >> flags;
...@@ -47,8 +47,13 @@ void NoteSh::load(CFRecord& record) ...@@ -47,8 +47,13 @@ void NoteSh::load(CFRecord& record)
record >> idObj >> stAuthor; record >> idObj >> stAuthor;
record.skipNunBytes(1); // unused record.skipNunBytes(1); // unused
}
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
void NoteSh::calculate()
{
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info->sheet_size_info[global_info->current_sheet - 1];
ref_ = CellRef(row, col, true, true).toString(); ref_ = CellRef(row, col, true, true).toString();
double kfCol = 17640 / 256.; double kfCol = 17640 / 256.;
...@@ -56,20 +61,20 @@ void NoteSh::load(CFRecord& record) ...@@ -56,20 +61,20 @@ void NoteSh::load(CFRecord& record)
for (int i = 0 ; i < col; i++) for (int i = 0 ; i < col; i++)
{ {
if (global_info->customColumnsWidth.find(i) != global_info->customColumnsWidth.end()) if (sheet_info.customColumnsWidth.find(i) != sheet_info.customColumnsWidth.end())
x_ += 256 * kfCol * global_info->customColumnsWidth[i]; x_ += 256 * kfCol * sheet_info.customColumnsWidth[i];
else else
x_ += 256 * kfCol * global_info->defaultColumnWidth; x_ += 256 * kfCol * sheet_info.defaultColumnWidth;
} }
for (int i = 0 ; i < row; i++) for (int i = 0 ; i < row; i++)
{ {
if (global_info->customRowsHeight.find(i) != global_info->customRowsHeight.end()) if (sheet_info.customRowsHeight.find(i) != sheet_info.customRowsHeight.end())
{ {
y_ += 256 * kfRow * global_info->customRowsHeight[i]; y_ += 256 * kfRow * sheet_info.customRowsHeight[i];
} }
else else
y_ += 256 * kfRow * global_info->defaultRowHeight; y_ += 256 * kfRow * sheet_info.defaultRowHeight;
} }
} }
......
...@@ -30,6 +30,10 @@ public: ...@@ -30,6 +30,10 @@ public:
ObjId idObj; ObjId idObj;
XLUnicodeString stAuthor; XLUnicodeString stAuthor;
//------------------------------------------ //------------------------------------------
GlobalWorkbookInfoPtr global_info;
void calculate();
std::wstring ref_; std::wstring ref_;
int x_; int x_;
int y_; int y_;
......
...@@ -36,84 +36,90 @@ void OfficeArtClientAnchorSheet::storeFields(XLS::CFRecord& record) ...@@ -36,84 +36,90 @@ void OfficeArtClientAnchorSheet::storeFields(XLS::CFRecord& record)
void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record) void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record)
{ {
XLS::GlobalWorkbookInfoPtr global_info = record.getGlobalWorkbookInfo(); global_info = record.getGlobalWorkbookInfo();
unsigned short flags; unsigned short flags;
record >> flags >> colL >> dxL >> rwT >> dyT >> colR >> dxR >> rwB >> dyB; record >> flags >> colL >> dxL >> rwT >> dyT >> colR >> dxR >> rwB >> dyB;
fMove = GETBIT(flags, 0); fMove = GETBIT(flags, 0);
fSize = GETBIT(flags, 1); fSize = GETBIT(flags, 1);
}
void OfficeArtClientAnchorSheet::calculate()
{
XLS::GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info->sheet_size_info[global_info->current_sheet - 1];
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
double kfCol = 17640 / 256.; double kfCol = 17640 / 256.;
double kfRow = ( 360000 * 2.54 / 72) / 256. ; double kfRow = ( 360000 * 2.54 / 72) / 256. ;
if (global_info->customColumnsWidth.find(colL) != global_info->customColumnsWidth.end()) if (sheet_info.customColumnsWidth.find(colL) != sheet_info.customColumnsWidth.end())
{ {
_dxL = dxL * kfCol * global_info->customColumnsWidth[colL]; _dxL = dxL * kfCol * sheet_info.customColumnsWidth[colL];
} }
else else
_dxL = dxL * kfCol * global_info->defaultColumnWidth; _dxL = dxL * kfCol * sheet_info.defaultColumnWidth;
if (global_info->customColumnsWidth.find(colR) != global_info->customColumnsWidth.end()) if (sheet_info.customColumnsWidth.find(colR) != sheet_info.customColumnsWidth.end())
{ {
_dxR = dxR * kfCol * global_info->customColumnsWidth[colR]; _dxR = dxR * kfCol * sheet_info.customColumnsWidth[colR];
} }
else else
_dxR = dxR * kfCol * global_info->defaultColumnWidth; _dxR = dxR * kfCol * sheet_info.defaultColumnWidth;
//--------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------
if (global_info->customRowsHeight.find(rwT) != global_info->customRowsHeight.end()) if (sheet_info.customRowsHeight.find(rwT) != sheet_info.customRowsHeight.end())
{ {
_dyT = dyT * kfRow * global_info->customRowsHeight[rwT]; _dyT = dyT * kfRow * sheet_info.customRowsHeight[rwT];
} }
else else
_dyT = dyT * kfRow * global_info->defaultRowHeight; _dyT = dyT * kfRow * sheet_info.defaultRowHeight;
if (global_info->customRowsHeight.find(rwB) != global_info->customRowsHeight.end()) if (sheet_info.customRowsHeight.find(rwB) != sheet_info.customRowsHeight.end())
{ {
_dyB = dyB * kfRow * global_info->customRowsHeight[rwB]; _dyB = dyB * kfRow * sheet_info.customRowsHeight[rwB];
} }
else else
_dyB = dyB * kfRow * global_info->defaultRowHeight; _dyB = dyB * kfRow * sheet_info.defaultRowHeight;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
for (int i = 0 ; i < colL; i++) for (int i = 0 ; i < colL; i++)
{ {
if (global_info->customColumnsWidth.find(i) != global_info->customColumnsWidth.end()) if (sheet_info.customColumnsWidth.find(i) != sheet_info.customColumnsWidth.end())
_x += 256 * kfCol * global_info->customColumnsWidth[i]; _x += 256 * kfCol * sheet_info.customColumnsWidth[i];
else else
_x += 256 * kfCol * global_info->defaultColumnWidth; _x += 256 * kfCol * sheet_info.defaultColumnWidth;
} }
_x += _dxL; _x += _dxL;
for (int i = colL ; i < colR; i++) for (int i = colL ; i < colR; i++)
{ {
if (global_info->customColumnsWidth.find(i) != global_info->customColumnsWidth.end()) if (sheet_info.customColumnsWidth.find(i) != sheet_info.customColumnsWidth.end())
_cx += 256 * kfCol * global_info->customColumnsWidth[i]; _cx += 256 * kfCol * sheet_info.customColumnsWidth[i];
else else
_cx += 256 * kfCol * global_info->defaultColumnWidth; _cx += 256 * kfCol * sheet_info.defaultColumnWidth;
} }
_cx += _dxR; _cx += _dxR;
for (int i = 0 ; i < rwT; i++) for (int i = 0 ; i < rwT; i++)
{ {
if (global_info->customRowsHeight.find(i) != global_info->customRowsHeight.end()) if (sheet_info.customRowsHeight.find(i) != sheet_info.customRowsHeight.end())
{ {
_y += 256 * kfRow * global_info->customRowsHeight[i]; _y += 256 * kfRow * sheet_info.customRowsHeight[i];
} }
else else
_y += 256 * kfRow * global_info->defaultRowHeight; _y += 256 * kfRow * sheet_info.defaultRowHeight;
} }
_y += _dyT; _y += _dyT;
for (int i = rwT ; i < rwB; i++) for (int i = rwT ; i < rwB; i++)
{ {
if (global_info->customRowsHeight.find(i) != global_info->customRowsHeight.end()) if (sheet_info.customRowsHeight.find(i) != sheet_info.customRowsHeight.end())
{ {
_cy += 256 * kfRow * global_info->customRowsHeight[i]; _cy += 256 * kfRow * sheet_info.customRowsHeight[i];
} }
else else
_cy += 256 * kfRow * global_info->defaultRowHeight; _cy += 256 * kfRow * sheet_info.defaultRowHeight;
} }
_cy += _dyT; _cy += _dyT;
} }
...@@ -123,8 +129,7 @@ void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record) ...@@ -123,8 +129,7 @@ void OfficeArtClientAnchorSheet::loadFields(XLS::CFRecord& record)
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
OfficeArtChildAnchor::OfficeArtChildAnchor() OfficeArtChildAnchor::OfficeArtChildAnchor() : OfficeArtRecord(0x00, ChildAnchor)
: OfficeArtRecord(0x00, ChildAnchor)
{ {
_x = _y = _cx = _cy = 0; _x = _y = _cx = _cy = 0;
} }
......
...@@ -36,6 +36,11 @@ public: ...@@ -36,6 +36,11 @@ public:
XLS::RwU rwB; XLS::RwU rwB;
short dyB; short dyB;
//-----------------------------------------------------------------------------
XLS::GlobalWorkbookInfoPtr global_info;
void calculate();
_UINT32 _dxL; _UINT32 _dxL;
_UINT32 _dyT; _UINT32 _dyT;
_UINT32 _dxR; _UINT32 _dxR;
......
...@@ -49,32 +49,38 @@ int AI::serialize(std::wostream & _stream) ...@@ -49,32 +49,38 @@ int AI::serialize(std::wostream & _stream)
{ {
BRAI* brai = dynamic_cast<BRAI*>(m_BRAI.get()); BRAI* brai = dynamic_cast<BRAI*>(m_BRAI.get());
CP_XML_WRITER(_stream) if (brai)
{ {
if ((brai) && (brai->formula.getAssembledFormula().empty() == false)) std::wstring forumla = brai->formula.getAssembledFormula();
if (forumla.empty() == false)
{ {
CP_XML_NODE(L"c:tx") CP_XML_WRITER(_stream)
{ {
CP_XML_NODE(L"c:strRef") CP_XML_NODE(L"c:tx")
{ {
CP_XML_NODE(L"c:f") CP_XML_NODE(L"c:strRef")
{ {
CP_XML_STREAM() << brai->formula.getAssembledFormula(); CP_XML_NODE(L"c:f")
{
CP_XML_STREAM() << forumla;
}
} }
} }
} }
return 0;
} }
else }
SeriesText * text = dynamic_cast<SeriesText *>(m_SeriesText.get());
if ((text) && (text->stText.value().empty() == false))
{
CP_XML_WRITER(_stream)
{ {
SeriesText * text = dynamic_cast<SeriesText *>(m_SeriesText.get()); CP_XML_NODE(L"c:tx")
if ((text) && (text->stText.value().empty() == false))
{ {
CP_XML_NODE(L"c:tx") CP_XML_NODE(L"c:v")
{ {
CP_XML_NODE(L"c:v") CP_XML_STREAM() << text->stText.value();
{
CP_XML_STREAM() << text->stText.value();
}
} }
} }
} }
......
...@@ -29,6 +29,8 @@ public: ...@@ -29,6 +29,8 @@ public:
const bool loadContent(BinProcessor& proc) const bool loadContent(BinProcessor& proc)
{ {
global_info_ = proc.getGlobalWorkbookInfo(); global_info_ = proc.getGlobalWorkbookInfo();
GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info_->sheet_size_info[global_info_->current_sheet - 1];
int count, count_row = 0; int count, count_row = 0;
...@@ -41,9 +43,9 @@ public: ...@@ -41,9 +43,9 @@ public:
Row* row = dynamic_cast<Row*>(elements_.back().get()); Row* row = dynamic_cast<Row*>(elements_.back().get());
if (row) if (row)
{ {
if (row->miyRw > 0 && std::abs(row->miyRw/20. - global_info_->defaultRowHeight) > 0.001) if (row->miyRw > 0 && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.001)
{ {
global_info_->customRowsHeight.insert(std::pair<int, double>(row->rw, row->miyRw / 20.)); sheet_info.customRowsHeight.insert(std::pair<int, double>(row->rw, row->miyRw / 20.));
} }
} }
m_rows.insert(m_rows.begin(), elements_.back()); m_rows.insert(m_rows.begin(), elements_.back());
...@@ -117,7 +119,10 @@ struct _CompareColumnCell ...@@ -117,7 +119,10 @@ struct _CompareColumnCell
int CELL_GROUP::serialize(std::wostream & stream) int CELL_GROUP::serialize(std::wostream & stream)
{ {
GlobalWorkbookInfo::_sheet_size_info & sheet_info = global_info_->sheet_size_info[global_info_->current_sheet - 1];
elements_.sort(CompareRowCell);// .. todooo (rownumb, list<cells> - ) elements_.sort(CompareRowCell);// .. todooo (rownumb, list<cells> - )
CP_XML_WRITER(stream) CP_XML_WRITER(stream)
{ {
std::list<XLS::BaseObjectPtr>::iterator current_cell_start = elements_.begin(); std::list<XLS::BaseObjectPtr>::iterator current_cell_start = elements_.begin();
...@@ -181,7 +186,7 @@ int CELL_GROUP::serialize(std::wostream & stream) ...@@ -181,7 +186,7 @@ int CELL_GROUP::serialize(std::wostream & stream)
} }
CP_XML_ATTR(L"customFormat", true); CP_XML_ATTR(L"customFormat", true);
} }
if (row->miyRw > 0 && std::abs(row->miyRw/20. - global_info_->defaultRowHeight) > 0.01) if (row->miyRw > 0/* && std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
{ {
CP_XML_ATTR(L"ht", row->miyRw / 20.); CP_XML_ATTR(L"ht", row->miyRw / 20.);
CP_XML_ATTR(L"customHeight", true); CP_XML_ATTR(L"customHeight", true);
...@@ -263,7 +268,7 @@ int CELL_GROUP::serialize(std::wostream & stream) ...@@ -263,7 +268,7 @@ int CELL_GROUP::serialize(std::wostream & stream)
CP_XML_ATTR(L"customFormat", true); CP_XML_ATTR(L"customFormat", true);
} }
if (row->miyRw > 0 && std::abs(row->miyRw/20. - global_info_->defaultRowHeight) > 0.01) if (row->miyRw > 0 /*&& std::abs(row->miyRw/20. - sheet_info.defaultRowHeight) > 0.01*/)
{ {
CP_XML_ATTR(L"ht", row->miyRw / 20.); CP_XML_ATTR(L"ht", row->miyRw / 20.);
CP_XML_ATTR(L"customHeight", true); CP_XML_ATTR(L"customHeight", true);
......
...@@ -36,7 +36,7 @@ const bool COLUMNS::loadContent(BinProcessor& proc) ...@@ -36,7 +36,7 @@ const bool COLUMNS::loadContent(BinProcessor& proc)
m_DefColWidth = elements_.back(); m_DefColWidth = elements_.back();
elements_.pop_back(); elements_.pop_back();
} }
bool col_ok = proc.repeated<ColInfo>(0, 255); int count = proc.repeated<ColInfo>(0, 255);
int last_add = 0; int last_add = 0;
...@@ -46,15 +46,19 @@ const bool COLUMNS::loadContent(BinProcessor& proc) ...@@ -46,15 +46,19 @@ 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++)
{ {
if (column_info->coldx > 0) if (column_info->coldx > 0 && column_info->fUserSet)
{ {
global_info_->customColumnsWidth.insert(std::pair<int, double>(i,column_info->coldx / 256.)); global_info_->sheet_size_info.back().customColumnsWidth.insert(std::pair<int, double>(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));
} }
} }
} }
return def_ok || col_ok; return def_ok || (count > 0);
} }
int COLUMNS::serialize(std::wostream & stream) int COLUMNS::serialize(std::wostream & stream)
......
#include "GLOBALS.h" #include "GLOBALS.h"
#include <Logic/Biff_records/DefColWidth.h> #include <Logic/Biff_records/DefColWidth.h>
#include <Logic/Biff_records/DxGCol.h>
#include <Logic/Biff_records/Protect.h> #include <Logic/Biff_records/Protect.h>
#include <Logic/Biff_records/CalcMode.h> #include <Logic/Biff_records/CalcMode.h>
...@@ -47,6 +48,7 @@ GLOBALS = CalcMode CalcCount CalcRefMode CalcIter CalcDelta CalcSaveRecalc Print ...@@ -47,6 +48,7 @@ GLOBALS = CalcMode CalcCount CalcRefMode CalcIter CalcDelta CalcSaveRecalc Print
*/ */
const bool GLOBALS::loadContent(BinProcessor& proc) const bool GLOBALS::loadContent(BinProcessor& proc)
{ {
global_info_ = proc.getGlobalWorkbookInfo();
// if(!proc.mandatory<CalcMode>()) // if(!proc.mandatory<CalcMode>())
// { // {
// return false; // return false;
...@@ -121,7 +123,12 @@ int GLOBALS::serialize(std::wostream & stream) ...@@ -121,7 +123,12 @@ int GLOBALS::serialize(std::wostream & stream)
{ {
CP_XML_ATTR(L"defaultRowHeight", 14.4); CP_XML_ATTR(L"defaultRowHeight", 14.4);
} }
if (m_DefColWidth) if (m_DxGCol)
{
DxGCol* def_col = dynamic_cast<DxGCol*>(m_DxGCol.get());
CP_XML_ATTR(L"defaultColWidth", def_col->dxgCol / 256.);
}
else if (m_DefColWidth)
{ {
DefColWidth* def_col = dynamic_cast<DefColWidth*>(m_DefColWidth.get()); DefColWidth* def_col = dynamic_cast<DefColWidth*>(m_DefColWidth.get());
CP_XML_ATTR(L"defaultColWidth", def_col->cchdefColWidth); CP_XML_ATTR(L"defaultColWidth", def_col->cchdefColWidth);
......
...@@ -24,10 +24,15 @@ public: ...@@ -24,10 +24,15 @@ public:
bool is_dialog; bool is_dialog;
BaseObjectPtr m_DefColWidth;
BaseObjectPtr m_DefaultRowHeight; BaseObjectPtr m_DefaultRowHeight;
BaseObjectPtr m_Guts; BaseObjectPtr m_Guts;
BaseObjectPtr m_WsBool; BaseObjectPtr m_WsBool;
//--------------------------------------------------------------
GlobalWorkbookInfoPtr global_info_;
BaseObjectPtr m_DxGCol;
BaseObjectPtr m_DefColWidth;
}; };
} // namespace XLS } // namespace XLS
......
...@@ -11,9 +11,6 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver ...@@ -11,9 +11,6 @@ GlobalWorkbookInfo::GlobalWorkbookInfo(const unsigned short code_page, XlsConver
last_AXES_id = initial_AXES_id; last_AXES_id = initial_AXES_id;
defaultColumnWidth = 8;
defaultRowHeight = 14.4;
Version = 0x0600; // xls Version = 0x0600; // xls
xls_converter = xls_converter_; xls_converter = xls_converter_;
......
...@@ -57,6 +57,7 @@ public: ...@@ -57,6 +57,7 @@ public:
std::vector<BaseObjectPtr> *m_arFonts; std::vector<BaseObjectPtr> *m_arFonts;
unsigned int current_sheet; unsigned int current_sheet;
unsigned int last_AXES_id; unsigned int last_AXES_id;
const static unsigned int initial_AXES_id = 0x2000000; const static unsigned int initial_AXES_id = 0x2000000;
...@@ -69,15 +70,21 @@ public: ...@@ -69,15 +70,21 @@ public:
std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data; std::vector<std::pair<boost::shared_array<char>, size_t> > bin_data;
std::map<int, double> customColumnsWidth; struct _sheet_size_info
std::map<int, double> customRowsHeight; {
_sheet_size_info() : defaultColumnWidth(8.), defaultRowHeight (14.4) {}
double defaultColumnWidth; std::map<int, double> customColumnsWidth;
double defaultRowHeight; std::map<int, double> customRowsHeight;
int cmt_rules;
double defaultColumnWidth;
double defaultRowHeight;
};
std::vector<_sheet_size_info> sheet_size_info;
int Version; int Version;
int cmt_rules;
int cellStyleXfs_count; int cellStyleXfs_count;
int cellStyleDxfs_count; int cellStyleDxfs_count;
......
...@@ -73,8 +73,10 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -73,8 +73,10 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
{ {
GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo(); GlobalWorkbookInfoPtr global_info = proc.getGlobalWorkbookInfo();
global_info->defaultColumnWidth = 8; GlobalWorkbookInfo::_sheet_size_info sheet_size_info;
global_info->defaultRowHeight = 14.4; 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;
int count = 0; int count = 0;
...@@ -222,7 +224,14 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -222,7 +224,14 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
count--; count--;
} }
proc.optional<DxGCol> (); if (proc.optional<DxGCol>())
{
m_DxGCol = elements_.back();
elements_.pop_back();
DxGCol* dx = dynamic_cast<DxGCol*>(m_DxGCol.get());
global_info->sheet_size_info.back().defaultColumnWidth = dx->dxgCol / 256.;
}
count = proc.repeated<MergeCells>(0, 0); count = proc.repeated<MergeCells>(0, 0);
while(count > 0) while(count > 0)
...@@ -292,9 +301,6 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc) ...@@ -292,9 +301,6 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
proc.mandatory<EOF_T>(); proc.mandatory<EOF_T>();
global_info->customColumnsWidth.clear();
global_info->customRowsHeight.clear();
return true; return true;
} }
......
...@@ -40,6 +40,7 @@ public: ...@@ -40,6 +40,7 @@ public:
BaseObjectPtr m_CONDFMTS; BaseObjectPtr m_CONDFMTS;
BaseObjectPtr m_CodeName; BaseObjectPtr m_CodeName;
BaseObjectPtr m_SheetExt; BaseObjectPtr m_SheetExt;
BaseObjectPtr m_DxGCol;
std::vector<BaseObjectPtr> m_arFEAT; std::vector<BaseObjectPtr> m_arFEAT;
std::vector<BaseObjectPtr> m_arFEAT11; std::vector<BaseObjectPtr> m_arFEAT11;
......
...@@ -251,7 +251,7 @@ namespace oox ...@@ -251,7 +251,7 @@ namespace oox
//case msosptPlaque : return L"plaque"; //case msosptPlaque : return L"plaque";
//case msosptCan : return L"can"; //case msosptCan : return L"can";
//case msosptDonut : return L"donut"; //case msosptDonut : return L"donut";
case msosptStraightConnector1 : return L"straightConnector1"; //case msosptStraightConnector1 : return L"straightConnector1";
//case msosptBentConnector2 : return L"bentConnector2"; //case msosptBentConnector2 : return L"bentConnector2";
//case msosptBentConnector3 : return L"bentConnector3"; //case msosptBentConnector3 : return L"bentConnector3";
//case msosptBentConnector4 : return L"bentConnector4"; //case msosptBentConnector4 : return L"bentConnector4";
......
...@@ -265,6 +265,7 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook) ...@@ -265,6 +265,7 @@ void XlsConverter::convert(XLS::WorkbookStreamObject* woorkbook)
for (int i=0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++) for (int i=0 ; i < woorkbook->m_arWorksheetSubstream.size(); i++)
{ {
xls_global_info->current_sheet = i + 1; xls_global_info->current_sheet = i + 1;
xlsx_context->start_table(xls_global_info->sheets_names.size() > i ? xls_global_info->sheets_names[i] : L"Sheet_" + boost::lexical_cast<std::wstring>(i+1)); xlsx_context->start_table(xls_global_info->sheets_names.size() > i ? xls_global_info->sheets_names[i] : L"Sheet_" + boost::lexical_cast<std::wstring>(i+1));
xlsx_context->set_state(xls_global_info->sheets_state.size() > i ? xls_global_info->sheets_state[i] : L"visible"); xlsx_context->set_state(xls_global_info->sheets_state.size() > i ? xls_global_info->sheets_state[i] : L"visible");
...@@ -308,10 +309,12 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet) ...@@ -308,10 +309,12 @@ void XlsConverter::convert(XLS::WorksheetSubstream* sheet)
XLS::GLOBALS * globals = dynamic_cast<XLS::GLOBALS *>(sheet->m_GLOBALS.get()); XLS::GLOBALS * globals = dynamic_cast<XLS::GLOBALS *>(sheet->m_GLOBALS.get());
XLS::COLUMNS * columns = dynamic_cast<XLS::COLUMNS *>(sheet->m_COLUMNS.get()); XLS::COLUMNS * columns = dynamic_cast<XLS::COLUMNS *>(sheet->m_COLUMNS.get());
if (globals && columns) if (columns)
{ {
globals->m_DefColWidth = columns->m_DefColWidth; globals->m_DefColWidth = columns->m_DefColWidth;
} }
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 (sheet->m_COLUMNS) if (sheet->m_COLUMNS)
...@@ -512,15 +515,16 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ ...@@ -512,15 +515,16 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ
if (type_ext == L"dib_data") if (type_ext == L"dib_data")
{ {
bool bPNG = false; bool bPNG = false;
int offset = 0; int offset = 0, biSizeImage = 0;
CBgraFrame frame; CBgraFrame frame;
BITMAPINFOHEADER * header = (BITMAPINFOHEADER *)data; BITMAPINFOHEADER * header = (BITMAPINFOHEADER *)data;
if (header->biWidth > 100000 || header->biHeight > 100000) if (header->biWidth > 100000 || header->biHeight > 100000)
{ {
//Formulas Matriciais - A Outra Dimensão do Excel.xls todoooo найти еще файлы //Formulas Matriciais - A Outra Dimensão do Excel.xls 775x20 todoooo найти еще файлы
//775x20 //Planilha Bastter Blue 7.0 Free.xls 10x3836
//
offset = 12; //sizeof(BITMAPCOREHEADER) offset = 12; //sizeof(BITMAPCOREHEADER)
BITMAPCOREHEADER * header_core = (BITMAPCOREHEADER *)data; BITMAPCOREHEADER * header_core = (BITMAPCOREHEADER *)data;
...@@ -530,11 +534,13 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ ...@@ -530,11 +534,13 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ
int sz_bitmap = header_core->bcHeight * header_core->bcWidth * header_core->bcBitCount/ 8; int sz_bitmap = header_core->bcHeight * header_core->bcWidth * header_core->bcBitCount/ 8;
if (header_core->bcWidth % 2 != 0 && sz_bitmap < size -offset) //if (header_core->bcWidth % 2 != 0 && sz_bitmap < size - offset)
header_core->bcWidth++; // header_core->bcWidth++;
frame.put_Stride (header_core->bcBitCount * header_core->bcWidth /8); int stride = (size - offset) / header_core->bcHeight;
frame.put_Stride (stride/*header_core->bcBitCount * header_core->bcWidth /8 */);
biSizeImage = size - offset;
bPNG = true; bPNG = true;
} }
else if (header->biBitCount >=24) else if (header->biBitCount >=24)
...@@ -548,6 +554,8 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ ...@@ -548,6 +554,8 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ
if (header->biWidth % 2 != 0 && sz_bitmap < size -offset) if (header->biWidth % 2 != 0 && sz_bitmap < size -offset)
header->biWidth++; header->biWidth++;
biSizeImage = header->biSizeImage;
frame.put_Stride (header->biBitCount * header->biWidth /8); frame.put_Stride (header->biBitCount * header->biWidth /8);
bPNG = true; bPNG = true;
...@@ -566,7 +574,7 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ ...@@ -566,7 +574,7 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ
// //
} }
} }
else else if (biSizeImage > 0)
{ {
//тут паттерные картинки //тут паттерные картинки
file_name += std::wstring(L".bmp"); file_name += std::wstring(L".bmp");
...@@ -574,7 +582,7 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ ...@@ -574,7 +582,7 @@ std::wstring XlsConverter::WriteMediaFile(char *data, int size, std::wstring typ
if (file.CreateFileW(xlsx_context->get_mediaitems().media_path() + file_name)) if (file.CreateFileW(xlsx_context->get_mediaitems().media_path() + file_name))
{ {
WORD vtType = 0x4D42; file.WriteFile((BYTE*)&vtType, 2); WORD vtType = 0x4D42; file.WriteFile((BYTE*)&vtType, 2);
DWORD dwLen = header->biSizeImage; file.WriteFile((BYTE*)&dwLen, 4); DWORD dwLen = biSizeImage; file.WriteFile((BYTE*)&dwLen, 4);
DWORD dwRes = 0; file.WriteFile((BYTE*)&dwRes, 4); DWORD dwRes = 0; file.WriteFile((BYTE*)&dwRes, 4);
DWORD dwOffset = 2; file.WriteFile((BYTE*)&dwOffset, 4); DWORD dwOffset = 2; file.WriteFile((BYTE*)&dwOffset, 4);
...@@ -864,7 +872,8 @@ void XlsConverter::convert(ODRAW::OfficeArtRecord * art) ...@@ -864,7 +872,8 @@ void XlsConverter::convert(ODRAW::OfficeArtRecord * art)
{ {
ODRAW::OfficeArtClientAnchorSheet * ch = dynamic_cast<ODRAW::OfficeArtClientAnchorSheet *>(art); ODRAW::OfficeArtClientAnchorSheet * ch = dynamic_cast<ODRAW::OfficeArtClientAnchorSheet *>(art);
xlsx_context->get_drawing_context().set_child_anchor(ch->_x, ch->_y, ch->_cx, ch->_cy); ch->calculate();
//xlsx_context->get_drawing_context().set_child_anchor(ch->_x, ch->_y, ch->_cx, ch->_cy);
xlsx_context->get_drawing_context().set_sheet_anchor(ch->colL, ch->_dxL, ch->rwT, ch->_dyT, ch->colR, ch->_dxR, ch->rwB, ch->_dyB); xlsx_context->get_drawing_context().set_sheet_anchor(ch->colL, ch->_dxL, ch->rwT, ch->_dyT, ch->colR, ch->_dxR, ch->rwB, ch->_dyB);
}break; }break;
} }
...@@ -1386,6 +1395,8 @@ void XlsConverter::convert(XLS::Note* note) ...@@ -1386,6 +1395,8 @@ void XlsConverter::convert(XLS::Note* note)
{ {
if (note == NULL) return; if (note == NULL) return;
note->note_sh.calculate();
xlsx_context->get_comments_context().set_ref (note->note_sh.ref_, xlsx_context->get_comments_context().set_ref (note->note_sh.ref_,
note->note_sh.col, note->note_sh.col,
note->note_sh.row); note->note_sh.row);
......
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