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

List:       koffice
Subject:    patch for kspread
From:       montel laurent <montell () club-internet ! fr>
Date:       2000-08-30 19:08:06
[Download RAW message or body]

hi,

I added to my previous patch :
-setModified( true ); when I give area name

-fix a bug when you selected a entire column or entire row and you press
right mouse button ->PopupMenu
But if there is a editor, you close it and write value in marker cell, but 
when you select a entire column or entire row marker cell changed
=>so now I tested if editor exist and close it.

that's all

could you test it please.

thanks 
bye
["patch37.diff" (text/plain)]

? patch29.diff
? patch26.diff
? kword.kwd
? fonts.dir
? toto.csv
? toto2.ksp
? KSpreadLocation.diff
? ???
? KSpreadCellIface_stub.h
? KSpreadCellIface_stub.cpp
? toto.ksp
? filters/Makefile.in
? filters/Makefile
? filters/csv/Makefile
? filters/csv/Makefile.in
? filters/csv/csvfilter
? filters/komma/Makefile.in
? filters/komma/Makefile
? pics/@kde_minidir@
cvs server: Diffing .
Index: kspread_canvas.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_canvas.cc,v
retrieving revision 1.145
diff -p -u -r1.145 kspread_canvas.cc
--- kspread_canvas.cc	2000/08/27 16:06:02	1.145
+++ kspread_canvas.cc	2000/08/30 19:05:18
@@ -389,7 +389,7 @@ void KSpreadCanvas::gotoLocation( const 
   gotoLocation( _cell.pos.x(), _cell.pos.y(), table );
 }
 
