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