summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcvcastro@gmail.com>2015-03-04 17:26:05 -0400
committerAndras Timar <andras.timar@collabora.com>2015-03-05 12:58:53 +0100
commit36a808de7cb79e1c20c9e23d41b54a7c8399dcd3 (patch)
tree4b5840b0ebc892befd8f82dc8b8c8c11bd920e2a
parent997195580a4436409c752a357391107ffd91119e (diff)
Resolves tdf#78221 Cannot drag twice the same cell when editing formula
Change-Id: I69402778e68a2955bdda1ba2c9d31d9b10fb60cc Reviewed-on: https://gerrit.libreoffice.org/14748 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit 3381cb4a421bf390445b7dac9ea42f9ccaf3d875) Signed-off-by: Andras Timar <andras.timar@collabora.com>
-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 482a56fc6cb2..c44257b45e30 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -340,6 +340,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
@@ -347,11 +348,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();
@@ -361,6 +365,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++)
@@ -369,6 +374,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