parrtf.cxx (d92770c0) parrtf.cxx (facfa769)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_svtools.hxx"
26
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_svtools.hxx"
26
27/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
28
29#include <stdio.h> // for EOF
27#include <stdio.h> // for EOF
30#include <rtl/tencinfo.h>
31#include <tools/stream.hxx>
32#include <tools/debug.hxx>
33#include <svtools/rtftoken.h>
34#include <svtools/rtfkeywd.hxx>
35#include <svtools/parrtf.hxx>
36
37const int MAX_STRING_LEN = 1024;
38const int MAX_TOKEN_LEN = 128;
39
40#define RTF_ISDIGIT( c ) (c >= '0' && c <= '9')
41#define RTF_ISALPHA( c ) ( (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') )
42
43SvRTFParser::SvRTFParser( SvStream& rIn, sal_uInt8 nStackSize )
44 : SvParser( rIn, nStackSize ),
28#include <rtl/tencinfo.h>
29#include <tools/stream.hxx>
30#include <tools/debug.hxx>
31#include <svtools/rtftoken.h>
32#include <svtools/rtfkeywd.hxx>
33#include <svtools/parrtf.hxx>
34
35const int MAX_STRING_LEN = 1024;
36const int MAX_TOKEN_LEN = 128;
37
38#define RTF_ISDIGIT( c ) (c >= '0' && c <= '9')
39#define RTF_ISALPHA( c ) ( (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') )
40
41SvRTFParser::SvRTFParser( SvStream& rIn, sal_uInt8 nStackSize )
42 : SvParser( rIn, nStackSize ),
45 eUNICodeSet( RTL_TEXTENCODING_MS_1252 ), // default ist ANSI-CodeSet
43 eUNICodeSet( RTL_TEXTENCODING_MS_1252 ), // default is ANSI code set
46 nUCharOverread( 1 )
47{
44 nUCharOverread( 1 )
45{
48 // default ist ANSI-CodeSet
46 // default is ANSI code set
49 SetSrcEncoding( RTL_TEXTENCODING_MS_1252 );
50 bRTF_InTextRead = false;
51}
52
53SvRTFParser::~SvRTFParser()
54{
55}
56

--- 28 unchanged lines hidden (view full) ---

85 break;
86
87 case '*': // ignoreflag
88 nRet = RTF_IGNOREFLAG;
89 break;
90 case ':': // subentry in an index entry
91 nRet = RTF_SUBENTRYINDEX;
92 break;
47 SetSrcEncoding( RTL_TEXTENCODING_MS_1252 );
48 bRTF_InTextRead = false;
49}
50
51SvRTFParser::~SvRTFParser()
52{
53}
54

--- 28 unchanged lines hidden (view full) ---

83 break;
84
85 case '*': // ignoreflag
86 nRet = RTF_IGNOREFLAG;
87 break;
88 case ':': // subentry in an index entry
89 nRet = RTF_SUBENTRYINDEX;
90 break;
93 case '|': // formula-charakter
91 case '|': // formula-character
94 nRet = RTF_FORMULA;
95 break;
96
97 case 0x0a:
98 case 0x0d:
99 nRet = RTF_PAR;
100 break;
101

--- 6 unchanged lines hidden (view full) ---

