diff options
author | Dávid Vastag <davewwpublic@gmail.com> | 2013-02-11 16:49:40 +0100 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2013-02-13 10:19:14 +0100 |
commit | d06c698b799e0e4ceaf3a3760c9589fe29dc29a9 (patch) | |
tree | 3bfb9ee128aa58f2dd0d436dba1ffe04df933bc4 /helpcompiler/inc/BasCodeTagger.hxx | |
parent | 089a9afc95acf7eeff242369fcddee0f5337df62 (diff) |
Basic code syntaxhighlighting added to LibreOffice help
Change-Id: Id47172d0386e7aa28d82178f04b5f626f0c441fe
Diffstat (limited to 'helpcompiler/inc/BasCodeTagger.hxx')
-rw-r--r-- | helpcompiler/inc/BasCodeTagger.hxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/helpcompiler/inc/BasCodeTagger.hxx b/helpcompiler/inc/BasCodeTagger.hxx new file mode 100644 index 000000000000..3cf9261ed8db --- /dev/null +++ b/helpcompiler/inc/BasCodeTagger.hxx @@ -0,0 +1,57 @@ +#ifndef BASCODETAGGER_HXX +#define BASCODETAGGER_HXX + +#include <iostream> +#include <cstdlib> +#include <string> +#include <list> +#include <libxml/xmlmemory.h> +#include <libxml/parser.h> +#include <rtl/ustring.hxx> +#include <svtools/syntaxhighlight.hxx> +#include <helpcompiler/dllapi.h> + +class BasicCodeTagger; +class LibXmlTreeWalker; + +//!Tagger class. +class L10N_DLLPUBLIC BasicCodeTagger +{ + private: + xmlDocPtr m_pDocument; + std::list<xmlNodePtr> m_BasicCodeContainerTags; + LibXmlTreeWalker *m_pXmlTreeWalker; + std::list<std::string> m_BasicCodeStringList; + SyntaxHighlighter m_Highlighter; + bool m_bTaggingCompleted; + void tagParagraph( xmlNodePtr paragraph ); + xmlChar* getTypeString( TokenTypes tokenType ); + void getBasicCodeContainerNodes(); + void tagBasCodeParagraphs(); + + public: + enum TaggerException { FILE_WRITING, NULL_DOCUMENT, EMPTY_DOCUMENT }; + BasicCodeTagger( xmlDocPtr rootDoc ); + ~BasicCodeTagger(); + void tagBasicCodes(); + void saveTreeToFile( const std::string& filePath, const std::string& encoding ); +}; + +//================LibXmlTreeWalker=========================================================== + +class L10N_DLLPUBLIC LibXmlTreeWalker +{ + private: + xmlNodePtr m_pCurrentNode; + std::list<xmlNodePtr> m_Queue; //!Queue for breath-first search + + public: + LibXmlTreeWalker( xmlDocPtr doc ); + ~LibXmlTreeWalker() {} + void nextNode(); + xmlNodePtr currentNode(); + bool end(); + void ignoreCurrNodesChildren(); +}; + +#endif |