[Libreoffice-commits] core.git: chart2/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Jun 26 11:26:55 PDT 2014


 chart2/source/inc/InternalData.hxx   |    4 --
 chart2/source/tools/InternalData.cxx |   57 +++++++++++++++++++++--------------
 2 files changed, 36 insertions(+), 25 deletions(-)

New commits:
commit aa6495b6fa231abfe8b55a806ff6d5a306843cd3
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Jun 26 14:23:29 2014 -0400

    Better way to dump the content of InternalData.
    
    Row levels are currently not dumped, but that may change later.
    
    Change-Id: I849f8b65d6f419bc4d97e2af2d456e73c7e9a355

diff --git a/chart2/source/inc/InternalData.hxx b/chart2/source/inc/InternalData.hxx
index 082f6ee..94b7eee 100644
--- a/chart2/source/inc/InternalData.hxx
+++ b/chart2/source/inc/InternalData.hxx
@@ -76,9 +76,7 @@ public:
     void setComplexColumnLabels( const tVecVecAny& rNewColumnLabels );
     tVecVecAny getComplexColumnLabels() const { return m_aColumnLabels;}
 
-#if OSL_DEBUG_LEVEL > 1
-    void traceData() const;
-#endif
+    void dump() const;
 
 private: //methods
     /** resizes the data if at least one of the given dimensions is larger than
diff --git a/chart2/source/tools/InternalData.cxx b/chart2/source/tools/InternalData.cxx
index f79bd62..ac796a9 100644
--- a/chart2/source/tools/InternalData.cxx
+++ b/chart2/source/tools/InternalData.cxx
@@ -22,6 +22,14 @@
 #include "Strings.hrc"
 
 #include <rtl/math.hxx>
+#if OSL_DEBUG_LEVEL > 1
+#define DEBUG_INTERNAL_DATA 1
+#endif
+
+#ifdef DEBUG_INTERNAL_DATA
+#include <svl/gridprinter.hxx>
+#endif
+
 #include <algorithm>
 #include <iterator>
 
@@ -223,6 +231,8 @@ void InternalData::setComplexColumnLabel( sal_Int32 nColumnIndex, const vector<
         enlargeData( nColumnIndex+1, 0 );
     }
     m_aColumnLabels[nColumnIndex]=rComplexLabel;
+
+    dump();
 }
 
 void InternalData::setComplexRowLabel( sal_Int32 nRowIndex, const vector< uno::Any >& rComplexLabel )
@@ -351,9 +361,7 @@ void InternalData::insertColumn( sal_Int32 nAfterIndex )
     if( nAfterIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
         m_aColumnLabels.insert( m_aColumnLabels.begin() + (nAfterIndex + 1), vector< uno::Any >(1) );
 
-#if OSL_DEBUG_LEVEL > 1
-    traceData();
-#endif
+    dump();
 }
 
 sal_Int32 InternalData::appendColumn()
@@ -403,9 +411,7 @@ void InternalData::insertRow( sal_Int32 nAfterIndex )
     if( nAfterIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
         m_aRowLabels.insert( m_aRowLabels.begin() + nIndex, vector< uno::Any > (1));
 
-#if OSL_DEBUG_LEVEL > 1
-    traceData();
-#endif
+    dump();
 }
 
 void InternalData::deleteColumn( sal_Int32 nAtIndex )
@@ -439,9 +445,7 @@ void InternalData::deleteColumn( sal_Int32 nAtIndex )
     if( nAtIndex < static_cast< sal_Int32 >( m_aColumnLabels.size()))
         m_aColumnLabels.erase( m_aColumnLabels.begin() + nAtIndex );
 
-#if OSL_DEBUG_LEVEL > 1
-    traceData();
-#endif
+    dump();
 }
 
 void InternalData::deleteRow( sal_Int32 nAtIndex )
@@ -479,9 +483,7 @@ void InternalData::deleteRow( sal_Int32 nAtIndex )
     if( nAtIndex < static_cast< sal_Int32 >( m_aRowLabels.size()))
         m_aRowLabels.erase( m_aRowLabels.begin() + nAtIndex );
 
-#if OSL_DEBUG_LEVEL > 1
-    traceData();
-#endif
+    dump();
 }
 
 
@@ -507,21 +509,32 @@ void InternalData::setComplexColumnLabels( const vector< vector< uno::Any > >& r
         enlargeData( nNewColumnCount, 0 );
 }
 
-
-#if OSL_DEBUG_LEVEL > 1
-void InternalData::traceData() const
+#ifdef DEBUG_INTERNAL_DATA
+void InternalData::dump() const
 {
-    OSL_TRACE( "InternalData: Data in rows" );
+    // Header
+    svl::GridPrinter aPrinter(1, m_nColumnCount, true);
+    for (sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol)
+    {
+        OUString aStr;
+        if (m_aColumnLabels[nCol][0] >>= aStr)
+            aPrinter.set(0, nCol, aStr);
+    }
+    aPrinter.print("Header");
 
-    for( sal_Int32 i=0; i<m_nRowCount; ++i )
+    aPrinter.resize(m_nRowCount, m_nColumnCount);
+
+    for (sal_Int32 nRow = 0; nRow < m_nRowCount; ++nRow)
     {
-        tDataType aSlice( m_aData[ ::std::slice( i*m_nColumnCount, m_nColumnCount, 1 ) ] );
-        for( sal_Int32 j=0; j<m_nColumnCount; ++j )
-            OSL_TRACE( "%lf ", aSlice[j] );
-        OSL_TRACE( "\n" );
+        tDataType aSlice( m_aData[ ::std::slice( nRow*m_nColumnCount, m_nColumnCount, 1 ) ] );
+        for (sal_Int32 nCol = 0; nCol < m_nColumnCount; ++nCol)
+            aPrinter.set(nRow, nCol, OUString::number(aSlice[nCol]));
     }
-    OSL_TRACE( "\n" );
+
+    aPrinter.print("Column data");
 }
+#else
+void InternalData::dump() const {}
 #endif
 
 } //  namespace chart


More information about the Libreoffice-commits mailing list