[ooo-build-commit] patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Sep 29 11:33:14 PDT 2009


 patches/dev300/apply                                       |    5 
 patches/dev300/calc-general-type-auto-decimal-sc.diff      |   91 +++++++++
 patches/dev300/calc-general-type-auto-decimal-svtools.diff |  122 +++++++++++++
 3 files changed, 218 insertions(+)

New commits:
commit fb536c206482bb18e5faf1861a69e3f3f0575f0e
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Sep 29 14:19:34 2009 -0400

    Automatically adjust the number of decimals for 'General' cell type.
    
    * patches/dev300/apply: add these two new patches.
    
    * patches/dev300/calc-general-type-auto-decimal-sc.diff:
    * patches/dev300/calc-general-type-auto-decimal-svtools.diff: when
      the format type of a cell is 'General', and the cell content is
      a number, automatically adjust the number of decimals in the
      displayed number based on the cell value.  For instance, when
      '1.23456' is entered, the cell would display '1.23456', instead of
      just '1.23' (old behavior). (n#541973)

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 161e631..70b1855 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -846,6 +846,11 @@ calc-combo-listbox-export-fix.diff, n#540566, noelp
 # Disable context menu on non-selectable cells.
 calc-selection-protected-cells.diff, n#542024, kohei
 
+# When the cell format is 'General', automatically adjust the number of decimals
+# to be displayed based on the cell value.
+calc-general-type-auto-decimal-sc.diff,      n#541973, kohei
+calc-general-type-auto-decimal-svtools.diff, n#541973, kohei
+
 # Support PHONETIC function to display asian phonetic guide.
 # LATER: I'll take care of this later.  --kohei
 # calc-formula-asian-phonetic.diff, i#80764, i#80765, i#80766, kohei
diff --git a/patches/dev300/calc-general-type-auto-decimal-sc.diff b/patches/dev300/calc-general-type-auto-decimal-sc.diff
new file mode 100644
index 0000000..4cea62e
--- /dev/null
+++ b/patches/dev300/calc-general-type-auto-decimal-sc.diff
@@ -0,0 +1,91 @@
+diff --git sc/inc/cellform.hxx sc/inc/cellform.hxx
+index a94ef54..d5c5b20 100644
+--- sc/inc/cellform.hxx
++++ sc/inc/cellform.hxx
+@@ -58,7 +58,7 @@ public:
+                                ScForceTextFmt eForceTextFmt = ftDontForce );
+ 
+     static void		GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rString,
+-                                      SvNumberFormatter& rFormatter );
++                                      SvNumberFormatter& rFormatter, Color** ppColor = NULL );
+ };
+ 
+ 
+diff --git sc/source/core/tool/cellform.cxx sc/source/core/tool/cellform.cxx
+index e6177b0..e17ef9c 100644
+--- sc/source/core/tool/cellform.cxx
++++ sc/source/core/tool/cellform.cxx
+@@ -159,8 +159,11 @@ void ScCellFormat::GetString( ScBaseCell* pCell, ULONG nFormat, String& rString,
+ }
+ 
+ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rString,
+-                                      SvNumberFormatter& rFormatter )
++                                      SvNumberFormatter& rFormatter, Color** ppColor )
+ {
++    if (ppColor)
++        *ppColor = NULL;
++
+     if (&rFormatter==NULL)
+     {
+         rString.Erase();
+@@ -173,17 +176,19 @@ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rSt
+         case CELLTYPE_STRING:
+             {
+                 ((ScStringCell*)pCell)->GetString( rString );
++                rFormatter.GetStringColor(nFormat, ppColor);
+             }
+             break;
+         case CELLTYPE_EDIT:
+             {
+                 ((ScEditCell*)pCell)->GetString( rString );
++                rFormatter.GetStringColor(nFormat, ppColor);
+             }
+             break;
+         case CELLTYPE_VALUE:
+             {
+                 double nValue = ((ScValueCell*)pCell)->GetValue();
+-                rFormatter.GetInputLineString( nValue, nFormat, rString );
++                rFormatter.GetInputLineString( nValue, nFormat, rString, ppColor );
+             }
+             break;
+         case CELLTYPE_FORMULA:
+@@ -195,7 +200,7 @@ void ScCellFormat::GetInputString( ScBaseCell* pCell, ULONG nFormat, String& rSt
+                 else if (((ScFormulaCell*)pCell)->IsValue())
+                 {
+                     double nValue = ((ScFormulaCell*)pCell)->GetValue();
+-                    rFormatter.GetInputLineString( nValue, nFormat, rString );
++                    rFormatter.GetInputLineString( nValue, nFormat, rString, ppColor );
+                 }
+                 else
+                 {
+diff --git sc/source/ui/view/output2.cxx sc/source/ui/view/output2.cxx
+index 8942a38..5826bb1 100644
+--- sc/source/ui/view/output2.cxx
++++ sc/source/ui/view/output2.cxx
+@@ -454,12 +454,20 @@ BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell )
+ 
+             Color* pColor;
+             ULONG nFormat = GetValueFormat();
+-            ScCellFormat::GetString( pCell,
+-                                     nFormat, aString, &pColor,
+-                                     *pFormatter,
+-                                     pOutput->bShowNullValues,
+-                                     pOutput->bShowFormulas,
+-                                     ftCheck );
++
++            if (static_cast<NfIndexTableOffset>(nFormat) == NF_NUMBER_STANDARD)
++                // For 'General' format type, display the value the same way it
++                // is displayed in the edit window, which automatically
++                // adjusts the number of decimal places based on the value of
++                // the cell.
++                ScCellFormat::GetInputString(pCell, nFormat, aString, *pFormatter, &pColor);
++            else
++                ScCellFormat::GetString( pCell,
++                                         nFormat, aString, &pColor,
++                                         *pFormatter,
++                                         pOutput->bShowNullValues,
++                                         pOutput->bShowFormulas,
++                                         ftCheck );
+ 
+             if (aString.Len() > DRAWTEXT_MAX)
+                 aString.Erase(DRAWTEXT_MAX);
diff --git a/patches/dev300/calc-general-type-auto-decimal-svtools.diff b/patches/dev300/calc-general-type-auto-decimal-svtools.diff
new file mode 100644
index 0000000..a0c0111
--- /dev/null
+++ b/patches/dev300/calc-general-type-auto-decimal-svtools.diff
@@ -0,0 +1,122 @@
+diff --git svtools/inc/svtools/zforlist.hxx svtools/inc/svtools/zforlist.hxx
+index bb4a589..069930e 100644
+--- svtools/inc/svtools/zforlist.hxx
++++ svtools/inc/svtools/zforlist.hxx
+@@ -492,11 +492,16 @@ public:
+     void GetOutputString( String& sString, sal_uInt32 nFIndex,
+                           String& sOutString, Color** ppColor );
+ 
++    void GetStringColor( sal_uInt32 nFIndex, Color** ppColor );
++
+     /** Format a number according to the standard default format matching
+         the given format index */
+     void GetInputLineString( const double& fOutNumber,
+                             sal_uInt32 nFIndex, String& sOutString );
+ 
++    void GetInputLineString( const double& fOutNumber,
++                             sal_uInt32 nFIndex, String& sOutString, Color** ppColor );
++
+     /** Format a number according to a format code string to be scanned.
+         @return
+             <FALSE/> if format code contains an error
+diff --git svtools/inc/svtools/zformat.hxx svtools/inc/svtools/zformat.hxx
+index 4c52b10..d502bb6 100644
+--- svtools/inc/svtools/zformat.hxx
++++ svtools/inc/svtools/zformat.hxx
+@@ -241,6 +241,7 @@ public:
+ 
+     BOOL GetOutputString( double fNumber, String& OutString, Color** ppColor );
+     BOOL GetOutputString( String& sString, String& OutString, Color** ppColor );
++    void GetStringColor( Color** ppColor );
+ 
+     // True if type text
+     BOOL IsTextFormat() const { return (eType & NUMBERFORMAT_TEXT) != 0; }
+diff --git svtools/source/numbers/zforlist.cxx svtools/source/numbers/zforlist.cxx
+index 4b13774..ceedb05 100644
+--- svtools/source/numbers/zforlist.cxx
++++ svtools/source/numbers/zforlist.cxx
+@@ -1488,9 +1488,16 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
+                                            sal_uInt32 nFIndex,
+                                            String& sOutString)
+ {
++    Color* pColor;
++    GetInputLineString(fOutNumber, nFIndex, sOutString, &pColor);
++}
++
++void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
++                                           sal_uInt32 nFIndex,
++                                           String& sOutString, Color** ppColor)
++{
+     SvNumberformat* pFormat;
+     short nOldPrec;
+-    Color* pColor;
+     pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
+     if (!pFormat)
+         pFormat = aFTable.Get(ZF_STANDARD);
+@@ -1531,7 +1538,13 @@ void SvNumberFormatter::GetInputLineString(const double& fOutNumber,
+             nOldPrec = pFormatScanner->GetStandardPrec();
+             ChangeStandardPrec(300);						// Merkwert
+         }
+-        pFormat->GetOutputString(fOutNumber, sOutString, &pColor);
++        if (ppColor)
++            pFormat->GetOutputString(fOutNumber, sOutString, ppColor);
++        else
++        {
++            Color* pColor; // throw away the color info.
++            pFormat->GetOutputString(fOutNumber, sOutString, &pColor);
++        }
+     }
+     if (nOldPrec != -1)
+         ChangeStandardPrec(nOldPrec);
+@@ -1574,6 +1587,21 @@ void SvNumberFormatter::GetOutputString(String& sString,
+     }
+ }
+ 
++void SvNumberFormatter::GetStringColor( sal_uInt32 nFIndex, Color** ppColor)
++{
++    if (!ppColor)
++        return;
++
++    SvNumberformat* pFormat = (SvNumberformat*) aFTable.Get(nFIndex);
++    if (!pFormat)
++        pFormat = aFTable.Get(ZF_STANDARD_TEXT);
++
++    if (pFormat->IsTextFormat() || pFormat->HasTextFormat())
++        pFormat->GetStringColor(ppColor);
++    else
++        *ppColor = NULL;
++}
++
+ BOOL SvNumberFormatter::GetPreviewString(const String& sFormatString,
+                                          double fPreviewNumber,
+                                          String& sOutString,
+diff --git svtools/source/numbers/zformat.cxx svtools/source/numbers/zformat.cxx
+index 368fb16..65c0592 100644
+--- svtools/source/numbers/zformat.cxx
++++ svtools/source/numbers/zformat.cxx
+@@ -1915,6 +1915,25 @@ BOOL SvNumberformat::GetOutputString(String& sString,
+     }
+     return FALSE;
+ }
++
++void SvNumberformat::GetStringColor( Color** ppColor )
++{
++    if (!ppColor)
++        return;
++
++    USHORT nIx;
++    if (eType & NUMBERFORMAT_TEXT)
++        nIx = 0;
++    else if (NumFor[3].GetnAnz() > 0)
++        nIx = 3;
++    else
++    {
++        *ppColor = NULL;        // no change of color
++        return;
++    }
++    *ppColor = NumFor[nIx].GetColor();
++}
++
+ /*
+ void SvNumberformat::GetNextFareyNumber(ULONG nPrec, ULONG x0, ULONG x1,
+                                         ULONG y0, ULONG y1,


More information about the ooo-build-commit mailing list