summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xmlcomposer.cpp24
1 files changed, 24 insertions, 0 deletions
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