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. --- ChangeLog | 2 +- src/xmlcomposer.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a7daeb3..b152bf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,9 @@ Version 0.9.7 - - Don't let most characters below 0x0020 through. Old RTF's seem to have these for strange reasons. - Send data in chunks so massive amounts of picture data don't slow down the conversion. + - Don't let page number fields through. Version 0.9.6 - Add character styles 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