[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kspread
From:       Robert Knight <robertknight () gmail ! com>
Date:       2006-02-01 4:34:20
Message-ID: 1138768460.898730.7127.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 504437 by knight:

Fixes to highlighted ranges:  If the same range reference appears more than once it \
is now highlighted in the same color.  Fixed another crash with invalid range names.  \
Fixed all ranges disappearing when entering say '=C1+C2' then deleting the last \
character.

 M  +0 -5      kspread_canvas.cc  
 M  +23 -12    kspread_editors.cc  
 M  +38 -5     kspread_util.cc  
 M  +5 -0      kspread_util.h  
 M  +2 -1      selection.cc  


--- trunk/koffice/kspread/kspread_canvas.cc #504436:504437
@@ -4079,11 +4079,6 @@
 
 void Canvas::paintHighlightedRanges(QPainter& painter, const KoRect& /*viewRect*/)
 {
-  if (!d->chooseCell)
-  {
-    return;
-  }
-
   QValueList<QColor> colors = choice()->colors();
   QBrush nullBrush;
   int index = 0;
--- trunk/koffice/kspread/kspread_editors.cc #504436:504437
@@ -99,15 +99,11 @@
 
 int FormulaEditorHighlighter::highlightParagraph(const QString& text, int /* \
endStateOfLastPara */)  {
-//   kdDebug() << k_funcinfo << endl;
-
-  
   // reset syntax highlighting
   setFormat(0, text.length(), Qt::black);
 
   // save the old ones to identify range changes
   Tokens oldTokens = d->tokens;
- // d->rangeChanged = false;
 
   // interpret the text as formula
   // we accept invalid/incomplete formulas
@@ -121,6 +117,8 @@
   
   d->rangeCount = 0;
   QValueList<QColor> colors = d->canvas->choice()->colors();
+  QValueList<Range> alreadyFoundRanges;
+  
   for (uint i = 0; i < d->tokens.count(); ++i)
   {
     Token token = d->tokens[i];
@@ -130,13 +128,22 @@
     {
       case Token::Cell:
       case Token::Range:
-        // don't compare, if we have already found a change
-        if (!d->rangeChanged && i < oldTokens.count() && token.text() != \
oldTokens[i].text())  {
-          d->rangeChanged = true;
+            // don't compare, if we have already found a change
+            if (!d->rangeChanged && i < oldTokens.count() && token.text() != \
oldTokens[i].text()) +            {
+                d->rangeChanged = true;
+            }
+        
+            Range newRange( token.text() );
+       
+            if (!alreadyFoundRanges.contains(newRange))
+            { 
+                alreadyFoundRanges.append(newRange);
+                d->rangeCount++;
+            }
+            setFormat(token.pos() + 1, token.text().length(), colors[ \
alreadyFoundRanges.findIndex(newRange) % colors.size()] );  }
-        setFormat(token.pos() + 1, token.text().length(), colors[d->rangeCount % \
                colors.size()]);
-        d->rangeCount++;
         break;
       case Token::Boolean:     // True, False (also i18n-ized)
 /*        font = QFont(editorFont);
@@ -759,9 +766,10 @@
           Region region(d->canvas->view(), token.text());
           it = region.constBegin();
           
-          //if (!alreadyUsedRegions.contains(region))
+          if (!alreadyUsedRegions.contains(region))
           {
-          
+            QRect r=(*it)->rect();
+            
             if (d->canvas->choice()->isEmpty())
                 d->canvas->choice()->initialize((*it)->rect(), (*it)->sheet());
             else
@@ -771,7 +779,10 @@
           }
         }
       }
-
+      
+      Selection* selec = d->canvas->choice();
+      selec;
+      
       setUpdateChoice(true);
       d->canvas->doc()->emitEndOperation(*d->canvas->choice());
     }
--- trunk/koffice/kspread/kspread_util.cc #504436:504437
@@ -232,7 +232,9 @@
 
 void Point::init(const QString & _str)
 {
-
+    _columnFixed=false;
+    _rowFixed=false;
+    
 //    kdDebug(36001) <<"Point::init ("<<_str<<")"<<endl;
     _pos.setX(-1);
 
@@ -375,6 +377,7 @@
 Point::Point( const QString & str, Map * map,
                             Sheet * sheet )
 {
+    
     uint p = 0;
     int p2 = str.find( '!' );
     if ( p2 != -1 )
@@ -431,6 +434,19 @@
       ((pos().y() == cell.pos().y()) && (pos().x() < cell.pos().x()));
 }
 
+bool Range::operator ==(const Range& otherRange) const
+{
+    if (    _range == otherRange._range
+        &&  _leftFixed == otherRange._leftFixed
+        &&  _rightFixed == otherRange._rightFixed
+        &&  _bottomFixed == otherRange._bottomFixed
+        &&  _topFixed == otherRange._topFixed
+        &&  _sheet == otherRange._sheet )
+            return true;
+    else
+            return false;
+}
+
 Range::Range()
 {
     _sheet = 0;
@@ -447,11 +463,23 @@
     _sheet = 0;
 
     int p = _str.find(':');
-    if (p == -1)
-  return;
+ //   if (p == -1)
+ // return;
 
-    Point ul(_str.left(p));
-    Point lr(_str.mid(p + 1));
+    Point ul;
+    Point lr; ;
+    
+    if ( p != -1)
+    {
+        ul = Point(_str.left(p));
+        lr = Point(_str.mid(p + 1));
+    }
+    else
+    {
+        ul = Point(_str);
+        lr = ul;
+    }
+        
     _range = QRect(ul.pos(), lr.pos());
     _sheetName = ul.sheetName();
 
@@ -467,6 +495,11 @@
     _sheetName = r.sheetName();
     _range = r.range();
     _namedArea = r.namedArea();
+    
+    _leftFixed=r._leftFixed;
+    _rightFixed=r._rightFixed;
+    _topFixed=r._topFixed;
+    _bottomFixed=r._bottomFixed;
   }
   
  Range::Range( const Point& ul, const Point& lr )
--- trunk/koffice/kspread/kspread_util.h #504436:504437
@@ -216,6 +216,11 @@
   */
   QString namedArea() const;
   
+  /**
+  * Returns true if the other range occupies the same area on the same sheet as this \
range. +  */
+  bool operator==(const Range& range) const;
+  
 
 private:
   Sheet* _sheet;
--- trunk/koffice/kspread/selection.cc #504436:504437
@@ -478,7 +478,8 @@
 
 void Selection::extend(const QRect& range, Sheet* sheet)
 {
-    if (!util_isRectValid(range))
+    //See comment in Selection::initialize(const QRect& range, Sheet* sheet)
+    if (!util_isRectValid(range) || (range == QRect(0,0,1,1)))
         return;
         
   if (!sheet)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic