Bug 90569 - goal seek ignores number format from locale
Summary: goal seek ignores number format from locale
Status: RESOLVED FIXED
Alias: None
Product: calligrasheets
Classification: Applications
Component: general (show other bugs)
Version: 1.3.2
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Laurent Montel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-30 22:35 UTC by Ismael Orenstein
Modified: 2004-10-02 18:57 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch to enable locale in the goal seek dialog (1.61 KB, patch)
2004-10-01 02:38 UTC, Tim Beaulen
Details
A better way to fix the locale in the goal seek dialog (1.64 KB, patch)
2004-10-01 13:49 UTC, Tim Beaulen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ismael Orenstein 2004-09-30 22:35:15 UTC
Version:           1.3.2 (using KDE 3.3.0, Gentoo)
Compiler:          gcc version 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)
OS:                Linux (i686) release 2.6.8-gentoo-r3

I'm from Brazil, and here we use commas to separate decimal values. So, 15/10 is written as 1,5. My locale is configure this way and all over KDE (inclusive in kspread), this setting is respect.

However, when using the Goal Seek function from KSpread, the "To value" input box doesn't respect this setting. If I enter 1,5 as the value, it says "target value is invalid". 

Using 1.5 it works correctly, although it is inconsistent with the rest of the system.
Comment 1 Tim Beaulen 2004-10-01 02:38:22 UTC
Created attachment 7740 [details]
Patch to enable locale in the goal seek dialog

The attached patch is a suggestion to fix this bug.

I also changed the way to display the current value and new value string to
reflect the locale.
Comment 2 Tim Beaulen 2004-10-01 13:49:42 UTC
Created attachment 7744 [details]
A better way to fix the locale in the goal seek dialog

This patch uses m_pView->doc()->locale(), where m_pView is a KSpreadView object
and doc() returns a KSpreadDoc object.

The previous patch used KGlobal::locale()
Comment 3 Tomas Mecir 2004-10-02 18:57:08 UTC
CVS commit by mecir: 

Fixing bug #90569 (Goal seek ignores number format from locale).
Patch sent by Tim Beaulen, tbscope <> gmail () com

CCMAIL: 90569-done@bugs.kde.org


  M +4 -4      kspread_dlg_goalseek.cc   1.23


--- koffice/kspread/dialogs/kspread_dlg_goalseek.cc  #1.22:1.23
@@ -271,5 +271,5 @@ void KSpreadGoalSeekDlg::buttonOkClicked
 
     bool ok = false;
-    double goal = m_targetValueEdit->text().toDouble( &ok );
+    double goal = m_pView->doc()->locale()->readNumber(m_targetValueEdit->text(), &ok );
     if ( !ok )
     {
@@ -471,6 +471,6 @@ void KSpreadGoalSeekDlg::startCalc(doubl
 
     m_resultText->setText( i18n( "Goal seeking with cell %1 found a solution:" ).arg( m_sourceEdit->text() ) );
-    m_newValue->setText( QString::number( startA ) );
-    m_currentValue->setText( QString::number( m_oldSource ) );
+    m_newValue->setText( m_pView->doc()->locale()->formatNumber( startA ) );
+    m_currentValue->setText( m_pView->doc()->locale()->formatNumber( m_oldSource ) );
     m_restored = false;
   }
@@ -484,5 +484,5 @@ void KSpreadGoalSeekDlg::startCalc(doubl
     m_resultText->setText( i18n( "Goal seeking with cell %1 has found NO solution." ).arg( m_sourceEdit->text() ) );
     m_newValue->setText( "" );
-    m_currentValue->setText( QString::number( m_oldSource ) );
+    m_currentValue->setText( m_pView->doc()->locale()->formatNumber( m_oldSource ) );
     m_restored = true;
   }