KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
4.7KB

  1. #include "kspread_locale.h"
  2. #include <tqdom.h>
  3. using namespace KSpread;
  4. Locale::Locale()
  5. : TDELocale("kspread")
  6. {
  7. insertCatalogue("koffice");
  8. }
  9. void Locale::load( const TQDomElement& element )
  10. {
  11. if ( element.hasAttribute( "weekStartsMonday" ) )
  12. {
  13. TQString c = element.attribute( "weekStartsMonday" );
  14. if ( c != "False")
  15. {
  16. setWeekStartDay( 1 /*Monday*/ );
  17. }
  18. }
  19. if ( element.hasAttribute( "decimalSymbol" ) )
  20. setDecimalSymbol( element.attribute( "decimalSymbol" ) );
  21. if ( element.hasAttribute( "thousandsSeparator" ) )
  22. setThousandsSeparator( element.attribute( "thousandsSeparator" ) );
  23. if ( element.hasAttribute( "currencySymbol" ) )
  24. setCurrencySymbol( element.attribute( "currencySymbol" ) );
  25. if ( element.hasAttribute( "monetaryDecimalSymbol" ) )
  26. setMonetaryDecimalSymbol( element.attribute( "monetaryDecimalSymbol" ) );
  27. if ( element.hasAttribute( "monetaryThousandsSeparator" ) )
  28. setMonetaryThousandsSeparator( element.attribute( "monetaryThousandsSeparator" ) );
  29. if ( element.hasAttribute( "positiveSign" ) )
  30. setPositiveSign( element.attribute( "positiveSign" ) );
  31. if ( element.hasAttribute( "negativeSign" ) )
  32. setNegativeSign( element.attribute( "negativeSign" ) );
  33. if ( element.hasAttribute( "fracDigits" ) )
  34. setFracDigits( element.attribute( "fracDigits" ).toInt() );
  35. if ( element.hasAttribute( "positivePrefixCurrencySymbol" ) )
  36. {
  37. TQString c = element.attribute( "positivePrefixCurrencySymbol" );
  38. setPositivePrefixCurrencySymbol( c == "True" );
  39. }
  40. if ( element.hasAttribute( "negativePrefixCurrencySymbol" ) )
  41. {
  42. TQString c = element.attribute( "negativePrefixCurrencySymbol" );
  43. setNegativePrefixCurrencySymbol( c == "True" );
  44. }
  45. if ( element.hasAttribute( "positiveMonetarySignPosition" ) )
  46. setPositiveMonetarySignPosition( (SignPosition)element.attribute( "positiveMonetarySignPosition" ).toInt() );
  47. if ( element.hasAttribute( "negativeMonetarySignPosition" ) )
  48. setNegativeMonetarySignPosition( (SignPosition)element.attribute( "negativeMonetarySignPosition" ).toInt() );
  49. if ( element.hasAttribute( "timeFormat" ) )
  50. setTimeFormat( element.attribute( "timeFormat" ) );
  51. if ( element.hasAttribute( "dateFormat" ) )
  52. setDateFormat( element.attribute( "dateFormat" ) );
  53. if ( element.hasAttribute( "dateFormatShort" ) )
  54. setDateFormatShort( element.attribute( "dateFormatShort" ) );
  55. }
  56. TQDomElement Locale::save( TQDomDocument& doc ) const
  57. {
  58. TQDomElement element = doc.createElement( "locale" );
  59. element.setAttribute( "weekStartsMonday", (weekStartDay() == 1) ? "True" : "False" );
  60. element.setAttribute( "decimalSymbol", decimalSymbol() );
  61. element.setAttribute( "thousandsSeparator", thousandsSeparator() );
  62. element.setAttribute( "currencySymbol", currencySymbol() );
  63. element.setAttribute( "monetaryDecimalSymbol", monetaryDecimalSymbol() );
  64. element.setAttribute( "monetaryThousandsSeparator", monetaryThousandsSeparator() );
  65. element.setAttribute( "positiveSign", positiveSign() );
  66. element.setAttribute( "negativeSign", negativeSign() );
  67. element.setAttribute( "fracDigits", fracDigits() );
  68. element.setAttribute( "positivePrefixCurrencySymbol", positivePrefixCurrencySymbol() ? "True" : "False");
  69. element.setAttribute( "negativePrefixCurrencySymbol", negativePrefixCurrencySymbol() ? "True" : "False");
  70. element.setAttribute( "positiveMonetarySignPosition", (int)positiveMonetarySignPosition() );
  71. element.setAttribute( "negativeMonetarySignPosition", (int)negativeMonetarySignPosition() );
  72. element.setAttribute( "timeFormat", timeFormat() );
  73. element.setAttribute( "dateFormat", dateFormat() );
  74. element.setAttribute( "dateFormatShort", dateFormatShort() );
  75. return element;
  76. }
  77. void Locale::defaultSystemConfig( )
  78. {
  79. TDELocale locale("kspread");
  80. setWeekStartDay( locale.weekStartDay() );
  81. setDecimalSymbol( locale.decimalSymbol());
  82. setThousandsSeparator( locale.thousandsSeparator() );
  83. setCurrencySymbol( locale.currencySymbol() );
  84. setMonetaryDecimalSymbol( locale.monetaryDecimalSymbol() );
  85. setMonetaryThousandsSeparator( locale.monetaryThousandsSeparator());
  86. setPositiveSign( locale.positiveSign() );
  87. setNegativeSign( locale.negativeSign() );
  88. setFracDigits( locale.fracDigits() );
  89. setPositivePrefixCurrencySymbol( locale.positivePrefixCurrencySymbol() );
  90. setNegativePrefixCurrencySymbol( locale.negativePrefixCurrencySymbol() );
  91. setPositiveMonetarySignPosition( locale.positiveMonetarySignPosition() );
  92. setNegativeMonetarySignPosition( locale.negativeMonetarySignPosition() );
  93. setTimeFormat( locale.timeFormat() );
  94. setDateFormat( locale.dateFormat() );
  95. setDateFormatShort( locale.dateFormatShort() );
  96. }