Update ooo320-m1
[ooovba.git] / autodoc / source / parser / adoc / docu_pe.cxx
blob20674878c1d3c8ab9339daafcbd314f96eefd328
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docu_pe.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include <adoc/docu_pe.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/doc/d_oldcppdocu.hxx>
37 #include <ary/info/ci_attag.hxx>
38 #include <ary/info/ci_text.hxx>
39 #include <adoc/adoc_tok.hxx>
40 #include <adoc/tk_attag.hxx>
41 #include <adoc/tk_docw.hxx>
44 namespace adoc
48 inline bool
49 Adoc_PE::UsesHtmlInDocuText()
51 return bUsesHtmlInDocuText;
57 Adoc_PE::Adoc_PE()
58 : pCurDocu(0),
59 pCurAtTag(0),
60 nLineCountInDocu(0),
61 nCurSpecialMeaningTokens(0),
62 nCurSubtractFromLineStart(0),
63 eCurTagState(ts_new),
64 eDocuState(ds_wait_for_short),
65 bIsComplete(false),
66 bUsesHtmlInDocuText(false)
70 Adoc_PE::~Adoc_PE()
74 void
75 Adoc_PE::Hdl_at_std( const Tok_at_std & i_rTok )
77 InstallAtTag(
78 CurDocu().Create_StdTag(i_rTok.Id()) );
81 void
82 Adoc_PE::Hdl_at_base( const Tok_at_base & )
84 InstallAtTag(
85 CurDocu().CheckIn_BaseTag() );
88 void
89 Adoc_PE::Hdl_at_exception( const Tok_at_exception & )
91 InstallAtTag(
92 CurDocu().CheckIn_ExceptionTag() );
95 void
96 Adoc_PE::Hdl_at_impl( const Tok_at_impl & )
98 InstallAtTag(
99 CurDocu().Create_ImplementsTag() );
102 void
103 Adoc_PE::Hdl_at_key( const Tok_at_key & )
105 InstallAtTag(
106 CurDocu().Create_KeywordTag() );
109 void
110 Adoc_PE::Hdl_at_param( const Tok_at_param & )
112 InstallAtTag(
113 CurDocu().CheckIn_ParameterTag() );
116 void
117 Adoc_PE::Hdl_at_see( const Tok_at_see & )
119 InstallAtTag(
120 CurDocu().CheckIn_SeeTag() );
123 void
124 Adoc_PE::Hdl_at_template( const Tok_at_template & )
126 InstallAtTag(
127 CurDocu().CheckIn_TemplateTag() );
130 void
131 Adoc_PE::Hdl_at_interface( const Tok_at_interface & )
133 CurDocu().Set_Interface();
136 void
137 Adoc_PE::Hdl_at_internal( const Tok_at_internal & )
139 CurDocu().Set_Internal();
142 void
143 Adoc_PE::Hdl_at_obsolete( const Tok_at_obsolete & )
145 CurDocu().Set_Obsolete();
148 void
149 Adoc_PE::Hdl_at_module( const Tok_at_module & )
151 // KORR_FUTURE
153 // pCurAtTag = CurDocu().Assign2_ModuleTag();
154 // nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens();
157 void
158 Adoc_PE::Hdl_at_file( const Tok_at_file & )
160 // KORR_FUTURE
162 // pCurAtTag = CurDocu().Assign2_FileTag();
163 // nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens();
166 void
167 Adoc_PE::Hdl_at_gloss( const Tok_at_gloss & )
169 // KORR_FUTURE
171 // Create_GlossaryEntry();
174 void
175 Adoc_PE::Hdl_at_global( const Tok_at_global & )
177 // KORR_FUTURE
178 // Create_GlobalTextComponent();
181 void
182 Adoc_PE::Hdl_at_include( const Tok_at_include & )
184 // KORR_FUTURE
187 void
188 Adoc_PE::Hdl_at_label( const Tok_at_label & )
190 InstallAtTag(
191 CurDocu().Create_LabelTag() );
194 void
195 Adoc_PE::Hdl_at_since( const Tok_at_since & )
197 InstallAtTag(
198 CurDocu().Create_SinceTag() );
201 void
202 Adoc_PE::Hdl_at_HTML( const Tok_at_HTML & )
204 bUsesHtmlInDocuText = true;
207 void
208 Adoc_PE::Hdl_at_NOHTML( const Tok_at_NOHTML & )
210 bUsesHtmlInDocuText = false;
213 void
214 Adoc_PE::Hdl_DocWord( const Tok_DocWord & i_rTok )
216 bool bIsSpecial = false;
217 if ( nCurSpecialMeaningTokens > 0 )
219 bIsSpecial = CurAtTag().Add_SpecialMeaningToken(
220 i_rTok.Text(),
221 CurAtTag().NrOfSpecialMeaningTokens()
222 - (--nCurSpecialMeaningTokens) );
225 if ( NOT bIsSpecial )
227 if ( eDocuState == ds_wait_for_short OR eDocuState == ds_1newline_after_short )
228 eDocuState = ds_in_short;
229 if (nLineCountInDocu == 0)
230 nLineCountInDocu = 1;
232 uintt nLength = i_rTok.Length();
233 if ( nLength > 2 )
235 bool bMaybeGlobalLink = strncmp( "::", i_rTok.Text(), 2 ) == 0;
236 bool bMayBeFunction = *(i_rTok.Text() + nLength - 2) == '('
237 AND *(i_rTok.Text() + nLength - 1) == ')';
238 if ( bMaybeGlobalLink OR bMayBeFunction )
240 CurAtTag().Add_PotentialLink( i_rTok.Text(),
241 bMaybeGlobalLink,
242 bMayBeFunction );
243 return;
247 CurAtTag().Add_Token( i_rTok.Text() );
248 eCurTagState = ts_std;
252 void
253 Adoc_PE::Hdl_Whitespace( const Tok_Whitespace & i_rTok )
255 if ( eCurTagState == ts_std )
258 CurAtTag().Add_Whitespace(i_rTok.Size());
262 void
263 Adoc_PE::Hdl_LineStart( const Tok_LineStart & i_rTok )
265 if ( pCurAtTag == 0 )
266 return;
268 if ( nLineCountInDocu == 2 )
270 nCurSubtractFromLineStart = i_rTok.Size();
271 eCurTagState = ts_std;
273 else if ( nLineCountInDocu > 2 )
275 if ( i_rTok.Size() > nCurSubtractFromLineStart )
277 CurAtTag().Add_Whitespace( i_rTok.Size()
278 - nCurSubtractFromLineStart );
280 // else do nothing, because there is no whitespace.
284 void
285 Adoc_PE::Hdl_Eol( const Tok_Eol & )
287 if ( pCurAtTag == 0 )
288 return;
290 nLineCountInDocu++;
292 if ( nCurSpecialMeaningTokens == 0 )
294 CurAtTag().Add_Eol();
296 switch ( eDocuState )
298 case ds_wait_for_short: break;
299 case ds_in_short: if ( nLineCountInDocu < 4 )
300 eDocuState = ds_1newline_after_short;
301 else
303 RenameCurShortTag();
304 eDocuState = ds_in_descr;
306 break;
307 case ds_1newline_after_short: FinishCurShortTag();
308 eDocuState = ds_in_descr;
309 break;
310 default:
311 ; // Do noting.
314 else
316 nCurSpecialMeaningTokens = 0;
322 void
323 Adoc_PE::Hdl_EoDocu( const Tok_EoDocu & )
325 bIsComplete = true;
328 DYN ary::doc::OldCppDocu *
329 Adoc_PE::ReleaseJustParsedDocu()
331 pCurAtTag = 0;
332 nLineCountInDocu = 0;
333 nCurSpecialMeaningTokens = 0;
334 nCurSubtractFromLineStart = 0;
335 eCurTagState = ts_new;
336 eDocuState = ds_wait_for_short;
337 bIsComplete = false;
338 return pCurDocu.Release();
341 void
342 Adoc_PE::InstallAtTag( DYN ary::info::AtTag * let_dpTag,
343 bool i_bImplicit )
345 pCurAtTag = let_dpTag;
346 if ( pCurAtTag != 0 )
348 nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens();
349 pCurAtTag->Set_HtmlUseInDocuText( bUsesHtmlInDocuText );
352 eCurTagState = ts_new;
353 if ( NOT i_bImplicit )
354 eDocuState = ds_std;
357 ary::doc::OldCppDocu &
358 Adoc_PE::CurDocu()
360 if (NOT pCurDocu)
361 pCurDocu = new ary::doc::OldCppDocu;
362 return *pCurDocu;
365 ary::info::AtTag &
366 Adoc_PE::CurAtTag()
368 if (NOT pCurAtTag)
370 if ( int(eDocuState) < int(ds_in_descr) )
372 InstallAtTag(
373 CurDocu().Create_StdTag(ary::info::atid_short),
374 true );
376 else
378 InstallAtTag(
379 CurDocu().Create_StdTag(ary::info::atid_descr),
380 true );
383 return *pCurAtTag;
386 void
387 Adoc_PE::RenameCurShortTag()
389 CurDocu().Replace_AtShort_By_AtDescr();
392 void
393 Adoc_PE::FinishCurShortTag()
395 InstallAtTag(
396 CurDocu().Create_StdTag(ary::info::atid_descr),
397 true );
401 } // namespace adoc