1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include <precomp.h>
29*cdf0e10cSrcweir #include <s2_dsapi/cx_docu2.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
33*cdf0e10cSrcweir #include <../../parser/inc/tokens/parseinc.hxx>
34*cdf0e10cSrcweir #include <s2_dsapi/tokrecv.hxx>
35*cdf0e10cSrcweir #include <s2_dsapi/tk_html.hxx>
36*cdf0e10cSrcweir #include <s2_dsapi/tk_xml.hxx>
37*cdf0e10cSrcweir #include <s2_dsapi/tk_docw2.hxx>
38*cdf0e10cSrcweir #include <x_parse2.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace csi
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir namespace dsapi
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir bool
50*cdf0e10cSrcweir Cx_Base::PassNewToken()
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir 	if (pNewToken)
53*cdf0e10cSrcweir 	{
54*cdf0e10cSrcweir 		rReceiver.Receive(*pNewToken.Release());
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 		return true;
57*cdf0e10cSrcweir 	}
58*cdf0e10cSrcweir 	return false;
59*cdf0e10cSrcweir }
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir TkpContext &
62*cdf0e10cSrcweir Cx_Base::FollowUpContext()
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 	csv_assert(pFollowUpContext != 0);
65*cdf0e10cSrcweir 	return *pFollowUpContext;
66*cdf0e10cSrcweir }
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir void
69*cdf0e10cSrcweir Cx_Base::Handle_DocuSyntaxError( CharacterSource & io_rText )
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir     // KORR_FUTURE
72*cdf0e10cSrcweir     // Put this into Error Log File
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir     Cerr() << "Error:  Syntax error in documentation within "
75*cdf0e10cSrcweir               << "this text:\n\""
76*cdf0e10cSrcweir               << io_rText.CutToken()
77*cdf0e10cSrcweir               << "\"."
78*cdf0e10cSrcweir               << Endl();
79*cdf0e10cSrcweir     SetToken( new Tok_Word(io_rText.CurToken()) );
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir void
83*cdf0e10cSrcweir Cx_EoHtml::ReadCharChain( CharacterSource & io_rText )
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir 	if ( NULCH == jumpTo(io_rText,'>') )
86*cdf0e10cSrcweir 		throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
87*cdf0e10cSrcweir 	io_rText.MoveOn();
88*cdf0e10cSrcweir 	SetToken(new Tok_HtmlTag(io_rText.CutToken(),bToken_IsStartOfParagraph));
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir void
92*cdf0e10cSrcweir Cx_EoXmlConst::ReadCharChain( CharacterSource & io_rText )
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir     char c = jumpTo(io_rText,'>','*');
95*cdf0e10cSrcweir 	if ( NULCH == c OR '*' == c )
96*cdf0e10cSrcweir     {
97*cdf0e10cSrcweir         Handle_DocuSyntaxError(io_rText);
98*cdf0e10cSrcweir         return;
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 	io_rText.MoveOn();
102*cdf0e10cSrcweir 	io_rText.CutToken();
103*cdf0e10cSrcweir 	SetToken(new Tok_XmlConst(eTokenId));
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir void
107*cdf0e10cSrcweir Cx_EoXmlLink_BeginTag::ReadCharChain( CharacterSource & io_rText )
108*cdf0e10cSrcweir {
109*cdf0e10cSrcweir 	String 	sScope;
110*cdf0e10cSrcweir 	String 	sDim;
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     do {
113*cdf0e10cSrcweir         char cReached = jumpTo(io_rText,'"','>','*');
114*cdf0e10cSrcweir         switch (cReached)
115*cdf0e10cSrcweir     	{
116*cdf0e10cSrcweir 	    	case '"':
117*cdf0e10cSrcweir             {
118*cdf0e10cSrcweir             	io_rText.MoveOn();
119*cdf0e10cSrcweir 			    io_rText.CutToken();
120*cdf0e10cSrcweir                 char c = jumpTo(io_rText,'"','*', '>');
121*cdf0e10cSrcweir             	if ( NULCH == c OR '*' == c OR '>' == c)
122*cdf0e10cSrcweir                 {
123*cdf0e10cSrcweir                     if ( '>' == c )
124*cdf0e10cSrcweir                     	io_rText.MoveOn();
125*cdf0e10cSrcweir                     Handle_DocuSyntaxError(io_rText);
126*cdf0e10cSrcweir                     return;
127*cdf0e10cSrcweir                 }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 		    	const char * pAttribute = io_rText.CutToken();
130*cdf0e10cSrcweir                 if ( *pAttribute != '[' )
131*cdf0e10cSrcweir                     sScope = pAttribute;
132*cdf0e10cSrcweir                 else
133*cdf0e10cSrcweir                     sDim = pAttribute;
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir                 io_rText.MoveOn();
136*cdf0e10cSrcweir     			break;
137*cdf0e10cSrcweir             }
138*cdf0e10cSrcweir 	    	case '>':
139*cdf0e10cSrcweir 		    	break;
140*cdf0e10cSrcweir             case '*':
141*cdf0e10cSrcweir                 Handle_DocuSyntaxError(io_rText);
142*cdf0e10cSrcweir                 return;
143*cdf0e10cSrcweir     		default:
144*cdf0e10cSrcweir 	    		throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
145*cdf0e10cSrcweir     	}   // end switch
146*cdf0e10cSrcweir     }   while ( io_rText.CurChar() != '>' );
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	io_rText.MoveOn();
149*cdf0e10cSrcweir 	io_rText.CutToken();
150*cdf0e10cSrcweir 	SetToken( new Tok_XmlLink_BeginTag(eTokenId, sScope.c_str(), sDim.c_str()) );
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir void
154*cdf0e10cSrcweir Cx_EoXmlLink_EndTag::ReadCharChain( CharacterSource & io_rText )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir     char c = jumpTo(io_rText,'>','*');
157*cdf0e10cSrcweir     if ( NULCH == c OR '*' == c )
158*cdf0e10cSrcweir     {
159*cdf0e10cSrcweir         Handle_DocuSyntaxError(io_rText);
160*cdf0e10cSrcweir         return;
161*cdf0e10cSrcweir     }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 	io_rText.MoveOn();
164*cdf0e10cSrcweir 	io_rText.CutToken();
165*cdf0e10cSrcweir 	SetToken(new Tok_XmlLink_EndTag(eTokenId));
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir void
169*cdf0e10cSrcweir Cx_EoXmlFormat_BeginTag::ReadCharChain( CharacterSource & io_rText )
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir 	String 	sDim;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     char cReached = jumpTo(io_rText,'"','>','*');
174*cdf0e10cSrcweir     switch (cReached)
175*cdf0e10cSrcweir     {
176*cdf0e10cSrcweir         case '"':
177*cdf0e10cSrcweir         {
178*cdf0e10cSrcweir             io_rText.MoveOn();
179*cdf0e10cSrcweir 			io_rText.CutToken();
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir             char c = jumpTo(io_rText,'"','*','>');
182*cdf0e10cSrcweir             if ( NULCH == c OR '*' == c OR '>' == c )
183*cdf0e10cSrcweir             {
184*cdf0e10cSrcweir                 if ('>' == c )
185*cdf0e10cSrcweir                     io_rText.MoveOn();
186*cdf0e10cSrcweir                 Handle_DocuSyntaxError(io_rText);
187*cdf0e10cSrcweir                 return;
188*cdf0e10cSrcweir             }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir 		    sDim = io_rText.CutToken();
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir             c = jumpTo(io_rText,'>','*');
193*cdf0e10cSrcweir             if ( NULCH == c OR '*' == c )
194*cdf0e10cSrcweir             {
195*cdf0e10cSrcweir                 Handle_DocuSyntaxError(io_rText);
196*cdf0e10cSrcweir                 return;
197*cdf0e10cSrcweir             }
198*cdf0e10cSrcweir     		break;
199*cdf0e10cSrcweir         }
200*cdf0e10cSrcweir         case '>':
201*cdf0e10cSrcweir 		   	break;
202*cdf0e10cSrcweir         case '*':
203*cdf0e10cSrcweir             Handle_DocuSyntaxError(io_rText);
204*cdf0e10cSrcweir             return;
205*cdf0e10cSrcweir     	default:
206*cdf0e10cSrcweir 	    	throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
207*cdf0e10cSrcweir     }   // end switch
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 	io_rText.MoveOn();
210*cdf0e10cSrcweir 	io_rText.CutToken();
211*cdf0e10cSrcweir 	SetToken(new Tok_XmlFormat_BeginTag(eTokenId, sDim));
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir void
215*cdf0e10cSrcweir Cx_EoXmlFormat_EndTag::ReadCharChain( CharacterSource & io_rText )
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir     char c = jumpTo(io_rText,'>','*');
218*cdf0e10cSrcweir     if ( NULCH == c OR '*' == c )
219*cdf0e10cSrcweir     {
220*cdf0e10cSrcweir         Handle_DocuSyntaxError(io_rText);
221*cdf0e10cSrcweir         return;
222*cdf0e10cSrcweir     }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	io_rText.MoveOn();
225*cdf0e10cSrcweir 	io_rText.CutToken();
226*cdf0e10cSrcweir 	SetToken(new Tok_XmlFormat_EndTag(eTokenId));
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir void
230*cdf0e10cSrcweir Cx_CheckStar::ReadCharChain( CharacterSource & io_rText )
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir 	bEndTokenFound = false;
233*cdf0e10cSrcweir 	if (bIsEnd)
234*cdf0e10cSrcweir 	{
235*cdf0e10cSrcweir 		char cNext = jumpOver(io_rText,'*');
236*cdf0e10cSrcweir 		if ( NULCH == cNext )
237*cdf0e10cSrcweir 			throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF);
238*cdf0e10cSrcweir 		if (cNext == '/')
239*cdf0e10cSrcweir 		{
240*cdf0e10cSrcweir 			io_rText.MoveOn();
241*cdf0e10cSrcweir 			SetToken(new Tok_DocuEnd);
242*cdf0e10cSrcweir             bEndTokenFound = true;
243*cdf0e10cSrcweir 		}
244*cdf0e10cSrcweir 		else
245*cdf0e10cSrcweir 		{
246*cdf0e10cSrcweir 			SetToken( new Tok_Word(io_rText.CutToken()) );
247*cdf0e10cSrcweir 		}
248*cdf0e10cSrcweir 	}
249*cdf0e10cSrcweir 	else
250*cdf0e10cSrcweir 	{
251*cdf0e10cSrcweir 		jumpToWhite(io_rText);
252*cdf0e10cSrcweir 		SetToken( new Tok_Word(io_rText.CutToken()) );
253*cdf0e10cSrcweir 	}
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir TkpContext &
257*cdf0e10cSrcweir Cx_CheckStar::FollowUpContext()
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir 	if (bEndTokenFound)
260*cdf0e10cSrcweir 		return *pEnd_FollowUpContext;
261*cdf0e10cSrcweir 	else
262*cdf0e10cSrcweir 		return Cx_Base::FollowUpContext();
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir }   // namespace dsapi
266*cdf0e10cSrcweir }   // namespace csi
267*cdf0e10cSrcweir 
268