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 "IWORKStyle_fwd.h"
23 #include "IWORKStyleStack.h"
24 #include "IWORKOutputElements.h"
25
26 namespace libetonyek
27 {
28
29 class IWORKLanguageManager;
30 class IWORKTextRecorder;
31
32 class IWORKText
33 {
34 public:
35 IWORKText(const IWORKLanguageManager &langManager, bool discardEmptyContent);
36 ~IWORKText();
37
38 void setRecorder(const std::shared_ptr<IWORKTextRecorder> &recorder);
39 const std::shared_ptr<IWORKTextRecorder> &getRecorder() const;
40
42 void pushBaseLayoutStyle(const IWORKStylePtr_t &style);
44 void pushBaseParagraphStyle(const IWORKStylePtr_t &style);
45
47 void setLayoutStyle(const IWORKStylePtr_t &style);
49 void flushLayout();
50
52 void setListStyle(const IWORKStylePtr_t &style);
54 void setListLevel(const unsigned level);
56 void flushList();
57
59 void setParagraphStyle(const IWORKStylePtr_t &style);
61 void flushParagraph();
62
64 void setSpanStyle(const IWORKStylePtr_t &style);
66 void setLanguage(const IWORKStylePtr_t &style);
68 void flushSpan();
69
70 void openLink(const std::string &url);
71 void closeLink();
72
73 void insertText(const std::string &text);
74 void insertTab();
75 void insertSpace();
76 void insertLineBreak();
77 void insertPageBreak();
78
79 void insertInlineContent(const IWORKOutputElements &elements);
80 void insertBlockContent(const IWORKOutputElements &elements);
81
82 bool empty() const;
83
84 void draw(IWORKOutputElements &elements);
85
86 // utility function
87 static void fillCharPropList(const IWORKStyleStack &style, const IWORKLanguageManager &langManager, librevenge::RVNGPropertyList &props);
88
89 private:
90 void openSection();
91 void closeSection();
92 bool needsSection() const;
93
94 void handleListLevelChange(unsigned level);
95
96 void openPara();
97 void closePara();
98 void fillParaPropList(librevenge::RVNGPropertyList &propList);
99
100 void openSpan();
101 void closeSpan();
102
103 private:
104 const IWORKLanguageManager &m_langManager;
105
106 IWORKStyleStack m_layoutStyleStack;
107 IWORKStyleStack m_paraStyleStack;
108
109 IWORKOutputElements m_elements;
110
111 IWORKStylePtr_t m_layoutStyle;
112 bool m_inSection;
113 mutable librevenge::RVNGPropertyList m_sectionProps;
114 mutable bool m_checkedSection;
115
116 IWORKStylePtr_t m_listStyle;
117 unsigned m_listLevel;
118 unsigned m_inListLevel;
120 std::stack<bool> m_isOrderedStack;
121
122 IWORKStylePtr_t m_paraStyle;
123 bool m_pageBreakDelayed;
124 bool m_inPara;
125 bool m_ignoreEmptyPara;
126
127 IWORKStylePtr_t m_spanStyle;
128 IWORKStylePtr_t m_langStyle;
129 bool m_spanStyleChanged;
130 bool m_inSpan;
131
132 IWORKStylePtr_t m_oldSpanStyle;
133
134 std::shared_ptr<IWORKTextRecorder> m_recorder;
135 };
136
137 }
138
139 #endif // IWORKTEXT_H_INCLUDED
140
141 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
IWORKStyle_fwd.h
libetonyek::IWORKText::closeLink
void closeLink()
Definition: IWORKText.cpp:678
libetonyek
Definition: IWORKBezierElement.cpp:18
libetonyek::IWORKText::m_isOrderedStack
std::stack< bool > m_isOrderedStack
Saves info about the currently opened list levels being ordered or unordered.
Definition: IWORKText.h:120
libetonyek::IWORKText::setLanguage
void setLanguage(const IWORKStylePtr_t &style)
Set language used for the next span.
Definition: IWORKText.cpp:631
libetonyek::IWORKOutputElements
Definition: IWORKOutputElements.h:29
libetonyek::IWORKText::closeSection
void closeSection()
Definition: IWORKText.cpp:546
libetonyek::IWORKText::openSection
void openSection()
Definition: IWORKText.cpp:534
IWORKOutputElements.h
libetonyek::IWORKText::m_paraStyleStack
IWORKStyleStack m_paraStyleStack
Definition: IWORKText.h:107
libetonyek::IWORKText::closeSpan
void closeSpan()
Definition: IWORKText.cpp:892
libetonyek::IWORKText
Definition: IWORKText.h:32
libetonyek::IWORKStyleStack
Representation of a dynamic inheritance of styles.
Definition: IWORKStyleStack.h:34
libetonyek::IWORKText::empty
bool empty() const
Definition: IWORKText.cpp:782
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:522
libetonyek::IWORKText::handleListLevelChange
void handleListLevelChange(unsigned level)
Definition: IWORKText.cpp:787
libetonyek::IWORKText::m_langManager
const IWORKLanguageManager & m_langManager
Definition: IWORKText.h:104
libetonyek::IWORKText::fillParaPropList
void fillParaPropList(librevenge::RVNGPropertyList &propList)
Definition: IWORKText.cpp:858
libetonyek::IWORKText::openSpan
void openSpan()
Definition: IWORKText.cpp:872
libetonyek::IWORKText::insertPageBreak
void insertPageBreak()
Definition: IWORKText.cpp:754
libetonyek::IWORKToken::text
Definition: IWORKToken.h:284
libetonyek::IWORKText::m_layoutStyleStack
IWORKStyleStack m_layoutStyleStack
Definition: IWORKText.h:106
libetonyek::IWORKText::m_oldSpanStyle
IWORKStylePtr_t m_oldSpanStyle
Definition: IWORKText.h:132
libetonyek::IWORKText::m_ignoreEmptyPara
bool m_ignoreEmptyPara
Definition: IWORKText.h:125
libetonyek::IWORKText::setListLevel
void setListLevel(const unsigned level)
Set the list level of the next paragraph, 0 meaning no list.
Definition: IWORKText.cpp:569
libetonyek::IWORKToken::style
Definition: IWORKToken.h:268
libetonyek::IWORKText::m_recorder
std::shared_ptr< IWORKTextRecorder > m_recorder
Definition: IWORKText.h:134
libetonyek::IWORKText::m_pageBreakDelayed
bool m_pageBreakDelayed
Definition: IWORKText.h:123
libetonyek::IWORKText::m_inPara
bool m_inPara
Definition: IWORKText.h:124
libetonyek::IWORKText::insertText
void insertText(const std::string &text)
Definition: IWORKText.cpp:694
libetonyek::IWORKText::m_paraStyle
IWORKStylePtr_t m_paraStyle
Definition: IWORKText.h:122
libetonyek::IWORKText::insertTab
void insertTab()
Definition: IWORKText.cpp:709
libetonyek::IWORKText::IWORKText
IWORKText(const IWORKLanguageManager &langManager, bool discardEmptyContent)
Definition: IWORKText.cpp:444
libetonyek::IWORKText::flushSpan
void flushSpan()
Flush the current span.
Definition: IWORKText.cpp:643
libetonyek::KEY1Token::level
Definition: KEY1Token.h:133
libetonyek::IWORKText::m_sectionProps
librevenge::RVNGPropertyList m_sectionProps
Definition: IWORKText.h:113
libetonyek::IWORKText::insertInlineContent
void insertInlineContent(const IWORKOutputElements &elements)
Definition: IWORKText.cpp:765
libetonyek::IWORKText::setSpanStyle
void setSpanStyle(const IWORKStylePtr_t &style)
Set style used for the next span.
Definition: IWORKText.cpp:619
libetonyek::IWORKText::getRecorder
const std::shared_ptr< IWORKTextRecorder > & getRecorder() const
Definition: IWORKText.cpp:482
libetonyek::IWORKText::openLink
void openLink(const std::string &url)
Definition: IWORKText.cpp:655
libetonyek::IWORKText::setRecorder
void setRecorder(const std::shared_ptr< IWORKTextRecorder > &recorder)
Definition: IWORKText.cpp:477
libetonyek::IWORKText::pushBaseLayoutStyle
void pushBaseLayoutStyle(const IWORKStylePtr_t &style)
Set style used as base for all layout styles in this text.
Definition: IWORKText.cpp:487
libetonyek::IWORKText::m_inSection
bool m_inSection
Definition: IWORKText.h:112
libetonyek::IWORKText::insertBlockContent
void insertBlockContent(const IWORKOutputElements &elements)
Definition: IWORKText.cpp:772
libetonyek::IWORKText::setLayoutStyle
void setLayoutStyle(const IWORKStylePtr_t &style)
Set style used for the next layout.
Definition: IWORKText.cpp:509
libetonyek::IWORKText::closePara
void closePara()
Definition: IWORKText.cpp:843
libetonyek::IWORKText::m_langStyle
IWORKStylePtr_t m_langStyle
Definition: IWORKText.h:128
IWORKStyleStack.h
libetonyek::IWORKText::insertLineBreak
void insertLineBreak()
Definition: IWORKText.cpp:739
libetonyek::IWORKText::m_listLevel
unsigned m_listLevel
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:498
libetonyek::IWORKText::m_inSpan
bool m_inSpan
Definition: IWORKText.h:130
libetonyek::IWORKLanguageManager
Definition: IWORKLanguageManager.h:23
libetonyek::IWORKToken::string
Definition: IWORKToken.h:266
libetonyek::IWORKText::setParagraphStyle
void setParagraphStyle(const IWORKStylePtr_t &style)
Set style used for the next paragraph.
Definition: IWORKText.cpp:591
libetonyek::IWORKText::m_spanStyle
IWORKStylePtr_t m_spanStyle
Definition: IWORKText.h:127
libetonyek::IWORKText::m_elements
IWORKOutputElements m_elements
Definition: IWORKText.h:109
libetonyek::IWORKText::insertSpace
void insertSpace()
Definition: IWORKText.cpp:724
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:558
libetonyek::IWORKText::m_layoutStyle
IWORKStylePtr_t m_layoutStyle
Definition: IWORKText.h:111
libetonyek::IWORKText::m_listStyle
IWORKStylePtr_t m_listStyle
Definition: IWORKText.h:116
libetonyek::IWORKText::draw
void draw(IWORKOutputElements &elements)
Definition: IWORKText.cpp:435
libetonyek::IWORKText::m_spanStyleChanged
bool m_spanStyleChanged
Definition: IWORKText.h:129
libetonyek::IWORKText::~IWORKText
~IWORKText()
Definition: IWORKText.cpp:472
IWORKText_fwd.h
libetonyek::IWORKText::openPara
void openPara()
Definition: IWORKText.cpp:826
libetonyek::IWORKText::flushParagraph
void flushParagraph()
Flush the current paragraph.
Definition: IWORKText.cpp:602
libetonyek::IWORKText::m_checkedSection
bool m_checkedSection
Definition: IWORKText.h:114
libetonyek::IWORKText::needsSection
bool needsSection() const
Definition: IWORKText.cpp:900
libetonyek::IWORKText::m_inListLevel
unsigned m_inListLevel
Definition: IWORKText.h:118
libetonyek::IWORKText::flushList
void flushList()
Flush the current list level(s).
Definition: IWORKText.cpp:580
libetonyek::IWORKText::fillCharPropList
static void fillCharPropList(const IWORKStyleStack &style, const IWORKLanguageManager &langManager, librevenge::RVNGPropertyList &props)
Definition: IWORKText.cpp:80