[Okular-devel] [Bug 154980] Bad ODT rendering

Brad Hards bradh at frogmouth.net
Sat Jan 3 08:36:35 CET 2009


http://bugs.kde.org/show_bug.cgi?id=154980


Brad Hards bradh frogmouth net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bradh at frogmouth.net




--- Comment #8 from Brad Hards <bradh frogmouth net>  2009-01-03 08:36:33 ---
I've started looking at this bug. There is more than one missing element
involved.

1. We aren't handling the different alignment of elements within a single cell.
So the first cell in the second row should render something like:
BOH
             MAH
    CHI LO SA
But we render it as
CHI LO SAMAHBOH (with some wordwrapping)
That is caused partly by inserting text at the beginning position
(cell.firstCursorPosition(), which is easily fixed) and partly by not being
able to set the alignment as a text property, only as a block property. The
only way I can see of resolving this is to insert invisible frames within the
cell, one for each <p> block.
           while ( !paragraphElement.isNull() ) {
             if ( paragraphElement.tagName() == QLatin1String( "p" ) ) {
               QTextTableCell cell = table->cellAt( rowCounter, columnCounter
);
-              QTextCursor cursor = cell.firstCursorPosition();
-              cursor.setBlockFormat( format );
+              // Insert a frame into the cell and work on that, so we can
handle
+              // different parts of the cell having different block formatting
+              QTextCursor cellCursor = cell.lastCursorPosition();
+              QTextFrame *frame = cellCursor.insertFrame( QTextFrameFormat()
);
+              QTextCursor frameCursor = frame->firstCursorPosition();
+              frameCursor.setBlockFormat( format );

-              if ( !convertParagraph( &cursor, paragraphElement, format ) )
+              if ( !convertParagraph( &frameCursor, paragraphElement, format )
)
                 return false;
             }

2. We don't support the start, end and justify alignment types. A temporary
hack to fix that:
--- styleparser.cpp     (revision 903994)
+++ styleparser.cpp     (working copy)
@@ -291,6 +291,9 @@
     alignMap.insert( "center", Qt::AlignCenter );
     alignMap.insert( "left", Qt::AlignLeft );
     alignMap.insert( "right", Qt::AlignRight );
+    alignMap.insert( "justify", Qt::AlignJustify );
+    alignMap.insert( "start", Qt::AlignLeft ); // TODO: fix for RL writing
mode
+    alignMap.insert( "end", Qt::AlignRight ); // TODO: fix for LR writing mode
   }
   if ( parent.hasAttribute( "text-align" ) ) {
     property.setTextAlignment( alignMap[ parent.attribute( "text-align",
"left" ) ] );

3. We don't properly size the cells / columns. Need to parse the table-column
attributes, and find a way to map that into a Qt property. Presumably that will
require some kind of call to tableFormat.setColumnWidthConstraints().

4. We don't support lists. Need to support the parsing and list styles.

I have part of this done, and can look at the rest.

Question for Pino - is this really a bug fix (i.e. 4.2) or an enhancement (i.e.
4.3)? It certainly could introduce regressions...


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Okular-devel mailing list