@@ -1130,7 +1130,7 @@ namespace OOX
1130
1130
}
1131
1131
namespace SharedFormulasRef
1132
1132
{
1133
- std::unique_ptr<std::vector< XLS::CellRef>> sharedRefsLocations;
1133
+ std::unique_ptr<std::map<_UINT32, XLS::CellRef>> sharedRefsLocations;
1134
1134
std::unique_ptr<std::vector<std::pair<XLS::CellRangeRef, XLS::CellRef>>> ArrayRefsLocations;
1135
1135
}
1136
1136
void CFormula::fromBin (XLS::StreamCacheReaderPtr& reader, XLS::CFRecordPtr& record)
@@ -1157,9 +1157,10 @@ namespace OOX
1157
1157
rowRef = static_cast <XLS::PtgExp*>(BinFmla.rgce .sequence .begin ()->get ())->rowXlsb ;
1158
1158
ColumnRef = static_cast <XLS::PtgExtraCol*>(BinFmla.rgcb .getPtgs ().back ().get ())->col ;
1159
1159
if (!SharedFormulasRef::sharedRefsLocations)
1160
- SharedFormulasRef::sharedRefsLocations = std::unique_ptr<std::vector<XLS::CellRef>>(new std::vector<XLS::CellRef>);
1161
- SharedFormulasRef::sharedRefsLocations->push_back (XLS::CellRef (rowRef, ColumnRef, true , true ));
1160
+ SharedFormulasRef::sharedRefsLocations = std::unique_ptr<std::map<_UINT32, XLS::CellRef>>(new std::map<_UINT32, XLS::CellRef>);
1162
1161
m_oSi = (unsigned int )SharedFormulasRef::sharedRefsLocations->size () - 1 ;
1162
+ SharedFormulasRef::sharedRefsLocations->emplace (m_oSi->GetValue (), XLS::CellRef (rowRef, ColumnRef, true , true ));
1163
+
1163
1164
}
1164
1165
}
1165
1166
auto fmlaRecord = reader->getNextRecord (XLSB::rt_ShrFmla);
@@ -2926,7 +2927,7 @@ namespace OOX
2926
2927
case SimpleTypes::Spreadsheet::celltypeInlineStr:
2927
2928
case SimpleTypes::Spreadsheet::celltypeStr:
2928
2929
{
2929
- if (m_oValue.IsInit () || m_oRichText.IsInit ())
2930
+ if (m_oValue.IsInit () || m_oRichText.IsInit () || m_oFormula. IsInit () )
2930
2931
{
2931
2932
if (!m_oFormula.IsInit ())
2932
2933
CellRecord = writer->getNextRecord (XLSB::rt_CellSt);
@@ -2936,8 +2937,10 @@ namespace OOX
2936
2937
XLSB::XLWideString str;
2937
2938
if (m_oValue.IsInit ())
2938
2939
str = m_oValue->m_sText ;
2939
- else
2940
+ else if (m_oRichText. IsInit ())
2940
2941
str = m_oRichText->ToString ();
2942
+ else
2943
+ str = L" " ;
2941
2944
*CellRecord << str;
2942
2945
}
2943
2946
else
@@ -2958,15 +2961,19 @@ namespace OOX
2958
2961
else if (m_oFormula->m_oT .get () == SimpleTypes::Spreadsheet::ECellFormulaType::cellformulatypeShared)
2959
2962
{
2960
2963
if (!SharedFormulasRef::sharedRefsLocations)
2961
- SharedFormulasRef::sharedRefsLocations = std::unique_ptr<std::vector< XLS::CellRef>>(new std::vector< XLS::CellRef>);
2964
+ SharedFormulasRef::sharedRefsLocations = std::unique_ptr<std::map<_UINT32, XLS::CellRef>>(new std::map<_UINT32, XLS::CellRef>);
2962
2965
if (!m_oFormula->m_sText .empty ())
2963
2966
{
2964
2967
ExtraRecord = writer->getNextRecord (XLSB::rt_ShrFmla);
2965
- SharedFormulasRef::sharedRefsLocations->push_back (CellReference);
2968
+ if (!m_oFormula->m_oSi .IsInit ())
2969
+ m_oFormula->m_oSi = (_UINT32)SharedFormulasRef::sharedRefsLocations->size ();
2970
+ SharedFormulasRef::sharedRefsLocations->emplace (m_oFormula->m_oSi ->GetValue (), CellReference);
2971
+ SharedFmlaRef = &CellReference;
2966
2972
}
2967
- if (m_oFormula->m_oSi .IsInit () && m_oFormula->m_oSi ->GetValue () < SharedFormulasRef::sharedRefsLocations->size ())
2973
+ if (m_oFormula->m_oSi .IsInit () && SharedFormulasRef::sharedRefsLocations-> find ( m_oFormula->m_oSi ->GetValue ()) != SharedFormulasRef::sharedRefsLocations->end ())
2968
2974
{
2969
- SharedFmlaRef = &SharedFormulasRef::sharedRefsLocations->at (m_oFormula->m_oSi ->GetValue ());
2975
+ if (m_oFormula->m_sText .empty ())
2976
+ SharedFmlaRef = &SharedFormulasRef::sharedRefsLocations->at (m_oFormula->m_oSi ->GetValue ());
2970
2977
XLS::CellParsedFormula BinFmla (false );
2971
2978
2972
2979
// пишем флаги для формулы
@@ -4727,6 +4734,8 @@ namespace OOX
4727
4734
}
4728
4735
if (SharedFormulasRef::sharedRefsLocations)
4729
4736
SharedFormulasRef::sharedRefsLocations.reset ();
4737
+ if (SharedFormulasRef::ArrayRefsLocations)
4738
+ SharedFormulasRef::ArrayRefsLocations.reset ();
4730
4739
}
4731
4740
XLS::BaseObjectPtr CSheetData::toBin ()
4732
4741
{
0 commit comments