diff options
Diffstat (limited to 'autodoc/source/parser_i/idoc')
-rw-r--r-- | autodoc/source/parser_i/idoc/cx_docu2.cxx | 267 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/cx_dsapi.cxx | 533 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/docu_pe2.cxx | 606 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/makefile.mk | 62 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/tk_atag2.cxx | 83 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/tk_docw2.cxx | 119 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/tk_html.cxx | 58 | ||||
-rw-r--r-- | autodoc/source/parser_i/idoc/tk_xml.cxx | 174 |
8 files changed, 1902 insertions, 0 deletions
diff --git a/autodoc/source/parser_i/idoc/cx_docu2.cxx b/autodoc/source/parser_i/idoc/cx_docu2.cxx new file mode 100644 index 000000000000..9cd8eddd0b76 --- /dev/null +++ b/autodoc/source/parser_i/idoc/cx_docu2.cxx @@ -0,0 +1,267 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/cx_docu2.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <../../parser/inc/tokens/parseinc.hxx> +#include <s2_dsapi/tokrecv.hxx> +#include <s2_dsapi/tk_html.hxx> +#include <s2_dsapi/tk_xml.hxx> +#include <s2_dsapi/tk_docw2.hxx> +#include <x_parse2.hxx> + + + +namespace csi +{ +namespace dsapi +{ + + + +bool +Cx_Base::PassNewToken() +{ + if (pNewToken) + { + rReceiver.Receive(*pNewToken.Release()); + + return true; + } + return false; +} + +TkpContext & +Cx_Base::FollowUpContext() +{ + csv_assert(pFollowUpContext != 0); + return *pFollowUpContext; +} + +void +Cx_Base::Handle_DocuSyntaxError( CharacterSource & io_rText ) +{ + // KORR_FUTURE + // Put this into Error Log File + + Cerr() << "Error: Syntax error in documentation within " + << "this text:\n\"" + << io_rText.CutToken() + << "\"." + << Endl(); + SetToken( new Tok_Word(io_rText.CurToken()) ); +} + +void +Cx_EoHtml::ReadCharChain( CharacterSource & io_rText ) +{ + if ( NULCH == jumpTo(io_rText,'>') ) + throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); + io_rText.MoveOn(); + SetToken(new Tok_HtmlTag(io_rText.CutToken(),bToken_IsStartOfParagraph)); +} + +void +Cx_EoXmlConst::ReadCharChain( CharacterSource & io_rText ) +{ + char c = jumpTo(io_rText,'>','*'); + if ( NULCH == c OR '*' == c ) + { + Handle_DocuSyntaxError(io_rText); + return; + } + + io_rText.MoveOn(); + io_rText.CutToken(); + SetToken(new Tok_XmlConst(eTokenId)); +} + +void +Cx_EoXmlLink_BeginTag::ReadCharChain( CharacterSource & io_rText ) +{ + String sScope; + String sDim; + + do { + char cReached = jumpTo(io_rText,'"','>','*'); + switch (cReached) + { + case '"': + { + io_rText.MoveOn(); + io_rText.CutToken(); + char c = jumpTo(io_rText,'"','*', '>'); + if ( NULCH == c OR '*' == c OR '>' == c) + { + if ( '>' == c ) + io_rText.MoveOn(); + Handle_DocuSyntaxError(io_rText); + return; + } + + const char * pAttribute = io_rText.CutToken(); + if ( *pAttribute != '[' ) + sScope = pAttribute; + else + sDim = pAttribute; + + io_rText.MoveOn(); + break; + } + case '>': + break; + case '*': + Handle_DocuSyntaxError(io_rText); + return; + default: + throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); + } // end switch + } while ( io_rText.CurChar() != '>' ); + + io_rText.MoveOn(); + io_rText.CutToken(); + SetToken( new Tok_XmlLink_BeginTag(eTokenId, sScope.c_str(), sDim.c_str()) ); +} + +void +Cx_EoXmlLink_EndTag::ReadCharChain( CharacterSource & io_rText ) +{ + char c = jumpTo(io_rText,'>','*'); + if ( NULCH == c OR '*' == c ) + { + Handle_DocuSyntaxError(io_rText); + return; + } + + io_rText.MoveOn(); + io_rText.CutToken(); + SetToken(new Tok_XmlLink_EndTag(eTokenId)); +} + +void +Cx_EoXmlFormat_BeginTag::ReadCharChain( CharacterSource & io_rText ) +{ + String sDim; + + char cReached = jumpTo(io_rText,'"','>','*'); + switch (cReached) + { + case '"': + { + io_rText.MoveOn(); + io_rText.CutToken(); + + char c = jumpTo(io_rText,'"','*','>'); + if ( NULCH == c OR '*' == c OR '>' == c ) + { + if ('>' == c ) + io_rText.MoveOn(); + Handle_DocuSyntaxError(io_rText); + return; + } + + sDim = io_rText.CutToken(); + + c = jumpTo(io_rText,'>','*'); + if ( NULCH == c OR '*' == c ) + { + Handle_DocuSyntaxError(io_rText); + return; + } + break; + } + case '>': + break; + case '*': + Handle_DocuSyntaxError(io_rText); + return; + default: + throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); + } // end switch + + io_rText.MoveOn(); + io_rText.CutToken(); + SetToken(new Tok_XmlFormat_BeginTag(eTokenId, sDim)); +} + +void +Cx_EoXmlFormat_EndTag::ReadCharChain( CharacterSource & io_rText ) +{ + char c = jumpTo(io_rText,'>','*'); + if ( NULCH == c OR '*' == c ) + { + Handle_DocuSyntaxError(io_rText); + return; + } + + io_rText.MoveOn(); + io_rText.CutToken(); + SetToken(new Tok_XmlFormat_EndTag(eTokenId)); +} + +void +Cx_CheckStar::ReadCharChain( CharacterSource & io_rText ) +{ + bEndTokenFound = false; + if (bIsEnd) + { + char cNext = jumpOver(io_rText,'*'); + if ( NULCH == cNext ) + throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); + if (cNext == '/') + { + io_rText.MoveOn(); + SetToken(new Tok_DocuEnd); + bEndTokenFound = true; + } + else + { + SetToken( new Tok_Word(io_rText.CutToken()) ); + } + } + else + { + jumpToWhite(io_rText); + SetToken( new Tok_Word(io_rText.CutToken()) ); + } +} + +TkpContext & +Cx_CheckStar::FollowUpContext() +{ + if (bEndTokenFound) + return *pEnd_FollowUpContext; + else + return Cx_Base::FollowUpContext(); +} + +} // namespace dsapi +} // namespace csi + diff --git a/autodoc/source/parser_i/idoc/cx_dsapi.cxx b/autodoc/source/parser_i/idoc/cx_dsapi.cxx new file mode 100644 index 000000000000..a4d845bb0088 --- /dev/null +++ b/autodoc/source/parser_i/idoc/cx_dsapi.cxx @@ -0,0 +1,533 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/cx_dsapi.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <x_parse2.hxx> +#include <tools/tkpchars.hxx> +#include <s2_dsapi/tk_atag2.hxx> +#include <s2_dsapi/tk_docw2.hxx> +#include <s2_dsapi/tk_xml.hxx> +#include <s2_dsapi/cx_docu2.hxx> +#include <s2_dsapi/tokrecv.hxx> + + +namespace csi +{ +namespace dsapi +{ + + +const intt C_nStatusSize = 128; +const intt C_nCppInitialNrOfStati = 400; + + +const uintt nF_fin_Error = 1; +const uintt nF_fin_Ignore = 2; +const uintt nF_fin_Eof = 3; +const uintt nF_fin_AnyWord = 4; +const uintt nF_fin_AtTag = 5; +const uintt nF_fin_EndSign = 6; +const uintt nF_goto_EoHtml = 7; +const uintt nF_goto_EoXmlConst = 8; +const uintt nF_goto_EoXmlLink_BeginTag = 9; +const uintt nF_goto_EoXmlLink_EndTag = 10; +const uintt nF_goto_EoXmlFormat_BeginTag = 11; +const uintt nF_goto_EoXmlFormat_EndTag = 12; +const uintt nF_goto_CheckStar = 13; +const uintt nF_fin_Comma = 14; +const uintt nF_fin_White = 15; + +const UINT16 nTok_at_author = 100 + Tok_AtTag::author; +const UINT16 nTok_at_see = 100 + Tok_AtTag::see; +const UINT16 nTok_at_param = 100 + Tok_AtTag::param; +const UINT16 nTok_at_return = 100 + Tok_AtTag::e_return; +const UINT16 nTok_at_throws = 100 + Tok_AtTag::e_throw; +const UINT16 nTok_at_example = 100 + Tok_AtTag::example; +const UINT16 nTok_at_deprecated = 100 + Tok_AtTag::deprecated; +const UINT16 nTok_at_suspicious = 100 + Tok_AtTag::suspicious; +const UINT16 nTok_at_missing = 100 + Tok_AtTag::missing; +const UINT16 nTok_at_incomplete = 100 + Tok_AtTag::incomplete; +const UINT16 nTok_at_version = 100 + Tok_AtTag::version; +const UINT16 nTok_at_guarantees = 100 + Tok_AtTag::guarantees; +const UINT16 nTok_at_exception = 100 + Tok_AtTag::exception; +const UINT16 nTok_at_since = 100 + Tok_AtTag::since; + +const UINT16 nTok_const_TRUE = 200 + Tok_XmlConst::e_true; +const UINT16 nTok_const_FALSE = 200 + Tok_XmlConst::e_false; +const UINT16 nTok_const_NULL = 200 + Tok_XmlConst::e_null; +const UINT16 nTok_const_void = 200 + Tok_XmlConst::e_void; + +const UINT16 nTok_link_typeB = 300 + Tok_XmlLink_BeginTag::type; +const UINT16 nTok_link_typeE = 325 + Tok_XmlLink_EndTag::type; +const UINT16 nTok_link_memberB = 300 + Tok_XmlLink_BeginTag::member; +const UINT16 nTok_link_membeE = 325 + Tok_XmlLink_EndTag::member; +const UINT16 nTok_link_constB = 300 + Tok_XmlLink_BeginTag::e_const; +const UINT16 nTok_link_constE = 325 + Tok_XmlLink_EndTag::e_const; + +const UINT16 nTok_format_listingB = 350 + Tok_XmlFormat_BeginTag::listing; +const UINT16 nTok_format_listingE = 375 + Tok_XmlFormat_EndTag::listing; +const UINT16 nTok_format_codeB = 350 + Tok_XmlFormat_BeginTag::code; +const UINT16 nTok_format_codeE = 375 + Tok_XmlFormat_EndTag::code; +const UINT16 nTok_format_atomB = 350 + Tok_XmlFormat_BeginTag::atom; +const UINT16 nTok_format_atomE = 375 + Tok_XmlFormat_EndTag::atom; + + +const UINT16 nTok_html_parastart = 400; + +const UINT16 nTok_MLDocuEnd = 501; +const UINT16 nTok_EOL = 502; + + +Context_Docu::Context_Docu( Token_Receiver & o_rReceiver ) + : aStateMachine(C_nStatusSize, C_nCppInitialNrOfStati), + pReceiver(&o_rReceiver), + pParentContext(0), + pCx_EoHtml(0), + pCx_EoXmlConst(0), + pCx_EoXmlLink_BeginTag(0), + pCx_EoXmlLink_EndTag(0), + pCx_EoXmlFormat_BeginTag(0), + pCx_EoXmlFormat_EndTag(0), + pCx_CheckStar(0), + pNewToken(0), + pFollowUpContext(0), + bIsMultiline(false) +{ + pCx_EoHtml = new Cx_EoHtml(o_rReceiver, *this); + pCx_EoXmlConst = new Cx_EoXmlConst(o_rReceiver, *this); + pCx_EoXmlLink_BeginTag = new Cx_EoXmlLink_BeginTag(o_rReceiver, *this); + pCx_EoXmlLink_EndTag = new Cx_EoXmlLink_EndTag(o_rReceiver, *this); + pCx_EoXmlFormat_BeginTag = new Cx_EoXmlFormat_BeginTag(o_rReceiver, *this); + pCx_EoXmlFormat_EndTag = new Cx_EoXmlFormat_EndTag(o_rReceiver, *this); + pCx_CheckStar = new Cx_CheckStar(*pReceiver,*this); + + SetupStateMachine(); +} + +void +Context_Docu::SetParentContext( TkpContext & io_rParentContext, + const char * ) +{ + pFollowUpContext = pParentContext = &io_rParentContext; + pCx_CheckStar->Set_End_FolloUpContext(io_rParentContext); +} + +Context_Docu::~Context_Docu() +{ +} + +void +Context_Docu::ReadCharChain( CharacterSource & io_rText ) +{ + csv_assert(pParentContext != 0); + + pNewToken = 0; + + UINT16 nTokenId = 0; + StmBoundsStatu2 & rBound = aStateMachine.GetCharChain(nTokenId, io_rText); + + // !!! + // The order of the next two lines is essential, because + // pFollowUpContext may be changed by PerformStatusFunction() also, + // which then MUST override the previous assignment. + pFollowUpContext = rBound.FollowUpContext(); + PerformStatusFunction(rBound.StatusFunctionNr(), nTokenId, io_rText); +} + +bool +Context_Docu::PassNewToken() +{ + if (pNewToken) + { + pReceiver->Receive(*pNewToken.Release()); + return true; + } + return false; +} + +TkpContext & +Context_Docu::FollowUpContext() +{ + csv_assert(pFollowUpContext != 0); + return *pFollowUpContext; +} + +void +Context_Docu::PerformStatusFunction( uintt i_nStatusSignal, + UINT16 i_nTokenId, + CharacterSource & io_rText ) +{ + switch (i_nStatusSignal) + { + case nF_fin_White: + io_rText.CutToken(); + pNewToken = new Tok_White; + break; + case nF_fin_Error: + throw X_AutodocParser(X_AutodocParser::x_InvalidChar); + // no break because of throw + case nF_fin_Ignore: + pNewToken = 0; + io_rText.CutToken(); + break; + case nF_fin_Eof: + if (bIsMultiline) + throw X_AutodocParser(X_AutodocParser::x_UnexpectedEOF); + else + io_rText.CutToken(); + pNewToken = new Tok_EOF; + break; + case nF_fin_AnyWord: + pNewToken = new Tok_Word(io_rText.CutToken()); + break; + case nF_fin_AtTag: + io_rText.CutToken(); + pNewToken = new Tok_AtTag( i_nTokenId - 100 ); + break; + case nF_fin_Comma: + io_rText.CutToken(); + pNewToken = new Tok_Comma; + break; + case nF_fin_EndSign: + io_rText.CutToken(); + switch (i_nTokenId) + { + case nTok_MLDocuEnd: + if (bIsMultiline) + { + pNewToken = new Tok_DocuEnd; + pFollowUpContext = pParentContext; + } + else + { + pNewToken = new Tok_Word(io_rText.CutToken()); + pFollowUpContext = this; + } + break; + case nTok_EOL: + if (bIsMultiline) + { + pNewToken = new Tok_EOL; + pFollowUpContext = this; + } + else + { + pNewToken = new Tok_DocuEnd; + pFollowUpContext = pParentContext; + } + pReceiver->Increment_CurLine(); + break; + default: + csv_assert(false); + } + break; + case nF_goto_EoHtml: + pCx_EoHtml->SetIfIsStartOfParagraph(i_nTokenId == nTok_html_parastart); + break; + case nF_goto_EoXmlConst: + pCx_EoXmlConst->SetTokenId(i_nTokenId - 200); + break; + case nF_goto_EoXmlLink_BeginTag: + pCx_EoXmlLink_BeginTag->SetTokenId(i_nTokenId - 300); + break; + case nF_goto_EoXmlLink_EndTag: + pCx_EoXmlLink_EndTag->SetTokenId(i_nTokenId - 325); + break; + case nF_goto_EoXmlFormat_BeginTag: + pCx_EoXmlFormat_BeginTag->SetTokenId(i_nTokenId - 350); + break; + case nF_goto_EoXmlFormat_EndTag: + pCx_EoXmlFormat_EndTag->SetTokenId(i_nTokenId - 375); + break; + case nF_goto_CheckStar: + pCx_CheckStar->SetIsEnd( bIsMultiline ); + break; + default: + csv_assert(false); + } // end switch (i_nStatusSignal) +} + +void +Context_Docu::SetupStateMachine() +{ + // Besondere Array-Stati (kein Tokenabschluss oder Kontextwechsel): +// const INT16 bas = 0; // Base-Status + const INT16 wht = 1; // Whitespace-overlook-Status + const INT16 awd = 2; // Any-Word-Read-Status + + // Kontextwechsel-Stati: + const INT16 goto_EoHtml = 3; + const INT16 goto_EoXmlConst = 4; + const INT16 goto_EoXmlLink_BeginTag = 5; + const INT16 goto_EoXmlLink_EndTag = 6; + const INT16 goto_EoXmlFormat_BeginTag = 7; + const INT16 goto_EoXmlFormat_EndTag = 8; + const INT16 goto_CheckStar = 9; + + // Tokenfinish-Stati: + const INT16 finError = 10; +// const INT16 finIgnore = 11; + const INT16 finEof = 12; + const INT16 finAnyWord = 13; + const INT16 finAtTag = 14; + const INT16 finEndSign = 15; +// const INT16 finComma = 16; + const INT16 finWhite = 17; + + // Konstanten zur Benutzung in der Tabelle: + const INT16 ght = goto_EoHtml; +/* + const INT16 gxc = goto_EoXmlConst; + const INT16 glb = goto_EoXmlLink_TagBegin; + const INT16 gle = goto_EoXmlLink_TagEnd; + const INT16 gfb = goto_EoXmlFormat_TagBegin; + const INT16 gfe = goto_EoXmlFormat_TagEnd; +*/ + const INT16 err = finError; + const INT16 faw = finAnyWord; +// const INT16 fig = finIgnore; +// const INT16 fes = finEndSign; + const INT16 fof = finEof; +// const INT16 fat = finAtTag; + const INT16 fwh = finWhite; + + /// The '0's will be replaced by calls of AddToken(). + + const INT16 A_nTopStatus[C_nStatusSize] = + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + {fof,err,err,err,err,err,err,err,err,wht, 0,wht,wht, 0,err,err, + err,err,err,err,err,err,err,err,err,err,fof,err,err,err,err,err, // ... 31 + wht,awd,awd,awd,awd,awd,awd,awd,awd,awd, 0,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, 0,awd,awd,awd, // ... 63 + 0,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, // ... 95 + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd // ... 127 + }; + + const INT16 A_nWhitespaceStatus[C_nStatusSize] = + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + {fof,err,err,err,err,err,err,err,err,wht,fwh,wht,wht,fwh,err,err, + err,err,err,err,err,err,err,err,err,err,fof,err,err,err,err,err, // ... 31 + wht,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh, + fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh, // ... 63 + fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh, + fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh, // ... 95 + fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh, + fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh,fwh // ... 127 + }; + + const INT16 A_nWordStatus[C_nStatusSize] = + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + {faw,err,err,err,err,err,err,err,err,faw,faw,faw,faw,faw,err,err, + err,err,err,err,err,err,err,err,err,err,faw,err,err,err,err,err, // ... 31 + faw,awd,awd,awd,awd,awd,awd,awd,awd,awd,faw,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,faw,awd,awd,awd, // ... 63 + faw,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, // ... 95 + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd // ... 127 + }; + + const INT16 A_nAtTagDefStatus[C_nStatusSize] = + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + {faw,err,err,err,err,err,err,err,err,faw,faw,faw,faw,faw,err,err, + err,err,err,err,err,err,err,err,err,err,faw,err,err,err,err,err, // ... 31 + faw,awd,awd,awd,awd,awd,awd,awd,awd,awd,faw,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,faw,awd,faw,awd,awd,awd, // ... 63 + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, // ... 95 + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd, + awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd,awd // ... 127 + }; + + const INT16 A_nHtmlDefStatus[C_nStatusSize] = + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + {ght,err,err,err,err,err,err,err,err,ght,ght,ght,ght,ght,err,err, + err,err,err,err,err,err,err,err,err,err,ght,err,err,err,err,err, // ... 31 + ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght, + ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght, // ... 63 + ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght, + ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght, // ... 95 + ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght, + ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght,ght // ... 127 + }; + + const INT16 A_nPunctDefStatus[C_nStatusSize] = + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + {err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 16 ... + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 48 ... + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, // 80 ... + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err, + err,err,err,err,err,err,err,err,err,err,err,err,err,err,err,err // 112 ... + }; + + DYN StmArrayStatu2 * dpStatusTop + = new StmArrayStatu2( C_nStatusSize, A_nTopStatus, 0, true); + DYN StmArrayStatu2 * dpStatusWhite + = new StmArrayStatu2( C_nStatusSize, A_nWhitespaceStatus, 0, true); + DYN StmArrayStatu2 * dpStatusWord + = new StmArrayStatu2( C_nStatusSize, A_nWordStatus, 0, true); + + DYN StmBoundsStatu2 * dpBst_goto_EoHtml + = new StmBoundsStatu2( *this, *pCx_EoHtml, nF_goto_EoHtml, true ); + DYN StmBoundsStatu2 * dpBst_goto_EoXmlConst + = new StmBoundsStatu2( *this, *pCx_EoXmlConst, nF_goto_EoXmlConst, true ); + DYN StmBoundsStatu2 * dpBst_goto_EoXmlLink_BeginTag + = new StmBoundsStatu2( *this, *pCx_EoXmlLink_BeginTag, nF_goto_EoXmlLink_BeginTag, true ); + DYN StmBoundsStatu2 * dpBst_goto_EoXmlLink_EndTag + = new StmBoundsStatu2( *this, *pCx_EoXmlLink_EndTag, nF_goto_EoXmlLink_EndTag, true ); + DYN StmBoundsStatu2 * dpBst_goto_EoXmlFormat_BeginTag + = new StmBoundsStatu2( *this, *pCx_EoXmlFormat_BeginTag, nF_goto_EoXmlFormat_BeginTag, true ); + DYN StmBoundsStatu2 * dpBst_goto_EoXmlFormat_EndTag + = new StmBoundsStatu2( *this, *pCx_EoXmlFormat_EndTag, nF_goto_EoXmlFormat_EndTag, true ); + DYN StmBoundsStatu2 * dpBst_goto_CheckStar + = new StmBoundsStatu2( *this, *pCx_CheckStar, nF_goto_CheckStar, true ); + + + DYN StmBoundsStatu2 * dpBst_finError + = new StmBoundsStatu2( *this, TkpContext_Null2_(), nF_fin_Error, true ); + DYN StmBoundsStatu2 * dpBst_finIgnore + = new StmBoundsStatu2( *this, *this, nF_fin_Ignore, true); + DYN StmBoundsStatu2 * dpBst_finEof + = new StmBoundsStatu2( *this, TkpContext_Null2_(), nF_fin_Eof, false); + DYN StmBoundsStatu2 * dpBst_finAnyWord + = new StmBoundsStatu2( *this, *this, nF_fin_AnyWord, true); + DYN StmBoundsStatu2 * dpBst_finAtTag + = new StmBoundsStatu2( *this, *this, nF_fin_AtTag, false); + DYN StmBoundsStatu2 * dpBst_finEndSign + = new StmBoundsStatu2( *this, *pParentContext, nF_fin_EndSign, false); + DYN StmBoundsStatu2 * dpBst_fin_Comma + = new StmBoundsStatu2( *this, *this, nF_fin_Comma, false ); + DYN StmBoundsStatu2 * dpBst_finWhite + = new StmBoundsStatu2( *this, *this, nF_fin_White, false); + + + // dpMain aufbauen: + aStateMachine.AddStatus(dpStatusTop); + aStateMachine.AddStatus(dpStatusWhite); + aStateMachine.AddStatus(dpStatusWord); + + aStateMachine.AddStatus(dpBst_goto_EoHtml); + aStateMachine.AddStatus(dpBst_goto_EoXmlConst); + aStateMachine.AddStatus(dpBst_goto_EoXmlLink_BeginTag); + aStateMachine.AddStatus(dpBst_goto_EoXmlLink_EndTag); + aStateMachine.AddStatus(dpBst_goto_EoXmlFormat_BeginTag); + aStateMachine.AddStatus(dpBst_goto_EoXmlFormat_EndTag); + aStateMachine.AddStatus(dpBst_goto_CheckStar); + + aStateMachine.AddStatus(dpBst_finError); + aStateMachine.AddStatus(dpBst_finIgnore); + aStateMachine.AddStatus(dpBst_finEof); + aStateMachine.AddStatus(dpBst_finAnyWord); + aStateMachine.AddStatus(dpBst_finAtTag); + aStateMachine.AddStatus(dpBst_finEndSign); + aStateMachine.AddStatus(dpBst_fin_Comma); + aStateMachine.AddStatus(dpBst_finWhite); + + + aStateMachine.AddToken( "@author", nTok_at_author, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@param", nTok_at_param, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@throws", nTok_at_throws, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@see", nTok_at_see, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@since", nTok_at_since, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@example", nTok_at_example, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@return", nTok_at_return, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@returns", nTok_at_return, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@deprecated", + nTok_at_deprecated, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@suspicious", + nTok_at_suspicious, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@missing", nTok_at_missing, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@incomplete", + nTok_at_incomplete, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@version", nTok_at_version, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@guarantees", + nTok_at_guarantees, A_nAtTagDefStatus, finAtTag ); + aStateMachine.AddToken( "@exception", + nTok_at_exception, A_nAtTagDefStatus, finAtTag ); + + aStateMachine.AddToken( "<", 0, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "*", 0, A_nPunctDefStatus, goto_CheckStar ); +// aStateMachine.AddToken( ",", 0, A_nPunctDefStatus, finComma ); + + aStateMachine.AddToken( "<type", nTok_link_typeB, A_nHtmlDefStatus, goto_EoXmlLink_BeginTag ); + aStateMachine.AddToken( "</type", nTok_link_typeE, A_nHtmlDefStatus, goto_EoXmlLink_EndTag ); + aStateMachine.AddToken( "<member", nTok_link_memberB, A_nHtmlDefStatus, goto_EoXmlLink_BeginTag ); + aStateMachine.AddToken( "</member", nTok_link_membeE, A_nHtmlDefStatus, goto_EoXmlLink_EndTag ); + aStateMachine.AddToken( "<const", nTok_link_constB, A_nHtmlDefStatus, goto_EoXmlLink_BeginTag ); + aStateMachine.AddToken( "</const", nTok_link_constE, A_nHtmlDefStatus, goto_EoXmlLink_EndTag ); + + aStateMachine.AddToken( "<listing", nTok_format_listingB,A_nHtmlDefStatus, goto_EoXmlFormat_BeginTag ); + aStateMachine.AddToken( "</listing",nTok_format_listingE,A_nHtmlDefStatus, goto_EoXmlFormat_EndTag ); + aStateMachine.AddToken( "<code", nTok_format_codeB, A_nHtmlDefStatus, goto_EoXmlFormat_BeginTag ); + aStateMachine.AddToken( "</code", nTok_format_codeE, A_nHtmlDefStatus, goto_EoXmlFormat_EndTag ); + aStateMachine.AddToken( "<atom", nTok_format_atomB, A_nHtmlDefStatus, goto_EoXmlFormat_BeginTag ); + aStateMachine.AddToken( "</atom", nTok_format_atomE, A_nHtmlDefStatus, goto_EoXmlFormat_EndTag ); + + aStateMachine.AddToken( "<TRUE/", nTok_const_TRUE, A_nHtmlDefStatus, goto_EoXmlConst ); + aStateMachine.AddToken( "<true/", nTok_const_TRUE, A_nHtmlDefStatus, goto_EoXmlConst ); + aStateMachine.AddToken( "<FALSE/", nTok_const_FALSE, A_nHtmlDefStatus, goto_EoXmlConst ); + aStateMachine.AddToken( "<false/", nTok_const_FALSE, A_nHtmlDefStatus, goto_EoXmlConst ); + aStateMachine.AddToken( "<NULL/", nTok_const_NULL, A_nHtmlDefStatus, goto_EoXmlConst ); + aStateMachine.AddToken( "<void/", nTok_const_void, A_nHtmlDefStatus, goto_EoXmlConst ); + + aStateMachine.AddToken( "<p", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<pre", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<dl", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<ul", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<ol", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<table", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<P", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<PRE", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<DL", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<UL", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<OL", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + aStateMachine.AddToken( "<TABLE", nTok_html_parastart, A_nHtmlDefStatus, goto_EoHtml ); + + aStateMachine.AddToken( "\r\n", nTok_EOL, A_nPunctDefStatus, finEndSign ); + aStateMachine.AddToken( "\n", nTok_EOL, A_nPunctDefStatus, finEndSign ); + aStateMachine.AddToken( "\r", nTok_EOL, A_nPunctDefStatus, finEndSign ); +}; + +void +Context_Docu::SetMode_IsMultiLine( bool i_bTrue ) +{ + bIsMultiline = i_bTrue; +} + + +} // namespace dsapi +} // namespace csi + diff --git a/autodoc/source/parser_i/idoc/docu_pe2.cxx b/autodoc/source/parser_i/idoc/docu_pe2.cxx new file mode 100644 index 000000000000..084dbbf0660c --- /dev/null +++ b/autodoc/source/parser_i/idoc/docu_pe2.cxx @@ -0,0 +1,606 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/docu_pe2.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <ary/doc/d_oldidldocu.hxx> +#include <ary_i/d_token.hxx> +#include <parser/parserinfo.hxx> +#include <adc_cl.hxx> +#include <adc_msg.hxx> +#include <../parser/inc/x_docu.hxx> +#include <s2_dsapi/dsapitok.hxx> +#include <s2_dsapi/tk_atag2.hxx> +#include <s2_dsapi/tk_html.hxx> +#include <s2_dsapi/tk_docw2.hxx> +#include <s2_dsapi/tk_xml.hxx> + + +#ifdef UNX +#define strnicmp strncasecmp +#endif + + +namespace csi +{ +namespace dsapi +{ + + +const char * AtTagTitle( + const Tok_AtTag & i_rToken ); + + +SapiDocu_PE::SapiDocu_PE(ParserInfo & io_rPositionInfo) + : pDocu(0), + eState(e_none), + pPositionInfo(&io_rPositionInfo), + fCurTokenAddFunction(&SapiDocu_PE::AddDocuToken2Void), + pCurAtTag(0), + sCurDimAttribute(), + sCurAtSeeType_byXML(200) +{ +} + +SapiDocu_PE::~SapiDocu_PE() +{ +} + +void +SapiDocu_PE::ProcessToken( DYN csi::dsapi::Token & let_drToken ) +{ + if (IsComplete()) + { + pDocu = 0; + eState = e_none; + } + + if ( eState == e_none ) + { + pDocu = new ary::doc::OldIdlDocu; + eState = st_short; + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Short; + } + + csv_assert(pDocu); + + let_drToken.Trigger(*this); + delete &let_drToken; +} + +void +SapiDocu_PE::Process_AtTag( const Tok_AtTag & i_rToken ) +{ + if (NOT pCurAtTag) + { + eState = st_attags; + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; + } + else + { + csv_assert(eState == st_attags); + pDocu->AddAtTag(*pCurAtTag.Release()); + } + + if (i_rToken.Id() == Tok_AtTag::param) + { + pCurAtTag = new DT_ParameterAtTag; + fCurTokenAddFunction = &SapiDocu_PE::SetCurParameterAtTagName; + } + else if (i_rToken.Id() == Tok_AtTag::see) + { + pCurAtTag = new DT_SeeAlsoAtTag; + fCurTokenAddFunction = &SapiDocu_PE::SetCurSeeAlsoAtTagLinkText; + } + else if (i_rToken.Id() == Tok_AtTag::deprecated) + { + pDocu->SetDeprecated(); + pCurAtTag = new DT_StdAtTag(""); // Dummy that will not be used. + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Deprecated; + } + else if (i_rToken.Id() == Tok_AtTag::since) + { + pCurAtTag = new DT_SinceAtTag; + fCurTokenAddFunction = &SapiDocu_PE::SetCurSinceAtTagVersion; + } + else + { + pCurAtTag = new DT_StdAtTag( AtTagTitle(i_rToken) ); + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; + } +} + +void +SapiDocu_PE::Process_HtmlTag( const Tok_HtmlTag & i_rToken ) +{ + if (eState == st_short AND i_rToken.IsParagraphStarter()) + { + eState = st_description; + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Description; + } + + // Workaround special for some errors in API docu: + if ( strnicmp("<true",i_rToken.Text(),5 ) == 0 ) + { + if ( strcmp("<TRUE/>",i_rToken.Text()) != 0 ) + TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), + pPositionInfo->CurFile(), + pPositionInfo->CurLine() ); + (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>true</b>") ); + return; + } + else if ( strnicmp("<false",i_rToken.Text(),6 ) == 0 ) + { + if ( strcmp("<FALSE/>",i_rToken.Text()) != 0 ) + TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), + pPositionInfo->CurFile(), + pPositionInfo->CurLine() ); + (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>false</b>") ); + return; + } + else if ( strnicmp("<NULL",i_rToken.Text(),5 ) == 0 ) + { + if ( strcmp("<NULL/>",i_rToken.Text()) != 0 ) + TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), + pPositionInfo->CurFile(), + pPositionInfo->CurLine() ); + (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>null</b>") ); + return; + } + else if ( strnicmp("<void",i_rToken.Text(),5 ) == 0 ) + { + if ( strcmp("<void/>",i_rToken.Text()) != 0 ) + TheMessages().Out_InvalidConstSymbol( i_rToken.Text(), + pPositionInfo->CurFile(), + pPositionInfo->CurLine() ); + (this->*fCurTokenAddFunction)( *new DT_TextToken("<b>void</b>") ); + return; + } + + (this->*fCurTokenAddFunction)( *new DT_Style(i_rToken.Text(),false) ); +} + +void +SapiDocu_PE::Process_XmlConst( const Tok_XmlConst & i_rToken ) +{ + (this->*fCurTokenAddFunction)(*new DT_MupConst(i_rToken.Text())); +} + +void +SapiDocu_PE::Process_XmlLink_BeginTag( const Tok_XmlLink_BeginTag & i_rToken ) +{ + switch (i_rToken.Id()) + { + case Tok_XmlLink_Tag::e_const: + (this->*fCurTokenAddFunction)(*new DT_Style("<b>",false)); + break; + case Tok_XmlLink_Tag::member: + (this->*fCurTokenAddFunction)(*new DT_MupMember(i_rToken.Scope())); + break; + case Tok_XmlLink_Tag::type: + (this->*fCurTokenAddFunction)(*new DT_MupType(i_rToken.Scope())); + break; + default: + // Do nothing. + ; + } + + if ( i_rToken.Dim().length() > 0 ) + sCurDimAttribute = i_rToken.Dim(); + else + sCurDimAttribute.clear(); +} + +void +SapiDocu_PE::Process_XmlLink_EndTag( const Tok_XmlLink_EndTag & i_rToken ) +{ + switch (i_rToken.Id()) + { + case Tok_XmlLink_Tag::e_const: + (this->*fCurTokenAddFunction)(*new DT_Style("</b>",false)); + break; + case Tok_XmlLink_Tag::member: + (this->*fCurTokenAddFunction)(*new DT_MupMember(true)); + break; + case Tok_XmlLink_Tag::type: + (this->*fCurTokenAddFunction)(*new DT_MupType(true)); + break; + default: + // Do nothing. + ; + } + if ( sCurDimAttribute.length() > 0 ) + { + (this->*fCurTokenAddFunction)( *new DT_TextToken(sCurDimAttribute.c_str()) ); + sCurDimAttribute.clear(); + } +} + +void +SapiDocu_PE::Process_XmlFormat_BeginTag( const Tok_XmlFormat_BeginTag & i_rToken ) +{ + switch (i_rToken.Id()) + { + case Tok_XmlFormat_Tag::code: + (this->*fCurTokenAddFunction)(*new DT_Style("<code>",false)); + break; + case Tok_XmlFormat_Tag::listing: + (this->*fCurTokenAddFunction)(*new DT_Style("<pre>",true)); + break; + case Tok_XmlFormat_Tag::atom: + (this->*fCurTokenAddFunction)(*new DT_Style("<code>",true)); + break; + default: + // Do nothing. + ; + } + if ( i_rToken.Dim().length() > 0 ) + sCurDimAttribute = i_rToken.Dim(); + else + sCurDimAttribute.clear(); +} + +void +SapiDocu_PE::Process_XmlFormat_EndTag( const Tok_XmlFormat_EndTag & i_rToken ) +{ + switch (i_rToken.Id()) + { + case Tok_XmlFormat_Tag::code: + (this->*fCurTokenAddFunction)(*new DT_Style("</code>",false)); + break; + case Tok_XmlFormat_Tag::listing: + (this->*fCurTokenAddFunction)(*new DT_Style("</pre>",true)); + break; + case Tok_XmlFormat_Tag::atom: + (this->*fCurTokenAddFunction)(*new DT_Style("</code>",true)); + break; + default: + // Do nothing. + ; + } + if ( sCurDimAttribute.length() > 0 ) + { + (this->*fCurTokenAddFunction)( *new DT_TextToken(sCurDimAttribute.c_str()) ); + sCurDimAttribute.clear(); + } +} + +void +SapiDocu_PE::Process_Word( const Tok_Word & i_rToken ) +{ + (this->*fCurTokenAddFunction)(*new DT_TextToken(i_rToken.Text())); +} + +void +SapiDocu_PE::Process_Comma() +{ + csv_assert(1==7); +// (this->*fCurTokenAddFunction)(*new DT_Comma(i_rToken.Text())); +} + +void +SapiDocu_PE::Process_DocuEnd() +{ + eState = st_complete; + if (pCurAtTag) + pDocu->AddAtTag(*pCurAtTag.Release()); + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2Void; +} + +void +SapiDocu_PE::Process_EOL() +{ + (this->*fCurTokenAddFunction)(*new DT_EOL); +} + +void +SapiDocu_PE::Process_White() +{ + (this->*fCurTokenAddFunction)(*new DT_White); +} + +DYN ary::doc::OldIdlDocu * +SapiDocu_PE::ReleaseJustParsedDocu() +{ + if (IsComplete()) + { + eState = e_none; + return pDocu.Release(); + } + return 0; +} + + +bool +SapiDocu_PE::IsComplete() const +{ + return eState == st_complete; +} + +void +SapiDocu_PE::AddDocuToken2Void( DYN ary::inf::DocuToken & let_drNewToken ) +{ + delete &let_drNewToken; +} + +void +SapiDocu_PE::AddDocuToken2Short( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pDocu); + pDocu->AddToken2Short(let_drNewToken); +} + +void +SapiDocu_PE::AddDocuToken2Description( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pDocu); + pDocu->AddToken2Description(let_drNewToken); +} + +void +SapiDocu_PE::AddDocuToken2Deprecated( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pDocu); + pDocu->AddToken2DeprecatedText(let_drNewToken); +} + +void +SapiDocu_PE::AddDocuToken2CurAtTag( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pCurAtTag); + pCurAtTag->AddToken(let_drNewToken); +} + +void +SapiDocu_PE::SetCurParameterAtTagName( DYN ary::inf::DocuToken & let_drNewToken ) +{ + if (let_drNewToken.IsWhiteOnly()) + { + delete &let_drNewToken; + return; + } + + csv_assert(pCurAtTag); + DT_TextToken * dpText = dynamic_cast< DT_TextToken* >(&let_drNewToken); + if (dpText != 0) + pCurAtTag->SetName(dpText->GetText()); + else + pCurAtTag->SetName("parameter ?"); + delete &let_drNewToken; + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; +} + +void +SapiDocu_PE::SetCurSeeAlsoAtTagLinkText( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pCurAtTag); + + if (let_drNewToken.IsWhiteOnly()) + { + delete &let_drNewToken; + return; + } + + DT_TextToken * pText = dynamic_cast< DT_TextToken* >(&let_drNewToken); + if (pText != 0) + pCurAtTag->SetName(pText->GetText()); + else + { + DT_MupType * + pTypeBegin = dynamic_cast< DT_MupType* >(&let_drNewToken); + DT_MupMember * + pMemberBegin = dynamic_cast< DT_MupMember* >(&let_drNewToken); + if (pTypeBegin != 0 OR pMemberBegin != 0) + { + sCurAtSeeType_byXML.reset(); + + sCurAtSeeType_byXML + << ( pTypeBegin != 0 + ? pTypeBegin->Scope() + : pMemberBegin->Scope() ); + + if (sCurAtSeeType_byXML.tellp() > 0) + { + sCurAtSeeType_byXML + << "::"; + } + delete &let_drNewToken; + fCurTokenAddFunction = &SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_2; + return; + } + else + { + pCurAtTag->SetName("? (no identifier found)"); + } + } + delete &let_drNewToken; + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; +} + +void +SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_2( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pCurAtTag); + + if (let_drNewToken.IsWhiteOnly()) + { + delete &let_drNewToken; + return; + } + + DT_TextToken * + pText = dynamic_cast< DT_TextToken* >(&let_drNewToken); + if (pText != 0) + { + sCurAtSeeType_byXML + << pText->GetText(); + pCurAtTag->SetName(sCurAtSeeType_byXML.c_str()); + } + else + { + pCurAtTag->SetName("? (no identifier found)"); + } + sCurAtSeeType_byXML.reset(); + delete &let_drNewToken; + fCurTokenAddFunction = &SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_3; +} + +void +SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_3( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pCurAtTag); + + if (let_drNewToken.IsWhiteOnly()) + { + delete &let_drNewToken; + return; + } + + /// Could emit warning, but don't because this parser is obsolete. +// Tok_XmlLink_BeginTag * +// pLinkEnd = dynamic_cast< Tok_XmlLink_EndTag* >(&let_drNewToken); +// if (pLinkEnd == 0) +// { +// warn_aboutMissingClosingTag(); +// } + + delete &let_drNewToken; + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag; +} + + + +void +SapiDocu_PE::SetCurSinceAtTagVersion( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pCurAtTag); + + DT_TextToken * pToken = dynamic_cast< DT_TextToken* >(&let_drNewToken); + if (pToken == 0) + { + delete &let_drNewToken; + return; + } + + const String + sVersion(pToken->GetText()); + const char + cFirst = *sVersion.begin(); + const char + cCiphersend = '9' + 1; + const autodoc::CommandLine & + rCommandLine = autodoc::CommandLine::Get_(); + + + if ( rCommandLine.DoesTransform_SinceTag()) + { + // The @since version number shall be interpreted, + + if ( NOT csv::in_range('0', cFirst, cCiphersend) ) + { + // But this is a non-number-part, so we wait for + // the next one. + delete &let_drNewToken; + return; + } + else if (rCommandLine.DisplayOf_SinceTagValue(sVersion).empty()) + { + // This is the numbered part, but we don't know it. + delete &let_drNewToken; + + StreamLock + sl(200); + sl() + << "Since-value '" + << sVersion + << "' not found in translation table."; + throw X_Docu("since", sl().c_str()); + } + } + + // Either since tags are not specially interpreted, or + // we got a known one. + pCurAtTag->AddToken(let_drNewToken); + fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2SinceAtTag; +} + +void +SapiDocu_PE::AddDocuToken2SinceAtTag( DYN ary::inf::DocuToken & let_drNewToken ) +{ + csv_assert(pCurAtTag); + String & + sValue = pCurAtTag->Access_Text().Access_TextOfFirstToken(); + StreamLock + sHelp(1000); + + DT_TextToken * + pToken = dynamic_cast< DT_TextToken* >(&let_drNewToken); + if (pToken != 0) + { + sValue = sHelp() << sValue << pToken->GetText() << c_str; + } + else if (dynamic_cast< DT_White* >(&let_drNewToken) != 0) + { + sValue = sHelp() << sValue << " " << c_str; + } + delete &let_drNewToken; +} + +const char * +AtTagTitle( const Tok_AtTag & i_rToken ) +{ + switch (i_rToken.Id()) + { + case Tok_AtTag::author: return ""; + case Tok_AtTag::see: return "See also"; + case Tok_AtTag::param: return "Parameters"; + case Tok_AtTag::e_return: return "Returns"; + case Tok_AtTag::e_throw: return "Throws"; + case Tok_AtTag::example: return "Example"; + case Tok_AtTag::deprecated: return "Deprecated"; + case Tok_AtTag::suspicious: return ""; + case Tok_AtTag::missing: return ""; + case Tok_AtTag::incomplete: return ""; + case Tok_AtTag::version: return ""; + case Tok_AtTag::guarantees: return "Guarantees"; + case Tok_AtTag::exception: return "Exception"; + case Tok_AtTag::since: return "Since version"; + default: + // See below. + ; + } + return i_rToken.Text(); +} + + + +} // namespace dsapi +} // namespace csi + diff --git a/autodoc/source/parser_i/idoc/makefile.mk b/autodoc/source/parser_i/idoc/makefile.mk new file mode 100644 index 000000000000..c4e760bd2973 --- /dev/null +++ b/autodoc/source/parser_i/idoc/makefile.mk @@ -0,0 +1,62 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=autodoc +TARGET=parser2_s2_dsapi + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/cx_docu2.obj \ + $(OBJ)$/cx_dsapi.obj \ + $(OBJ)$/docu_pe2.obj \ + $(OBJ)$/tk_atag2.obj \ + $(OBJ)$/tk_docw2.obj \ + $(OBJ)$/tk_html.obj \ + $(OBJ)$/tk_xml.obj + + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/autodoc/source/parser_i/idoc/tk_atag2.cxx b/autodoc/source/parser_i/idoc/tk_atag2.cxx new file mode 100644 index 000000000000..5454e31ad839 --- /dev/null +++ b/autodoc/source/parser_i/idoc/tk_atag2.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/tk_atag2.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <s2_dsapi/tokintpr.hxx> + + + +using csi::dsapi::Tok_AtTag; + +lux::EnumValueMap G_aTokAtTag_EV_TokenId_Values; +Tok_AtTag::EV_TokenId ev_none2(Tok_AtTag::e_none,""); +Tok_AtTag::EV_TokenId ev_author(Tok_AtTag::author,"@author"); +Tok_AtTag::EV_TokenId ev_see(Tok_AtTag::see,"@see"); +Tok_AtTag::EV_TokenId ev_param(Tok_AtTag::param,"@param"); +Tok_AtTag::EV_TokenId ev_e_return(Tok_AtTag::e_return,"@return"); +Tok_AtTag::EV_TokenId ev_e_throw(Tok_AtTag::e_throw,"@throws"); +Tok_AtTag::EV_TokenId ev_example(Tok_AtTag::example,"@example"); +Tok_AtTag::EV_TokenId ev_deprecated(Tok_AtTag::deprecated,"@deprecated"); +Tok_AtTag::EV_TokenId ev_suspicious(Tok_AtTag::suspicious,"@suspicious"); +Tok_AtTag::EV_TokenId ev_missing(Tok_AtTag::missing,"@missing"); +Tok_AtTag::EV_TokenId ev_incomplete(Tok_AtTag::incomplete,"@incomplete"); +Tok_AtTag::EV_TokenId ev_version(Tok_AtTag::version,"@version"); +Tok_AtTag::EV_TokenId ev_guarantees(Tok_AtTag::guarantees,"@guarantees"); +Tok_AtTag::EV_TokenId ev_exception(Tok_AtTag::exception,"@exception"); +Tok_AtTag::EV_TokenId ev_since(Tok_AtTag::since,"@since"); + + +namespace lux +{ +template<> EnumValueMap & +Tok_AtTag::EV_TokenId::Values_() { return G_aTokAtTag_EV_TokenId_Values; } +} + + +namespace csi +{ +namespace dsapi +{ + +void +Tok_AtTag::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_AtTag(*this); +} + +const char * +Tok_AtTag::Text() const +{ + return eTag.Text(); +} + +} // namespace dsapi +} // namespace csi + diff --git a/autodoc/source/parser_i/idoc/tk_docw2.cxx b/autodoc/source/parser_i/idoc/tk_docw2.cxx new file mode 100644 index 000000000000..56e0a935ac38 --- /dev/null +++ b/autodoc/source/parser_i/idoc/tk_docw2.cxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/tk_docw2.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <s2_dsapi/tokintpr.hxx> + + + +namespace csi +{ +namespace dsapi +{ + +void +Tok_Word::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_Word(*this); +} + +const char * +Tok_Word::Text() const +{ + return sText; +} + +void +Tok_Comma::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_Comma(); +} + +const char * +Tok_Comma::Text() const +{ + return ","; +} + +void +Tok_DocuEnd::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_DocuEnd(); +} + +const char * +Tok_DocuEnd::Text() const +{ + return "*/"; +} + +void +Tok_EOL::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_EOL(); +} + +const char * +Tok_EOL::Text() const +{ + return "\r\n"; +} + +void +Tok_EOF::Trigger( TokenInterpreter & ) const +{ + csv_assert(false); +} + +const char * +Tok_EOF::Text() const +{ + return ""; +} + +void +Tok_White::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_White(); +} + +const char * +Tok_White::Text() const +{ + return " "; +} + + + + +} // namespace dsapi +} // namespace csi + diff --git a/autodoc/source/parser_i/idoc/tk_html.cxx b/autodoc/source/parser_i/idoc/tk_html.cxx new file mode 100644 index 000000000000..bfb44a3789e8 --- /dev/null +++ b/autodoc/source/parser_i/idoc/tk_html.cxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/tk_html.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <s2_dsapi/tokintpr.hxx> + + + +namespace csi +{ +namespace dsapi +{ + +void +Tok_HtmlTag::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_HtmlTag(*this); +} + +const char * +Tok_HtmlTag::Text() const +{ + return sTag; +} + + +} // namespace dsapi +} // namespace csi + + diff --git a/autodoc/source/parser_i/idoc/tk_xml.cxx b/autodoc/source/parser_i/idoc/tk_xml.cxx new file mode 100644 index 000000000000..9626fdb330ed --- /dev/null +++ b/autodoc/source/parser_i/idoc/tk_xml.cxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <s2_dsapi/tk_xml.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <s2_dsapi/tokintpr.hxx> + +using csi::dsapi::Tok_XmlConst; +using csi::dsapi::Tok_XmlLink_Tag; +using csi::dsapi::Tok_XmlFormat_Tag; + + +lux::EnumValueMap G_aTok_XmlConst_EV_TokenId_Values; +Tok_XmlConst::EV_TokenId ev_consts_none(Tok_XmlConst::e_none,""); +Tok_XmlConst::EV_TokenId ev_e_true(Tok_XmlConst::e_true,"true"); +Tok_XmlConst::EV_TokenId ev_e_false(Tok_XmlConst::e_false,"false"); +Tok_XmlConst::EV_TokenId ev_e_null(Tok_XmlConst::e_null,"NULL"); +Tok_XmlConst::EV_TokenId ev_e_void(Tok_XmlConst::e_void,"void"); + +lux::EnumValueMap G_aTok_XmlLink_Tag_EV_TokenId_Values; +Tok_XmlLink_Tag::EV_TokenId ev_linktags_none(Tok_XmlLink_Tag::e_none,""); +Tok_XmlLink_Tag::EV_TokenId ev_e_const(Tok_XmlLink_Tag::e_const,"const"); +Tok_XmlLink_Tag::EV_TokenId ev_member(Tok_XmlLink_Tag::member,"member"); +Tok_XmlLink_Tag::EV_TokenId ev_type(Tok_XmlLink_Tag::type,"type"); + +lux::EnumValueMap G_aTok_XmlFormat_Tag_EV_TokenId_Values; +Tok_XmlFormat_Tag::EV_TokenId ev_formattags_none(Tok_XmlFormat_Tag::e_none,""); +Tok_XmlFormat_Tag::EV_TokenId ev_code(Tok_XmlFormat_Tag::code,"code"); +Tok_XmlFormat_Tag::EV_TokenId ev_listing(Tok_XmlFormat_Tag::listing,"listing"); +Tok_XmlFormat_Tag::EV_TokenId ev_atom(Tok_XmlFormat_Tag::atom,"code"); + + +namespace lux +{ + +template<> EnumValueMap & +Tok_XmlConst::EV_TokenId::Values_() { return G_aTok_XmlConst_EV_TokenId_Values; } +template<> EnumValueMap & +Tok_XmlLink_Tag::EV_TokenId::Values_() { return G_aTok_XmlLink_Tag_EV_TokenId_Values; } +template<> EnumValueMap & +Tok_XmlFormat_Tag::EV_TokenId::Values_() { return G_aTok_XmlFormat_Tag_EV_TokenId_Values; } + +} // namespace lux + + + +namespace csi +{ +namespace dsapi +{ + +void +Tok_XmlConst::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_XmlConst(*this); +} + +const char * +Tok_XmlConst::Text() const +{ + return eTag.Text(); +} + +void +Tok_XmlLink_BeginTag::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_XmlLink_BeginTag(*this); +} + +const char * +Tok_XmlLink_BeginTag::Text() const +{ + static StreamStr ret(120); + ret.seekp(0); + if (sScope.length() > 0) + { + ret << "<" + << eTag.Text() + << " scope=\"" + << sScope + << "\">"; + } + else + { + ret << "<" + << eTag.Text() + << ">"; + } + return ret.c_str(); +} + +void +Tok_XmlLink_EndTag::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_XmlLink_EndTag(*this); +} + +const char * +Tok_XmlLink_EndTag::Text() const +{ + static StreamStr ret(120); + ret.seekp(0); + ret << "</" + << eTag.Text() + << ">"; + return ret.c_str(); +} + +void +Tok_XmlFormat_BeginTag::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_XmlFormat_BeginTag(*this); +} + +const char * +Tok_XmlFormat_BeginTag::Text() const +{ + static StreamStr ret(120); + ret.seekp(0); + ret << "<" + << eTag.Text() + << ">"; + return ret.c_str(); +} + +void +Tok_XmlFormat_EndTag::Trigger( TokenInterpreter & io_rInterpreter ) const +{ + io_rInterpreter.Process_XmlFormat_EndTag(*this); +} + +const char * +Tok_XmlFormat_EndTag::Text() const +{ + static StreamStr ret(120); + ret.seekp(0); + ret << "</" + << eTag.Text() + << ">"; + return ret.c_str(); +} + + +} // namespace dsapi +} // namespace csi + + |