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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVTOOLS_PARRTF_HXX
21 : #define INCLUDED_SVTOOLS_PARRTF_HXX
22 :
23 : #include <svtools/svtdllapi.h>
24 : #include <svtools/svparser.hxx>
25 : #include <stack>
26 :
27 : struct RtfParserState_Impl
28 : {
29 : rtl_TextEncoding eCodeSet;
30 : sal_uInt8 nUCharOverread;
31 :
32 0 : RtfParserState_Impl( sal_uInt8 nUOverread, rtl_TextEncoding eCdSt )
33 0 : : eCodeSet( eCdSt ), nUCharOverread( nUOverread )
34 0 : {}
35 : };
36 :
37 : typedef std::stack< RtfParserState_Impl > RtfParserStates_Impl;
38 :
39 : class SVT_DLLPUBLIC SvRTFParser : public SvParser
40 : {
41 : RtfParserStates_Impl aParserStates;
42 :
43 : int nOpenBrakets;
44 : rtl_TextEncoding eCodeSet, eUNICodeSet;
45 : sal_uInt8 nUCharOverread;
46 :
47 : private:
48 : static short _inSkipGroup;
49 :
50 : protected:
51 : sal_Unicode GetHexValue();
52 : void ScanText( const sal_Unicode = 0 );
53 : void SkipGroup();
54 :
55 : // scanne das naechste Token,
56 : virtual int _GetNextToken() SAL_OVERRIDE;
57 :
58 : virtual void ReadUnknownData();
59 : virtual void ReadBitmapData();
60 : virtual void ReadOLEData();
61 :
62 : virtual ~SvRTFParser();
63 :
64 0 : rtl_TextEncoding GetCodeSet() const { return eCodeSet; }
65 : void SetEncoding( rtl_TextEncoding eEnc );
66 :
67 : rtl_TextEncoding GetUNICodeSet() const { return eUNICodeSet; }
68 : void SetUNICodeSet( rtl_TextEncoding eSet ) { eUNICodeSet = eSet; }
69 :
70 : public:
71 : SvRTFParser( SvStream& rIn, sal_uInt8 nStackSize = 3 );
72 :
73 : virtual SvParserState CallParser() SAL_OVERRIDE; // Aufruf des Parsers
74 :
75 : int GetOpenBrakets() const { return nOpenBrakets; }
76 :
77 : // fuers asynchrone lesen aus dem SvStream
78 : // virtual void SaveState( int nToken );
79 : // virtual void RestoreState();
80 : virtual void Continue( int nToken ) SAL_OVERRIDE;
81 : };
82 :
83 : #endif // INCLUDED_SVTOOLS_PARRTF_HXX
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|