summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-06-16 17:57:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-06-17 15:59:42 +0200
commit12b817140641a94ebb3ef8271c5e955eb80e56f2 (patch)
treeed920ec3c4efe6051ca65b340ed14bf0a51a8c22
parentc1eba8d34a5ea13e6317c7820507d717ace4ec5c (diff)
create getter for ScCellValue::mpString
so we can assert that it has the correct tag type Change-Id: I8933919aefc2bb22694a283b54dc3de11d16e5a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136002 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sc/inc/cellvalue.hxx2
-rw-r--r--sc/qa/unit/ucalc_sharedformula.cxx2
-rw-r--r--sc/source/core/data/column3.cxx2
-rw-r--r--sc/source/core/data/column4.cxx4
-rw-r--r--sc/source/core/data/conditio.cxx2
-rw-r--r--sc/source/core/data/dociter.cxx2
-rw-r--r--sc/source/core/data/documen8.cxx4
-rw-r--r--sc/source/core/data/documentimport.cxx4
-rw-r--r--sc/source/core/data/table3.cxx6
-rw-r--r--sc/source/core/data/table4.cxx4
-rw-r--r--sc/source/core/data/validat.cxx2
-rw-r--r--sc/source/core/tool/cellform.cxx2
-rw-r--r--sc/source/core/tool/chgtrack.cxx4
-rw-r--r--sc/source/filter/excel/xetable.cxx2
-rw-r--r--sc/source/filter/xcl97/XclExpChangeTrack.cxx2
-rw-r--r--sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx4
-rw-r--r--sc/source/ui/docshell/docsh.cxx4
-rw-r--r--sc/source/ui/undo/undocell.cxx2
-rw-r--r--sc/source/ui/view/spellcheckcontext.cxx6
-rw-r--r--sc/source/ui/view/tabvwsh5.cxx2
20 files changed, 32 insertions, 30 deletions
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 9513fcfc99d5..643889e2c154 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -63,6 +63,7 @@ public:
CellType getType() const { return meType; }
double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue1; }
+ svl::SharedString* getSharedString() const { assert(meType == CELLTYPE_STRING); return mpString; }
/**
* Take cell value from specified position in specified document.
@@ -134,6 +135,7 @@ public:
CellType getType() const { return meType; }
double getDouble() const { assert(meType == CELLTYPE_VALUE); return mfValue1; }
+ const svl::SharedString* getSharedString() const { assert(meType == CELLTYPE_STRING); return mpString; }
/**
* Take cell value from specified position in specified document.
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index 64f248c91cf8..69f3e3be3d42 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -284,7 +284,7 @@ void TestSharedFormula::testSharedFormulas()
ScCellValue aCell(svl::SharedString("Test"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("This should be a string value.", CELLTYPE_STRING, aCell.getType());
aCell.commit(*m_pDoc, aPos);
- CPPUNIT_ASSERT_EQUAL(aCell.mpString->getString(), m_pDoc->GetString(aPos));
+ CPPUNIT_ASSERT_EQUAL(aCell.getSharedString()->getString(), m_pDoc->GetString(aPos));
aPos.SetRow(16);
pFC = m_pDoc->GetFormulaCell(aPos);
CPPUNIT_ASSERT(pFC);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index e8a14b75b498..7586b000768d 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2885,7 +2885,7 @@ public:
rColumn.SetValue(aBlockPos, r.mnRow, r.maValue.getDouble(), false);
break;
case CELLTYPE_STRING:
- rColumn.SetRawString(aBlockPos, r.mnRow, *r.maValue.mpString, false);
+ rColumn.SetRawString(aBlockPos, r.mnRow, *r.maValue.getSharedString(), false);
break;
default:
;
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 7861ed5ce55e..6c710d9ed22e 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -291,8 +291,8 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
// same document. If not, re-intern shared strings.
svl::SharedStringPool* pSharedStringPool = (bSameDocPool ? nullptr : &rDocument.GetSharedStringPool());
svl::SharedString aStr = (pSharedStringPool ?
- pSharedStringPool->intern( rSrcCell.mpString->getString()) :
- *rSrcCell.mpString);
+ pSharedStringPool->intern( rSrcCell.getSharedString()-> getString()) :
+ *rSrcCell.getSharedString());
std::vector<svl::SharedString> aStrs(nDestSize, aStr);
pBlockPos->miCellPos =
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 6c4213888017..90ea65ba1b0c 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -746,7 +746,7 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr
case CELLTYPE_EDIT:
bVal = false;
if (rCell.getType() == CELLTYPE_STRING)
- rArgStr = rCell.mpString->getString();
+ rArgStr = rCell.getSharedString()->getString();
else if (rCell.mpEditText)
rArgStr = ScEditUtil::GetString(*rCell.mpEditText, pDoc);
break;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 3efaa48d7b5a..3eb95c8eaeb9 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -975,7 +975,7 @@ ScCellValue ScCellIterator::getCellValue() const
switch (maCurCell.getType())
{
case CELLTYPE_STRING:
- return ScCellValue(new svl::SharedString(*maCurCell.mpString));
+ return ScCellValue(maCurCell.getSharedString());
break;
case CELLTYPE_EDIT:
return ScCellValue(maCurCell.mpEditText->Clone());
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index c09bd16d3dc8..2da4ddfa53fb 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1262,7 +1262,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, Transliteratio
}
pEngine->SetDefaults( std::move(aDefaults) );
if (aCell.getType() == CELLTYPE_STRING)
- pEngine->SetTextCurrentDefaults(aCell.mpString->getString());
+ pEngine->SetTextCurrentDefaults(aCell.getSharedString()->getString());
else if (aCell.mpEditText)
pEngine->SetTextCurrentDefaults(*aCell.mpEditText);
@@ -1298,7 +1298,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, Transliteratio
else if (aCell.getType() == CELLTYPE_STRING)
{
- OUString aOldStr = aCell.mpString->getString();
+ OUString aOldStr = aCell.getSharedString()->getString();
sal_Int32 nOldLen = aOldStr.getLength();
if ( bConsiderLanguage )
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 867a16a6f1ec..b091b99ff152 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -224,7 +224,7 @@ void ScDocumentImport::setAutoInput(const ScAddress& rPos, const OUString& rStr,
{
case CELLTYPE_STRING:
// string is copied.
- pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), *aCell.mpString);
+ pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), *aCell.getSharedString());
break;
case CELLTYPE_EDIT:
// Cell takes the ownership of the text object.
@@ -583,7 +583,7 @@ void ScDocumentImport::fillDownCells(const ScAddress& rPos, SCROW nFillSize)
}
case CELLTYPE_STRING:
{
- std::vector<svl::SharedString> aCopied(nFillSize, *aRefCell.mpString);
+ std::vector<svl::SharedString> aCopied(nFillSize, *aRefCell.getSharedString());
pBlockPos->miCellPos = rCells.set(
pBlockPos->miCellPos, rPos.Row()+1, aCopied.begin(), aCopied.end());
break;
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 19db5e6c08dc..f1027716f03e 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -728,7 +728,7 @@ void fillSortedColumnArray(
{
case CELLTYPE_STRING:
assert(rCell.mpAttr);
- rCellStore.push_back(*rCell.maCell.mpString);
+ rCellStore.push_back(*rCell.maCell.getSharedString());
break;
case CELLTYPE_VALUE:
assert(rCell.mpAttr);
@@ -1570,11 +1570,11 @@ short ScTable::CompareCell(
OUString aStr1;
OUString aStr2;
if (eType1 == CELLTYPE_STRING)
- aStr1 = rCell1.mpString->getString();
+ aStr1 = rCell1.getSharedString()->getString();
else
aStr1 = GetString(nCell1Col, nCell1Row);
if (eType2 == CELLTYPE_STRING)
- aStr2 = rCell2.mpString->getString();
+ aStr2 = rCell2.getSharedString()->getString();
else
aStr2 = GetString(nCell2Col, nCell2Row);
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 80d656d4dd59..8877e90d20e0 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1916,7 +1916,7 @@ void ScTable::FillAutoSimple(
case CELLTYPE_STRING:
case CELLTYPE_EDIT:
if (aSrcCell.getType() == CELLTYPE_STRING)
- aValue = aSrcCell.mpString->getString();
+ aValue = aSrcCell.getSharedString()->getString();
else
aValue = ScEditUtil::GetString(*aSrcCell.mpEditText, &rDocument);
if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
@@ -2460,7 +2460,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
}
OUString aValue;
if (eCellType == CELLTYPE_STRING)
- aValue = aSrcCell.mpString->getString();
+ aValue = aSrcCell.getSharedString()->getString();
else
aValue = ScEditUtil::GetString(*aSrcCell.mpEditText, &rDocument);
sal_Int32 nStringValue;
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index abe48eecb3a9..4c8617a47c9e 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -579,7 +579,7 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos
nVal = rCell.getDouble();
break;
case CELLTYPE_STRING:
- aString = rCell.mpString->getString();
+ aString = rCell.getSharedString()->getString();
bIsVal = false;
break;
case CELLTYPE_EDIT:
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 742e896e03b1..7e75ced777ab 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -39,7 +39,7 @@ OUString ScCellFormat::GetString( const ScRefCellValue& rCell, sal_uInt32 nForma
case CELLTYPE_STRING:
{
OUString str;
- rFormatter.GetOutputString(rCell.mpString->getString(), nFormat, str, ppColor, bUseStarFormat);
+ rFormatter.GetOutputString(rCell.getSharedString()->getString(), nFormat, str, ppColor, bUseStarFormat);
return str;
}
case CELLTYPE_EDIT:
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index cf6cd43ffd0c..d89f38dbb06d 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1564,7 +1564,7 @@ OUString ScChangeActionContent::GetStringOfCell(
return str;
}
case CELLTYPE_STRING:
- return rCell.mpString->getString();
+ return rCell.getSharedString()->getString();
case CELLTYPE_EDIT:
if (rCell.mpEditText)
return ScEditUtil::GetString(*rCell.mpEditText, pDoc);
@@ -1705,7 +1705,7 @@ OUString ScChangeActionContent::GetValueString(
switch (rCell.getType())
{
case CELLTYPE_STRING :
- return rCell.mpString->getString();
+ return rCell.getSharedString()->getString();
case CELLTYPE_EDIT :
if (rCell.mpEditText)
return ScEditUtil::GetString(*rCell.mpEditText, pDoc);
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 6a65d5c7dd8f..0df688d335bd 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2666,7 +2666,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) :
case CELLTYPE_STRING:
{
xCell = new XclExpLabelCell(
- GetRoot(), aXclPos, pPattern, nMergeBaseXFId, rScCell.mpString->getString());
+ GetRoot(), aXclPos, pPattern, nMergeBaseXFId, rScCell.getSharedString()->getString());
}
break;
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index 93fce08f6f24..ed0a8c94a7c8 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -870,7 +870,7 @@ void XclExpChTrCellContent::GetCellData(
OUString sCellStr;
if (rScCell.getType() == CELLTYPE_STRING)
{
- sCellStr = rScCell.mpString->getString();
+ sCellStr = rScCell.getSharedString()->getString();
rpData->mpFormattedString = XclExpStringHelper::CreateCellString(
rRoot, sCellStr, nullptr);
}
diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
index 4263c0b0740e..843b9a0a3d21 100644
--- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
@@ -264,11 +264,11 @@ void ScChangeTrackingExportHelper::WriteStringCell(const ScCellValue& rCell)
rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, true, true);
- if (!rCell.mpString->isEmpty())
+ if (!rCell.getSharedString()->isEmpty())
{
SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, true, false);
bool bPrevCharWasSpace(true);
- rExport.GetTextParagraphExport()->exportCharacterData(rCell.mpString->getString(), bPrevCharWasSpace);
+ rExport.GetTextParagraphExport()->exportCharacterData(rCell.getSharedString()->getString(), bPrevCharWasSpace);
}
}
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index a5935402ba1d..644afc8d14e6 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2005,7 +2005,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
{
if (pCell->getType() == CELLTYPE_STRING)
{
- aString = pCell->mpString->getString();
+ aString = pCell->getSharedString()->getString();
if (aString.getLength() <= 5 && aString.startsWithIgnoreAsciiCase("sep="))
{
// Cell content is /^sep=.?$/ so write current separator.
@@ -2170,7 +2170,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt,
aString = ScCellFormat::GetString(*pCell, nFormat, &pDummy, rFormatter, *m_pDocument);
}
else
- aString = pCell->mpString->getString();
+ aString = pCell->getSharedString()->getString();
bString = true;
break;
case CELLTYPE_EDIT :
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 007c0f862c9d..6690c05c5a3b 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -464,7 +464,7 @@ void ScUndoSetCell::SetValue( const ScCellValue& rVal )
aParam.setTextInput();
// Undo only cell content, without setting any number format.
aParam.meSetTextNumFormat = ScSetStringParam::Keep;
- rDoc.SetString(maPos, rVal.mpString->getString(), &aParam);
+ rDoc.SetString(maPos, rVal.getSharedString()->getString(), &aParam);
}
break;
case CELLTYPE_EDIT:
diff --git a/sc/source/ui/view/spellcheckcontext.cxx b/sc/source/ui/view/spellcheckcontext.cxx
index 3f0d917126cf..1b29c17371af 100644
--- a/sc/source/ui/view/spellcheckcontext.cxx
+++ b/sc/source/ui/view/spellcheckcontext.cxx
@@ -77,7 +77,7 @@ public:
CellType eType = rCell.getType();
if (eType == CELLTYPE_STRING)
{
- SharedStringMapType::const_iterator it = maStringMisspells.find(rCell.mpString->getData());
+ SharedStringMapType::const_iterator it = maStringMisspells.find(rCell.getSharedString()->getData());
if (it == maStringMisspells.end())
return false; // Not available
@@ -103,7 +103,7 @@ public:
{
CellType eType = rCell.getType();
if (eType == CELLTYPE_STRING)
- maStringMisspells.insert_or_assign(rCell.mpString->getData(), std::move(pRanges));
+ maStringMisspells.insert_or_assign(rCell.getSharedString()->getData(), std::move(pRanges));
else if (eType == CELLTYPE_EDIT)
maEditTextMisspells.insert_or_assign(CellPos(nCol, nRow), std::move(pRanges));
}
@@ -328,7 +328,7 @@ void SpellCheckContext::ensureResults(SCCOL nCol, SCROW nRow)
// Cache miss, the cell needs spell-check..
if (eType == CELLTYPE_STRING)
- mpEngine->SetText(aCell.mpString->getString());
+ mpEngine->SetText(aCell.getSharedString()->getString());
else
mpEngine->SetText(*aCell.mpEditText);
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 7a6bde95c7fd..6b35721986a8 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -332,7 +332,7 @@ std::unique_ptr<SvxNumberInfoItem> ScTabViewShell::MakeNumberInfoItem( ScDocumen
case CELLTYPE_STRING:
{
- aCellString = aCell.mpString->getString();
+ aCellString = aCell.getSharedString()->getString();
eValType = SvxNumberValueType::String;
}
break;