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