xref: /AOO41X/main/svtools/inc/svtools/parrtf.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _PARRTF_HXX
25 #define _PARRTF_HXX
26 
27 #include "svtools/svtdllapi.h"
28 #include <svtools/svparser.hxx>
29 #include <stack>
30 
31 struct RtfParserState_Impl
32 {
33     rtl_TextEncoding eCodeSet;
34     sal_uInt8 nUCharOverread;
35 
RtfParserState_ImplRtfParserState_Impl36     RtfParserState_Impl( sal_uInt8 nUOverread, rtl_TextEncoding eCdSt )
37         : eCodeSet( eCdSt ), nUCharOverread( nUOverread )
38     {}
39 };
40 
41 typedef std::stack< RtfParserState_Impl > RtfParserStates_Impl;
42 
43 class SVT_DLLPUBLIC SvRTFParser : public SvParser
44 {
45     RtfParserStates_Impl aParserStates;
46 
47     int nOpenBrakets;
48     rtl_TextEncoding eCodeSet, eUNICodeSet;
49     sal_uInt8 nUCharOverread;
50 
51 private:
52     static short _inSkipGroup;
53 
54 protected:
55     sal_Unicode GetHexValue();
56     void ScanText( const sal_Unicode = 0 );
57     void SkipGroup();
58 
59     // scanne das naechste Token,
60     virtual int _GetNextToken();
61 
62     virtual void ReadUnknownData();
63     virtual void ReadBitmapData();
64     virtual void ReadOLEData();
65 
66     virtual ~SvRTFParser();
67 
GetCodeSet() const68     rtl_TextEncoding GetCodeSet() const             { return eCodeSet; }
69     void SetEncoding( rtl_TextEncoding eEnc );
70 
GetUNICodeSet() const71     rtl_TextEncoding GetUNICodeSet() const          { return eUNICodeSet; }
SetUNICodeSet(rtl_TextEncoding eSet)72     void SetUNICodeSet( rtl_TextEncoding eSet )     { eUNICodeSet = eSet; }
73 
74 public:
75     SvRTFParser( SvStream& rIn, sal_uInt8 nStackSize = 3 );
76 
77     virtual SvParserState CallParser();   // Aufruf des Parsers
78 
GetOpenBrakets() const79     int GetOpenBrakets() const { return nOpenBrakets; }
80 
81     // fuers asynchrone lesen aus dem SvStream
82 //  virtual void SaveState( int nToken );
83 //  virtual void RestoreState();
84     virtual void Continue( int nToken );
85 };
86 
87 #endif //_PARRTF_HXX
88