Bug 126990 - points are saved with , instead of . in e.g. french locale
Summary: points are saved with , instead of . in e.g. french locale
Status: RESOLVED FIXED
Alias: None
Product: koffice
Classification: Applications
Component: general (show other bugs)
Version: git
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-08 23:41 UTC by Nicolas Arnaud-Cormos
Modified: 2006-05-10 01:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Arnaud-Cormos 2006-05-08 23:41:48 UTC
Version:           1.5.0 (using KDE KDE 3.5.2)
Installed from:    Ubuntu Packages

When I put an image in the main slide (the background for all slide), the pen is not saved :
  - I put an image
  - I change the default pen to "No Pen" (I tried to other options, it's the same)
  - I close KPresenter
  - I reload my presentation

Result : the image have a solid pen of 1 pt.

Here is a simple exemple :
 - presentation : http://nikikko.free.fr/temp/kpresenter/bug-image-pen.odp
 - image used : http://nikikko.free.fr/temp/kpresenter/bug-image-pen.png
Comment 1 T Zachmann 2006-05-09 07:52:47 UTC
Change severity to normal as it is not a crash.

The problem you describe is allready fixed in svn and will be in koffice 1.5.1.

I have had a look at the open doc file  http://nikikko.free.fr/temp/kpresenter/bug-image-pen.odp 
but the image has no width/hight for me. Looks like I hid a different bug here. Which locale are you using?

Comment 2 Nicolas Arnaud-Cormos 2006-05-09 08:12:38 UTC
I'm using french locale.
The image is 400x100. It is placed in the upper left corner.

I have attached the image here :
http://nikikko.free.fr/temp/kpresenter/bug-image-pen.png 
Comment 3 Nicolas Arnaud-Cormos 2006-05-09 08:28:22 UTC
I have forgotten...
Thank you for the fix, do I have to close the bug now ?
Comment 4 T Zachmann 2006-05-09 09:04:06 UTC
No please let it open because of the other bug I found. Change title to have give the correct description about the problems of saving in e.g. French locale.

See output of oasislint

/home/hugo/test2/styles.xml:31:171: error: bad value for attribute "width" from namespace "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
/home/hugo/test2/styles.xml:31:171: error: bad value for attribute "height" from namespace "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"

and here is the coresponding line to the errors:
<draw:frame presentation:style-name="pr1" draw:id="object1" svg:width="299,999999999976pt" svg:height="74,999999999994pt" svg:x="0pt" svg:y="0pt" draw:name="Image">

Comment 5 T Zachmann 2006-05-09 09:55:35 UTC
@David: Can you please have a look at this
Comment 6 David Faure 2006-05-09 10:12:22 UTC
This seems - impossible ...
svg:width is saved using KoXmlWriter::addAttributePt, which calls QCString::setNum, which uses "." as decimal separator, always. This is locale-independent.

At least in my Qt-3.3.5. Which version of Qt do you use exactly?
Comment 7 Nicolas Arnaud-Cormos 2006-05-09 19:04:19 UTC
My systems :
 Kubuntu dapper beta up-to-date (all upgrades)
 KDE 3.5.2, KPresenter 1.5
 Qt 3.3.6

I tried to change the local in KDE for US English, but no effect.

So I tried to change the LANG variable (fr_FR.UTF-8 => en_GB.UTF-8) :
 export LANG=en_GB.UTF-8 && kpresenter

And it's working now, there "." instead of "," in the xml.

Maybe it's an ubuntu bug... if you need more information, don't hesitate.

Comment 8 David Faure 2006-05-09 19:55:08 UTC
>  Qt 3.3.6

I downloaded Qt 3.3.6, the code in QCString::setNum(double) hasn't changed, still using "." unconditionally.

> So I tried to change the LANG variable (fr_FR.UTF-8 => en_GB.UTF-8) :
>  export LANG=en_GB.UTF-8 && kpresenter
> 
> And it's working now, there "." instead of "," in the xml.


Huh. And if you export LANG to fr_FR.UTF-8 the problem is back?

> Maybe it's an ubuntu bug... if you need more information, don't hesitate.


Is there a way to check for ubuntu patches to Qt? I guess this would be in the src package for qt, right?

Can you compile this test program and run it?

#include <qcstring.h>
#include <stdio.h>
#include <float.h>
#include <assert.h>
int main()
{
   QCString str;
   str.setNum( 123.4567, 'g', DBL_DIG );
   qDebug( "%s", str.data() );
   assert( str == "123.4567" );
   return 0;
}

Save it into a file like qcstring.cpp, in an empty directory called qcstring; then do
qmake -project ; qmake ; ./qcstring
Do you see "123.4567" or do you get an assertion failure?
Comment 9 David Faure 2006-05-09 19:56:30 UTC
I meant 
  qmake -project ; qmake ; make ; ./qcstring
of course
Comment 10 David Faure 2006-05-09 19:57:46 UTC
On Tuesday 09 May 2006 19:55, David Faure wrote:
> I downloaded Qt 3.3.6, the code in QCString::setNum(double) hasn't changed, still using "." unconditionally.

Oh, I misread that code. The "." is only a format string, after that it calls sprintf, which might very well do locale-dependent things indeed....
Comment 11 David Faure 2006-05-09 20:09:13 UTC
OK don't bother - I can reproduce the problem now. Fix coming up.
Comment 12 David Faure 2006-05-09 20:21:13 UTC
SVN commit 539110 by dfaure:

Fix for "points are saved with , instead of . in e.g. french locale".
QCString has very unexpected side effects due to it calling sprintf, but it's too late to fix that in Qt.
Qt4's QByteArray doesn't have this problem
BUG: 126990


 M  +4 -1      KoGlobal.cpp  


--- branches/koffice/1.5/koffice/lib/kofficecore/KoGlobal.cpp #539109:539110
@@ -32,8 +32,8 @@
 #include <kimageio.h>
 #include <kiconloader.h>
 #include <kstandarddirs.h>
+#include <locale.h>
 
-
 KoGlobal* KoGlobal::s_global = 0L;
 static KStaticDeleter<KoGlobal> sdg;
 
@@ -47,6 +47,9 @@
 KoGlobal::KoGlobal()
     : m_pointSize( -1 ), m_kofficeConfig( 0L )
 {
+    // Make sure that QCString::setNum doesn't give us "," as decimal point, e.g. when saving to OpenDocument.
+    setlocale( LC_NUMERIC, "C" );
+
     // Install the libkoffice* translations
     KGlobal::locale()->insertCatalogue("koffice");
 
Comment 13 Nicolas Arnaud-Cormos 2006-05-09 20:49:36 UTC
You are really too fast for me ;)
Thank you !
Comment 14 Nicolas Arnaud-Cormos 2006-05-09 22:55:28 UTC
As a side effect of this bug, my presentation is completely messy when I change the locale and open with KPresenter, or when I open with OpenOffice.

I have to unzip the odp file, to change all "," in "." in the xml files and to zip back.

Just a note for those who have the problem.
Comment 15 David Faure 2006-05-10 01:40:34 UTC
A simpler workaround: open in kpresenter, save as .kpr, export LC_NUMERIC=C , reopen .kpr in kpresenter, save as .odp again.