Rev 9672 | Rev 20691 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
415 | Franz | 7 | /*************************************************************************** |
8 | * Copyright (C) 2004 by Riku Leino * |
||
1184 | tsoots | 9 | * tsoots@gmail.com * |
415 | Franz | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | * This program is distributed in the hope that it will be useful, * |
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
19 | * GNU General Public License for more details. * |
||
20 | * * |
||
21 | * You should have received a copy of the GNU General Public License * |
||
22 | * along with this program; if not, write to the * |
||
23 | * Free Software Foundation, Inc., * |
||
18122 | mrdocs | 24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
415 | Franz | 25 | ***************************************************************************/ |
26 | |||
27 | #include "prefsreader.h" |
||
28 | |||
29 | PrefsReader::PrefsReader(ContextMap *appContexts, ContextMap *pluginContexts) |
||
30 | { |
||
31 | aContexts = appContexts; |
||
32 | pContexts = pluginContexts; |
||
33 | inApp = false; |
||
34 | rowIndex = 0; |
||
35 | colIndex = 0; |
||
36 | inTable = false; |
||
37 | } |
||
38 | |||
39 | bool PrefsReader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs) |
||
40 | { |
||
41 | if (name == "context") |
||
42 | { |
||
43 | for (int i = 0; i < attrs.count(); ++i) |
||
44 | if (attrs.localName(i) == "name") |
||
45 | currentContext = new PrefsContext(attrs.value(i)); |
||
46 | } |
||
47 | else if (name == "level") |
||
48 | { |
||
49 | bool found = false; |
||
50 | for (int i = 0; i < attrs.count(); ++i) |
||
51 | if ((attrs.localName(i) == "name") && (attrs.value(i) == "application")) |
||
52 | found = true; |
||
53 | inApp = found; |
||
54 | } |
||
55 | else if (name == "attribute") |
||
56 | { |
||
57 | QString key = ""; |
||
58 | QString value = ""; |
||
59 | for (int i = 0; i < attrs.count(); ++i) |
||
60 | { |
||
61 | if (attrs.localName(i) == "key") |
||
62 | key = attrs.value(i); |
||
63 | else if (attrs.localName(i) == "value") |
||
64 | value = attrs.value(i); |
||
65 | } |
||
66 | currentContext->set(key, value); |
||
67 | } |
||
68 | else if (name == "table") |
||
69 | { |
||
70 | for (int i = 0; i < attrs.count(); ++i) |
||
71 | { |
||
72 | if (attrs.localName(i) == "name") |
||
73 | currentTable = currentContext->getTable(attrs.value(i)); |
||
74 | } |
||
75 | } |
||
76 | else if (name == "col") |
||
77 | inTable = true; |
||
78 | |||
79 | return true; |
||
80 | } |
||
81 | |||
82 | bool PrefsReader::characters (const QString& ch) |
||
83 | { |
||
84 | if (inTable) |
||
85 | currentTable->set(rowIndex, colIndex, ch); |
||
86 | return true; |
||
87 | } |
||
88 | |||
89 | bool PrefsReader::endElement(const QString&, const QString&, const QString &name) |
||
90 | { |
||
91 | if (name == "context") |
||
92 | { |
||
93 | if (inApp) |
||
94 | (*aContexts)[currentContext->getName()] = currentContext; |
||
95 | else |
||
96 | (*pContexts)[currentContext->getName()] = currentContext; |
||
97 | } |
||
98 | else if (name == "row") |
||
99 | { |
||
100 | ++rowIndex; |
||
101 | colIndex = 0; |
||
102 | } |
||
103 | else if (name == "col") |
||
104 | { |
||
105 | ++colIndex; |
||
106 | inTable = false; |
||
107 | } |
||
108 | else if (name == "table") |
||
109 | { |
||
110 | rowIndex = 0; |
||
111 | colIndex = 0; |
||
112 | } |
||
113 | return true; |
||
114 | } |
||
115 | |||
116 | PrefsReader::~PrefsReader() |
||
117 | { |
||
118 | |||
119 | } |