1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docu_pe.cxx,v $
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 ************************************************************************/
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>
49 Adoc_PE::UsesHtmlInDocuText()
51 return bUsesHtmlInDocuText
;
61 nCurSpecialMeaningTokens(0),
62 nCurSubtractFromLineStart(0),
64 eDocuState(ds_wait_for_short
),
66 bUsesHtmlInDocuText(false)
75 Adoc_PE::Hdl_at_std( const Tok_at_std
& i_rTok
)
78 CurDocu().Create_StdTag(i_rTok
.Id()) );
82 Adoc_PE::Hdl_at_base( const Tok_at_base
& )
85 CurDocu().CheckIn_BaseTag() );
89 Adoc_PE::Hdl_at_exception( const Tok_at_exception
& )
92 CurDocu().CheckIn_ExceptionTag() );
96 Adoc_PE::Hdl_at_impl( const Tok_at_impl
& )
99 CurDocu().Create_ImplementsTag() );
103 Adoc_PE::Hdl_at_key( const Tok_at_key
& )
106 CurDocu().Create_KeywordTag() );
110 Adoc_PE::Hdl_at_param( const Tok_at_param
& )
113 CurDocu().CheckIn_ParameterTag() );
117 Adoc_PE::Hdl_at_see( const Tok_at_see
& )
120 CurDocu().CheckIn_SeeTag() );
124 Adoc_PE::Hdl_at_template( const Tok_at_template
& )
127 CurDocu().CheckIn_TemplateTag() );
131 Adoc_PE::Hdl_at_interface( const Tok_at_interface
& )
133 CurDocu().Set_Interface();
137 Adoc_PE::Hdl_at_internal( const Tok_at_internal
& )
139 CurDocu().Set_Internal();
143 Adoc_PE::Hdl_at_obsolete( const Tok_at_obsolete
& )
145 CurDocu().Set_Obsolete();
149 Adoc_PE::Hdl_at_module( const Tok_at_module
& )
153 // pCurAtTag = CurDocu().Assign2_ModuleTag();
154 // nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens();
158 Adoc_PE::Hdl_at_file( const Tok_at_file
& )
162 // pCurAtTag = CurDocu().Assign2_FileTag();
163 // nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens();
167 Adoc_PE::Hdl_at_gloss( const Tok_at_gloss
& )
171 // Create_GlossaryEntry();
175 Adoc_PE::Hdl_at_global( const Tok_at_global
& )
178 // Create_GlobalTextComponent();
182 Adoc_PE::Hdl_at_include( const Tok_at_include
& )
188 Adoc_PE::Hdl_at_label( const Tok_at_label
& )
191 CurDocu().Create_LabelTag() );
195 Adoc_PE::Hdl_at_since( const Tok_at_since
& )
198 CurDocu().Create_SinceTag() );
202 Adoc_PE::Hdl_at_HTML( const Tok_at_HTML
& )
204 bUsesHtmlInDocuText
= true;
208 Adoc_PE::Hdl_at_NOHTML( const Tok_at_NOHTML
& )
210 bUsesHtmlInDocuText
= false;
214 Adoc_PE::Hdl_DocWord( const Tok_DocWord
& i_rTok
)
216 bool bIsSpecial
= false;
217 if ( nCurSpecialMeaningTokens
> 0 )
219 bIsSpecial
= CurAtTag().Add_SpecialMeaningToken(
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();
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(),
247 CurAtTag().Add_Token( i_rTok
.Text() );
248 eCurTagState
= ts_std
;
253 Adoc_PE::Hdl_Whitespace( const Tok_Whitespace
& i_rTok
)
255 if ( eCurTagState
== ts_std
)
258 CurAtTag().Add_Whitespace(i_rTok
.Size());
263 Adoc_PE::Hdl_LineStart( const Tok_LineStart
& i_rTok
)
265 if ( pCurAtTag
== 0 )
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.
285 Adoc_PE::Hdl_Eol( const Tok_Eol
& )
287 if ( pCurAtTag
== 0 )
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
;
304 eDocuState
= ds_in_descr
;
307 case ds_1newline_after_short
: FinishCurShortTag();
308 eDocuState
= ds_in_descr
;
316 nCurSpecialMeaningTokens
= 0;
323 Adoc_PE::Hdl_EoDocu( const Tok_EoDocu
& )
328 DYN
ary::doc::OldCppDocu
*
329 Adoc_PE::ReleaseJustParsedDocu()
332 nLineCountInDocu
= 0;
333 nCurSpecialMeaningTokens
= 0;
334 nCurSubtractFromLineStart
= 0;
335 eCurTagState
= ts_new
;
336 eDocuState
= ds_wait_for_short
;
338 return pCurDocu
.Release();
342 Adoc_PE::InstallAtTag( DYN
ary::info::AtTag
* let_dpTag
,
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
)
357 ary::doc::OldCppDocu
&
361 pCurDocu
= new ary::doc::OldCppDocu
;
370 if ( int(eDocuState
) < int(ds_in_descr
) )
373 CurDocu().Create_StdTag(ary::info::atid_short
),
379 CurDocu().Create_StdTag(ary::info::atid_descr
),
387 Adoc_PE::RenameCurShortTag()
389 CurDocu().Replace_AtShort_By_AtDescr();
393 Adoc_PE::FinishCurShortTag()
396 CurDocu().Create_StdTag(ary::info::atid_descr
),