1 /* This file is part of the KDE project
2 Copyright (C) 2001 Laurent Montel <montel@kde.org>
3 (C) 2000 Torben Weis <weis@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */
20
21 #include "Localization.h"
22
23 #include <QDomDocument>
24
25 using namespace Calligra::Sheets;
26
Localization()27 Localization::Localization()
28 : KLocale()
29 {
30 }
31
load(const KoXmlElement & element)32 void Localization::load(const KoXmlElement& element)
33 {
34 if (element.hasAttribute("weekStartsMonday")) {
35 QString c = element.attribute("weekStartsMonday");
36 if (c != "False") {
37 setWeekStartDay(1 /*Monday*/);
38 }
39 }
40 if (element.hasAttribute("decimalSymbol"))
41 setDecimalSymbol(element.attribute("decimalSymbol"));
42 if (element.hasAttribute("thousandsSeparator"))
43 setThousandsSeparator(element.attribute("thousandsSeparator"));
44 if (element.hasAttribute("currencySymbol"))
45 setCurrencySymbol(element.attribute("currencySymbol"));
46 if (element.hasAttribute("monetaryDecimalSymbol"))
47 setMonetaryDecimalSymbol(element.attribute("monetaryDecimalSymbol"));
48 if (element.hasAttribute("monetaryThousandsSeparator"))
49 setMonetaryThousandsSeparator(element.attribute("monetaryThousandsSeparator"));
50 if (element.hasAttribute("positiveSign"))
51 setPositiveSign(element.attribute("positiveSign"));
52 if (element.hasAttribute("negativeSign"))
53 setNegativeSign(element.attribute("negativeSign"));
54 if (element.hasAttribute("fracDigits"))
55 setMonetaryDecimalPlaces(element.attribute("fracDigits").toInt());
56 if (element.hasAttribute("positivePrefixCurrencySymbol")) {
57 QString c = element.attribute("positivePrefixCurrencySymbol");
58 setPositivePrefixCurrencySymbol(c == "True");
59 }
60 if (element.hasAttribute("negativePrefixCurrencySymbol")) {
61 QString c = element.attribute("negativePrefixCurrencySymbol");
62 setNegativePrefixCurrencySymbol(c == "True");
63 }
64 if (element.hasAttribute("positiveMonetarySignPosition"))
65 setPositiveMonetarySignPosition((SignPosition)element.attribute("positiveMonetarySignPosition").toInt());
66 if (element.hasAttribute("negativeMonetarySignPosition"))
67 setNegativeMonetarySignPosition((SignPosition)element.attribute("negativeMonetarySignPosition").toInt());
68 if (element.hasAttribute("timeFormat"))
69 setTimeFormat(element.attribute("timeFormat"));
70 if (element.hasAttribute("dateFormat"))
71 setDateFormat(element.attribute("dateFormat"));
72 if (element.hasAttribute("dateFormatShort"))
73 setDateFormatShort(element.attribute("dateFormatShort"));
74 }
75
save(QDomDocument & doc) const76 QDomElement Localization::save(QDomDocument& doc) const
77 {
78 QDomElement element = doc.createElement("locale");
79
80 element.setAttribute("weekStartsMonday", (weekStartDay() == 1) ? "True" : "False");
81 element.setAttribute("decimalSymbol", decimalSymbol());
82 element.setAttribute("thousandsSeparator", thousandsSeparator());
83 element.setAttribute("currencySymbol", currencySymbol());
84 element.setAttribute("monetaryDecimalSymbol", monetaryDecimalSymbol());
85 element.setAttribute("monetaryThousandsSeparator", monetaryThousandsSeparator());
86 element.setAttribute("positiveSign", positiveSign());
87 element.setAttribute("negativeSign", negativeSign());
88 element.setAttribute("fracDigits", QString::number(monetaryDecimalPlaces()));
89 element.setAttribute("positivePrefixCurrencySymbol", positivePrefixCurrencySymbol() ? "True" : "False");
90 element.setAttribute("negativePrefixCurrencySymbol", negativePrefixCurrencySymbol() ? "True" : "False");
91 element.setAttribute("positiveMonetarySignPosition", QString::number((int)positiveMonetarySignPosition()));
92 element.setAttribute("negativeMonetarySignPosition", QString::number((int)negativeMonetarySignPosition()));
93 element.setAttribute("timeFormat", timeFormat());
94 element.setAttribute("dateFormat", dateFormat());
95 element.setAttribute("dateFormatShort", dateFormatShort());
96
97 return element;
98 }
99
defaultSystemConfig()100 void Localization::defaultSystemConfig()
101 {
102 KLocale locale("calligrasheets");
103 setWeekStartDay(locale.weekStartDay());
104 setDecimalSymbol(locale.decimalSymbol());
105 setThousandsSeparator(locale.thousandsSeparator());
106 setCurrencySymbol(locale.currencySymbol());
107 setMonetaryDecimalSymbol(locale.monetaryDecimalSymbol());
108 setMonetaryThousandsSeparator(locale.monetaryThousandsSeparator());
109 setPositiveSign(locale.positiveSign());
110 setNegativeSign(locale.negativeSign());
111 setMonetaryDecimalPlaces(locale.monetaryDecimalPlaces());
112 setDecimalPlaces(locale.decimalPlaces());
113 setPositivePrefixCurrencySymbol(locale.positivePrefixCurrencySymbol());
114 setNegativePrefixCurrencySymbol(locale.negativePrefixCurrencySymbol());
115 setPositiveMonetarySignPosition(locale.positiveMonetarySignPosition());
116 setNegativeMonetarySignPosition(locale.negativeMonetarySignPosition());
117 setTimeFormat(locale.timeFormat());
118 setDateFormat(locale.dateFormat());
119 setDateFormatShort(locale.dateFormatShort());
120
121 }
122
123