IWORKText.h
Go to the documentation of this file.
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#ifndef IWORKTEXT_H_INCLUDED
11#define IWORKTEXT_H_INCLUDED
12
13#include "IWORKText_fwd.h"
14
15#include <deque>
16#include <stack>
17
18#include <glm/glm.hpp>
19
20#include <librevenge/librevenge.h>
21
22#include "IWORKEnum.h"
23#include "IWORKStyle_fwd.h"
24#include "IWORKStyleStack.h"
25#include "IWORKOutputElements.h"
26
27 namespace libetonyek
28{
29
30 class IWORKLanguageManager;
31 class IWORKTextRecorder;
32
33 class IWORKText
34{
35 public:
36 IWORKText(const IWORKLanguageManager &langManager, bool discardEmptyContent, bool allowListInsertion);
37 ~IWORKText();
38
39 void setRecorder(const std::shared_ptr<IWORKTextRecorder> &recorder);
40 const std::shared_ptr<IWORKTextRecorder> &getRecorder() const;
41
43 void pushBaseLayoutStyle(const IWORKStylePtr_t &style);
45 void pushBaseParagraphStyle(const IWORKStylePtr_t &style);
46
48 void setLayoutStyle(const IWORKStylePtr_t &style);
50 void flushLayout();
52 IWORKStylePtr_t getLayoutStyle();
53
55 void setListStyle(const IWORKStylePtr_t &style);
57 void setListLevel(const unsigned level);
59 void flushList();
60
62 void setParagraphStyle(const IWORKStylePtr_t &style);
64 void flushParagraph();
65
67 void setSpanStyle(const IWORKStylePtr_t &style);
69 void setLanguage(const IWORKStylePtr_t &style);
71 void flushSpan();
72
73 void insertField(IWORKFieldType fieldType);
74 void openLink(const std::string &url);
75 void closeLink();
76 void insertText(const std::string &text);
77 void insertTab();
78 void insertSpace();
79 void insertColumnBreak();
80 void insertLineBreak();
81 void insertPageBreak();
82
83 void insertInlineContent(const IWORKOutputElements &elements);
84 void insertBlockContent(const IWORKOutputElements &elements);
85
86 bool empty() const;
87
88 void draw(IWORKOutputElements &elements);
89
90 // utility function
91 static void fillCharPropList(const IWORKStyleStack &style, const IWORKLanguageManager &langManager, librevenge::RVNGPropertyList &props);
92
93 private:
94 void openSection();
95 void closeSection();
96 bool needsSection() const;
97
98 void handleListLevelChange(unsigned level);
99
100 void openPara();
101 void closePara();
102 void fillParaPropList(librevenge::RVNGPropertyList &propList, bool realParagraph=true);
103
104 void openSpan();
105 void closeSpan();
106
107 private:
108 const IWORKLanguageManager &m_langManager;
109
110 IWORKStyleStack m_layoutStyleStack;
111 IWORKStyleStack m_paraStyleStack;
112
113 IWORKOutputElements m_elements;
114
115 bool m_hasContent;
116 IWORKStylePtr_t m_layoutStyle;
117 bool m_inSection;
118 mutable librevenge::RVNGPropertyList m_sectionProps;
119 mutable bool m_checkedSection;
120
121 IWORKStylePtr_t m_listStyle;
123 IWORKStylePtr_t m_previousListStyle;
124 bool m_listAllowed;
126 bool m_listHasLevel0;
127 unsigned m_listLevel;
128 unsigned m_inListLevel;
130 std::stack<bool> m_isOrderedStack;
131
132 IWORKStylePtr_t m_paraStyle;
133 IWORKBreakType m_breakDelayed;
134 bool m_inPara;
135 bool m_inListElement;
136 bool m_ignoreEmptyPara;
137
138 bool m_inLink;
139 IWORKStylePtr_t m_spanStyle;
140 IWORKStylePtr_t m_langStyle;
141 bool m_spanStyleChanged;
142 bool m_inSpan;
143
144 IWORKStylePtr_t m_oldSpanStyle;
145
146 std::shared_ptr<IWORKTextRecorder> m_recorder;
147};
148
149}
150
151#endif // IWORKTEXT_H_INCLUDED
152
153/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
IWORKEnum.h
IWORKOutputElements.h
IWORKStyleStack.h
IWORKStyle_fwd.h
IWORKText_fwd.h
libetonyek::IWORKLanguageManager
Definition IWORKLanguageManager.h:24
libetonyek::IWORKOutputElements
Definition IWORKOutputElements.h:33
libetonyek::IWORKStyleStack
Representation of a dynamic inheritance of styles.
Definition IWORKStyleStack.h:35
libetonyek::IWORKTextRecorder
Definition IWORKTextRecorder.h:25
libetonyek::IWORKText::openPara
void openPara()
Definition IWORKText.cpp:1007
libetonyek::IWORKText::insertInlineContent
void insertInlineContent(const IWORKOutputElements &elements)
Definition IWORKText.cpp:929
libetonyek::IWORKText::setLanguage
void setLanguage(const IWORKStylePtr_t &style)
Set language used for the next span.
Definition IWORKText.cpp:731
libetonyek::IWORKText::m_layoutStyle
IWORKStylePtr_t m_layoutStyle
Definition IWORKText.h:116
libetonyek::IWORKText::m_recorder
std::shared_ptr< IWORKTextRecorder > m_recorder
Definition IWORKText.h:146
libetonyek::IWORKText::setListLevel
void setListLevel(const unsigned level)
Set the list level of the next paragraph, 0 meaning no list.
Definition IWORKText.cpp:669
libetonyek::IWORKText::m_inPara
bool m_inPara
Definition IWORKText.h:134
libetonyek::IWORKText::m_ignoreEmptyPara
bool m_ignoreEmptyPara
Definition IWORKText.h:136
libetonyek::IWORKText::IWORKText
IWORKText(const IWORKLanguageManager &langManager, bool discardEmptyContent, bool allowListInsertion)
Definition IWORKText.cpp:518
libetonyek::IWORKText::insertBlockContent
void insertBlockContent(const IWORKOutputElements &elements)
Definition IWORKText.cpp:937
libetonyek::IWORKText::insertTab
void insertTab()
Definition IWORKText.cpp:857
libetonyek::IWORKText::m_paraStyle
IWORKStylePtr_t m_paraStyle
Definition IWORKText.h:132
libetonyek::IWORKText::getRecorder
const std::shared_ptr< IWORKTextRecorder > & getRecorder() const
Definition IWORKText.cpp:563
libetonyek::IWORKText::flushParagraph
void flushParagraph()
Flush the current paragraph.
Definition IWORKText.cpp:703
libetonyek::IWORKText::m_inLink
bool m_inLink
Definition IWORKText.h:138
libetonyek::IWORKText::insertText
void insertText(const std::string &text)
Definition IWORKText.cpp:834
libetonyek::IWORKText::closeSpan
void closeSpan()
Definition IWORKText.cpp:1081
libetonyek::IWORKText::m_breakDelayed
IWORKBreakType m_breakDelayed
Definition IWORKText.h:133
libetonyek::IWORKText::needsSection
bool needsSection() const
Definition IWORKText.cpp:1089
libetonyek::IWORKText::getLayoutStyle
IWORKStylePtr_t getLayoutStyle()
returns the current layout style
Definition IWORKText.cpp:590
libetonyek::IWORKText::openSpan
void openSpan()
Definition IWORKText.cpp:1061
libetonyek::IWORKText::m_inListElement
bool m_inListElement
Definition IWORKText.h:135
libetonyek::IWORKText::fillCharPropList
static void fillCharPropList(const IWORKStyleStack &style, const IWORKLanguageManager &langManager, librevenge::RVNGPropertyList &props)
Definition IWORKText.cpp:79
libetonyek::IWORKText::m_listAllowed
bool m_listAllowed
Definition IWORKText.h:124
libetonyek::IWORKText::setListStyle
void setListStyle(const IWORKStylePtr_t &style)
Set list style used for the next paragraph, if it is in a list.
Definition IWORKText.cpp:644
libetonyek::IWORKText::m_isOrderedStack
std::stack< bool > m_isOrderedStack
Saves info about the currently opened list levels being ordered or unordered.
Definition IWORKText.h:130
libetonyek::IWORKText::m_langManager
const IWORKLanguageManager & m_langManager
Definition IWORKText.h:108
libetonyek::IWORKText::openSection
void openSection()
Definition IWORKText.cpp:620
libetonyek::IWORKText::handleListLevelChange
void handleListLevelChange(unsigned level)
Definition IWORKText.cpp:952
libetonyek::IWORKText::closePara
void closePara()
Definition IWORKText.cpp:1030
libetonyek::IWORKText::insertField
void insertField(IWORKFieldType fieldType)
Definition IWORKText.cpp:755
libetonyek::IWORKText::m_layoutStyleStack
IWORKStyleStack m_layoutStyleStack
Definition IWORKText.h:110
libetonyek::IWORKText::flushLayout
void flushLayout()
Flush the current layout.
Definition IWORKText.cpp:608
libetonyek::IWORKText::m_listHasLevel0
bool m_listHasLevel0
flag to know if the list level 0 is defined
Definition IWORKText.h:126
libetonyek::IWORKText::~IWORKText
~IWORKText()
Definition IWORKText.cpp:553
libetonyek::IWORKText::m_checkedSection
bool m_checkedSection
Definition IWORKText.h:119
libetonyek::IWORKText::m_sectionProps
librevenge::RVNGPropertyList m_sectionProps
Definition IWORKText.h:118
libetonyek::IWORKText::openLink
void openLink(const std::string &url)
Definition IWORKText.cpp:787
libetonyek::IWORKText::m_spanStyle
IWORKStylePtr_t m_spanStyle
Definition IWORKText.h:139
libetonyek::IWORKText::m_previousListStyle
IWORKStylePtr_t m_previousListStyle
the previous list style
Definition IWORKText.h:123
libetonyek::IWORKText::m_hasContent
bool m_hasContent
Definition IWORKText.h:115
libetonyek::IWORKText::m_paraStyleStack
IWORKStyleStack m_paraStyleStack
Definition IWORKText.h:111
libetonyek::IWORKText::closeLink
void closeLink()
Definition IWORKText.cpp:813
libetonyek::IWORKText::empty
bool empty() const
Definition IWORKText.cpp:947
libetonyek::IWORKText::m_inSpan
bool m_inSpan
Definition IWORKText.h:142
libetonyek::IWORKText::m_listStyle
IWORKStylePtr_t m_listStyle
Definition IWORKText.h:121
libetonyek::IWORKText::insertLineBreak
void insertLineBreak()
Definition IWORKText.cpp:901
libetonyek::IWORKText::setParagraphStyle
void setParagraphStyle(const IWORKStylePtr_t &style)
Set style used for the next paragraph.
Definition IWORKText.cpp:692
libetonyek::IWORKText::flushSpan
void flushSpan()
Flush the current span.
Definition IWORKText.cpp:743
libetonyek::IWORKText::setLayoutStyle
void setLayoutStyle(const IWORKStylePtr_t &style)
Set style used for the next layout.
Definition IWORKText.cpp:595
libetonyek::IWORKText::draw
void draw(IWORKOutputElements &elements)
Definition IWORKText.cpp:507
libetonyek::IWORKText::insertSpace
void insertSpace()
Definition IWORKText.cpp:873
libetonyek::IWORKText::m_listLevel
unsigned m_listLevel
Definition IWORKText.h:127
libetonyek::IWORKText::m_langStyle
IWORKStylePtr_t m_langStyle
Definition IWORKText.h:140
libetonyek::IWORKText::insertColumnBreak
void insertColumnBreak()
Definition IWORKText.cpp:889
libetonyek::IWORKText::closeSection
void closeSection()
Definition IWORKText.cpp:632
libetonyek::IWORKText::setSpanStyle
void setSpanStyle(const IWORKStylePtr_t &style)
Set style used for the next span.
Definition IWORKText.cpp:719
libetonyek::IWORKText::flushList
void flushList()
Flush the current list level(s).
Definition IWORKText.cpp:680
libetonyek::IWORKText::m_inListLevel
unsigned m_inListLevel
Definition IWORKText.h:128
libetonyek::IWORKText::m_spanStyleChanged
bool m_spanStyleChanged
Definition IWORKText.h:141
libetonyek::IWORKText::setRecorder
void setRecorder(const std::shared_ptr< IWORKTextRecorder > &recorder)
Definition IWORKText.cpp:558
libetonyek::IWORKText::m_oldSpanStyle
IWORKStylePtr_t m_oldSpanStyle
Definition IWORKText.h:144
libetonyek::IWORKText::insertPageBreak
void insertPageBreak()
Definition IWORKText.cpp:917
libetonyek::IWORKText::pushBaseLayoutStyle
void pushBaseLayoutStyle(const IWORKStylePtr_t &style)
Set style used as base for all layout styles in this text.
Definition IWORKText.cpp:568
libetonyek::IWORKText::m_inSection
bool m_inSection
Definition IWORKText.h:117
libetonyek::IWORKText::pushBaseParagraphStyle
void pushBaseParagraphStyle(const IWORKStylePtr_t &style)
Set style used as base for all paragraph styles in this text.
Definition IWORKText.cpp:579
libetonyek::IWORKText::m_elements
IWORKOutputElements m_elements
Definition IWORKText.h:113
libetonyek::IWORKText::fillParaPropList
void fillParaPropList(librevenge::RVNGPropertyList &propList, bool realParagraph=true)
Definition IWORKText.cpp:1044
libetonyek::IWORKToken::text
@ text
Definition IWORKToken.h:472
libetonyek::IWORKToken::style
@ style
Definition IWORKToken.h:421
libetonyek::KEY1Token::level
@ level
Definition KEY1Token.h:158
libetonyek
Definition IWORKBezierElement.cpp:21
libetonyek::IWORKFieldType
IWORKFieldType
Definition IWORKEnum.h:144
libetonyek::IWORKBreakType
IWORKBreakType
Definition IWORKEnum.h:50
libetonyek::IWORKStylePtr_t
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition IWORKStyle_fwd.h:23