Bug 134044

Summary: KOffice 1.6: formulas lost in saved document
Product: [Applications] calligraformula Reporter: Yuriy Kozlov <yuriy.kozlov>
Component: generalAssignee: Alfredo Beaumont <alfredo.beaumont>
Status: RESOLVED FIXED    
Severity: normal CC: alfredo.beaumont
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: the test file
a screenshot where commas are inserted

Description Yuriy Kozlov 2006-09-14 03:59:10 UTC
Version:           1.5.91 (using KDE KDE 3.5.4)
Installed from:    Ubuntu Packages
OS:                Linux

I had two documents in KWord, on two different machines both running Kubuntu Edgy with KOffice 1.6 Beta 1.

Each document had several in-line formulas and were saved in ODT (ODF) format.  When I open them with KWord, most (not all) of the contents of the formulas are gone.  The frames are still there.  OpenOffice.org 2.0 crashes when trying to open either of the documents.

In a couple formulas that remain intact, there are commas inserted between parentheses and the content between those parentheses.

I made a test file with just one formula.  I saved it in both KWord and ODF formats.  Either of those opened in KWord yields a blank frame.  When the ODT is opened in OpenOffice.org 2.0, the formula is there.
Comment 1 Yuriy Kozlov 2006-09-14 04:00:44 UTC
Created attachment 17761 [details]
the test file

This contains one formula, created in KWord, that appears in OpenOffice but not
in KWord.
Comment 2 Yuriy Kozlov 2006-09-14 04:03:22 UTC
Created attachment 17762 [details]
a screenshot where commas are inserted
Comment 3 Alfredo Beaumont 2006-09-14 10:31:48 UTC
Thanks for your report, I can confirm it. Hope to fix later today.
Comment 4 Alfredo Beaumont 2006-09-14 20:05:55 UTC
SVN commit 584398 by abeaumont:

OpenDocument: Fix saving <semantics>, it does not infer mrows, so mrow is
manually added.

BUG: 134044


 M  +9 -4      formulaelement.cc  


--- branches/koffice/1.6/koffice/lib/kformula/formulaelement.cc #584397:584398
@@ -316,16 +316,21 @@
 void FormulaElement::writeMathML( QDomDocument& doc, QDomNode& parent, bool oasisFormat ) const
 {
     QDomElement de;
-    if ( !oasisFormat )
+    if ( !oasisFormat ) {
         de = doc.createElementNS( "http://www.w3.org/1998/Math/MathML",
                                               "math" );
-    else
-        de =doc.createElement( "math:semantics" );
+        parent.appendChild( de );
+    }
+    else {
+        QDomElement element = doc.createElement( "math:semantics" );
+        de = doc.createElement( "math:mrow" );
+        parent.appendChild( element );
+        element.appendChild( de );
+    }
     for ( uint i = 0; i < countChildren(); ++i ) {
         const BasicElement* e = getChild( i );
         e->writeMathML( doc, de, oasisFormat );
     }
-    parent.appendChild( de );
 }
 
 KFORMULA_NAMESPACE_END