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 <adoc/docu_pe.hxx> 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <ary/doc/d_oldcppdocu.hxx> 34*cdf0e10cSrcweir #include <ary/info/ci_attag.hxx> 35*cdf0e10cSrcweir #include <ary/info/ci_text.hxx> 36*cdf0e10cSrcweir #include <adoc/adoc_tok.hxx> 37*cdf0e10cSrcweir #include <adoc/tk_attag.hxx> 38*cdf0e10cSrcweir #include <adoc/tk_docw.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace adoc 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir inline bool 46*cdf0e10cSrcweir Adoc_PE::UsesHtmlInDocuText() 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir return bUsesHtmlInDocuText; 49*cdf0e10cSrcweir } 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir Adoc_PE::Adoc_PE() 55*cdf0e10cSrcweir : pCurDocu(0), 56*cdf0e10cSrcweir pCurAtTag(0), 57*cdf0e10cSrcweir nLineCountInDocu(0), 58*cdf0e10cSrcweir nCurSpecialMeaningTokens(0), 59*cdf0e10cSrcweir nCurSubtractFromLineStart(0), 60*cdf0e10cSrcweir eCurTagState(ts_new), 61*cdf0e10cSrcweir eDocuState(ds_wait_for_short), 62*cdf0e10cSrcweir bIsComplete(false), 63*cdf0e10cSrcweir bUsesHtmlInDocuText(false) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir Adoc_PE::~Adoc_PE() 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir void 72*cdf0e10cSrcweir Adoc_PE::Hdl_at_std( const Tok_at_std & i_rTok ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir InstallAtTag( 75*cdf0e10cSrcweir CurDocu().Create_StdTag(i_rTok.Id()) ); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir void 79*cdf0e10cSrcweir Adoc_PE::Hdl_at_base( const Tok_at_base & ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir InstallAtTag( 82*cdf0e10cSrcweir CurDocu().CheckIn_BaseTag() ); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir void 86*cdf0e10cSrcweir Adoc_PE::Hdl_at_exception( const Tok_at_exception & ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir InstallAtTag( 89*cdf0e10cSrcweir CurDocu().CheckIn_ExceptionTag() ); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir void 93*cdf0e10cSrcweir Adoc_PE::Hdl_at_impl( const Tok_at_impl & ) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir InstallAtTag( 96*cdf0e10cSrcweir CurDocu().Create_ImplementsTag() ); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void 100*cdf0e10cSrcweir Adoc_PE::Hdl_at_key( const Tok_at_key & ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir InstallAtTag( 103*cdf0e10cSrcweir CurDocu().Create_KeywordTag() ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir void 107*cdf0e10cSrcweir Adoc_PE::Hdl_at_param( const Tok_at_param & ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir InstallAtTag( 110*cdf0e10cSrcweir CurDocu().CheckIn_ParameterTag() ); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir void 114*cdf0e10cSrcweir Adoc_PE::Hdl_at_see( const Tok_at_see & ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir InstallAtTag( 117*cdf0e10cSrcweir CurDocu().CheckIn_SeeTag() ); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void 121*cdf0e10cSrcweir Adoc_PE::Hdl_at_template( const Tok_at_template & ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir InstallAtTag( 124*cdf0e10cSrcweir CurDocu().CheckIn_TemplateTag() ); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir void 128*cdf0e10cSrcweir Adoc_PE::Hdl_at_interface( const Tok_at_interface & ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir CurDocu().Set_Interface(); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void 134*cdf0e10cSrcweir Adoc_PE::Hdl_at_internal( const Tok_at_internal & ) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir CurDocu().Set_Internal(); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir void 140*cdf0e10cSrcweir Adoc_PE::Hdl_at_obsolete( const Tok_at_obsolete & ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir CurDocu().Set_Obsolete(); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir void 146*cdf0e10cSrcweir Adoc_PE::Hdl_at_module( const Tok_at_module & ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir // KORR_FUTURE 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir // pCurAtTag = CurDocu().Assign2_ModuleTag(); 151*cdf0e10cSrcweir // nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens(); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir void 155*cdf0e10cSrcweir Adoc_PE::Hdl_at_file( const Tok_at_file & ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir // KORR_FUTURE 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // pCurAtTag = CurDocu().Assign2_FileTag(); 160*cdf0e10cSrcweir // nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens(); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir void 164*cdf0e10cSrcweir Adoc_PE::Hdl_at_gloss( const Tok_at_gloss & ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir // KORR_FUTURE 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir // Create_GlossaryEntry(); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir void 172*cdf0e10cSrcweir Adoc_PE::Hdl_at_global( const Tok_at_global & ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir // KORR_FUTURE 175*cdf0e10cSrcweir // Create_GlobalTextComponent(); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir void 179*cdf0e10cSrcweir Adoc_PE::Hdl_at_include( const Tok_at_include & ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir // KORR_FUTURE 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir void 185*cdf0e10cSrcweir Adoc_PE::Hdl_at_label( const Tok_at_label & ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir InstallAtTag( 188*cdf0e10cSrcweir CurDocu().Create_LabelTag() ); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir void 192*cdf0e10cSrcweir Adoc_PE::Hdl_at_since( const Tok_at_since & ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir InstallAtTag( 195*cdf0e10cSrcweir CurDocu().Create_SinceTag() ); 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir void 199*cdf0e10cSrcweir Adoc_PE::Hdl_at_HTML( const Tok_at_HTML & ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir bUsesHtmlInDocuText = true; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir void 205*cdf0e10cSrcweir Adoc_PE::Hdl_at_NOHTML( const Tok_at_NOHTML & ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir bUsesHtmlInDocuText = false; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir void 211*cdf0e10cSrcweir Adoc_PE::Hdl_DocWord( const Tok_DocWord & i_rTok ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir bool bIsSpecial = false; 214*cdf0e10cSrcweir if ( nCurSpecialMeaningTokens > 0 ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir bIsSpecial = CurAtTag().Add_SpecialMeaningToken( 217*cdf0e10cSrcweir i_rTok.Text(), 218*cdf0e10cSrcweir CurAtTag().NrOfSpecialMeaningTokens() 219*cdf0e10cSrcweir - (--nCurSpecialMeaningTokens) ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir if ( NOT bIsSpecial ) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir if ( eDocuState == ds_wait_for_short OR eDocuState == ds_1newline_after_short ) 225*cdf0e10cSrcweir eDocuState = ds_in_short; 226*cdf0e10cSrcweir if (nLineCountInDocu == 0) 227*cdf0e10cSrcweir nLineCountInDocu = 1; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir uintt nLength = i_rTok.Length(); 230*cdf0e10cSrcweir if ( nLength > 2 ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir bool bMaybeGlobalLink = strncmp( "::", i_rTok.Text(), 2 ) == 0; 233*cdf0e10cSrcweir bool bMayBeFunction = *(i_rTok.Text() + nLength - 2) == '(' 234*cdf0e10cSrcweir AND *(i_rTok.Text() + nLength - 1) == ')'; 235*cdf0e10cSrcweir if ( bMaybeGlobalLink OR bMayBeFunction ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir CurAtTag().Add_PotentialLink( i_rTok.Text(), 238*cdf0e10cSrcweir bMaybeGlobalLink, 239*cdf0e10cSrcweir bMayBeFunction ); 240*cdf0e10cSrcweir return; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir CurAtTag().Add_Token( i_rTok.Text() ); 245*cdf0e10cSrcweir eCurTagState = ts_std; 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir void 250*cdf0e10cSrcweir Adoc_PE::Hdl_Whitespace( const Tok_Whitespace & i_rTok ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if ( eCurTagState == ts_std ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir CurAtTag().Add_Whitespace(i_rTok.Size()); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir void 260*cdf0e10cSrcweir Adoc_PE::Hdl_LineStart( const Tok_LineStart & i_rTok ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir if ( pCurAtTag == 0 ) 263*cdf0e10cSrcweir return; 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if ( nLineCountInDocu == 2 ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir nCurSubtractFromLineStart = i_rTok.Size(); 268*cdf0e10cSrcweir eCurTagState = ts_std; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir else if ( nLineCountInDocu > 2 ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir if ( i_rTok.Size() > nCurSubtractFromLineStart ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir CurAtTag().Add_Whitespace( i_rTok.Size() 275*cdf0e10cSrcweir - nCurSubtractFromLineStart ); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir // else do nothing, because there is no whitespace. 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir void 282*cdf0e10cSrcweir Adoc_PE::Hdl_Eol( const Tok_Eol & ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir if ( pCurAtTag == 0 ) 285*cdf0e10cSrcweir return; 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir nLineCountInDocu++; 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir if ( nCurSpecialMeaningTokens == 0 ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir CurAtTag().Add_Eol(); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir switch ( eDocuState ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir case ds_wait_for_short: break; 296*cdf0e10cSrcweir case ds_in_short: if ( nLineCountInDocu < 4 ) 297*cdf0e10cSrcweir eDocuState = ds_1newline_after_short; 298*cdf0e10cSrcweir else 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir RenameCurShortTag(); 301*cdf0e10cSrcweir eDocuState = ds_in_descr; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir break; 304*cdf0e10cSrcweir case ds_1newline_after_short: FinishCurShortTag(); 305*cdf0e10cSrcweir eDocuState = ds_in_descr; 306*cdf0e10cSrcweir break; 307*cdf0e10cSrcweir default: 308*cdf0e10cSrcweir ; // Do noting. 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir else 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir nCurSpecialMeaningTokens = 0; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir void 320*cdf0e10cSrcweir Adoc_PE::Hdl_EoDocu( const Tok_EoDocu & ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir bIsComplete = true; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir DYN ary::doc::OldCppDocu * 326*cdf0e10cSrcweir Adoc_PE::ReleaseJustParsedDocu() 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir pCurAtTag = 0; 329*cdf0e10cSrcweir nLineCountInDocu = 0; 330*cdf0e10cSrcweir nCurSpecialMeaningTokens = 0; 331*cdf0e10cSrcweir nCurSubtractFromLineStart = 0; 332*cdf0e10cSrcweir eCurTagState = ts_new; 333*cdf0e10cSrcweir eDocuState = ds_wait_for_short; 334*cdf0e10cSrcweir bIsComplete = false; 335*cdf0e10cSrcweir return pCurDocu.Release(); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir void 339*cdf0e10cSrcweir Adoc_PE::InstallAtTag( DYN ary::info::AtTag * let_dpTag, 340*cdf0e10cSrcweir bool i_bImplicit ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir pCurAtTag = let_dpTag; 343*cdf0e10cSrcweir if ( pCurAtTag != 0 ) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir nCurSpecialMeaningTokens = pCurAtTag->NrOfSpecialMeaningTokens(); 346*cdf0e10cSrcweir pCurAtTag->Set_HtmlUseInDocuText( bUsesHtmlInDocuText ); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir eCurTagState = ts_new; 350*cdf0e10cSrcweir if ( NOT i_bImplicit ) 351*cdf0e10cSrcweir eDocuState = ds_std; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir ary::doc::OldCppDocu & 355*cdf0e10cSrcweir Adoc_PE::CurDocu() 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir if (NOT pCurDocu) 358*cdf0e10cSrcweir pCurDocu = new ary::doc::OldCppDocu; 359*cdf0e10cSrcweir return *pCurDocu; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir ary::info::AtTag & 363*cdf0e10cSrcweir Adoc_PE::CurAtTag() 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir if (NOT pCurAtTag) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir if ( int(eDocuState) < int(ds_in_descr) ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir InstallAtTag( 370*cdf0e10cSrcweir CurDocu().Create_StdTag(ary::info::atid_short), 371*cdf0e10cSrcweir true ); 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir else 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir InstallAtTag( 376*cdf0e10cSrcweir CurDocu().Create_StdTag(ary::info::atid_descr), 377*cdf0e10cSrcweir true ); 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir return *pCurAtTag; 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void 384*cdf0e10cSrcweir Adoc_PE::RenameCurShortTag() 385*cdf0e10cSrcweir { 386*cdf0e10cSrcweir CurDocu().Replace_AtShort_By_AtDescr(); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir void 390*cdf0e10cSrcweir Adoc_PE::FinishCurShortTag() 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir InstallAtTag( 393*cdf0e10cSrcweir CurDocu().Create_StdTag(ary::info::atid_descr), 394*cdf0e10cSrcweir true ); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir } // namespace adoc 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir 404