summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-03 14:58:06 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-04 19:15:25 -0400
commit3f6f7566dd92be7b27cee99d3291fdb4fc5f5a38 (patch)
treee6d0841fdec59a0075655bde9436da7eeb07a875 /sc
parent875f47cb5a20e2ce6ed54d88fd5bbf1d6128a47d (diff)
Test comparison between simple and rich-text string values.
Change-Id: Icdb9a81b1be80b058b71c23b3fcb58a5e8970e21
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx52
1 files changed, 52 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index ba9a78e5c546..3e7239efa870 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -57,6 +57,8 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/brushitem.hxx>
+#include "editeng/wghtitem.hxx"
+#include "editeng/postitem.hxx"
#include <svx/svdograf.hxx>
#include <svx/svdpage.hxx>
@@ -535,6 +537,56 @@ void Test::testCellStringPool()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rPool.getCount());
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rPool.getCountIgnoreCase());
+ // Now, compare string and edit text cells.
+ m_pDoc->SetString(ScAddress(0,0,0), "Andy and Bruce"); // A1
+ ScFieldEditEngine& rEE = m_pDoc->GetEditEngine();
+ rEE.SetText("Andy and Bruce");
+
+ ESelection aSel;
+ aSel.nStartPara = aSel.nEndPara = 0;
+
+ {
+ // Set 'Andy' bold.
+ SfxItemSet aItemSet = rEE.GetEmptyItemSet();
+ aSel.nStartPos = 0;
+ aSel.nEndPos = 4;
+ SvxWeightItem aWeight(WEIGHT_BOLD, EE_CHAR_WEIGHT);
+ aItemSet.Put(aWeight);
+ rEE.QuickSetAttribs(aItemSet, aSel);
+ }
+
+ {
+ // Set 'Bruce' italic.
+ SfxItemSet aItemSet = rEE.GetEmptyItemSet();
+ SvxPostureItem aItalic(ITALIC_NORMAL, EE_CHAR_ITALIC);
+ aItemSet.Put(aItalic);
+ aSel.nStartPos = 9;
+ aSel.nEndPos = 14;
+ rEE.QuickSetAttribs(aItemSet, aSel);
+ }
+
+ 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);
+
+ 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);
+
+ // 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);
+
m_pDoc->DeleteTab(0);
}