Version: (using KDE KDE 3.3.0) Installed from: Compiled From Sources follow up to http://bugs.kde.org/show_bug.cgi?id=46831... Yes, you can set the direction of the sheets... however the RTL sheets are really messed up. Actually, also the LTR sheets in RTL desktops are messed up (use kspread --reverse to test).
Created attachment 7653 [details] desktop is RTL, sheet is LTR as you see there is a small offset in the location of the cells.
Created attachment 7656 [details] desktop is RTL, sheet is RTL you will see something similar in LTR desktops, but it's definetly broken, and I cannot even explain whats wrong. What I tried to do here, is select some cells, as you see, it did not end up as I expected.
CVS commit by livne: Fix the view on RTL desktops (this has nothing to do with RTL sheets). The thing is that Q*Layout::setDirection() leads to the opposite effect on RTL desktops, so this has to be taken into account in specific cases like this where we want a certain specific directionality regardless of the desktop's directionality. The broken-ness of RTL sheets in kspread is another story... CCMAIL: 90127@bugs.kde.org M +8 -5 kspread_view.cc 1.792 --- koffice/kspread/kspread_view.cc #1.791:1.792 @@ -4899,18 +4899,21 @@ void KSpreadView::refreshView() d->vBorderWidget->setMinimumWidth( d->doc->zoomItX( YBORDER_WIDTH ) ); - if( table->layoutDirection() == KSpreadSheet::LeftToRight ) + KSpreadSheet::LayoutDirection sheetDir = table->layoutDirection(); + bool interfaceIsRTL = QApplication::reverseLayout(); + + if ((sheetDir == KSpreadSheet::LeftToRight && !interfaceIsRTL) || + (sheetDir == KSpreadSheet::RightToLeft && interfaceIsRTL)) { d->formulaBarLayout->setDirection( QBoxLayout::LeftToRight ); d->viewLayout->setOrigin( QGridLayout::TopLeft ); d->tabScrollBarLayout->setDirection( QBoxLayout::LeftToRight ); - d->tabBar->setReverseLayout( false ); + d->tabBar->setReverseLayout( interfaceIsRTL ); } - - if( table->layoutDirection() == KSpreadSheet::RightToLeft ) + else { d->formulaBarLayout->setDirection( QBoxLayout::RightToLeft ); d->viewLayout->setOrigin( QGridLayout::TopRight ); d->tabScrollBarLayout->setDirection( QBoxLayout::RightToLeft ); - d->tabBar->setReverseLayout( true ); + d->tabBar->setReverseLayout( !interfaceIsRTL ); }
CVS commit by livne: Attempt to fix the displaying of RTL sheets. It looks better now... They do seem to be aligned correctly with the HBorder. However, the major problem with RTL sheets is that repainting and scrolling them is badly broken, not only with the Canvas itself but also with its HBorder. CCMAIL: 90127@bugs.kde.org M +5 -2 kspread_cell.cc 1.629 --- koffice/kspread/kspread_cell.cc #1.628:1.629 @@ -7,5 +7,5 @@ Copyright 2002-2003 Norbert Andres <nandres@web.de> Copyright 2003 Reinhart Geiser <geiseri@kde.org> - Copyright 2003 Meni Livne <livne@kde.org> + Copyright 2003-2004 Meni Livne <livne@kde.org> Copyright 2003 Peter Simonsson <psn@linux.se> Copyright 1999-2002 David Faure <faure@kde.org> @@ -2328,5 +2328,8 @@ void KSpreadCell::paintCell( const KoRec if ( m_pTable->layoutDirection()==KSpreadSheet::RightToLeft && view && view->canvasWidget() ) - left = view->canvasWidget()->width() - coordinate.x() - width; + { + double dwidth = view->doc()->unzoomItX(view->canvasWidget()->width()); + left = dwidth - coordinate.x() - width; + } const KoRect cellRect( left, coordinate.y(), width, height );
CVS commit by livne: Fix selections with RTL sheets. The problem was that negative width values have caused the selection marker to appear at the wrong place or to not appear at all. That should (hopefully) be fixed now. CCMAIL: 90127@bugs.kde.org M +3 -3 kspread_canvas.cc 1.420 --- koffice/kspread/kspread_canvas.cc #1.419:1.420 @@ -3884,5 +3884,5 @@ void KSpreadCanvas::retrieveMarkerInfo( const ColumnFormat *columnFormat = table->columnFormat( marker.right() ); double tw = columnFormat->dblWidth( ); - double w = ( x - xpos ) + tw; + double w = QABS( x - xpos ) + tw; double y = table->dblRowPos( marker.bottom() ) - yOffset(); @@ -3917,7 +3917,7 @@ void KSpreadCanvas::retrieveMarkerInfo( (bottom >= viewRect.top()) && (top <= viewRect.bottom()); paintSides[1] = (viewRect.top() <= top) && (top <= viewRect.bottom()) - && (right >= viewRect.left()) && (left - 1 <= viewRect.right()); + && (QABS(right) >= viewRect.left()) && (left - 1 <= viewRect.right()); paintSides[3] = (viewRect.top() <= bottom) && (bottom <= viewRect.bottom()) - && (right >= viewRect.left()) && (left - 1 <= viewRect.right()); + && (QABS(right) >= viewRect.left()) && (left - 1 <= viewRect.right()); } else
CVS commit by livne: Fix keyboard navigation in RTL sheets. CCMAIL: 90127@bugs.kde.org M +106 -3 kspread_canvas.cc 1.421 --- koffice/kspread/kspread_canvas.cc #1.420:1.421 @@ -1892,7 +1892,15 @@ void KSpreadCanvas::processArrowKey( QKe break; case Key_Left: + if (activeTable()->layoutDirection()==KSpreadSheet::RightToLeft) + direction = KSpread::Right; + else direction = KSpread::Left; break; case Key_Right: + if (activeTable()->layoutDirection()==KSpreadSheet::RightToLeft) + direction = KSpread::Left; + else + direction = KSpread::Right; + break; case Key_Tab: direction = KSpread::Right; @@ -2304,4 +2312,50 @@ bool KSpreadCanvas::processControlArrowK case Key_Left: + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + { + cell = table->cellAt( marker.x(), marker.y() ); + if ( (cell != NULL) && (!cell->isEmpty()) && (marker.x() != KS_colMax)) + { + lastCell = cell; + col = marker.x()+1; + cell = table->cellAt(col, cell->row()); + while ((cell != NULL) && (col < KS_colMax) && (!cell->isEmpty()) ) + { + if (!(table->columnFormat(cell->column())->isHide())) + { + lastCell = cell; + searchThroughEmpty = FALSE; + } + col++; + cell = table->cellAt(col, cell->row()); + } + cell = lastCell; + } + if (searchThroughEmpty) + { + cell = table->getNextCellRight(marker.x(), marker.y()); + + while ((cell != NULL) && + (cell->isEmpty() || (table->columnFormat(cell->column())->isHide()))) + { + cell = table->getNextCellRight(cell->column(), cell->row()); + } + } + + if (cell == NULL) + col = marker.x(); + else + col = cell->column(); + + while ( table->columnFormat(col)->isHide() ) + { + col--; + } + + destination.setX(col); + destination.setY(marker.y()); + } + else + { cell = table->cellAt( marker.x(), marker.y() ); if ( (cell != NULL) && (!cell->isEmpty()) && (marker.x() != 1)) @@ -2346,4 +2400,5 @@ bool KSpreadCanvas::processControlArrowK destination.setX(col); destination.setY(marker.y()); + } break; @@ -2351,4 +2406,51 @@ bool KSpreadCanvas::processControlArrowK case Key_Right: + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + { + cell = table->cellAt( marker.x(), marker.y() ); + if ( (cell != NULL) && (!cell->isEmpty()) && (marker.x() != 1)) + { + lastCell = cell; + col = marker.x()-1; + cell = table->cellAt(col, cell->row()); + while ((cell != NULL) && (col > 0) && (!cell->isEmpty()) ) + { + if (!(table->columnFormat(cell->column())->isHide())) + { + lastCell = cell; + searchThroughEmpty = FALSE; + } + col--; + if ( col > 0 ) + cell = table->cellAt(col, cell->row()); + } + cell = lastCell; + } + if (searchThroughEmpty) + { + cell = table->getNextCellLeft(marker.x(), marker.y()); + + while ((cell != NULL) && + (cell->isEmpty() || (table->columnFormat(cell->column())->isHide()))) + { + cell = table->getNextCellLeft(cell->column(), cell->row()); + } + } + + if (cell == NULL) + col = 1; + else + col = cell->column(); + + while ( table->columnFormat(col)->isHide() ) + { + col++; + } + + destination.setX(col); + destination.setY(marker.y()); + } + else + { cell = table->cellAt( marker.x(), marker.y() ); if ( (cell != NULL) && (!cell->isEmpty()) && (marker.x() != KS_colMax)) @@ -2392,4 +2494,5 @@ bool KSpreadCanvas::processControlArrowK destination.setX(col); destination.setY(marker.y()); + } break;
CVS commit by livne: Have the editor of each cell appear at the right place in RTL sheets. CCMAIL: 90127@bugs.kde.org M +10 -1 kspread_canvas.cc 1.422 --- koffice/kspread/kspread_canvas.cc #1.421:1.422 @@ -3187,5 +3187,14 @@ bool KSpreadCanvas::createEditor( Editor //kdDebug(36001) << "HEIGHT=" << min_h << " EXTRA=" << h << endl; } - double xpos = table->dblColumnPos( markerColumn() ) - xOffset(); + + double xpos; + if ( table->layoutDirection() == KSpreadSheet::RightToLeft ) + { + double dwidth = doc()->unzoomItX( width() ); + xpos = dwidth - min_w - table->dblColumnPos( markerColumn() ) - xOffset(); + } + else + xpos = table->dblColumnPos( markerColumn() ) - xOffset(); + double ypos = table->dblRowPos( markerRow() ) - yOffset(); QPalette p = m_pEditor->palette();
CVS commit by livne: A simpler, better way for handling selections in RTL sheets. Fixes some problems with selections there. CCMAIL: 90127@bugs.kde.org M +23 -29 kspread_canvas.cc 1.423 --- koffice/kspread/kspread_canvas.cc #1.422:1.423 @@ -3984,6 +3984,6 @@ void KSpreadCanvas::retrieveMarkerInfo( if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) { - xpos = dWidth - table->dblColumnPos( marker.left() ) - xOffset(); - x = dWidth - table->dblColumnPos( marker.right() ) - xOffset(); + xpos = dWidth - table->dblColumnPos( marker.right() ) + xOffset(); + x = dWidth - table->dblColumnPos( marker.left() ) + xOffset(); } else @@ -3996,5 +3996,5 @@ void KSpreadCanvas::retrieveMarkerInfo( const ColumnFormat *columnFormat = table->columnFormat( marker.right() ); double tw = columnFormat->dblWidth( ); - double w = QABS( x - xpos ) + tw; + double w = x - xpos + tw; double y = table->dblRowPos( marker.bottom() ) - yOffset(); @@ -4004,10 +4004,15 @@ void KSpreadCanvas::retrieveMarkerInfo( /* left, top, right, bottom */ - positions[0] = xpos; - positions[1] = ypos; if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) - positions[2] = xpos - w + 1; + { + positions[0] = xpos - tw; + positions[2] = xpos - tw + w; + } else + { + positions[0] = xpos; positions[2] = xpos + w; + } + positions[1] = ypos; positions[3] = ypos + h; @@ -4018,30 +4023,19 @@ void KSpreadCanvas::retrieveMarkerInfo( double bottom = positions[3]; - if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) - kdDebug() << "X: " << x << ", xpos: " << xpos << ", w: " << w - << ", Right: " << right << ", VRight: " << viewRect.right() - << ", Left: " << left << ", VLeft: " << viewRect.left() << endl; - /* left, top, right, bottom */ - if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) - { - paintSides[0] = (viewRect.left() <= left) && (left - 1 <= viewRect.right()) && - (bottom >= viewRect.top()) && (top <= viewRect.bottom()); - paintSides[1] = (viewRect.top() <= top) && (top <= viewRect.bottom()) - && (QABS(right) >= viewRect.left()) && (left - 1 <= viewRect.right()); - paintSides[3] = (viewRect.top() <= bottom) && (bottom <= viewRect.bottom()) - && (QABS(right) >= viewRect.left()) && (left - 1 <= viewRect.right()); - } - else - { paintSides[0] = (viewRect.left() <= left) && (left <= viewRect.right()) && (bottom >= viewRect.top()) && (top <= viewRect.bottom()); paintSides[1] = (viewRect.top() <= top) && (top <= viewRect.bottom()) && (right >= viewRect.left()) && (left <= viewRect.right()); + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + paintSides[2] = (viewRect.left() <= right ) && + (right - 1 <= viewRect.right()) && + (bottom >= viewRect.top()) && (top <= viewRect.bottom()); + else + paintSides[2] = (viewRect.left() <= right ) && + (right <= viewRect.right()) && + (bottom >= viewRect.top()) && (top <= viewRect.bottom()); paintSides[3] = (viewRect.top() <= bottom) && (bottom <= viewRect.bottom()) && (right >= viewRect.left()) && (left <= viewRect.right()); - } - paintSides[2] = (viewRect.left() <= right ) && (right <= viewRect.right()) && - (bottom >= viewRect.top()) && (top <= viewRect.bottom()); positions[0] = QMAX( left, viewRect.left() );
CVS commit by livne: Fix painting of the selection marker in RTL sheets. CCMAIL: 90127@bugs.kde.org M +52 -18 kspread_canvas.cc 1.424 --- koffice/kspread/kspread_canvas.cc #1.423:1.424 @@ -3938,4 +3938,37 @@ void KSpreadCanvas::paintNormalMarker(QP doc()->zoomItX( right ) + 2 * l, doc()->zoomItY( top ) ); } + if ( activeTable()->layoutDirection()==KSpreadSheet::RightToLeft ) + { + if ( paintRight ) + { + painter.drawLine( doc()->zoomItX( right ), doc()->zoomItY( top ), + doc()->zoomItX( right ), doc()->zoomItY( bottom ) ); + } + if ( paintLeft && paintBottom ) + { + /* then the 'handle' in the bottom left corner is visible. */ + painter.drawLine( doc()->zoomItX( left ), doc()->zoomItY( top ), + doc()->zoomItX( left ), doc()->zoomItY( bottom ) - 3 ); + painter.drawLine( doc()->zoomItX( left ) + 4, doc()->zoomItY( bottom ), + doc()->zoomItX( right ) + l + 1, doc()->zoomItY( bottom ) ); + painter.fillRect( doc()->zoomItX( left ) - 2, doc()->zoomItY( bottom ) -2, 5, 5, + painter.pen().color() ); + } + else + { + if ( paintLeft ) + { + painter.drawLine( doc()->zoomItX( left ), doc()->zoomItY( top ), + doc()->zoomItX( left ), doc()->zoomItY( bottom ) ); + } + if ( paintBottom ) + { + painter.drawLine( doc()->zoomItX( left ) - l, doc()->zoomItY( bottom ), + doc()->zoomItX( right ) + l + 1, doc()->zoomItY( bottom )); + } + } + } + else + { if ( paintLeft ) { @@ -3966,4 +3999,5 @@ void KSpreadCanvas::paintNormalMarker(QP } } + } }
CVS commit by livne: Fix scrolling in RTL sheets. CCMAIL: 90127@bugs.kde.org M +43 -23 kspread_canvas.cc 1.426
O.K... Just to give an update on the status of right-to-left spreadsheets in KSpread: Now that scrolling, repainting and selections are fixed, RTL sheets are already partially usable. What remains now is lots and lots of smaller issues that I hope to take care of, depending on the time I have. These are issues that I know of. If you find others, add your comment here. Once they're all fixed this bug can be closed. In RTL Sheets: * Autoscrolling seems not to behave always correctly. * Resizing columns doesn't work right. * Behaviour of the horizontal scrollbar should be reversed. * "Choose" selections behave unexpectedly. * Jumping to a cell using the location combo box works only for jumping backwards. Jumping forward doesn't work (weird!). * Drag and drop doesn't behave correctly. * Moving the mouse over cells doesn't yield expected results (i.e. tooltips don't appear, selection's handles don't function, ...) * Cell left and right borders (which can be toggled through the toolbar or the cell properties dialog) aren't displayed right. * Same goes for page borders (toggled through the sheet properties dialog). * The comment indicator and formula indicator should appear in their opposite locations. RTL In KSpread In General: * The long text indicator should appear on the left in case the text in a cell is RTL. * When editing text in a cell, the editor automatically extends itself to the right when the text becomes too long. It should do so to the left if the text is RTL.
CVS commit by livne: Fix choose selections in RTL sheets. CCMAIL: 90127@bugs.kde.org M +20 -4 kspread_canvas.cc 1.428 --- koffice/kspread/kspread_canvas.cc #1.427:1.428 @@ -1416,7 +1416,15 @@ void KSpreadCanvas::chooseMouseMoveEvent double tmp; - double ev_PosX = doc()->unzoomItX( _ev->pos().x() ); + double ev_PosX; + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + { + double dwidth = doc()->unzoomItX( width() ); + ev_PosX = dwidth - doc()->unzoomItX( _ev->pos().x() ); + } + else + ev_PosX = doc()->unzoomItX( _ev->pos().x() ); + double ev_PosY = doc()->unzoomItY( _ev->pos().y() ); - int col = table->leftColumn( (ev_PosX + xOffset()), tmp ); // TODO + int col = table->leftColumn( (ev_PosX + xOffset()), tmp ); int row = table->topRow( (ev_PosY + yOffset()), tmp ); @@ -1451,8 +1459,16 @@ void KSpreadCanvas::chooseMousePressEven - double ev_PosX = doc()->unzoomItX( _ev->pos().x() ); + double ev_PosX; + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + { + double dwidth = doc()->unzoomItX( width() ); + ev_PosX = dwidth - doc()->unzoomItX( _ev->pos().x() ); + } + else + ev_PosX = doc()->unzoomItX( _ev->pos().x() ); + double ev_PosY = doc()->unzoomItY( _ev->pos().y() ); double ypos, xpos; - int col = table->leftColumn( (ev_PosX + xOffset()), xpos ); // TODO rtl + int col = table->leftColumn( (ev_PosX + xOffset()), xpos ); int row = table->topRow( (ev_PosY + yOffset()), ypos );
CVS commit by livne: Fix problems related to moving the mouse over cells in RTL sheets (tooltips, selection handles, links...). CCMAIL: 90127@bugs.kde.org M +49 -22 kspread_canvas.cc 1.429 --- koffice/kspread/kspread_canvas.cc #1.428:1.429 @@ -989,19 +989,15 @@ void KSpreadCanvas::mouseMoveEvent( QMou } + double dwidth = doc()->unzoomItX( width() ); double ev_PosX; if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) - ev_PosX = doc()->unzoomItX( _ev->pos().x() ) - xOffset(); + ev_PosX = dwidth - doc()->unzoomItX( _ev->pos().x() ) + xOffset(); else ev_PosX = doc()->unzoomItX( _ev->pos().x() ) + xOffset(); double ev_PosY = doc()->unzoomItY( _ev->pos().y() ) + yOffset(); - double dwidth = doc()->unzoomItX( width() ); double xpos; double ypos; - int col; - if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) - col = table->leftColumn( dwidth - ev_PosX, xpos ); - else - col = table->leftColumn( ev_PosX, xpos ); + int col = table->leftColumn( ev_PosX, xpos ); int row = table->topRow( ev_PosY, ypos ); @@ -1036,5 +1032,10 @@ void KSpreadCanvas::mouseMoveEvent( QMou { KSpreadCell *cell = table->visibleCellAt( col, row ); - QString anchor = cell->testAnchor( doc()->zoomItX( ev_PosX - xpos ), + QString anchor; + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + anchor = cell->testAnchor( doc()->zoomItX( cell->dblWidth() - ev_PosX + + xpos ), doc()->zoomItY( ev_PosY - ypos ) ); + else + anchor = cell->testAnchor( doc()->zoomItX( ev_PosX - xpos ), doc()->zoomItY( ev_PosY - ypos ) ); if ( !anchor.isEmpty() && anchor != m_strAnchor ) @@ -1049,13 +1050,15 @@ void KSpreadCanvas::mouseMoveEvent( QMou //If the cursor is over the hanlde, than it might be already on the next cell. //Recalculate the cell! - if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) - col = table->leftColumn( dwidth - ev_PosX - doc()->unzoomItX( 2 ), xpos ); - else col = table->leftColumn( ev_PosX - doc()->unzoomItX( 2 ), xpos ); row = table->topRow( ev_PosY - doc()->unzoomItY( 2 ), ypos ); if ( !table->isProtected() ) + { + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + setCursor( sizeBDiagCursor ); + else setCursor( sizeFDiagCursor ); } + } else if ( !m_strAnchor.isEmpty() ) { @@ -5599,6 +5602,14 @@ void KSpreadToolTip::maybeTip( const QPo // Over which cell is the mouse ? double ypos, xpos; - int col = table->leftColumn( (m_canvas->doc()->unzoomItX( p.x() ) + + double dwidth = m_canvas->doc()->unzoomItX( m_canvas->width() ); + int col; + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + col = table->leftColumn( (dwidth - m_canvas->doc()->unzoomItX( p.x() ) + m_canvas->xOffset()), xpos ); + else + col = table->leftColumn( (m_canvas->doc()->unzoomItX( p.x() ) + + m_canvas->xOffset()), xpos ); + + int row = table->topRow( (m_canvas->doc()->unzoomItY( p.y() ) + m_canvas->yOffset()), ypos ); @@ -5650,5 +5661,7 @@ void KSpreadToolTip::maybeTip( const QPo // Get the cell dimensions - KoRect unzoomedMarker( xpos - m_canvas->xOffset(), + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + { + KoRect unzoomedMarker( dwidth - u - xpos + m_canvas->xOffset(), ypos - m_canvas->yOffset(), u, @@ -5654,10 +5667,24 @@ void KSpreadToolTip::maybeTip( const QPo u, v ); + QRect marker( m_canvas->doc()->zoomRect( unzoomedMarker ) ); + if ( marker.contains( p ) ) + { + tip( marker, comment ); + } + } + else + { + KoRect unzoomedMarker( xpos - m_canvas->xOffset(), + ypos - m_canvas->yOffset(), + u, + v ); + QRect marker( m_canvas->doc()->zoomRect( unzoomedMarker ) ); if ( marker.contains( p ) ) { tip( marker, comment ); } + } }
CVS commit by livne: Fix resizing of columns in RTL sheets. CCMAIL: 90127@bugs.kde.org M +56 -36 kspread_canvas.cc 1.430
CVS commit by livne: Fix autoscrolling in RTL sheets. CCMAIL: 90127@bugs.kde.org M +31 -8 kspread_canvas.cc 1.431 --- koffice/kspread/kspread_canvas.cc #1.430:1.431 @@ -3078,4 +3078,8 @@ void KSpreadCanvas::doAutoScroll() if ( pos.x() < 0 ) { + if ( activeTable()->layoutDirection() == KSpreadSheet::RightToLeft ) + horzScrollBar()->setValue ((int) (horzScrollBar()->value() + + autoScrollAccelerationX( - pos.x() ))); + else horzScrollBar()->setValue ((int) (horzScrollBar()->value() - autoScrollAccelerationX( - pos.x() ))); @@ -3084,4 +3088,8 @@ void KSpreadCanvas::doAutoScroll() else if ( pos.x() > width() ) { + if ( activeTable()->layoutDirection() == KSpreadSheet::RightToLeft ) + horzScrollBar()->setValue ((int) (horzScrollBar()->value() - + autoScrollAccelerationX( pos.x() - width()))); + else horzScrollBar()->setValue ((int) (horzScrollBar()->value() + autoScrollAccelerationX( pos.x() - width()))); @@ -5217,5 +5225,19 @@ void KSpreadHBorder::mouseMoveEvent( QMo m_pView->activeTable() ); - if ( _ev->pos().x() < 0 ) // TODO rtl + if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) + { + if ( _ev->pos().x() < width() - m_pCanvas->width() ) + { + ColumnFormat *cl = table->columnFormat( col + 1 ); + x = table->dblColumnPos( col + 1 ); + m_pCanvas->horzScrollBar()->setValue ((int) + (m_pCanvas->doc()->zoomItX (ev_PosX + cl->dblWidth()) - m_pCanvas->doc()->unzoomItX( m_pCanvas->width() ))); + } + else if ( _ev->pos().x() > width() ) + m_pCanvas->horzScrollBar()->setValue( m_pCanvas->doc()->zoomItX( ev_PosX - dWidth + m_pCanvas->doc()->unzoomItX( m_pCanvas->width() ) ) ); + } + else + { + if ( _ev->pos().x() < 0 ) m_pCanvas->horzScrollBar()->setValue( m_pCanvas->doc()->zoomItX( ev_PosX ) ); else if ( _ev->pos().x() > m_pCanvas->width() ) @@ -5229,4 +5251,5 @@ void KSpreadHBorder::mouseMoveEvent( QMo } } + } }
CVS commit by livne: Fix jumping to a cell using the location combo box in RTL sheets. CCMAIL: 90127@bugs.kde.org M +5 -10 kspread_canvas.cc 1.432 --- koffice/kspread/kspread_canvas.cc #1.431:1.432 @@ -746,13 +746,8 @@ void KSpreadCanvas::scrollToCell(QPoint if ( table->layoutDirection()==KSpreadSheet::RightToLeft ) { - double minX = 100.0; // less than that, we scroll - double maxX = unzoomedWidth - 100.0; // more than that, we scroll - - kdDebug() << "rtl: XPos: " << xpos << ", min: " << minX << ", maxX: " << maxX << endl; - - minX = unzoomedWidth - 100.0; // less than that, we scroll - maxX = 100.0; // more than that, we scroll + double minX = unzoomedWidth - 100.0; // less than that, we scroll + double maxX = 100.0; // more than that, we scroll - kdDebug() << "rtl2: XPos: " << xpos << ", min: " << minX << ", maxX: " << maxX << ", Offset: " << xOffset() << endl; + // kdDebug() << "rtl2: XPos: " << xpos << ", min: " << minX << ", maxX: " << maxX << ", Offset: " << xOffset() << endl; // do we need to scroll left @@ -763,6 +758,6 @@ void KSpreadCanvas::scrollToCell(QPoint else if ( xpos < maxX ) { - double horzScrollBarValue = xOffset() + xpos + maxX; - double horzScrollBarValueMax = table->sizeMaxX() + unzoomedWidth; + double horzScrollBarValue = xOffset() - xpos + maxX; + double horzScrollBarValueMax = table->sizeMaxX() - unzoomedWidth; //We don't want to display any area > KS_colMax widths
CVS commit by livne: Reverse behaviour of horizontal scrollbar in RTL sheets. CCMAIL: 90127@bugs.kde.org M +25 -16 kspread_canvas.cc 1.433 M +13 -0 kspread_view.cc 1.796
CVS commit by livne: Fix drag and drop in RTL sheets. CCMAIL: 90127@bugs.kde.org M +16 -2 kspread_canvas.cc 1.434 --- koffice/kspread/kspread_canvas.cc #1.433:1.434 @@ -1602,4 +1602,5 @@ void KSpreadCanvas::dragMoveEvent( QDrag _ev->accept( KSpreadTextDrag::canDecode( _ev ) ); + double dwidth = doc()->unzoomItX( width() ); double xpos = table->dblColumnPos( selectionInfo()->selection().left() ); double ypos = table->dblRowPos( selectionInfo()->selection().top() ); @@ -1608,5 +1609,11 @@ void KSpreadCanvas::dragMoveEvent( QDrag QRect r1 ((int) xpos - 1, (int) ypos - 1, (int) width + 3, (int) height + 3); - double ev_PosX = doc()->unzoomItX( _ev->pos().x() ) + xOffset(); + + double ev_PosX; + if (table->layoutDirection()==KSpreadSheet::RightToLeft) + ev_PosX = dwidth - doc()->unzoomItX( _ev->pos().x() ) + xOffset(); + else + ev_PosX = doc()->unzoomItX( _ev->pos().x() ) + xOffset(); + double ev_PosY = doc()->unzoomItY( _ev->pos().y() ) + yOffset(); @@ -1631,4 +1638,5 @@ void KSpreadCanvas::dropEvent( QDropEven } + double dwidth = doc()->unzoomItX( width() ); double xpos = table->dblColumnPos( selectionInfo()->selection().left() ); double ypos = table->dblRowPos( selectionInfo()->selection().top() ); @@ -1637,5 +1645,11 @@ void KSpreadCanvas::dropEvent( QDropEven QRect r1 ((int) xpos - 1, (int) ypos - 1, (int) width + 3, (int) height + 3); - double ev_PosX = doc()->unzoomItX( _ev->pos().x() ) + xOffset(); + + double ev_PosX; + if (table->layoutDirection()==KSpreadSheet::RightToLeft) + ev_PosX = dwidth - doc()->unzoomItX( _ev->pos().x() ) + xOffset(); + else + ev_PosX = doc()->unzoomItX( _ev->pos().x() ) + xOffset(); + double ev_PosY = doc()->unzoomItY( _ev->pos().y() ) + yOffset();
CVS commit by livne: Fix locations of comment and formula indicators in RTL sheets. In an RTL sheet, the comment and formula indicators should appear in the upper left and lower right corners respectively. CCBUG: 90127 M +36 -12 kspread_cell.cc 1.634 --- koffice/kspread/kspread_cell.cc #1.633:1.634 @@ -2801,4 +2801,15 @@ void KSpreadCell::paintCommentIndicator( QPointArray point( 3 ); + if ( m_pTable->layoutDirection()==KSpreadSheet::RightToLeft ) + { + point.setPoint( 0, doc->zoomItX( cellRect.x() + 6.0 ), + doc->zoomItY( cellRect.y() ) ); + point.setPoint( 1, doc->zoomItX( cellRect.x() ), + doc->zoomItY( cellRect.y() ) ); + point.setPoint( 2, doc->zoomItX( cellRect.x() ), + doc->zoomItY( cellRect.y() + 6.0 ) ); + } + else + { point.setPoint( 0, doc->zoomItX( cellRect.right() - 5.0 ), doc->zoomItY( cellRect.y() ) ); @@ -2807,4 +2818,5 @@ void KSpreadCell::paintCommentIndicator( point.setPoint( 2, doc->zoomItX( cellRect.right() ), doc->zoomItY( cellRect.y() + 5.0 ) ); + } painter.setBrush( QBrush( penColor ) ); painter.setPen( Qt::NoPen ); @@ -2836,4 +2848,15 @@ void KSpreadCell::paintFormulaIndicator( QPointArray point( 3 ); + if ( m_pTable->layoutDirection()==KSpreadSheet::RightToLeft ) + { + point.setPoint( 0, doc->zoomItX( cellRect.right() - 6.0 ), + doc->zoomItY( cellRect.bottom() ) ); + point.setPoint( 1, doc->zoomItX( cellRect.right() ), + doc->zoomItY( cellRect.bottom() ) ); + point.setPoint( 2, doc->zoomItX( cellRect.right() ), + doc->zoomItY( cellRect.bottom() - 6.0 ) ); + } + else + { point.setPoint( 0, doc->zoomItX( cellRect.x() ), doc->zoomItY( cellRect.bottom() - 6.0 ) ); @@ -2842,4 +2865,5 @@ void KSpreadCell::paintFormulaIndicator( point.setPoint( 2, doc->zoomItX( cellRect.x() + 6.0 ), doc->zoomItY( cellRect.bottom() ) ); + } painter.setBrush( QBrush( penColor ) ); painter.setPen( Qt::NoPen );
CVS commit by livne: Have the long text indicator appear on the left in case the text in a cell is RTL. CCBUG: 90127 M +20 -6 kspread_cell.cc 1.635 --- koffice/kspread/kspread_cell.cc #1.634:1.635 @@ -2897,4 +2897,16 @@ void KSpreadCell::paintMoreTextIndicator QPointArray point( 3 ); + + if ( d->strOutText.isRightToLeft() ) + { + point.setPoint( 0, doc->zoomItX( cellRect.left() + 4.0 ), + doc->zoomItY( cellRect.y() + cellRect.height() / 2.0 -4.0 ) ); + point.setPoint( 1, doc->zoomItX( cellRect.left() ), + doc->zoomItY( cellRect.y() + cellRect.height() / 2.0 )); + point.setPoint( 2, doc->zoomItX( cellRect.left() + 4.0 ), + doc->zoomItY( cellRect.y() + cellRect.height() / 2.0 +4.0 ) ); + } + else + { point.setPoint( 0, doc->zoomItX( cellRect.right() - 4.0 ), doc->zoomItY( cellRect.y() + cellRect.height() / 2.0 - 4.0 ) ); @@ -2903,4 +2915,6 @@ void KSpreadCell::paintMoreTextIndicator point.setPoint( 2, doc->zoomItX( cellRect.right() - 4.0 ), doc->zoomItY( cellRect.y() + cellRect.height() / 2.0 + 4.0 ) ); + } + painter.setBrush( QBrush( penColor ) ); painter.setPen( Qt::NoPen );
CVS commit by livne: Have the cell editor extend itself to the left (instead of to the right) if text in a cell is RTL. CCBUG: 90127 M +5 -1 kspread_editors.cc 1.61 --- koffice/kspread/kspread_editors.cc #1.60:1.61 @@ -146,5 +146,9 @@ void KSpreadTextEditor::slotTextChanged( mw = width(); + if (t.isRightToLeft()) + setGeometry(x() - mw + width(), y(), mw, height()); + else setGeometry(x(), y(), mw, height()); + m_length -= 2; }
CVS commit by livne: Fix displaying of cell borders in RTL sheets. CCBUG: 90127 M +83 -32 kspread_cell.cc 1.638 M +16 -4 kspread_view.cc 1.797
CVS commit by livne: Fix displaying of page borders in RTL sheets. CCBUG: 90127 M +20 -4 kspread_cell.cc 1.639 --- koffice/kspread/kspread_cell.cc #1.638:1.639 @@ -2980,4 +2980,6 @@ void KSpreadCell::paintPageBorders( QPai KSpreadSheetPrint* print = m_pTable->print(); + KSpreadSheet::LayoutDirection sheetDir = m_pTable->layoutDirection(); + // Draw page borders if( m_pTable->isShowPageBorders() ) @@ -2993,4 +2995,11 @@ void KSpreadCell::paintPageBorders( QPai { painter.setPen( table()->doc()->pageBorderColor() ); + + if ( sheetDir == KSpreadSheet::RightToLeft ) + painter.drawLine( doc->zoomItX( cellRect.right() ), + doc->zoomItY( cellRect.y() ), + doc->zoomItX( cellRect.right() ), + doc->zoomItY( cellRect.bottom() ) ); + else painter.drawLine( doc->zoomItX( cellRect.x() ), doc->zoomItY( cellRect.y() ), doc->zoomItX( cellRect.x() ), doc->zoomItY( cellRect.bottom() ) ); @@ -3011,4 +3020,11 @@ void KSpreadCell::paintPageBorders( QPai { painter.setPen( table()->doc()->pageBorderColor() ); + + if ( sheetDir == KSpreadSheet::RightToLeft ) + painter.drawLine( doc->zoomItX( cellRect.x() ), + doc->zoomItY( cellRect.y() ), + doc->zoomItX( cellRect.x() ), + doc->zoomItY( cellRect.bottom() ) ); + else painter.drawLine( doc->zoomItX( cellRect.right() ), doc->zoomItY( cellRect.y() ), doc->zoomItX( cellRect.right() ), doc->zoomItY( cellRect.bottom() ) );
Good then, all issues I've listed in comment #11 are now fixed. Right-to-left spreadsheets are very much usable in KSpread now. There definitely may be more small issues with RTL sheets. If you find any, report them in new reports. I'm closing this bug.