2013-02-13 12:00:22 +00:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
2022-06-18 07:54:56 -04:00
|
|
|
#pragma once
|
2013-02-11 16:49:40 +01:00
|
|
|
|
2017-11-26 16:41:00 +01:00
|
|
|
#include <deque>
|
2018-01-12 08:22:09 +02:00
|
|
|
#include <memory>
|
2017-11-26 16:41:00 +01:00
|
|
|
#include <vector>
|
2013-02-11 16:49:40 +01:00
|
|
|
#include <libxml/parser.h>
|
2013-02-15 13:02:10 +01:00
|
|
|
#include <comphelper/syntaxhighlight.hxx>
|
2013-02-11 16:49:40 +01:00
|
|
|
|
|
|
|
class LibXmlTreeWalker;
|
|
|
|
|
|
|
|
//!Tagger class.
|
2019-11-02 07:46:49 +02:00
|
|
|
class BasicCodeTagger
|
2013-02-11 16:49:40 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
xmlDocPtr m_pDocument;
|
2017-11-26 16:41:00 +01:00
|
|
|
std::vector<xmlNodePtr> m_BasicCodeContainerTags;
|
2018-01-12 08:22:09 +02:00
|
|
|
std::unique_ptr<LibXmlTreeWalker> m_pXmlTreeWalker;
|
2013-02-11 16:49:40 +01:00
|
|
|
SyntaxHighlighter m_Highlighter;
|
|
|
|
bool m_bTaggingCompleted;
|
|
|
|
void tagParagraph( xmlNodePtr paragraph );
|
2016-02-24 10:11:43 +02:00
|
|
|
static xmlChar* getTypeString( TokenType tokenType );
|
2013-02-11 16:49:40 +01:00
|
|
|
void getBasicCodeContainerNodes();
|
|
|
|
void tagBasCodeParagraphs();
|
|
|
|
|
|
|
|
public:
|
2016-01-18 14:55:27 +01:00
|
|
|
enum TaggerException { NULL_DOCUMENT, EMPTY_DOCUMENT };
|
2013-02-11 16:49:40 +01:00
|
|
|
BasicCodeTagger( xmlDocPtr rootDoc );
|
|
|
|
~BasicCodeTagger();
|
|
|
|
void tagBasicCodes();
|
|
|
|
};
|
|
|
|
|
|
|
|
//================LibXmlTreeWalker===========================================================
|
|
|
|
|
2019-11-02 07:46:49 +02:00
|
|
|
class LibXmlTreeWalker
|
2013-02-11 16:49:40 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
xmlNodePtr m_pCurrentNode;
|
2017-11-26 16:41:00 +01:00
|
|
|
std::deque<xmlNodePtr> m_Queue; //!Queue for breath-first search
|
2013-02-11 16:49:40 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
LibXmlTreeWalker( xmlDocPtr doc );
|
|
|
|
void nextNode();
|
2014-06-09 10:09:42 +02:00
|
|
|
xmlNodePtr currentNode() { return m_pCurrentNode;}
|
2017-10-30 11:45:58 +02:00
|
|
|
bool end() const;
|
2013-02-11 16:49:40 +01:00
|
|
|
void ignoreCurrNodesChildren();
|
|
|
|
};
|
|
|
|
|
2013-02-13 12:00:22 +00:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|