1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFTOKENIZER_HXX
11 #define INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFTOKENIZER_HXX
13 #include "rtflistener.hxx"
17 #include <com/sun/star/uno/Reference.h>
19 #include <rtl/ustring.hxx>
20 #include <tools/ref.hxx>
30 class XStatusIndicator
;
37 namespace writerfilter
41 /// RTF tokenizer that separates control words from text.
42 class RTFTokenizer final
: public virtual SvRefBase
45 RTFTokenizer(RTFListener
& rImport
, SvStream
* pInStream
,
46 css::uno::Reference
<css::task::XStatusIndicator
> const& xStatusIndicator
);
47 ~RTFTokenizer() override
;
49 RTFError
resolveParse();
50 /// Number of states on the stack.
51 int getGroup() const { return m_nGroup
; }
52 /// To be invoked by the pushState() callback to signal when the importer enters a group.
54 /// To be invoked by the popState() callback to signal when the importer leaves a group.
56 OUString
getPosition();
57 std::size_t getGroupStart() { return m_nGroupStart
; }
58 /// To look up additional properties of a math symbol.
59 static bool lookupMathKeyword(RTFMathSymbol
& rSymbol
);
62 SvStream
& Strm() { return *m_pInStream
; }
63 RTFError
resolveKeyword();
64 RTFError
dispatchKeyword(OString
const& rKeyword
, bool bParam
, int nParam
);
66 RTFListener
& m_rImport
;
67 SvStream
* m_pInStream
;
68 css::uno::Reference
<css::task::XStatusIndicator
> const& m_xStatusIndicator
;
69 // This is the same as aRTFControlWords, but sorted
70 static std::vector
<RTFSymbol
> s_aRTFControlWords
;
71 static bool s_bControlWordsSorted
;
72 // This is the same as aRTFMathControlWords, but sorted
73 static std::vector
<RTFMathSymbol
> s_aRTFMathControlWords
;
74 static bool s_bMathControlWordsSorted
;
75 /// Same as the size of the importer's states, except that this can be negative for invalid input.
77 sal_Int32 m_nLineNumber
;
78 std::size_t m_nLineStartPos
;
79 std::size_t m_nGroupStart
;
82 } // namespace writerfilter
84 #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFTOKENIZER_HXX
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */