kspread

kspread_locale.cc

00001 #include "kspread_locale.h"
00002 
00003 #include <qdom.h>
00004 
00005 using namespace KSpread;
00006 
00007 Locale::Locale()
00008     : KLocale("kspread")
00009 {
00010     insertCatalogue("koffice");
00011 }
00012 
00013 void Locale::load( const QDomElement& element )
00014 {
00015     if ( element.hasAttribute( "weekStartsMonday" ) )
00016     {
00017     QString c = element.attribute( "weekStartsMonday" );
00018         if ( c != "False")
00019         {
00020           setWeekStartDay( 1 /*Monday*/ );
00021         }
00022     }
00023     if ( element.hasAttribute( "decimalSymbol" ) )
00024     setDecimalSymbol( element.attribute( "decimalSymbol" ) );
00025     if ( element.hasAttribute( "thousandsSeparator" ) )
00026     setThousandsSeparator( element.attribute( "thousandsSeparator" ) );
00027     if ( element.hasAttribute( "currencySymbol" ) )
00028     setCurrencySymbol( element.attribute( "currencySymbol" ) );
00029     if ( element.hasAttribute( "monetaryDecimalSymbol" ) )
00030     setMonetaryDecimalSymbol( element.attribute( "monetaryDecimalSymbol" ) );
00031     if ( element.hasAttribute( "monetaryThousandsSeparator" ) )
00032     setMonetaryThousandsSeparator( element.attribute( "monetaryThousandsSeparator" ) );
00033     if ( element.hasAttribute( "positiveSign" ) )
00034     setPositiveSign( element.attribute( "positiveSign" ) );
00035     if ( element.hasAttribute( "negativeSign" ) )
00036     setNegativeSign( element.attribute( "negativeSign" ) );
00037     if ( element.hasAttribute( "fracDigits" ) )
00038     setFracDigits( element.attribute( "fracDigits" ).toInt() );
00039     if ( element.hasAttribute( "positivePrefixCurrencySymbol" ) )
00040     {
00041     QString c = element.attribute( "positivePrefixCurrencySymbol" );
00042         setPositivePrefixCurrencySymbol( c == "True" );
00043     }
00044     if ( element.hasAttribute( "negativePrefixCurrencySymbol" ) )
00045     {
00046     QString c = element.attribute( "negativePrefixCurrencySymbol" );
00047     setNegativePrefixCurrencySymbol( c == "True" );
00048     }
00049     if ( element.hasAttribute( "positiveMonetarySignPosition" ) )
00050     setPositiveMonetarySignPosition( (SignPosition)element.attribute( "positiveMonetarySignPosition" ).toInt() );
00051     if ( element.hasAttribute( "negativeMonetarySignPosition" ) )
00052     setNegativeMonetarySignPosition( (SignPosition)element.attribute( "negativeMonetarySignPosition" ).toInt() );
00053     if ( element.hasAttribute( "timeFormat" ) )
00054     setTimeFormat( element.attribute( "timeFormat" ) );
00055     if ( element.hasAttribute( "dateFormat" ) )
00056     setDateFormat( element.attribute( "dateFormat" ) );
00057     if ( element.hasAttribute( "dateFormatShort" ) )
00058     setDateFormatShort( element.attribute( "dateFormatShort" ) );
00059 }
00060 
00061 QDomElement Locale::save( QDomDocument& doc ) const
00062 {
00063     QDomElement element = doc.createElement( "locale" );
00064 
00065     element.setAttribute( "weekStartsMonday", (weekStartDay() == 1) ? "True" : "False" );
00066     element.setAttribute( "decimalSymbol", decimalSymbol() );
00067     element.setAttribute( "thousandsSeparator", thousandsSeparator() );
00068     element.setAttribute( "currencySymbol", currencySymbol() );
00069     element.setAttribute( "monetaryDecimalSymbol", monetaryDecimalSymbol() );
00070     element.setAttribute( "monetaryThousandsSeparator", monetaryThousandsSeparator() );
00071     element.setAttribute( "positiveSign", positiveSign() );
00072     element.setAttribute( "negativeSign", negativeSign() );
00073     element.setAttribute( "fracDigits", fracDigits() );
00074     element.setAttribute( "positivePrefixCurrencySymbol", positivePrefixCurrencySymbol() ? "True" : "False");
00075     element.setAttribute( "negativePrefixCurrencySymbol", negativePrefixCurrencySymbol() ? "True" : "False");
00076     element.setAttribute( "positiveMonetarySignPosition", (int)positiveMonetarySignPosition() );
00077     element.setAttribute( "negativeMonetarySignPosition", (int)negativeMonetarySignPosition() );
00078     element.setAttribute( "timeFormat", timeFormat() );
00079     element.setAttribute( "dateFormat", dateFormat() );
00080     element.setAttribute( "dateFormatShort", dateFormatShort() );
00081 
00082     return element;
00083 }
00084 
00085 void Locale::defaultSystemConfig( )
00086 {
00087     KLocale locale("kspread");
00088     setWeekStartDay( locale.weekStartDay() );
00089     setDecimalSymbol( locale.decimalSymbol());
00090     setThousandsSeparator( locale.thousandsSeparator() );
00091     setCurrencySymbol( locale.currencySymbol() );
00092     setMonetaryDecimalSymbol( locale.monetaryDecimalSymbol() );
00093     setMonetaryThousandsSeparator( locale.monetaryThousandsSeparator());
00094     setPositiveSign( locale.positiveSign() );
00095     setNegativeSign( locale.negativeSign() );
00096     setFracDigits( locale.fracDigits() );
00097     setPositivePrefixCurrencySymbol( locale.positivePrefixCurrencySymbol() );
00098     setNegativePrefixCurrencySymbol( locale.negativePrefixCurrencySymbol() );
00099     setPositiveMonetarySignPosition( locale.positiveMonetarySignPosition() );
00100     setNegativeMonetarySignPosition( locale.negativeMonetarySignPosition() );
00101     setTimeFormat( locale.timeFormat() );
00102     setDateFormat( locale.dateFormat() );
00103     setDateFormatShort( locale.dateFormatShort() );
00104 
00105 }
00106 
KDE Home | KDE Accessibility Home | Description of Access Keys