summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-09-19 22:16:54 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-09-19 22:44:01 -0400
commit311dbc3b4ccd202c3ca0f8f1b577262f3f666e69 (patch)
treefeb3439e69342f3fac4fb5779c8ef2e043f13dd4 /sc
parentExtracted method for inserting source data for pivot table testing. (diff)
downloadcore-311dbc3b4ccd202c3ca0f8f1b577262f3f666e69.tar.gz
core-311dbc3b4ccd202c3ca0f8f1b577262f3f666e69.zip
Use the method to insert source data.
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/ucalc.cxx53
1 files changed, 11 insertions, 42 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index fd46aaf4c52a..6afc80b0876b 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -997,52 +997,21 @@ void Test::testDataPilot()
};
// Raw data
- struct {
- const char* pName; const char* pGroup; int nScore;
- } aData[] = {
- { "Andy", "A", 30 },
- { "Bruce", "A", 20 },
- { "Charlie", "B", 45 },
- { "David", "B", 12 },
- { "Edward", "C", 8 },
- { "Frank", "C", 15 },
+ const char* aData[][3] = {
+ { "Andy", "A", "30" },
+ { "Bruce", "A", "20" },
+ { "Charlie", "B", "45" },
+ { "David", "B", "12" },
+ { "Edward", "C", "8" },
+ { "Frank", "C", "15" },
};
size_t nFieldCount = SAL_N_ELEMENTS(aFields);
size_t nDataCount = SAL_N_ELEMENTS(aData);
- // Insert field names in row 0.
- for (size_t i = 0; i < nFieldCount; ++i)
- m_pDoc->SetString(static_cast<SCCOL>(i), 0, 0, OUString(aFields[i].pName, strlen(aFields[i].pName), RTL_TEXTENCODING_UTF8));
-
- // Insert data into row 1 and downward.
- for (size_t i = 0; i < nDataCount; ++i)
- {
- SCROW nRow = static_cast<SCROW>(i) + 1;
- m_pDoc->SetString(0, nRow, 0, OUString(aData[i].pName, strlen(aData[i].pName), RTL_TEXTENCODING_UTF8));
- m_pDoc->SetString(1, nRow, 0, OUString(aData[i].pGroup, strlen(aData[i].pGroup), RTL_TEXTENCODING_UTF8));
- m_pDoc->SetValue(2, nRow, 0, aData[i].nScore);
- }
-
- SCROW nRow1 = 0, nRow2 = 0;
- SCCOL nCol1 = 0, nCol2 = 0;
- m_pDoc->GetDataArea(0, nCol1, nRow1, nCol2, nRow2, true, false);
- CPPUNIT_ASSERT_MESSAGE("Data is expected to start from (col=0,row=0).", nCol1 == 0 && nRow1 == 0);
- CPPUNIT_ASSERT_MESSAGE("Unexpected data range.",
- nCol2 == static_cast<SCCOL>(nFieldCount - 1) && nRow2 == static_cast<SCROW>(nDataCount));
-
- SheetPrinter printer(nRow2 - nRow1 + 1, nCol2 - nCol1 + 1);
- for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
- {
- for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
- {
- String aVal;
- m_pDoc->GetString(nCol, nRow, 0, aVal);
- printer.set(nRow, nCol, aVal);
- }
- }
- printer.print("Data sheet content");
- printer.clear();
+ ScRange aSrcRange = insertDPSourceData(m_pDoc, aFields, nFieldCount, aData, nDataCount);
+ SCROW nRow1 = aSrcRange.aStart.Row(), nRow2 = aSrcRange.aEnd.Row();
+ SCCOL nCol1 = aSrcRange.aStart.Col(), nCol2 = aSrcRange.aEnd.Col();
ScDPObject* pDPObj = createDPFromRange(
m_pDoc, ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0), aFields, nFieldCount, false);
@@ -1086,7 +1055,7 @@ void Test::testDataPilot()
m_pDoc->SetValue(2, nRow, 0, aData2[i]);
}
- printer.resize(nRow2 - nRow1 + 1, nCol2 - nCol1 + 1);
+ SheetPrinter printer(nRow2 - nRow1 + 1, nCol2 - nCol1 + 1);
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
{
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)