/src/libetonyek/src/lib/contexts/IWORKFormatElement.cpp
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* |
3 | | * This file is part of the libetonyek project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #include <deque> |
11 | | |
12 | | #include "IWORKFormatElement.h" |
13 | | |
14 | | #include "IWORKContainerContext.h" |
15 | | #include "IWORKDictionary.h" |
16 | | #include "IWORKNumberConverter.h" |
17 | | #include "IWORKProperties.h" |
18 | | #include "IWORKRefContext.h" |
19 | | #include "IWORKToken.h" |
20 | | #include "IWORKXMLParserState.h" |
21 | | |
22 | | #include "libetonyek_utils.h" |
23 | | #include "libetonyek_xml.h" |
24 | | |
25 | | namespace libetonyek |
26 | | { |
27 | | |
28 | | using boost::optional; |
29 | | |
30 | | IWORKDateTimeFormatElement::IWORKDateTimeFormatElement(IWORKXMLParserState &state, optional<IWORKDateTimeFormat> &value) |
31 | 0 | : IWORKXMLEmptyContextBase(state) |
32 | 0 | , m_value(value) |
33 | 0 | { |
34 | 0 | m_value=IWORKDateTimeFormat(); |
35 | 0 | } |
36 | | |
37 | | void IWORKDateTimeFormatElement::attribute(const int name, const char *const value) |
38 | 0 | { |
39 | 0 | switch (name) |
40 | 0 | { |
41 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::fmt: |
42 | 0 | get(m_value).m_format = value; |
43 | 0 | break; |
44 | 0 | case +IWORKToken::NS_URI_SFA | IWORKToken::ID : |
45 | 0 | IWORKXMLEmptyContextBase::attribute(name, value); |
46 | 0 | break; |
47 | 0 | default: |
48 | 0 | ETONYEK_DEBUG_MSG(("DateTimeFormatElement::attribute[IWORKPropertyMapElement.cpp]: find unknown attribute\n")); |
49 | 0 | } |
50 | 0 | } |
51 | | |
52 | | void IWORKDateTimeFormatElement::endOfElement() |
53 | 0 | { |
54 | 0 | if (getId()) |
55 | 0 | getState().getDictionary().m_dateTimeFormats.insert(IWORKDateTimeFormatMap_t::value_type(get(getId()),get(m_value))); |
56 | 0 | } |
57 | | |
58 | | ///////////////////////////// |
59 | | IWORKDurationFormatElement::IWORKDurationFormatElement(IWORKXMLParserState &state, optional<IWORKDurationFormat> &value) |
60 | 0 | : IWORKXMLEmptyContextBase(state) |
61 | 0 | , m_value(value) |
62 | 0 | { |
63 | 0 | m_value=IWORKDurationFormat(); |
64 | 0 | } |
65 | | |
66 | | void IWORKDurationFormatElement::attribute(const int name, const char *const value) |
67 | 0 | { |
68 | 0 | switch (name) |
69 | 0 | { |
70 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::fmt: |
71 | 0 | get(m_value).m_format = value; |
72 | 0 | break; |
73 | 0 | case +IWORKToken::NS_URI_SFA | IWORKToken::ID : |
74 | 0 | IWORKXMLEmptyContextBase::attribute(name, value); |
75 | 0 | break; |
76 | 0 | default: |
77 | 0 | ETONYEK_DEBUG_MSG(("DurationFormatElement::attribute[IWORKPropertyMapElement.cpp]: find unknown attribute\n")); |
78 | 0 | } |
79 | 0 | } |
80 | | |
81 | | void IWORKDurationFormatElement::endOfElement() |
82 | 0 | { |
83 | 0 | if (getId()) |
84 | 0 | getState().getDictionary().m_durationFormats.insert(IWORKDurationFormatMap_t::value_type(get(getId()),get(m_value))); |
85 | 0 | } |
86 | | |
87 | | ///////////////////////////// |
88 | | IWORKNumberFormatElement::IWORKNumberFormatElement(IWORKXMLParserState &state, optional<IWORKNumberFormat> &value) |
89 | 0 | : IWORKXMLEmptyContextBase(state) |
90 | 0 | , m_value(value) |
91 | 0 | { |
92 | 0 | m_value=IWORKNumberFormat(); |
93 | 0 | } |
94 | | |
95 | | void IWORKNumberFormatElement::attribute(const int name, const char *const value) |
96 | 0 | { |
97 | 0 | switch (name) |
98 | 0 | { |
99 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_base : |
100 | 0 | get(m_value).m_base = int_cast(value); |
101 | 0 | break; |
102 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_base_places : |
103 | 0 | get(m_value).m_basePlaces = int_cast(value); |
104 | 0 | break; |
105 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_base_use_minus_sign : |
106 | 0 | get(m_value).m_baseUseMinusSign = bool_cast(value); |
107 | 0 | break; |
108 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_currency_code : |
109 | 0 | get(m_value).m_currencyCode = value; |
110 | 0 | break; |
111 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_decimal_places : |
112 | 0 | get(m_value).m_decimalPlaces = int_cast(value); |
113 | 0 | break; |
114 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_fraction_accuracy : |
115 | 0 | get(m_value).m_fractionAccuracy = int_cast(value); |
116 | 0 | break; |
117 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_negative_style : |
118 | 0 | get(m_value).m_negativeStyle = int_cast(value); |
119 | 0 | break; |
120 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_show_thousands_separator : |
121 | 0 | get(m_value).m_thousandsSeparator = bool_cast(value); |
122 | 0 | break; |
123 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_string : |
124 | 0 | get(m_value).m_string = value; |
125 | 0 | break; |
126 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_type : |
127 | 0 | get(m_value).m_type = get(IWORKNumberConverter<IWORKCellNumberType>::convert(value)); |
128 | 0 | break; |
129 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_use_accounting_style : |
130 | 0 | get(m_value).m_accountingStyle = bool_cast(value); |
131 | 0 | break; |
132 | 0 | case +IWORKToken::NS_URI_SFA | IWORKToken::ID : |
133 | 0 | IWORKXMLEmptyContextBase::attribute(name, value); |
134 | 0 | break; |
135 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::custom : |
136 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::format_name : |
137 | 0 | break; |
138 | 0 | default: |
139 | 0 | ETONYEK_DEBUG_MSG(("IWORKNumberFormatElement::attribute[IWORKFormatElement.cpp]: find unknown attribute\n")); |
140 | 0 | } |
141 | 0 | } |
142 | | |
143 | | void IWORKNumberFormatElement::endOfElement() |
144 | 0 | { |
145 | 0 | if (getId()) |
146 | 0 | getState().getDictionary().m_numberFormats.insert(IWORKNumberFormatMap_t::value_type(get(getId()),get(m_value))); |
147 | 0 | } |
148 | | |
149 | | } |
150 | | |
151 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |