summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/column.hxx3
-rw-r--r--sc/inc/document.hxx4
-rw-r--r--sc/inc/table.hxx3
-rw-r--r--sc/qa/unit/ucalc.cxx84
-rw-r--r--sc/qa/unit/ucalc.hxx4
-rw-r--r--sc/source/core/data/column3.cxx48
-rw-r--r--sc/source/core/data/document.cxx14
-rw-r--r--sc/source/core/data/table2.cxx14
8 files changed, 61 insertions, 113 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ec29627421e2..d623efa87b4c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -280,8 +280,7 @@ public:
ScFormulaCell* SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell );
bool SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell );
- sal_uIntPtr GetCellStringID( SCROW nRow ) const;
- sal_uIntPtr GetCellStringIDIgnoreCase( SCROW nRow ) const;
+ svl::SharedString GetSharedString( SCROW nRow ) const;
void SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast = true );
void SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 69c8bdc7b163..076982c27e26 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -855,8 +855,8 @@ public:
SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
const svl::SharedStringPool& GetSharedStringPool() const;
- sal_uIntPtr GetCellStringID( const ScAddress& rPos ) const;
- sal_uIntPtr GetCellStringIDIgnoreCase( const ScAddress& rPos ) const;
+
+ svl::SharedString GetSharedString( const ScAddress& rPos ) const;
SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 5a216ae3d4d4..2ab016a94300 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -343,8 +343,7 @@ public:
ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
bool SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
- sal_uIntPtr GetCellStringID( SCCOL nCol, SCROW nRow ) const;
- sal_uIntPtr GetCellStringIDIgnoreCase( SCCOL nCol, SCROW nRow ) const;
+ svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
void SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
void SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3c7bf0740308..9bba942f429a 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -461,7 +461,7 @@ void Test::testCollator()
CPPUNIT_ASSERT_MESSAGE("these strings are supposed to be different!", nRes != 0);
}
-void Test::testCellStringPool()
+void Test::testSharedStringPool()
{
m_pDoc->InsertTab(0, "foo");
@@ -472,34 +472,34 @@ void Test::testCellStringPool()
m_pDoc->SetString(ScAddress(0,3,0), "andy"); // A4
m_pDoc->SetString(ScAddress(0,4,0), "BRUCE"); // A5
- sal_uIntPtr nId1 = m_pDoc->GetCellStringID(ScAddress(0,0,0));
- sal_uIntPtr nId2 = m_pDoc->GetCellStringID(ScAddress(0,1,0));
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId1);
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
- CPPUNIT_ASSERT_EQUAL(nId1, nId2);
-
- nId2 = m_pDoc->GetCellStringID(ScAddress(0,2,0));
- CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
- nId2 = m_pDoc->GetCellStringID(ScAddress(0,3,0));
- CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
- nId2 = m_pDoc->GetCellStringID(ScAddress(0,4,0));
- CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
- // A3 and A5 should differ but should be equal case-insensitively.
- nId1 = m_pDoc->GetCellStringID(ScAddress(0,2,0));
- nId2 = m_pDoc->GetCellStringID(ScAddress(0,4,0));
- CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
- nId1 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,2,0));
- nId2 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,4,0));
- CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", nId1 == nId2);
-
- // A2 and A4 should be equal when ignoring cases.
- nId1 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,1,0));
- nId2 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,3,0));
- CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", nId1 == nId2);
+ {
+ // These two shared string objects must go out of scope before the purge test.
+ svl::SharedString aSS1 = m_pDoc->GetSharedString(ScAddress(0,0,0));
+ svl::SharedString aSS2 = m_pDoc->GetSharedString(ScAddress(0,1,0));
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid shared string.", aSS1.isValid());
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid shared string.", aSS2.isValid());
+ CPPUNIT_ASSERT_EQUAL(aSS1.getData(), aSS2.getData());
+
+ aSS2 = m_pDoc->GetSharedString(ScAddress(0,2,0));
+ CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+
+ aSS2 = m_pDoc->GetSharedString(ScAddress(0,3,0));
+ CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+
+ aSS2 = m_pDoc->GetSharedString(ScAddress(0,4,0));
+ CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+
+ // A3 and A5 should differ but should be equal case-insensitively.
+ aSS1 = m_pDoc->GetSharedString(ScAddress(0,2,0));
+ aSS2 = m_pDoc->GetSharedString(ScAddress(0,4,0));
+ CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+ CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", aSS1.getDataIgnoreCase() == aSS2.getDataIgnoreCase());
+
+ // A2 and A4 should be equal when ignoring cases.
+ aSS1 = m_pDoc->GetSharedString(ScAddress(0,1,0));
+ aSS2 = m_pDoc->GetSharedString(ScAddress(0,3,0));
+ CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", aSS1.getDataIgnoreCase() == aSS2.getDataIgnoreCase());
+ }
// Check the string counts after purging. Purging shouldn't remove any strings in this case.
svl::SharedStringPool& rPool = m_pDoc->GetSharedStringPool();
@@ -568,24 +568,24 @@ void Test::testCellStringPool()
m_pDoc->SetEditText(ScAddress(1,0,0), rEE.CreateTextObject()); // B1
// These two should be equal.
- nId1 = m_pDoc->GetCellStringID(ScAddress(0,0,0));
- nId2 = m_pDoc->GetCellStringID(ScAddress(1,0,0));
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId1);
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
- CPPUNIT_ASSERT_EQUAL(nId1, nId2);
+ svl::SharedString aSS1 = m_pDoc->GetSharedString(ScAddress(0,0,0));
+ svl::SharedString aSS2 = m_pDoc->GetSharedString(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS1.isValid());
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS2.isValid());
+ CPPUNIT_ASSERT_EQUAL(aSS1.getData(), aSS2.getData());
rEE.SetText("ANDY and BRUCE");
m_pDoc->SetEditText(ScAddress(2,0,0), rEE.CreateTextObject()); // C1
- nId2 = m_pDoc->GetCellStringID(ScAddress(2,0,0));
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
- CPPUNIT_ASSERT_MESSAGE("These two should be different when cases are considered.", nId1 != nId2);
+ aSS2 = m_pDoc->GetSharedString(ScAddress(2,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS2.isValid());
+ CPPUNIT_ASSERT_MESSAGE("These two should be different when cases are considered.", aSS1.getData() != aSS2.getData());
// But they should be considered equal when cases are ignored.
- nId1 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,0,0));
- nId2 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(2,0,0));
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId1);
- CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
- CPPUNIT_ASSERT_EQUAL(nId1, nId2);
+ aSS1 = m_pDoc->GetSharedString(ScAddress(0,0,0));
+ aSS2 = m_pDoc->GetSharedString(ScAddress(2,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS1.isValid());
+ CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS2.isValid());
+ CPPUNIT_ASSERT_EQUAL(aSS1.getDataIgnoreCase(), aSS2.getDataIgnoreCase());
m_pDoc->DeleteTab(0);
}
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d1ba668e52c8..2c30f434de26 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -80,7 +80,7 @@ public:
*/
void testPerf();
void testCollator();
- void testCellStringPool();
+ void testSharedStringPool();
void testRangeList();
void testInput();
@@ -285,7 +285,7 @@ public:
CPPUNIT_TEST(testPerf);
#endif
CPPUNIT_TEST(testCollator);
- CPPUNIT_TEST(testCellStringPool);
+ CPPUNIT_TEST(testSharedStringPool);
CPPUNIT_TEST(testRangeList);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testFormulaHashAndTag);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f331d354b2e1..ae84c131cd77 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1736,62 +1736,28 @@ bool ScColumn::SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell )
return true;
}
-sal_uIntPtr ScColumn::GetCellStringID( SCROW nRow ) const
+svl::SharedString ScColumn::GetSharedString( SCROW nRow ) const
{
sc::CellStoreType::const_position_type aPos = maCells.position(nRow);
switch (aPos.first->type)
{
case sc::element_type_string:
- {
- const svl::SharedString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
- return reinterpret_cast<sal_uIntPtr>(rStr.getData());
- }
- break;
- case sc::element_type_edittext:
- {
- std::vector<sal_uIntPtr> aIDs;
- const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
- pObj->GetStringIDs(pDocument->GetSharedStringPool(), aIDs);
- if (aIDs.size() != 1)
- // We don't handle multiline content for now.
- return 0;
-
- return aIDs[0];
- }
- break;
- default:
- ;
- }
- return 0;
-}
-
-sal_uIntPtr ScColumn::GetCellStringIDIgnoreCase( SCROW nRow ) const
-{
- sc::CellStoreType::const_position_type aPos = maCells.position(nRow);
- switch (aPos.first->type)
- {
- case sc::element_type_string:
- {
- const svl::SharedString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
- return reinterpret_cast<sal_uIntPtr>(rStr.getDataIgnoreCase());
- }
- break;
+ return sc::string_block::at(*aPos.first->data, aPos.second);
case sc::element_type_edittext:
{
- std::vector<sal_uIntPtr> aIDs;
const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
- pObj->GetStringIDsIgnoreCase(pDocument->GetSharedStringPool(), aIDs);
- if (aIDs.size() != 1)
+ std::vector<svl::SharedString> aSSs = pObj->GetSharedStrings();
+ if (aSSs.size() != 1)
// We don't handle multiline content for now.
- return 0;
+ return svl::SharedString();
- return aIDs[0];
+ return aSSs[0];
}
break;
default:
;
}
- return 0;
+ return svl::SharedString();
}
namespace {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b5f6b8e4dc58..51a5c2ef8eb0 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3213,20 +3213,12 @@ double* ScDocument::GetValueCell( const ScAddress& rPos )
return maTabs[rPos.Tab()]->GetValueCell(rPos.Col(), rPos.Row());
}
-sal_uIntPtr ScDocument::GetCellStringID( const ScAddress& rPos ) const
+svl::SharedString ScDocument::GetSharedString( const ScAddress& rPos ) const
{
if (!TableExists(rPos.Tab()))
- return 0;
-
- return maTabs[rPos.Tab()]->GetCellStringID(rPos.Col(), rPos.Row());
-}
-
-sal_uIntPtr ScDocument::GetCellStringIDIgnoreCase( const ScAddress& rPos ) const
-{
- if (!TableExists(rPos.Tab()))
- return 0;
+ return svl::SharedString();
- return maTabs[rPos.Tab()]->GetCellStringIDIgnoreCase(rPos.Col(), rPos.Row());
+ return maTabs[rPos.Tab()]->GetSharedString(rPos.Col(), rPos.Row());
}
void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a7504ccb5234..be791ca1abcb 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1505,20 +1505,12 @@ bool ScTable::SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell
return aCol[nCol].SetGroupFormulaCell(nRow, pCell);
}
-sal_uIntPtr ScTable::GetCellStringID( SCCOL nCol, SCROW nRow ) const
+svl::SharedString ScTable::GetSharedString( SCCOL nCol, SCROW nRow ) const
{
if (!ValidColRow(nCol, nRow))
- return 0;
-
- return aCol[nCol].GetCellStringID(nRow);
-}
-
-sal_uIntPtr ScTable::GetCellStringIDIgnoreCase( SCCOL nCol, SCROW nRow ) const
-{
- if (!ValidColRow(nCol, nRow))
- return 0;
+ return svl::SharedString();
- return aCol[nCol].GetCellStringIDIgnoreCase(nRow);
+ return aCol[nCol].GetSharedString(nRow);
}
void ScTable::SetValue( SCCOL nCol, SCROW nRow, const double& rVal )