[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.3' - sc/source

Henry Castro hcvcastro at gmail.com
Thu Mar 5 04:57:37 PST 2015


 sc/source/ui/app/inputhdl.cxx |    8 ++++++
 sc/source/ui/app/rfindlst.cxx |   52 +++++++++++++++++++++++++++++++++++++-----
 sc/source/ui/inc/rfindlst.hxx |    2 +
 3 files changed, 56 insertions(+), 6 deletions(-)

New commits:
commit 69bc259abe1c9c8576179c7d764c03b5fbf239f2
Author: Henry Castro <hcvcastro at gmail.com>
Date:   Wed Mar 4 17:26:05 2015 -0400

    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 at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit 3381cb4a421bf390445b7dac9ea42f9ccaf3d875)

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 961cbcd..75a723a 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 90c426e..59c63f5 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 b0b1012..85644aa 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


More information about the Libreoffice-commits mailing list