bool TableRowElement::moveCursor(FormulaCursor& newcursor, FormulaCursor& oldcursor) { //TODO: Moving the cursor vertically in the tableelement is a little bit fragile if ( (newcursor.isHome() && newcursor.direction()==MoveLeft) || (newcursor.isEnd() && newcursor.direction()==MoveRight) ) { return false; } int rowpos=parentElement()->positionOfChild(this); int colpos=(newcursor.position()!=endPosition() ? newcursor.position() : newcursor.position()-1); if (newcursor.isSelecting()) { switch(newcursor.direction()) { case MoveLeft: newcursor.moveTo(this,newcursor.position()-1); break; case MoveRight: newcursor.moveTo(this,newcursor.position()+1); break; case MoveUp: case MoveDown: return false; default: break; } } else { switch(newcursor.direction()) { case MoveLeft: newcursor.setCurrentElement(m_data[newcursor.position()-1]); newcursor.moveEnd(); break; case MoveRight: newcursor.setCurrentElement(m_data[newcursor.position()]); newcursor.moveHome(); break; case MoveUp: if ( rowpos>1 ) { BasicElement* b=parentElement()->childElements()[rowpos/2-1]->childElements()[colpos]; return newcursor.moveCloseTo(b, oldcursor); } else { return false; } case MoveDown: if ( rowpos<endPosition()-1 ) { BasicElement* b=parentElement()->childElements()[rowpos/2+1]->childElements()[colpos]; return newcursor.moveCloseTo(b, oldcursor); } else { return false; } default: break; } } return true; }