summaryrefslogtreecommitdiff
path: root/writerfilter/source/rtftok/rtflistener.hxx
blob: 150440afbb4780bc476ee9539fd41710dc437baf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* -*- 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/.
 */

#pragma once

#include "rtfcontrolwords.hxx"

namespace writerfilter::rtftok
{
enum class RTFInternalState
{
    NORMAL,
    BIN,
    HEX
};

enum class RTFError
{
    OK,
    GROUP_UNDER,
    GROUP_OVER,
    UNEXPECTED_EOF,
    HEX_INVALID,
    CHAR_OVER,
    CLASSIFICATION
};

/**
 * RTFTokenizer needs a class implementing this interface. While
 * RTFTokenizer separates control words (and their arguments) from
 * text, the class implementing this interface is expected to map the
 * raw RTF tokens to dmapper tokens.
 */
class RTFListener
{
public:
    virtual ~RTFListener() = default;
    // Dispatching of control words and characters.
    virtual RTFError dispatchDestination(RTFKeyword nKeyword) = 0;
    virtual RTFError dispatchFlag(RTFKeyword nKeyword) = 0;
    virtual RTFError dispatchSymbol(RTFKeyword nKeyword) = 0;
    virtual RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) = 0;
    virtual RTFError dispatchValue(RTFKeyword nKeyword, int nParam) = 0;
    virtual RTFError resolveChars(char ch) = 0;

    // State handling.
    virtual RTFError pushState() = 0;
    virtual RTFError popState() = 0;

    virtual Destination getDestination() = 0;
    virtual void setDestination(Destination eDestination) = 0;
    virtual RTFInternalState getInternalState() = 0;
    virtual void setInternalState(RTFInternalState nInternalState) = 0;
    virtual bool getSkipUnknown() = 0;
    virtual void setSkipUnknown(bool bSkipUnknown) = 0;

    // Substream handling.
    virtual void finishSubstream() = 0;
    virtual bool isSubstream() const = 0;
};
} // namespace writerfilter::rtftok

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