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

List:       kde-commits
Subject:    koffice/plugins/textshape
From:       Elvis Stansvik <elvstone () gmail ! com>
Date:       2009-08-03 14:42:51
Message-ID: 1249310571.184249.9480.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1006353 by astan:

Use the Qt way for empty block before table for now, we can fix
something else later.

 M  +12 -26    Layout.cpp  
 M  +0 -9      Layout.h  


--- trunk/koffice/plugins/textshape/Layout.cpp #1006352:1006353
@@ -470,6 +470,7 @@
         m_dropCapsNChars = 0;
     }
 
+
     layout->beginLayout();
     m_fragmentIterator = m_block.begin();
     m_newParag = true;
@@ -496,18 +497,6 @@
     return m_data->documentOffset();
 }
 
-bool Layout::keepTableWithBlock(QTextBlock &block)
-{
-    QTextCursor nextCursor(block.next());
-    QTextCursor previousCursor(block.previous());
-
-    return (block.isValid() && block.length() == 1 &&
-            // Block is between table and beginning of document.
-            ((block.position() == 0 && nextCursor.currentTable()) ||
-            // Block is between two tables.
-            (nextCursor.currentTable() && previousCursor.currentTable())));
-}
-
 void Layout::handleTable()
 {
     // Check if we are inside a table.
@@ -524,21 +513,18 @@
         QTextTableCell previousCell = table->cellAt(m_block.previous().position());
 
         if (!previousCell.isValid()) {
-            // The previous cell is invalid, which means we have entered a
-            // table, so set the current table on the table layout, and initialize
-            // a layout from the beginning positioning the first new
-            // rect at the current position, or at the position of the previous
-            // block if it's an empty block between this table and the document
-            // start or another table.
-            QPointF startPos = QPointF(x(), y());
-            QTextBlock previousBlock = m_block.previous();
-            if (keepTableWithBlock(previousBlock)) {
-                // We should keep the table with the previous block.
-                startPos = previousBlock.layout()->lineAt(0).position();
-            }
+            // The previous cell is invalid, which means we have entered a table.
+
+            // Set the current table on the table layout.
             m_tableLayout.setTable(table);
-            qDebug() << "initial layout about to start at " << x() << " " << y();
-            m_tableLayout.startNewTableRect(startPos, shape->size().width(), 0);
+
+            // Position the table. Use position of previous block if it's empty.
+            QTextBlock prevBlock = m_block.previous();
+            QPointF pos = prevBlock.length() == 1 ? \
prevBlock.layout()->lineAt(0).position() : QPointF(x(), y()); +
+            // Start the first rect of the table.
+            qDebug() << "initial layout about to start at " << pos;
+            m_tableLayout.startNewTableRect(pos, shape->size().width(), 0);
             m_restartingAfterTableBreak = false; // You never know
             m_restartingFirstCellAfterTableBreak = false; // You never know
         }
--- trunk/koffice/plugins/textshape/Layout.h #1006352:1006353
@@ -128,15 +128,6 @@
      */
     void handleTableBreak(QTextTableCell &previousCell, QTextTable *table);
 
-    /**
-     * Returns true if the table follwing the given block should be kept with
-     * it. This function returns true if the given block is:
-     *
-     * 1) An empty block between two tables.
-     * 2) An empty block between a table and beginning of document.
-     */
-    bool keepTableWithBlock(QTextBlock &block);
-
 private:
     KoStyleManager *m_styleManager;
 


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

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