From b4536dcb0909e8049df7424c8a39424933b88d3e Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 24 Oct 2006 02:46:20 +0000 Subject: - Don't let page number fields through. --- src/xmlcomposer.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 6a731ff..e1ae89e 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -79,6 +79,22 @@ void tokenize(const string& str, StringArray& tokens, } } +void trim(string& str, const char* whitespace = " \t") +{ + string::size_type pos = str.find_last_not_of(whitespace); + if(pos != string::npos) + { + str.erase(pos + 1); + pos = str.find_first_not_of(whitespace); + if(pos != string::npos) + str.erase(0, pos); + } + else + { + str.erase(str.begin(), str.end()); + } +} + /* ---------------------------------------------------------------------------------- * CONSTRUCTION */ @@ -1074,6 +1090,7 @@ ON_CONTROLWORD(Info) // Field Analyser ------------------------------------------------------------------- static const string kFieldHyperlink = "HYPERLINK"; +static const string kFieldPage = "PAGE"; ON_CONTROLWORD(Field) { @@ -1086,6 +1103,7 @@ ON_CONTROLWORD(Field) { StringArray codes; tokenize(fieldCode, codes, " ", '"'); + trim(fieldCode); if(codes.size() >= 2 && codes[0].compare(kFieldHyperlink) == 0) { @@ -1106,6 +1124,12 @@ ON_CONTROLWORD(Field) AN_ATTRIBUTE(kAtTo, codes[1]); } } + + // Page numbers don't make sense, don't let through + else if(fieldCode.compare(kFieldPage) == 0) + { + AN_DESTINATION(Null); + } } // The internal link data -- cgit v1.2.3