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 <kdeversion.h>
24#include <QDomDocument>
25
26using namespace Calligra::Sheets;
27
28Localization::Localization()
29 : KLocale("calligra")
30{
31 insertCatalog("calligra");
32}
33
34void Localization::load(const KoXmlElement& element)
35{
36 if (element.hasAttribute("weekStartsMonday")) {
37 QString c = element.attribute("weekStartsMonday");
38 if (c != "False") {
39 setWeekStartDay(1 /*Monday*/);
40 }
41 }
42 if (element.hasAttribute("decimalSymbol"))
43 setDecimalSymbol(element.attribute("decimalSymbol"));
44 if (element.hasAttribute("thousandsSeparator"))
45 setThousandsSeparator(element.attribute("thousandsSeparator"));
46 if (element.hasAttribute("currencySymbol"))
47 setCurrencySymbol(element.attribute("currencySymbol"));
48 if (element.hasAttribute("monetaryDecimalSymbol"))
49 setMonetaryDecimalSymbol(element.attribute("monetaryDecimalSymbol"));
50 if (element.hasAttribute("monetaryThousandsSeparator"))
51 setMonetaryThousandsSeparator(element.attribute("monetaryThousandsSeparator"));
52 if (element.hasAttribute("positiveSign"))
53 setPositiveSign(element.attribute("positiveSign"));
54 if (element.hasAttribute("negativeSign"))
55 setNegativeSign(element.attribute("negativeSign"));
56 if (element.hasAttribute("fracDigits"))
57 setMonetaryDecimalPlaces(element.attribute("fracDigits").toInt());
58 if (element.hasAttribute("positivePrefixCurrencySymbol")) {
59 QString c = element.attribute("positivePrefixCurrencySymbol");
60 setPositivePrefixCurrencySymbol(c == "True");
61 }
62 if (element.hasAttribute("negativePrefixCurrencySymbol")) {
63 QString c = element.attribute("negativePrefixCurrencySymbol");
64 setNegativePrefixCurrencySymbol(c == "True");
65 }
66 if (element.hasAttribute("positiveMonetarySignPosition"))
67 setPositiveMonetarySignPosition((SignPosition)element.attribute("positiveMonetarySignPosition").toInt());
68 if (element.hasAttribute("negativeMonetarySignPosition"))
69 setNegativeMonetarySignPosition((SignPosition)element.attribute("negativeMonetarySignPosition").toInt());
70 if (element.hasAttribute("timeFormat"))
71 setTimeFormat(element.attribute("timeFormat"));
72 if (element.hasAttribute("dateFormat"))
73 setDateFormat(element.attribute("dateFormat"));
74 if (element.hasAttribute("dateFormatShort"))
75 setDateFormatShort(element.attribute("dateFormatShort"));
76}
77
78QDomElement Localization::save(QDomDocument& doc) const
79{
80 QDomElement element = doc.createElement("locale");
81
82 element.setAttribute("weekStartsMonday", (weekStartDay() == 1) ? "True" : "False");
83 element.setAttribute("decimalSymbol", decimalSymbol());
84 element.setAttribute("thousandsSeparator", thousandsSeparator());
85 element.setAttribute("currencySymbol", currencySymbol());
86 element.setAttribute("monetaryDecimalSymbol", monetaryDecimalSymbol());
87 element.setAttribute("monetaryThousandsSeparator", monetaryThousandsSeparator());
88 element.setAttribute("positiveSign", positiveSign());
89 element.setAttribute("negativeSign", negativeSign());
90 element.setAttribute("fracDigits", monetaryDecimalPlaces());
91 element.setAttribute("positivePrefixCurrencySymbol", positivePrefixCurrencySymbol() ? "True" : "False");
92 element.setAttribute("negativePrefixCurrencySymbol", negativePrefixCurrencySymbol() ? "True" : "False");
93 element.setAttribute("positiveMonetarySignPosition", (int)positiveMonetarySignPosition());
94 element.setAttribute("negativeMonetarySignPosition", (int)negativeMonetarySignPosition());
95 element.setAttribute("timeFormat", timeFormat());
96 element.setAttribute("dateFormat", dateFormat());
97 element.setAttribute("dateFormatShort", dateFormatShort());
98
99 return element;
100}
101
102void Localization::defaultSystemConfig()
103{
104 KLocale locale("sheets");
105 setWeekStartDay(locale.weekStartDay());
106 setDecimalSymbol(locale.decimalSymbol());
107 setThousandsSeparator(locale.thousandsSeparator());
108 setCurrencySymbol(locale.currencySymbol());
109 setMonetaryDecimalSymbol(locale.monetaryDecimalSymbol());
110 setMonetaryThousandsSeparator(locale.monetaryThousandsSeparator());
111 setPositiveSign(locale.positiveSign());
112 setNegativeSign(locale.negativeSign());
113 setMonetaryDecimalPlaces(locale.monetaryDecimalPlaces());
114 setDecimalPlaces(locale.decimalPlaces());
115 setPositivePrefixCurrencySymbol(locale.positivePrefixCurrencySymbol());
116 setNegativePrefixCurrencySymbol(locale.negativePrefixCurrencySymbol());
117 setPositiveMonetarySignPosition(locale.positiveMonetarySignPosition());
118 setNegativeMonetarySignPosition(locale.negativeMonetarySignPosition());
119 setTimeFormat(locale.timeFormat());
120 setDateFormat(locale.dateFormat());
121 setDateFormatShort(locale.dateFormatShort());
122
123}
124
125