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