summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-15 10:26:01 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-16 11:37:57 +0200
commitfa9c68a5410e9d62124519adf70f0d6e9b95b5e3 (patch)
tree16c02171930a685126ab50ea415f4d6900ec6915 /sc
parentd30af8c77940b9e7d03a21a595d3eeaf703ddea3 (diff)
AdjustRangesOfChartsOnDestinationPage never passed null ScDocument*s
Change-Id: Ic31a6b19dc9701bb4e8be500050ca6f689352342 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102838 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/charthelper.hxx2
-rw-r--r--sc/source/core/data/documen9.cxx2
-rw-r--r--sc/source/core/tool/charthelper.cxx14
-rw-r--r--sc/source/ui/view/viewfun2.cxx29
4 files changed, 22 insertions, 25 deletions
diff --git a/sc/inc/charthelper.hxx b/sc/inc/charthelper.hxx
index 4f850f155b38..2228d06506c7 100644
--- a/sc/inc/charthelper.hxx
+++ b/sc/inc/charthelper.hxx
@@ -37,7 +37,7 @@ class ScChartHelper
{
public:
static sal_uInt16 DoUpdateAllCharts( ScDocument* pDoc );
- static void AdjustRangesOfChartsOnDestinationPage( const ScDocument* pSrcDoc, ScDocument* pDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab );
+ static void AdjustRangesOfChartsOnDestinationPage( const ScDocument& rSrcDoc, ScDocument& rDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab );
static void UpdateChartsOnDestinationPage( ScDocument* pDestDoc, const SCTAB nDestTab );
static css::uno::Reference< css::chart2::XChartDocument > GetChartFromSdrObject( const SdrObject* pObject );
static void GetChartRanges( const css::uno::Reference< css::chart2::XChartDocument >& xChartDoc,
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index fdf2605b09a0..6a188d847115 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -89,7 +89,7 @@ void ScDocument::TransferDrawPage(const ScDocument& rSrcDoc, SCTAB nSrcPos, SCTA
// make sure the data references of charts are adapted
// (this must be after InsertObject!)
- ScChartHelper::AdjustRangesOfChartsOnDestinationPage( &rSrcDoc, this, nSrcPos, nDestPos );
+ ScChartHelper::AdjustRangesOfChartsOnDestinationPage( rSrcDoc, *this, nSrcPos, nDestPos );
ScChartHelper::UpdateChartsOnDestinationPage(this, nDestPos);
}
diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx
index 326b041857be..cabc209077f5 100644
--- a/sc/source/core/tool/charthelper.cxx
+++ b/sc/source/core/tool/charthelper.cxx
@@ -109,11 +109,9 @@ sal_uInt16 ScChartHelper::DoUpdateAllCharts( ScDocument* pDoc )
return lcl_DoUpdateCharts( pDoc );
}
-void ScChartHelper::AdjustRangesOfChartsOnDestinationPage( const ScDocument* pSrcDoc, ScDocument* pDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab )
+void ScChartHelper::AdjustRangesOfChartsOnDestinationPage( const ScDocument& rSrcDoc, ScDocument& rDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab )
{
- if( !pSrcDoc || !pDestDoc )
- return;
- ScDrawLayer* pDrawLayer = pDestDoc->GetDrawLayer();
+ ScDrawLayer* pDrawLayer = rDestDoc.GetDrawLayer();
if( !pDrawLayer )
return;
@@ -129,18 +127,18 @@ void ScChartHelper::AdjustRangesOfChartsOnDestinationPage( const ScDocument* pSr
{
OUString aChartName = static_cast<SdrOle2Obj*>(pObject)->GetPersistName();
- Reference< chart2::XChartDocument > xChartDoc( pDestDoc->GetChartByName( aChartName ) );
+ Reference< chart2::XChartDocument > xChartDoc( rDestDoc.GetChartByName( aChartName ) );
Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
if( xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider() )
{
::std::vector< ScRangeList > aRangesVector;
- pDestDoc->GetChartRanges( aChartName, aRangesVector, *pSrcDoc );
+ rDestDoc.GetChartRanges( aChartName, aRangesVector, rSrcDoc );
for( ScRangeList& rScRangeList : aRangesVector )
{
- lcl_AdjustRanges( rScRangeList, nSrcTab, nDestTab, pDestDoc->GetTableCount() );
+ lcl_AdjustRanges( rScRangeList, nSrcTab, nDestTab, rDestDoc.GetTableCount() );
}
- pDestDoc->SetChartRanges( aChartName, aRangesVector );
+ rDestDoc.SetChartRanges( aChartName, aRangesVector );
}
}
pObject = aIter.Next();
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index fd0e48b8eff7..b9d5e389e4b6 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2766,7 +2766,6 @@ void ScViewFunc::MoveTable(
{
ScDocument& rDoc = GetViewData().GetDocument();
ScDocShell* pDocShell = GetViewData().GetDocShell();
- ScDocument* pDestDoc = nullptr;
ScDocShell* pDestShell = nullptr;
ScTabViewShell* pDestViewSh = nullptr;
bool bUndo (rDoc.IsUndoEnabled());
@@ -2816,15 +2815,15 @@ void ScViewFunc::MoveTable(
return;
}
- pDestDoc = &pDestShell->GetDocument();
+ ScDocument& rDestDoc = pDestShell->GetDocument();
- if (pDestDoc != &rDoc)
+ if (&rDestDoc != &rDoc)
{
if (bNewDoc)
{
- while (pDestDoc->GetTableCount() > 1)
- pDestDoc->DeleteTab(0);
- pDestDoc->RenameTab( 0, "______42_____" );
+ while (rDestDoc.GetTableCount() > 1)
+ rDestDoc.DeleteTab(0);
+ rDestDoc.RenameTab( 0, "______42_____" );
}
SCTAB nTabCount = rDoc.GetTableCount();
@@ -2858,11 +2857,11 @@ void ScViewFunc::MoveTable(
pDestShell->MakeDrawLayer();
if (!bNewDoc && bUndo)
- pDestDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
+ rDestDoc.BeginDrawUndo(); // drawing layer must do its own undo actions
sal_uLong nErrVal =1;
if(nDestTab==SC_TAB_APPEND)
- nDestTab=pDestDoc->GetTableCount();
+ nDestTab=rDestDoc.GetTableCount();
SCTAB nDestTab1=nDestTab;
ScClipParam aParam;
for( size_t j=0; j<TheTabs.size(); ++j, ++nDestTab1 )
@@ -2873,8 +2872,8 @@ void ScViewFunc::MoveTable(
else
rDoc.GetName( TheTabs[j], aName );
- pDestDoc->CreateValidTabName( aName );
- if ( !pDestDoc->InsertTab( nDestTab1, aName ) )
+ rDestDoc.CreateValidTabName( aName );
+ if ( !rDestDoc.InsertTab( nDestTab1, aName ) )
{
nErrVal = 0; // total error
break; // for
@@ -2895,7 +2894,7 @@ void ScViewFunc::MoveTable(
OUString sName;
if (!bNewDoc && bUndo)
{
- pDestDoc->GetName(nDestTab, sName);
+ rDestDoc.GetName(nDestTab, sName);
pDestShell->GetUndoManager()->AddUndoAction(
std::make_unique<ScUndoImportTab>( pDestShell, nDestTab,
static_cast<SCTAB>(TheTabs.size())));
@@ -2941,13 +2940,13 @@ void ScViewFunc::MoveTable(
if (bNewDoc)
{
// ChartListenerCollection must be updated before DeleteTab
- if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
- pDestDoc->UpdateChartListenerCollection();
+ if ( rDestDoc.IsChartListenerCollectionNeedsUpdate() )
+ rDestDoc.UpdateChartListenerCollection();
SCTAB nNumTabsInserted = static_cast<SCTAB>(TheTabs.size());
pDestShell->Broadcast( ScTablesHint( SC_TABS_INSERTED, 0, nNumTabsInserted ) );
- pDestDoc->DeleteTab( nNumTabsInserted ); // old first table
+ rDestDoc.DeleteTab( nNumTabsInserted ); // old first table
pDestShell->Broadcast( ScTablesHint( SC_TAB_DELETED, nNumTabsInserted ) );
if (pDestViewSh)
@@ -3108,7 +3107,7 @@ void ScViewFunc::MoveTable(
//#i29848# adjust references to data on the copied sheet
if( bCopy )
- ScChartHelper::AdjustRangesOfChartsOnDestinationPage( &rDoc, pDestDoc, nTab, nNewTab );
+ ScChartHelper::AdjustRangesOfChartsOnDestinationPage( rDoc, rDestDoc, nTab, nNewTab );
}
}