Bug 154980 - Bad ODT rendering
Summary: Bad ODT rendering
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: ODT backend (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: testcase
Depends on:
Blocks:
 
Reported: 2008-01-02 18:39 UTC by Dario Panico
Modified: 2009-01-08 12:39 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Example file (11.08 KB, application/vnd.oasis.opendocument.text)
2008-01-02 18:40 UTC, Dario Panico
Details
Good rendering (103.84 KB, image/png)
2008-01-02 18:42 UTC, Dario Panico
Details
Very bad rendering (79.89 KB, image/png)
2008-01-02 18:42 UTC, Dario Panico
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dario Panico 2008-01-02 18:39:43 UTC
Version:           0.5.94 (using KDE 3.97.1 (KDE 4.0 >= 20071214), compiled sources)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.22-14-generic

File Prova.odt is bad rendered, text in a table is not aligned (Left, Right, Center), every line is mixed with the others, the table is not displayed in all its length and this way numbered lists are not shown.
Everything is a mess. Look by yourself.
shot1.png good OOo-Writer rendering
shot2.png bad Okular rendering
Comment 1 Dario Panico 2008-01-02 18:40:10 UTC
Created attachment 22801 [details]
Example file
Comment 2 Dario Panico 2008-01-02 18:42:00 UTC
Created attachment 22802 [details]
Good rendering
Comment 3 Dario Panico 2008-01-02 18:42:28 UTC
Created attachment 22803 [details]
Very bad rendering
Comment 4 Dario Andres 2008-08-16 14:41:00 UTC
Version 0.7 Using KDE 4.1.1 (KDE 4.1.0 (4.1 >= 20080722)) (KDEmod) in ArchLinux i686:
I can confirm this bug in rendering
Comment 5 Dario Andres 2008-11-29 19:59:27 UTC
This bug still happens on KDE 4.1.3 and KDE4.2svn (kdegraphics rev. 890639).

Here is some shell output:

[dario@emiDell Desktop]$ okular Prova.odt 
okular(11584)/kdecore (KSycoca) KSycocaPrivate::openDatabase: Trying to open ksycoca from  "/var/tmp/kdecache-dario/ksycoca4"
okular(11584)/kio (KDirWatch) KDirWatchPrivate::KDirWatchPrivate: Available methods:  ("Stat", "INotify")                    
okular(11584)/kparts KParts::MainWindow::createGUI: MainWindow::createGUI, part= Part(0xf941c0)   Part   ""                  
okular(11584)/kdecore (trader) KMimeTypeTrader::query: query for mimeType  "application/vnd.oasis.opendocument.text" ,  "okular/Generator"  : returning  1  offers
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
okular(11584)/KZip KZip::openArchive: trying to seek for next PK78                                                                                                
unknown tag table-properties                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown unit                                                                                                                                                      
unknown tag graphic-properties                                                                                                                                    
unknown tag table-properties                                                                                                                                      
unknown tag table-row-properties                                                                                                                                  
unknown tag outline-style                                                                                                                                         
unknown tag notes-configuration                                                                                                                                   
unknown tag notes-configuration                                                                                                                                   
unknown tag linenumbering-configuration                                                                                                                           
unknown tag default-page-layout

I wonder if all the "unknown" lines have something to do with this bug / strange odt file.
Comment 6 Dario Andres 2008-12-14 17:34:27 UTC
I can still reproduce it using:

Qt: 4.4.3
KDE: 4.1.85 (KDE 4.1.85 (KDE 4.2 Beta2))
kdelibs svn rev. 896844 / kdebase svn rev. 896844
kdegraphics svn rev. 896874

Confirming.
Comment 7 Pino Toscano 2008-12-14 17:39:56 UTC
@Darío Andrés:
please use the "testcase" keyword.
Comment 8 Brad Hards 2009-01-03 08:36:33 UTC
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...
Comment 9 Brad Hards 2009-01-04 01:34:27 UTC
SVN commit 905238 by bhards:

Add support for the "justify", "start" and "end" text alignment
modes.

Partly addresses rendering problems identified at
http://bugs.kde.org/show_bug.cgi?id=154980

CCBUG:154980


 M  +5 -0      formatproperty.cpp  
 M  +2 -0      formatproperty.h  
 M  +9 -0      styleparser.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=905238
Comment 10 Brad Hards 2009-01-06 07:48:30 UTC
SVN commit 906395 by bhards:

General improvements to visual rendering of .odt
documents.

We can now (more) correctly render cell widths,
documents containing more than just a table,
documents containing lists within table cells,
and documents containing variable formatting
within a single table cell.

Significantly improves rendering of example in
http://bugs.kde.org/show_bug.cgi?id=154980
There is still an issue relating to list indenting.

CCBUG:154980.


 M  +33 -14    converter.cpp  
 M  +1 -1      converter.h  
 M  +5 -1      formatproperty.cpp  
 M  +1 -0      formatproperty.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=906395
Comment 11 Brad Hards 2009-01-08 12:39:05 UTC
SVN commit 907544 by bhards:

Implement support for the left-margin property.

This completes the work on the test sample in http://bugs.kde.org/show_bug.cgi?id=154980

BUG:154980


 M  +7 -0      formatproperty.cpp  
 M  +2 -0      formatproperty.h  
 M  +6 -0      styleparser.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=907544