108 sal_Unicode* pStr = aStrBuffer.AllocBuffer(
109 MAX_TOKEN_LEN );
110 xub_StrLen nStrLen = 0;
111 do {
112 *(pStr + nStrLen++) = nNextCh;
113 if( MAX_TOKEN_LEN == nStrLen )
114 {
115 aToken += aStrBuffer;
92 nRet = RTF_FORMULA;
93 break;
94
95 case 0x0a:
96 case 0x0d:
97 nRet = RTF_PAR;
98 break;
99

--- 6 unchanged lines hidden (view full) ---

106 sal_Unicode* pStr = aStrBuffer.AllocBuffer(
107 MAX_TOKEN_LEN );
108 xub_StrLen nStrLen = 0;
109 do {
110 *(pStr + nStrLen++) = nNextCh;
111 if( MAX_TOKEN_LEN == nStrLen )
112 {
113 aToken += aStrBuffer;
116 aToken.GetBufferAccess(); // make unique string!
114 aToken.GetBufferAccess(); // make unique string!
117 nStrLen = 0;
118 }
119 nNextCh = GetNextChar();
120 } while( RTF_ISALPHA( nNextCh ) );
121 if( nStrLen )
122 {
123 aStrBuffer.ReleaseBufferAccess( nStrLen );
124 aToken += aStrBuffer;

--- 16 unchanged lines hidden (view full) ---

141 nTokenValue *= 10;
142 nTokenValue += nNextCh - '0';
143 nNextCh = GetNextChar();
144 } while( RTF_ISDIGIT( nNextCh ) );
145 if( bNegValue )
146 nTokenValue = -nTokenValue;
147 bTokenHasValue=true;
148 }
115 nStrLen = 0;
116 }
117 nNextCh = GetNextChar();
118 } while( RTF_ISALPHA( nNextCh ) );
119 if( nStrLen )
120 {
121 aStrBuffer.ReleaseBufferAccess( nStrLen );
122 aToken += aStrBuffer;

--- 16 unchanged lines hidden (view full) ---

139 nTokenValue *= 10;
140 nTokenValue += nNextCh - '0';
141 nNextCh = GetNextChar();
142 } while( RTF_ISDIGIT( nNextCh ) );
143 if( bNegValue )
144 nTokenValue = -nTokenValue;
145 bTokenHasValue=true;
146 }
149 else if( bNegValue ) // das Minus wieder zurueck
147 else if( bNegValue ) // das Minus wieder zurueck
150 {
151 nNextCh = '-';
152 rInput.SeekRel( -1 );
153 }
148 {
149 nNextCh = '-';
150 rInput.SeekRel( -1 );
151 }
154 if( ' ' == nNextCh ) // Blank gehoert zum Token!
152 if( ' ' == nNextCh ) // Blank gehoert zum Token!
155 nNextCh = GetNextChar();
156
157 // suche das Token in der Tabelle:
158 if( 0 == (nRet = GetRTFToken( aToken )) )
159 // Unknown Control
160 nRet = RTF_UNKNOWNCONTROL;
161
162 // bug 76812 - unicode token handled as normal text
163 bNextCh = false;
164 switch( nRet )
165 {
166 case RTF_UC:
167 if( 0 <= nTokenValue )
168 {
169 nUCharOverread = (sal_uInt8)nTokenValue;
170#if 1
153 nNextCh = GetNextChar();
154
155 // suche das Token in der Tabelle:
156 if( 0 == (nRet = GetRTFToken( aToken )) )
157 // Unknown Control
158 nRet = RTF_UNKNOWNCONTROL;
159
160 // bug 76812 - unicode token handled as normal text
161 bNextCh = false;
162 switch( nRet )
163 {
164 case RTF_UC:
165 if( 0 <= nTokenValue )
166 {
167 nUCharOverread = (sal_uInt8)nTokenValue;
168#if 1
171 //cmc: other ifdef breaks #i3584
169 // cmc: other ifdef breaks #i3584
172 aParserStates.top().
173 nUCharOverread = nUCharOverread;
174#else
175 if( !nUCharOverread )
176 nUCharOverread = aParserStates.top().nUCharOverread;
177 else
178 aParserStates.top().
179 nUCharOverread = nUCharOverread;
180#endif
181 }
182 aToken.Erase(); // #i47831# erase token to prevent the token from being treated as text
183 // read next token
184 nRet = 0;
185 break;
186
187 case RTF_UPR:
188 if (!_inSkipGroup) {
189 // UPR - overread the group with the ansi
170 aParserStates.top().
171 nUCharOverread = nUCharOverread;
172#else
173 if( !nUCharOverread )
174 nUCharOverread = aParserStates.top().nUCharOverread;
175 else
176 aParserStates.top().
177 nUCharOverread = nUCharOverread;
178#endif
179 }
180 aToken.Erase(); // #i47831# erase token to prevent the token from being treated as text
181 // read next token
182 nRet = 0;
183 break;
184
185 case RTF_UPR:
186 if (!_inSkipGroup) {
187 // UPR - overread the group with the ansi
190 // informations
188 // information
191 while( '{' != _GetNextToken() )
192 ;
193 SkipGroup();
189 while( '{' != _GetNextToken() )
190 ;
191 SkipGroup();
194 _GetNextToken(); // overread the last bracket
192 _GetNextToken(); // overread the last bracket
195 nRet = 0;
196 }
197 break;
198
199 case RTF_U:
200 if( !bRTF_InTextRead )
201 {
202 nRet = RTF_TEXTTOKEN;

--- 37 unchanged lines hidden (view full) ---

240 nRet = nNextCh;
241 break;
242
243 case '{':
244 {
245 if( 0 <= nOpenBrakets )
246 {
247 RtfParserState_Impl aState( nUCharOverread, GetSrcEncoding() );
193 nRet = 0;
194 }
195 break;
196
197 case RTF_U:
198 if( !bRTF_InTextRead )
199 {
200 nRet = RTF_TEXTTOKEN;

--- 37 unchanged lines hidden (view full) ---

238 nRet = nNextCh;
239 break;
240
241 case '{':
242 {
243 if( 0 <= nOpenBrakets )
244 {
245 RtfParserState_Impl aState( nUCharOverread, GetSrcEncoding() );
248 aParserStates.push( aState );
246 aParserStates.push( aState );
249 }
250 ++nOpenBrakets;
247 }
248 ++nOpenBrakets;
251 DBG_ASSERT(
252 static_cast<size_t>(nOpenBrakets) == aParserStates.size(),
253 "ParserStateStack unequal to bracket count" );
249 DBG_ASSERT(
250 static_cast<size_t>(nOpenBrakets) == aParserStates.size(),
251 "ParserStateStack unequal to bracket count" );
254 nRet = nNextCh;
255 }
256 break;
257
258 case '}':
259 --nOpenBrakets;
260 if( 0 <= nOpenBrakets )
261 {
252 nRet = nNextCh;
253 }
254 break;
255
256 case '}':
257 --nOpenBrakets;
258 if( 0 <= nOpenBrakets )
259 {
262 aParserStates.pop();
260 aParserStates.pop();
263 if( !aParserStates.empty() )
264 {
265 const RtfParserState_Impl& rRPS =
266 aParserStates.top();
267 nUCharOverread = rRPS.nUCharOverread;
268 SetSrcEncoding( rRPS.eCodeSet );
269 }
270 else
271 {
272 nUCharOverread = 1;
273 SetSrcEncoding( GetCodeSet() );
274 }
275 }
261 if( !aParserStates.empty() )
262 {
263 const RtfParserState_Impl& rRPS =
264 aParserStates.top();
265 nUCharOverread = rRPS.nUCharOverread;
266 SetSrcEncoding( rRPS.eCodeSet );
267 }
268 else
269 {
270 nUCharOverread = 1;
271 SetSrcEncoding( GetCodeSet() );
272 }
273 }
276 DBG_ASSERT(
277 static_cast<size_t>(nOpenBrakets) == aParserStates.size(),
278 "ParserStateStack unequal to bracket count" );
274 DBG_ASSERT(
275 static_cast<size_t>(nOpenBrakets) == aParserStates.size(),
276 "ParserStateStack unequal to bracket count" );
279 nRet = nNextCh;
280 break;
281
282 case 0x0d:
283 case 0x0a:
284 break;
285
286 default:

--- 44 unchanged lines hidden (view full) ---

331 case '\\':
332 {
333 switch (nNextCh = GetNextChar())
334 {
335 case '\'':
336 {
337
338#if 0
277 nRet = nNextCh;
278 break;
279
280 case 0x0d:
281 case 0x0a:
282 break;
283
284 default:

--- 44 unchanged lines hidden (view full) ---

329 case '\\':
330 {
331 switch (nNextCh = GetNextChar())
332 {
333 case '\'':
334 {
335
336#if 0
339 // #i35653 patch from cmc
340 ByteString aByteString(static_cast<char>(GetHexValue()));
341 if (aByteString.Len())
342 aStrBuffer.Append(String(aByteString, GetSrcEncoding()));
337 // #i35653 patch from cmc
338 ByteString aByteString(static_cast<char>(GetHexValue()));
339 if (aByteString.Len())
340 aStrBuffer.Append(String(aByteString, GetSrcEncoding()));
343#else
341#else
344 ByteString aByteString;
345 while (1)
346 {
347 aByteString.Append((char)GetHexValue());
342 ByteString aByteString;
343 while (1)
344 {
345 aByteString.Append((char)GetHexValue());
348
346
349 bool bBreak = false;
350 sal_Char nSlash = '\\';
351 while (!bBreak)
352 {
347 bool bBreak = false;
348 sal_Char nSlash = '\\';
349 while (!bBreak)
350 {
353 wchar_t __next=GetNextChar();
354 if (__next>0xFF) // fix for #i43933# and #i35653#
355 {
356 if (aByteString.Len())
357 aStrBuffer.Append(String(aByteString, GetSrcEncoding()));
358 aStrBuffer.Append((sal_Unicode)__next);
359
360 aByteString.Erase();
361 continue;
362 }
351 wchar_t __next=GetNextChar();
352 if (__next>0xFF) // fix for #i43933# and #i35653#
353 {
354 if (aByteString.Len())
355 aStrBuffer.Append(String(aByteString, GetSrcEncoding()));
356 aStrBuffer.Append((sal_Unicode)__next);
357
358 aByteString.Erase();
359 continue;
360 }
363 nSlash = (sal_Char)__next;
364 while (nSlash == 0xD || nSlash == 0xA)
365 nSlash = (sal_Char)GetNextChar();
361 nSlash = (sal_Char)__next;
362 while (nSlash == 0xD || nSlash == 0xA)
363 nSlash = (sal_Char)GetNextChar();
366
364
367 switch (nSlash)
368 {
369 case '{':
370 case '}':
371 case '\\':
372 bBreak = true;
373 break;
374 default:
375 aByteString.Append(nSlash);
376 break;
377 }
378 }
365 switch (nSlash)
366 {
367 case '{':
368 case '}':
369 case '\\':
370 bBreak = true;
371 break;
372 default:
373 aByteString.Append(nSlash);
374 break;
375 }
376 }
379
377
380 nNextCh = GetNextChar();
378 nNextCh = GetNextChar();
381
379
382 if (nSlash != '\\' || nNextCh != '\'')
383 {
384 rInput.SeekRel(-1);
385 nNextCh = nSlash;
386 break;
387 }
388 }
380 if (nSlash != '\\' || nNextCh != '\'')
381 {
382 rInput.SeekRel(-1);
383 nNextCh = nSlash;
384 break;
385 }
386 }
389
387
390 bNextCh = false;
388 bNextCh = false;
391
389
392 if (aByteString.Len())
393 aStrBuffer.Append(String(aByteString, GetSrcEncoding()));
390 if (aByteString.Len())
391 aStrBuffer.Append(String(aByteString, GetSrcEncoding()));
394#endif
392#endif
395 }
393 }
396 break;
397 case '\\':
398 case '}':
399 case '{':
400 case '+': // habe ich in einem RTF-File gefunden
401 aStrBuffer.Append(nNextCh);
402 break;
403 case '~': // nonbreaking space

--- 13 unchanged lines hidden (view full) ---

417 rInput.SeekRel( -2 );
418
419 if( '-' == nNextCh || RTF_ISDIGIT( nNextCh ) )
420 {
421 bRTF_InTextRead = true;
422
423 String sSave( aToken );
424 nNextCh = '\\';
394 break;
395 case '\\':
396 case '}':
397 case '{':
398 case '+': // habe ich in einem RTF-File gefunden
399 aStrBuffer.Append(nNextCh);
400 break;
401 case '~': // nonbreaking space

--- 13 unchanged lines hidden (view full) ---

415 rInput.SeekRel( -2 );
416
417 if( '-' == nNextCh || RTF_ISDIGIT( nNextCh ) )
418 {
419 bRTF_InTextRead = true;
420
421 String sSave( aToken );
422 nNextCh = '\\';
425 #ifdef DBG_UTIL
423 #ifdef DBG_UTIL
426 int nToken =
424 int nToken =
427 #endif
428 _GetNextToken();
425 #endif
426 _GetNextToken();
429 DBG_ASSERT( RTF_U == nToken, "doch kein UNI-Code Zeichen" );
430 // dont convert symbol chars
431 aStrBuffer.Append(
427 DBG_ASSERT( RTF_U == nToken, "doch kein UNI-Code Zeichen" );
428 // dont convert symbol chars
429 aStrBuffer.Append(
432 static_cast< sal_Unicode >(nTokenValue));
430 static_cast< sal_Unicode >(nTokenValue));
433
434 // overread the next n "RTF" characters. This
435 // can be also \{, \}, \'88
436 for( sal_uInt8 m = 0; m < nUCharOverread; ++m )
437 {
438 sal_Unicode cAnsi = nNextCh;
439 while( 0xD == cAnsi )
440 cAnsi = GetNextChar();

--- 8 unchanged lines hidden (view full) ---

449 }
450 bNextCh = false;
451 aToken = sSave;
452 bRTF_InTextRead = false;
453 }
454 else
455 {
456 nNextCh = '\\';
431
432 // overread the next n "RTF" characters. This
433 // can be also \{, \}, \'88
434 for( sal_uInt8 m = 0; m < nUCharOverread; ++m )
435 {
436 sal_Unicode cAnsi = nNextCh;
437 while( 0xD == cAnsi )
438 cAnsi = GetNextChar();

--- 8 unchanged lines hidden (view full) ---

447 }
448 bNextCh = false;
449 aToken = sSave;
450 bRTF_InTextRead = false;
451 }
452 else
453 {
454 nNextCh = '\\';
457 bWeiter = false; // Abbrechen, String zusammen
455 bWeiter = false; // Abbrechen, String zusammen
458 }
459 }
460 break;
461
462 default:
463 rInput.SeekRel( -1 );
464 nNextCh = '\\';
456 }
457 }
458 break;
459
460 default:
461 rInput.SeekRel( -1 );
462 nNextCh = '\\';
465 bWeiter = false; // Abbrechen, String zusammen
463 bWeiter = false; // Abbrechen, String zusammen
466 break;
467 }
468 }
469 break;
470
471 case sal_Unicode(EOF):
472 eState = SVPAR_ERROR;
473 // weiter

--- 12 unchanged lines hidden (view full) ---

486 else
487 {
488 do {
489 // alle anderen Zeichen kommen in den Text
490 aStrBuffer.Append(nNextCh);
491
492 if (sal_Unicode(EOF) == (nNextCh = GetNextChar()))
493 {
464 break;
465 }
466 }
467 break;
468
469 case sal_Unicode(EOF):
470 eState = SVPAR_ERROR;
471 // weiter

--- 12 unchanged lines hidden (view full) ---

484 else
485 {
486 do {
487 // alle anderen Zeichen kommen in den Text
488 aStrBuffer.Append(nNextCh);
489
490 if (sal_Unicode(EOF) == (nNextCh = GetNextChar()))
491 {
494 if (aStrBuffer.Len())
495 aToken += aStrBuffer;
492 if (aStrBuffer.Len())
493 aToken += aStrBuffer;
496 return;
497 }
498 } while
494 return;
495 }
496 } while
499 (
500 (RTF_ISALPHA(nNextCh) || RTF_ISDIGIT(nNextCh)) &&
501 (aStrBuffer.Len() < MAX_STRING_LEN)
502 );
497 (
498 (RTF_ISALPHA(nNextCh) || RTF_ISDIGIT(nNextCh)) &&
499 (aStrBuffer.Len() < MAX_STRING_LEN)
500 );
503 bNextCh = false;
504 }
505 }
506
507 if( bWeiter && bNextCh )
508 nNextCh = GetNextChar();
509 }
510
511 if (aStrBuffer.Len())
512 aToken += aStrBuffer;
513}
514
515
516short SvRTFParser::_inSkipGroup=0;
517
518void SvRTFParser::SkipGroup()
519{
520short nBrackets=1;
501 bNextCh = false;
502 }
503 }
504
505 if( bWeiter && bNextCh )
506 nNextCh = GetNextChar();
507 }
508
509 if (aStrBuffer.Len())
510 aToken += aStrBuffer;
511}
512
513
514short SvRTFParser::_inSkipGroup=0;
515
516void SvRTFParser::SkipGroup()
517{
518short nBrackets=1;
521if (_inSkipGroup>0)
519if (_inSkipGroup>0)
522 return;
523_inSkipGroup++;
520 return;
521_inSkipGroup++;
524#if 1 //#i16185# fecking \bin keyword
525 do
526 {
527 switch (nNextCh)
528 {
529 case '{':
530 ++nBrackets;
531 break;
532 case '}':
522#if 1 // #i16185# fecking \bin keyword
523 do
524 {
525 switch (nNextCh)
526 {
527 case '{':
528 ++nBrackets;
529 break;
530 case '}':
533 if (!--nBrackets) {
534 _inSkipGroup--;
531 if (!--nBrackets) {
532 _inSkipGroup--;
535 return;
533 return;
536 }
534 }
537 break;
538 }
539 int nToken = _GetNextToken();
540 if (nToken == RTF_BIN)
541 {
542 rInput.SeekRel(-1);
543 rInput.SeekRel(nTokenValue);
544 nNextCh = GetNextChar();
545 }
535 break;
536 }
537 int nToken = _GetNextToken();
538 if (nToken == RTF_BIN)
539 {
540 rInput.SeekRel(-1);
541 rInput.SeekRel(nTokenValue);
542 nNextCh = GetNextChar();
543 }
546 while (nNextCh==0xa || nNextCh==0xd)
547 {
548 nNextCh = GetNextChar();
549 }
544 while (nNextCh==0xa || nNextCh==0xd)
545 {
546 nNextCh = GetNextChar();
547 }
550 } while (sal_Unicode(EOF) != nNextCh && IsParserWorking());
548 } while (sal_Unicode(EOF) != nNextCh && IsParserWorking());
551#else
552 sal_Unicode cPrev = 0;
553 do {
554 switch( nNextCh )
555 {
556 case '{':
557 if( '\\' != cPrev )
558 ++nBrackets;

--- 22 unchanged lines hidden (view full) ---

581void SvRTFParser::ReadUnknownData() { SkipGroup(); }
582void SvRTFParser::ReadBitmapData() { SkipGroup(); }
583void SvRTFParser::ReadOLEData() { SkipGroup(); }
584
585
586SvParserState SvRTFParser::CallParser()
587{
588 sal_Char cFirstCh;
549#else
550 sal_Unicode cPrev = 0;
551 do {
552 switch( nNextCh )
553 {
554 case '{':
555 if( '\\' != cPrev )
556 ++nBrackets;

--- 22 unchanged lines hidden (view full) ---

579void SvRTFParser::ReadUnknownData() { SkipGroup(); }
580void SvRTFParser::ReadBitmapData() { SkipGroup(); }
581void SvRTFParser::ReadOLEData() { SkipGroup(); }
582
583
584SvParserState SvRTFParser::CallParser()
585{
586 sal_Char cFirstCh;
589 nNextChPos = rInput.Tell();
587 nNextChPos = rInput.Tell();
590 rInput >> cFirstCh; nNextCh = cFirstCh;
591 eState = SVPAR_WORKING;
592 nOpenBrakets = 0;
593 SetSrcEncoding( eCodeSet = RTL_TEXTENCODING_MS_1252 );
594 eUNICodeSet = RTL_TEXTENCODING_MS_1252; // default ist ANSI-CodeSet
595
596 // die 1. beiden Token muessen '{' und \\rtf sein !!
597 if( '{' == GetNextToken() && RTF_RTF == GetNextToken() )

--- 45 unchanged lines hidden (view full) ---

643 break; // auf zum naechsten Token!!
644 }
645 }
646 goto NEXTTOKEN;
647
648 case RTF_UNKNOWNCONTROL:
649 break; // unbekannte Token ueberspringen
650 case RTF_NEXTTYPE:
588 rInput >> cFirstCh; nNextCh = cFirstCh;
589 eState = SVPAR_WORKING;
590 nOpenBrakets = 0;
591 SetSrcEncoding( eCodeSet = RTL_TEXTENCODING_MS_1252 );
592 eUNICodeSet = RTL_TEXTENCODING_MS_1252; // default ist ANSI-CodeSet
593
594 // die 1. beiden Token muessen '{' und \\rtf sein !!
595 if( '{' == GetNextToken() && RTF_RTF == GetNextToken() )

--- 45 unchanged lines hidden (view full) ---

641 break; // auf zum naechsten Token!!
642 }
643 }
644 goto NEXTTOKEN;
645
646 case RTF_UNKNOWNCONTROL:
647 break; // unbekannte Token ueberspringen
648 case RTF_NEXTTYPE:
651 case RTF_ANSITYPE:
652 SetEncoding( eCodeSet = RTL_TEXTENCODING_MS_1252 );
653 break;
654 case RTF_MACTYPE:
655 SetEncoding( eCodeSet = RTL_TEXTENCODING_APPLE_ROMAN );
656 break;
657 case RTF_PCTYPE:
658 SetEncoding( eCodeSet = RTL_TEXTENCODING_IBM_437 );
659 break;
660 case RTF_PCATYPE:
661 SetEncoding( eCodeSet = RTL_TEXTENCODING_IBM_850 );
662 break;
649 case RTF_ANSITYPE:
650 SetEncoding( eCodeSet = RTL_TEXTENCODING_MS_1252 );
651 break;
652 case RTF_MACTYPE:
653 SetEncoding( eCodeSet = RTL_TEXTENCODING_APPLE_ROMAN );
654 break;
655 case RTF_PCTYPE:
656 SetEncoding( eCodeSet = RTL_TEXTENCODING_IBM_437 );
657 break;
658 case RTF_PCATYPE:
659 SetEncoding( eCodeSet = RTL_TEXTENCODING_IBM_850 );
660 break;
663 case RTF_ANSICPG:
661 case RTF_ANSICPG:
664 eCodeSet = rtl_getTextEncodingFromWindowsCodePage(nTokenValue);
665 SetEncoding(eCodeSet);
662 eCodeSet = rtl_getTextEncodingFromWindowsCodePage(nTokenValue);
663 SetEncoding(eCodeSet);
666 break;
667 default:
668NEXTTOKEN:
669 NextToken( nToken );
670 break;
671 }
672 if( IsParserWorking() )
673 SaveState( 0 ); // bis hierhin abgearbeitet,

--- 21 unchanged lines hidden (view full) ---

695}
696
697void SvRTFParser::RestoreState()
698{
699 SvParser::RestoreState();
700}
701#endif
702
664 break;
665 default:
666NEXTTOKEN:
667 NextToken( nToken );
668 break;
669 }
670 if( IsParserWorking() )
671 SaveState( 0 ); // bis hierhin abgearbeitet,

--- 21 unchanged lines hidden (view full) ---

693}
694
695void SvRTFParser::RestoreState()
696{
697 SvParser::RestoreState();
698}
699#endif
700
703/* vi:set tabstop=4 shiftwidth=4 expandtab: */
701/* vim: set noet sw=4 ts=4: */