/src/libetonyek/src/lib/contexts/IWORKLinkElement.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 "IWORKLinkElement.h" |
11 | | |
12 | | #include "IWORKSpanElement.h" |
13 | | #include "IWORKText.h" |
14 | | #include "IWORKToken.h" |
15 | | #include "IWORKXMLParserState.h" |
16 | | |
17 | | namespace libetonyek |
18 | | { |
19 | | |
20 | | IWORKLinkElement::IWORKLinkElement(IWORKXMLParserState &state) |
21 | 0 | : IWORKXMLMixedContextBase(state) |
22 | 0 | , m_opened(false) |
23 | 0 | { |
24 | 0 | } |
25 | | |
26 | | void IWORKLinkElement::attribute(const int name, const char *const value) |
27 | 0 | { |
28 | 0 | if (IWORKToken::href == name) |
29 | 0 | { |
30 | 0 | if (bool(getState().m_currentText)) |
31 | 0 | getState().m_currentText->openLink(value); |
32 | 0 | m_opened = true; |
33 | 0 | } |
34 | 0 | } |
35 | | |
36 | | IWORKXMLContextPtr_t IWORKLinkElement::element(const int name) |
37 | 0 | { |
38 | 0 | switch (name) |
39 | 0 | { |
40 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::span : |
41 | 0 | return std::make_shared<IWORKSpanElement>(getState()); |
42 | 0 | default: |
43 | 0 | ETONYEK_DEBUG_MSG(("IWORKLinkElement::element: find unknown element\n")); |
44 | 0 | break; |
45 | 0 | } |
46 | | |
47 | 0 | return IWORKXMLContextPtr_t(); |
48 | 0 | } |
49 | | |
50 | | void IWORKLinkElement::text(const char *const value) |
51 | 0 | { |
52 | 0 | if (bool(getState().m_currentText)) |
53 | 0 | getState().m_currentText->insertText(value); |
54 | 0 | } |
55 | | |
56 | | void IWORKLinkElement::endOfElement() |
57 | 0 | { |
58 | 0 | if (m_opened && bool(getState().m_currentText)) |
59 | 0 | getState().m_currentText->closeLink(); |
60 | 0 | } |
61 | | |
62 | | } |
63 | | |
64 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |