/src/libetonyek/src/lib/contexts/PAG1ShapeContext.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 "PAG1ShapeContext.h" |
11 | | |
12 | | #include <cassert> |
13 | | |
14 | | #include <boost/optional.hpp> |
15 | | |
16 | | #include "libetonyek_xml.h" |
17 | | |
18 | | #include "IWORKDictionary.h" |
19 | | #include "IWORKGeometryElement.h" |
20 | | #include "IWORKPathElement.h" |
21 | | #include "IWORKRefContext.h" |
22 | | #include "IWORKTextElement.h" |
23 | | #include "IWORKToken.h" |
24 | | |
25 | | #include "PAGCollector.h" |
26 | | #include "PAG1ParserState.h" |
27 | | #include "PAG1TextStorageElement.h" |
28 | | #include "PAG1Token.h" |
29 | | |
30 | | namespace libetonyek |
31 | | { |
32 | | |
33 | | namespace |
34 | | { |
35 | | class TextElement : public PAG1XMLContextBase<IWORKTextElement> |
36 | | { |
37 | | public: |
38 | | explicit TextElement(PAG1ParserState &state); |
39 | | |
40 | | private: |
41 | | IWORKXMLContextPtr_t element(int name) override; |
42 | | }; |
43 | | |
44 | | |
45 | | TextElement::TextElement(PAG1ParserState &state) |
46 | 0 | : PAG1XMLContextBase<IWORKTextElement>(state) |
47 | 0 | { |
48 | 0 | } |
49 | | |
50 | | IWORKXMLContextPtr_t TextElement::element(const int name) |
51 | 0 | { |
52 | 0 | switch (name) |
53 | 0 | { |
54 | 0 | case IWORKToken::NS_URI_SF | IWORKToken::text_storage : |
55 | 0 | return std::make_shared<PAG1TextStorageElement>(getState(), PAG1XMLContextBase<IWORKTextElement>::m_stylesheet, PAG_TEXTSTORAGE_KIND_TEXTBOX); |
56 | 0 | default: |
57 | 0 | break; |
58 | 0 | } |
59 | | |
60 | 0 | return PAG1XMLContextBase<IWORKTextElement>::element(name); |
61 | 0 | } |
62 | | } |
63 | | |
64 | | |
65 | | PAG1ShapeContext::PAG1ShapeContext(PAG1ParserState &state) |
66 | 0 | : PAG1XMLContextBase<IWORKShapeContext>(state) |
67 | 0 | { |
68 | 0 | } |
69 | | |
70 | | void PAG1ShapeContext::attribute(const int name, const char *const value) |
71 | 0 | { |
72 | 0 | switch (name) |
73 | 0 | { |
74 | 0 | case PAG1Token::order | PAG1Token::NS_URI_SL : |
75 | 0 | m_order=try_int_cast(value); |
76 | 0 | break; |
77 | 0 | default: |
78 | 0 | PAG1XMLContextBase<IWORKShapeContext>::attribute(name, value); |
79 | 0 | } |
80 | 0 | } |
81 | | |
82 | | IWORKXMLContextPtr_t PAG1ShapeContext::element(const int name) |
83 | 0 | { |
84 | 0 | switch (name) |
85 | 0 | { |
86 | 0 | case IWORKToken::NS_URI_SF | IWORKToken::text : |
87 | 0 | return std::make_shared<TextElement>(getState()); |
88 | 0 | default: |
89 | 0 | break; |
90 | 0 | } |
91 | | |
92 | 0 | return PAG1XMLContextBase<IWORKShapeContext>::element(name); |
93 | 0 | } |
94 | | |
95 | | } |
96 | | |
97 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |