diff options
author | Stef Walter <stef@memberwebs.com> | 2005-06-07 22:52:02 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2005-06-07 22:52:02 +0000 |
commit | 9066b1cee6b62d90144c8685950a9720a0765290 (patch) | |
tree | 5c64423f3bf36658fa55a5628eecaa9cff48b71a /src/xmlcomposer.cpp | |
parent | 8803295019b0fe0b56c08899adf3f8231effb0f5 (diff) |
Add <link> tag for hyperlink fields.
Diffstat (limited to 'src/xmlcomposer.cpp')
-rw-r--r-- | src/xmlcomposer.cpp | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 0bcfbcc..aa7485f 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -322,10 +322,10 @@ void XmlComposer::addDocumentOption(DOM::Element& option) m_composer->popElement() #define AN_ATTRIBUTE(name, value) \ m_composer->setAttribute(name, value) -#define AN_DESTINATION_ATTR(name) \ - m_composer->setDestination(new Attribute(name)) #define AN_DESTINATION(cls) \ m_composer->setDestination(new cls) +#define AN_DESTINATION_ARG(cls, arg) \ + m_composer->setDestination(new cls(arg)) #define AN_ANALYSER(cls) \ m_composer->setAnalyser(AnalyserPtr(new cls)) #define AN_SET_ANALYSER(cls) \ @@ -663,7 +663,7 @@ ON_CONTROLWORD(Style) if(!haveStyle) { AN_ELEMENT(kElStyle); - AN_DESTINATION_ATTR(kAtName); + AN_DESTINATION_ARG(Attribute, kAtName); haveStyle = true; } @@ -742,7 +742,7 @@ ON_DONE(FontTable) ON_INITIALIZE(Font) { AN_ELEMENT(kElFontDef); - AN_DESTINATION_ATTR(kAtName); + AN_DESTINATION_ARG(Attribute, kAtName); } ON_CONTROLWORD(Font) @@ -796,7 +796,7 @@ ON_CONTROLWORD(List) { // The name if(cw == "listname") - AN_DESTINATION_ATTR(kAtName); + AN_DESTINATION_ARG(Attribute, kAtName); // The list id else if(cw == "listid" && HAS_PARAM) @@ -983,6 +983,57 @@ ON_CONTROLWORD(Info) DEFAULT_CONTROLWORD; } +// Field Analyser ------------------------------------------------------------------- + +static const string kFieldHyperlink = "HYPERLINK"; + +ON_CONTROLWORD(Field) +{ + // Pull out the field code and data nicely + if(cw == "fldinst" && flags & kAsterisk) + AN_DESTINATION_ARG(String, fieldCode); + + // And now we get to the precalculated field result... + else if(cw == "fldrslt") + { + // If we have a field code that we want to mess with ... + if(!fieldCode.empty()) + { + // Try to find a field code we recognize + wstring::size_type p = fieldCode.find_first_not_of(" \t"); + + if(fieldCode.compare(p, kFieldHyperlink.size(), kFieldHyperlink) == 0) + { + p += kFieldHyperlink.size(); + + // Find first quote + p = fieldCode.find('"', p); + p = (p == string::npos) ? 0 : p + 1; + + // And the end quote + wstring::size_type e = fieldCode.find('"', p); + e = (e == string::npos) ? string::npos : e - p; + + AN_ELEMENT(kElLink); + AN_ATTRIBUTE(kAtHref, fieldCode.substr(p, e)); + } + } + } + + // The internal link data + else if(flags & kAsterisk) + AN_DESTINATION(Null); + + // Process text content in the foot note + else if(processTextContent(cw, flags, param)) + DUMMY; + else if(processTextAutoContent(cw, flags, param)) + DUMMY; + else if(processTextFormatting(cw, flags, param)) + DUMMY; + else + DEFAULT_CONTROLWORD; +} // Root Analyser -------------------------------------------------------------------- @@ -1018,6 +1069,8 @@ ON_CONTROLWORD(Root) AN_ANALYSER(Skip); AN_DESTINATION(Null); } + else if(cw == "field") + AN_ANALYSER(Field); else if(flags & kAsterisk) AN_ANALYSER(Skip); else if(processTextContent(cw, flags, param)) @@ -1239,3 +1292,9 @@ ON_CHARDATA(Attribute) element.setAttribute(name, cur); } +// String Destination --------------------------------------------------------------- + +ON_CHARDATA(String) +{ + str.append(data); +} |