-void KSpreadCanvas::gotoLocation( int x, int y, KSpreadTable* table, bool \
make_select,bool move_into_area ) +void KSpreadCanvas::gotoLocation( int x, int y, \
KSpreadTable* table, bool make_select,bool move_into_area, bool keyPress )  {
   //kdDebug(36001) << "KSpreadCanvas::gotoLocation" << " x=" << x << " y=" << y <<
   //  " table=" << table << " make_select=" << (make_select ? "true" : "false" ) << \
endl; @@ -397,7 +397,8 @@ void KSpreadCanvas::gotoLocation( int x,
     table->setActiveTable();
   else
     table = activeTable();
-
+  QRect extraArea;
+  QRect tmpArea;
   KSpreadCell* cell = table->cellAt( x, y );
   if ( cell->isObscured() && cell->isObscuringForced() )
   {
@@ -407,16 +408,69 @@ void KSpreadCanvas::gotoLocation( int x,
     QRect extraCell;
     extraCell.setCoords(moveX,moveY,moveX+cell->extraXCells(),moveY+cell->extraYCells());
                
     if( (x-markerColumn())!=0 && \
                extraCell.contains(QPoint(markerColumn(),markerRow())))
-        x=cell->extraXCells()+x;
+        {
+        extraArea.setCoords(markerColumn(),1,cell->extraXCells()+x-1,0x7FFF);
+        if(keyPress)
+                {
+                tmpArea.setCoords(1,markerRow(),0x7FFF,cell->extraYCells()+markerRow());
 +                if(!extraArea.contains(table->getOldPos().x(),1)&& \
tmpArea.contains(1,table->getOldPos().y())) +                        \
y=table->getOldPos().y(); +                else if( \
extraArea.contains(table->getOldPos().x(),1)&& \
table->getOldPos().y()==(cell->extraYCells()+y+1)) +                        \
y=table->getOldPos().y()-1; +                x=cell->extraXCells()+x;
+                }
+        }
     else if((y-markerRow())!=0 && \
extraCell.contains(QPoint(markerColumn(),markerRow()))) +        {
+        extraArea.setCoords(1,markerRow(),0x7FFF,cell->extraYCells()+y-1);
+
+        tmpArea.setCoords(markerColumn(),1,cell->extraXCells()+markerColumn(),0x7FFF);
 +        if(keyPress)
+                {
+                if( \
!extraArea.contains(1,table->getOldPos().y())&&tmpArea.contains(table->getOldPos().x(),1))
 +                        x=table->getOldPos().x();
+                else if(/* extraArea.contains(1,table->getOldPos().y())&&*/ \
table->getOldPos().x()==(cell->extraXCells()+markerColumn()+1)) +                     \
x=table->getOldPos().x()-1; +                }
         y=cell->extraYCells()+y;
-    else
+        }
+     else
         {
         y = moveY;
         x = moveX;
         }
   }
-
+  else
+  {
+  cell = table->cellAt( table->marker().x(), table->marker().y() );
+  if ( cell->isForceExtraCells() )
+        {
+        if(keyPress && (x-markerColumn())!=0)
+                {
+                extraArea.setCoords(markerColumn(),1,cell->extraXCells()+markerColumn(),0x7FFF);
 +                tmpArea.setCoords(1,markerRow(),0x7FFF,cell->extraYCells()+markerRow());
 +                if( !extraArea.contains(QPoint(table->getOldPos().x(),1))&& \
tmpArea.contains(1,table->getOldPos().y())) +                        \
y=table->getOldPos().y(); +                else if( \
extraArea.contains(table->getOldPos().x(),1)&& \
table->getOldPos().y()==(cell->extraYCells()+markerRow()+1)) +                        \
y=table->getOldPos().y()-1; +                }
+        else if(keyPress && (y-markerRow())!=0 )
+                {
+                tmpArea.setCoords(markerColumn(),1,cell->extraXCells()+markerColumn(),0x7FFF);
 +                extraArea.setCoords(1,markerRow(),0x7FFF,cell->extraYCells()+markerRow());
 +                if( \
!extraArea.contains(QPoint(1,table->getOldPos().y()))&&tmpArea.contains(table->getOldPos().x(),1))
 +                        x=table->getOldPos().x();
+                else if( /*extraArea.contains(QPoint(1,table->getOldPos().y()))&&*/ \
table->getOldPos().x()==(cell->extraXCells()+markerColumn()+1)) +                     \
x=table->getOldPos().x()-1; +                }
+        }
+  }
+  cell= table->cellAt( x, y );
+  if( cell->isObscured() && cell->isObscuringForced() )
+  {
+   x=cell->obscuringCellsColumn();
+   y=cell->obscuringCellsRow();
+  }
   int xpos = table->columnPos( x, this );
   int ypos = table->rowPos( y, this );
 
@@ -442,20 +496,14 @@ void KSpreadCanvas::gotoLocation( int x,
 
   if ( !make_select )
   {
-       //if ( selection.left() != 0 && !move_into_area)
-      // activeTable()->unselect();
-      /*
 
-      */
       if ( selection.left() != 0 && !move_into_area)
         activeTable()->setMarker( QPoint( x, y ) );
       else if(selection.left() != 0 && move_into_area)
         activeTable()->setSelection(selection,QPoint( x, y ),this);
       else
         activeTable()->setMarker( QPoint( x, y ) );
-      /*
-      */
-    //activeTable()->setMarker( QPoint( x, y ) );
+
   }
   else
   {
@@ -685,15 +733,17 @@ void KSpreadCanvas::mouseMoveEvent( QMou
     if ( row <= m_iMouseStartRow )
     {
         selection.setTop( row );
-        selection.setBottom( m_iMouseStartRow);
+        selection.setBottom( m_iMouseStartRow );
     }
     else
         selection.setBottom( row );
 
+    selection=table->selectionCellMerged(selection);
+
     // If nothing changed, then quit
     if ( selection == table->selectionRect() )
         return;
-    
+
     // Set the new selection
     table->setSelection( selection, QPoint( col, row ), this );
     // Scroll the table if necessary
@@ -1286,17 +1336,17 @@ void KSpreadCanvas::keyPressEvent ( QKey
       {
         QRect selection = activeTable()->selectionRect();
         if( selection.left() == 0 )
-            gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 1 ), 0, \
make_select ); +            gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + \
1 ), 0, make_select,false,true  );  else
         {
             if(markerColumn()<selection.right()&&markerRow()<selection.bottom() )
-                gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 1 ), 0, \
make_select,true ); +                gotoLocation( markerColumn(), QMIN( 0x7FFF, \
                markerRow() + 1 ), 0, make_select,true ,true);
             else if( markerRow()==selection.bottom() && \
                markerColumn()<selection.right())
-                gotoLocation( markerColumn()+1, QMIN( 0x7FFF, selection.top() ), 0, \
make_select,true ); +                gotoLocation( markerColumn()+1, QMIN( 0x7FFF, \
                selection.top() ), 0, make_select,true, true );
             else if( markerRow()==selection.bottom() && \
                markerColumn()==selection.right())
-                gotoLocation( selection.left(), QMIN( 0x7FFF, selection.top() ), 0, \
make_select,true ); +                gotoLocation( selection.left(), QMIN( 0x7FFF, \
                selection.top() ), 0, make_select,true,true );
             else if(markerColumn()==selection.right() && \
                markerRow()<selection.bottom())
-                gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 1 ), 0, \
make_select,true ); +                gotoLocation( markerColumn(), QMIN( 0x7FFF, \
markerRow() + 1 ), 0, make_select,true,true );  }
       }
       return;
