summaryrefslogtreecommitdiff
path: root/autodoc/source/parser_i/idoc/docu_pe2.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'autodoc/source/parser_i/idoc/docu_pe2.cxx')
-rw-r--r--autodoc/source/parser_i/idoc/docu_pe2.cxx180
1 files changed, 47 insertions, 133 deletions
diff --git a/autodoc/source/parser_i/idoc/docu_pe2.cxx b/autodoc/source/parser_i/idoc/docu_pe2.cxx
index 2f1af7f68ba3..6b807a57bd95 100644
--- a/autodoc/source/parser_i/idoc/docu_pe2.cxx
+++ b/autodoc/source/parser_i/idoc/docu_pe2.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* 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
@@ -31,7 +31,6 @@
// NOT FULLY DEFINED SERVICES
-#include <cctype>
#include <ary/doc/d_oldidldocu.hxx>
#include <ary_i/d_token.hxx>
#include <parser/parserinfo.hxx>
@@ -56,12 +55,12 @@ namespace dsapi
{
-const char * AtTagTitle(
- const Tok_AtTag & i_rToken );
+const char * AtTagTitle(
+ const Tok_AtTag & i_rToken );
SapiDocu_PE::SapiDocu_PE(ParserInfo & io_rPositionInfo)
- : pDocu(0),
+ : pDocu(0),
eState(e_none),
pPositionInfo(&io_rPositionInfo),
fCurTokenAddFunction(&SapiDocu_PE::AddDocuToken2Void),
@@ -98,7 +97,7 @@ SapiDocu_PE::ProcessToken( DYN csi::dsapi::Token & let_drToken )
}
void
-SapiDocu_PE::Process_AtTag( const Tok_AtTag & i_rToken )
+SapiDocu_PE::Process_AtTag( const Tok_AtTag & i_rToken )
{
if (NOT pCurAtTag)
{
@@ -130,7 +129,7 @@ SapiDocu_PE::Process_AtTag( const Tok_AtTag & i_rToken )
else if (i_rToken.Id() == Tok_AtTag::since)
{
pCurAtTag = new DT_SinceAtTag;
- fCurTokenAddFunction = &SapiDocu_PE::SetCurSinceAtTagVersion_OOo;
+ fCurTokenAddFunction = &SapiDocu_PE::SetCurSinceAtTagVersion;
}
else
{
@@ -295,7 +294,7 @@ SapiDocu_PE::Process_XmlFormat_EndTag( const Tok_XmlFormat_EndTag & i_rToken )
}
void
-SapiDocu_PE::Process_Word( const Tok_Word & i_rToken )
+SapiDocu_PE::Process_Word( const Tok_Word & i_rToken )
{
(this->*fCurTokenAddFunction)(*new DT_TextToken(i_rToken.Text()));
}
@@ -304,7 +303,7 @@ void
SapiDocu_PE::Process_Comma()
{
csv_assert(1==7);
-// (this->*fCurTokenAddFunction)(*new DT_Comma(i_rToken.Text()));
+// (this->*fCurTokenAddFunction)(*new DT_Comma(i_rToken.Text()));
}
void
@@ -486,22 +485,21 @@ SapiDocu_PE::SetCurSeeAlsoAtTagLinkText_3( DYN ary::inf::DocuToken & let_drNewTo
}
/// 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();
-// }
+// Tok_XmlLink_BeginTag *
+// pLinkEnd = dynamic_cast< Tok_XmlLink_EndTag* >(&let_drNewToken);
+// if (pLinkEnd == 0)
+// {
+// warn_aboutMissingClosingTag();
+// }
delete &let_drNewToken;
fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2CurAtTag;
}
-const String
- C_sSinceFormat("Correct version format: \"OOo <major>.<minor>[.<micro> if micro is not 0]\".");
+
void
-SapiDocu_PE::SetCurSinceAtTagVersion_OOo( DYN ary::inf::DocuToken & let_drNewToken )
+SapiDocu_PE::SetCurSinceAtTagVersion( DYN ary::inf::DocuToken & let_drNewToken )
{
csv_assert(pCurAtTag);
@@ -514,62 +512,26 @@ SapiDocu_PE::SetCurSinceAtTagVersion_OOo( DYN ary::inf::DocuToken & let_drNewTok
const String
sVersion(pToken->GetText());
- if (NOT CheckVersionSyntax_OOo(sVersion))
- {
- Cerr() << "Version information in @since tag has incorrect format.\n"
- << "Found: \"" << sVersion << "\"\n"
- << C_sSinceFormat
- << Endl();
- exit(1);
- }
-
+ const char
+ cFirst = *sVersion.begin();
+ const char
+ cCiphersend = '9' + 1;
const autodoc::CommandLine &
rCommandLine = autodoc::CommandLine::Get_();
- if (NOT rCommandLine.DoesTransform_SinceTag())
- pCurAtTag->AddToken(let_drNewToken);
-
- fCurTokenAddFunction = &SapiDocu_PE::SetCurSinceAtTagVersion_Number;
-}
-
-void
-SapiDocu_PE::SetCurSinceAtTagVersion_Number( DYN ary::inf::DocuToken & let_drNewToken )
-{
- csv_assert(pCurAtTag);
-
- DT_TextToken * pToken = dynamic_cast< DT_TextToken* >(&let_drNewToken);
- if (pToken == 0)
- {
- if (dynamic_cast< DT_White* >(&let_drNewToken) != 0)
- {
- String &
- sValue = pCurAtTag->Access_Text().Access_TextOfFirstToken();
- StreamLock
- sHelp(1000);
- sValue = sHelp() << sValue << " " << c_str;
- }
-
- delete &let_drNewToken;
- return;
- }
- const String
- sVersion(pToken->GetText());
- if (NOT CheckVersionSyntax_Number(sVersion))
- {
- Cerr() << "Version information in @since tag has incorrect format.\n"
- << "Found: \"" << sVersion << "\"\n"
- << C_sSinceFormat
- << Endl();
- exit(1);
- }
- const autodoc::CommandLine &
- rCommandLine = autodoc::CommandLine::Get_();
if ( rCommandLine.DoesTransform_SinceTag())
{
- pCurAtTag->AddToken(let_drNewToken);
+ // The @since version number shall be interpreted,
- if (rCommandLine.DisplayOf_SinceTagValue(sVersion).empty())
+ 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;
@@ -583,10 +545,10 @@ SapiDocu_PE::SetCurSinceAtTagVersion_Number( DYN ary::inf::DocuToken & let_drNew
throw X_Docu("since", sl().c_str());
}
}
- else
- {
- AddDocuToken2SinceAtTag(let_drNewToken);
- }
+
+ // Either since tags are not specially interpreted, or
+ // we got a known one.
+ pCurAtTag->AddToken(let_drNewToken);
fCurTokenAddFunction = &SapiDocu_PE::AddDocuToken2SinceAtTag;
}
@@ -612,73 +574,25 @@ SapiDocu_PE::AddDocuToken2SinceAtTag( DYN ary::inf::DocuToken & let_drNewToken )
delete &let_drNewToken;
}
-bool
-SapiDocu_PE::CheckVersionSyntax_OOo(const String & i_versionPart1)
-{
- return i_versionPart1 == "OOo"
- OR i_versionPart1 == "OpenOffice.org";
-}
-
-bool
-SapiDocu_PE::CheckVersionSyntax_Number(const String & i_versionPart2)
-{
- if (i_versionPart2.length () == 0)
- return false;
-
- const char
- pt = '.';
- unsigned int countDigit = 0;
- unsigned int countPoint = 0;
- const char *
- pFirstPoint = 0;
- const char *
- pLastPoint = 0;
-
- for ( const char * p = i_versionPart2.begin();
- *p != 0;
- ++p )
- {
- if ( std::isdigit(*p) )
- ++countDigit;
- else if (*p == pt)
- {
- if (countPoint == 0)
- pFirstPoint = p;
- pLastPoint = p;
- ++countPoint;
- }
- }
-
- if ( countDigit + countPoint == i_versionPart2.length() // only digits and points
- AND pFirstPoint != 0 AND countPoint < 3 // 1 or 2 points
- AND pFirstPoint + 1 != pLastPoint // there are digits between two points
- AND *i_versionPart2.begin() != pt AND *(pLastPoint + 1) != 0 // points are surrounded by digits
- AND (*(pLastPoint + 1) != '0' OR pLastPoint == pFirstPoint) ) // the first micro-digit is not 0
- {
- return true;
- }
- return false;
-}
-
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";
+ 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.
;