[Libreoffice-commits] core.git: sc/inc sc/qa sc/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 16 08:58:45 UTC 2020
sc/inc/document.hxx | 2 -
sc/qa/unit/ucalc_condformat.cxx | 2 -
sc/source/core/data/documen2.cxx | 44 +++++++++++++++++++-------------------
sc/source/core/data/documen3.cxx | 2 -
sc/source/ui/docshell/docsh5.cxx | 2 -
sc/source/ui/docshell/tablink.cxx | 2 -
6 files changed, 27 insertions(+), 27 deletions(-)
New commits:
commit 5e522d5c9b49ba2ed04cca8111044994427c20aa
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Sep 15 10:11:17 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 16 10:57:44 2020 +0200
TransferTab always dereferences its ScDocument* argument
Change-Id: I68b1fb4cda82a8a334e60b43216cfa74534e4a28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102836
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 1b756f8e82fb..0e2fc1142356 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -954,7 +954,7 @@ public:
bool MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress = nullptr );
bool CopyTab( SCTAB nOldPos, SCTAB nNewPos,
const ScMarkData* pOnlyMarked = nullptr );
- SC_DLLPUBLIC sal_uLong TransferTab(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
+ SC_DLLPUBLIC sal_uLong TransferTab(ScDocument& rSrcDoc, SCTAB nSrcPos, SCTAB nDestPos,
bool bInsertNew = true,
bool bResultsOnly = false );
SC_DLLPUBLIC void TransferDrawPage(const ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos);
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index d6f32d13b7c4..b0d66091fe2b 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -507,7 +507,7 @@ void Test::testCondCopyPasteSheetBetweenDoc()
m_pDoc->AddCondFormat(std::move(pFormat), 0);
ScDocument aDoc;
- aDoc.TransferTab(m_pDoc, 0, 0);
+ aDoc.TransferTab(*m_pDoc, 0, 0);
ScConditionalFormatList* pList = aDoc.GetCondFormList(0);
CPPUNIT_ASSERT_EQUAL(size_t(1), pList->size());
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 34af43060d15..7b50c9d1ec38 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -903,7 +903,7 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM
return bValid;
}
-sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
+sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, SCTAB nSrcPos,
SCTAB nDestPos, bool bInsertNew,
bool bResultsOnly )
{
@@ -911,29 +911,29 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
// 3 => NameBox
// 4 => both
- if (pSrcDoc->mpShell->GetMedium())
+ if (rSrcDoc.mpShell->GetMedium())
{
- pSrcDoc->maFileURL = pSrcDoc->mpShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
+ rSrcDoc.maFileURL = rSrcDoc.mpShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
// for unsaved files use the title name and adjust during save of file
- if (pSrcDoc->maFileURL.isEmpty())
- pSrcDoc->maFileURL = pSrcDoc->mpShell->GetName();
+ if (rSrcDoc.maFileURL.isEmpty())
+ rSrcDoc.maFileURL = rSrcDoc.mpShell->GetName();
}
else
{
- pSrcDoc->maFileURL = pSrcDoc->mpShell->GetName();
+ rSrcDoc.maFileURL = rSrcDoc.mpShell->GetName();
}
bool bValid = true;
if (bInsertNew) // re-insert
{
OUString aName;
- pSrcDoc->GetName(nSrcPos, aName);
+ rSrcDoc.GetName(nSrcPos, aName);
CreateValidTabName(aName);
bValid = InsertTab(nDestPos, aName);
// Copy the RTL settings
- maTabs[nDestPos]->SetLayoutRTL(pSrcDoc->maTabs[nSrcPos]->IsLayoutRTL());
- maTabs[nDestPos]->SetLoadingRTL(pSrcDoc->maTabs[nSrcPos]->IsLoadingRTL());
+ maTabs[nDestPos]->SetLayoutRTL(rSrcDoc.maTabs[nSrcPos]->IsLayoutRTL());
+ maTabs[nDestPos]->SetLoadingRTL(rSrcDoc.maTabs[nSrcPos]->IsLoadingRTL());
}
else // replace existing tables
{
@@ -953,12 +953,12 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
SetNoListening( true );
if ( bResultsOnly )
{
- bOldAutoCalcSrc = pSrcDoc->GetAutoCalc();
- pSrcDoc->SetAutoCalc( true ); // in case something needs calculation
+ bOldAutoCalcSrc = rSrcDoc.GetAutoCalc();
+ rSrcDoc.SetAutoCalc( true ); // in case something needs calculation
}
{
- NumFmtMergeHandler aNumFmtMergeHdl(this, pSrcDoc);
+ NumFmtMergeHandler aNumFmtMergeHdl(this, &rSrcDoc);
sc::CopyToDocContext aCxt(*this);
nDestPos = std::min(nDestPos, static_cast<SCTAB>(GetTableCount() - 1));
@@ -967,19 +967,19 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
if (!bResultsOnly)
{
const bool bGlobalNamesToLocal = false;
- const ScRangeName* pNames = pSrcDoc->GetRangeName( nSrcPos);
+ const ScRangeName* pNames = rSrcDoc.GetRangeName( nSrcPos);
if (pNames)
- pNames->CopyUsedNames( nSrcPos, nSrcPos, nDestPos, *pSrcDoc, *this, bGlobalNamesToLocal);
- pSrcDoc->GetRangeName()->CopyUsedNames( -1, nSrcPos, nDestPos, *pSrcDoc, *this, bGlobalNamesToLocal);
+ pNames->CopyUsedNames( nSrcPos, nSrcPos, nDestPos, rSrcDoc, *this, bGlobalNamesToLocal);
+ rSrcDoc.GetRangeName()->CopyUsedNames( -1, nSrcPos, nDestPos, rSrcDoc, *this, bGlobalNamesToLocal);
}
- pSrcDoc->maTabs[nSrcPos]->CopyToTable(aCxt, 0, 0, MaxCol(), MaxRow(),
+ rSrcDoc.maTabs[nSrcPos]->CopyToTable(aCxt, 0, 0, MaxCol(), MaxRow(),
( bResultsOnly ? InsertDeleteFlags::ALL & ~InsertDeleteFlags::FORMULA : InsertDeleteFlags::ALL),
false, maTabs[nDestPos].get(), /*pMarkData*/nullptr, /*bAsLink*/false, /*bColRowFlags*/true,
/*bGlobalNamesToLocal*/false, /*bCopyCaptions*/true );
}
}
maTabs[nDestPos]->SetTabNo(nDestPos);
- maTabs[nDestPos]->SetTabBgColor(pSrcDoc->maTabs[nSrcPos]->GetTabBgColor());
+ maTabs[nDestPos]->SetTabBgColor(rSrcDoc.maTabs[nSrcPos]->GetTabBgColor());
if ( !bResultsOnly )
{
@@ -1004,15 +1004,15 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
SetDirty( ScRange( 0, 0, nDestPos, MaxCol(), MaxRow(), nDestPos), false);
if ( bResultsOnly )
- pSrcDoc->SetAutoCalc( bOldAutoCalcSrc );
+ rSrcDoc.SetAutoCalc( bOldAutoCalcSrc );
SetAutoCalc( bOldAutoCalc );
// copy Drawing
if (bInsertNew)
- TransferDrawPage( pSrcDoc, nSrcPos, nDestPos );
+ TransferDrawPage( &rSrcDoc, nSrcPos, nDestPos );
- maTabs[nDestPos]->SetPendingRowHeights( pSrcDoc->maTabs[nSrcPos]->IsPendingRowHeights() );
+ maTabs[nDestPos]->SetPendingRowHeights( rSrcDoc.maTabs[nSrcPos]->IsPendingRowHeights() );
}
if (!bValid)
nRetVal = 0;
@@ -1020,7 +1020,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
if ( bVbaEnabled )
{
- SfxObjectShell* pSrcShell = pSrcDoc->GetDocumentShell();
+ SfxObjectShell* pSrcShell = rSrcDoc.GetDocumentShell();
if ( pSrcShell )
{
OUString aLibName("Standard");
@@ -1041,7 +1041,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
if( xLib.is() )
{
OUString sSrcCodeName;
- pSrcDoc->GetCodeName( nSrcPos, sSrcCodeName );
+ rSrcDoc.GetCodeName( nSrcPos, sSrcCodeName );
OUString sRTLSource;
xLib->getByName( sSrcCodeName ) >>= sRTLSource;
sSource = sRTLSource;
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index a3c412aff02a..f0d1e28c1947 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -577,7 +577,7 @@ bool ScDocument::LinkExternalTab( SCTAB& rTab, const OUString& aDocTab,
}
rTab = GetTableCount() - 1;
// Don't insert anew, just the results
- TransferTab( pSrcDoc, nSrcTab, rTab, false, true );
+ TransferTab( *pSrcDoc, nSrcTab, rTab, false, true );
}
else
return false;
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index db59950de64f..cdba44ccdca0 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -864,7 +864,7 @@ sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
aParam.maRanges.push_back(aRange);
rSrcDoc.SetClipParam(aParam);
- sal_uLong nErrVal = m_aDocument.TransferTab( &rSrcDoc, nSrcPos, nDestPos,
+ sal_uLong nErrVal = m_aDocument.TransferTab( rSrcDoc, nSrcPos, nDestPos,
bInsertNew ); // no insert
// TransferTab doesn't copy drawing objects with bInsertNew=FALSE
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 087119c653df..c39b0fb9cecf 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -280,7 +280,7 @@ bool ScTableLink::Refresh(const OUString& rNewFile, const OUString& rNewFilter,
}
if (bFound)
- rDoc.TransferTab( &rSrcDoc, nSrcTab, nTab, false, // don't insert anew
+ rDoc.TransferTab( rSrcDoc, nSrcTab, nTab, false, // don't insert anew
(nMode == ScLinkMode::VALUE) ); // only values?
else
{
More information about the Libreoffice-commits
mailing list