Compare commits

...

3 Commits

Author SHA1 Message Date
59d2dd2840 . 2019-06-27 12:24:51 +03:00
967ab71adc XLsFormat - fix bug #41967 2019-06-26 15:37:01 +03:00
a48322f1cc [x2t] Fix CStreamBinaryWriter 2019-06-25 20:20:28 +03:00
4 changed files with 45 additions and 36 deletions

View File

@ -1060,47 +1060,46 @@ void ods_table_state::add_or_find_cell_shared_formula(std::wstring & formula, st
if (col2 - col1 > 0)moving_type = 1;
}
ods_shared_formula_state state = {(unsigned int)ind, odf_formula,ref, current_table_column_,current_table_row_, moving_type};
shared_formulas_.push_back(state);
shared_formulas_.insert(std::make_pair((unsigned int)ind, state));
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
else
{
for (size_t i = 0; i < shared_formulas_.size() ;i++)
std::map<unsigned int, ods_shared_formula_state>::iterator pFind = shared_formulas_.find(ind);
if (pFind != shared_formulas_.end())
{
if (shared_formulas_[i].index == ind)
{
odf_formula = shared_formulas_[i].formula;
odf_formula = pFind->second.formula;
//поменять по ref формулу !!!
if (shared_formulas_[i].moving_type == 1)
{
tmp_column_ = shared_formulas_[i].base_column;
tmp_row_ = shared_formulas_[i].base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_column,
boost::match_default | boost::format_all);
odf_formula = res;
}
if (shared_formulas_[i].moving_type == 2)
{
tmp_column_ = shared_formulas_[i].base_column;
tmp_row_ = shared_formulas_[i].base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_row,
boost::match_default | boost::format_all);
odf_formula = res;
}
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
//поменять по ref формулу !!!
if (pFind->second.moving_type == 1)
{
tmp_column_ = pFind->second.base_column;
tmp_row_ = pFind->second.base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_column,
boost::match_default | boost::format_all);
odf_formula = res;
}
else if (pFind->second.moving_type == 2)
{
tmp_column_ = pFind->second.base_column;
tmp_row_ = pFind->second.base_row;
const std::wstring res = boost::regex_replace(
odf_formula,
boost::wregex(L"([a-zA-Z]{1,3}[0-9]{1,3})|(?='.*?')|(?=\".*?\")"),
&ods_table_state::replace_cell_row,
boost::match_default | boost::format_all);
odf_formula = res;
}
cell->attlist_.table_formula_ = odf_formula;
cells_.back().empty = false;
}
}
}

View File

@ -453,8 +453,8 @@ private:
std::vector<ods_cell_state> cells_;
long cells_size_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::vector<ods_shared_formula_state> shared_formulas_;
std::vector<ods_hyperlink_state> hyperlinks_;
std::map<unsigned int, ods_shared_formula_state> shared_formulas_;
std::vector<table_part_state> table_parts_;

View File

@ -1129,7 +1129,17 @@ namespace NSBinPptxRW
}
void CBinaryFileWriter::_WriteStringWithLength(const WCHAR* sBuffer, _UINT32 lCount, bool bByte)
{
CheckBufferSize(UINT32_SIZEOF);
//CheckBufferSize at first to prevent negative m_lPosition after Flush in CStreamBinaryWriter
if (sizeof(wchar_t) == 4)
{
_INT32 lSizeMemMax = 4 * lCount + 2;//2 - for null terminator
CheckBufferSize(UINT32_SIZEOF + lSizeMemMax);
}
else
{
_INT32 lSizeMem = 2 * lCount;
CheckBufferSize(UINT32_SIZEOF + lSizeMem);
}
//skip size
m_lPosition += UINT32_SIZEOF;
m_pStreamCur += UINT32_SIZEOF;

View File

@ -212,7 +212,7 @@ const bool WorksheetSubstream::loadContent(BinProcessor& proc)
count = proc.repeated<BIGNAME>(0, 0);
while(count > 0)
{
m_arBIGNAME.insert(m_arNote.begin(), elements_.back());
m_arBIGNAME.insert(m_arBIGNAME.begin(), elements_.back());
elements_.pop_back();
count--;
}