summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-10 02:14:16 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-10 02:34:16 +0200
commitb1ba05b2cc7bdbb21fb2a9626b029f0c46926ac4 (patch)
tree5944f7fb4afe95bc23a323360262d57471008356
parent7c99fff933a112044589874d91e226df8e0332fd (diff)
Color Scales are now displayed after import from xlsx
It is still displayed at the wrong position but it looks promising. Change-Id: I7ee55525cc219594635d81240f198b0a30c8707d
-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 df653337a038..01ff306ba45d 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -55,6 +55,8 @@ private:
55 typedef boost::ptr_vector<ScColorScaleEntry> ColorScaleEntries; 55 typedef boost::ptr_vector<ScColorScaleEntry> ColorScaleEntries;
56 ColorScaleEntries maColorScales; 56 ColorScaleEntries maColorScales;
57public: 57public:
58 ScColorScaleFormat(ScDocument* pDoc);
59
58 Color* GetColor(const ScAddress& rAddr) const; 60 Color* GetColor(const ScAddress& rAddr) const;
59 void AddEntry(ScColorScaleEntry* pEntry); 61 void AddEntry(ScColorScaleEntry* pEntry);
60 62
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 @@
31 31
32#include <svx/framelinkarray.hxx> 32#include <svx/framelinkarray.hxx>
33#include "global.hxx" 33#include "global.hxx"
34#include <boost/shared_ptr.hpp>
35 34
36class SfxItemSet; 35class SfxItemSet;
37class SvxBrushItem; 36class SvxBrushItem;
@@ -69,7 +68,7 @@ struct CellInfo
69 68
70 const ScPatternAttr* pPatternAttr; 69 const ScPatternAttr* pPatternAttr;
71 const SfxItemSet* pConditionSet; 70 const SfxItemSet* pConditionSet;
72 boost::shared_ptr<Color> pColorScale; 71 const Color* pColorScale;
73 72
74 const SvxBrushItem* pBackground; 73 const SvxBrushItem* pBackground;
75 74
@@ -103,6 +102,14 @@ struct CellInfo
103 102
104 sal_Bool bHideGrid : 1; // output-internal 103 sal_Bool bHideGrid : 1; // output-internal
105 sal_Bool bEditEngine : 1; // output-internal 104 sal_Bool bEditEngine : 1; // output-internal
105
106 CellInfo():
107 pColorScale(NULL) {}
108
109 ~CellInfo()
110 {
111 delete pColorScale;
112 }
106}; 113};
107 114
108const SCCOL SC_ROTMAX_NONE = SCCOL_MAX; 115const 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
54 return maColor; 54 return maColor;
55} 55}
56 56
57ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc):
58 mpDoc(pDoc)
59{
60}
61
57void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry ) 62void ScColorScaleFormat::AddEntry( ScColorScaleEntry* pEntry )
58{ 63{
59 maColorScales.push_back( pEntry ); 64 maColorScales.push_back( pEntry );
@@ -99,7 +104,7 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
99 // now we have for sure a value 104 // now we have for sure a value
100 double nVal = mpDoc->GetValue(rAddr); 105 double nVal = mpDoc->GetValue(rAddr);
101 106
102 if (!maColorScales.size() < 2) 107 if (maColorScales.size() < 2)
103 return NULL; 108 return NULL;
104 109
105 const_iterator itr = begin(); 110 const_iterator itr = begin();
@@ -109,13 +114,14 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
109 double nValMax = itr->GetValue(); 114 double nValMax = itr->GetValue();
110 Color rColMax = itr->GetColor(); 115 Color rColMax = itr->GetColor();
111 116
117 ++itr;
112 while(itr != end() && nVal > nValMin) 118 while(itr != end() && nVal > nValMin)
113 { 119 {
114 ++itr;
115 rColMin = rColMax; 120 rColMin = rColMax;
116 nValMin = nValMax; 121 nValMin = nValMax;
117 rColMax = itr->GetColor(); 122 rColMax = itr->GetColor();
118 nValMax = itr->GetValue(); 123 nValMax = itr->GetValue();
124 ++itr;
119 } 125 }
120 126
121 Color aColor = CalcColor(nVal, nValMin, rColMin, nValMax, rColMax); 127 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
568 if ( pColorScale ) 568 if ( pColorScale )
569 { 569 {
570 Color* pColor = pColorScale->GetColor( ScAddress( nX, nCurRow, nTab ) ); 570 Color* pColor = pColorScale->GetColor( ScAddress( nX, nCurRow, nTab ) );
571 pInfo->pColorScale.reset(pColor); 571 pInfo->pColorScale = pColor;
572 } 572 }
573 573
574 ++nArrY; 574 ++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 @@
61#include "docpool.hxx" 61#include "docpool.hxx"
62#include "scitems.hxx" 62#include "scitems.hxx"
63 63
64#include <iostream>
65
66namespace oox { 64namespace oox {
67namespace xls { 65namespace xls {
68 66
@@ -158,7 +156,6 @@ void ColorScaleRule::importValue( const AttributeList& rAttribs )
158 { 156 {
159 double nVal = rAttribs.getDouble( XML_val, 0.0 ); 157 double nVal = rAttribs.getDouble( XML_val, 0.0 );
160 maValues.push_back(nVal); 158 maValues.push_back(nVal);
161 std::cout << "ColorScaleRule::importValue: " << nVal << std::endl;
162 } 159 }
163} 160}
164 161
@@ -659,7 +656,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
659 else if( mpColor ) 656 else if( mpColor )
660 { 657 {
661 ScDocument& rDoc = getScDocument(); 658 ScDocument& rDoc = getScDocument();
662 ScColorScaleFormat* pFormat = new ScColorScaleFormat(); 659 ScColorScaleFormat* pFormat = new ScColorScaleFormat(&rDoc);
663 660
664 mpColor->AddEntries( pFormat ); 661 mpColor->AddEntries( pFormat );
665 sal_Int32 nIndex = rDoc.AddColorScaleFormat(pFormat); 662 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 @@
73 73
74#include <math.h> 74#include <math.h>
75 75
76#include <iostream>
77
76using namespace com::sun::star; 78using namespace com::sun::star;
77 79
78// STATIC DATA ----------------------------------------------------------- 80// STATIC DATA -----------------------------------------------------------
@@ -760,6 +762,17 @@ sal_Bool lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther,
760 if ( rFirst.pCellInfo[nX+1].bPrinted != rOther.pCellInfo[nX+1].bPrinted ) 762 if ( rFirst.pCellInfo[nX+1].bPrinted != rOther.pCellInfo[nX+1].bPrinted )
761 return false; 763 return false;
762 764
765 for ( nX=nX1; nX<=nX2; nX++ )
766 {
767 const Color* pCol1 = rFirst.pCellInfo[nX+1].pColorScale;
768 const Color* pCol2 = rOther.pCellInfo[nX+1].pColorScale;
769 if( (pCol1 && !pCol2) || (!pCol1 && pCol2) )
770 return false;
771
772 if (pCol1 && (*pCol1 != *pCol2))
773 return false;
774 }
775
763 return sal_True; 776 return sal_True;
764} 777}
765 778
@@ -869,7 +882,22 @@ void ScOutputData::DrawBackground()
869 pBackground = lcl_FindBackground( pDoc, nX, nY, nTab ); 882 pBackground = lcl_FindBackground( pDoc, nX, nY, nTab );
870 } 883 }
871 884
872 if ( pBackground != pOldBackground ) 885 if( pInfo->pColorScale )
886 {
887 std::cout << "pColorScale: finally Found it !" << std::endl;
888 std::cout << nX << " " << nArrY << std::endl;
889 pOldBackground = NULL;
890
891 aRect.Right() = nPosX-nSignedOneX;
892 const Color* pColor = pInfo->pColorScale;
893 if( !pColor->GetTransparency() )
894 {
895 pDev->SetFillColor( *pColor );
896 pDev->DrawRect( aRect );
897 }
898 aRect.Left() = nPosX - nSignedOneX;
899 }
900 else if ( pBackground != pOldBackground )
873 { 901 {
874 aRect.Right() = nPosX-nSignedOneX; 902 aRect.Right() = nPosX-nSignedOneX;
875 if (pOldBackground) // ==0 if hidden 903 if (pOldBackground) // ==0 if hidden
@@ -1463,28 +1491,47 @@ void ScOutputData::DrawRotatedFrame( const Color* pForceColor )
1463 // high contrast for cell borders and backgrounds -> empty background 1491 // high contrast for cell borders and backgrounds -> empty background
1464 pBackground = ScGlobal::GetEmptyBrushItem(); 1492 pBackground = ScGlobal::GetEmptyBrushItem();
1465 } 1493 }
1466 const Color& rColor = pBackground->GetColor(); 1494 if(!pInfo->pColorScale)
1467 if ( rColor.GetTransparency() != 255 )
1468 { 1495 {
1469 // draw background only for the changed row itself 1496 const Color& rColor = pBackground->GetColor();
1470 // (background doesn't extend into other cells). 1497 if ( rColor.GetTransparency() != 255 )
1471 // For the borders (rotated and normal), clipping should be
1472 // set if the row isn't changed, but at least the borders
1473 // don't cover the cell contents.
1474 if ( rThisRowInfo.bChanged )
1475 { 1498 {
1476 Polygon aPoly( 4, aPoints ); 1499 // draw background only for the changed row itself
1477 1500 // (background doesn't extend into other cells).
1478 // ohne Pen wird bei DrawPolygon rechts und unten 1501 // For the borders (rotated and normal), clipping should be
1479 // ein Pixel weggelassen... 1502 // set if the row isn't changed, but at least the borders
1480 if ( rColor.GetTransparency() == 0 ) 1503 // don't cover the cell contents.
1481 pDev->SetLineColor(rColor); 1504 if ( rThisRowInfo.bChanged )
1482 else 1505 {
1483 pDev->SetLineColor(); 1506 Polygon aPoly( 4, aPoints );
1484 pDev->SetFillColor(rColor); 1507
1485 pDev->DrawPolygon( aPoly ); 1508 // ohne Pen wird bei DrawPolygon rechts und unten
1509 // ein Pixel weggelassen...
1510 if ( rColor.GetTransparency() == 0 )
1511 pDev->SetLineColor(rColor);
1512 else
1513 pDev->SetLineColor();
1514 pDev->SetFillColor(rColor);
1515 pDev->DrawPolygon( aPoly );
1516 }
1486 } 1517 }
1487 } 1518 }
1519 else
1520 {
1521 std::cout << "ColorScale" << std::endl;
1522 Polygon aPoly( 4, aPoints );
1523 const Color* pColor = pInfo->pColorScale;
1524
1525 // ohne Pen wird bei DrawPolygon rechts und unten
1526 // ein Pixel weggelassen...
1527 if ( pColor->GetTransparency() == 0 )
1528 pDev->SetLineColor(*pColor);
1529 else
1530 pDev->SetLineColor();
1531 pDev->SetFillColor(*pColor);
1532 pDev->DrawPolygon( aPoly );
1533
1534 }
1488 1535
1489 svx::frame::Style aTopLine, aBottomLine, aLeftLine, aRightLine; 1536 svx::frame::Style aTopLine, aBottomLine, aLeftLine, aRightLine;
1490 1537