From aa35c653ec5fe40c50426873ca1dbe3122428709 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 8 Jun 2005 22:29:56 +0000 Subject: Bookmark support in rtfx. --- ChangeLog | 1 + doc/rtfx.xsd | 14 ++++++++ src/tags.h | 1 + src/xmlcomposer.cpp | 101 ++++++++++++++++++++++++++++------------------------ src/xmlcomposer.h | 5 +++ 5 files changed, 76 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index f150e72..42c31c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Version 0.9.6 - Now has option for pretty printing output XML - Displays version with '-v' argument - Fixed problems with Unicode + - Support for bookmarks. Version 0.9.5 - Allow conversions on stdin and stdout diff --git a/doc/rtfx.xsd b/doc/rtfx.xsd index 6ee37ee..df8da43 100644 --- a/doc/rtfx.xsd +++ b/doc/rtfx.xsd @@ -378,6 +378,7 @@ + @@ -546,4 +547,17 @@ + + + A bookmark. + + + + + The ID of the bookmark. + + + + + diff --git a/src/tags.h b/src/tags.h index fefcdc9..be140d1 100644 --- a/src/tags.h +++ b/src/tags.h @@ -85,6 +85,7 @@ static const char* kElCell = "cell"; static const char* kElRow = "row"; static const char* kElTable = "table"; static const char* kElFootNote = "footnote"; +static const char* kElBookmark = "bookmark"; static const char* kElRef = "ref"; static const char* kElFont = "font"; static const char* kElOptions = "options"; diff --git a/src/xmlcomposer.cpp b/src/xmlcomposer.cpp index 93ae306..b23a06c 100644 --- a/src/xmlcomposer.cpp +++ b/src/xmlcomposer.cpp @@ -1093,6 +1093,59 @@ ON_CONTROLWORD(Field) DEFAULT_CONTROLWORD; } + +// FootNote Analyser ---------------------------------------------------------------- + +ON_INITIALIZE(FootNote) +{ + int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE); + + AN_ELEMENT(kElFootNote); + AN_ATTRIBUTE(kAtId, ac); + AN_DESTINATION(Content); +} + +ON_CONTROLWORD(FootNote) +{ + // Inside foot notes there's no link to the foot note + if(cw == "chftn") + { + // Only put actual text when in extras mode + if(DO_EXTRAS()) + { + DestinationPtr dest = m_composer->getDestination(); + ASSERT(dest != NULL); + int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE); + dest->charData(formatInt(ac)); + } + + return; + } + + // 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; +} + +ON_DONE(FootNote) +{ + m_composer->incrementAutoCount(AUTOCOUNT_FOOTNOTE); +} + +// Bookmark Analyzer ---------------------------------------------------------------- + +ON_INITIALIZE(Bookmark) +{ + AN_ELEMENT(kElBookmark); + AN_DESTINATION_ARG(Attribute, kAtId); +} + // Root Analyser -------------------------------------------------------------------- ON_INITIALIZE(Root) @@ -1122,6 +1175,8 @@ ON_CONTROLWORD(Root) AN_ANALYSER(Skip); else if(cw == "footnote") AN_ANALYSER(FootNote); + else if(cw == "bkmkstart") + AN_ANALYSER(Bookmark); else if(cw == "pict") { AN_ANALYSER(Skip); @@ -1271,52 +1326,6 @@ ON_CHARDATA(Content) AN_POP_ELEMENT(); } - -// FootNote Analyser ---------------------------------------------------------------- - -ON_INITIALIZE(FootNote) -{ - int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE); - - AN_ELEMENT(kElFootNote); - AN_ATTRIBUTE(kAtId, ac); - AN_DESTINATION(Content); -} - -ON_CONTROLWORD(FootNote) -{ - // Inside foot notes there's no link to the foot note - if(cw == "chftn") - { - // Only put actual text when in extras mode - if(DO_EXTRAS()) - { - DestinationPtr dest = m_composer->getDestination(); - ASSERT(dest != NULL); - int ac = m_composer->getAutoCount(AUTOCOUNT_FOOTNOTE); - dest->charData(formatInt(ac)); - } - - return; - } - - // 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; -} - -ON_DONE(FootNote) -{ - m_composer->incrementAutoCount(AUTOCOUNT_FOOTNOTE); -} - - // Raw Destination ------------------------------------------------------------------ ON_CHARDATA(Raw) diff --git a/src/xmlcomposer.h b/src/xmlcomposer.h index c9c321c..f2c9336 100644 --- a/src/xmlcomposer.h +++ b/src/xmlcomposer.h @@ -321,6 +321,11 @@ protected: CONTROLWORD DONE END_ANALYSER + + // Handles bookmarks + ANALYSER(Bookmark) + INITIALIZE + END_ANALYSER }; #endif // __XMLCOMPOSER_H__ -- cgit v1.2.3