merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser / adoc / cx_a_sub.cxx
blob0d3b0760f719efba59aed175b5ea5582ff790075
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: cx_a_sub.cxx,v $
10 * $Revision: 1.6 $
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/cx_a_sub.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <tokens/parseinc.hxx>
37 #include <x_parse.hxx>
38 #include <adoc/tk_docw.hxx>
41 namespace adoc {
43 //************************ Cx_LineStart ************************//
45 Cx_LineStart::Cx_LineStart( TkpContext & i_rFollowUpContext )
46 : pDealer(0),
47 pFollowUpContext(&i_rFollowUpContext)
51 void
52 Cx_LineStart::ReadCharChain( CharacterSource & io_rText )
54 uintt nCount = 0;
55 for ( char cNext = io_rText.CurChar(); cNext == 32 OR cNext == 9; cNext = io_rText.MoveOn() )
57 if (cNext == 32)
58 nCount++;
59 else if (cNext == 9)
60 nCount += 4;
62 io_rText.CutToken();
64 if (nCount < 50)
65 pNewToken = new Tok_LineStart(UINT8(nCount));
66 else
67 pNewToken = new Tok_LineStart(0);
70 bool
71 Cx_LineStart::PassNewToken()
73 if (pNewToken)
75 pNewToken.Release()->DealOut(*pDealer);
76 return true;
78 return false;
81 TkpContext &
82 Cx_LineStart::FollowUpContext()
84 return *pFollowUpContext;
88 //************************ Cx_CheckStar ************************//
90 Cx_CheckStar::Cx_CheckStar( TkpContext & i_rFollowUpContext )
91 : pDealer(0),
92 pFollowUpContext(&i_rFollowUpContext),
93 pEnd_FollowUpContext(0),
94 bCanBeEnd(false),
95 bEndTokenFound(false)
100 void
101 Cx_CheckStar::ReadCharChain( CharacterSource & io_rText )
103 bEndTokenFound = false;
104 if (bCanBeEnd)
106 char cNext = jumpOver(io_rText,'*');
107 if ( NULCH == cNext )
108 throw X_Parser(X_Parser::x_UnexpectedEOF, "", String::Null_(), 0);
109 if (cNext == '/')
111 io_rText.MoveOn();
112 pNewToken = new Tok_EoDocu;
113 bEndTokenFound = true;
115 else
117 pNewToken = new Tok_DocWord(io_rText.CutToken());
120 else
122 jumpToWhite(io_rText);
123 pNewToken = new Tok_DocWord(io_rText.CutToken());
127 bool
128 Cx_CheckStar::PassNewToken()
130 if (pNewToken)
132 pNewToken.Release()->DealOut(*pDealer);
133 return true;
135 return false;
138 TkpContext &
139 Cx_CheckStar::FollowUpContext()
141 if (bEndTokenFound)
142 return *pEnd_FollowUpContext;
143 else
144 return *pFollowUpContext;
148 //************************ Cx_AtTagCompletion ************************//
150 Cx_AtTagCompletion::Cx_AtTagCompletion( TkpContext & i_rFollowUpContext )
151 : pDealer(0),
152 pFollowUpContext(&i_rFollowUpContext)
156 void
157 Cx_AtTagCompletion::ReadCharChain( CharacterSource & io_rText )
159 jumpToWhite(io_rText);
160 csv_assert(fCur_TokenCreateFunction != 0);
161 pNewToken = (*fCur_TokenCreateFunction)(io_rText.CutToken());
164 bool
165 Cx_AtTagCompletion::PassNewToken()
167 if (pNewToken)
169 pNewToken.Release()->DealOut(*pDealer);
170 return true;
172 return false;
175 TkpContext &
176 Cx_AtTagCompletion::FollowUpContext()
178 return *pFollowUpContext;
184 } // namespace adoc