BasCodeTagger.hxx 1.86 KB
Newer Older
1 2 3 4 5 6 7 8 9
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

10 11
#ifndef INCLUDED_HELPCOMPILER_INC_BASCODETAGGER_HXX
#define INCLUDED_HELPCOMPILER_INC_BASCODETAGGER_HXX
12 13 14 15

#include <iostream>
#include <cstdlib>
#include <string>
16
#include <deque>
17
#include <memory>
18
#include <vector>
19 20 21
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <rtl/ustring.hxx>
22
#include <comphelper/syntaxhighlight.hxx>
23 24 25 26 27 28 29 30 31 32
#include <helpcompiler/dllapi.h>

class BasicCodeTagger;
class LibXmlTreeWalker;

//!Tagger class.
class L10N_DLLPUBLIC BasicCodeTagger
{
  private:
    xmlDocPtr             m_pDocument;
33
    std::vector<xmlNodePtr> m_BasicCodeContainerTags;
34
    std::unique_ptr<LibXmlTreeWalker>  m_pXmlTreeWalker;
35 36 37
    SyntaxHighlighter     m_Highlighter;
    bool m_bTaggingCompleted;
    void tagParagraph( xmlNodePtr paragraph );
38
    static xmlChar* getTypeString( TokenType tokenType );
39 40 41 42
    void getBasicCodeContainerNodes();
    void tagBasCodeParagraphs();

  public:
43
    enum TaggerException { NULL_DOCUMENT, EMPTY_DOCUMENT };
44 45 46 47 48 49 50 51 52 53 54
    BasicCodeTagger( xmlDocPtr rootDoc );
    ~BasicCodeTagger();
    void tagBasicCodes();
};

//================LibXmlTreeWalker===========================================================

class L10N_DLLPUBLIC LibXmlTreeWalker
{
  private:
    xmlNodePtr            m_pCurrentNode;
55
    std::deque<xmlNodePtr> m_Queue; //!Queue for breath-first search
56 57 58 59

  public:
    LibXmlTreeWalker( xmlDocPtr doc );
    void nextNode();
60
    xmlNodePtr currentNode() { return m_pCurrentNode;}
61
    bool end() const;
62 63 64 65
    void ignoreCurrNodesChildren();
};

#endif
66 67

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */