MCPcopy Create free account
hub / github.com/buggins/coolreader / OnText

Method OnText

crengine/src/rtfimp.cpp:157–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155 }
156 }
157 virtual void OnText( const lChar16 * text, int len, lUInt32 flags )
158 {
159 lString16 s = text;
160 s.trimDoubleSpaces(!last_space, true, false);
161 text = s.c_str();
162 len = s.length();
163 if ( !len ) {
164 m_callback->OnTagOpenNoAttr(NULL, L"empty-line");
165 m_callback->OnTagClose(NULL, L"empty-line");
166 return;
167 }
168 bool intbl = m_stack.getInt( pi_intbl )>0;
169 bool asteriskFlag = ( s.compare( L"* * *" )==0 );
170 bool titleFlag = m_stack.getInt( pi_align )==ha_center && len<200;
171 if ( last_notitle && titleFlag && !asteriskFlag ) {
172 OnAction(RA_SECTION);
173 }
174 if ( !in_section ) {
175 m_callback->OnTagOpenNoAttr(NULL, L"section");
176 in_section = true;
177 }
178 if ( !intbl ) {
179 if ( !in_title && titleFlag ) {
180 if ( asteriskFlag ) {
181 m_callback->OnTagOpenNoAttr(NULL, L"subtitle");
182 in_subtitle = true;
183 } else {
184 m_callback->OnTagOpenNoAttr(NULL, L"title");
185 in_subtitle = false;
186 }
187 in_title = true;
188 last_notitle = false;
189 }
190 }
191 if ( intbl )
192 SetTableState( tbls_incell );
193 if ( !in_para ) {
194 if ( !in_title )
195 last_notitle = true;
196 m_callback->OnTagOpenNoAttr(NULL, L"p");
197 last_space = false;
198 in_para = true;
199 }
200 if ( m_stack.getInt(pi_ch_bold) ) {
201 m_callback->OnTagOpenNoAttr(NULL, L"strong");
202 }
203 if ( m_stack.getInt(pi_ch_italic) ) {
204 m_callback->OnTagOpenNoAttr(NULL, L"emphasis");
205 }
206 if ( m_stack.getInt(pi_ch_sub) ) {
207 m_callback->OnTagOpenNoAttr(NULL, L"sub");
208 } else if ( m_stack.getInt(pi_ch_super) ) {
209 m_callback->OnTagOpenNoAttr(NULL, L"sup");
210 }
211
212 m_callback->OnText( text, len, flags );
213 last_space = text[len-1]==' ';
214

Callers 2

CommitTextMethod · 0.45
ParseMethod · 0.45

Calls 6

OnTagOpenNoAttrMethod · 0.80
c_strMethod · 0.45
lengthMethod · 0.45
OnTagCloseMethod · 0.45
getIntMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected