You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dm...@apache.org on 2004/03/10 21:45:30 UTC
cvs commit: xml-xalan/c/src/xalanc/PlatformSupport XalanDecimalFormatSymbols.cpp
dmitryh 2004/03/10 12:45:30
Modified: c/src/xalanc/ICUBridge ICUFormatNumberFunctor.cpp
ICUFormatNumberFunctor.hpp
c/src/xalanc/PlatformSupport XalanDecimalFormatSymbols.cpp
Log:
Fix for 13 numberformat test failures
Revision Changes Path
1.3 +75 -3 xml-xalan/c/src/xalanc/ICUBridge/ICUFormatNumberFunctor.cpp
Index: ICUFormatNumberFunctor.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/ICUBridge/ICUFormatNumberFunctor.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ICUFormatNumberFunctor.cpp 26 Feb 2004 23:07:12 -0000 1.2
+++ ICUFormatNumberFunctor.cpp 10 Mar 2004 20:45:30 -0000 1.3
@@ -146,16 +146,20 @@
XalanDOMString& theResult,
const XalanDecimalFormatSymbols* theDFS) const
{
+
if (theDFS == 0)
{
return doICUFormat(theNumber,thePattern,theResult);
}
+ XalanDOMString nonLocalPattern = UnlocalizePatternFunctor(*theDFS)(thePattern);
+
+
DecimalFormatType* theFormatter = getCachedDecimalFormat(*theDFS);
if (theFormatter != 0)
{
- return doICUFormat(theNumber, thePattern, theResult, theFormatter);
+ return doICUFormat(theNumber, nonLocalPattern, theResult, theFormatter);
}
else
{
@@ -170,11 +174,11 @@
// will be controlled by the cache...
DecimalFormatType * theDecimalFormat = theDecimalFormatGuard.release();
- return doICUFormat(theNumber, thePattern, theResult, theDecimalFormat);
+ return doICUFormat(theNumber, nonLocalPattern, theResult, theDecimalFormat);
}
else
{
- return doICUFormat(theNumber,thePattern,theResult);
+ return doICUFormat(theNumber,nonLocalPattern,theResult);
}
}
}
@@ -292,6 +296,74 @@
return U_SUCCESS(theStatus);
}
+XalanDOMString
+ICUFormatNumberFunctor::UnlocalizePatternFunctor::operator()(const XalanDOMString& thePattern) const
+{
+ XalanDOMString theResult;
+
+ XalanDecimalFormatSymbols defaultDFS;
+
+ XalanDOMString::const_iterator iterator = thePattern.begin();
+ while( iterator != thePattern.end())
+ {
+
+ if( m_DFS.getDecimalSeparator() == *iterator )
+ {
+ theResult.push_back(defaultDFS.getDecimalSeparator());
+ }
+ else if(m_DFS.getDigit() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getDigit());
+ }
+ else if(m_DFS.getGroupingSeparator() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getGroupingSeparator());
+ }
+ else if(m_DFS.getMinusSign() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getMinusSign());
+ }
+ else if(m_DFS.getPatternSeparator() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getPatternSeparator());
+ }
+ else if(m_DFS.getPercent() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getPercent());
+ }
+ else if(m_DFS.getPerMill() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getPerMill());
+ }
+ else if(m_DFS.getZeroDigit() == *iterator)
+ {
+ theResult.push_back(defaultDFS.getZeroDigit());
+ }
+ else
+ {
+ switch(*iterator)
+ {
+ case XalanUnicode::charFullStop:
+ case XalanUnicode::charNumberSign:
+ case XalanUnicode::charComma:
+ case XalanUnicode::charHyphenMinus:
+ case XalanUnicode::charSemicolon:
+ case XalanUnicode::charPercentSign:
+ case XalanUnicode::charPerMilleSign:
+ case XalanUnicode::charDigit_0:
+ {
+ theResult.push_back(XalanUnicode::charAmpersand);
+ theResult.push_back(*iterator);
+ theResult.push_back(XalanUnicode::charAmpersand);
+ }
+ }
+ }
+
+ iterator++;
+ }
+
+ return theResult;
+}
XALAN_CPP_NAMESPACE_END
1.3 +16 -0 xml-xalan/c/src/xalanc/ICUBridge/ICUFormatNumberFunctor.hpp
Index: ICUFormatNumberFunctor.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/ICUBridge/ICUFormatNumberFunctor.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ICUFormatNumberFunctor.hpp 26 Feb 2004 23:07:12 -0000 1.2
+++ ICUFormatNumberFunctor.hpp 10 Mar 2004 20:45:30 -0000 1.3
@@ -72,6 +72,22 @@
#else
typedef DecimalFormat DecimalFormatType;
#endif
+
+ class UnlocalizePatternFunctor
+ {
+ public:
+ UnlocalizePatternFunctor(const XalanDecimalFormatSymbols& theDFS):
+ m_DFS(theDFS)
+ {
+ }
+
+ XalanDOMString
+ operator()(const XalanDOMString& thePattern) const;
+
+ private:
+ const XalanDecimalFormatSymbols& m_DFS;
+ };
+
struct DecimalFormatCacheStruct
{
DecimalFormatCacheStruct(
1.5 +1 -1 xml-xalan/c/src/xalanc/PlatformSupport/XalanDecimalFormatSymbols.cpp
Index: XalanDecimalFormatSymbols.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/PlatformSupport/XalanDecimalFormatSymbols.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XalanDecimalFormatSymbols.cpp 26 Feb 2004 22:34:18 -0000 1.4
+++ XalanDecimalFormatSymbols.cpp 10 Mar 2004 20:45:30 -0000 1.5
@@ -59,7 +59,7 @@
XalanDecimalFormatSymbols::XalanDecimalFormatSymbols() :
m_currencySymbol(theCurrencySymbol),
m_decimalSeparator(XalanUnicode::charFullStop),
- m_digit(0),
+ m_digit(XalanUnicode::charNumberSign),
m_groupingSeparator(XalanUnicode::charComma),
m_infinity(theInfinityDefault),
m_internationalCurrencySymbol(),
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org