/src/libetonyek/src/lib/contexts/IWORKListLabelGeometriesProperty.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 "IWORKListLabelGeometriesProperty.h" |
11 | | |
12 | | #include "IWORKContainerContext.h" |
13 | | #include "IWORKDictionary.h" |
14 | | #include "IWORKListLabelGeometryElement.h" |
15 | | #include "IWORKMutableArrayElement.h" |
16 | | #include "IWORKPropertyMap.h" |
17 | | #include "IWORKProperties.h" |
18 | | #include "IWORKPushCollector.h" |
19 | | #include "IWORKToken.h" |
20 | | #include "IWORKXMLParserState.h" |
21 | | |
22 | | namespace libetonyek |
23 | | { |
24 | | |
25 | | namespace |
26 | | { |
27 | | |
28 | | typedef IWORKMutableArrayElement<IWORKListLabelGeometry, IWORKListLabelGeometryElement, IWORKPushCollector, IWORKToken::NS_URI_SF | IWORKToken::list_label_geometry, IWORKToken::NS_URI_SF | IWORKToken::list_label_geometry_ref> MutableArrayElement; |
29 | | } |
30 | | |
31 | | IWORKListLabelGeometriesProperty::IWORKListLabelGeometriesProperty(IWORKXMLParserState &state, IWORKPropertyMap &propMap) |
32 | 0 | : IWORKXMLElementContextBase(state) |
33 | 0 | , m_propertyMap(propMap) |
34 | 0 | , m_elements() |
35 | 0 | , m_ref() |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | IWORKXMLContextPtr_t IWORKListLabelGeometriesProperty::element(const int name) |
40 | 0 | { |
41 | 0 | switch (name) |
42 | 0 | { |
43 | 0 | case IWORKToken::NS_URI_SF | IWORKToken::array: |
44 | 0 | case IWORKToken::NS_URI_SF | IWORKToken::mutable_array : |
45 | 0 | return std::make_shared<MutableArrayElement>(getState(), getState().getDictionary().m_listLabelGeometriesArrays, |
46 | 0 | getState().getDictionary().m_listLabelGeometries, |
47 | 0 | m_elements); |
48 | 0 | case IWORKToken::NS_URI_SF | IWORKToken::array_ref: |
49 | 0 | case IWORKToken::NS_URI_SF | IWORKToken::mutable_array_ref : |
50 | 0 | return std::make_shared<IWORKRefContext>(getState(), m_ref); |
51 | 0 | default: |
52 | 0 | break; |
53 | 0 | } |
54 | 0 | ETONYEK_DEBUG_MSG(("IWORKListLabelGeometriesProperty::element: unknown element %d\n", name)); |
55 | 0 | return IWORKXMLContextPtr_t(); |
56 | 0 | } |
57 | | |
58 | | void IWORKListLabelGeometriesProperty::endOfElement() |
59 | 0 | { |
60 | 0 | if (m_ref) |
61 | 0 | { |
62 | 0 | const std::unordered_map<ID_t, std::deque<IWORKListLabelGeometry> >::const_iterator it = getState().getDictionary().m_listLabelGeometriesArrays.find(get(m_ref)); |
63 | 0 | if (it != getState().getDictionary().m_listLabelGeometriesArrays.end()) |
64 | 0 | m_propertyMap.put<property::ListLabelGeometries>(it->second); |
65 | 0 | else |
66 | 0 | { |
67 | 0 | ETONYEK_DEBUG_MSG(("IWORKListLabelGeometriesProperty::endOfElement: unknown element %s\n", get(m_ref).c_str())); |
68 | 0 | } |
69 | 0 | } |
70 | 0 | else |
71 | 0 | m_propertyMap.put<property::ListLabelGeometries>(m_elements); |
72 | 0 | } |
73 | | } |
74 | | |
75 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |