From b3d5de767c6dbd30ded0881da9de8ae9638abb54 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sun, 23 Sep 2012 19:51:02 +0200 Subject: improve the dump code for cond formats Change-Id: Icefaa4777f64ca934928ae2ad95496000df364e9 --- sc/inc/colorscale.hxx | 8 ++++-- sc/inc/conditio.hxx | 6 ++--- sc/source/core/data/colorscale.cxx | 54 +++++++++++++++++++++++++++++++++----- sc/source/core/data/conditio.cxx | 4 +-- 4 files changed, 59 insertions(+), 13 deletions(-) (limited to 'sc') diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index db13e92db74e..df3e17a66507 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -86,6 +86,10 @@ public: ScColorScaleEntryType GetType() const; void SetType( ScColorScaleEntryType eType ); + +#if DUMP_FORMAT_INFO + void dumpInfo(rtl::OUStringBuffer& rBuf) const; +#endif }; namespace databar @@ -228,7 +232,7 @@ public: size_t size() const; #if DUMP_FORMAT_INFO - virtual void dumpInfo() const; + virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const; #endif }; @@ -252,7 +256,7 @@ public: virtual condformat::ScFormatEntryType GetType() const; #if DUMP_FORMAT_INFO - virtual void dumpInfo() const; + virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const; #endif private: double getMin(double nMin, double nMax) const; diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index b4f686ea6dc6..7b1cf170ebe7 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -114,7 +114,7 @@ public: bool operator==( const ScFormatEntry& ) const; #if DUMP_FORMAT_INFO - virtual void dumpInfo() const = 0; + virtual void dumpInfo(rtl::OUStringBuffer& rBuf) const = 0; #endif protected: ScDocument* mpDoc; @@ -213,7 +213,7 @@ public: static ScConditionMode GetModeFromApi(sal_Int32 nOperator); #if DUMP_FORMAT_INFO - virtual void dumpInfo() const {} + virtual void dumpInfo(rtl::OUStringBuffer& ) const {} #endif protected: @@ -319,7 +319,7 @@ public: bool MarkUsedExternalReferences() const; #if DUMP_FORMAT_INFO - void dumpInfo() const; + void dumpInfo(rtl::OUStringBuffer& rBuf) const; #endif // sorted (via PTRARR) by Index diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 1303e0165096..4ca1bc7c6baf 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -147,6 +147,44 @@ void ScColorScaleEntry::SetColor(const Color& rColor) maColor = rColor; } +#if DUMP_FORMAT_INFO + +void ScColorScaleEntry::dumpInfo(rtl::OUStringBuffer& rBuf) const +{ + rBuf.append("Color Scale Entry\n"); + rBuf.append("Type: "); + switch(meType) + { + case COLORSCALE_VALUE: + rBuf.append( "Value\n" ); + break; + case COLORSCALE_MIN: + rBuf.append( "Min\n" ); + break; + case COLORSCALE_MAX: + rBuf.append( "Max\n" ); + break; + case COLORSCALE_PERCENT: + rBuf.append( "Percent\n" ); + break; + case COLORSCALE_PERCENTILE: + rBuf.append( "Percentile\n" ); + break; + case COLORSCALE_FORMULA: + rBuf.append( "Formual\n" ); + break; + default: + rBuf.append( "Unsupported Type\n" ); + } + rBuf.append( "Color: " ).append( (int)maColor.GetRed() ).append( "," ).append( (int)maColor.GetGreen() ).append( "," ).append( (int)maColor.GetBlue() ).append( "\n" ); + if(meType == COLORSCALE_FORMULA) + rBuf.append( "Formula: " ).append( GetFormula( formula::FormulaGrammar::GRAM_DEFAULT ) ).append("\n"); + else if( meType != COLORSCALE_MIN && meType != COLORSCALE_MAX ) + rBuf.append( "Value: " ).append( mnVal ).append( "\n" ); +} + +#endif + ScColorFormat::ScColorFormat(ScDocument* pDoc): ScFormatEntry(pDoc) { @@ -491,9 +529,14 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const } #if DUMP_FORMAT_INFO -void ScColorScaleFormat::dumpInfo() const +void ScColorScaleFormat::dumpInfo(rtl::OUStringBuffer& rBuf) const { - std::cout << "Color Scale" << std::endl; + rBuf.append("Color Scale with ").append(static_cast(size())).append(" entries\n"); + for(const_iterator itr = begin(); itr != end(); ++itr) + { + itr->dumpInfo(rBuf); + } + const ScRangeList& rRange = GetRange(); size_t n = rRange.size(); for(size_t i = 0; i < n; ++i) @@ -505,9 +548,8 @@ void ScColorScaleFormat::dumpInfo() const for( SCROW nRow = pRange->aStart.Row(), nEndRow = pRange->aEnd.Row(); nRow <= nEndRow; ++nRow) { boost::scoped_ptr pColor( GetColor(ScAddress(nCol, nRow, nTab)) ); - std::cout << nCol << "," << nRow << "," << nTab << ","; - std::cout << ((int)pColor->GetRed()) << "," << ((int)pColor->GetGreen()) << "," << ((int)pColor->GetBlue()); - std::cout << std::endl; + rBuf.append(nCol).append(",").append(nRow).append(",").append(nTab).append(","); + rBuf.append(((int)pColor->GetRed())).append(",").append(((int)pColor->GetGreen())).append(",").append(((int)pColor->GetBlue())).append("\n"); } } } @@ -852,7 +894,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const } #if DUMP_FORMAT_INFO -void ScDataBarFormat::dumpInfo() const +void ScDataBarFormat::dumpInfo(rtl::OUStringBuffer& rBuf) const { const ScRangeList& rRange = GetRange(); size_t n = rRange.size(); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 7f0c2d97b004..c8e2dbc5409b 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1457,11 +1457,11 @@ ScCondFormatData ScConditionalFormat::GetData( ScBaseCell* pCell, const ScAddres #if DUMP_FORMAT_INFO -void ScConditionalFormat::dumpInfo() const +void ScConditionalFormat::dumpInfo(rtl::OUStringBuffer& rBuf) const { for(CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - itr->dumpInfo(); + itr->dumpInfo(rBuf); } } #endif -- cgit v1.2.3