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 | |
parent | 089a9afc95acf7eeff242369fcddee0f5337df62 (diff) |
Basic code syntaxhighlighting added to LibreOffice help
Change-Id: Id47172d0386e7aa28d82178f04b5f626f0c441fe
Diffstat (limited to 'helpcompiler/inc')
-rw-r--r-- | helpcompiler/inc/BasCodeTagger.hxx | 57 | ||||
-rw-r--r-- | helpcompiler/inc/HelpCompiler.hxx | 6 |
2 files changed, 60 insertions, 3 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 diff --git a/helpcompiler/inc/HelpCompiler.hxx b/helpcompiler/inc/HelpCompiler.hxx index f0a4177f5507..034a629c25e6 100644 --- a/helpcompiler/inc/HelpCompiler.hxx +++ b/helpcompiler/inc/HelpCompiler.hxx @@ -71,7 +71,6 @@ namespace fs { rtl::OUString sWorkingDir; osl_getProcessWorkingDir(&sWorkingDir.pData); - rtl::OString tmp(in.c_str()); rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding())); osl::File::getFileURLFromSystemPath(ustrSystemPath, data); @@ -230,6 +229,7 @@ public: HelpCompiler(StreamTable &streamTable, const fs::path &in_inputFile, const fs::path &in_src, + const fs::path &in_zipdir, const fs::path &in_resEmbStylesheet, const std::string &in_module, const std::string &in_lang, @@ -245,9 +245,10 @@ public: const std::string &entryName, const Hashtable &bytesToAdd); private: xmlDocPtr getSourceDocument(const fs::path &filePath); + void sourceDocumentPreWorks( xmlDocPtr doc , const fs::path &filePath); xmlNodePtr clone(xmlNodePtr node, const std::string& appl); StreamTable &streamTable; - const fs::path inputFile, src; + const fs::path inputFile, src, zipdir; const std::string module, lang; const fs::path resEmbStylesheet; bool bExtensionMode; @@ -260,5 +261,4 @@ inline char tocharlower(char c) } #endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |