summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-26 13:33:09 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-06-26 13:35:33 -0400
commitf15e440d148ed021091ef9b20f3aed2488f0fde3 (patch)
tree99a1f7c54ffd0c63588d2599075d2be7eebc79da /sc
parentb7de76d825b02005ab8cf02b3977e4be441200c5 (diff)
Move SheetPrinter to svl and rename it to GridPrinter.
I need to use this outside of sc. Change-Id: I153863d6c5c31e5ab5f25da2dba81bd4d4b6d3fe
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/helper/debughelper.hxx113
-rw-r--r--sc/qa/unit/helper/qahelper.hxx2
-rw-r--r--sc/qa/unit/ucalc.cxx2
3 files changed, 5 insertions, 112 deletions
diff --git a/sc/qa/unit/helper/debughelper.hxx b/sc/qa/unit/helper/debughelper.hxx
index dc6e7bd3d190..509f4aff72fc 100644
--- a/sc/qa/unit/helper/debughelper.hxx
+++ b/sc/qa/unit/helper/debughelper.hxx
@@ -23,10 +23,10 @@
#undef NOMINMAX
#endif
-#define MDDS_HASH_CONTAINER_BOOST 1
-#include <mdds/mixed_type_matrix.hpp>
-
#include <iostream>
+#include <vector>
+
+#include <svl/gridprinter.hxx>
#define CALC_DEBUG_OUTPUT 0
#define CALC_TEST_PERF 0
@@ -37,113 +37,6 @@ using ::std::cerr;
using ::std::endl;
using ::std::vector;
-/**
- * Print nicely formatted sheet content to stdout. Indispensable when
- * debugging the unit test code involving testing of sheet contents.
- */
-class SheetPrinter
-{
- typedef ::mdds::mixed_type_matrix<OUString, bool> MatrixType;
-public:
- SheetPrinter(size_t rows, size_t cols) :
- maMatrix(rows, cols, ::mdds::matrix_density_sparse_empty) {}
-
- void set(size_t row, size_t col, const OUString& aStr)
- {
- maMatrix.set_string(row, col, new OUString(aStr));
- }
-
-#if CALC_DEBUG_OUTPUT
- void print(const char* header) const
- {
- if (header)
- cout << header << endl;
-
- MatrixType::size_pair_type ns = maMatrix.size();
- vector<sal_Int32> aColWidths(ns.second, 0);
-
- // Calculate column widths first.
- for (size_t row = 0; row < ns.first; ++row)
- {
- for (size_t col = 0; col < ns.second; ++col)
- {
- const OUString* p = maMatrix.get_string(row, col);
- if (aColWidths[col] < p->getLength())
- aColWidths[col] = p->getLength();
- }
- }
-
- // Make the row separator string.
- OUStringBuffer aBuf;
- aBuf.appendAscii("+");
- for (size_t col = 0; col < ns.second; ++col)
- {
- aBuf.appendAscii("-");
- for (sal_Int32 i = 0; i < aColWidths[col]; ++i)
- aBuf.append(sal_Unicode('-'));
- aBuf.appendAscii("-+");
- }
-
- OUString aSep = aBuf.makeStringAndClear();
-
- // Now print to stdout.
- cout << aSep << endl;
- for (size_t row = 0; row < ns.first; ++row)
- {
- cout << "| ";
- for (size_t col = 0; col < ns.second; ++col)
- {
- const OUString* p = maMatrix.get_string(row, col);
- size_t nPadding = aColWidths[col] - p->getLength();
- aBuf.append(*p);
- for (size_t i = 0; i < nPadding; ++i)
- aBuf.append(sal_Unicode(' '));
- cout << aBuf.makeStringAndClear() << " | ";
- }
- cout << endl;
- cout << aSep << endl;
- }
- }
-#else
- void print(const char*) const {}
-#endif
-
- /**
- * Print nested string array which can be copy-n-pasted into the test code
- * for content verification.
- */
- void printArray() const
- {
-#if CALC_DEBUG_OUTPUT
- MatrixType::size_pair_type ns = maMatrix.size();
- for (size_t row = 0; row < ns.first; ++row)
- {
- cout << " { ";
- for (size_t col = 0; col < ns.second; ++col)
- {
- const OUString* p = maMatrix.get_string(row, col);
- if (p->getLength())
- cout << "\"" << *p << "\"";
- else
- cout << "0";
- if (col < ns.second - 1)
- cout << ", ";
- }
- cout << " }";
- if (row < ns.first - 1)
- cout << ",";
- cout << endl;
- }
-#endif
- }
-
- void clear() { maMatrix.clear(); }
- void resize(size_t rows, size_t cols) { maMatrix.resize(rows, cols); }
-
-private:
- MatrixType maMatrix;
-};
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index a4273bc8a4c4..8c96e360a731 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -136,7 +136,7 @@ bool checkOutput(ScDocument* pDoc, const ScRange& aOutRange, const char* aOutput
bool bResult = true;
const ScAddress& s = aOutRange.aStart;
const ScAddress& e = aOutRange.aEnd;
- SheetPrinter printer(e.Row() - s.Row() + 1, e.Col() - s.Col() + 1);
+ svl::GridPrinter printer(e.Row() - s.Row() + 1, e.Col() - s.Col() + 1, CALC_DEBUG_OUTPUT != 0);
SCROW nOutRowSize = e.Row() - s.Row() + 1;
SCCOL nOutColSize = e.Col() - s.Col() + 1;
for (SCROW nRow = 0; nRow < nOutRowSize; ++nRow)
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8d2dd47b91be..d412abdd4aa4 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6410,7 +6410,7 @@ void Test::printRange(ScDocument* pDoc, const ScRange& rRange, const char* pCapt
{
SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
- SheetPrinter printer(nRow2 - nRow1 + 1, nCol2 - nCol1 + 1);
+ svl::GridPrinter printer(nRow2 - nRow1 + 1, nCol2 - nCol1 + 1, CALC_DEBUG_OUTPUT != 0);
for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
{
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)