mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/519
This commit is contained in:
@ -81,7 +81,12 @@ void PtgExtraArray::load(CFRecord& record)
|
||||
for(int i = 0; i < (tempcols) * (temprows); ++i)
|
||||
{
|
||||
if (record.getRdPtr() >= record.getDataSize())
|
||||
break;
|
||||
{
|
||||
unsigned char rec_type = SerAr::SerType::typeSerNil;
|
||||
SerArPtr ser(SerAr::createSerAr(rec_type));
|
||||
array_.push_back(ser);
|
||||
continue;
|
||||
}
|
||||
unsigned char rec_type;
|
||||
record >> rec_type;
|
||||
if (record.getGlobalWorkbookInfo()->Version >= 0x0800)
|
||||
@ -138,24 +143,31 @@ void PtgExtraArray::save(CFRecord& record)
|
||||
const std::wstring PtgExtraArray::toString() const
|
||||
{
|
||||
std::wstring ret_val;
|
||||
unsigned char col_cnt = cols + 1;
|
||||
unsigned char col_cnt = cols;
|
||||
|
||||
if (array_.empty()) return L"";
|
||||
|
||||
for(std::vector<SerArPtr>::const_iterator it = array_.begin(), itEnd = --array_.end(); it != itEnd; ++it)
|
||||
{
|
||||
ret_val += (*it)->toString();
|
||||
if(--col_cnt)
|
||||
auto tempVal = (*it)->toString();
|
||||
if(tempVal.empty())
|
||||
tempVal = L"#N/A";
|
||||
ret_val += tempVal;
|
||||
if (col_cnt > 1)
|
||||
{
|
||||
ret_val += L',';
|
||||
--col_cnt;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_val += L';';
|
||||
col_cnt = cols + 1;
|
||||
col_cnt = cols;
|
||||
}
|
||||
}
|
||||
ret_val += array_.back()->toString();
|
||||
auto tempVal = array_.back()->toString();
|
||||
if(tempVal.empty())
|
||||
tempVal = L"#N/A";
|
||||
ret_val += tempVal;
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
|
||||
@ -62,6 +62,16 @@ BiffStructurePtr SerNum::clone()
|
||||
void SerNum::load(CFRecord& record)
|
||||
{
|
||||
record >> xnum;
|
||||
// Excel limitations
|
||||
constexpr double ExcelMinAbs = 2.229e-308;
|
||||
constexpr double ExcelMax = 9.99999999999999e+307;
|
||||
|
||||
if(std::abs(xnum) < ExcelMinAbs && xnum != 0.0)
|
||||
xnum = (xnum > 0) ? ExcelMinAbs : -ExcelMinAbs;
|
||||
else if(xnum > ExcelMax)
|
||||
xnum = ExcelMax;
|
||||
else if(xnum < -ExcelMax)
|
||||
xnum = -ExcelMax;
|
||||
}
|
||||
|
||||
void SerNum::save(CFRecord& record)
|
||||
@ -77,7 +87,10 @@ void SerNum::save(CFRecord& record)
|
||||
|
||||
const std::wstring SerNum::toString() const
|
||||
{
|
||||
return STR::double2str(xnum);
|
||||
auto tempNum = STR::double2str(xnum);
|
||||
if(tempNum == L"-nan")
|
||||
tempNum = L"#NUM!";
|
||||
return tempNum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -94,7 +94,11 @@ void SerStr::save(CFRecord& record)
|
||||
|
||||
const std::wstring SerStr::toString() const
|
||||
{
|
||||
return L"\"" + boost::algorithm::replace_all_copy(std::wstring(rgch), L"\"", L"\"\"") + L"\"";
|
||||
std::wstring tempVal = rgch;
|
||||
tempVal.erase(std::remove(tempVal.begin(), tempVal.end(), L'\0'), tempVal.end());
|
||||
if(tempVal.size() > 255)
|
||||
tempVal.resize(255);
|
||||
return L"\"" + boost::algorithm::replace_all_copy(tempVal, L"\"", L"\"\"") + L"\"";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -814,7 +814,10 @@ namespace OOX
|
||||
if(m_oRowBreaks.IsInit())
|
||||
m_oRowBreaks->toXML(writer);
|
||||
if(m_oColBreaks.IsInit())
|
||||
{
|
||||
m_oColBreaks->m_fRowBreak = false;
|
||||
m_oColBreaks->toXML(writer);
|
||||
}
|
||||
if (m_oCellWatches.IsInit())
|
||||
m_oCellWatches->toXML(writer);
|
||||
if(m_oDrawing.IsInit())
|
||||
|
||||
@ -3193,7 +3193,10 @@ namespace OOX
|
||||
}
|
||||
void CRowColBreaks::toXML(NSStringUtils::CStringBuilder& writer) const
|
||||
{
|
||||
toXML2(writer, L"rowBreaks");
|
||||
if(m_fRowBreak)
|
||||
toXML2(writer, L"rowBreaks");
|
||||
else
|
||||
toXML2(writer, L"colBreaks");
|
||||
}
|
||||
void CRowColBreaks::toXML2(NSStringUtils::CStringBuilder& writer, const std::wstring& sName) const
|
||||
{
|
||||
|
||||
@ -754,6 +754,8 @@ namespace OOX
|
||||
public:
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber> m_oCount;
|
||||
nullable<SimpleTypes::CUnsignedDecimalNumber> m_oManualBreakCount;
|
||||
|
||||
bool m_fRowBreak = true;
|
||||
};
|
||||
|
||||
class CSheetProtection : public WritingElement
|
||||
|
||||
Reference in New Issue
Block a user