Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #ifndef INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFTOKENIZER_HXX
11 : #define INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFTOKENIZER_HXX
12 :
13 : #include <rtflistener.hxx>
14 : #include <com/sun/star/task/XStatusIndicator.hpp>
15 :
16 : class SvStream;
17 :
18 : namespace writerfilter
19 : {
20 : namespace rtftok
21 : {
22 : /// RTF tokenizer that separates control words from text.
23 : class RTFTokenizer
24 : {
25 : public:
26 : RTFTokenizer(RTFListener& rImport, SvStream* pInStream, com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const& xStatusIndicator);
27 : virtual ~RTFTokenizer();
28 :
29 : int resolveParse();
30 : int asHex(char ch);
31 : /// Number of states on the stack.
32 62852 : int getGroup() const
33 : {
34 62852 : return m_nGroup;
35 : }
36 : /// To be invoked by the pushState() callback to signal when the importer enters a group.
37 : void pushGroup();
38 : /// To be invoked by the popState() callback to single when the importer leaves a group.
39 : void popGroup();
40 : OUString getPosition();
41 14 : sal_Size getGroupStart()
42 : {
43 14 : return m_nGroupStart;
44 : }
45 : /// To look up additional properties of a math symbol.
46 : static bool lookupMathKeyword(RTFMathSymbol& rSymbol);
47 : private:
48 3676636 : SvStream& Strm()
49 : {
50 3676636 : return *m_pInStream;
51 : }
52 : int resolveKeyword();
53 : int dispatchKeyword(OString& rKeyword, bool bParam, int nParam);
54 :
55 : RTFListener& m_rImport;
56 : SvStream* m_pInStream;
57 : com::sun::star::uno::Reference<com::sun::star::task::XStatusIndicator> const& m_xStatusIndicator;
58 : // This is the same as aRTFControlWords, but sorted
59 : static std::vector<RTFSymbol> m_aRTFControlWords;
60 : static bool m_bControlWordsSorted;
61 : // This is the same as aRTFMathControlWords, but sorted
62 : static std::vector<RTFMathSymbol> m_aRTFMathControlWords;
63 : static bool m_bMathControlWordsSorted;
64 : /// Same as the size of the importer's states, except that this can be negative for invalid input.
65 : int m_nGroup;
66 : sal_Int32 m_nLineNumber;
67 : sal_Size m_nLineStartPos;
68 : sal_Size m_nGroupStart;
69 : };
70 : } // namespace rtftok
71 : } // namespace writerfilter
72 :
73 : #endif // INCLUDED_WRITERFILTER_SOURCE_RTFTOK_RTFTOKENIZER_HXX
74 :
75 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|