summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/cellvalue.hxx2
-rw-r--r--sc/inc/dociter.hxx10
-rw-r--r--sc/inc/dpcache.hxx8
-rw-r--r--sc/inc/dpobject.hxx16
-rw-r--r--sc/qa/unit/ucalc_pivottable.cxx4
-rw-r--r--sc/source/core/data/cellvalue.cxx4
-rw-r--r--sc/source/core/data/dociter.cxx58
-rw-r--r--sc/source/core/data/documen3.cxx2
-rw-r--r--sc/source/core/data/dpcache.cxx77
-rw-r--r--sc/source/core/data/dpdimsave.cxx4
-rw-r--r--sc/source/core/data/dpobject.cxx46
-rw-r--r--sc/source/core/tool/interpr2.cxx2
12 files changed, 116 insertions, 117 deletions
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 68e38d845c84..5dfe66ba2763 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -170,7 +170,7 @@ struct SC_DLLPUBLIC ScRefCellValue
*
* This method is thread-safe.
*/
- OUString getRawString( const ScDocument* pDoc ) const;
+ OUString getRawString( const ScDocument& rDoc ) const;
bool isEmpty() const;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 81cb345cfa82..23e35e06514a 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -131,7 +131,7 @@ private:
{
typedef std::pair<sc::CellStoreType::const_iterator,size_t> PositionType;
public:
- DataAccessInternal(ScDBQueryParamInternal* pParam, ScDocument* pDoc, const ScInterpreterContext& rContext);
+ DataAccessInternal(ScDBQueryParamInternal* pParam, ScDocument& rDoc, const ScInterpreterContext& rContext);
virtual ~DataAccessInternal() override;
virtual bool getCurrent(Value& rValue) override;
virtual bool getFirst(Value& rValue) override;
@@ -144,7 +144,7 @@ private:
const sc::CellStoreType* mpCells;
PositionType maCurPos;
ScDBQueryParamInternal* mpParam;
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
const ScInterpreterContext& mrContext;
const ScAttrArray* pAttrArray;
sal_uInt32 nNumFormat; // for CalcAsShown
@@ -479,8 +479,8 @@ private:
class ScHorizontalValueIterator
{
private:
- ScDocument *pDoc;
- const ScAttrArray *pAttrArray;
+ ScDocument& rDoc;
+ const ScAttrArray* pAttrArray;
std::unique_ptr<ScHorizontalCellIterator>
pCellIter;
sal_uInt32 nNumFormat; // for CalcAsShown
@@ -493,7 +493,7 @@ private:
public:
- ScHorizontalValueIterator( ScDocument* pDocument,
+ ScHorizontalValueIterator( ScDocument& rDocument,
const ScRange& rRange );
~ScHorizontalValueIterator();
/// Does NOT reset rValue if no value found!
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 50088234f398..9265046d939d 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -108,7 +108,7 @@ public:
private:
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
SCCOL mnColumnCount;
/**
@@ -169,7 +169,7 @@ public:
const IndexArrayType* GetFieldIndexArray( size_t nDim ) const;
const ScDPItemDataVec& GetDimMemberValues( SCCOL nDim ) const;
- void InitFromDoc(ScDocument* pDoc, const ScRange& rRange);
+ void InitFromDoc(ScDocument& rDoc, const ScRange& rRange);
bool InitFromDataBase(DBConnector& rDB);
/**
@@ -189,7 +189,7 @@ public:
bool IsRowEmpty(SCROW nRow) const;
bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const;
- ScDocument* GetDoc() const;
+ ScDocument& GetDoc() const;
long GetColumnCount() const;
const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
@@ -199,7 +199,7 @@ public:
ScDPCache(const ScDPCache&) = delete;
const ScDPCache& operator=(const ScDPCache&) = delete;
- ScDPCache(ScDocument* pDoc);
+ ScDPCache(ScDocument& rDoc);
~ScDPCache();
#if DUMP_PIVOT_TABLE
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index a1a2c6e9e4b6..992e719e76ef 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -292,9 +292,9 @@ public:
typedef std::vector<ScRange> RangeIndexType;
CachesType m_Caches;
RangeIndexType maRanges;
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
public:
- SheetCaches(ScDocument* pDoc);
+ SheetCaches(ScDocument& rDoc);
bool hasCache(const ScRange& rRange) const;
const ScDPCache* getCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData);
SC_DLLPUBLIC size_t size() const;
@@ -319,9 +319,9 @@ public:
friend class ScDPCollection;
typedef ::std::map<OUString, std::unique_ptr<ScDPCache>> CachesType;
CachesType m_Caches;
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
public:
- NameCaches(ScDocument* pDoc);
+ NameCaches(ScDocument& rDoc);
bool hasCache(const OUString& rName) const;
const ScDPCache* getCache(
const OUString& rName, const ScRange& rRange, const ScDPDimensionSaveData* pDimData);
@@ -359,9 +359,9 @@ public:
friend class ScDPCollection;
typedef ::std::map<DBType, std::unique_ptr<ScDPCache>, DBType::less> CachesType;
CachesType m_Caches;
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
public:
- DBCaches(ScDocument* pDoc);
+ DBCaches(ScDocument& rDoc);
bool hasCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) const;
const ScDPCache* getCache(
sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
@@ -380,7 +380,7 @@ public:
bool remove(const ScDPCache* p);
};
- ScDPCollection(ScDocument* pDocument);
+ ScDPCollection(ScDocument& rDocument);
ScDPCollection(const ScDPCollection& r);
~ScDPCollection();
@@ -442,7 +442,7 @@ private:
private:
typedef std::vector< std::unique_ptr<ScDPObject> > TablesType;
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
TablesType maTables;
SheetCaches maSheetCaches;
NameCaches maNameCaches;
diff --git a/sc/qa/unit/ucalc_pivottable.cxx b/sc/qa/unit/ucalc_pivottable.cxx
index 9649eeb7b598..30308802e5e9 100644
--- a/sc/qa/unit/ucalc_pivottable.cxx
+++ b/sc/qa/unit/ucalc_pivottable.cxx
@@ -773,8 +773,8 @@ void Test::testPivotTableCache()
ScRange aDataRange = insertRangeData(m_pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
CPPUNIT_ASSERT_EQUAL_MESSAGE("failed to insert range data at correct position", aPos, aDataRange.aStart);
- ScDPCache aCache(m_pDoc);
- aCache.InitFromDoc(m_pDoc, aDataRange);
+ ScDPCache aCache(*m_pDoc);
+ aCache.InitFromDoc(*m_pDoc, aDataRange);
long nDimCount = aCache.GetColumnCount();
CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong dimension count.", 3L, nDimCount);
OUString aDimName = aCache.GetDimensionName(0);
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 463b7695e786..dc6cdaa326c4 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -662,9 +662,9 @@ OUString ScRefCellValue::getString( const ScDocument* pDoc ) const
return getStringImpl(*this, pDoc);
}
-OUString ScRefCellValue::getRawString( const ScDocument* pDoc ) const
+OUString ScRefCellValue::getRawString( const ScDocument& rDoc ) const
{
- return getRawStringImpl(*this, pDoc);
+ return getRawStringImpl(*this, &rDoc);
}
bool ScRefCellValue::isEmpty() const
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 217d997bafbd..0d2591191743 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -78,21 +78,21 @@ void decBlock(std::pair<Iter, size_t>& rPos)
static void ScAttrArray_IterGetNumberFormat( sal_uInt32& nFormat, const ScAttrArray*& rpArr,
SCROW& nAttrEndRow, const ScAttrArray* pNewArr, SCROW nRow,
- const ScDocument* pDoc, const ScInterpreterContext* pContext = nullptr )
+ const ScDocument& rDoc, const ScInterpreterContext* pContext = nullptr )
{
if ( rpArr == pNewArr && nAttrEndRow >= nRow )
return;
SCROW nRowStart = 0;
- SCROW nRowEnd = pDoc->MaxRow();
+ SCROW nRowEnd = rDoc.MaxRow();
const ScPatternAttr* pPattern = pNewArr->GetPatternRange( nRowStart, nRowEnd, nRow );
if( !pPattern )
{
- pPattern = pDoc->GetDefPattern();
- nRowEnd = pDoc->MaxRow();
+ pPattern = rDoc.GetDefPattern();
+ nRowEnd = rDoc.MaxRow();
}
- nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : pDoc->GetFormatTable() );
+ nFormat = pPattern->GetNumberFormat( pContext ? pContext->GetFormatTable() : rDoc.GetFormatTable() );
rpArr = pNewArr;
nAttrEndRow = nRowEnd;
}
@@ -209,7 +209,7 @@ bool ScValueIterator::GetThis(double& rValue, FormulaError& rErr)
if (bCalcAsShown)
{
ScAttrArray_IterGetNumberFormat(nNumFormat, pAttrArray,
- nAttrEndRow, pCol->pAttrArray.get(), nCurRow, &mrDoc, pContext);
+ nAttrEndRow, pCol->pAttrArray.get(), nCurRow, mrDoc, pContext);
rValue = mrDoc.RoundValueAsShown(rValue, nNumFormat, pContext);
}
return true; // Found it!
@@ -344,11 +344,11 @@ bool ScDBQueryDataIterator::IsQueryValid(
return rDoc.maTabs[nTab]->ValidQuery(nRow, rParam, pCell);
}
-ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(ScDBQueryParamInternal* pParam, ScDocument* pDoc, const ScInterpreterContext& rContext)
+ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(ScDBQueryParamInternal* pParam, ScDocument& rDoc, const ScInterpreterContext& rContext)
: DataAccess()
, mpCells(nullptr)
, mpParam(pParam)
- , mpDoc(pDoc)
+ , mrDoc(rDoc)
, mrContext(rContext)
, pAttrArray(nullptr)
, nNumFormat(0) // Initialized in GetNumberFormat
@@ -358,7 +358,7 @@ ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(ScDBQueryParamInte
, nAttrEndRow(0)
, nTab(mpParam->nTab)
, nNumFmtType(SvNumFormatType::ALL)
- , bCalcAsShown(pDoc->GetDocOptions().IsCalcAsShown())
+ , bCalcAsShown(rDoc.GetDocOptions().IsCalcAsShown())
{
SCSIZE i;
SCSIZE nCount = mpParam->GetEntryCount();
@@ -369,7 +369,7 @@ ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(ScDBQueryParamInte
rItems.resize(1);
ScQueryEntry::Item& rItem = rItems.front();
sal_uInt32 nIndex = 0;
- bool bNumber = mpDoc->GetFormatTable()->IsNumberFormat(
+ bool bNumber = mrDoc.GetFormatTable()->IsNumberFormat(
rItem.maString.getString(), nIndex, rItem.mfVal);
rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
}
@@ -412,7 +412,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
pCell = &aCell;
}
- if (ScDBQueryDataIterator::IsQueryValid(*mpDoc, *mpParam, nTab, nRow, pCell))
+ if (ScDBQueryDataIterator::IsQueryValid(mrDoc, *mpParam, nTab, nRow, pCell))
{
if (!pCell)
aCell = sc::toRefCell(maCurPos.first, maCurPos.second);
@@ -425,10 +425,10 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
if ( bCalcAsShown )
{
const ScAttrArray* pNewAttrArray =
- ScDBQueryDataIterator::GetAttrArrayByCol(*mpDoc, nTab, nCol);
+ ScDBQueryDataIterator::GetAttrArrayByCol(mrDoc, nTab, nCol);
ScAttrArray_IterGetNumberFormat( nNumFormat, pAttrArray,
- nAttrEndRow, pNewAttrArray, nRow, mpDoc );
- rValue.mfValue = mpDoc->RoundValueAsShown( rValue.mfValue, nNumFormat );
+ nAttrEndRow, pNewAttrArray, nRow, mrDoc );
+ rValue.mfValue = mrDoc.RoundValueAsShown( rValue.mfValue, nNumFormat );
}
nNumFmtType = SvNumFormatType::NUMBER;
nNumFmtIndex = 0;
@@ -442,7 +442,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
{
rValue.mfValue = aCell.mpFormula->GetValue();
rValue.mbIsNumber = true;
- mpDoc->GetNumberFormatInfo(
+ mrDoc.GetNumberFormatInfo(
mrContext, nNumFmtType, nNumFmtIndex, ScAddress(nCol, nRow, nTab));
rValue.mnError = aCell.mpFormula->GetErrCode();
return true; // Found it!
@@ -465,7 +465,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue)
incPos();
else
{
- rValue.maString = aCell.getString(mpDoc);
+ rValue.maString = aCell.getString(&mrDoc);
rValue.mfValue = 0.0;
rValue.mnError = FormulaError::NONE;
rValue.mbIsNumber = false;
@@ -487,7 +487,7 @@ bool ScDBQueryDataIterator::DataAccessInternal::getFirst(Value& rValue)
if (mpParam->bHasHeader)
++nRow;
- mpCells = ScDBQueryDataIterator::GetColumnCellStore(*mpDoc, nTab, nCol);
+ mpCells = ScDBQueryDataIterator::GetColumnCellStore(mrDoc, nTab, nCol);
if (!mpCells)
return false;
@@ -758,7 +758,7 @@ ScDBQueryDataIterator::ScDBQueryDataIterator(ScDocument& rDocument, const ScInte
case ScDBQueryParamBase::INTERNAL:
{
ScDBQueryParamInternal* p = static_cast<ScDBQueryParamInternal*>(mpParam.get());
- mpData.reset(new DataAccessInternal(p, &rDocument, rContext));
+ mpData.reset(new DataAccessInternal(p, rDocument, rContext));
}
break;
case ScDBQueryParamBase::MATRIX:
@@ -2287,11 +2287,11 @@ void ScHorizontalCellIterator::SkipInvalid()
mbMore = false;
}
-ScHorizontalValueIterator::ScHorizontalValueIterator( ScDocument* pDocument,
+ScHorizontalValueIterator::ScHorizontalValueIterator( ScDocument& rDocument,
const ScRange& rRange ) :
- pDoc( pDocument ),
+ rDoc( rDocument ),
nEndTab( rRange.aEnd.Tab() ),
- bCalcAsShown( pDocument->GetDocOptions().IsCalcAsShown() )
+ bCalcAsShown( rDocument.GetDocOptions().IsCalcAsShown() )
{
SCCOL nStartCol = rRange.aStart.Col();
SCROW nStartRow = rRange.aStart.Row();
@@ -2302,10 +2302,10 @@ ScHorizontalValueIterator::ScHorizontalValueIterator( ScDocument* pDocument,
PutInOrder( nStartRow, nEndRow);
PutInOrder( nStartTab, nEndTab );
- if (!pDoc->ValidCol(nStartCol)) nStartCol = pDoc->MaxCol();
- if (!pDoc->ValidCol(nEndCol)) nEndCol = pDoc->MaxCol();
- if (!pDoc->ValidRow(nStartRow)) nStartRow = pDoc->MaxRow();
- if (!pDoc->ValidRow(nEndRow)) nEndRow = pDoc->MaxRow();
+ if (!rDoc.ValidCol(nStartCol)) nStartCol = rDoc.MaxCol();
+ if (!rDoc.ValidCol(nEndCol)) nEndCol = rDoc.MaxCol();
+ if (!rDoc.ValidRow(nStartRow)) nStartRow = rDoc.MaxRow();
+ if (!rDoc.ValidRow(nEndRow)) nEndRow = rDoc.MaxRow();
if (!ValidTab(nStartTab)) nStartTab = MAXTAB;
if (!ValidTab(nEndTab)) nEndTab = MAXTAB;
@@ -2317,7 +2317,7 @@ ScHorizontalValueIterator::ScHorizontalValueIterator( ScDocument* pDocument,
pAttrArray = nullptr;
nAttrEndRow = 0;
- pCellIter.reset( new ScHorizontalCellIterator( pDoc, nStartTab, nStartCol,
+ pCellIter.reset( new ScHorizontalCellIterator( &rDoc, nStartTab, nStartCol,
nStartRow, nEndCol, nEndRow ) );
}
@@ -2349,10 +2349,10 @@ bool ScHorizontalValueIterator::GetNext( double& rValue, FormulaError& rErr )
rErr = FormulaError::NONE;
if ( bCalcAsShown )
{
- ScColumn* pCol = &pDoc->maTabs[nCurTab]->aCol[nCurCol];
+ ScColumn* pCol = &rDoc.maTabs[nCurTab]->aCol[nCurCol];
ScAttrArray_IterGetNumberFormat( nNumFormat, pAttrArray,
- nAttrEndRow, pCol->pAttrArray.get(), nCurRow, pDoc );
- rValue = pDoc->RoundValueAsShown( rValue, nNumFormat );
+ nAttrEndRow, pCol->pAttrArray.get(), nCurRow, rDoc );
+ rValue = rDoc.RoundValueAsShown( rValue, nNumFormat );
}
bFound = true;
}
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 790203a4d76d..69c93b30e221 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -346,7 +346,7 @@ bool ScDocument::HasPivotTable() const
ScDPCollection* ScDocument::GetDPCollection()
{
if (!pDPCollection)
- pDPCollection.reset( new ScDPCollection(this) );
+ pDPCollection.reset( new ScDPCollection(*this) );
return pDPCollection.get();
}
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 0fbaa52bd57d..6a6cddb5f67f 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -68,10 +68,10 @@ ScDPCache::GroupItems::GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGrou
ScDPCache::Field::Field() : mnNumFormat(0) {}
-ScDPCache::ScDPCache(ScDocument* pDoc) :
- mpDoc( pDoc ),
+ScDPCache::ScDPCache(ScDocument& rDoc) :
+ mrDoc( rDoc ),
mnColumnCount ( 0 ),
- maEmptyRows(0, pDoc->GetSheetLimits().GetMaxRowCount(), true),
+ maEmptyRows(0, rDoc.GetSheetLimits().GetMaxRowCount(), true),
mnDataSize(-1),
mnRowCount(0),
mbDisposing(false)
@@ -107,17 +107,17 @@ namespace {
class MacroInterpretIncrementer
{
public:
- explicit MacroInterpretIncrementer(ScDocument* pDoc) :
- mpDoc(pDoc)
+ explicit MacroInterpretIncrementer(ScDocument& rDoc) :
+ mrDoc(rDoc)
{
- mpDoc->IncMacroInterpretLevel();
+ mrDoc.IncMacroInterpretLevel();
}
~MacroInterpretIncrementer()
{
- mpDoc->DecMacroInterpretLevel();
+ mrDoc.DecMacroInterpretLevel();
}
private:
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
};
rtl_uString* internString( ScDPCache::StringSetType& rPool, const OUString& rStr )
@@ -125,9 +125,9 @@ rtl_uString* internString( ScDPCache::StringSetType& rPool, const OUString& rStr
return rPool.insert(rStr).first->pData;
}
-OUString createLabelString( const ScDocument* pDoc, SCCOL nCol, const ScRefCellValue& rCell )
+OUString createLabelString( const ScDocument& rDoc, SCCOL nCol, const ScRefCellValue& rCell )
{
- OUString aDocStr = rCell.getRawString(pDoc);
+ OUString aDocStr = rCell.getRawString(rDoc);
if (aDocStr.isEmpty())
{
@@ -144,20 +144,20 @@ OUString createLabelString( const ScDocument* pDoc, SCCOL nCol, const ScRefCellV
}
void initFromCell(
- ScDPCache::StringSetType& rStrPool, const ScDocument* pDoc, const ScAddress& rPos,
+ ScDPCache::StringSetType& rStrPool, const ScDocument& rDoc, const ScAddress& rPos,
const ScRefCellValue& rCell, ScDPItemData& rData, sal_uInt32& rNumFormat)
{
- OUString aDocStr = rCell.getRawString(pDoc);
+ OUString aDocStr = rCell.getRawString(rDoc);
rNumFormat = 0;
if (rCell.hasError())
{
- rData.SetErrorStringInterned(internString(rStrPool, pDoc->GetString(rPos.Col(), rPos.Row(), rPos.Tab())));
+ rData.SetErrorStringInterned(internString(rStrPool, rDoc.GetString(rPos.Col(), rPos.Row(), rPos.Tab())));
}
else if (rCell.hasNumeric())
{
double fVal = rCell.getRawValue();
- rNumFormat = pDoc->GetNumberFormat(rPos);
+ rNumFormat = rDoc.GetNumberFormat(rPos);
rData.SetValue(fVal);
}
else if (!rCell.isEmpty())
@@ -319,14 +319,14 @@ struct InitColumnData
struct InitDocData
{
- ScDocument* mpDoc;
+ ScDocument& mrDoc;
SCTAB mnDocTab;
SCROW mnStartRow;
SCROW mnEndRow;
bool mbTailEmptyRows;
- InitDocData() :
- mpDoc(nullptr),
+ InitDocData(ScDocument& rDoc) :
+ mrDoc(rDoc),
mnDocTab(-1),
mnStartRow(-1),
mnEndRow(-1),
@@ -388,7 +388,7 @@ std::vector<OUString> normalizeLabels(const ScDPCache::DBConnector& rDB, const s
void initColumnFromDoc( InitDocData& rDocData, InitColumnData &rColData )
{
ScDPCache::Field& rField = *rColData.mpField;
- ScDocument* pDoc = rDocData.mpDoc;
+ ScDocument& rDoc = rDocData.mrDoc;
SCTAB nDocTab = rDocData.mnDocTab;
SCCOL nCol = rColData.mnCol;
SCROW nStartRow = rDocData.mnStartRow;
@@ -396,13 +396,13 @@ void initColumnFromDoc( InitDocData& rDocData, InitColumnData &rColData )
bool bTailEmptyRows = rDocData.mbTailEmptyRows;
std::unique_ptr<sc::ColumnIterator> pIter =
- pDoc->GetColumnIterator(nDocTab, nCol, nStartRow, nEndRow);
+ rDoc.GetColumnIterator(nDocTab, nCol, nStartRow, nEndRow);
assert(pIter);
assert(pIter->hasCell());
ScDPItemData aData;
- rColData.maLabel = createLabelString(pDoc, nCol, pIter->getCell());
+ rColData.maLabel = createLabelString(rDoc, nCol, pIter->getCell());
pIter->next();
std::vector<Bucket> aBuckets;
@@ -415,7 +415,7 @@ void initColumnFromDoc( InitDocData& rDocData, InitColumnData &rColData )
sal_uInt32 nNumFormat = 0;
ScAddress aPos(nCol, pIter->getRow(), nDocTab);
- initFromCell(*rColData.mpStrPool, pDoc, aPos, pIter->getCell(), aData, nNumFormat);
+ initFromCell(*rColData.mpStrPool, rDoc, aPos, pIter->getCell(), aData, nNumFormat);
aBuckets.emplace_back(aData, i);
@@ -507,24 +507,23 @@ public:
}
-void ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
+void ScDPCache::InitFromDoc(ScDocument& rDoc, const ScRange& rRange)
{
Clear();
- InitDocData aDocData;
- aDocData.mpDoc = pDoc;
+ InitDocData aDocData(rDoc);
// Make sure the formula cells within the data range are interpreted
// during this call, for this method may be called from the interpretation
// of GETPIVOTDATA, which disables nested formula interpretation without
// increasing the macro level.
- MacroInterpretIncrementer aMacroInc(pDoc);
+ MacroInterpretIncrementer aMacroInc(rDoc);
aDocData.mnStartRow = rRange.aStart.Row(); // start of data
aDocData.mnEndRow = rRange.aEnd.Row();
// Sanity check
- if (!GetDoc()->ValidRow(aDocData.mnStartRow) || !GetDoc()->ValidRow(aDocData.mnEndRow) || aDocData.mnEndRow <= aDocData.mnStartRow)
+ if (!GetDoc().ValidRow(aDocData.mnStartRow) || !GetDoc().ValidRow(aDocData.mnEndRow) || aDocData.mnEndRow <= aDocData.mnStartRow)
return;
SCCOL nStartCol = rRange.aStart.Col();
@@ -539,7 +538,7 @@ void ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
// Skip trailing empty rows if exists.
SCCOL nCol1 = nStartCol, nCol2 = nEndCol;
SCROW nRow1 = aDocData.mnStartRow, nRow2 = aDocData.mnEndRow;
- pDoc->ShrinkToDataArea(aDocData.mnDocTab, nCol1, nRow1, nCol2, nRow2);
+ rDoc.ShrinkToDataArea(aDocData.mnDocTab, nCol1, nRow1, nCol2, nRow2);
aDocData.mbTailEmptyRows = aDocData.mnEndRow > nRow2; // Trailing empty rows exist.
aDocData.mnEndRow = nRow2;
@@ -553,7 +552,7 @@ void ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
}
maStringPools.resize(mnColumnCount);
- std::vector<InitColumnData> aColData(mnColumnCount, InitColumnData(pDoc->GetSheetLimits()));
+ std::vector<InitColumnData> aColData(mnColumnCount, InitColumnData(rDoc.GetSheetLimits()));
maFields.reserve(mnColumnCount);
for (SCCOL i = 0; i < mnColumnCount; ++i)
maFields.push_back(std::make_unique<Field>());
@@ -561,7 +560,7 @@ void ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
maLabelNames.reserve(mnColumnCount+1);
// Ensure that none of the formula cells in the data range are dirty.
- pDoc->EnsureFormulaCellResults(rRange);
+ rDoc.EnsureFormulaCellResults(rRange);
#if ENABLE_THREADED_PIVOT_CACHE
ThreadQueue aQueue(std::thread::hardware_concurrency());
@@ -659,7 +658,7 @@ bool ScDPCache::InitFromDataBase(DBConnector& rDB)
if (!aData.IsEmpty())
{
maEmptyRows.insert_back(nRow, nRow+1, false);
- SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
+ SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
rField.mnNumFormat = pFormatter ? pFormatter->GetStandardFormat(nFormatType) : 0;
}
@@ -692,7 +691,7 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
if (!rParam.GetEntry(0).bDoQuery)
return true;
- bool bMatchWholeCell = mpDoc->GetDocOptions().IsMatchWholeCell();
+ bool bMatchWholeCell = mrDoc.GetDocOptions().IsMatchWholeCell();
SCSIZE nEntryCount = rParam.GetEntryCount();
std::vector<bool> aPassed(nEntryCount, false);
@@ -883,9 +882,9 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
return bRet;
}
-ScDocument* ScDPCache::GetDoc() const
+ScDocument& ScDPCache::GetDoc() const
{
- return mpDoc;
+ return mrDoc;
}
long ScDPCache::GetColumnCount() const
@@ -1071,7 +1070,7 @@ bool ScDPCache::IsDateDimension( long nDim ) const
if (nDim >= mnColumnCount)
return false;
- SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
+ SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
if (!pFormatter)
return false;
@@ -1114,7 +1113,7 @@ void ScDPCache::RemoveReference(ScDPObject* pObj) const
maRefObjects.erase(pObj);
if (maRefObjects.empty())
- mpDoc->GetDPCollection()->RemoveCache(this);
+ mrDoc.GetDPCollection()->RemoveCache(this);
}
const ScDPCache::ScDPObjectSet& ScDPCache::GetAllReferences() const
@@ -1217,7 +1216,7 @@ OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem, boo
if (eType == ScDPItemData::Value)
{
// Format value using the stored number format.
- SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
+ SvNumberFormatter* pFormatter = mrDoc.GetFormatTable();
if (pFormatter)
{
sal_uInt32 nNumFormat = GetNumberFormat(nDim);
@@ -1245,7 +1244,7 @@ OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem, boo
fEnd = p->maInfo.mfEnd;
}
return ScDPUtil::getDateGroupName(
- aAttr.mnGroupType, aAttr.mnValue, mpDoc->GetFormatTable(), fStart, fEnd);
+ aAttr.mnGroupType, aAttr.mnValue, mrDoc.GetFormatTable(), fStart, fEnd);
}
if (eType == ScDPItemData::RangeStart)
@@ -1256,7 +1255,7 @@ OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem, boo
return rItem.GetString();
sal_Unicode cDecSep = ScGlobal::getLocaleDataPtr()->getNumDecimalSep()[0];
- return ScDPUtil::getNumGroupName(fVal, p->maInfo, cDecSep, mpDoc->GetFormatTable());
+ return ScDPUtil::getNumGroupName(fVal, p->maInfo, cDecSep, mrDoc.GetFormatTable());
}
return rItem.GetString();
@@ -1264,7 +1263,7 @@ OUString ScDPCache::GetFormattedString(long nDim, const ScDPItemData& rItem, boo
SvNumberFormatter* ScDPCache::GetNumberFormatter() const
{
- return mpDoc->GetFormatTable();
+ return mrDoc.GetFormatTable();
}
long ScDPCache::AppendGroupField()
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx
index 8df2a547eaa6..99a442a338b3 100644
--- a/sc/source/core/data/dpdimsave.cxx
+++ b/sc/source/core/data/dpdimsave.cxx
@@ -368,7 +368,7 @@ void ScDPSaveGroupDimension::AddToCache(ScDPCache& rCache) const
return;
long nDim = rCache.AppendGroupField();
- SvNumberFormatter* pFormatter = rCache.GetDoc()->GetFormatTable();
+ SvNumberFormatter* pFormatter = rCache.GetDoc().GetFormatTable();
if (nDatePart)
{
@@ -428,7 +428,7 @@ void ScDPSaveNumGroupDimension::AddToCache(ScDPCache& rCache) const
if (aDateInfo.mbEnable)
{
// Date grouping
- SvNumberFormatter* pFormatter = rCache.GetDoc()->GetFormatTable();
+ SvNumberFormatter* pFormatter = rCache.GetDoc().GetFormatTable();
fillDateGroupDimension(rCache, aDateInfo, nDim, nDim, nDatePart, pFormatter);
}
else if (aGroupInfo.mbEnable)
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 7c4bc44e967f..d36e25be1b3a 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2872,7 +2872,7 @@ void ScDPObject::DumpCache() const
}
#endif
-ScDPCollection::SheetCaches::SheetCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
+ScDPCollection::SheetCaches::SheetCaches(ScDocument& rDoc) : mrDoc(rDoc) {}
namespace {
@@ -2939,8 +2939,8 @@ const ScDPCache* ScDPCollection::SheetCaches::getCache(const ScRange& rRange, co
}
// Not cached. Create a new cache.
- ::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
- pCache->InitFromDoc(mpDoc, rRange);
+ ::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mrDoc));
+ pCache->InitFromDoc(mrDoc, rRange);
if (pDimData)
pDimData->WriteToCache(*pCache);
@@ -3025,7 +3025,7 @@ void ScDPCollection::SheetCaches::updateReference(
SCTAB nTab2 = rKeyRange.aEnd.Tab();
ScRefUpdateRes eRes = ScRefUpdate::Update(
- mpDoc, eMode,
+ &mrDoc, eMode,
r.aStart.Col(), r.aStart.Row(), r.aStart.Tab(),
r.aEnd.Col(), r.aEnd.Row(), r.aEnd.Tab(), nDx, nDy, nDz,
nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
@@ -3061,7 +3061,7 @@ void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<Sc
ScDPCache& rCache = *itCache->second;
// Update the cache with new cell values. This will clear all group dimension info.
- rCache.InitFromDoc(mpDoc, rRange);
+ rCache.InitFromDoc(mrDoc, rRange);
std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
rRefs.swap(aRefs);
@@ -3089,7 +3089,7 @@ const std::vector<ScRange>& ScDPCollection::SheetCaches::getAllRanges() const
return maRanges;
}
-ScDPCollection::NameCaches::NameCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
+ScDPCollection::NameCaches::NameCaches(ScDocument& rDoc) : mrDoc(rDoc) {}
bool ScDPCollection::NameCaches::hasCache(const OUString& rName) const
{
@@ -3104,8 +3104,8 @@ const ScDPCache* ScDPCollection::NameCaches::getCache(
// already cached.
return itr->second.get();
- ::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
- pCache->InitFromDoc(mpDoc, rRange);
+ ::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mrDoc));
+ pCache->InitFromDoc(mrDoc, rRange);
if (pDimData)
pDimData->WriteToCache(*pCache);
@@ -3137,7 +3137,7 @@ void ScDPCollection::NameCaches::updateCache(
ScDPCache& rCache = *itr->second;
// Update the cache with new cell values. This will clear all group dimension info.
- rCache.InitFromDoc(mpDoc, rRange);
+ rCache.InitFromDoc(mrDoc, rRange);
std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
rRefs.swap(aRefs);
@@ -3166,7 +3166,7 @@ bool ScDPCollection::DBType::less::operator() (const DBType& left, const DBType&
return left < right;
}
-ScDPCollection::DBCaches::DBCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
+ScDPCollection::DBCaches::DBCaches(ScDocument& rDoc) : mrDoc(rDoc) {}
bool ScDPCollection::DBCaches::hasCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand) const
{
@@ -3189,7 +3189,7 @@ const ScDPCache* ScDPCollection::DBCaches::getCache(
if (!xRowSet.is())
return nullptr;
- ::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mpDoc));
+ ::std::unique_ptr<ScDPCache> pCache(new ScDPCache(mrDoc));
SvNumberFormatter aFormat( comphelper::getProcessComponentContext(), ScGlobal::eLnge);
DBConnector aDB(*pCache, xRowSet, aFormat.GetNullDate());
if (!aDB.isValid())
@@ -3328,19 +3328,19 @@ bool ScDPCollection::DBCaches::remove(const ScDPCache* p)
return false;
}
-ScDPCollection::ScDPCollection(ScDocument* pDocument) :
- mpDoc( pDocument ),
- maSheetCaches(pDocument),
- maNameCaches(pDocument),
- maDBCaches(pDocument)
+ScDPCollection::ScDPCollection(ScDocument& rDocument) :
+ mrDoc(rDocument),
+ maSheetCaches(rDocument),
+ maNameCaches(rDocument),
+ maDBCaches(rDocument)
{
}
ScDPCollection::ScDPCollection(const ScDPCollection& r) :
- mpDoc(r.mpDoc),
- maSheetCaches(r.mpDoc),
- maNameCaches(r.mpDoc),
- maDBCaches(r.mpDoc)
+ mrDoc(r.mrDoc),
+ maSheetCaches(r.mrDoc),
+ maNameCaches(r.mrDoc),
+ maDBCaches(r.mrDoc)
{
}
@@ -3616,7 +3616,7 @@ void ScDPCollection::CopyToTab( SCTAB nOld, SCTAB nNew )
e.SetTab(nNew);
ScDPObject* pNew = new ScDPObject(rObj);
pNew->SetOutRange(aOutRange);
- mpDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), ScMF::DpTable);
+ mrDoc.ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), ScMF::DpTable);
aAdded.push_back(std::unique_ptr<ScDPObject>(pNew));
}
@@ -3718,7 +3718,7 @@ void ScDPCollection::FreeTable(const ScDPObject* pDPObject)
const ScRange& rOutRange = pDPObject->GetOutRange();
const ScAddress& s = rOutRange.aStart;
const ScAddress& e = rOutRange.aEnd;
- mpDoc->RemoveFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), ScMF::DpTable);
+ mrDoc.RemoveFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), ScMF::DpTable);
auto funcRemoveCondition = [pDPObject] (std::unique_ptr<ScDPObject> const & pCurrent)
{
@@ -3733,7 +3733,7 @@ ScDPObject* ScDPCollection::InsertNewTable(std::unique_ptr<ScDPObject> pDPObj)
const ScRange& rOutRange = pDPObj->GetOutRange();
const ScAddress& s = rOutRange.aStart;
const ScAddress& e = rOutRange.aEnd;
- mpDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), ScMF::DpTable);
+ mrDoc.ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), ScMF::DpTable);
maTables.push_back(std::move(pDPObj));
return maTables.back().get();
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index e3ef57037476..49d6bfc95d1f 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1356,7 +1356,7 @@ void ScInterpreter::ScNPV()
FormulaError nErr = FormulaError::NONE;
double fCellVal;
PopDoubleRef( aRange, nParamCount, nRefInList);
- ScHorizontalValueIterator aValIter( &mrDoc, aRange );
+ ScHorizontalValueIterator aValIter( mrDoc, aRange );
while ((nErr == FormulaError::NONE) && aValIter.GetNext(fCellVal, nErr))
{
fVal += (fCellVal / pow(1.0 + fRate, fCount));