summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/app/inputhdl.cxx8
-rw-r--r--sc/source/ui/app/rfindlst.cxx52
-rw-r--r--sc/source/ui/inc/rfindlst.hxx2
3 files changed, 56 insertions, 6 deletions
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 1a70373ce0f2..eef56d029438 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -337,6 +337,7 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew )
ScRangeFindData* pData = pRangeFindList->GetObject( nIndex );
sal_Int32 nOldStart = pData->nSelStart;
sal_Int32 nOldEnd = pData->nSelEnd;
+ ColorData nNewColor = pRangeFindList->FindColor( rNew, nIndex );
ScRange aJustified = rNew;
aJustified.Justify(); // Always display Ref in the Formula the right way
@@ -344,11 +345,14 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew )
const ScAddress::Details aAddrDetails( pDoc, aCursorPos );
OUString aNewStr(aJustified.Format(pData->nFlags, pDoc, aAddrDetails));
ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
+ SfxItemSet aSet( pEngine->GetEmptyItemSet() );
DataChanging();
lcl_Replace( pTopView, aNewStr, aOldSel );
lcl_Replace( pTableView, aNewStr, aOldSel );
+ aSet.Put( SvxColorItem( Color( nNewColor ), EE_CHAR_COLOR ) );
+ pEngine->QuickSetAttribs( aSet, aOldSel );
bInRangeUpdate = true;
DataChanged();
@@ -358,6 +362,7 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew )
pData->aRef = rNew;
pData->nSelEnd = pData->nSelEnd + nDiff;
+ pData->nColorData = nNewColor;
sal_uInt16 nCount = (sal_uInt16) pRangeFindList->Count();
for (sal_uInt16 i=nIndex+1; i<nCount; i++)
@@ -366,6 +371,9 @@ void ScInputHandler::UpdateRange( sal_uInt16 nIndex, const ScRange& rNew )
pNext->nSelStart = pNext->nSelStart + nDiff;
pNext->nSelEnd = pNext->nSelEnd + nDiff;
}
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ pActiveView->ShowCursor( false, true );
}
else
{
diff --git a/sc/source/ui/app/rfindlst.cxx b/sc/source/ui/app/rfindlst.cxx
index 90c426ed0336..59c63f59fe41 100644
--- a/sc/source/ui/app/rfindlst.cxx
+++ b/sc/source/ui/app/rfindlst.cxx
@@ -18,6 +18,7 @@
*/
#include "rfindlst.hxx"
+#include <tools/debug.hxx>
// STATIC DATA -----------------------------------------------------------
@@ -29,22 +30,24 @@ static const ColorData aColNames[SC_RANGECOLORS] =
ScRangeFindList::ScRangeFindList(const OUString& rName) :
aDocName( rName ),
- bHidden( false )
+ bHidden( false ),
+ nIndexColor( 0 )
{
}
ColorData ScRangeFindList::Insert( const ScRangeFindData &rNew )
{
- for(std::vector<ScRangeFindData>::iterator it=maEntries.begin(); it!=maEntries.end(); ++it)
+ std::vector<ScRangeFindData>::iterator it=maEntries.begin();
+ for( ; it!=maEntries.end(); ++it)
{
if(it->aRef == rNew.aRef)
- {
- return it->nColorData;
- }
+ break;
}
ScRangeFindData insertData(rNew);
- insertData.nColorData = aColNames[maEntries.size() % SC_RANGECOLORS];
+ insertData.nColorData = ( it != maEntries.end() ? it->nColorData :
+ ScRangeFindList::GetColorName( maEntries.size() ) );
maEntries.push_back(insertData);
+ nIndexColor = maEntries.size() - 1;
return insertData.nColorData;
}
@@ -53,4 +56,41 @@ ColorData ScRangeFindList::GetColorName( const size_t nIndex )
return aColNames[nIndex % SC_RANGECOLORS];
}
+ColorData ScRangeFindList::FindColor( const ScRange& rRef, const size_t nIndex )
+{
+ sal_Int32 nOldCntr = 0;
+ sal_Int32 nNewCntr = 0;
+ ColorData nOldColor = 0;
+ ColorData nNewColor = 0;
+
+ DBG_ASSERT( (nIndex < maEntries.size()), "nIndex out of range!" );
+
+ nOldColor = maEntries[nIndex].nColorData;
+ nNewColor = ScRangeFindList::GetColorName( nIndex );
+
+ std::vector<ScRangeFindData>::iterator it=maEntries.begin();
+ for( ;it!=maEntries.end(); ++it)
+ {
+ if(it->aRef == rRef)
+ break;
+
+ if (it->nColorData == nOldColor )
+ nOldCntr++;
+
+ if (it->nColorData == nNewColor )
+ nNewCntr++;
+ }
+
+ if ( it != maEntries.end() )
+ return it->nColorData;
+
+ if ( nOldCntr == 1 )
+ return nOldColor;
+
+ if ( nNewCntr > 0 )
+ return ScRangeFindList::GetColorName( ++nIndexColor );
+
+ return nNewColor;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/rfindlst.hxx b/sc/source/ui/inc/rfindlst.hxx
index 7159b108f6b1..80aaecfbd4ee 100644
--- a/sc/source/ui/inc/rfindlst.hxx
+++ b/sc/source/ui/inc/rfindlst.hxx
@@ -41,6 +41,7 @@ class ScRangeFindList
std::vector<ScRangeFindData> maEntries;
OUString aDocName;
bool bHidden;
+ sal_uInt16 nIndexColor;
public:
ScRangeFindList(const OUString& rName);
@@ -56,6 +57,7 @@ public:
bool IsHidden() const { return bHidden; }
static ColorData GetColorName(const size_t nIndex);
+ ColorData FindColor(const ScRange& rRef, const size_t nIndex);
};
#endif