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/docu_pe2.hxx> 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <cctype> 34*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx> 35*cdf0e10cSrcweir #include <ary_i/d_token.hxx> 36*cdf0e10cSrcweir #include <parser/parserinfo.hxx> 37*cdf0e10cSrcweir #include <adc_cl.hxx> 38*cdf0e10cSrcweir #include <adc_msg.hxx> 39*cdf0e10cSrcweir #include <../parser/inc/x_docu.hxx> 40*cdf0e10cSrcweir #include <s2_dsapi/dsapitok.hxx> 41*cdf0e10cSrcweir #include <s2_dsapi/tk_atag2.hxx> 42*cdf0e10cSrcweir #include <s2_dsapi/tk_html.hxx> 43*cdf0e10cSrcweir #include <s2_dsapi/tk_docw2.hxx> 44*cdf0e10cSrcweir #include <s2_dsapi/tk_xml.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #ifdef UNX 48*cdf0e10cSrcweir #define strnicmp strncasecmp 49*cdf0e10cSrcweir #endif 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir namespace csi 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir namespace dsapi 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir const char * AtTagTitle( 59*cdf0e10cSrcweir const Tok_AtTag & i_rToken ); 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir SapiDocu_PE::SapiDocu_PE(ParserInfo & io_rPositionInfo) 63*cdf0e10cSrcweir : pDocu(0), 64*cdf0e10cSrcweir eState(e_none), 65*cdf0e10cSrcweir pPositionInfo(&io_rPositionInfo), 66*cdf0e10cSrcweir fCurTokenAddFunction(&SapiDocu_PE::AddDocuToken2Void), 67*cdf0e10cSrcweir pCurAtTag(0), 68*cdf0e10cSrcweir sCurDimAttribute(), 69*cdf0e10cSrcweir sCurAtSeeType_byXML(200) 70*cdf0e10cSrcweir { 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir SapiDocu_PE::~SapiDocu_PE() 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void 78*cdf0e10cSrcweir SapiDocu_PE::ProcessToken( DYN csi::dsapi::Token & let_drToken ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir if (IsComplete()) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir pDocu = 0; 83*cdf0e10cSrcweir eState = e_none; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir if ( eState == e_none ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir pDocu = new ary::doc::OldIdlDocu; 89*cdf0e10cSrcweir eState = st_short; 90*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Short; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir csv_assert(pDocu); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir let_drToken.Trigger(*this); 96*cdf0e10cSrcweir delete &let_drToken; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void 100*cdf0e10cSrcweir SapiDocu_PE::Process_AtTag( const Tok_AtTag & i_rToken ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir if (NOT pCurAtTag) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir eState = st_attags; 105*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir else 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir csv_assert(eState == st_attags); 110*cdf0e10cSrcweir pDocu->AddAtTag(*pCurAtTag.Release()); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if (i_rToken.Id() == Tok_AtTag::param) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir pCurAtTag = new DT_ParameterAtTag; 116*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::SetCurParameterAtTagName; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir else if (i_rToken.Id() == Tok_AtTag::see) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir pCurAtTag = new DT_SeeAlsoAtTag; 121*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::SetCurSeeAlsoAtTagLinkText; 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir else if (i_rToken.Id() == Tok_AtTag::deprecated) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir pDocu->SetDeprecated(); 126*cdf0e10cSrcweir pCurAtTag = new DT_StdAtTag(""); // Dummy that will not be used. 127*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Deprecated; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir else if (i_rToken.Id() == Tok_AtTag::since) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir pCurAtTag = new DT_SinceAtTag; 132*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::SetCurSinceAtTagVersion_OOo; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir else 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir pCurAtTag = new DT_StdAtTag( AtTagTitle(i_rToken) ); 137*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir void 142*cdf0e10cSrcweir SapiDocu_PE::Process_HtmlTag( const Tok_HtmlTag & i_rToken ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if (eState == st_short AND i_rToken.IsParagraphStarter()) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir eState = st_description; 147*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Description; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // Workaround special for some errors in API docu: 151*cdf0e10cSrcweir if ( strnicmp("<true",i_rToken.Text(),5 ) == 0 ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir if ( strcmp("<TRUE/>",i_rToken.Text()) != 0 ) 154*cdf0e10cSrcweir TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), 155*cdf0e10cSrcweir pPositionInfo->CurFile(), 156*cdf0e10cSrcweir pPositionInfo->CurLine() ); 157*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>true</b>") ); 158*cdf0e10cSrcweir return; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir else if ( strnicmp("<false",i_rToken.Text(),6 ) == 0 ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir if ( strcmp("<FALSE/>",i_rToken.Text()) != 0 ) 163*cdf0e10cSrcweir TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), 164*cdf0e10cSrcweir pPositionInfo->CurFile(), 165*cdf0e10cSrcweir pPositionInfo->CurLine() ); 166*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>false</b>") ); 167*cdf0e10cSrcweir return; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir else if ( strnicmp("<NULL",i_rToken.Text(),5 ) == 0 ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir if ( strcmp("<NULL/>",i_rToken.Text()) != 0 ) 172*cdf0e10cSrcweir TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), 173*cdf0e10cSrcweir pPositionInfo->CurFile(), 174*cdf0e10cSrcweir pPositionInfo->CurLine() ); 175*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>null</b>") ); 176*cdf0e10cSrcweir return; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir else if ( strnicmp("<void",i_rToken.Text(),5 ) == 0 ) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir if ( strcmp("<void/>",i_rToken.Text()) != 0 ) 181*cdf0e10cSrcweir TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), 182*cdf0e10cSrcweir pPositionInfo->CurFile(), 183*cdf0e10cSrcweir pPositionInfo->CurLine() ); 184*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>void</b>") ); 185*cdf0e10cSrcweir return; 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_Style(i_rToken.Text(),false) ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir void 192*cdf0e10cSrcweir SapiDocu_PE::Process_XmlConst( const Tok_XmlConst & i_rToken ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_MupConst(i_rToken.Text())); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir void 198*cdf0e10cSrcweir SapiDocu_PE::Process_XmlLink_BeginTag( const Tok_XmlLink_BeginTag & i_rToken ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir switch (i_rToken.Id()) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir case Tok_XmlLink_Tag::e_const: 203*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("<b>",false)); 204*cdf0e10cSrcweir break; 205*cdf0e10cSrcweir case Tok_XmlLink_Tag::member: 206*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_MupMember(i_rToken.Scope())); 207*cdf0e10cSrcweir break; 208*cdf0e10cSrcweir case Tok_XmlLink_Tag::type: 209*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_MupType(i_rToken.Scope())); 210*cdf0e10cSrcweir break; 211*cdf0e10cSrcweir default: 212*cdf0e10cSrcweir // Do nothing. 213*cdf0e10cSrcweir ; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir if ( i_rToken.Dim().length() > 0 ) 217*cdf0e10cSrcweir sCurDimAttribute = i_rToken.Dim(); 218*cdf0e10cSrcweir else 219*cdf0e10cSrcweir sCurDimAttribute.clear(); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir void 223*cdf0e10cSrcweir SapiDocu_PE::Process_XmlLink_EndTag( const Tok_XmlLink_EndTag & i_rToken ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir switch (i_rToken.Id()) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir case Tok_XmlLink_Tag::e_const: 228*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("</b>",false)); 229*cdf0e10cSrcweir break; 230*cdf0e10cSrcweir case Tok_XmlLink_Tag::member: 231*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_MupMember(true)); 232*cdf0e10cSrcweir break; 233*cdf0e10cSrcweir case Tok_XmlLink_Tag::type: 234*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_MupType(true)); 235*cdf0e10cSrcweir break; 236*cdf0e10cSrcweir default: 237*cdf0e10cSrcweir // Do nothing. 238*cdf0e10cSrcweir ; 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir if ( sCurDimAttribute.length() > 0 ) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_TextToken(sCurDimAttribute.c_str()) ); 243*cdf0e10cSrcweir sCurDimAttribute.clear(); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir void 248*cdf0e10cSrcweir SapiDocu_PE::Process_XmlFormat_BeginTag( const Tok_XmlFormat_BeginTag & i_rToken ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir switch (i_rToken.Id()) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir case Tok_XmlFormat_Tag::code: 253*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("<code>",false)); 254*cdf0e10cSrcweir break; 255*cdf0e10cSrcweir case Tok_XmlFormat_Tag::listing: 256*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("<pre>",true)); 257*cdf0e10cSrcweir break; 258*cdf0e10cSrcweir case Tok_XmlFormat_Tag::atom: 259*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("<code>",true)); 260*cdf0e10cSrcweir break; 261*cdf0e10cSrcweir default: 262*cdf0e10cSrcweir // Do nothing. 263*cdf0e10cSrcweir ; 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir if ( i_rToken.Dim().length() > 0 ) 266*cdf0e10cSrcweir sCurDimAttribute = i_rToken.Dim(); 267*cdf0e10cSrcweir else 268*cdf0e10cSrcweir sCurDimAttribute.clear(); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir void 272*cdf0e10cSrcweir SapiDocu_PE::Process_XmlFormat_EndTag( const Tok_XmlFormat_EndTag & i_rToken ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir switch (i_rToken.Id()) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir case Tok_XmlFormat_Tag::code: 277*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("</code>",false)); 278*cdf0e10cSrcweir break; 279*cdf0e10cSrcweir case Tok_XmlFormat_Tag::listing: 280*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("</pre>",true)); 281*cdf0e10cSrcweir break; 282*cdf0e10cSrcweir case Tok_XmlFormat_Tag::atom: 283*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_Style("</code>",true)); 284*cdf0e10cSrcweir break; 285*cdf0e10cSrcweir default: 286*cdf0e10cSrcweir // Do nothing. 287*cdf0e10cSrcweir ; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir if ( sCurDimAttribute.length() > 0 ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir (this->*fCurTokenAddFunction)( *new DT_TextToken(sCurDimAttribute.c_str()) ); 292*cdf0e10cSrcweir sCurDimAttribute.clear(); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir void 297*cdf0e10cSrcweir SapiDocu_PE::Process_Word( const Tok_Word & i_rToken ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_TextToken(i_rToken.Text())); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir void 303*cdf0e10cSrcweir SapiDocu_PE::Process_Comma() 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir csv_assert(1==7); 306*cdf0e10cSrcweir // (this->*fCurTokenAddFunction)(*new DT_Comma(i_rToken.Text())); 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir void 310*cdf0e10cSrcweir SapiDocu_PE::Process_DocuEnd() 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir eState = st_complete; 313*cdf0e10cSrcweir if (pCurAtTag) 314*cdf0e10cSrcweir pDocu->AddAtTag(*pCurAtTag.Release()); 315*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Void; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir void 319*cdf0e10cSrcweir SapiDocu_PE::Process_EOL() 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_EOL); 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir void 325*cdf0e10cSrcweir SapiDocu_PE::Process_White() 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir (this->*fCurTokenAddFunction)(*new DT_White); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir DYN ary::doc::OldIdlDocu * 331*cdf0e10cSrcweir SapiDocu_PE::ReleaseJustParsedDocu() 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir if (IsComplete()) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir eState = e_none; 336*cdf0e10cSrcweir return pDocu.Release(); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir return 0; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir bool 343*cdf0e10cSrcweir SapiDocu_PE::IsComplete() const 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir return eState == st_complete; 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir void 349*cdf0e10cSrcweir SapiDocu_PE::AddDocuToken2Void( DYN ary::inf::DocuToken & let_drNewToken ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir delete &let_drNewToken; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir void 355*cdf0e10cSrcweir SapiDocu_PE::AddDocuToken2Short( DYN ary::inf::DocuToken & let_drNewToken ) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir csv_assert(pDocu); 358*cdf0e10cSrcweir pDocu->AddToken2Short(let_drNewToken); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir void 362*cdf0e10cSrcweir SapiDocu_PE::AddDocuToken2Description( DYN ary::inf::DocuToken & let_drNewToken ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir csv_assert(pDocu); 365*cdf0e10cSrcweir pDocu->AddToken2Description(let_drNewToken); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir void 369*cdf0e10cSrcweir SapiDocu_PE::AddDocuToken2Deprecated( DYN ary::inf::DocuToken & let_drNewToken ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir csv_assert(pDocu); 372*cdf0e10cSrcweir pDocu->AddToken2DeprecatedText(let_drNewToken); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir void 376*cdf0e10cSrcweir SapiDocu_PE::AddDocuToken2CurAtTag( DYN ary::inf::DocuToken & let_drNewToken ) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir csv_assert(pCurAtTag); 379*cdf0e10cSrcweir pCurAtTag->AddToken(let_drNewToken); 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir void 383*cdf0e10cSrcweir SapiDocu_PE::SetCurParameterAtTagName( DYN ary::inf::DocuToken & let_drNewToken ) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir if (let_drNewToken.IsWhiteOnly()) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir delete &let_drNewToken; 388*cdf0e10cSrcweir return; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir csv_assert(pCurAtTag); 392*cdf0e10cSrcweir DT_TextToken * dpText = dynamic_cast< DT_TextToken* >(&let_drNewToken); 393*cdf0e10cSrcweir if (dpText != 0) 394*cdf0e10cSrcweir pCurAtTag->SetName(dpText->GetText()); 395*cdf0e10cSrcweir else 396*cdf0e10cSrcweir pCurAtTag->SetName("parameter ?"); 397*cdf0e10cSrcweir delete &let_drNewToken; 398*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir void 402*cdf0e10cSrcweir SapiDocu_PE::SetCurSeeAlsoAtTagLinkText( DYN ary::inf::DocuToken & let_drNewToken ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir csv_assert(pCurAtTag); 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir if (let_drNewToken.IsWhiteOnly()) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir delete &let_drNewToken; 409*cdf0e10cSrcweir return; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir DT_TextToken * pText = dynamic_cast< DT_TextToken* >(&let_drNewToken); 413*cdf0e10cSrcweir if (pText != 0) 414*cdf0e10cSrcweir pCurAtTag->SetName(pText->GetText()); 415*cdf0e10cSrcweir else 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir DT_MupType * 418*cdf0e10cSrcweir pTypeBegin = dynamic_cast< DT_MupType* >(&let_drNewToken); 419*cdf0e10cSrcweir DT_MupMember * 420*cdf0e10cSrcweir pMemberBegin = dynamic_cast< DT_MupMember* >(&let_drNewToken); 421*cdf0e10cSrcweir if (pTypeBegin != 0 OR pMemberBegin != 0) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir sCurAtSeeType_byXML.reset(); 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir sCurAtSeeType_byXML 426*cdf0e10cSrcweir << ( pTypeBegin != 0 427*cdf0e10cSrcweir ? pTypeBegin->Scope() 428*cdf0e10cSrcweir : pMemberBegin->Scope() ); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir if (sCurAtSeeType_byXML.tellp() > 0) 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir sCurAtSeeType_byXML 433*cdf0e10cSrcweir << "::"; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir delete &let_drNewToken; 436*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_2; 437*cdf0e10cSrcweir return; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir else 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir pCurAtTag->SetName("? (no identifier found)"); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir delete &let_drNewToken; 445*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir void 449*cdf0e10cSrcweir SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_2( DYN ary::inf::DocuToken & let_drNewToken ) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir csv_assert(pCurAtTag); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir if (let_drNewToken.IsWhiteOnly()) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir delete &let_drNewToken; 456*cdf0e10cSrcweir return; 457*cdf0e10cSrcweir } 458*cdf0e10cSrcweir 459*cdf0e10cSrcweir DT_TextToken * 460*cdf0e10cSrcweir pText = dynamic_cast< DT_TextToken* >(&let_drNewToken); 461*cdf0e10cSrcweir if (pText != 0) 462*cdf0e10cSrcweir { 463*cdf0e10cSrcweir sCurAtSeeType_byXML 464*cdf0e10cSrcweir << pText->GetText(); 465*cdf0e10cSrcweir pCurAtTag->SetName(sCurAtSeeType_byXML.c_str()); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir else 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir pCurAtTag->SetName("? (no identifier found)"); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir sCurAtSeeType_byXML.reset(); 472*cdf0e10cSrcweir delete &let_drNewToken; 473*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_3; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir void 477*cdf0e10cSrcweir SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_3( DYN ary::inf::DocuToken & let_drNewToken ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir csv_assert(pCurAtTag); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir if (let_drNewToken.IsWhiteOnly()) 482*cdf0e10cSrcweir { 483*cdf0e10cSrcweir delete &let_drNewToken; 484*cdf0e10cSrcweir return; 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir /// Could emit warning, but don't because this parser is obsolete. 488*cdf0e10cSrcweir // Tok_XmlLink_BeginTag * 489*cdf0e10cSrcweir // pLinkEnd = dynamic_cast< Tok_XmlLink_EndTag* >(&let_drNewToken); 490*cdf0e10cSrcweir // if (pLinkEnd == 0) 491*cdf0e10cSrcweir // { 492*cdf0e10cSrcweir // warn_aboutMissingClosingTag(); 493*cdf0e10cSrcweir // } 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir delete &let_drNewToken; 496*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir const String 500*cdf0e10cSrcweir C_sSinceFormat("Correct version format: \"OOo <major>.<minor>[.<micro> if micro is not 0]\"."); 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir void 503*cdf0e10cSrcweir SapiDocu_PE::SetCurSinceAtTagVersion_OOo( DYN ary::inf::DocuToken & let_drNewToken ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir csv_assert(pCurAtTag); 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir DT_TextToken * pToken = dynamic_cast< DT_TextToken* >(&let_drNewToken); 508*cdf0e10cSrcweir if (pToken == 0) 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir delete &let_drNewToken; 511*cdf0e10cSrcweir return; 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir const String 515*cdf0e10cSrcweir sVersion(pToken->GetText()); 516*cdf0e10cSrcweir if (NOT CheckVersionSyntax_OOo(sVersion)) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir Cerr() << "Version information in @since tag has incorrect format.\n" 519*cdf0e10cSrcweir << "Found: \"" << sVersion << "\"\n" 520*cdf0e10cSrcweir << C_sSinceFormat 521*cdf0e10cSrcweir << Endl(); 522*cdf0e10cSrcweir exit(1); 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir const autodoc::CommandLine & 526*cdf0e10cSrcweir rCommandLine = autodoc::CommandLine::Get_(); 527*cdf0e10cSrcweir if (NOT rCommandLine.DoesTransform_SinceTag()) 528*cdf0e10cSrcweir pCurAtTag->AddToken(let_drNewToken); 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::SetCurSinceAtTagVersion_Number; 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir void 534*cdf0e10cSrcweir SapiDocu_PE::SetCurSinceAtTagVersion_Number( DYN ary::inf::DocuToken & let_drNewToken ) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir csv_assert(pCurAtTag); 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir DT_TextToken * pToken = dynamic_cast< DT_TextToken* >(&let_drNewToken); 539*cdf0e10cSrcweir if (pToken == 0) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir if (dynamic_cast< DT_White* >(&let_drNewToken) != 0) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir String & 544*cdf0e10cSrcweir sValue = pCurAtTag->Access_Text().Access_TextOfFirstToken(); 545*cdf0e10cSrcweir StreamLock 546*cdf0e10cSrcweir sHelp(1000); 547*cdf0e10cSrcweir sValue = sHelp() << sValue << " " << c_str; 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir delete &let_drNewToken; 551*cdf0e10cSrcweir return; 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir const String 555*cdf0e10cSrcweir sVersion(pToken->GetText()); 556*cdf0e10cSrcweir if (NOT CheckVersionSyntax_Number(sVersion)) 557*cdf0e10cSrcweir { 558*cdf0e10cSrcweir Cerr() << "Version information in @since tag has incorrect format.\n" 559*cdf0e10cSrcweir << "Found: \"" << sVersion << "\"\n" 560*cdf0e10cSrcweir << C_sSinceFormat 561*cdf0e10cSrcweir << Endl(); 562*cdf0e10cSrcweir exit(1); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir const autodoc::CommandLine & 566*cdf0e10cSrcweir rCommandLine = autodoc::CommandLine::Get_(); 567*cdf0e10cSrcweir if ( rCommandLine.DoesTransform_SinceTag()) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir pCurAtTag->AddToken(let_drNewToken); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir if (rCommandLine.DisplayOf_SinceTagValue(sVersion).empty()) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir // This is the numbered part, but we don't know it. 574*cdf0e10cSrcweir delete &let_drNewToken; 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir StreamLock 577*cdf0e10cSrcweir sl(200); 578*cdf0e10cSrcweir sl() 579*cdf0e10cSrcweir << "Since-value '" 580*cdf0e10cSrcweir << sVersion 581*cdf0e10cSrcweir << "' not found in translation table."; 582*cdf0e10cSrcweir throw X_Docu("since", sl().c_str()); 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir else 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir AddDocuToken2SinceAtTag(let_drNewToken); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2SinceAtTag; 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir void 593*cdf0e10cSrcweir SapiDocu_PE::AddDocuToken2SinceAtTag( DYN ary::inf::DocuToken & let_drNewToken ) 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir csv_assert(pCurAtTag); 596*cdf0e10cSrcweir String & 597*cdf0e10cSrcweir sValue = pCurAtTag->Access_Text().Access_TextOfFirstToken(); 598*cdf0e10cSrcweir StreamLock 599*cdf0e10cSrcweir sHelp(1000); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir DT_TextToken * 602*cdf0e10cSrcweir pToken = dynamic_cast< DT_TextToken* >(&let_drNewToken); 603*cdf0e10cSrcweir if (pToken != 0) 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir sValue = sHelp() << sValue << pToken->GetText() << c_str; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir else if (dynamic_cast< DT_White* >(&let_drNewToken) != 0) 608*cdf0e10cSrcweir { 609*cdf0e10cSrcweir sValue = sHelp() << sValue << " " << c_str; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir delete &let_drNewToken; 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir bool 615*cdf0e10cSrcweir SapiDocu_PE::CheckVersionSyntax_OOo(const String & i_versionPart1) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir return i_versionPart1 == "OOo" 618*cdf0e10cSrcweir OR i_versionPart1 == "OpenOffice.org"; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir bool 622*cdf0e10cSrcweir SapiDocu_PE::CheckVersionSyntax_Number(const String & i_versionPart2) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir if (i_versionPart2.length () == 0) 625*cdf0e10cSrcweir return false; 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir const char 628*cdf0e10cSrcweir pt = '.'; 629*cdf0e10cSrcweir unsigned int countDigit = 0; 630*cdf0e10cSrcweir unsigned int countPoint = 0; 631*cdf0e10cSrcweir const char * 632*cdf0e10cSrcweir pFirstPoint = 0; 633*cdf0e10cSrcweir const char * 634*cdf0e10cSrcweir pLastPoint = 0; 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir for ( const char * p = i_versionPart2.begin(); 637*cdf0e10cSrcweir *p != 0; 638*cdf0e10cSrcweir ++p ) 639*cdf0e10cSrcweir { 640*cdf0e10cSrcweir if ( std::isdigit(*p) ) 641*cdf0e10cSrcweir ++countDigit; 642*cdf0e10cSrcweir else if (*p == pt) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir if (countPoint == 0) 645*cdf0e10cSrcweir pFirstPoint = p; 646*cdf0e10cSrcweir pLastPoint = p; 647*cdf0e10cSrcweir ++countPoint; 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir } 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir if ( countDigit + countPoint == i_versionPart2.length() // only digits and points 652*cdf0e10cSrcweir AND pFirstPoint != 0 AND countPoint < 3 // 1 or 2 points 653*cdf0e10cSrcweir AND pFirstPoint + 1 != pLastPoint // there are digits between two points 654*cdf0e10cSrcweir AND *i_versionPart2.begin() != pt AND *(pLastPoint + 1) != 0 // points are surrounded by digits 655*cdf0e10cSrcweir AND (*(pLastPoint + 1) != '0' OR pLastPoint == pFirstPoint) ) // the first micro-digit is not 0 656*cdf0e10cSrcweir { 657*cdf0e10cSrcweir return true; 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir return false; 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir const char * 663*cdf0e10cSrcweir AtTagTitle( const Tok_AtTag & i_rToken ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir switch (i_rToken.Id()) 666*cdf0e10cSrcweir { 667*cdf0e10cSrcweir case Tok_AtTag::author: return ""; 668*cdf0e10cSrcweir case Tok_AtTag::see: return "See also"; 669*cdf0e10cSrcweir case Tok_AtTag::param: return "Parameters"; 670*cdf0e10cSrcweir case Tok_AtTag::e_return: return "Returns"; 671*cdf0e10cSrcweir case Tok_AtTag::e_throw: return "Throws"; 672*cdf0e10cSrcweir case Tok_AtTag::example: return "Example"; 673*cdf0e10cSrcweir case Tok_AtTag::deprecated: return "Deprecated"; 674*cdf0e10cSrcweir case Tok_AtTag::suspicious: return ""; 675*cdf0e10cSrcweir case Tok_AtTag::missing: return ""; 676*cdf0e10cSrcweir case Tok_AtTag::incomplete: return ""; 677*cdf0e10cSrcweir case Tok_AtTag::version: return ""; 678*cdf0e10cSrcweir case Tok_AtTag::guarantees: return "Guarantees"; 679*cdf0e10cSrcweir case Tok_AtTag::exception: return "Exception"; 680*cdf0e10cSrcweir case Tok_AtTag::since: return "Since version"; 681*cdf0e10cSrcweir default: 682*cdf0e10cSrcweir // See below. 683*cdf0e10cSrcweir ; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir return i_rToken.Text(); 686*cdf0e10cSrcweir } 687*cdf0e10cSrcweir 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir } // namespace dsapi 691*cdf0e10cSrcweir } // namespace csi 692*cdf0e10cSrcweir 693