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