summaryrefslogtreecommitdiff
path: root/sc/qa/unit/helper/debughelper.hxx
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/qa/unit/helper/debughelper.hxx
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/qa/unit/helper/debughelper.hxx')
-rw-r--r--sc/qa/unit/helper/debughelper.hxx113
1 files changed, 3 insertions, 110 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: */