summaryrefslogtreecommitdiff
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-10 00:14:16 (GMT)
committer Markus Mohrhard <markus.mohrhard@googlemail.com>2012-05-10 00:34:16 (GMT)
commitb1ba05b2cc7bdbb21fb2a9626b029f0c46926ac4 (patch) (side-by-side diff)
tree5944f7fb4afe95bc23a323360262d57471008356
parent7c99fff933a112044589874d91e226df8e0332fd (diff)
downloadcore-b1ba05b2cc7bdbb21fb2a9626b029f0c46926ac4.zip
core-b1ba05b2cc7bdbb21fb2a9626b029f0c46926ac4.tar.gz
Color Scales are now displayed after import from xlsx
It is still displayed at the wrong position but it looks promising. Change-Id: I7ee55525cc219594635d81240f198b0a30c8707d
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--sc/inc/colorscale.hxx2
-rw-r--r--sc/inc/fillinfo.hxx11
-rw-r--r--sc/source/core/data/colorscale.cxx10
-rw-r--r--sc/source/core/data/fillinfo.cxx2
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx5
-rw-r--r--sc/source/ui/view/output.cxx85
6 files changed, 87 insertions, 28 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index df65333..01ff306 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -55,6 +55,8 @@ private:
typedef boost::ptr_vector<ScColorScaleEntry> 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 167e24a..a5786ba 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -31,7 +31,6 @@
#include <svx/framelinkarray.hxx>
#include "global.hxx"
-#include <boost/shared_ptr.hpp>
class SfxItemSet;
class SvxBrushItem;
@@ -69,7 +68,7 @@ struct CellInfo
const ScPatternAttr* pPatternAttr;
const SfxItemSet* pConditionSet;
- boost::shared_ptr<Color> 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 787690d..f05afb0 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 8ad3dba..9d7fc2f 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 e189c75..8cc7778 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 <iostream>
-
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 b892c51..72db311 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -73,6 +73,8 @@
#include <math.h>
+#include <iostream>
+
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;