IWORKText.h Source File documentation

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: */
libetonyek::IWORKText::m_listAllowed
bool m_listAllowed
Definition: IWORKText.h:124
IWORKStyle_fwd.h
libetonyek::IWORKText::closeLink
void closeLink()
Definition: IWORKText.cpp:790
libetonyek::IWORKText::m_inLink
bool m_inLink
Definition: IWORKText.h:138
libetonyek
Definition: IWORKBezierElement.cpp:20
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::setLanguage
void setLanguage(const IWORKStylePtr_t &style)
Set language used for the next span.
Definition: IWORKText.cpp:709
libetonyek::IWORKText::insertField
void insertField(IWORKFieldType fieldType)
Definition: IWORKText.cpp:733
libetonyek::IWORKOutputElements
Definition: IWORKOutputElements.h:32
libetonyek::IWORKText::closeSection
void closeSection()
Definition: IWORKText.cpp:609
libetonyek::IWORKText::openSection
void openSection()
Definition: IWORKText.cpp:597
IWORKOutputElements.h
libetonyek::IWORKText::m_paraStyleStack
IWORKStyleStack m_paraStyleStack
Definition: IWORKText.h:111
libetonyek::IWORKText::closeSpan
void closeSpan()
Definition: IWORKText.cpp:1056
libetonyek::IWORKText
Definition: IWORKText.h:33
libetonyek::IWORKStyleStack
Representation of a dynamic inheritance of styles.
Definition: IWORKStyleStack.h:34
libetonyek::IWORKBreakType
IWORKBreakType
Definition: IWORKEnum.h:49
libetonyek::IWORKText::empty
bool empty() const
Definition: IWORKText.cpp:919
libetonyek::IWORKStylePtr_t
std::shared_ptr< IWORKStyle > IWORKStylePtr_t
Definition: IWORKStyle_fwd.h:21
libetonyek::IWORKText::flushLayout
void flushLayout()
Flush the current layout.
Definition: IWORKText.cpp:585
libetonyek::IWORKText::handleListLevelChange
void handleListLevelChange(unsigned level)
Definition: IWORKText.cpp:924
libetonyek::IWORKText::m_langManager
const IWORKLanguageManager & m_langManager
Definition: IWORKText.h:108
libetonyek::IWORKText::openSpan
void openSpan()
Definition: IWORKText.cpp:1036
libetonyek::IWORKText::fillParaPropList
void fillParaPropList(librevenge::RVNGPropertyList &propList, bool realParagraph=true)
Definition: IWORKText.cpp:1019
libetonyek::IWORKText::insertPageBreak
void insertPageBreak()
Definition: IWORKText.cpp:889
libetonyek::IWORKToken::text
Definition: IWORKToken.h:465
libetonyek::IWORKText::m_layoutStyleStack
IWORKStyleStack m_layoutStyleStack
Definition: IWORKText.h:110
libetonyek::IWORKText::m_oldSpanStyle
IWORKStylePtr_t m_oldSpanStyle
Definition: IWORKText.h:144
libetonyek::IWORKText::m_ignoreEmptyPara
bool m_ignoreEmptyPara
Definition: IWORKText.h:136
libetonyek::IWORKText::m_previousListStyle
IWORKStylePtr_t m_previousListStyle
the previous list style
Definition: IWORKText.h:123
libetonyek::IWORKText::setListLevel
void setListLevel(const unsigned level)
Set the list level of the next paragraph, 0 meaning no list.
Definition: IWORKText.cpp:646
libetonyek::IWORKToken::style
Definition: IWORKToken.h:414
libetonyek::IWORKText::m_recorder
std::shared_ptr< IWORKTextRecorder > m_recorder
Definition: IWORKText.h:146
libetonyek::IWORKText::m_inPara
bool m_inPara
Definition: IWORKText.h:134
libetonyek::IWORKText::insertText
void insertText(const std::string &text)
Definition: IWORKText.cpp:806
libetonyek::IWORKText::m_paraStyle
IWORKStylePtr_t m_paraStyle
Definition: IWORKText.h:132
libetonyek::IWORKText::insertTab
void insertTab()
Definition: IWORKText.cpp:829
libetonyek::IWORKText::flushSpan
void flushSpan()
Flush the current span.
Definition: IWORKText.cpp:721
libetonyek::KEY1Token::level
Definition: KEY1Token.h:158
libetonyek::IWORKText::m_sectionProps
librevenge::RVNGPropertyList m_sectionProps
Definition: IWORKText.h:118
libetonyek::IWORKText::insertInlineContent
void insertInlineContent(const IWORKOutputElements &elements)
Definition: IWORKText.cpp:901
libetonyek::IWORKText::getLayoutStyle
IWORKStylePtr_t getLayoutStyle()
returns the current layout style
Definition: IWORKText.cpp:567
libetonyek::IWORKText::setSpanStyle
void setSpanStyle(const IWORKStylePtr_t &style)
Set style used for the next span.
Definition: IWORKText.cpp:697
libetonyek::IWORKText::getRecorder
const std::shared_ptr< IWORKTextRecorder > & getRecorder() const
Definition: IWORKText.cpp:540
IWORKEnum.h
libetonyek::IWORKText::openLink
void openLink(const std::string &url)
Definition: IWORKText.cpp:765
libetonyek::IWORKText::insertColumnBreak
void insertColumnBreak()
Definition: IWORKText.cpp:861
libetonyek::IWORKText::setRecorder
void setRecorder(const std::shared_ptr< IWORKTextRecorder > &recorder)
Definition: IWORKText.cpp:535
libetonyek::IWORKText::pushBaseLayoutStyle
void pushBaseLayoutStyle(const IWORKStylePtr_t &style)
Set style used as base for all layout styles in this text.
Definition: IWORKText.cpp:545
libetonyek::IWORKText::m_inSection
bool m_inSection
Definition: IWORKText.h:117
libetonyek::IWORKText::insertBlockContent
void insertBlockContent(const IWORKOutputElements &elements)
Definition: IWORKText.cpp:909
libetonyek::IWORKText::setLayoutStyle
void setLayoutStyle(const IWORKStylePtr_t &style)
Set style used for the next layout.
Definition: IWORKText.cpp:572
libetonyek::IWORKText::closePara
void closePara()
Definition: IWORKText.cpp:1001
libetonyek::IWORKText::m_langStyle
IWORKStylePtr_t m_langStyle
Definition: IWORKText.h:140
IWORKStyleStack.h
libetonyek::IWORKText::insertLineBreak
void insertLineBreak()
Definition: IWORKText.cpp:873
libetonyek::IWORKFieldType
IWORKFieldType
Definition: IWORKEnum.h:142
libetonyek::IWORKText::m_listLevel
unsigned m_listLevel
Definition: IWORKText.h:127
libetonyek::IWORKText::m_hasContent
bool m_hasContent
Definition: IWORKText.h:115
libetonyek::IWORKText::m_listHasLevel0
bool m_listHasLevel0
flag to know if the list level 0 is defined
Definition: IWORKText.h:126
libetonyek::IWORKText::pushBaseParagraphStyle
void pushBaseParagraphStyle(const IWORKStylePtr_t &style)
Set style used as base for all paragraph styles in this text.
Definition: IWORKText.cpp:556
libetonyek::IWORKText::m_inSpan
bool m_inSpan
Definition: IWORKText.h:142
libetonyek::IWORKLanguageManager
Definition: IWORKLanguageManager.h:23
libetonyek::IWORKToken::string
Definition: IWORKToken.h:411
libetonyek::IWORKText::m_inListElement
bool m_inListElement
Definition: IWORKText.h:135
libetonyek::IWORKText::setParagraphStyle
void setParagraphStyle(const IWORKStylePtr_t &style)
Set style used for the next paragraph.
Definition: IWORKText.cpp:669
libetonyek::IWORKText::m_spanStyle
IWORKStylePtr_t m_spanStyle
Definition: IWORKText.h:139
libetonyek::IWORKText::m_elements
IWORKOutputElements m_elements
Definition: IWORKText.h:113
libetonyek::IWORKText::insertSpace
void insertSpace()
Definition: IWORKText.cpp:845
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:621
libetonyek::IWORKText::m_layoutStyle
IWORKStylePtr_t m_layoutStyle
Definition: IWORKText.h:116
libetonyek::IWORKText::m_listStyle
IWORKStylePtr_t m_listStyle
Definition: IWORKText.h:121
libetonyek::IWORKText::draw
void draw(IWORKOutputElements &elements)
Definition: IWORKText.cpp:484
libetonyek::IWORKText::m_spanStyleChanged
bool m_spanStyleChanged
Definition: IWORKText.h:141
libetonyek::IWORKText::~IWORKText
~IWORKText()
Definition: IWORKText.cpp:530
libetonyek::IWORKText::m_breakDelayed
IWORKBreakType m_breakDelayed
Definition: IWORKText.h:133
IWORKText_fwd.h
libetonyek::IWORKText::openPara
void openPara()
Definition: IWORKText.cpp:978
libetonyek::IWORKText::flushParagraph
void flushParagraph()
Flush the current paragraph.
Definition: IWORKText.cpp:680
libetonyek::IWORKText::m_checkedSection
bool m_checkedSection
Definition: IWORKText.h:119
libetonyek::IWORKText::needsSection
bool needsSection() const
Definition: IWORKText.cpp:1064
libetonyek::IWORKText::m_inListLevel
unsigned m_inListLevel
Definition: IWORKText.h:128
libetonyek::IWORKText::IWORKText
IWORKText(const IWORKLanguageManager &langManager, bool discardEmptyContent, bool allowListInsertion)
Definition: IWORKText.cpp:495
libetonyek::IWORKText::flushList
void flushList()
Flush the current list level(s).
Definition: IWORKText.cpp:657
libetonyek::IWORKText::fillCharPropList
static void fillCharPropList(const IWORKStyleStack &style, const IWORKLanguageManager &langManager, librevenge::RVNGPropertyList &props)
Definition: IWORKText.cpp:79