diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-16 09:14:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-17 22:10:52 +0200 |
commit | 20ee99fce1ea00cff54a3f3362e5ceadc71db933 (patch) | |
tree | 192ffc0586d44e06e501e1cc1fbbb02773c7609c | |
parent | efe8082b888ddd7c5c8f18ebf8df4cd8b300bd40 (diff) |
GetAddressFromString never passed a null ScDocument*
for the xml case this isn't immediately obvious, but pDoc should
only be null between Init and Destroy.
Change-Id: I6f517be6c620a8a2e5eec0f5a2fabd176745bb8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102957
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sc/inc/rangeutl.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/rangeutl.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLConsolidationContext.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLTableShapeImportHelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xml/xmldpimp.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/uitest/uiobject.cxx | 2 |
8 files changed, 21 insertions, 20 deletions
diff --git a/sc/inc/rangeutl.hxx b/sc/inc/rangeutl.hxx index a47ce79fefd0..2212d6bb9a41 100644 --- a/sc/inc/rangeutl.hxx +++ b/sc/inc/rangeutl.hxx @@ -120,7 +120,7 @@ public: static bool GetAddressFromString( ScAddress& rAddress, const OUString& rAddressStr, - const ScDocument* pDocument, + const ScDocument& rDocument, formula::FormulaGrammar::AddressConvention eConv, sal_Int32& nOffset, sal_Unicode cSeparator = ' ', diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index 034c0063a492..7582479dc05d 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -437,7 +437,7 @@ sal_Int32 ScRangeStringConverter::GetTokenCount( const OUString& rString, sal_Un bool ScRangeStringConverter::GetAddressFromString( ScAddress& rAddress, const OUString& rAddressStr, - const ScDocument* pDocument, + const ScDocument& rDocument, FormulaGrammar::AddressConvention eConv, sal_Int32& nOffset, sal_Unicode cSeparator, @@ -447,11 +447,11 @@ bool ScRangeStringConverter::GetAddressFromString( GetTokenByOffset( sToken, rAddressStr, nOffset, cSeparator, cQuote ); if( nOffset >= 0 ) { - if ((rAddress.Parse( sToken, pDocument, eConv ) & ScRefFlags::VALID) == ScRefFlags::VALID) + if ((rAddress.Parse( sToken, &rDocument, eConv ) & ScRefFlags::VALID) == ScRefFlags::VALID) return true; - ::formula::FormulaGrammar::AddressConvention eConvUI = pDocument->GetAddressConvention(); + ::formula::FormulaGrammar::AddressConvention eConvUI = rDocument.GetAddressConvention(); if (eConv != eConvUI) - return ((rAddress.Parse(sToken, pDocument, eConvUI) & ScRefFlags::VALID) == ScRefFlags::VALID); + return ((rAddress.Parse(sToken, &rDocument, eConvUI) & ScRefFlags::VALID) == ScRefFlags::VALID); } return false; } diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx index 37becac3a72d..d2d00b35df44 100644 --- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx +++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx @@ -57,7 +57,7 @@ const ScCellValue& ScMyCellInfo::CreateCell(ScDocument& rDoc) { ScAddress aPos; sal_Int32 nOffset(0); - ScRangeStringConverter::GetAddressFromString(aPos, sFormulaAddress, &rDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); + ScRangeStringConverter::GetAddressFromString(aPos, sFormulaAddress, rDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); maCell.meType = CELLTYPE_FORMULA; maCell.mpFormula = new ScFormulaCell(rDoc, aPos, sFormula, eGrammar, nMatrixFlag); maCell.mpFormula->SetMatColsRows(static_cast<SCCOL>(nMatrixCols), static_cast<SCROW>(nMatrixRows)); diff --git a/sc/source/filter/xml/XMLConsolidationContext.cxx b/sc/source/filter/xml/XMLConsolidationContext.cxx index 18d5c49a5718..610a3e27591e 100644 --- a/sc/source/filter/xml/XMLConsolidationContext.cxx +++ b/sc/source/filter/xml/XMLConsolidationContext.cxx @@ -53,8 +53,10 @@ ScXMLConsolidationContext::ScXMLConsolidationContext( case XML_ELEMENT( TABLE, XML_TARGET_CELL_ADDRESS ): { sal_Int32 nOffset(0); + ScDocument* pDoc = GetScImport().GetDocument(); + assert(pDoc); bTargetAddr = ScRangeStringConverter::GetAddressFromString( - aTargetAddr, aIter.toString(), GetScImport().GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset ); + aTargetAddr, aIter.toString(), *pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset ); } break; case XML_ELEMENT( TABLE, XML_USE_LABEL ): diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx index 28761b738230..8c82e65b8732 100644 --- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx +++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx @@ -110,7 +110,9 @@ void XMLTableShapeImportHelper::finishShape( if (IsXMLToken(aLocalName, XML_END_CELL_ADDRESS)) { sal_Int32 nOffset(0); - ScRangeStringConverter::GetAddressFromString(aAnchor.maEnd, rValue, static_cast<ScXMLImport&>(mrImporter).GetDocument(), ::formula::FormulaGrammar::CONV_OOO, nOffset); + ScDocument* pDoc = static_cast<ScXMLImport&>(mrImporter).GetDocument(); + assert(pDoc); + ScRangeStringConverter::GetAddressFromString(aAnchor.maEnd, rValue, *pDoc, ::formula::FormulaGrammar::CONV_OOO, nOffset); // When the cell end address is set, we let the shape resize with the cell aAnchor.mbResizeWithCell = true; } diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx index 29ffd5efb4e3..8447d800f160 100644 --- a/sc/source/filter/xml/xmldpimp.cxx +++ b/sc/source/filter/xml/xmldpimp.cxx @@ -330,7 +330,7 @@ void ScXMLDataPilotTableContext::SetButtons(ScDPObject* pDPObject) { ScAddress aScAddress; sal_Int32 nAddrOffset(0); - if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset )) + if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, *pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset )) { std::pair<ScDPOutputGeometry::FieldType, size_t> aBtnType = aGeometry.getFieldButtonType(aScAddress); const ScDPSaveDimension* pDim = getDimension( diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 12ebb66b2c0c..f692d7d04568 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -1476,12 +1476,12 @@ namespace { class RangeNameInserter { - ScDocument* mpDoc; + ScDocument& mrDoc; ScRangeName& mrRangeName; public: - RangeNameInserter(ScDocument* pDoc, ScRangeName& rRangeName) : - mpDoc(pDoc), mrRangeName(rRangeName) {} + RangeNameInserter(ScDocument& rDoc, ScRangeName& rRangeName) : + mrDoc(rDoc), mrRangeName(rRangeName) {} void operator() (const std::unique_ptr<ScMyNamedExpression>& p) const { @@ -1496,14 +1496,11 @@ public: if ( nUnoType & sheet::NamedRangeFlag::COLUMN_HEADER ) nNewType |= ScRangeData::Type::ColHeader; if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= ScRangeData::Type::RowHeader; - if (!mpDoc) - return; - // Insert a new name. ScAddress aPos; sal_Int32 nOffset = 0; bool bSuccess = ScRangeStringConverter::GetAddressFromString( - aPos, p->sBaseCellAddress, mpDoc, FormulaGrammar::CONV_OOO, nOffset); + aPos, p->sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset); if (bSuccess) { @@ -1512,7 +1509,7 @@ public: ScXMLConverter::ConvertCellRangeAddress(aContent); ScRangeData* pData = new ScRangeData( - *mpDoc, p->sName, aContent, aPos, nNewType, p->eGrammar); + mrDoc, p->sName, aContent, aPos, nNewType, p->eGrammar); mrRangeName.insert(pData); } } @@ -1530,7 +1527,7 @@ void ScXMLImport::SetNamedRanges() // Insert the namedRanges ScRangeName* pRangeNames = pDoc->GetRangeName(); - ::std::for_each(m_pMyNamedExpressions->begin(), m_pMyNamedExpressions->end(), RangeNameInserter(pDoc, *pRangeNames)); + ::std::for_each(m_pMyNamedExpressions->begin(), m_pMyNamedExpressions->end(), RangeNameInserter(*pDoc, *pRangeNames)); } void ScXMLImport::SetSheetNamedRanges() @@ -1546,7 +1543,7 @@ void ScXMLImport::SetSheetNamedRanges() continue; const ScMyNamedExpressions& rNames = *itr.second; - ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(pDoc, *pRangeNames)); + ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*pDoc, *pRangeNames)); } } diff --git a/sc/source/ui/uitest/uiobject.cxx b/sc/source/ui/uitest/uiobject.cxx index f408ce7328bf..3668b0c9727b 100644 --- a/sc/source/ui/uitest/uiobject.cxx +++ b/sc/source/ui/uitest/uiobject.cxx @@ -38,7 +38,7 @@ ScAddress get_address_from_string(const ScDocument& rDoc, const OUString& rStr) { ScAddress aAddr; sal_Int32 nOffset = 0; - ScRangeStringConverter::GetAddressFromString(aAddr, rStr, &rDoc, formula::FormulaGrammar::CONV_OOO, nOffset); + ScRangeStringConverter::GetAddressFromString(aAddr, rStr, rDoc, formula::FormulaGrammar::CONV_OOO, nOffset); return aAddr; } |