/src/libetonyek/src/lib/contexts/IWORKLayoutElement.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 "IWORKLayoutElement.h" |
11 | | |
12 | | #include "IWORKDictionary.h" |
13 | | #include "IWORKPElement.h" |
14 | | #include "IWORKStyle.h" |
15 | | #include "IWORKText.h" |
16 | | #include "IWORKToken.h" |
17 | | #include "IWORKXMLParserState.h" |
18 | | |
19 | | namespace libetonyek |
20 | | { |
21 | | |
22 | | IWORKLayoutElement::IWORKLayoutElement(IWORKXMLParserState &state) |
23 | 0 | : IWORKXMLElementContextBase(state) |
24 | 0 | , m_opened(false) |
25 | 0 | , m_style() |
26 | 0 | { |
27 | 0 | } |
28 | | |
29 | | void IWORKLayoutElement::attribute(const int name, const char *const value) |
30 | 0 | { |
31 | 0 | if ((+IWORKToken::NS_URI_SF | IWORKToken::style) == name) |
32 | 0 | m_style=getState().getStyleByName(value, getState().getDictionary().m_layoutStyles); |
33 | 0 | else // also sfa:ID |
34 | 0 | { |
35 | 0 | ETONYEK_DEBUG_MSG(("IWORKLayoutElement::attribute: unknown attribute\n")); |
36 | 0 | } |
37 | 0 | } |
38 | | |
39 | | IWORKXMLContextPtr_t IWORKLayoutElement::element(const int name) |
40 | 0 | { |
41 | 0 | if (!m_opened) |
42 | 0 | open(); |
43 | |
|
44 | 0 | if ((+IWORKToken::NS_URI_SF | IWORKToken::p) == name) |
45 | 0 | return std::make_shared<IWORKPElement>(getState()); |
46 | | |
47 | 0 | return IWORKXMLContextPtr_t(); |
48 | 0 | } |
49 | | |
50 | | void IWORKLayoutElement::endOfElement() |
51 | 0 | { |
52 | 0 | if (m_opened) |
53 | 0 | { |
54 | 0 | if (bool(getState().m_currentText)) |
55 | 0 | getState().m_currentText->flushLayout(); |
56 | 0 | } |
57 | 0 | } |
58 | | |
59 | | void IWORKLayoutElement::open() |
60 | 0 | { |
61 | 0 | assert(!m_opened); |
62 | |
|
63 | 0 | if (bool(getState().m_currentText)) |
64 | 0 | getState().m_currentText->setLayoutStyle(m_style); |
65 | 0 | m_opened = true; |
66 | 0 | } |
67 | | |
68 | | } |
69 | | |
70 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |