/src/libetonyek/src/lib/contexts/IWORKTextElement.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 "IWORKTextElement.h" |
11 | | |
12 | | #include "IWORKCollector.h" |
13 | | #include "IWORKDictionary.h" |
14 | | #include "IWORKTextStorageElement.h" |
15 | | #include "IWORKText.h" |
16 | | #include "IWORKToken.h" |
17 | | #include "IWORKXMLParserState.h" |
18 | | |
19 | | namespace libetonyek |
20 | | { |
21 | | |
22 | | IWORKTextElement::IWORKTextElement(IWORKXMLParserState &state) |
23 | 0 | : IWORKXMLElementContextBase(state) |
24 | 0 | , m_layoutStyleRef() |
25 | 0 | , m_stylesheet() |
26 | 0 | { |
27 | 0 | } |
28 | | |
29 | | void IWORKTextElement::attribute(const int name, const char *value) |
30 | 0 | { |
31 | 0 | switch (name) |
32 | 0 | { |
33 | 0 | case +IWORKToken::NS_URI_SFA | IWORKToken::ID : // TODO: storeme ? |
34 | 0 | IWORKXMLElementContextBase::attribute(name, value); |
35 | 0 | break; |
36 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::layoutstyle : |
37 | 0 | m_layoutStyleRef = value; |
38 | 0 | break; |
39 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::tscale : // find one time with value 90 |
40 | 0 | break; |
41 | 0 | default: |
42 | 0 | ETONYEK_DEBUG_MSG(("IWORKTextElement::attribute: find some unknown attribute\n")); |
43 | 0 | } |
44 | 0 | } |
45 | | |
46 | | IWORKXMLContextPtr_t IWORKTextElement::element(const int name) |
47 | 0 | { |
48 | 0 | switch (name) |
49 | 0 | { |
50 | 0 | case +IWORKToken::NS_URI_SF | IWORKToken::text_storage : |
51 | 0 | return std::make_shared<IWORKTextStorageElement>(getState(), m_stylesheet); |
52 | 0 | default: |
53 | 0 | ETONYEK_DEBUG_MSG(("IWORKTextElement::element: find some unknown element\n")); |
54 | 0 | } |
55 | | |
56 | 0 | return IWORKXMLContextPtr_t(); |
57 | 0 | } |
58 | | |
59 | | void IWORKTextElement::endOfElement() |
60 | 0 | { |
61 | 0 | if (!isCollector() || !bool(m_layoutStyleRef)) |
62 | 0 | return; |
63 | 0 | IWORKStylePtr_t style= getState().getStyleByName(get(m_layoutStyleRef).c_str(), getState().getDictionary().m_layoutStyles,false); |
64 | 0 | if (!style && m_stylesheet) |
65 | 0 | style = m_stylesheet->find(get(m_layoutStyleRef)); |
66 | 0 | if (!style) |
67 | 0 | { |
68 | 0 | ETONYEK_DEBUG_MSG(("IWORKTextElement::endOfElement: can not find style %s\n", get(m_layoutStyleRef).c_str())); |
69 | 0 | } |
70 | 0 | if (bool(getState().m_currentText)) |
71 | 0 | getState().m_currentText->setLayoutStyle(style); |
72 | 0 | } |
73 | | } |
74 | | |
75 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |