[Libreoffice-commits] core.git: sc/inc sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 15 09:13:41 UTC 2020
sc/inc/rangelst.hxx | 2 +-
sc/source/core/data/documen5.cxx | 7 ++++---
sc/source/core/tool/rangelst.cxx | 6 +++---
sc/source/ui/condformat/condformatdlg.cxx | 4 ++--
sc/source/ui/docshell/docsh4.cxx | 2 +-
sc/source/ui/drawfunc/fuins2.cxx | 2 +-
sc/source/ui/miscdlgs/acredlin.cxx | 2 +-
sc/source/ui/miscdlgs/highred.cxx | 2 +-
sc/source/ui/unoobj/cellsuno.cxx | 2 +-
sc/source/ui/unoobj/chartuno.cxx | 2 +-
sc/source/ui/vba/vbarange.cxx | 2 +-
sc/source/ui/view/drawvie4.cxx | 2 +-
12 files changed, 18 insertions(+), 17 deletions(-)
New commits:
commit 2943c7b1d7b8e6c087f1ad5f1be9ed8f5bbc027c
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Sep 14 11:12:38 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Sep 15 11:12:55 2020 +0200
ScRangeList::Parse ScDocument* argument dereferenced on all used paths
so nDefaultTab is always used
(in ScAcceptChgDlg::FilterHandle pDoc might possibly be
null, but that doesn't seem possible in practice)
Change-Id: I39ec7f7f96fa2421f492c9e73659abdfba21c3f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102666
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 6a74662d7572..48a2b088065e 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -41,7 +41,7 @@ public:
ScRangeList& operator=(const ScRangeList& rList);
ScRangeList& operator=(ScRangeList&& rList) noexcept;
- ScRefFlags Parse( const OUString&, const ScDocument*,
+ ScRefFlags Parse( const OUString&, const ScDocument&,
formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO,
SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 );
diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx
index 2702e1e65e54..71a4b97f1e73 100644
--- a/sc/source/core/data/documen5.cxx
+++ b/sc/source/core/data/documen5.cxx
@@ -163,6 +163,7 @@ uno::Reference< chart2::XChartDocument > ScDocument::GetChartByName( const OUStr
}
return xReturn;
}
+
void ScDocument::GetChartRanges( const OUString& rChartName, ::std::vector< ScRangeList >& rRangesVector, const ScDocument* pSheetNameDoc )
{
rRangesVector.clear();
@@ -174,7 +175,7 @@ void ScDocument::GetChartRanges( const OUString& rChartName, ::std::vector< ScRa
for(const OUString & aRangeString : aRangeStrings)
{
ScRangeList aRanges;
- aRanges.Parse( aRangeString, pSheetNameDoc, pSheetNameDoc->GetAddressConvention() );
+ aRanges.Parse( aRangeString, *pSheetNameDoc, pSheetNameDoc->GetAddressConvention() );
rRangesVector.push_back(aRanges);
}
}
@@ -228,7 +229,7 @@ void ScDocument::GetOldChartParameters( const OUString& rName,
OUString aRangesStr;
lcl_GetChartParameters( xChartDoc, aRangesStr, eDataRowSource, bHasCategories, bFirstCellAsLabel );
- rRanges.Parse( aRangesStr, this );
+ rRanges.Parse( aRangesStr, *this );
if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
{
rRowHeaders = bHasCategories;
@@ -284,7 +285,7 @@ void ScDocument::UpdateChartArea( const OUString& rChartName,
// append to old ranges, keep other settings
aNewRanges = new ScRangeList;
- aNewRanges->Parse( aRangesStr, this );
+ aNewRanges->Parse( aRangesStr, *this );
for ( size_t nAdd = 0, nAddCount = rNewList->size(); nAdd < nAddCount; ++nAdd )
aNewRanges->push_back( (*rNewList)[nAdd] );
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 5b156e2d3449..4121f2c5baea 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -103,7 +103,7 @@ ScRangeList::~ScRangeList()
{
}
-ScRefFlags ScRangeList::Parse( const OUString& rStr, const ScDocument* pDoc,
+ScRefFlags ScRangeList::Parse( const OUString& rStr, const ScDocument& rDoc,
formula::FormulaGrammar::AddressConvention eConv,
SCTAB nDefaultTab, sal_Unicode cDelimiter )
{
@@ -114,14 +114,14 @@ ScRefFlags ScRangeList::Parse( const OUString& rStr, const ScDocument* pDoc,
ScRefFlags nResult = ~ScRefFlags::ZERO; // set all bits
ScRange aRange;
- const SCTAB nTab = pDoc ? nDefaultTab : 0;
+ const SCTAB nTab = nDefaultTab;
sal_Int32 nPos = 0;
do
{
const OUString aOne = rStr.getToken( 0, cDelimiter, nPos );
aRange.aStart.SetTab( nTab ); // default tab if not specified
- ScRefFlags nRes = aRange.ParseAny( aOne, pDoc, eConv );
+ ScRefFlags nRes = aRange.ParseAny( aOne, &rDoc, eConv );
ScRefFlags nEndRangeBits = ScRefFlags::COL2_VALID | ScRefFlags::ROW2_VALID | ScRefFlags::TAB2_VALID;
ScRefFlags nTmp1 = nRes & ScRefFlags::BITS;
ScRefFlags nTmp2 = nRes & nEndRangeBits;
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 5d32b070dd55..40756b7866d2 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -570,7 +570,7 @@ std::unique_ptr<ScConditionalFormat> ScCondFormatDlg::GetConditionalFormat() con
return nullptr;
ScRangeList aRange;
- ScRefFlags nFlags = aRange.Parse(aRangeStr, mpViewData->GetDocument(),
+ ScRefFlags nFlags = aRange.Parse(aRangeStr, *mpViewData->GetDocument(),
mpViewData->GetDocument()->GetAddressConvention(), maPos.Tab());
mxCondFormList->SetRange(aRange);
std::unique_ptr<ScConditionalFormat> pFormat = mxCondFormList->GetConditionalFormat();
@@ -671,7 +671,7 @@ IMPL_LINK(ScCondFormatDlg, EdRangeModifyHdl, formula::RefEdit&, rEdit, void)
{
OUString aRangeStr = rEdit.GetText();
ScRangeList aRange;
- ScRefFlags nFlags = aRange.Parse(aRangeStr, mpViewData->GetDocument(),
+ ScRefFlags nFlags = aRange.Parse(aRangeStr, *mpViewData->GetDocument(),
mpViewData->GetDocument()->GetAddressConvention());
if(nFlags & ScRefFlags::VALID)
{
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index dab72363ce3f..f04c57b6ab98 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -360,7 +360,7 @@ void ScDocShell::Execute( SfxRequest& rReq )
if (!bValid)
{
aRangeListRef = new ScRangeList;
- aRangeListRef->Parse( aRangeName, &rDoc );
+ aRangeListRef->Parse( aRangeName, rDoc );
if ( !aRangeListRef->empty() )
{
bMultiRange = true;
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 0faac4dc664e..015457d6b08d 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -152,7 +152,7 @@ void lcl_ChartInit(const uno::Reference <embed::XEmbeddedObject>& xObj, ScViewDa
// use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version)
ScRangeListRef aRangeListRef( new ScRangeList );
- aRangeListRef->Parse( aRangeString, &rScDoc, rScDoc.GetAddressConvention() );
+ aRangeListRef->Parse( aRangeString, rScDoc, rScDoc.GetAddressConvention() );
if ( !aRangeListRef->empty() )
{
rScDoc.LimitChartIfAll( aRangeListRef ); // limit whole columns/rows to used area
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 8837fc5510e5..7d5b3a3569b2 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -865,7 +865,7 @@ IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef, void )
{
ClearView();
aRangeList.RemoveAll();
- aRangeList.Parse(pTPFilter->GetRange(),pDoc);
+ aRangeList.Parse(pTPFilter->GetRange(), *pDoc);
UpdateView();
}
}
diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx
index ee2cb04e43d0..584119681fa0 100644
--- a/sc/source/ui/miscdlgs/highred.cxx
+++ b/sc/source/ui/miscdlgs/highred.cxx
@@ -212,7 +212,7 @@ IMPL_LINK_NOARG(ScHighlightChgDlg, OKBtnHdl, weld::Button&, void)
aChangeViewSet.SetHasComment(m_xFilterCtr->IsComment());
aChangeViewSet.SetTheComment(m_xFilterCtr->GetComment());
ScRangeList aLocalRangeList;
- aLocalRangeList.Parse(m_xFilterCtr->GetRange(), pDoc);
+ aLocalRangeList.Parse(m_xFilterCtr->GetRange(), *pDoc);
aChangeViewSet.SetTheRangeList(aLocalRangeList);
aChangeViewSet.AdjustDateMode( *pDoc );
pDoc->SetChangeViewSettings(aChangeViewSet);
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 86a2ca68d1a6..74455762d6db 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -4378,7 +4378,7 @@ void SAL_CALL ScCellRangesObj::removeByName( const OUString& aName )
{
// deselect any ranges (parsed or named entry)
ScRangeList aDiff;
- bool bValid = ( aDiff.Parse( aName, &pDocSh->GetDocument() ) & ScRefFlags::VALID )
+ bool bValid = ( aDiff.Parse( aName, pDocSh->GetDocument() ) & ScRefFlags::VALID )
== ScRefFlags::VALID;
if (!bValid)
{
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
index 1df6f56dc0b7..87812b90a94f 100644
--- a/sc/source/ui/unoobj/chartuno.cxx
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -476,7 +476,7 @@ void ScChartObj::GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool&
rColHeaders=bHasCategories;
rRowHeaders=bFirstCellAsLabel;
}
- rRanges->Parse( aRanges, &rDoc);
+ rRanges->Parse( aRanges, rDoc);
}
bFound = true;
}
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 93c3404b87b3..819f5a9fd5bb 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1149,7 +1149,7 @@ ScVbaRange::getCellRangesForAddress( ScRefFlags& rResFlags, const OUString& sAdd
if ( pDocSh )
{
ScDocument& rDoc = pDocSh->GetDocument();
- rResFlags = rCellRanges.Parse( sAddress, &rDoc, eConv, 0, cDelimiter );
+ rResFlags = rCellRanges.Parse( sAddress, rDoc, eConv, 0, cDelimiter );
if ( rResFlags & ScRefFlags::VALID )
{
return true;
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
index 5c6364850308..f4331b034f71 100644
--- a/sc/source/ui/view/drawvie4.cxx
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -247,7 +247,7 @@ void getOleSourceRanges(const SdrMarkList& rMarkList, bool& rAnyOle, bool& rOneO
{
ScRangeList aRange;
ScAddress aAddr;
- if (aRange.Parse(rRangeRep, pDoc, pDoc->GetAddressConvention()) & ScRefFlags::VALID)
+ if (aRange.Parse(rRangeRep, *pDoc, pDoc->GetAddressConvention()) & ScRefFlags::VALID)
{
for(size_t i = 0; i < aRange.size(); ++i)
pRanges->push_back(aRange[i]);
More information about the Libreoffice-commits
mailing list