diff options
author | Rachit Gupta <rachitgupta1792@gmail.com> | 2014-01-18 16:07:02 +0530 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-02-08 22:30:56 +0100 |
commit | 5ff8e1d8e31f23492ee1ccc3af0b73791cd5101b (patch) | |
tree | 5b3f60402f2e7842f8d6ef1eb2e5c1495a7d5e01 | |
parent | dec544be7c929a5c006008ddd3b901f18f4fbbe1 (diff) |
fdo#52461 Multiple instances of same cell now get same color.
nColorData added to ScRangeFindData for color assigned to cell.
While inserting a range in maEntries, vector is checked.
If the range is already present, the color is returned.
Else, a new entry is pushed in the vector and it's color is returned.
Conflicts:
sc/source/ui/inc/rfindlst.hxx
Change-Id: I38b93092cd22fa42ada55fa5d28eec9b71c12703
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/app/rfindlst.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/inc/rfindlst.hxx | 11 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 2 |
4 files changed, 26 insertions, 8 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 531a2443103a..53ea0bbb2ff3 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -277,11 +277,11 @@ handle_r1c1: pRangeFindList = new ScRangeFindList( pDocSh->GetTitle() ); } - pRangeFindList->Insert( ScRangeFindData( aRange, nFlags, nStart, nPos ) ); + ColorData nColorData = pRangeFindList->Insert( ScRangeFindData( aRange, nFlags, nStart, nPos ) ); ESelection aSel( 0, nStart, 0, nPos ); SfxItemSet aSet( pEngine->GetEmptyItemSet() ); - aSet.Put( SvxColorItem( Color( ScRangeFindList::GetColorName( nCount ) ), + aSet.Put( SvxColorItem( Color( nColorData ), EE_CHAR_COLOR ) ); pEngine->QuickSetAttribs( aSet, aSel ); ++nCount; diff --git a/sc/source/ui/app/rfindlst.cxx b/sc/source/ui/app/rfindlst.cxx index f24b9eb63f44..b3c16f4a5245 100644 --- a/sc/source/ui/app/rfindlst.cxx +++ b/sc/source/ui/app/rfindlst.cxx @@ -35,7 +35,22 @@ ScRangeFindList::ScRangeFindList(const OUString& rName) : { } -ColorData ScRangeFindList::GetColorName( size_t nIndex ) +ColorData ScRangeFindList::Insert( const ScRangeFindData &rNew ) +{ + for(std::vector<ScRangeFindData>::iterator it=maEntries.begin(); it!=maEntries.end(); ++it) + { + if(it->aRef == rNew.aRef) + { + return it->nColorData; + } + } + ScRangeFindData insertData(rNew); + insertData.nColorData = aColNames[maEntries.size() % SC_RANGECOLORS]; + maEntries.push_back(insertData); + return insertData.nColorData; +} + +ColorData ScRangeFindList::GetColorName( const size_t nIndex ) { return aColNames[nIndex % SC_RANGECOLORS]; } diff --git a/sc/source/ui/inc/rfindlst.hxx b/sc/source/ui/inc/rfindlst.hxx index 090ea65603c7..28f1facdff22 100644 --- a/sc/source/ui/inc/rfindlst.hxx +++ b/sc/source/ui/inc/rfindlst.hxx @@ -28,12 +28,15 @@ struct ScRangeFindData { - ScRange aRef; - sal_uInt16 nFlags; + ScRange aRef; + sal_uInt16 nFlags; sal_Int32 nSelStart; sal_Int32 nSelEnd; ScRangeFindData( const ScRange& rR, sal_uInt16 nF, sal_Int32 nS, sal_Int32 nE ) : + ColorData nColorData; + + ScRangeFindData( const ScRange& rR, sal_uInt16 nF, xub_StrLen nS, xub_StrLen nE) : aRef(rR), nFlags(nF), nSelStart(nS), nSelEnd(nE) {} }; @@ -47,7 +50,7 @@ public: ScRangeFindList(const OUString& rName); sal_uLong Count() const { return maEntries.size(); } - void Insert( const ScRangeFindData &rNew ) { maEntries.push_back(rNew); } + ColorData Insert( const ScRangeFindData &rNew ); ScRangeFindData* GetObject( sal_uLong nIndex ) { return &(maEntries[nIndex]); } @@ -56,7 +59,7 @@ public: const OUString& GetDocName() const { return aDocName; } bool IsHidden() const { return bHidden; } - static ColorData GetColorName( size_t nIndex ); + static ColorData GetColorName(const size_t nIndex); }; diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 6390f8b9b9f5..729073b23d96 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -805,7 +805,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab ) aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(), aRef.aEnd.Col(), aRef.aEnd.Row(), - Color( ScRangeFindList::GetColorName( i ) ), + Color( pData->nColorData ), sal_True ); } } |