From b1ba05b2cc7bdbb21fb2a9626b029f0c46926ac4 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 10 May 2012 02:14:16 +0200 Subject: Color Scales are now displayed after import from xlsx It is still displayed at the wrong position but it looks promising. Change-Id: I7ee55525cc219594635d81240f198b0a30c8707d --- sc/inc/colorscale.hxx | 2 + sc/inc/fillinfo.hxx | 11 +++- sc/source/core/data/colorscale.cxx | 10 +++- sc/source/core/data/fillinfo.cxx | 2 +- sc/source/filter/oox/condformatbuffer.cxx | 5 +- sc/source/ui/view/output.cxx | 85 ++++++++++++++++++++++++------- 6 files changed, 87 insertions(+), 28 deletions(-) diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index df653337a038..01ff306ba45d 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -55,6 +55,8 @@ private: typedef boost::ptr_vector ColorScaleEntries; ColorScaleEntries maColorScales; public: + ScColorScaleFormat(ScDocument* pDoc); + Color* GetColor(const ScAddress& rAddr) const; void AddEntry(ScColorScaleEntry* pEntry); diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx index 167e24a8aebc..a5786ba79d34 100644 --- a/sc/inc/fillinfo.hxx +++ b/sc/inc/fillinfo.hxx @@ -31,7 +31,6 @@ #include #include "global.hxx" -#include class SfxItemSet; class SvxBrushItem; @@ -69,7 +68,7 @@ struct CellInfo const ScPatternAttr* pPatternAttr; const SfxItemSet* pConditionSet; - boost::shared_ptr pColorScale; + const Color* pColorScale; const SvxBrushItem* pBackground; @@ -103,6 +102,14 @@ struct CellInfo sal_Bool bHideGrid : 1; // output-internal sal_Bool bEditEngine : 1; // output-internal + + CellInfo(): + pColorScale(NULL) {} + + ~CellInfo() + { + delete pColorScale; + } }; const SCCOL SC_ROTMAX_NONE = SCCOL_MAX; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 787690dbe048..f05afb015fbb 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -54,6 +54,11 @@ const Color& ScColorScaleEntry::GetColor() const return maColor; } +ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc): + mpDoc(pDoc) +{ +} + void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry ) { maColorScales.push_back( pEntry ); @@ -99,7 +104,7 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const // now we have for sure a value double nVal = mpDoc->GetValue(rAddr); - if (!maColorScales.size() < 2) + if (maColorScales.size() < 2) return NULL; const_iterator itr = begin(); @@ -109,13 +114,14 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const double nValMax = itr->GetValue(); Color rColMax = itr->GetColor(); + ++itr; while(itr != end() && nVal > nValMin) { - ++itr; rColMin = rColMax; nValMin = nValMax; rColMax = itr->GetColor(); nValMax = itr->GetValue(); + ++itr; } Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax); diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 8ad3dba30180..9d7fc2f9972d 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -568,7 +568,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX if ( pColorScale ) { Color* pColor = pColorScale->GetColor( ScAddress( nX, nCurRow, nTab ) ); - pInfo->pColorScale.reset(pColor); + pInfo->pColorScale = pColor; } ++nArrY; diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index e189c75c64bb..8cc7778d60c9 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -61,8 +61,6 @@ #include "docpool.hxx" #include "scitems.hxx" -#include - namespace oox { namespace xls { @@ -158,7 +156,6 @@ void ColorScaleRule::importValue( const AttributeList& rAttribs ) { double nVal = rAttribs.getDouble( XML_val, 0.0 ); maValues.push_back(nVal); - std::cout << "ColorScaleRule::importValue: " << nVal << std::endl; } } @@ -659,7 +656,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > else if( mpColor ) { ScDocument& rDoc = getScDocument(); - ScColorScaleFormat* pFormat = new ScColorScaleFormat(); + ScColorScaleFormat* pFormat = new ScColorScaleFormat(&rDoc); mpColor->AddEntries( pFormat ); sal_Int32 nIndex = rDoc.AddColorScaleFormat(pFormat); diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index b892c51701bf..72db311d7d27 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -73,6 +73,8 @@ #include +#include + using namespace com::sun::star; // STATIC DATA ----------------------------------------------------------- @@ -760,6 +762,17 @@ sal_Bool lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther, if ( rFirst.pCellInfo[nX+1].bPrinted != rOther.pCellInfo[nX+1].bPrinted ) return false; + for ( nX=nX1; nX<=nX2; nX++ ) + { + const Color* pCol1 = rFirst.pCellInfo[nX+1].pColorScale; + const Color* pCol2 = rOther.pCellInfo[nX+1].pColorScale; + if( (pCol1 && !pCol2) || (!pCol1 && pCol2) ) + return false; + + if (pCol1 && (*pCol1 != *pCol2)) + return false; + } + return sal_True; } @@ -869,7 +882,22 @@ void ScOutputData::DrawBackground() pBackground = lcl_FindBackground( pDoc, nX, nY, nTab ); } - if ( pBackground != pOldBackground ) + if( pInfo->pColorScale ) + { + std::cout << "pColorScale: finally Found it !" << std::endl; + std::cout << nX << " " << nArrY << std::endl; + pOldBackground = NULL; + + aRect.Right() = nPosX-nSignedOneX; + const Color* pColor = pInfo->pColorScale; + if( !pColor->GetTransparency() ) + { + pDev->SetFillColor( *pColor ); + pDev->DrawRect( aRect ); + } + aRect.Left() = nPosX - nSignedOneX; + } + else if ( pBackground != pOldBackground ) { aRect.Right() = nPosX-nSignedOneX; if (pOldBackground) // ==0 if hidden @@ -1463,28 +1491,47 @@ void ScOutputData::DrawRotatedFrame( const Color* pForceColor ) // high contrast for cell borders and backgrounds -> empty background pBackground = ScGlobal::GetEmptyBrushItem(); } - const Color& rColor = pBackground->GetColor(); - if ( rColor.GetTransparency() != 255 ) + if(!pInfo->pColorScale) { - // draw background only for the changed row itself - // (background doesn't extend into other cells). - // For the borders (rotated and normal), clipping should be - // set if the row isn't changed, but at least the borders - // don't cover the cell contents. - if ( rThisRowInfo.bChanged ) + const Color& rColor = pBackground->GetColor(); + if ( rColor.GetTransparency() != 255 ) { - Polygon aPoly( 4, aPoints ); - - // ohne Pen wird bei DrawPolygon rechts und unten - // ein Pixel weggelassen... - if ( rColor.GetTransparency() == 0 ) - pDev->SetLineColor(rColor); - else - pDev->SetLineColor(); - pDev->SetFillColor(rColor); - pDev->DrawPolygon( aPoly ); + // draw background only for the changed row itself + // (background doesn't extend into other cells). + // For the borders (rotated and normal), clipping should be + // set if the row isn't changed, but at least the borders + // don't cover the cell contents. + if ( rThisRowInfo.bChanged ) + { + Polygon aPoly( 4, aPoints ); + + // ohne Pen wird bei DrawPolygon rechts und unten + // ein Pixel weggelassen... + if ( rColor.GetTransparency() == 0 ) + pDev->SetLineColor(rColor); + else + pDev->SetLineColor(); + pDev->SetFillColor(rColor); + pDev->DrawPolygon( aPoly ); + } } } + else + { + std::cout << "ColorScale" << std::endl; + Polygon aPoly( 4, aPoints ); + const Color* pColor = pInfo->pColorScale; + + // ohne Pen wird bei DrawPolygon rechts und unten + // ein Pixel weggelassen... + if ( pColor->GetTransparency() == 0 ) + pDev->SetLineColor(*pColor); + else + pDev->SetLineColor(); + pDev->SetFillColor(*pColor); + pDev->DrawPolygon( aPoly ); + + } svx::frame::Style aTopLine, aBottomLine, aLeftLine, aRightLine; -- cgit v1.2.3