Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Brothers & sisters in LibO :)

Can some1 please review the attached patch? It fixes fdo#36673 (one of the 
most annoying ones), which is a regression from 3.3. Some data in cells 
formatted using certain date formats are lost, since the default date format 
is used instead. The issue affects all locale :(

The regression was introduced by commit b0e90c6561dcf3 which adds two new 
fraction number formats. Unfortunately, new num. formats can't be added ad-hoc 
like that, since NfIndexTableOffset enum in 'svl/inc/svl/zforlist.hxx' and 
locale XML files in 'i18npool/source/localedata/data/*.xml are interconnected  
(and I learned that the hard way).  
Changing the former means that we'd have to adjust the latter ... and ehm ... 
I guess we don't really want to do that as there are some integrity checks for 
locale files and this would effectively make them not pass anymore.

I'm not really proud of the code, especially not of this bit:

ImpInsertNewStandardFormat( aSingleFormatCode, nPos+1, 
SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS )

since we're not defining any standard here. But the "standard" bit seems to be 
necessary for Calc to pick up a format that is neither within the boundaries 
set by NfIndexTableOffset nor defined by locale XML file in i18npool. Few 
lines below  ( in SvNumberFormatter::ImpGenerateAdditionalFormats() ) similar 
code is used to collect any optional formats defined by locale.

Alternatively, if we want to retain the two new fraction formats (and I gather 
we do, because of Excel compatibility), they can be added into locale XML 
files. But that would mean editing ... uhm ... ~200 files, so it's certainly 
nothing for 3.4

Thx for feedback

frozenB.
-- 
  \\\\\              Katarina Machalkova    
  \\\\\\\__o          LibO developer
__\\\\\\\'/_          & hedgehog painter
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx
index fe5a966..eef1904 100644
--- a/svl/inc/svl/zforlist.hxx
+++ b/svl/inc/svl/zforlist.hxx
@@ -129,9 +129,7 @@ enum NfIndexTableOffset
     NF_FRACTION_START,
     NF_FRACTION_1 = NF_FRACTION_START,         // # ?/?
     NF_FRACTION_2,                                                     // # ??/??
-    NF_FRACTION_3,                          // # ?/4
-    NF_FRACTION_4,                          // # ??/100
-    NF_FRACTION_END = NF_FRACTION_4,
+    NF_FRACTION_END = NF_FRACTION_2,
 
     NF_NUMERIC_END = NF_FRACTION_END,
 
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index dac2139..ae7cfae 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2594,7 +2594,6 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, sal_Bool 
bLoadi
 
      // # ?/?
     aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?/?" ) );
-    String s25( RTL_CONSTASCII_USTRINGPARAM( "# ?/?" ) );                      // # ?/?
     ImpInsertFormat( aSingleFormatCode,
         CLOffset + SetIndexTable( NF_FRACTION_1, ZF_STANDARD_FRACTION ));
 
@@ -2604,14 +2603,6 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, sal_Bool 
bLoadi
     ImpInsertFormat( aSingleFormatCode,
         CLOffset + SetIndexTable( NF_FRACTION_2, ZF_STANDARD_FRACTION+1 ));
 
-    aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?/4" ) );
-    ImpInsertFormat( aSingleFormatCode,
-        CLOffset + SetIndexTable( NF_FRACTION_3, ZF_STANDARD_FRACTION+2 ));
-
-    aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?\?/100" ) );
-    ImpInsertFormat( aSingleFormatCode,
-        CLOffset + SetIndexTable( NF_FRACTION_4, ZF_STANDARD_FRACTION+3 ));
-
     // Week of year   must be appended here because of nNewExtended
     const String* pKeyword = pFormatScanner->GetKeywords();
     aSingleFormatCode.Code = pKeyword[NF_KEY_WW];
@@ -2630,6 +2621,18 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, sal_Bool 
bLoadi
     if ( !bLoadingSO5 )
         ImpGenerateAdditionalFormats( CLOffset, aNumberFormatCode, sal_False );
 
+    sal_uInt32 nPos = CLOffset + pStdFormat->GetLastInsertKey();
+
+    aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?/4" ) );
+    ImpInsertNewStandardFormat( aSingleFormatCode, nPos+1, 
SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS );
+    nPos++;
+
+    aSingleFormatCode.Code = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "# ?\?/100" ) );
+    ImpInsertNewStandardFormat( aSingleFormatCode, nPos+1, 
SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS );
+    nPos++;
+
+    pStdFormat->SetLastInsertKey( (sal_uInt16)(nPos - CLOffset) );
+
     if (bOldConvertMode)
         pFormatScanner->SetConvertMode(sal_True);
 }

Attachment: signature.asc
Description: This is a digitally signed message part.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.