@@ -1308,9 +1358,9 @@ void KSpreadCanvas::keyPressEvent ( QKey
         return;
 
       if ( m_bChoose )
-        chooseGotoLocation( chooseMarkerColumn(), QMIN( 0x7FFF, chooseMarkerRow() + \
1 ), 0, make_select ); +        chooseGotoLocation( chooseMarkerColumn(), QMIN( \
0x7FFF, chooseMarkerRow() + 1 ), 0, make_select);  else
-        gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 1 ), 0, \
make_select ); +        gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 1 \
), 0, make_select,false,true  );  
       return;
 
@@ -1324,7 +1374,7 @@ void KSpreadCanvas::keyPressEvent ( QKey
       if ( m_bChoose )
         chooseGotoLocation( chooseMarkerColumn(), QMAX( 1, chooseMarkerRow() - 1 ), \
0, make_select );  else
-        gotoLocation( markerColumn(), QMAX( 1, markerRow() - 1 ), 0, make_select );
+        gotoLocation( markerColumn(), QMAX( 1, markerRow() - 1 ), 0, \
make_select,false,true );  
       return;
 
@@ -1338,7 +1388,7 @@ void KSpreadCanvas::keyPressEvent ( QKey
       if ( m_bChoose )
         chooseGotoLocation( QMIN( 26*26/*0x7FFF*/, chooseMarkerColumn() + 1 ), \
chooseMarkerRow(), 0, make_select );  else
-        gotoLocation( QMIN( /*26*26*/0x7FFF, markerColumn() + 1 ), markerRow(), 0, \
make_select ); +        gotoLocation( QMIN( /*26*26*/0x7FFF, markerColumn() + 1 ), \
markerRow(), 0, make_select,false,true );  
       return;
 
@@ -1352,7 +1402,7 @@ void KSpreadCanvas::keyPressEvent ( QKey
       if ( m_bChoose )
         chooseGotoLocation( QMAX( 1, chooseMarkerColumn() - 1 ), chooseMarkerRow(), \
0, make_select );  else
-        gotoLocation( QMAX( 1, markerColumn() - 1 ), markerRow(), 0, make_select );
+        gotoLocation( QMAX( 1, markerColumn() - 1 ), markerRow(), 0, \
make_select,false,true );  
       return;
 
@@ -1384,7 +1434,7 @@ void KSpreadCanvas::keyPressEvent ( QKey
         if ( m_bChoose )
           chooseGotoLocation( 1, markerRow(), 0, make_select );
         else
-          gotoLocation( 1, markerRow(), 0, make_select );
+          gotoLocation( 1, markerRow(), 0, make_select,false,true );
       }
       return;
 
@@ -1398,7 +1448,7 @@ void KSpreadCanvas::keyPressEvent ( QKey
       if ( m_bChoose )
         chooseGotoLocation( chooseMarkerColumn(), QMAX( 1, chooseMarkerRow() - 10 ), \
0, make_select );  else
-        gotoLocation( markerColumn(), QMAX( 1, markerRow() - 10 ), 0, make_select );
+        gotoLocation( markerColumn(), QMAX( 1, markerRow() - 10 ), 0, \
make_select,false,true );  
       return;
 
@@ -1412,7 +1462,7 @@ void KSpreadCanvas::keyPressEvent ( QKey
       if ( m_bChoose )
         chooseGotoLocation( chooseMarkerColumn(), QMIN( 0x7FFF, chooseMarkerRow() + \
10 ), 0, make_select );  else
-        gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 10 ), 0, \
make_select ); +        gotoLocation( markerColumn(), QMIN( 0x7FFF, markerRow() + 10 \
), 0, make_select,false,true );  
       return;
 
@@ -1826,7 +1876,26 @@ void KSpreadCanvas::updateSelection( con
                  ||new_marker.contains(QPoint(x,y))||old_marker.contains(QPoint(x,y)))
  
             {
-                cell->paintCell( view, painter, xpos, ypos, x, y, col_lay, row_lay, \
&r ); +                if(cell->isForceExtraCells())
+                        cell->paintCell( view, painter, xpos, ypos, x, y, col_lay, \
row_lay, &r ); +                else if ( cell->isObscured() && \
cell->isObscuringForced() ) +                {
+                        int moveX=cell->obscuringCellsColumn();
+                        int moveY=cell->obscuringCellsRow();
+                        KSpreadCell *cell2 = table->cellAt( moveX, moveY );
+                        if(cell2->extraXCells()>1 && cell2->extraYCells()>1)
+                        {
+                        QRect area;
+                        \
area.setCoords(moveX+1,moveY+1,moveX+cell2->extraXCells()-1,moveY+cell2->extraYCells()-1);
 +                        if(!area.contains(x,y))
+                                cell->paintCell( view, painter, xpos, ypos, x, y, \
col_lay, row_lay, &r ); +                        }
+                        else
+                                cell->paintCell( view, painter, xpos, ypos, x, y, \
col_lay, row_lay, &r ); +
+                }
+                else
+                        cell->paintCell( view, painter, xpos, ypos, x, y, col_lay, \
row_lay, &r );  }
 
             xpos += col_lay->width();
@@ -2150,7 +2219,11 @@ void KSpreadVBorder::mousePressEvent( QM
 
   KSpreadTable *table = m_pCanvas->activeTable();
   assert( table );
-
+  // We were editing a cell -> save value and get out of editing mode
+  if ( m_pCanvas->editor() )
+        {
+                m_pCanvas->deleteEditor( true ); // save changes
+        }
   // Find the first visible row and the y position of this row.
   int y = 0;
   int row = table->topRow( 0, y, m_pCanvas );
@@ -2574,7 +2647,11 @@ void KSpreadHBorder::mousePressEvent( QM
   assert( table );
   if(!m_pView->koDocument()->isReadWrite())
     return;
-
+  // We were editing a cell -> save value and get out of editing mode
+  if ( m_pCanvas->editor() )
+        {
+                m_pCanvas->deleteEditor( true ); // save changes
+        }
   m_bResize = FALSE;
   m_bSelection = FALSE;
 
Index: kspread_canvas.h
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_canvas.h,v
retrieving revision 1.53
diff -p -u -r1.53 kspread_canvas.h
--- kspread_canvas.h	2000/08/18 21:39:10	1.53
+++ kspread_canvas.h	2000/08/30 19:05:20
@@ -208,7 +208,7 @@ public:
      *                    moves the cursor keys. In this case the selection is
      *                    updated accordingly.
      */
-    void gotoLocation( int x, int y, KSpreadTable* table = 0, bool make_select = \
FALSE,bool move_into_area=false); +    void gotoLocation( int x, int y, KSpreadTable* \
table = 0, bool make_select = FALSE,bool move_into_area=false,bool keypress=false);  
     /**
      * Chooses the correct @ref #EditorType by looking at
Index: kspread_doc.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_doc.cc,v
retrieving revision 1.95
diff -p -u -r1.95 kspread_doc.cc
--- kspread_doc.cc	2000/08/24 20:10:04	1.95
+++ kspread_doc.cc	2000/08/30 19:05:23
@@ -845,6 +845,7 @@ DCOPObject* KSpreadDoc::dcopObject()
 
 void KSpreadDoc::addAreaName(QRect &_rect,QString name,QString tableName)
 {
+  setModified( true );
   Reference tmp;
   tmp.rect = _rect;
   tmp.table_name = tableName;
Index: kspread_table.cc
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_table.cc,v
retrieving revision 1.201
diff -p -u -r1.201 kspread_table.cc
--- kspread_table.cc	2000/08/29 04:33:43	1.201
+++ kspread_table.cc	2000/08/30 19:05:45
@@ -224,6 +224,7 @@ KSpreadTable::KSpreadTable( KSpreadMap *
       s.sprintf("Table%i", s_id );
       QObject::setName( s.data() );
   }
+  m_oldPos=QPoint(1,1);
 }
 
 bool KSpreadTable::isEmpty( unsigned long int x, unsigned long int y )
@@ -594,7 +595,7 @@ QRect KSpreadTable::marker() const
 }
 
 void KSpreadTable::setSelection( const QRect &_sel, KSpreadCanvas *_canvas )
-{
+{   m_oldPos=QPoint( m_marker.topLeft());
     if ( _sel.left() == 0 )
         setSelection( _sel, m_marker.topLeft(), _canvas );
     else
@@ -636,17 +637,24 @@ void KSpreadTable::setSelection( const Q
         {
         KSpreadCell* cell2 = cellAt( cell->obscuringCellsColumn(),
         cell->obscuringCellsRow() );
-        if( m.x()==cell->obscuringCellsColumn()+ cell2->extraXCells() &&
-                m.y()==cell->obscuringCellsRow()+ cell2->extraYCells())
+        QRect extraArea;
+        extraArea.setCoords( cell->obscuringCellsColumn(),cell->obscuringCellsRow(),
+        cell->obscuringCellsColumn()+ \
cell2->extraXCells(),cell->obscuringCellsRow()+ cell2->extraYCells()); +        \
if(extraArea.contains(m.x(),m.y()))  {
-                m_marker.setCoords( cell->obscuringCellsColumn(),
-                        cell->obscuringCellsRow(), m.x(), m.y()  );
+                m_marker=extraArea;
                 }
         else
+                {
+                m_oldPos=QPoint( m.x(),m.y());
                 m_marker = QRect( m, m );
+                }
         }
   else
+        {
+        m_oldPos=QPoint( m.x(),m.y());
       m_marker = QRect( m, m );
+      }
 
   emit sig_changeSelection( this, old, old_marker );
 }
@@ -2064,7 +2072,46 @@ KSpreadCell* c = m_cells.firstCell();
 
 }
 
+QRect KSpreadTable::selectionCellMerged(const QRect &_sel)
+{
+QRect selection(_sel);
+if(selection.bottom()==0x7FFF ||selection.right()==0x7FFF)
+        return selection;
+else
+  {
+  int top=selection.top();
+  int left=selection.left();
+  int bottom=selection.bottom();
+  int right=selection.right();
+  for ( int x = selection.left(); x <= selection.right(); x++ )
+        for ( int y = selection.top(); y <= selection.bottom(); y++ )
+        {
+                KSpreadCell *cell = cellAt( x, y );
+                if( cell->isForceExtraCells())
+                {
+                        right=QMAX(right,cell->extraXCells()+x);
+                        bottom=QMAX(bottom,cell->extraYCells()+y);
+                }
+                else if ( cell->isObscured() && cell->isObscuringForced() )
+                {
+                        int moveX=cell->obscuringCellsColumn();
+                        int moveY=cell->obscuringCellsRow();
+                        cell = cellAt( moveX, moveY );
+                        left=QMIN(left,moveX);
+                        top=QMIN(top,moveY);
+                        bottom=QMAX(bottom,moveY+cell->extraYCells());
+                        right=QMAX(right,moveX+cell->extraXCells());
+                }
+        }
+
+  selection.setCoords(left,top,right,bottom);
+  }
+  return selection;
 
+
+
+}
+
 void KSpreadTable::changeNameCellRef(const QPoint & pos, bool fullRowOrColumn, \
ChangeRef ref, QString tabname)  {
   bool correctDefaultTableName = (tabname == name()); // for cells without table ref \
(eg "A1") @@ -4204,6 +4251,7 @@ void KSpreadTable::mergeCell( const QPoi
 {
     if(m_rctSelection.left() == 0)
         return;
+    m_pDoc->setModified( true );
     int x=_marker.x();
     int y=_marker.y();
     if( _marker.x() > m_rctSelection.left() )
Index: kspread_table.h
===================================================================
RCS file: /home/kde/koffice/kspread/kspread_table.h,v
retrieving revision 1.117
diff -p -u -r1.117 kspread_table.h
--- kspread_table.h	2000/08/26 06:27:46	1.117
+++ kspread_table.h	2000/08/30 19:05:49
@@ -516,7 +516,9 @@ public:
     void removeTable();
 
     void setActiveTable();
+    QPoint getOldPos() {return m_oldPos;}
 
+    QRect selectionCellMerged(const QRect &_sel);
     /**
      * Change name of reference when the user inserts or removes a column,
      * a row or a cell (= insertion of a row [or column] on a single column [or \
row]). @@ -889,6 +891,8 @@ protected:
     QPen m_emptyPen;
     QBrush m_emptyBrush;
     QColor m_emptyColor;
+
+     QPoint m_oldPos;
 };
 
 #endif
cvs server: Diffing dtd
cvs server: Diffing extensions
cvs server: Diffing filters
cvs server: Diffing filters/csv
cvs server: Diffing filters/komma
cvs server: Diffing pics
cvs server: Diffing plugins
cvs server: Diffing plugins/calculator
cvs server: Diffing plugins/calculator/pics
cvs server: Diffing scripts
cvs server: Diffing tablestyles
cvs server: Diffing toolbar
cvs server: Diffing toolbar/hicolor
cvs server: Diffing toolbar/locolor



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

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