xref: /aoo41x/main/editeng/source/rtf/svxrtf.cxx (revision b264d727)
1190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5190118d0SAndrew Rist  * distributed with this work for additional information
6190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10190118d0SAndrew Rist  *
11190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12190118d0SAndrew Rist  *
13190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14190118d0SAndrew Rist  * software distributed under the License is distributed on an
15190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17190118d0SAndrew Rist  * specific language governing permissions and limitations
18190118d0SAndrew Rist  * under the License.
19190118d0SAndrew Rist  *
20190118d0SAndrew Rist  *************************************************************/
21190118d0SAndrew Rist 
22190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <ctype.h>
31cdf0e10cSrcweir #include <tools/datetime.hxx>
32*b264d727SArmin Le Grand #include <tools/diagnose_ex.h>
33cdf0e10cSrcweir #include <rtl/tencinfo.h>
34cdf0e10cSrcweir #include <svl/itemiter.hxx>
35cdf0e10cSrcweir #include <svl/whiter.hxx>
36cdf0e10cSrcweir #include <svtools/rtftoken.h>
37cdf0e10cSrcweir #include <svl/itempool.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <comphelper/string.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
42cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx>
43cdf0e10cSrcweir #include <editeng/fontitem.hxx>
44cdf0e10cSrcweir #include <editeng/colritem.hxx>
45cdf0e10cSrcweir #include <editeng/svxrtf.hxx>
46cdf0e10cSrcweir #include <editeng/editids.hrc>
47cdf0e10cSrcweir #include <vcl/svapp.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <com/sun/star/document/XDocumentProperties.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
SV_IMPL_PTRARR(SvxRTFItemStackList,SvxRTFItemStackType *)55cdf0e10cSrcweir SV_IMPL_PTRARR( SvxRTFItemStackList, SvxRTFItemStackType* )
56cdf0e10cSrcweir 
57cdf0e10cSrcweir CharSet lcl_GetDefaultTextEncodingForRTF()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     ::com::sun::star::lang::Locale aLocale;
61cdf0e10cSrcweir     ::rtl::OUString aLangString;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     aLocale = Application::GetSettings().GetLocale();
64cdf0e10cSrcweir     aLangString = aLocale.Language;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     if ( aLangString.equals( ::rtl::OUString::createFromAscii( "ru" ) )
67cdf0e10cSrcweir       || aLangString.equals( ::rtl::OUString::createFromAscii( "uk" ) ) )
68cdf0e10cSrcweir         return RTL_TEXTENCODING_MS_1251;
69cdf0e10cSrcweir     if ( aLangString.equals( ::rtl::OUString::createFromAscii( "tr" ) ) )
70cdf0e10cSrcweir         return RTL_TEXTENCODING_MS_1254;
71cdf0e10cSrcweir     else
72cdf0e10cSrcweir         return RTL_TEXTENCODING_MS_1252;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir // -------------- Methoden --------------------
76cdf0e10cSrcweir 
SvxRTFParser(SfxItemPool & rPool,SvStream & rIn,uno::Reference<document::XDocumentProperties> i_xDocProps,int bReadNewDoc)77cdf0e10cSrcweir SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn,
78cdf0e10cSrcweir             uno::Reference<document::XDocumentProperties> i_xDocProps,
79cdf0e10cSrcweir             int bReadNewDoc )
80cdf0e10cSrcweir 	: SvRTFParser( rIn, 5 ),
81cdf0e10cSrcweir     rStrm(rIn),
82cdf0e10cSrcweir 	aFontTbl( 16, 4 ),
83cdf0e10cSrcweir 	pInsPos( 0 ),
84cdf0e10cSrcweir 	pAttrPool( &rPool ),
85cdf0e10cSrcweir 	m_xDocProps( i_xDocProps ),
86cdf0e10cSrcweir 	pRTFDefaults( 0 ),
87cdf0e10cSrcweir 	nVersionNo( 0 )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	bNewDoc = bReadNewDoc;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	bChkStyleAttr = bCalcValue = bReadDocInfo = bIsInReadStyleTab = sal_False;
92cdf0e10cSrcweir 	bIsLeftToRightDef = sal_True;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	{
95cdf0e10cSrcweir 		RTFPlainAttrMapIds aTmp( rPool );
96cdf0e10cSrcweir 		aPlainMap.Insert( (sal_uInt16*)&aTmp,
97cdf0e10cSrcweir 					sizeof( RTFPlainAttrMapIds ) / sizeof(sal_uInt16), 0 );
98cdf0e10cSrcweir 	}
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir 		RTFPardAttrMapIds aTmp( rPool );
101cdf0e10cSrcweir 		aPardMap.Insert( (sal_uInt16*)&aTmp,
102cdf0e10cSrcweir 					sizeof( RTFPardAttrMapIds ) / sizeof(sal_uInt16), 0 );
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 	pDfltFont = new Font;
105cdf0e10cSrcweir 	pDfltColor = new Color;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
EnterEnvironment()108cdf0e10cSrcweir void SvxRTFParser::EnterEnvironment()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
LeaveEnvironment()112cdf0e10cSrcweir void SvxRTFParser::LeaveEnvironment()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
ResetPard()116cdf0e10cSrcweir void SvxRTFParser::ResetPard()
117cdf0e10cSrcweir {
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
~SvxRTFParser()120cdf0e10cSrcweir SvxRTFParser::~SvxRTFParser()
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	if( !aColorTbl.empty() )
123cdf0e10cSrcweir 		ClearColorTbl();
124cdf0e10cSrcweir 	if( aFontTbl.Count() )
125cdf0e10cSrcweir 		ClearFontTbl();
126cdf0e10cSrcweir 	if( aStyleTbl.Count() )
127cdf0e10cSrcweir 		ClearStyleTbl();
128cdf0e10cSrcweir 	if( !aAttrStack.empty() )
129cdf0e10cSrcweir 		ClearAttrStack();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	delete pRTFDefaults;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	delete pInsPos;
134cdf0e10cSrcweir 	delete pDfltFont;
135cdf0e10cSrcweir 	delete pDfltColor;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
SetInsPos(const SvxPosition & rNew)138cdf0e10cSrcweir void SvxRTFParser::SetInsPos( const SvxPosition& rNew )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	if( pInsPos )
141cdf0e10cSrcweir 		delete pInsPos;
142cdf0e10cSrcweir 	pInsPos = rNew.Clone();
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
CallParser()145cdf0e10cSrcweir SvParserState SvxRTFParser::CallParser()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	DBG_ASSERT( pInsPos, "no insertion" );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	if( !pInsPos )
150cdf0e10cSrcweir 		return SVPAR_ERROR;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	if( !aColorTbl.empty() )
153cdf0e10cSrcweir 		ClearColorTbl();
154cdf0e10cSrcweir 	if( aFontTbl.Count() )
155cdf0e10cSrcweir 		ClearFontTbl();
156cdf0e10cSrcweir 	if( aStyleTbl.Count() )
157cdf0e10cSrcweir 		ClearStyleTbl();
158cdf0e10cSrcweir 	if( !aAttrStack.empty() )
159cdf0e10cSrcweir 		ClearAttrStack();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	bIsSetDfltTab = sal_False;
162cdf0e10cSrcweir 	bNewGroup = sal_False;
163cdf0e10cSrcweir 	nDfltFont = 0;
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	sBaseURL.Erase();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	// erzeuge aus den gesetzten WhichIds die richtige WhichId-Tabelle.
168cdf0e10cSrcweir 	BuildWhichTbl();
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	return SvRTFParser::CallParser();
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
Continue(int nToken)173cdf0e10cSrcweir void SvxRTFParser::Continue( int nToken )
174cdf0e10cSrcweir {
175cdf0e10cSrcweir 	SvRTFParser::Continue( nToken );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	if( SVPAR_PENDING != GetStatus() )
178cdf0e10cSrcweir 	{
179cdf0e10cSrcweir 		SetAllAttrOfStk();
180cdf0e10cSrcweir #if 0
181cdf0e10cSrcweir     //Regardless of what "color 0" is, word defaults to auto as the default colour.
182cdf0e10cSrcweir     //e.g. see #i7713#
183cdf0e10cSrcweir 		if( bNewDoc && ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nColor )
184cdf0e10cSrcweir 			pAttrPool->SetPoolDefaultItem( SvxColorItem( GetColor( 0 ),
185cdf0e10cSrcweir 						((RTFPlainAttrMapIds*)aPlainMap.GetData())->nColor ));
186cdf0e10cSrcweir #endif
187cdf0e10cSrcweir 	 }
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // wird fuer jedes Token gerufen, das in CallParser erkannt wird
NextToken(int nToken)192cdf0e10cSrcweir void SvxRTFParser::NextToken( int nToken )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	sal_Unicode cCh;
195cdf0e10cSrcweir 	switch( nToken )
196cdf0e10cSrcweir 	{
197cdf0e10cSrcweir 	case RTF_COLORTBL:		ReadColorTable();		break;
198cdf0e10cSrcweir 	case RTF_FONTTBL:		ReadFontTable();		break;
199cdf0e10cSrcweir 	case RTF_STYLESHEET:	ReadStyleTable();		break;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	case RTF_DEFF:
202cdf0e10cSrcweir 			if( bNewDoc )
203cdf0e10cSrcweir 			{
204cdf0e10cSrcweir 				if( aFontTbl.Count() )
205cdf0e10cSrcweir 					// koennen wir sofort setzen
206cdf0e10cSrcweir 					SetDefault( nToken, nTokenValue );
207cdf0e10cSrcweir 				else
208cdf0e10cSrcweir 					// wird nach einlesen der Fonttabelle gesetzt
209cdf0e10cSrcweir 					nDfltFont = int(nTokenValue);
210cdf0e10cSrcweir 			}
211cdf0e10cSrcweir 			break;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	case RTF_DEFTAB:
214cdf0e10cSrcweir 	case RTF_DEFLANG:
215cdf0e10cSrcweir 			if( bNewDoc )
216cdf0e10cSrcweir 				SetDefault( nToken, nTokenValue );
217cdf0e10cSrcweir 			break;
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	case RTF_PICT:			ReadBitmapData();		break;
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	case RTF_LINE:			cCh = '\n';	goto INSINGLECHAR;
223cdf0e10cSrcweir 	case RTF_TAB:			cCh = '\t';	goto INSINGLECHAR;
224cdf0e10cSrcweir 	case RTF_SUBENTRYINDEX:	cCh = ':';	goto INSINGLECHAR;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	case RTF_EMDASH:		cCh = 151;	goto INSINGLECHAR;
227cdf0e10cSrcweir 	case RTF_ENDASH:		cCh = 150;	goto INSINGLECHAR;
228cdf0e10cSrcweir 	case RTF_BULLET:		cCh = 149;	goto INSINGLECHAR;
229cdf0e10cSrcweir 	case RTF_LQUOTE:		cCh = 145;	goto INSINGLECHAR;
230cdf0e10cSrcweir 	case RTF_RQUOTE:		cCh = 146;	goto INSINGLECHAR;
231cdf0e10cSrcweir 	case RTF_LDBLQUOTE:		cCh = 147;	goto INSINGLECHAR;
232cdf0e10cSrcweir 	case RTF_RDBLQUOTE:		cCh = 148;	goto INSINGLECHAR;
233cdf0e10cSrcweir INSINGLECHAR:
234cdf0e10cSrcweir 		aToken = ByteString::ConvertToUnicode( (sal_Char)cCh,
235cdf0e10cSrcweir 											RTL_TEXTENCODING_MS_1252 );
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 		// kein Break, aToken wird als Text gesetzt
238cdf0e10cSrcweir 	case RTF_TEXTTOKEN:
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			InsertText();
241cdf0e10cSrcweir 			// alle angesammelten Attribute setzen
242cdf0e10cSrcweir 			for( sal_uInt16 n = aAttrSetList.Count(); n; )
243cdf0e10cSrcweir 			{
244cdf0e10cSrcweir 				SvxRTFItemStackType* pStkSet = aAttrSetList[--n];
245cdf0e10cSrcweir 				SetAttrSet( *pStkSet );
246cdf0e10cSrcweir 				aAttrSetList.DeleteAndDestroy( n );
247cdf0e10cSrcweir 			}
248cdf0e10cSrcweir 		}
249cdf0e10cSrcweir 		break;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	case RTF_PAR:
253cdf0e10cSrcweir 		InsertPara();
254cdf0e10cSrcweir 		break;
255cdf0e10cSrcweir 	case '{':
256cdf0e10cSrcweir 		if (bNewGroup)			// Verschachtelung !!
257cdf0e10cSrcweir             _GetAttrSet();
258cdf0e10cSrcweir         EnterEnvironment();
259cdf0e10cSrcweir 		bNewGroup = true;
260cdf0e10cSrcweir 		break;
261cdf0e10cSrcweir 	case '}':
262cdf0e10cSrcweir 		if( !bNewGroup )		// leere Gruppe ??
263cdf0e10cSrcweir 			AttrGroupEnd();
264cdf0e10cSrcweir         LeaveEnvironment();
265cdf0e10cSrcweir 		bNewGroup = false;
266cdf0e10cSrcweir 		break;
267cdf0e10cSrcweir 	case RTF_INFO:
268cdf0e10cSrcweir #ifndef SVX_LIGHT
269cdf0e10cSrcweir 		if (bReadDocInfo && bNewDoc && m_xDocProps.is())
270cdf0e10cSrcweir 			ReadInfo();
271cdf0e10cSrcweir 		else
272cdf0e10cSrcweir #endif
273cdf0e10cSrcweir 			SkipGroup();
274cdf0e10cSrcweir 		break;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
277cdf0e10cSrcweir 	// erstmal gesamt ueberlesen (muessen alle in einer Gruppe stehen !!)
278cdf0e10cSrcweir 	// Koennen auch ohne dem IGNORE-Flag im RTF-File auftreten; alle Gruppen
279cdf0e10cSrcweir 	// mit IGNORE-Flag werden im default-Zweig ueberlesen.
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	case RTF_SWG_PRTDATA:
282cdf0e10cSrcweir 	case RTF_FIELD:
283cdf0e10cSrcweir 	case RTF_ATNID:
284cdf0e10cSrcweir 	case RTF_ANNOTATION:
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	case RTF_BKMKSTART:
287cdf0e10cSrcweir 	case RTF_BKMKEND:
288cdf0e10cSrcweir 	case RTF_BKMK_KEY:
289cdf0e10cSrcweir 	case RTF_XE:
290cdf0e10cSrcweir 	case RTF_TC:
291cdf0e10cSrcweir 	case RTF_NEXTFILE:
292cdf0e10cSrcweir 	case RTF_TEMPLATE:
293cdf0e10cSrcweir #if 0
294cdf0e10cSrcweir     //disabled for #i19718#
295cdf0e10cSrcweir 	case RTF_SHPRSLT:	// RTF_SHP fehlt noch !!
296cdf0e10cSrcweir #endif
297cdf0e10cSrcweir 							SkipGroup();
298cdf0e10cSrcweir 							break;
299cdf0e10cSrcweir 	// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 	case RTF_PGDSCNO:
302cdf0e10cSrcweir 	case RTF_PGBRK:
303cdf0e10cSrcweir 	case RTF_SHADOW:
304cdf0e10cSrcweir 			if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
305cdf0e10cSrcweir 				break;
306cdf0e10cSrcweir 			nToken = SkipToken( -1 );
307cdf0e10cSrcweir 			if( '{' == GetStackPtr( -1 )->nTokenId )
308cdf0e10cSrcweir 				nToken = SkipToken( -1 );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 			ReadAttr( nToken, &GetAttrSet() );
311cdf0e10cSrcweir 			break;
312cdf0e10cSrcweir 
313cdf0e10cSrcweir 	default:
314cdf0e10cSrcweir 		switch( nToken & ~(0xff | RTF_SWGDEFS) )
315cdf0e10cSrcweir 		{
316cdf0e10cSrcweir 		case RTF_PARFMT:		// hier gibts keine Swg-Defines
317cdf0e10cSrcweir 			ReadAttr( nToken, &GetAttrSet() );
318cdf0e10cSrcweir 			break;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 		case RTF_CHRFMT:
321cdf0e10cSrcweir 		case RTF_BRDRDEF:
322cdf0e10cSrcweir 		case RTF_TABSTOPDEF:
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 			if( RTF_SWGDEFS & nToken)
325cdf0e10cSrcweir 			{
326cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
327cdf0e10cSrcweir 					break;
328cdf0e10cSrcweir 				nToken = SkipToken( -1 );
329cdf0e10cSrcweir 				if( '{' == GetStackPtr( -1 )->nTokenId )
330cdf0e10cSrcweir 				{
331cdf0e10cSrcweir 					nToken = SkipToken( -1 );
332cdf0e10cSrcweir 				}
333cdf0e10cSrcweir 			}
334cdf0e10cSrcweir 			ReadAttr( nToken, &GetAttrSet() );
335cdf0e10cSrcweir 			break;
336cdf0e10cSrcweir 		default:
337cdf0e10cSrcweir 			{
338cdf0e10cSrcweir 				if( /*( '{' == GetStackPtr( -1 )->nTokenId ) ||*/
339cdf0e10cSrcweir 					( RTF_IGNOREFLAG == GetStackPtr( -1 )->nTokenId &&
340cdf0e10cSrcweir 					  '{' == GetStackPtr( -2 )->nTokenId ) )
341cdf0e10cSrcweir 					SkipGroup();
342cdf0e10cSrcweir 			}
343cdf0e10cSrcweir 			break;
344cdf0e10cSrcweir 		}
345cdf0e10cSrcweir 		break;
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
ReadStyleTable()349cdf0e10cSrcweir void SvxRTFParser::ReadStyleTable()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	int nToken, bSaveChkStyleAttr = bChkStyleAttr;
352cdf0e10cSrcweir 	short nStyleNo = 0;
353cdf0e10cSrcweir 	int _nOpenBrakets = 1;		// die erste wurde schon vorher erkannt !!
354cdf0e10cSrcweir 	SvxRTFStyleType* pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() );
355cdf0e10cSrcweir 	pStyle->aAttrSet.Put( GetRTFDefaults() );
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	bIsInReadStyleTab = sal_True;
358cdf0e10cSrcweir 	bChkStyleAttr = sal_False;		// Attribute nicht gegen die Styles checken
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	while( _nOpenBrakets && IsParserWorking() )
361cdf0e10cSrcweir 	{
362cdf0e10cSrcweir 		switch( nToken = GetNextToken() )
363cdf0e10cSrcweir 		{
364cdf0e10cSrcweir 		case '}':		if( --_nOpenBrakets && IsParserWorking() )
365cdf0e10cSrcweir 							// Style konnte vollstaendig gelesen werden,
366cdf0e10cSrcweir 							// also ist das noch ein stabiler Status
367cdf0e10cSrcweir 							SaveState( RTF_STYLESHEET );
368cdf0e10cSrcweir 						break;
369cdf0e10cSrcweir 		case '{':
370cdf0e10cSrcweir 			{
371cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetNextToken() )
372cdf0e10cSrcweir 					nToken = SkipToken( -1 );
373cdf0e10cSrcweir 				else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ) &&
374cdf0e10cSrcweir 							RTF_PN != nToken )
375cdf0e10cSrcweir 					nToken = SkipToken( -2 );
376cdf0e10cSrcweir 				else
377cdf0e10cSrcweir 				{
378cdf0e10cSrcweir 					// gleich herausfiltern
379cdf0e10cSrcweir 					ReadUnknownData();
380cdf0e10cSrcweir 					nToken = GetNextToken();
381cdf0e10cSrcweir 					if( '}' != nToken )
382cdf0e10cSrcweir 						eState = SVPAR_ERROR;
383cdf0e10cSrcweir 					break;
384cdf0e10cSrcweir 				}
385cdf0e10cSrcweir 				++_nOpenBrakets;
386cdf0e10cSrcweir 			}
387cdf0e10cSrcweir 			break;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 		case RTF_SBASEDON:	pStyle->nBasedOn = sal_uInt16(nTokenValue); pStyle->bBasedOnIsSet=sal_True;	break;
390cdf0e10cSrcweir 		case RTF_SNEXT:		pStyle->nNext = sal_uInt16(nTokenValue);   	break;
391cdf0e10cSrcweir 		case RTF_OUTLINELEVEL:
392cdf0e10cSrcweir 		case RTF_SOUTLVL:	pStyle->nOutlineNo = sal_uInt8(nTokenValue);	break;
393cdf0e10cSrcweir 		case RTF_S:			nStyleNo = (short)nTokenValue;			break;
394cdf0e10cSrcweir 		case RTF_CS:		nStyleNo = (short)nTokenValue;
395cdf0e10cSrcweir 							pStyle->bIsCharFmt = sal_True;
396cdf0e10cSrcweir 							break;
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 		case RTF_TEXTTOKEN:
399cdf0e10cSrcweir 			{
400cdf0e10cSrcweir 				pStyle->sName = DelCharAtEnd( aToken, ';' );
401cdf0e10cSrcweir 
402cdf0e10cSrcweir /*
403cdf0e10cSrcweir ??? soll man das umsetzen ???
404cdf0e10cSrcweir 				if( !pStyle->sName.Len() )
405cdf0e10cSrcweir 					pStyle->sName = "Standard";
406cdf0e10cSrcweir */
407cdf0e10cSrcweir 				// sollte die Nummer doppelt vergeben werden ?
408cdf0e10cSrcweir 				if( aStyleTbl.Count() )
409cdf0e10cSrcweir 				{
410cdf0e10cSrcweir 					SvxRTFStyleType* pOldSt = aStyleTbl.Remove( nStyleNo );
411cdf0e10cSrcweir 					if( pOldSt )
412cdf0e10cSrcweir 						delete pOldSt;
413cdf0e10cSrcweir 				}
414cdf0e10cSrcweir 				// alle Daten vom Style vorhanden, also ab in die Tabelle
415cdf0e10cSrcweir 				aStyleTbl.Insert( nStyleNo, pStyle );
416cdf0e10cSrcweir 				pStyle = new SvxRTFStyleType( *pAttrPool, aWhichMap.GetData() );
417cdf0e10cSrcweir 				pStyle->aAttrSet.Put( GetRTFDefaults() );
418cdf0e10cSrcweir 				nStyleNo = 0;
419cdf0e10cSrcweir 			}
420cdf0e10cSrcweir 			break;
421cdf0e10cSrcweir 		default:
422cdf0e10cSrcweir 			switch( nToken & ~(0xff | RTF_SWGDEFS) )
423cdf0e10cSrcweir 			{
424cdf0e10cSrcweir 			case RTF_PARFMT:		// hier gibts keine Swg-Defines
425cdf0e10cSrcweir 				ReadAttr( nToken, &pStyle->aAttrSet );
426cdf0e10cSrcweir 				break;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 			case RTF_CHRFMT:
429cdf0e10cSrcweir 			case RTF_BRDRDEF:
430cdf0e10cSrcweir 			case RTF_TABSTOPDEF:
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 				if( RTF_SWGDEFS & nToken)
433cdf0e10cSrcweir 				{
434cdf0e10cSrcweir 					if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
435cdf0e10cSrcweir 						break;
436cdf0e10cSrcweir 					nToken = SkipToken( -1 );
437cdf0e10cSrcweir 					if( '{' == GetStackPtr( -1 )->nTokenId )
438cdf0e10cSrcweir 					{
439cdf0e10cSrcweir 						nToken = SkipToken( -1 );
440cdf0e10cSrcweir #if 0
441cdf0e10cSrcweir 						--_nOpenBrakets;		// korrigieren!!
442cdf0e10cSrcweir #endif
443cdf0e10cSrcweir 					}
444cdf0e10cSrcweir 				}
445cdf0e10cSrcweir 				ReadAttr( nToken, &pStyle->aAttrSet );
446cdf0e10cSrcweir 				break;
447cdf0e10cSrcweir 			}
448cdf0e10cSrcweir 			break;
449cdf0e10cSrcweir 		}
450cdf0e10cSrcweir 	}
451cdf0e10cSrcweir 	delete pStyle;			// loesche das letze Style
452cdf0e10cSrcweir 	SkipToken( -1 );		// die schliesende Klammer wird "oben" ausgewertet
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	// Flag wieder auf alten Zustand
455cdf0e10cSrcweir 	bChkStyleAttr = bSaveChkStyleAttr;
456cdf0e10cSrcweir 	bIsInReadStyleTab = sal_False;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
ReadColorTable()459cdf0e10cSrcweir void SvxRTFParser::ReadColorTable()
460cdf0e10cSrcweir {
461cdf0e10cSrcweir 	int nToken;
462cdf0e10cSrcweir 	sal_uInt8 nRed = 0xff, nGreen = 0xff, nBlue = 0xff;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 	while( '}' != ( nToken = GetNextToken() ) && IsParserWorking() )
465cdf0e10cSrcweir 	{
466cdf0e10cSrcweir 		switch( nToken )
467cdf0e10cSrcweir 		{
468cdf0e10cSrcweir 		case RTF_RED:	nRed = sal_uInt8(nTokenValue);		break;
469cdf0e10cSrcweir 		case RTF_GREEN:	nGreen = sal_uInt8(nTokenValue);		break;
470cdf0e10cSrcweir 		case RTF_BLUE:	nBlue = sal_uInt8(nTokenValue);		break;
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 		case RTF_TEXTTOKEN:		// oder sollte irgendein Unsin darumstehen?
473cdf0e10cSrcweir 			if( 1 == aToken.Len()
474cdf0e10cSrcweir 					? aToken.GetChar( 0 ) != ';'
475cdf0e10cSrcweir 					: STRING_NOTFOUND == aToken.Search( ';' ) )
476cdf0e10cSrcweir 				break;		// es muss zumindestens das ';' gefunden werden
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 			// else kein break !!
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 		case ';':
481cdf0e10cSrcweir 			if( IsParserWorking() )
482cdf0e10cSrcweir 			{
483cdf0e10cSrcweir 				// eine Farbe ist Fertig, in die Tabelle eintragen
484cdf0e10cSrcweir 				// versuche die Werte auf SV interne Namen zu mappen
485cdf0e10cSrcweir 				ColorPtr pColor = new Color( nRed, nGreen, nBlue );
486cdf0e10cSrcweir 				if( aColorTbl.empty() &&
487cdf0e10cSrcweir 					sal_uInt8(-1) == nRed && sal_uInt8(-1) == nGreen && sal_uInt8(-1) == nBlue )
488cdf0e10cSrcweir 					pColor->SetColor( COL_AUTO );
489cdf0e10cSrcweir 				aColorTbl.push_back( pColor );
490cdf0e10cSrcweir 				nRed = 0, nGreen = 0, nBlue = 0;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 				// Color konnte vollstaendig gelesen werden,
493cdf0e10cSrcweir 				// also ist das noch ein stabiler Status
494cdf0e10cSrcweir 				SaveState( RTF_COLORTBL );
495cdf0e10cSrcweir 			}
496cdf0e10cSrcweir 			break;
497cdf0e10cSrcweir 		}
498cdf0e10cSrcweir 	}
499cdf0e10cSrcweir 	SkipToken( -1 );		// die schliesende Klammer wird "oben" ausgewertet
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
ReadFontTable()502cdf0e10cSrcweir void SvxRTFParser::ReadFontTable()
503cdf0e10cSrcweir {
504cdf0e10cSrcweir 	int nToken;
505cdf0e10cSrcweir 	int _nOpenBrakets = 1;		// die erste wurde schon vorher erkannt !!
506cdf0e10cSrcweir 	Font* pFont = new Font();
507cdf0e10cSrcweir 	short nFontNo(0), nInsFontNo (0);
508cdf0e10cSrcweir 	String sAltNm, sFntNm;
509cdf0e10cSrcweir 	sal_Bool bIsAltFntNm = sal_False, bCheckNewFont;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     CharSet nSystemChar = lcl_GetDefaultTextEncodingForRTF();
512cdf0e10cSrcweir     pFont->SetCharSet( nSystemChar );
513cdf0e10cSrcweir     SetEncoding( nSystemChar );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	while( _nOpenBrakets && IsParserWorking() )
516cdf0e10cSrcweir 	{
517cdf0e10cSrcweir 		bCheckNewFont = sal_False;
518cdf0e10cSrcweir 		switch( ( nToken = GetNextToken() ))
519cdf0e10cSrcweir 		{
520cdf0e10cSrcweir 		    case '}':
521cdf0e10cSrcweir 				bIsAltFntNm = sal_False;
522cdf0e10cSrcweir 				// Style konnte vollstaendig gelesen werden,
523cdf0e10cSrcweir 				// also ist das noch ein stabiler Status
524cdf0e10cSrcweir 				if( --_nOpenBrakets <= 1 && IsParserWorking() )
525cdf0e10cSrcweir 				    SaveState( RTF_FONTTBL );
526cdf0e10cSrcweir 				bCheckNewFont = sal_True;
527cdf0e10cSrcweir 				nInsFontNo = nFontNo;
528cdf0e10cSrcweir 				break;
529cdf0e10cSrcweir 		    case '{':
530cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetNextToken() )
531cdf0e10cSrcweir 					nToken = SkipToken( -1 );
532cdf0e10cSrcweir 				// Unknown und alle bekannten nicht ausgewerteten Gruppen
533cdf0e10cSrcweir 				// sofort ueberspringen
534cdf0e10cSrcweir 				else if( RTF_UNKNOWNCONTROL != ( nToken = GetNextToken() ) &&
535cdf0e10cSrcweir 						RTF_PANOSE != nToken && RTF_FNAME != nToken &&
536cdf0e10cSrcweir 						RTF_FONTEMB != nToken && RTF_FONTFILE != nToken )
537cdf0e10cSrcweir 					nToken = SkipToken( -2 );
538cdf0e10cSrcweir 				else
539cdf0e10cSrcweir 				{
540cdf0e10cSrcweir 					// gleich herausfiltern
541cdf0e10cSrcweir 					ReadUnknownData();
542cdf0e10cSrcweir 					nToken = GetNextToken();
543cdf0e10cSrcweir 					if( '}' != nToken )
544cdf0e10cSrcweir 						eState = SVPAR_ERROR;
545cdf0e10cSrcweir 					break;
546cdf0e10cSrcweir 				}
547cdf0e10cSrcweir 				++_nOpenBrakets;
548cdf0e10cSrcweir 			    break;
549cdf0e10cSrcweir 		    case RTF_FROMAN:
550cdf0e10cSrcweir                 pFont->SetFamily( FAMILY_ROMAN );
551cdf0e10cSrcweir                 break;
552cdf0e10cSrcweir 		    case RTF_FSWISS:
553cdf0e10cSrcweir                 pFont->SetFamily( FAMILY_SWISS );
554cdf0e10cSrcweir                 break;
555cdf0e10cSrcweir 		    case RTF_FMODERN:
556cdf0e10cSrcweir                 pFont->SetFamily( FAMILY_MODERN );
557cdf0e10cSrcweir                 break;
558cdf0e10cSrcweir 		    case RTF_FSCRIPT:
559cdf0e10cSrcweir                 pFont->SetFamily( FAMILY_SCRIPT );
560cdf0e10cSrcweir                 break;
561cdf0e10cSrcweir 		    case RTF_FDECOR:
562cdf0e10cSrcweir                 pFont->SetFamily( FAMILY_DECORATIVE );
563cdf0e10cSrcweir                 break;
564cdf0e10cSrcweir 		    // bei technischen/symbolischen Font wird der CharSet ungeschaltet!!
565cdf0e10cSrcweir 		    case RTF_FTECH:
566cdf0e10cSrcweir                 pFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
567cdf0e10cSrcweir                 // deliberate fall through
568cdf0e10cSrcweir 		    case RTF_FNIL:
569cdf0e10cSrcweir                 pFont->SetFamily( FAMILY_DONTKNOW );
570cdf0e10cSrcweir                 break;
571cdf0e10cSrcweir 		    case RTF_FCHARSET:
572cdf0e10cSrcweir 			    if (-1 != nTokenValue)
573cdf0e10cSrcweir                 {
574cdf0e10cSrcweir                     CharSet nCharSet = rtl_getTextEncodingFromWindowsCharset(
575cdf0e10cSrcweir                         (sal_uInt8)nTokenValue);
576cdf0e10cSrcweir 				    pFont->SetCharSet(nCharSet);
577cdf0e10cSrcweir                     //When we're in a font, the fontname is in the font
578cdf0e10cSrcweir                     //charset, except for symbol fonts I believe
579cdf0e10cSrcweir                     if (nCharSet == RTL_TEXTENCODING_SYMBOL)
580cdf0e10cSrcweir                         nCharSet = RTL_TEXTENCODING_DONTKNOW;
581cdf0e10cSrcweir                     SetEncoding(nCharSet);
582cdf0e10cSrcweir                 }
583cdf0e10cSrcweir 			    break;
584cdf0e10cSrcweir 		    case RTF_FPRQ:
585cdf0e10cSrcweir 			    switch( nTokenValue )
586cdf0e10cSrcweir 			    {
587cdf0e10cSrcweir 			        case 1:
588cdf0e10cSrcweir                         pFont->SetPitch( PITCH_FIXED );
589cdf0e10cSrcweir                         break;
590cdf0e10cSrcweir 			        case 2:
591cdf0e10cSrcweir                         pFont->SetPitch( PITCH_VARIABLE );
592cdf0e10cSrcweir                         break;
593cdf0e10cSrcweir 			    }
594cdf0e10cSrcweir 			    break;
595cdf0e10cSrcweir 		    case RTF_F:
596cdf0e10cSrcweir 			    bCheckNewFont = sal_True;
597cdf0e10cSrcweir 			    nInsFontNo = nFontNo;
598cdf0e10cSrcweir 			    nFontNo = (short)nTokenValue;
599cdf0e10cSrcweir 			    break;
600cdf0e10cSrcweir 		    case RTF_FALT:
601cdf0e10cSrcweir                 bIsAltFntNm = sal_True;
602cdf0e10cSrcweir                 break;
603cdf0e10cSrcweir 		    case RTF_TEXTTOKEN:
604cdf0e10cSrcweir 				DelCharAtEnd( aToken, ';' );
605cdf0e10cSrcweir 				if ( aToken.Len() )
606cdf0e10cSrcweir 				{
607cdf0e10cSrcweir 					if( bIsAltFntNm )
608cdf0e10cSrcweir 						sAltNm = aToken;
609cdf0e10cSrcweir 					else
610cdf0e10cSrcweir 						sFntNm = aToken;
611cdf0e10cSrcweir 				}
612cdf0e10cSrcweir 			    break;
613cdf0e10cSrcweir 		}
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 		if( bCheckNewFont && 1 >= _nOpenBrakets && sFntNm.Len() )  // one font is ready
616cdf0e10cSrcweir 		{
617cdf0e10cSrcweir 			// alle Daten vom Font vorhanden, also ab in die Tabelle
618cdf0e10cSrcweir 			if (sAltNm.Len())
619cdf0e10cSrcweir 				(sFntNm += ';' ) += sAltNm;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 			pFont->SetName( sFntNm );
622cdf0e10cSrcweir 			aFontTbl.Insert( nInsFontNo, pFont );
623cdf0e10cSrcweir 			pFont = new Font();
624cdf0e10cSrcweir 			pFont->SetCharSet( nSystemChar );
625cdf0e10cSrcweir 			sAltNm.Erase();
626cdf0e10cSrcweir 			sFntNm.Erase();
627cdf0e10cSrcweir 		}
628cdf0e10cSrcweir 	}
629cdf0e10cSrcweir 	// den letzen muessen wir selbst loeschen
630cdf0e10cSrcweir 	delete pFont;
631cdf0e10cSrcweir 	SkipToken( -1 );		// die schliesende Klammer wird "oben" ausgewertet
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 	// setze den default Font am Doc
634cdf0e10cSrcweir 	if( bNewDoc && IsParserWorking() )
635cdf0e10cSrcweir 		SetDefault( RTF_DEFF, nDfltFont );
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
ReadBitmapData()638cdf0e10cSrcweir void SvxRTFParser::ReadBitmapData()
639cdf0e10cSrcweir {
640cdf0e10cSrcweir 	SvRTFParser::ReadBitmapData();
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
ReadOLEData()643cdf0e10cSrcweir void SvxRTFParser::ReadOLEData()
644cdf0e10cSrcweir {
645cdf0e10cSrcweir 	SvRTFParser::ReadOLEData();
646cdf0e10cSrcweir }
647cdf0e10cSrcweir 
GetTextToEndGroup(String & rStr)648cdf0e10cSrcweir String& SvxRTFParser::GetTextToEndGroup( String& rStr )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir 	rStr.Erase( 0 );
651cdf0e10cSrcweir 	int _nOpenBrakets = 1, nToken;		// die erste wurde schon vorher erkannt !!
652cdf0e10cSrcweir 
653cdf0e10cSrcweir 	while( _nOpenBrakets && IsParserWorking() )
654cdf0e10cSrcweir 	{
655cdf0e10cSrcweir 		switch( nToken = GetNextToken() )
656cdf0e10cSrcweir 		{
657cdf0e10cSrcweir 		case '}':		--_nOpenBrakets;	break;
658cdf0e10cSrcweir 		case '{':
659cdf0e10cSrcweir 			{
660cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetNextToken() )
661cdf0e10cSrcweir 					nToken = SkipToken( -1 );
662cdf0e10cSrcweir 				else if( RTF_UNKNOWNCONTROL != GetNextToken() )
663cdf0e10cSrcweir 					nToken = SkipToken( -2 );
664cdf0e10cSrcweir 				else
665cdf0e10cSrcweir 				{
666cdf0e10cSrcweir 					// gleich herausfiltern
667cdf0e10cSrcweir 					ReadUnknownData();
668cdf0e10cSrcweir 					nToken = GetNextToken();
669cdf0e10cSrcweir 					if( '}' != nToken )
670cdf0e10cSrcweir 						eState = SVPAR_ERROR;
671cdf0e10cSrcweir 					break;
672cdf0e10cSrcweir 				}
673cdf0e10cSrcweir 				++_nOpenBrakets;
674cdf0e10cSrcweir 			}
675cdf0e10cSrcweir 			break;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 		case RTF_TEXTTOKEN:
678cdf0e10cSrcweir 			rStr += aToken;
679cdf0e10cSrcweir 			break;
680cdf0e10cSrcweir 		}
681cdf0e10cSrcweir 	}
682cdf0e10cSrcweir 	SkipToken( -1 );		// die schliesende Klammer wird "oben" ausgewertet
683cdf0e10cSrcweir 	return rStr;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir 
GetDateTimeStamp()686cdf0e10cSrcweir util::DateTime SvxRTFParser::GetDateTimeStamp( )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir 	util::DateTime aDT;
689cdf0e10cSrcweir 	sal_Bool bWeiter = sal_True;
690cdf0e10cSrcweir 	int nToken;
691cdf0e10cSrcweir 	while( bWeiter && IsParserWorking() )
692cdf0e10cSrcweir 	{
693cdf0e10cSrcweir 		switch( nToken = GetNextToken() )
694cdf0e10cSrcweir 		{
695cdf0e10cSrcweir 		case RTF_YR:	aDT.Year = (sal_uInt16)nTokenValue;	    break;
696cdf0e10cSrcweir 		case RTF_MO:    aDT.Month = (sal_uInt16)nTokenValue;	break;
697cdf0e10cSrcweir 		case RTF_DY:	aDT.Day = (sal_uInt16)nTokenValue;	    break;
698cdf0e10cSrcweir 		case RTF_HR:	aDT.Hours = (sal_uInt16)nTokenValue;	break;
699cdf0e10cSrcweir 		case RTF_MIN:	aDT.Minutes = (sal_uInt16)nTokenValue;	break;
700cdf0e10cSrcweir 		default:
701cdf0e10cSrcweir 			bWeiter = sal_False;
702cdf0e10cSrcweir 		}
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 	SkipToken( -1 );		// die schliesende Klammer wird "oben" ausgewertet
705cdf0e10cSrcweir 	return aDT;
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
ReadInfo(const sal_Char * pChkForVerNo)708cdf0e10cSrcweir void SvxRTFParser::ReadInfo( const sal_Char* pChkForVerNo )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir #ifndef SVX_LIGHT
711cdf0e10cSrcweir 	int _nOpenBrakets = 1, nToken;		// die erste wurde schon vorher erkannt !!
712cdf0e10cSrcweir     DBG_ASSERT(m_xDocProps.is(),
713cdf0e10cSrcweir         "SvxRTFParser::ReadInfo: no DocumentProperties");
714cdf0e10cSrcweir 	String sStr, sComment;
715cdf0e10cSrcweir 	long nVersNo = 0;
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 	while( _nOpenBrakets && IsParserWorking() )
718cdf0e10cSrcweir 	{
719cdf0e10cSrcweir 		switch( nToken = GetNextToken() )
720cdf0e10cSrcweir 		{
721cdf0e10cSrcweir 		case '}':		--_nOpenBrakets;	break;
722cdf0e10cSrcweir 		case '{':
723cdf0e10cSrcweir 			{
724cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetNextToken() )
725cdf0e10cSrcweir 					nToken = SkipToken( -1 );
726cdf0e10cSrcweir 				else if( RTF_UNKNOWNCONTROL != GetNextToken() )
727cdf0e10cSrcweir 					nToken = SkipToken( -2 );
728cdf0e10cSrcweir 				else
729cdf0e10cSrcweir 				{
730cdf0e10cSrcweir 					// gleich herausfiltern
731cdf0e10cSrcweir 					ReadUnknownData();
732cdf0e10cSrcweir 					nToken = GetNextToken();
733cdf0e10cSrcweir 					if( '}' != nToken )
734cdf0e10cSrcweir 						eState = SVPAR_ERROR;
735cdf0e10cSrcweir 					break;
736cdf0e10cSrcweir 				}
737cdf0e10cSrcweir 				++_nOpenBrakets;
738cdf0e10cSrcweir 			}
739cdf0e10cSrcweir 			break;
740cdf0e10cSrcweir 
741cdf0e10cSrcweir 		case RTF_TITLE:
742cdf0e10cSrcweir 			m_xDocProps->setTitle( GetTextToEndGroup( sStr ) );
743cdf0e10cSrcweir 			break;
744cdf0e10cSrcweir 		case RTF_SUBJECT:
745cdf0e10cSrcweir 			m_xDocProps->setSubject( GetTextToEndGroup( sStr ) );
746cdf0e10cSrcweir 			break;
747cdf0e10cSrcweir 		case RTF_AUTHOR:
748cdf0e10cSrcweir 			m_xDocProps->setAuthor( GetTextToEndGroup( sStr ) );
749cdf0e10cSrcweir 			break;
750cdf0e10cSrcweir 		case RTF_OPERATOR:
751cdf0e10cSrcweir 			m_xDocProps->setModifiedBy( GetTextToEndGroup( sStr ) );
752cdf0e10cSrcweir 			break;
753cdf0e10cSrcweir 		case RTF_KEYWORDS:
754cdf0e10cSrcweir             {
755cdf0e10cSrcweir                 ::rtl::OUString sTemp = GetTextToEndGroup( sStr );
756cdf0e10cSrcweir                 m_xDocProps->setKeywords(
757cdf0e10cSrcweir                     ::comphelper::string::convertCommaSeparated(sTemp) );
758cdf0e10cSrcweir                 break;
759cdf0e10cSrcweir             }
760cdf0e10cSrcweir 		case RTF_DOCCOMM:
761cdf0e10cSrcweir 			m_xDocProps->setDescription( GetTextToEndGroup( sStr ) );
762cdf0e10cSrcweir 			break;
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 		case RTF_HLINKBASE:
765cdf0e10cSrcweir 			sBaseURL = GetTextToEndGroup( sStr ) ;
766cdf0e10cSrcweir 			break;
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 		case RTF_CREATIM:
769cdf0e10cSrcweir 			m_xDocProps->setCreationDate( GetDateTimeStamp() );
770cdf0e10cSrcweir 			break;
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 		case RTF_REVTIM:
773cdf0e10cSrcweir 			m_xDocProps->setModificationDate( GetDateTimeStamp() );
774cdf0e10cSrcweir 			break;
775cdf0e10cSrcweir 
776cdf0e10cSrcweir 		case RTF_PRINTIM:
777cdf0e10cSrcweir 			m_xDocProps->setPrintDate( GetDateTimeStamp() );
778cdf0e10cSrcweir 			break;
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 		case RTF_COMMENT:
781cdf0e10cSrcweir 			GetTextToEndGroup( sComment );
782cdf0e10cSrcweir 			break;
783cdf0e10cSrcweir 
784cdf0e10cSrcweir 		case RTF_BUPTIM:
785cdf0e10cSrcweir 			SkipGroup();
786cdf0e10cSrcweir 			break;
787cdf0e10cSrcweir 
788cdf0e10cSrcweir 		case RTF_VERN:
789cdf0e10cSrcweir 			nVersNo = nTokenValue;
790cdf0e10cSrcweir 			break;
791cdf0e10cSrcweir 
792cdf0e10cSrcweir 		case RTF_EDMINS:
793cdf0e10cSrcweir 		case RTF_ID:
794cdf0e10cSrcweir 		case RTF_VERSION:
795cdf0e10cSrcweir 		case RTF_NOFPAGES:
796cdf0e10cSrcweir 		case RTF_NOFWORDS:
797cdf0e10cSrcweir 		case RTF_NOFCHARS:
798cdf0e10cSrcweir 			NextToken( nToken );
799cdf0e10cSrcweir 			break;
800cdf0e10cSrcweir 
801cdf0e10cSrcweir //		default:
802cdf0e10cSrcweir 		}
803cdf0e10cSrcweir 	}
804cdf0e10cSrcweir 
805cdf0e10cSrcweir 	if( pChkForVerNo &&
806cdf0e10cSrcweir 		COMPARE_EQUAL == sComment.CompareToAscii( pChkForVerNo ))
807cdf0e10cSrcweir 		nVersionNo = nVersNo;
808cdf0e10cSrcweir 
809cdf0e10cSrcweir 	SkipToken( -1 );		// die schliesende Klammer wird "oben" ausgewertet
810cdf0e10cSrcweir #endif
811cdf0e10cSrcweir }
812cdf0e10cSrcweir 
813cdf0e10cSrcweir 
ClearColorTbl()814cdf0e10cSrcweir void SvxRTFParser::ClearColorTbl()
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	while ( !aColorTbl.empty() )
817cdf0e10cSrcweir     {
818cdf0e10cSrcweir 		delete aColorTbl.back();
819cdf0e10cSrcweir     	aColorTbl.pop_back();
820cdf0e10cSrcweir     }
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
ClearFontTbl()823cdf0e10cSrcweir void SvxRTFParser::ClearFontTbl()
824cdf0e10cSrcweir {
825cdf0e10cSrcweir 	for( sal_uInt32 nCnt = aFontTbl.Count(); nCnt; )
826cdf0e10cSrcweir 		delete aFontTbl.GetObject( --nCnt );
827*b264d727SArmin Le Grand     aFontTbl.Clear();
828cdf0e10cSrcweir }
829cdf0e10cSrcweir 
ClearStyleTbl()830cdf0e10cSrcweir void SvxRTFParser::ClearStyleTbl()
831cdf0e10cSrcweir {
832cdf0e10cSrcweir 	for( sal_uInt32 nCnt = aStyleTbl.Count(); nCnt; )
833cdf0e10cSrcweir 		delete aStyleTbl.GetObject( --nCnt );
834*b264d727SArmin Le Grand     aStyleTbl.Clear();
835cdf0e10cSrcweir }
836cdf0e10cSrcweir 
ClearAttrStack()837cdf0e10cSrcweir void SvxRTFParser::ClearAttrStack()
838cdf0e10cSrcweir {
839cdf0e10cSrcweir 	SvxRTFItemStackType* pTmp;
840cdf0e10cSrcweir 	for( size_t nCnt = aAttrStack.size(); nCnt; --nCnt )
841cdf0e10cSrcweir 	{
842cdf0e10cSrcweir 		pTmp = aAttrStack.back();
843cdf0e10cSrcweir 		aAttrStack.pop_back();
844cdf0e10cSrcweir 		delete pTmp;
845cdf0e10cSrcweir 	}
846cdf0e10cSrcweir }
847cdf0e10cSrcweir 
DelCharAtEnd(String & rStr,const sal_Unicode cDel)848cdf0e10cSrcweir String& SvxRTFParser::DelCharAtEnd( String& rStr, const sal_Unicode cDel )
849cdf0e10cSrcweir {
850cdf0e10cSrcweir 	if( rStr.Len() && ' ' == rStr.GetChar( 0 ))
851cdf0e10cSrcweir 		rStr.EraseLeadingChars();
852cdf0e10cSrcweir 	if( rStr.Len() && ' ' == rStr.GetChar( rStr.Len()-1 ))
853cdf0e10cSrcweir 		rStr.EraseTrailingChars();
854cdf0e10cSrcweir 	if( rStr.Len() && cDel == rStr.GetChar( rStr.Len()-1 ))
855cdf0e10cSrcweir 		rStr.Erase( rStr.Len()-1 );
856cdf0e10cSrcweir 	return rStr;
857cdf0e10cSrcweir }
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 
GetFont(sal_uInt16 nId)860cdf0e10cSrcweir const Font& SvxRTFParser::GetFont( sal_uInt16 nId )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir 	const Font* pFont = aFontTbl.Get( nId );
863cdf0e10cSrcweir 	if( !pFont )
864cdf0e10cSrcweir 	{
865cdf0e10cSrcweir         const SvxFontItem& rDfltFont = (const SvxFontItem&)
866cdf0e10cSrcweir                         pAttrPool->GetDefaultItem(
867cdf0e10cSrcweir                     ((RTFPlainAttrMapIds*)aPlainMap.GetData())->nFont );
868cdf0e10cSrcweir         pDfltFont->SetName( rDfltFont.GetStyleName() );
869cdf0e10cSrcweir         pDfltFont->SetFamily( rDfltFont.GetFamily() );
870cdf0e10cSrcweir 		pFont = pDfltFont;
871cdf0e10cSrcweir 	}
872cdf0e10cSrcweir 	return *pFont;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir 
_GetAttrSet(int bCopyAttr)875cdf0e10cSrcweir SvxRTFItemStackType* SvxRTFParser::_GetAttrSet( int bCopyAttr )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir     SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
878cdf0e10cSrcweir 	SvxRTFItemStackType* pNew;
879cdf0e10cSrcweir 	if( pAkt )
880cdf0e10cSrcweir 		pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, bCopyAttr );
881cdf0e10cSrcweir 	else
882cdf0e10cSrcweir 		pNew = new SvxRTFItemStackType( *pAttrPool, aWhichMap.GetData(),
883cdf0e10cSrcweir 										*pInsPos );
884cdf0e10cSrcweir 	pNew->SetRTFDefaults( GetRTFDefaults() );
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 	aAttrStack.push_back( pNew );
887cdf0e10cSrcweir 	bNewGroup = sal_False;
888cdf0e10cSrcweir 	return pNew;
889cdf0e10cSrcweir }
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 
_ClearStyleAttr(SvxRTFItemStackType & rStkType)892cdf0e10cSrcweir void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir 	// check attributes to the attributes of the stylesheet or to
895cdf0e10cSrcweir 	// the default attrs of the document
896cdf0e10cSrcweir 	SfxItemSet &rSet = rStkType.GetAttrSet();
897cdf0e10cSrcweir 	const SfxItemPool& rPool = *rSet.GetPool();
898cdf0e10cSrcweir 	const SfxPoolItem* pItem;
899cdf0e10cSrcweir 	SfxWhichIter aIter( rSet );
900cdf0e10cSrcweir 
901cdf0e10cSrcweir 	SvxRTFStyleType* pStyle;
902cdf0e10cSrcweir 	if( !IsChkStyleAttr() ||
903cdf0e10cSrcweir 		!rStkType.GetAttrSet().Count() ||
904cdf0e10cSrcweir 		0 == ( pStyle = aStyleTbl.Get( rStkType.nStyleNo ) ))
905cdf0e10cSrcweir 	{
906cdf0e10cSrcweir 		for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
907cdf0e10cSrcweir 		{
908cdf0e10cSrcweir 			if( SFX_WHICH_MAX > nWhich &&
909cdf0e10cSrcweir 				SFX_ITEM_SET == rSet.GetItemState( nWhich, sal_False, &pItem ) &&
910cdf0e10cSrcweir 					 rPool.GetDefaultItem( nWhich ) == *pItem )
911cdf0e10cSrcweir 				rSet.ClearItem( nWhich );		// loeschen
912cdf0e10cSrcweir 		}
913cdf0e10cSrcweir 	}
914cdf0e10cSrcweir 	else
915cdf0e10cSrcweir 	{
916cdf0e10cSrcweir 		// alle Attribute, die schon vom Style definiert sind, aus dem
917cdf0e10cSrcweir 		// akt. AttrSet entfernen
918cdf0e10cSrcweir 		SfxItemSet &rStyleSet = pStyle->aAttrSet;
919cdf0e10cSrcweir 		const SfxPoolItem* pSItem;
920cdf0e10cSrcweir 		for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() )
921cdf0e10cSrcweir 		{
922cdf0e10cSrcweir 			if( SFX_ITEM_SET == rStyleSet.GetItemState( nWhich, sal_True, &pSItem ))
923cdf0e10cSrcweir 			{
924cdf0e10cSrcweir 				// JP 22.06.99: im Style und im Set gleich gesetzt -> loeschen
925cdf0e10cSrcweir 				if( SFX_ITEM_SET == rSet.GetItemState( nWhich, sal_False, &pItem )
926cdf0e10cSrcweir 					&& *pItem == *pSItem )
927cdf0e10cSrcweir 					rSet.ClearItem( nWhich );		// loeschen
928cdf0e10cSrcweir 			}
929cdf0e10cSrcweir 				// Bug 59571 - falls nicht im Style gesetzt und gleich mit
930cdf0e10cSrcweir 				// 				dem PoolDefault -> auch dann loeschen
931cdf0e10cSrcweir 			else if( SFX_WHICH_MAX > nWhich &&
932cdf0e10cSrcweir 					SFX_ITEM_SET == rSet.GetItemState( nWhich, sal_False, &pItem ) &&
933cdf0e10cSrcweir 					 rPool.GetDefaultItem( nWhich ) == *pItem )
934cdf0e10cSrcweir 				rSet.ClearItem( nWhich );		// loeschen
935cdf0e10cSrcweir 		}
936cdf0e10cSrcweir 	}
937cdf0e10cSrcweir }
938cdf0e10cSrcweir 
AttrGroupEnd()939cdf0e10cSrcweir void SvxRTFParser::AttrGroupEnd()	// den akt. Bearbeiten, vom Stack loeschen
940cdf0e10cSrcweir {
941cdf0e10cSrcweir 	if( !aAttrStack.empty() )
942cdf0e10cSrcweir 	{
943cdf0e10cSrcweir         SvxRTFItemStackType *pOld = aAttrStack.empty() ? 0 : aAttrStack.back();
944cdf0e10cSrcweir 		aAttrStack.pop_back();
945cdf0e10cSrcweir 		SvxRTFItemStackType *pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 		do {		// middle check loop
948cdf0e10cSrcweir 			sal_uLong nOldSttNdIdx = pOld->pSttNd->GetIdx();
949cdf0e10cSrcweir 			if( !pOld->pChildList &&
950cdf0e10cSrcweir 				((!pOld->aAttrSet.Count() && !pOld->nStyleNo ) ||
951cdf0e10cSrcweir 				(nOldSttNdIdx == pInsPos->GetNodeIdx() &&
952cdf0e10cSrcweir 				pOld->nSttCnt == pInsPos->GetCntIdx() )))
953cdf0e10cSrcweir 				break;			// keine Attribute oder Bereich
954cdf0e10cSrcweir 
955cdf0e10cSrcweir 			// setze nur die Attribute, die unterschiedlich zum Parent sind
956cdf0e10cSrcweir 			if( pAkt && pOld->aAttrSet.Count() )
957cdf0e10cSrcweir 			{
958cdf0e10cSrcweir 				SfxItemIter aIter( pOld->aAttrSet );
959cdf0e10cSrcweir 				const SfxPoolItem* pItem = aIter.GetCurItem(), *pGet;
960cdf0e10cSrcweir 				while( sal_True )
961cdf0e10cSrcweir 				{
962cdf0e10cSrcweir 					if( SFX_ITEM_SET == pAkt->aAttrSet.GetItemState(
963cdf0e10cSrcweir 						pItem->Which(), sal_False, &pGet ) &&
964cdf0e10cSrcweir 						*pItem == *pGet )
965cdf0e10cSrcweir 						pOld->aAttrSet.ClearItem( pItem->Which() );
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 					if( aIter.IsAtEnd() )
968cdf0e10cSrcweir 						break;
969cdf0e10cSrcweir 					pItem = aIter.NextItem();
970cdf0e10cSrcweir 				}
971cdf0e10cSrcweir 
972cdf0e10cSrcweir 				if( !pOld->aAttrSet.Count() && !pOld->pChildList &&
973cdf0e10cSrcweir 					!pOld->nStyleNo )
974cdf0e10cSrcweir 					break;
975cdf0e10cSrcweir 			}
976cdf0e10cSrcweir 
977cdf0e10cSrcweir 			// setze alle Attribute, die von Start bis hier
978cdf0e10cSrcweir 			// definiert sind.
979cdf0e10cSrcweir 			int bCrsrBack = !pInsPos->GetCntIdx();
980cdf0e10cSrcweir 			if( bCrsrBack )
981cdf0e10cSrcweir 			{
982cdf0e10cSrcweir 				// am Absatzanfang ? eine Position zurueck
983cdf0e10cSrcweir 				sal_uLong nNd = pInsPos->GetNodeIdx();
984cdf0e10cSrcweir 				MovePos( sal_False );
985cdf0e10cSrcweir 				// if can not move backward then later dont move forward !
986cdf0e10cSrcweir 				bCrsrBack = nNd != pInsPos->GetNodeIdx();
987cdf0e10cSrcweir 			}
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 			//Bug #46608#: ungueltige Bereiche ignorieren!
990cdf0e10cSrcweir 			if( ( pOld->pSttNd->GetIdx() < pInsPos->GetNodeIdx() ||
991cdf0e10cSrcweir 				( pOld->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
992cdf0e10cSrcweir 				pOld->nSttCnt <= pInsPos->GetCntIdx() ))
993cdf0e10cSrcweir #if 0
994cdf0e10cSrcweir //BUG 68555 - dont test for empty paragraph or any range
995cdf0e10cSrcweir 				&& ( nOldSttNdIdx != pInsPos->GetNodeIdx() ||
996cdf0e10cSrcweir 				pOld->nSttCnt != pInsPos->GetCntIdx() ||
997cdf0e10cSrcweir 				!pOld->nSttCnt )
998cdf0e10cSrcweir #endif
999cdf0e10cSrcweir 				)
1000cdf0e10cSrcweir 			{
1001cdf0e10cSrcweir 				if( !bCrsrBack )
1002cdf0e10cSrcweir 				{
1003cdf0e10cSrcweir 					// alle pard-Attribute gelten nur bis zum vorherigen
1004cdf0e10cSrcweir 					// Absatz !!
1005cdf0e10cSrcweir 					if( nOldSttNdIdx == pInsPos->GetNodeIdx() )
1006cdf0e10cSrcweir 					{
1007cdf0e10cSrcweir #if 0
1008cdf0e10cSrcweir //BUG 68555 - dont reset pard attrs, if the group not begins not at start of
1009cdf0e10cSrcweir //				paragraph
1010cdf0e10cSrcweir 						// Bereich innerhalb eines Absatzes:
1011cdf0e10cSrcweir 						// alle Absatz-Attribute und StyleNo loeschen
1012cdf0e10cSrcweir 						// aber nur wenn mitten drin angefangen wurde
1013cdf0e10cSrcweir 						if( pOld->nSttCnt )
1014cdf0e10cSrcweir 						{
1015cdf0e10cSrcweir 							pOld->nStyleNo = 0;
1016cdf0e10cSrcweir 							for( sal_uInt16 n = 0; n < aPardMap.Count() &&
1017cdf0e10cSrcweir 												pOld->aAttrSet.Count(); ++n )
1018cdf0e10cSrcweir 								if( aPardMap[n] )
1019cdf0e10cSrcweir 									pOld->aAttrSet.ClearItem( aPardMap[n] );
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 							if( !pOld->aAttrSet.Count() && !pOld->pChildList &&
1022cdf0e10cSrcweir 								!pOld->nStyleNo  )
1023cdf0e10cSrcweir 								break;	// auch dieser verlaesst uns jetzt
1024cdf0e10cSrcweir 						}
1025cdf0e10cSrcweir #endif
1026cdf0e10cSrcweir 					}
1027cdf0e10cSrcweir 					else
1028cdf0e10cSrcweir 					{
1029cdf0e10cSrcweir 						// jetzt wirds kompliziert:
1030cdf0e10cSrcweir 						// - alle Zeichen-Attribute behalten den Bereich,
1031cdf0e10cSrcweir 						// - alle Absatz-Attribute bekommen den Bereich
1032cdf0e10cSrcweir 						// 			bis zum vorherigen Absatz
1033cdf0e10cSrcweir 						SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
1034cdf0e10cSrcweir 									*pOld, *pInsPos, sal_True );
1035cdf0e10cSrcweir 						pNew->aAttrSet.SetParent( pOld->aAttrSet.GetParent() );
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 						// loesche aus pNew alle Absatz Attribute
1038cdf0e10cSrcweir 						for( sal_uInt16 n = 0; n < aPardMap.Count() &&
1039cdf0e10cSrcweir 											pNew->aAttrSet.Count(); ++n )
1040cdf0e10cSrcweir 							if( aPardMap[n] )
1041cdf0e10cSrcweir 								pNew->aAttrSet.ClearItem( aPardMap[n] );
1042cdf0e10cSrcweir 						pNew->SetRTFDefaults( GetRTFDefaults() );
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 						// gab es ueberhaupt welche ?
1045cdf0e10cSrcweir 						if( pNew->aAttrSet.Count() == pOld->aAttrSet.Count() )
1046cdf0e10cSrcweir 							delete pNew;		// das wars dann
1047cdf0e10cSrcweir 						else
1048cdf0e10cSrcweir 						{
1049cdf0e10cSrcweir 							pNew->nStyleNo = 0;
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir 							// spanne jetzt den richtigen Bereich auf
1052cdf0e10cSrcweir 							// pNew von alter
1053cdf0e10cSrcweir 							SetEndPrevPara( pOld->pEndNd, pOld->nEndCnt );
1054cdf0e10cSrcweir 							pNew->nSttCnt = 0;
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 							if( IsChkStyleAttr() )
1057cdf0e10cSrcweir                             {
1058cdf0e10cSrcweir 								_ClearStyleAttr( *pOld );
1059cdf0e10cSrcweir                                 _ClearStyleAttr( *pNew );   //#i10381#, methinks.
1060cdf0e10cSrcweir                             }
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir 							if( pAkt )
1063cdf0e10cSrcweir 							{
1064cdf0e10cSrcweir 								pAkt->Add( pOld );
1065cdf0e10cSrcweir 								pAkt->Add( pNew );
1066cdf0e10cSrcweir 							}
1067cdf0e10cSrcweir 							else
1068cdf0e10cSrcweir 							{
1069cdf0e10cSrcweir 								// letzter vom Stack, also zwischenspeichern, bis der
1070cdf0e10cSrcweir 								// naechste Text eingelesen wurde. (keine Attribute
1071cdf0e10cSrcweir 								// aufspannen!!)
1072cdf0e10cSrcweir 								aAttrSetList.Insert( pOld, aAttrSetList.Count() );
1073cdf0e10cSrcweir 								aAttrSetList.Insert( pNew, aAttrSetList.Count() );
1074cdf0e10cSrcweir 							}
1075cdf0e10cSrcweir 							pOld = 0;	// pOld nicht loeschen
1076cdf0e10cSrcweir 							break;		// das wars !!
1077cdf0e10cSrcweir 						}
1078cdf0e10cSrcweir 					}
1079cdf0e10cSrcweir 				}
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir 				pOld->pEndNd = pInsPos->MakeNodeIdx();
1082cdf0e10cSrcweir 				pOld->nEndCnt = pInsPos->GetCntIdx();
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir #if 0
1085cdf0e10cSrcweir 				if( IsChkStyleAttr() )
1086cdf0e10cSrcweir 					_ClearStyleAttr( *pOld );
1087cdf0e10cSrcweir #else
1088cdf0e10cSrcweir                 /*
1089cdf0e10cSrcweir                 #i21422#
1090cdf0e10cSrcweir                 If the parent (pAkt) sets something e.g. , and the child (pOld)
1091cdf0e10cSrcweir                 unsets it and the style both are based on has it unset then
1092cdf0e10cSrcweir                 clearing the pOld by looking at the style is clearly a disaster
1093cdf0e10cSrcweir                 as the text ends up with pAkts bold and not pOlds no bold, this
1094cdf0e10cSrcweir                 should be rethought out. For the moment its safest to just do
1095cdf0e10cSrcweir                 the clean if we have no parent, all we suffer is too many
1096cdf0e10cSrcweir                 redundant properties.
1097cdf0e10cSrcweir                 */
1098cdf0e10cSrcweir                 if (IsChkStyleAttr() && !pAkt)
1099cdf0e10cSrcweir 					_ClearStyleAttr( *pOld );
1100cdf0e10cSrcweir #endif
1101cdf0e10cSrcweir 
1102cdf0e10cSrcweir 				if( pAkt )
1103cdf0e10cSrcweir 				{
1104cdf0e10cSrcweir 					pAkt->Add( pOld );
1105cdf0e10cSrcweir 					// split up and create new entry, because it make no sense
1106cdf0e10cSrcweir 					// to create a "so long" depend list. Bug 95010
1107cdf0e10cSrcweir 					if( bCrsrBack && 50 < pAkt->pChildList->Count() )
1108cdf0e10cSrcweir 					{
1109cdf0e10cSrcweir 						// am Absatzanfang ? eine Position zurueck
1110cdf0e10cSrcweir 						MovePos( sal_True );
1111cdf0e10cSrcweir 						bCrsrBack = sal_False;
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 						// eine neue Gruppe aufmachen
1114cdf0e10cSrcweir 						SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
1115cdf0e10cSrcweir 												*pAkt, *pInsPos, sal_True );
1116cdf0e10cSrcweir 						pNew->SetRTFDefaults( GetRTFDefaults() );
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 						// alle bis hierher gueltigen Attribute "setzen"
1119cdf0e10cSrcweir 						AttrGroupEnd();
1120cdf0e10cSrcweir                         pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();  // can be changed after AttrGroupEnd!
1121cdf0e10cSrcweir 						pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
1122cdf0e10cSrcweir 						aAttrStack.push_back( pNew );
1123cdf0e10cSrcweir 						pAkt = pNew;
1124cdf0e10cSrcweir 					}
1125cdf0e10cSrcweir 				}
1126cdf0e10cSrcweir 				else
1127cdf0e10cSrcweir 					// letzter vom Stack, also zwischenspeichern, bis der
1128cdf0e10cSrcweir 					// naechste Text eingelesen wurde. (keine Attribute
1129cdf0e10cSrcweir 					// aufspannen!!)
1130cdf0e10cSrcweir 					aAttrSetList.Insert( pOld, aAttrSetList.Count() );
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir 				pOld = 0;
1133cdf0e10cSrcweir 			}
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 			if( bCrsrBack )
1136cdf0e10cSrcweir 				// am Absatzanfang ? eine Position zurueck
1137cdf0e10cSrcweir 				MovePos( sal_True );
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 		} while( sal_False );
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir 		if( pOld )
1142cdf0e10cSrcweir 			delete pOld;
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir 		bNewGroup = sal_False;
1145cdf0e10cSrcweir 	}
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir 
SetAllAttrOfStk()1148cdf0e10cSrcweir void SvxRTFParser::SetAllAttrOfStk()		// end all Attr. and set it into doc
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir 	// repeat until all attributes will be taken from stack
1151cdf0e10cSrcweir 	while( !aAttrStack.empty() )
1152cdf0e10cSrcweir 		AttrGroupEnd();
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir 	for( sal_uInt16 n = aAttrSetList.Count(); n; )
1155cdf0e10cSrcweir 	{
1156cdf0e10cSrcweir 		SvxRTFItemStackType* pStkSet = aAttrSetList[--n];
1157cdf0e10cSrcweir 		SetAttrSet( *pStkSet );
1158cdf0e10cSrcweir 		aAttrSetList.DeleteAndDestroy( n );
1159cdf0e10cSrcweir 	}
1160cdf0e10cSrcweir }
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir // setzt alle Attribute, die unterschiedlich zum aktuellen sind
SetAttrSet(SvxRTFItemStackType & rSet)1163cdf0e10cSrcweir void SvxRTFParser::SetAttrSet( SvxRTFItemStackType &rSet )
1164cdf0e10cSrcweir {
1165cdf0e10cSrcweir 	// wurde DefTab nie eingelesen? dann setze auf default
1166cdf0e10cSrcweir 	if( !bIsSetDfltTab )
1167cdf0e10cSrcweir 		SetDefault( RTF_DEFTAB, 720 );
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir 	if( rSet.pChildList )
1170cdf0e10cSrcweir 		rSet.Compress( *this );
1171cdf0e10cSrcweir 	if( rSet.aAttrSet.Count() || rSet.nStyleNo )
1172cdf0e10cSrcweir 		SetAttrInDoc( rSet );
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	// dann mal alle Childs abarbeiten
1175cdf0e10cSrcweir 	if( rSet.pChildList )
1176cdf0e10cSrcweir 		for( sal_uInt16 n = 0; n < rSet.pChildList->Count(); ++n )
1177cdf0e10cSrcweir 			SetAttrSet( *(*rSet.pChildList)[ n ] );
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 	// Is text wasn't inserted? (Get SttPos from the top of stack!)
IsAttrSttPos()1181cdf0e10cSrcweir int	SvxRTFParser::IsAttrSttPos()
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir     SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
1184cdf0e10cSrcweir 	return !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
1185cdf0e10cSrcweir 		pAkt->nSttCnt == pInsPos->GetCntIdx());
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 
SetAttrInDoc(SvxRTFItemStackType &)1189cdf0e10cSrcweir void SvxRTFParser::SetAttrInDoc( SvxRTFItemStackType & )
1190cdf0e10cSrcweir {
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir #ifdef USED
SaveState(int nToken)1194cdf0e10cSrcweir void SvxRTFParser::SaveState( int nToken )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir 	SvRTFParser::SaveState( nToken );
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir 
RestoreState()1199cdf0e10cSrcweir void SvxRTFParser::RestoreState()
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir 	SvRTFParser::RestoreState();
1202cdf0e10cSrcweir }
1203cdf0e10cSrcweir #endif
1204cdf0e10cSrcweir 
BuildWhichTbl()1205cdf0e10cSrcweir void SvxRTFParser::BuildWhichTbl()
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir 	if( aWhichMap.Count() )
1208cdf0e10cSrcweir 		aWhichMap.Remove( 0, aWhichMap.Count() );
1209cdf0e10cSrcweir 	aWhichMap.Insert( (sal_uInt16)0, (sal_uInt16)0 );
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 	// Aufbau einer Which-Map 'rWhichMap' aus einem Array von
1212cdf0e10cSrcweir 	// 'pWhichIds' von Which-Ids. Es hat die Lange 'nWhichIds'.
1213cdf0e10cSrcweir 	// Die Which-Map wird nicht geloescht.
1214cdf0e10cSrcweir 	SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)aPardMap.GetData(), aPardMap.Count() );
1215cdf0e10cSrcweir 	SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16*)aPlainMap.GetData(), aPlainMap.Count() );
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
GetRTFDefaults()1218cdf0e10cSrcweir const SfxItemSet& SvxRTFParser::GetRTFDefaults()
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir 	if( !pRTFDefaults )
1221cdf0e10cSrcweir 	{
1222cdf0e10cSrcweir 		pRTFDefaults = new SfxItemSet( *pAttrPool, aWhichMap.GetData() );
1223cdf0e10cSrcweir 		sal_uInt16 nId;
1224cdf0e10cSrcweir 		if( 0 != ( nId = ((RTFPardAttrMapIds*)aPardMap.GetData())->nScriptSpace ))
1225cdf0e10cSrcweir 		{
1226cdf0e10cSrcweir 			SvxScriptSpaceItem aItem( sal_False, nId );
1227cdf0e10cSrcweir 			if( bNewDoc )
1228cdf0e10cSrcweir 				pAttrPool->SetPoolDefaultItem( aItem );
1229cdf0e10cSrcweir 			else
1230cdf0e10cSrcweir 				pRTFDefaults->Put( aItem );
1231cdf0e10cSrcweir 		}
1232cdf0e10cSrcweir 	}
1233cdf0e10cSrcweir 	return *pRTFDefaults;
1234cdf0e10cSrcweir }
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir /**/
1237cdf0e10cSrcweir 
SvxRTFStyleType(SfxItemPool & rPool,const sal_uInt16 * pWhichRange)1238cdf0e10cSrcweir SvxRTFStyleType::SvxRTFStyleType( SfxItemPool& rPool, const sal_uInt16* pWhichRange )
1239cdf0e10cSrcweir 	: aAttrSet( rPool, pWhichRange )
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir 	nOutlineNo = sal_uInt8(-1);			// nicht gesetzt
1242cdf0e10cSrcweir 	nBasedOn = 0;
1243cdf0e10cSrcweir 	bBasedOnIsSet = sal_False;          //$flr #117411#
1244cdf0e10cSrcweir 	nNext = 0;
1245cdf0e10cSrcweir 	bIsCharFmt = sal_False;
1246cdf0e10cSrcweir }
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 
SvxRTFItemStackType(SfxItemPool & rPool,const sal_uInt16 * pWhichRange,const SvxPosition & rPos)1249cdf0e10cSrcweir SvxRTFItemStackType::SvxRTFItemStackType(
1250cdf0e10cSrcweir 		SfxItemPool& rPool, const sal_uInt16* pWhichRange,
1251cdf0e10cSrcweir 		const SvxPosition& rPos )
1252cdf0e10cSrcweir 	: aAttrSet( rPool, pWhichRange ),
1253cdf0e10cSrcweir 	pChildList( 0 ),
1254cdf0e10cSrcweir 	nStyleNo( 0 )
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir 	pSttNd = rPos.MakeNodeIdx();
1257cdf0e10cSrcweir 	nSttCnt = rPos.GetCntIdx();
1258cdf0e10cSrcweir 	pEndNd = pSttNd;
1259cdf0e10cSrcweir 	nEndCnt = nSttCnt;
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir 
SvxRTFItemStackType(const SvxRTFItemStackType & rCpy,const SvxPosition & rPos,int bCopyAttr)1262cdf0e10cSrcweir SvxRTFItemStackType::SvxRTFItemStackType(
1263cdf0e10cSrcweir 		const SvxRTFItemStackType& rCpy,
1264cdf0e10cSrcweir 		const SvxPosition& rPos,
1265cdf0e10cSrcweir 		int bCopyAttr )
1266cdf0e10cSrcweir 	: aAttrSet( *rCpy.aAttrSet.GetPool(), rCpy.aAttrSet.GetRanges() ),
1267cdf0e10cSrcweir 	pChildList( 0 ),
1268cdf0e10cSrcweir 	nStyleNo( rCpy.nStyleNo )
1269cdf0e10cSrcweir {
1270cdf0e10cSrcweir 	pSttNd = rPos.MakeNodeIdx();
1271cdf0e10cSrcweir 	nSttCnt = rPos.GetCntIdx();
1272cdf0e10cSrcweir 	pEndNd = pSttNd;
1273cdf0e10cSrcweir 	nEndCnt = nSttCnt;
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir 	aAttrSet.SetParent( &rCpy.aAttrSet );
1276cdf0e10cSrcweir 	if( bCopyAttr )
1277cdf0e10cSrcweir 		aAttrSet.Put( rCpy.aAttrSet );
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
~SvxRTFItemStackType()1280cdf0e10cSrcweir SvxRTFItemStackType::~SvxRTFItemStackType()
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir 	if( pChildList )
1283cdf0e10cSrcweir 		delete pChildList;
1284cdf0e10cSrcweir 	if( pSttNd != pEndNd )
1285cdf0e10cSrcweir 		delete pEndNd;
1286cdf0e10cSrcweir 	delete pSttNd;
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir 
Add(SvxRTFItemStackType * pIns)1289cdf0e10cSrcweir void SvxRTFItemStackType::Add( SvxRTFItemStackType* pIns )
1290cdf0e10cSrcweir {
1291cdf0e10cSrcweir 	if( !pChildList )
1292cdf0e10cSrcweir 		 pChildList = new SvxRTFItemStackList( 4, 16 );
1293cdf0e10cSrcweir 	pChildList->Insert( pIns, pChildList->Count() );
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir #if 0
1297cdf0e10cSrcweir //cmc: This is the original. nEndCnt is redundantly assigned to itself, and
1298cdf0e10cSrcweir //pEndNd can leak if not equal to pSttNd.
1299cdf0e10cSrcweir void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos )
1300cdf0e10cSrcweir {
1301cdf0e10cSrcweir 	delete pSttNd;
1302cdf0e10cSrcweir 	pSttNd = rPos.MakeNodeIdx();
1303cdf0e10cSrcweir 	nSttCnt = rPos.GetCntIdx();
1304cdf0e10cSrcweir 	pEndNd = pSttNd;
1305cdf0e10cSrcweir 	nEndCnt = nEndCnt;
1306cdf0e10cSrcweir }
1307cdf0e10cSrcweir #else
SetStartPos(const SvxPosition & rPos)1308cdf0e10cSrcweir void SvxRTFItemStackType::SetStartPos( const SvxPosition& rPos )
1309cdf0e10cSrcweir {
1310cdf0e10cSrcweir     if (pSttNd != pEndNd)
1311cdf0e10cSrcweir         delete pEndNd;
1312cdf0e10cSrcweir 	delete pSttNd;
1313cdf0e10cSrcweir 	pSttNd = rPos.MakeNodeIdx();
1314cdf0e10cSrcweir 	pEndNd = pSttNd;
1315cdf0e10cSrcweir 	nSttCnt = rPos.GetCntIdx();
1316cdf0e10cSrcweir }
1317cdf0e10cSrcweir #endif
1318cdf0e10cSrcweir 
MoveFullNode(const SvxNodeIdx & rOldNode,const SvxNodeIdx & rNewNode)1319cdf0e10cSrcweir void SvxRTFItemStackType::MoveFullNode(const SvxNodeIdx &rOldNode,
1320cdf0e10cSrcweir     const SvxNodeIdx &rNewNode)
1321cdf0e10cSrcweir {
1322cdf0e10cSrcweir     bool bSameEndAsStart = (pSttNd == pEndNd) ? true : false;
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir     if (GetSttNodeIdx() == rOldNode.GetIdx())
1325cdf0e10cSrcweir     {
1326cdf0e10cSrcweir         delete pSttNd;
1327cdf0e10cSrcweir         pSttNd = rNewNode.Clone();
1328cdf0e10cSrcweir         if (bSameEndAsStart)
1329cdf0e10cSrcweir             pEndNd = pSttNd;
1330cdf0e10cSrcweir     }
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir     if (!bSameEndAsStart && GetEndNodeIdx() == rOldNode.GetIdx())
1333cdf0e10cSrcweir     {
1334cdf0e10cSrcweir         delete pEndNd;
1335cdf0e10cSrcweir         pEndNd = rNewNode.Clone();
1336cdf0e10cSrcweir     }
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir     //And the same for all the children
1339cdf0e10cSrcweir     sal_uInt16 nCount = pChildList ? pChildList->Count() : 0;
1340cdf0e10cSrcweir     for (sal_uInt16 i = 0; i < nCount; ++i)
1341cdf0e10cSrcweir     {
1342cdf0e10cSrcweir         SvxRTFItemStackType* pStk = (*pChildList)[i];
1343cdf0e10cSrcweir         pStk->MoveFullNode(rOldNode, rNewNode);
1344cdf0e10cSrcweir     }
1345cdf0e10cSrcweir }
1346cdf0e10cSrcweir 
UncompressableStackEntry(const SvxRTFItemStackType &) const1347cdf0e10cSrcweir bool SvxRTFParser::UncompressableStackEntry(const SvxRTFItemStackType &) const
1348cdf0e10cSrcweir {
1349cdf0e10cSrcweir     return false;
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir 
Compress(const SvxRTFParser & rParser)1352cdf0e10cSrcweir void SvxRTFItemStackType::Compress( const SvxRTFParser& rParser )
1353cdf0e10cSrcweir {
1354*b264d727SArmin Le Grand     ENSURE_OR_RETURN_VOID(pChildList, "Compress: no ChildList" );
1355*b264d727SArmin Le Grand     ENSURE_OR_RETURN_VOID(pChildList->Count(), "Compress: ChildList empty");
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 	sal_uInt16 n;
1358cdf0e10cSrcweir 	SvxRTFItemStackType* pTmp = (*pChildList)[0];
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir 	if( !pTmp->aAttrSet.Count() ||
1361cdf0e10cSrcweir 		pSttNd->GetIdx() != pTmp->pSttNd->GetIdx() ||
1362cdf0e10cSrcweir 		nSttCnt != pTmp->nSttCnt )
1363cdf0e10cSrcweir 		return;
1364cdf0e10cSrcweir 
1365cdf0e10cSrcweir 	SvxNodeIdx* pLastNd = pTmp->pEndNd;
1366cdf0e10cSrcweir 	xub_StrLen nLastCnt = pTmp->nEndCnt;
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir 	SfxItemSet aMrgSet( pTmp->aAttrSet );
1369cdf0e10cSrcweir 	for( n = 1; n < pChildList->Count(); ++n )
1370cdf0e10cSrcweir 	{
1371cdf0e10cSrcweir 		pTmp = (*pChildList)[n];
1372cdf0e10cSrcweir 		if( pTmp->pChildList )
1373cdf0e10cSrcweir 			pTmp->Compress( rParser );
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 		if( !pTmp->nSttCnt
1376cdf0e10cSrcweir 			? (pLastNd->GetIdx()+1 != pTmp->pSttNd->GetIdx() ||
1377cdf0e10cSrcweir 			   !rParser.IsEndPara( pLastNd, nLastCnt ) )
1378cdf0e10cSrcweir 			: ( pTmp->nSttCnt != nLastCnt ||
1379cdf0e10cSrcweir 				pLastNd->GetIdx() != pTmp->pSttNd->GetIdx() ))
1380cdf0e10cSrcweir 		{
1381cdf0e10cSrcweir 			while( ++n < pChildList->Count() )
1382cdf0e10cSrcweir 				if( (pTmp = (*pChildList)[n])->pChildList )
1383cdf0e10cSrcweir 					pTmp->Compress( rParser );
1384cdf0e10cSrcweir 			return;
1385cdf0e10cSrcweir 		}
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir         if (rParser.UncompressableStackEntry(*pTmp))
1388cdf0e10cSrcweir             return;
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 		if( n )
1391cdf0e10cSrcweir 		{
1392cdf0e10cSrcweir 			// suche alle, die ueber den gesamten Bereich gesetzt sind
1393cdf0e10cSrcweir 			SfxItemIter aIter( aMrgSet );
1394cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1395cdf0e10cSrcweir 			do {
1396cdf0e10cSrcweir 				sal_uInt16 nWhich = aIter.GetCurItem()->Which();
1397cdf0e10cSrcweir 				if( SFX_ITEM_SET != pTmp->aAttrSet.GetItemState( nWhich,
1398cdf0e10cSrcweir 					  sal_False, &pItem ) || *pItem != *aIter.GetCurItem() )
1399cdf0e10cSrcweir 					aMrgSet.ClearItem( nWhich );
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 				if( aIter.IsAtEnd() )
1402cdf0e10cSrcweir 					break;
1403cdf0e10cSrcweir 				aIter.NextItem();
1404cdf0e10cSrcweir 			} while( sal_True );
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir 			if( !aMrgSet.Count() )
1407cdf0e10cSrcweir 				return;
1408cdf0e10cSrcweir 		}
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir 		pLastNd = pTmp->pEndNd;
1411cdf0e10cSrcweir 		nLastCnt = pTmp->nEndCnt;
1412cdf0e10cSrcweir 	}
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir 	if( pEndNd->GetIdx() != pLastNd->GetIdx() || nEndCnt != nLastCnt )
1415cdf0e10cSrcweir 		return;
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 	// es kann zusammengefasst werden
1418cdf0e10cSrcweir 	aAttrSet.Put( aMrgSet );
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir 	for( n = 0; n < pChildList->Count(); ++n )
1421cdf0e10cSrcweir 	{
1422cdf0e10cSrcweir 		pTmp = (*pChildList)[n];
1423cdf0e10cSrcweir 		pTmp->aAttrSet.Differentiate( aMrgSet );
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 		if( !pTmp->pChildList && !pTmp->aAttrSet.Count() && !pTmp->nStyleNo )
1426cdf0e10cSrcweir 		{
1427cdf0e10cSrcweir 			pChildList->Remove( n );
1428cdf0e10cSrcweir 			delete pTmp;
1429cdf0e10cSrcweir 			--n;
1430cdf0e10cSrcweir 			continue;
1431cdf0e10cSrcweir 		}
1432cdf0e10cSrcweir 	}
1433cdf0e10cSrcweir 	if( !pChildList->Count() )
1434cdf0e10cSrcweir 	{
1435cdf0e10cSrcweir 		delete pChildList;
1436cdf0e10cSrcweir 		pChildList = 0;
1437cdf0e10cSrcweir 	}
1438cdf0e10cSrcweir }
SetRTFDefaults(const SfxItemSet & rDefaults)1439cdf0e10cSrcweir void SvxRTFItemStackType::SetRTFDefaults( const SfxItemSet& rDefaults )
1440cdf0e10cSrcweir {
1441cdf0e10cSrcweir 	if( rDefaults.Count() )
1442cdf0e10cSrcweir 	{
1443cdf0e10cSrcweir 		SfxItemIter aIter( rDefaults );
1444cdf0e10cSrcweir 		do {
1445cdf0e10cSrcweir 			sal_uInt16 nWhich = aIter.GetCurItem()->Which();
1446cdf0e10cSrcweir 			if( SFX_ITEM_SET != aAttrSet.GetItemState( nWhich, sal_False ))
1447cdf0e10cSrcweir 				aAttrSet.Put( *aIter.GetCurItem() );
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 			if( aIter.IsAtEnd() )
1450cdf0e10cSrcweir 				break;
1451cdf0e10cSrcweir 			aIter.NextItem();
1452cdf0e10cSrcweir 		} while( sal_True );
1453cdf0e10cSrcweir 	}
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir 
1456cdf0e10cSrcweir /**/
1457cdf0e10cSrcweir 
RTFPlainAttrMapIds(const SfxItemPool & rPool)1458cdf0e10cSrcweir RTFPlainAttrMapIds::RTFPlainAttrMapIds( const SfxItemPool& rPool )
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir 	nCaseMap = rPool.GetTrueWhich( SID_ATTR_CHAR_CASEMAP, sal_False );
1461cdf0e10cSrcweir 	nBgColor = rPool.GetTrueWhich( SID_ATTR_BRUSH_CHAR, sal_False );
1462cdf0e10cSrcweir 	nColor = rPool.GetTrueWhich( SID_ATTR_CHAR_COLOR, sal_False );
1463cdf0e10cSrcweir 	nContour = rPool.GetTrueWhich( SID_ATTR_CHAR_CONTOUR, sal_False );
1464cdf0e10cSrcweir 	nCrossedOut = rPool.GetTrueWhich( SID_ATTR_CHAR_STRIKEOUT, sal_False );
1465cdf0e10cSrcweir 	nEscapement = rPool.GetTrueWhich( SID_ATTR_CHAR_ESCAPEMENT, sal_False );
1466cdf0e10cSrcweir 	nFont = rPool.GetTrueWhich( SID_ATTR_CHAR_FONT, sal_False );
1467cdf0e10cSrcweir 	nFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_FONTHEIGHT, sal_False );
1468cdf0e10cSrcweir 	nKering = rPool.GetTrueWhich( SID_ATTR_CHAR_KERNING, sal_False );
1469cdf0e10cSrcweir 	nLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_LANGUAGE, sal_False );
1470cdf0e10cSrcweir 	nPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_POSTURE, sal_False );
1471cdf0e10cSrcweir 	nShadowed = rPool.GetTrueWhich( SID_ATTR_CHAR_SHADOWED, sal_False );
1472cdf0e10cSrcweir 	nUnderline = rPool.GetTrueWhich( SID_ATTR_CHAR_UNDERLINE, sal_False );
1473cdf0e10cSrcweir 	nOverline = rPool.GetTrueWhich( SID_ATTR_CHAR_OVERLINE, sal_False );
1474cdf0e10cSrcweir 	nWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_WEIGHT, sal_False );
1475cdf0e10cSrcweir 	nWordlineMode = rPool.GetTrueWhich( SID_ATTR_CHAR_WORDLINEMODE, sal_False );
1476cdf0e10cSrcweir 	nAutoKerning = rPool.GetTrueWhich( SID_ATTR_CHAR_AUTOKERN, sal_False );
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir 	nCJKFont = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONT, sal_False );
1479cdf0e10cSrcweir 	nCJKFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT, sal_False );
1480cdf0e10cSrcweir 	nCJKLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_LANGUAGE, sal_False );
1481cdf0e10cSrcweir 	nCJKPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_POSTURE, sal_False );
1482cdf0e10cSrcweir 	nCJKWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_WEIGHT, sal_False );
1483cdf0e10cSrcweir 	nCTLFont = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONT, sal_False );
1484cdf0e10cSrcweir 	nCTLFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT, sal_False );
1485cdf0e10cSrcweir 	nCTLLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False );
1486cdf0e10cSrcweir 	nCTLPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_POSTURE, sal_False );
1487cdf0e10cSrcweir 	nCTLWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_WEIGHT, sal_False );
1488cdf0e10cSrcweir 	nEmphasis = rPool.GetTrueWhich( SID_ATTR_CHAR_EMPHASISMARK, sal_False );
1489cdf0e10cSrcweir 	nTwoLines = rPool.GetTrueWhich( SID_ATTR_CHAR_TWO_LINES, sal_False );
1490cdf0e10cSrcweir 	nRuby = 0; //rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_RUBY, sal_False );
1491cdf0e10cSrcweir 	nCharScaleX = rPool.GetTrueWhich( SID_ATTR_CHAR_SCALEWIDTH, sal_False );
1492cdf0e10cSrcweir 	nHorzVert = rPool.GetTrueWhich( SID_ATTR_CHAR_ROTATED, sal_False );
1493cdf0e10cSrcweir 	nRelief = rPool.GetTrueWhich( SID_ATTR_CHAR_RELIEF, sal_False );
1494cdf0e10cSrcweir 	nHidden = rPool.GetTrueWhich( SID_ATTR_CHAR_HIDDEN, sal_False );
1495cdf0e10cSrcweir }
1496cdf0e10cSrcweir 
RTFPardAttrMapIds(const SfxItemPool & rPool)1497cdf0e10cSrcweir RTFPardAttrMapIds ::RTFPardAttrMapIds ( const SfxItemPool& rPool )
1498cdf0e10cSrcweir {
1499cdf0e10cSrcweir 	nLinespacing = rPool.GetTrueWhich( SID_ATTR_PARA_LINESPACE, sal_False );
1500cdf0e10cSrcweir 	nAdjust = rPool.GetTrueWhich( SID_ATTR_PARA_ADJUST, sal_False );
1501cdf0e10cSrcweir 	nTabStop = rPool.GetTrueWhich( SID_ATTR_TABSTOP, sal_False );
1502cdf0e10cSrcweir 	nHyphenzone = rPool.GetTrueWhich( SID_ATTR_PARA_HYPHENZONE, sal_False );
1503cdf0e10cSrcweir 	nLRSpace = rPool.GetTrueWhich( SID_ATTR_LRSPACE, sal_False );
1504cdf0e10cSrcweir 	nULSpace = rPool.GetTrueWhich( SID_ATTR_ULSPACE, sal_False );
1505cdf0e10cSrcweir 	nBrush = rPool.GetTrueWhich( SID_ATTR_BRUSH, sal_False );
1506cdf0e10cSrcweir 	nBox = rPool.GetTrueWhich( SID_ATTR_BORDER_OUTER, sal_False );
1507cdf0e10cSrcweir 	nShadow = rPool.GetTrueWhich( SID_ATTR_BORDER_SHADOW, sal_False );
1508cdf0e10cSrcweir 	nOutlineLvl = rPool.GetTrueWhich( SID_ATTR_PARA_OUTLLEVEL, sal_False );
1509cdf0e10cSrcweir 	nSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, sal_False );
1510cdf0e10cSrcweir 	nKeep = rPool.GetTrueWhich( SID_ATTR_PARA_KEEP, sal_False );
1511cdf0e10cSrcweir 	nFontAlign = rPool.GetTrueWhich( SID_PARA_VERTALIGN, sal_False );
1512cdf0e10cSrcweir 	nScriptSpace = rPool.GetTrueWhich( SID_ATTR_PARA_SCRIPTSPACE, sal_False );
1513cdf0e10cSrcweir 	nHangPunct = rPool.GetTrueWhich( SID_ATTR_PARA_HANGPUNCTUATION, sal_False );
1514cdf0e10cSrcweir 	nForbRule = rPool.GetTrueWhich( SID_ATTR_PARA_FORBIDDEN_RULES, sal_False );
1515cdf0e10cSrcweir     nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False );
1516cdf0e10cSrcweir }
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
1519