merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser_i / idoc / cx_docu2.cxx
blob2f1422d59a57fb011446cd5ea0fef8fd78c0ec1b
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_docu2.cxx,v $
10 * $Revision: 1.8 $
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 <s2_dsapi/cx_docu2.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <../../parser/inc/tokens/parseinc.hxx>
37 #include <s2_dsapi/tokrecv.hxx>
38 #include <s2_dsapi/tk_html.hxx>
39 #include <s2_dsapi/tk_xml.hxx>
40 #include <s2_dsapi/tk_docw2.hxx>
41 #include <x_parse2.hxx>
45 namespace csi
47 namespace dsapi
52 bool
53 Cx_Base::PassNewToken()
55 if (pNewToken)
57 rReceiver.Receive(*pNewToken.Release());
59 return true;
61 return false;
64 TkpContext &
65 Cx_Base::FollowUpContext()
67 csv_assert(pFollowUpContext != 0);
68 return *pFollowUpContext;
71 void
72 Cx_Base::Handle_DocuSyntaxError( CharacterSource & io_rText )
74 // KORR_FUTURE
75 // Put this into Error Log File
77 Cerr() << "Error: Syntax error in documentation within "
78 << "this text:\n\""
79 << io_rText.CutToken()
80 << "\"."
81 << Endl();
82 SetToken( new Tok_Word(io_rText.CurToken()) );
85 void
86 Cx_EoHtml::ReadCharChain( CharacterSource & io_rText )
88 if ( NULCH == jumpTo(io_rText,'>') )
89 throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
90 io_rText.MoveOn();
91 SetToken(new Tok_HtmlTag(io_rText.CutToken(),bToken_IsStartOfParagraph));
94 void
95 Cx_EoXmlConst::ReadCharChain( CharacterSource & io_rText )
97 char c = jumpTo(io_rText,'>','*');
98 if ( NULCH == c OR '*' == c )
100 Handle_DocuSyntaxError(io_rText);
101 return;
104 io_rText.MoveOn();
105 io_rText.CutToken();
106 SetToken(new Tok_XmlConst(eTokenId));
109 void
110 Cx_EoXmlLink_BeginTag::ReadCharChain( CharacterSource & io_rText )
112 String sScope;
113 String sDim;
115 do {
116 char cReached = jumpTo(io_rText,'"','>','*');
117 switch (cReached)
119 case '"':
121 io_rText.MoveOn();
122 io_rText.CutToken();
123 char c = jumpTo(io_rText,'"','*', '>');
124 if ( NULCH == c OR '*' == c OR '>' == c)
126 if ( '>' == c )
127 io_rText.MoveOn();
128 Handle_DocuSyntaxError(io_rText);
129 return;
132 const char * pAttribute = io_rText.CutToken();
133 if ( *pAttribute != '[' )
134 sScope = pAttribute;
135 else
136 sDim = pAttribute;
138 io_rText.MoveOn();
139 break;
141 case '>':
142 break;
143 case '*':
144 Handle_DocuSyntaxError(io_rText);
145 return;
146 default:
147 throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
148 } // end switch
149 } while ( io_rText.CurChar() != '>' );
151 io_rText.MoveOn();
152 io_rText.CutToken();
153 SetToken( new Tok_XmlLink_BeginTag(eTokenId, sScope.c_str(), sDim.c_str()) );
156 void
157 Cx_EoXmlLink_EndTag::ReadCharChain( CharacterSource & io_rText )
159 char c = jumpTo(io_rText,'>','*');
160 if ( NULCH == c OR '*' == c )
162 Handle_DocuSyntaxError(io_rText);
163 return;
166 io_rText.MoveOn();
167 io_rText.CutToken();
168 SetToken(new Tok_XmlLink_EndTag(eTokenId));
171 void
172 Cx_EoXmlFormat_BeginTag::ReadCharChain( CharacterSource & io_rText )
174 String sDim;
176 char cReached = jumpTo(io_rText,'"','>','*');
177 switch (cReached)
179 case '"':
181 io_rText.MoveOn();
182 io_rText.CutToken();
184 char c = jumpTo(io_rText,'"','*','>');
185 if ( NULCH == c OR '*' == c OR '>' == c )
187 if ('>' == c )
188 io_rText.MoveOn();
189 Handle_DocuSyntaxError(io_rText);
190 return;
193 sDim = io_rText.CutToken();
195 c = jumpTo(io_rText,'>','*');
196 if ( NULCH == c OR '*' == c )
198 Handle_DocuSyntaxError(io_rText);
199 return;
201 break;
203 case '>':
204 break;
205 case '*':
206 Handle_DocuSyntaxError(io_rText);
207 return;
208 default:
209 throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
210 } // end switch
212 io_rText.MoveOn();
213 io_rText.CutToken();
214 SetToken(new Tok_XmlFormat_BeginTag(eTokenId, sDim));
217 void
218 Cx_EoXmlFormat_EndTag::ReadCharChain( CharacterSource & io_rText )
220 char c = jumpTo(io_rText,'>','*');
221 if ( NULCH == c OR '*' == c )
223 Handle_DocuSyntaxError(io_rText);
224 return;
227 io_rText.MoveOn();
228 io_rText.CutToken();
229 SetToken(new Tok_XmlFormat_EndTag(eTokenId));
232 void
233 Cx_CheckStar::ReadCharChain( CharacterSource & io_rText )
235 bEndTokenFound = false;
236 if (bIsEnd)
238 char cNext = jumpOver(io_rText,'*');
239 if ( NULCH == cNext )
240 throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
241 if (cNext == '/')
243 io_rText.MoveOn();
244 SetToken(new Tok_DocuEnd);
245 bEndTokenFound = true;
247 else
249 SetToken( new Tok_Word(io_rText.CutToken()) );
252 else
254 jumpToWhite(io_rText);
255 SetToken( new Tok_Word(io_rText.CutToken()) );
259 TkpContext &
260 Cx_CheckStar::FollowUpContext()
262 if (bEndTokenFound)
263 return *pEnd_FollowUpContext;
264 else
265 return Cx_Base::FollowUpContext();
268 } // namespace dsapi
269 } // namespace csi