xref: /aoo42x/main/editeng/source/rtf/rtfitem.cxx (revision 190118d0)
1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew 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 #include <editeng/flstitem.hxx>
30cdf0e10cSrcweir #include <editeng/fontitem.hxx>
31cdf0e10cSrcweir #include <editeng/postitem.hxx>
32cdf0e10cSrcweir #include <editeng/wghtitem.hxx>
33cdf0e10cSrcweir #include <editeng/fhgtitem.hxx>
34cdf0e10cSrcweir #include <editeng/fwdtitem.hxx>
35cdf0e10cSrcweir #include <editeng/udlnitem.hxx>
36cdf0e10cSrcweir #include <editeng/crsditem.hxx>
37cdf0e10cSrcweir #include <editeng/shdditem.hxx>
38cdf0e10cSrcweir #include <editeng/akrnitem.hxx>
39cdf0e10cSrcweir #include <editeng/wrlmitem.hxx>
40cdf0e10cSrcweir #include <editeng/cntritem.hxx>
41cdf0e10cSrcweir #include <editeng/prszitem.hxx>
42cdf0e10cSrcweir #include <editeng/colritem.hxx>
43cdf0e10cSrcweir #include <editeng/cscoitem.hxx>
44cdf0e10cSrcweir #include <editeng/kernitem.hxx>
45cdf0e10cSrcweir #include <editeng/cmapitem.hxx>
46cdf0e10cSrcweir #include <editeng/escpitem.hxx>
47cdf0e10cSrcweir #include <editeng/langitem.hxx>
48cdf0e10cSrcweir #include <editeng/nlbkitem.hxx>
49cdf0e10cSrcweir #include <editeng/nhypitem.hxx>
50cdf0e10cSrcweir #include <editeng/lcolitem.hxx>
51cdf0e10cSrcweir #include <editeng/blnkitem.hxx>
52cdf0e10cSrcweir #include <editeng/emphitem.hxx>
53cdf0e10cSrcweir #include <editeng/twolinesitem.hxx>
54cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
55cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
56cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
57cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
58cdf0e10cSrcweir #include <editeng/prntitem.hxx>
59cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
60cdf0e10cSrcweir #include <editeng/protitem.hxx>
61cdf0e10cSrcweir #include <editeng/shaditem.hxx>
62cdf0e10cSrcweir #include <editeng/boxitem.hxx>
63cdf0e10cSrcweir #include <editeng/brkitem.hxx>
64cdf0e10cSrcweir #include <editeng/keepitem.hxx>
65cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
66cdf0e10cSrcweir #include <editeng/brshitem.hxx>
67cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
68cdf0e10cSrcweir #include <editeng/adjitem.hxx>
69cdf0e10cSrcweir #include <editeng/orphitem.hxx>
70cdf0e10cSrcweir #include <editeng/widwitem.hxx>
71cdf0e10cSrcweir #include <editeng/tstpitem.hxx>
72cdf0e10cSrcweir #include <editeng/pmdlitem.hxx>
73cdf0e10cSrcweir #include <editeng/spltitem.hxx>
74cdf0e10cSrcweir #include <editeng/hyznitem.hxx>
75cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
76cdf0e10cSrcweir #include <editeng/charrotateitem.hxx>
77cdf0e10cSrcweir #include <editeng/charreliefitem.hxx>
78cdf0e10cSrcweir #include <editeng/paravertalignitem.hxx>
79cdf0e10cSrcweir #include <editeng/forbiddenruleitem.hxx>
80cdf0e10cSrcweir #include <editeng/hngpnctitem.hxx>
81cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx>
82cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
83cdf0e10cSrcweir #include <editeng/charhiddenitem.hxx>
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #include <svtools/rtftoken.h>
86cdf0e10cSrcweir #include <svl/itempool.hxx>
87cdf0e10cSrcweir #include <svl/itemiter.hxx>
88cdf0e10cSrcweir 
89cdf0e10cSrcweir #include <editeng/svxrtf.hxx>
90cdf0e10cSrcweir #include <editeng/editids.hrc>
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #define BRACELEFT	'{'
93cdf0e10cSrcweir #define BRACERIGHT	'}'
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 
96cdf0e10cSrcweir // einige Hilfs-Funktionen
97cdf0e10cSrcweir // char
GetEscapement(const SfxItemSet & rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)98cdf0e10cSrcweir inline const SvxEscapementItem& GetEscapement(const SfxItemSet& rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)
99cdf0e10cSrcweir 	{ return (const SvxEscapementItem&)rSet.Get( nId,bInP); }
GetLineSpacing(const SfxItemSet & rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)100cdf0e10cSrcweir inline const SvxLineSpacingItem& GetLineSpacing(const SfxItemSet& rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)
101cdf0e10cSrcweir 	{ return (const SvxLineSpacingItem&)rSet.Get( nId,bInP); }
102cdf0e10cSrcweir // frm
GetLRSpace(const SfxItemSet & rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)103cdf0e10cSrcweir inline const SvxLRSpaceItem& GetLRSpace(const SfxItemSet& rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)
104cdf0e10cSrcweir 	{ return (const SvxLRSpaceItem&)rSet.Get( nId,bInP); }
GetULSpace(const SfxItemSet & rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)105cdf0e10cSrcweir inline const SvxULSpaceItem& GetULSpace(const SfxItemSet& rSet,sal_uInt16 nId,sal_Bool bInP=sal_True)
106cdf0e10cSrcweir 	{ return (const SvxULSpaceItem&)rSet.Get( nId,bInP); }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir #define PARDID		((RTFPardAttrMapIds*)aPardMap.GetData())
109cdf0e10cSrcweir #define PLAINID		((RTFPlainAttrMapIds*)aPlainMap.GetData())
110cdf0e10cSrcweir 
SetScriptAttr(RTF_CharTypeDef eType,SfxItemSet & rSet,SfxPoolItem & rItem)111cdf0e10cSrcweir void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType, SfxItemSet& rSet,
112cdf0e10cSrcweir 									SfxPoolItem& rItem )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	const sal_uInt16 *pNormal = 0, *pCJK = 0, *pCTL = 0;
115cdf0e10cSrcweir 	const RTFPlainAttrMapIds* pIds = (RTFPlainAttrMapIds*)aPlainMap.GetData();
116cdf0e10cSrcweir 	switch( rItem.Which() )
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 	case SID_ATTR_CHAR_FONT:
119cdf0e10cSrcweir 		pNormal = &pIds->nFont;
120cdf0e10cSrcweir 		pCJK = &pIds->nCJKFont;
121cdf0e10cSrcweir 		pCTL = &pIds->nCTLFont;
122cdf0e10cSrcweir 		break;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	case SID_ATTR_CHAR_FONTHEIGHT:
125cdf0e10cSrcweir 		pNormal = &pIds->nFontHeight;
126cdf0e10cSrcweir 		pCJK = &pIds->nCJKFontHeight;
127cdf0e10cSrcweir 		pCTL = &pIds->nCTLFontHeight;
128cdf0e10cSrcweir 		break;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	case SID_ATTR_CHAR_POSTURE:
131cdf0e10cSrcweir 		pNormal = &pIds->nPosture;
132cdf0e10cSrcweir 		pCJK = &pIds->nCJKPosture;
133cdf0e10cSrcweir 		pCTL = &pIds->nCTLPosture;
134cdf0e10cSrcweir 		break;
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	case SID_ATTR_CHAR_WEIGHT:
137cdf0e10cSrcweir 		pNormal = &pIds->nWeight;
138cdf0e10cSrcweir 		pCJK = &pIds->nCJKWeight;
139cdf0e10cSrcweir 		pCTL = &pIds->nCTLWeight;
140cdf0e10cSrcweir 		break;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	case SID_ATTR_CHAR_LANGUAGE:
143cdf0e10cSrcweir 		pNormal = &pIds->nLanguage;
144cdf0e10cSrcweir 		pCJK = &pIds->nCJKLanguage;
145cdf0e10cSrcweir 		pCTL = &pIds->nCTLLanguage;
146cdf0e10cSrcweir 		break;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	case 0:
149cdf0e10cSrcweir 		// it exist no WhichId - don't set this item
150cdf0e10cSrcweir 		break;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	default:
153cdf0e10cSrcweir 	   rSet.Put( rItem );
154cdf0e10cSrcweir 	   break;
155cdf0e10cSrcweir 	}
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	if( DOUBLEBYTE_CHARTYPE == eType )
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		if( bIsLeftToRightDef && *pCJK )
161cdf0e10cSrcweir 		{
162cdf0e10cSrcweir 			rItem.SetWhich( *pCJK );
163cdf0e10cSrcweir 			rSet.Put( rItem );
164cdf0e10cSrcweir 		}
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir 	else if( !bIsLeftToRightDef )
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir 		if( *pCTL )
169cdf0e10cSrcweir 		{
170cdf0e10cSrcweir 			rItem.SetWhich( *pCTL );
171cdf0e10cSrcweir 			rSet.Put( rItem );
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 	else
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		if( LOW_CHARTYPE == eType )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			if( *pNormal )
179cdf0e10cSrcweir 			{
180cdf0e10cSrcweir 				rItem.SetWhich( *pNormal );
181cdf0e10cSrcweir 				rSet.Put( rItem );
182cdf0e10cSrcweir 			}
183cdf0e10cSrcweir 		}
184cdf0e10cSrcweir 		else if( HIGH_CHARTYPE == eType )
185cdf0e10cSrcweir 		{
186cdf0e10cSrcweir 			if( *pCTL )
187cdf0e10cSrcweir 			{
188cdf0e10cSrcweir 				rItem.SetWhich( *pCTL );
189cdf0e10cSrcweir 				rSet.Put( rItem );
190cdf0e10cSrcweir 			}
191cdf0e10cSrcweir 		}
192cdf0e10cSrcweir 		else
193cdf0e10cSrcweir 		{
194cdf0e10cSrcweir 			if( *pCJK )
195cdf0e10cSrcweir 			{
196cdf0e10cSrcweir 				rItem.SetWhich( *pCJK );
197cdf0e10cSrcweir 				rSet.Put( rItem );
198cdf0e10cSrcweir 			}
199cdf0e10cSrcweir 			if( *pCTL )
200cdf0e10cSrcweir 			{
201cdf0e10cSrcweir 				rItem.SetWhich( *pCTL );
202cdf0e10cSrcweir 				rSet.Put( rItem );
203cdf0e10cSrcweir 			}
204cdf0e10cSrcweir 			if( *pNormal )
205cdf0e10cSrcweir 			{
206cdf0e10cSrcweir 				rItem.SetWhich( *pNormal );
207cdf0e10cSrcweir 				rSet.Put( rItem );
208cdf0e10cSrcweir 			}
209cdf0e10cSrcweir 		}
210cdf0e10cSrcweir 	}
211cdf0e10cSrcweir }
212cdf0e10cSrcweir 
213cdf0e10cSrcweir // --------------------
214cdf0e10cSrcweir 
ReadAttr(int nToken,SfxItemSet * pSet)215cdf0e10cSrcweir void SvxRTFParser::ReadAttr( int nToken, SfxItemSet* pSet )
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	DBG_ASSERT( pSet, "Es muss ein SfxItemSet uebergeben werden!" );
218cdf0e10cSrcweir 	int bFirstToken = sal_True, bWeiter = sal_True;
219cdf0e10cSrcweir 	sal_uInt16 nStyleNo = 0; 		// default
220cdf0e10cSrcweir 	FontUnderline eUnderline;
221cdf0e10cSrcweir 	FontUnderline eOverline;
222cdf0e10cSrcweir 	FontEmphasisMark eEmphasis;
223cdf0e10cSrcweir 	bPardTokenRead = sal_False;
224cdf0e10cSrcweir 	RTF_CharTypeDef eCharType = NOTDEF_CHARTYPE;
225cdf0e10cSrcweir 	sal_uInt16 nFontAlign;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	int bChkStkPos = !bNewGroup && !aAttrStack.empty();
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 	while( bWeiter && IsParserWorking() )			// solange bekannte Attribute erkannt werden
230cdf0e10cSrcweir 	{
231cdf0e10cSrcweir 		switch( nToken )
232cdf0e10cSrcweir 		{
233cdf0e10cSrcweir 		case RTF_PARD:
234cdf0e10cSrcweir 			RTFPardPlain( sal_True, &pSet );
235cdf0e10cSrcweir             ResetPard();
236cdf0e10cSrcweir 			nStyleNo = 0;
237cdf0e10cSrcweir 			bPardTokenRead = sal_True;
238cdf0e10cSrcweir 			break;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 		case RTF_PLAIN:
241cdf0e10cSrcweir 			RTFPardPlain( sal_False, &pSet );
242cdf0e10cSrcweir 			break;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 		default:
245cdf0e10cSrcweir 			do {		// middle checked loop
246cdf0e10cSrcweir 				if( !bChkStkPos )
247cdf0e10cSrcweir 					break;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 				SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
250cdf0e10cSrcweir 				if( !pAkt || (pAkt->pSttNd->GetIdx() == pInsPos->GetNodeIdx() &&
251cdf0e10cSrcweir 					pAkt->nSttCnt == pInsPos->GetCntIdx() ))
252cdf0e10cSrcweir 					break;
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 				int nLastToken = GetStackPtr(-1)->nTokenId;
255cdf0e10cSrcweir 				if( RTF_PARD == nLastToken || RTF_PLAIN == nLastToken )
256cdf0e10cSrcweir 					break;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 				if( pAkt->aAttrSet.Count() || pAkt->pChildList ||
259cdf0e10cSrcweir 					pAkt->nStyleNo )
260cdf0e10cSrcweir 				{
261cdf0e10cSrcweir 					// eine neue Gruppe aufmachen
262cdf0e10cSrcweir 					SvxRTFItemStackType* pNew = new SvxRTFItemStackType(
263cdf0e10cSrcweir 												*pAkt, *pInsPos, sal_True );
264cdf0e10cSrcweir 					pNew->SetRTFDefaults( GetRTFDefaults() );
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 					// alle bis hierher gueltigen Attribute "setzen"
267cdf0e10cSrcweir 					AttrGroupEnd();
268cdf0e10cSrcweir 					pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();  // can be changed after AttrGroupEnd!
269cdf0e10cSrcweir 					pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
270cdf0e10cSrcweir 
271cdf0e10cSrcweir 					aAttrStack.push_back( pNew );
272cdf0e10cSrcweir 					pAkt = pNew;
273cdf0e10cSrcweir 				}
274cdf0e10cSrcweir 				else
275cdf0e10cSrcweir 					// diesen Eintrag als neuen weiterbenutzen
276cdf0e10cSrcweir 					pAkt->SetStartPos( *pInsPos );
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 				pSet = &pAkt->aAttrSet;
279cdf0e10cSrcweir 			} while( sal_False );
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 			switch( nToken )
282cdf0e10cSrcweir 			{
283cdf0e10cSrcweir 			case RTF_INTBL:
284cdf0e10cSrcweir 			case RTF_PAGEBB:
285cdf0e10cSrcweir 			case RTF_SBYS:
286cdf0e10cSrcweir 			case RTF_CS:
287cdf0e10cSrcweir 			case RTF_LS:
288cdf0e10cSrcweir 			case RTF_ILVL:
289cdf0e10cSrcweir 					UnknownAttrToken( nToken, pSet );
290cdf0e10cSrcweir 					break;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 			case RTF_S:
293cdf0e10cSrcweir 				if( bIsInReadStyleTab )
294cdf0e10cSrcweir 				{
295cdf0e10cSrcweir 					if( !bFirstToken )
296cdf0e10cSrcweir 						SkipToken( -1 );
297cdf0e10cSrcweir 					bWeiter = sal_False;
298cdf0e10cSrcweir 				}
299cdf0e10cSrcweir 				else
300cdf0e10cSrcweir 				{
301cdf0e10cSrcweir 					nStyleNo = -1 == nTokenValue ? 0 : sal_uInt16(nTokenValue);
302cdf0e10cSrcweir 					// setze am akt. auf dem AttrStack stehenden Style die
303cdf0e10cSrcweir 					// StyleNummer
304cdf0e10cSrcweir 					SvxRTFItemStackType* pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();
305cdf0e10cSrcweir 					if( !pAkt )
306cdf0e10cSrcweir 						break;
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 					pAkt->nStyleNo = sal_uInt16( nStyleNo );
309cdf0e10cSrcweir 
310cdf0e10cSrcweir #if 0
311cdf0e10cSrcweir // JP 05.09.95: zuruecksetzen der Style-Attribute fuehrt nur zu Problemen.
312cdf0e10cSrcweir //				Es muss reichen, wenn das ueber pard/plain erfolgt
313cdf0e10cSrcweir //	ansonsten Bugdoc 15304.rtf - nach nur "\pard" falscher Font !!
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 					SvxRTFStyleType* pStyle = aStyleTbl.Get( pAkt->nStyleNo );
316cdf0e10cSrcweir 					if( pStyle && pStyle->aAttrSet.Count() )
317cdf0e10cSrcweir 					{
318cdf0e10cSrcweir 						//JP 07.07.95:
319cdf0e10cSrcweir 						// alle Attribute, die in der Vorlage gesetzt werden
320cdf0e10cSrcweir 						// auf defaults setzen. In RTF werden die Attribute
321cdf0e10cSrcweir 						// der Vorlage danach ja wiederholt.
322cdf0e10cSrcweir 						// WICHTIG: Attribute die in der Vorlage definiert
323cdf0e10cSrcweir 						//			sind, werden zurueckgesetzt !!!!
324cdf0e10cSrcweir 						// pAkt->aAttrSet.Put( pStyle->aAttrSet );
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 						SfxItemIter aIter( pStyle->aAttrSet );
327cdf0e10cSrcweir 						SfxItemPool* pPool = pStyle->aAttrSet.GetPool();
328cdf0e10cSrcweir 						sal_uInt16 nWh = aIter.GetCurItem()->Which();
329cdf0e10cSrcweir 						while( sal_True )
330cdf0e10cSrcweir 						{
331cdf0e10cSrcweir 							pAkt->aAttrSet.Put( pPool->GetDefaultItem( nWh ));
332cdf0e10cSrcweir 							if( aIter.IsAtEnd() )
333cdf0e10cSrcweir 								break;
334cdf0e10cSrcweir 							nWh = aIter.NextItem()->Which();
335cdf0e10cSrcweir 						}
336cdf0e10cSrcweir 					}
337cdf0e10cSrcweir #endif
338cdf0e10cSrcweir 				}
339cdf0e10cSrcweir 				break;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 			case RTF_KEEP:
342cdf0e10cSrcweir 				if( PARDID->nSplit )
343cdf0e10cSrcweir 				{
344cdf0e10cSrcweir 					pSet->Put( SvxFmtSplitItem( sal_False, PARDID->nSplit ));
345cdf0e10cSrcweir 				}
346cdf0e10cSrcweir 				break;
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 			case RTF_KEEPN:
349cdf0e10cSrcweir 				if( PARDID->nKeep )
350cdf0e10cSrcweir 				{
351cdf0e10cSrcweir 					pSet->Put( SvxFmtKeepItem( sal_True, PARDID->nKeep ));
352cdf0e10cSrcweir 				}
353cdf0e10cSrcweir 				break;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 			case RTF_LEVEL:
356cdf0e10cSrcweir 				if( PARDID->nOutlineLvl )
357cdf0e10cSrcweir 				{
358cdf0e10cSrcweir 					pSet->Put( SfxUInt16Item( PARDID->nOutlineLvl,
359cdf0e10cSrcweir 												(sal_uInt16)nTokenValue ));
360cdf0e10cSrcweir 				}
361cdf0e10cSrcweir 				break;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 			case RTF_QL:
364cdf0e10cSrcweir 				if( PARDID->nAdjust )
365cdf0e10cSrcweir 				{
366cdf0e10cSrcweir 					pSet->Put( SvxAdjustItem( SVX_ADJUST_LEFT, PARDID->nAdjust ));
367cdf0e10cSrcweir 				}
368cdf0e10cSrcweir 				break;
369cdf0e10cSrcweir 			case RTF_QR:
370cdf0e10cSrcweir 				if( PARDID->nAdjust )
371cdf0e10cSrcweir 				{
372cdf0e10cSrcweir 					pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, PARDID->nAdjust ));
373cdf0e10cSrcweir 				}
374cdf0e10cSrcweir 				break;
375cdf0e10cSrcweir 			case RTF_QJ:
376cdf0e10cSrcweir 				if( PARDID->nAdjust )
377cdf0e10cSrcweir 				{
378cdf0e10cSrcweir 					pSet->Put( SvxAdjustItem( SVX_ADJUST_BLOCK, PARDID->nAdjust ));
379cdf0e10cSrcweir 				}
380cdf0e10cSrcweir 				break;
381cdf0e10cSrcweir 			case RTF_QC:
382cdf0e10cSrcweir 				if( PARDID->nAdjust )
383cdf0e10cSrcweir 				{
384cdf0e10cSrcweir 					pSet->Put( SvxAdjustItem( SVX_ADJUST_CENTER, PARDID->nAdjust ));
385cdf0e10cSrcweir 				}
386cdf0e10cSrcweir 				break;
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 			case RTF_FI:
389cdf0e10cSrcweir 				if( PARDID->nLRSpace )
390cdf0e10cSrcweir 				{
391cdf0e10cSrcweir 					SvxLRSpaceItem aLR( GetLRSpace(*pSet, PARDID->nLRSpace ));
392cdf0e10cSrcweir 					sal_uInt16 nSz = 0;
393cdf0e10cSrcweir 					if( -1 != nTokenValue )
394cdf0e10cSrcweir 					{
395cdf0e10cSrcweir 						if( IsCalcValue() )
396cdf0e10cSrcweir 							CalcValue();
397cdf0e10cSrcweir 						nSz = sal_uInt16(nTokenValue);
398cdf0e10cSrcweir 					}
399cdf0e10cSrcweir 					aLR.SetTxtFirstLineOfst( nSz );
400cdf0e10cSrcweir 					pSet->Put( aLR );
401cdf0e10cSrcweir 				}
402cdf0e10cSrcweir 				break;
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 			case RTF_LI:
405cdf0e10cSrcweir 			case RTF_LIN:
406cdf0e10cSrcweir 				if( PARDID->nLRSpace )
407cdf0e10cSrcweir 				{
408cdf0e10cSrcweir 					SvxLRSpaceItem aLR( GetLRSpace(*pSet, PARDID->nLRSpace ));
409cdf0e10cSrcweir 					sal_uInt16 nSz = 0;
410cdf0e10cSrcweir 					if( 0 < nTokenValue )
411cdf0e10cSrcweir 					{
412cdf0e10cSrcweir 						if( IsCalcValue() )
413cdf0e10cSrcweir 							CalcValue();
414cdf0e10cSrcweir 						nSz = sal_uInt16(nTokenValue);
415cdf0e10cSrcweir 					}
416cdf0e10cSrcweir 					aLR.SetTxtLeft( nSz );
417cdf0e10cSrcweir 					pSet->Put( aLR );
418cdf0e10cSrcweir 				}
419cdf0e10cSrcweir 				break;
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 			case RTF_RI:
422cdf0e10cSrcweir 			case RTF_RIN:
423cdf0e10cSrcweir 				if( PARDID->nLRSpace )
424cdf0e10cSrcweir 				{
425cdf0e10cSrcweir 					SvxLRSpaceItem aLR( GetLRSpace(*pSet, PARDID->nLRSpace ));
426cdf0e10cSrcweir 					sal_uInt16 nSz = 0;
427cdf0e10cSrcweir 					if( 0 < nTokenValue )
428cdf0e10cSrcweir 					{
429cdf0e10cSrcweir 						if( IsCalcValue() )
430cdf0e10cSrcweir 							CalcValue();
431cdf0e10cSrcweir 						nSz = sal_uInt16(nTokenValue);
432cdf0e10cSrcweir 					}
433cdf0e10cSrcweir 					aLR.SetRight( nSz );
434cdf0e10cSrcweir 					pSet->Put( aLR );
435cdf0e10cSrcweir 				}
436cdf0e10cSrcweir 				break;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir 			case RTF_SB:
439cdf0e10cSrcweir 				if( PARDID->nULSpace )
440cdf0e10cSrcweir 				{
441cdf0e10cSrcweir 					SvxULSpaceItem aUL( GetULSpace(*pSet, PARDID->nULSpace ));
442cdf0e10cSrcweir 					sal_uInt16 nSz = 0;
443cdf0e10cSrcweir 					if( 0 < nTokenValue )
444cdf0e10cSrcweir 					{
445cdf0e10cSrcweir 						if( IsCalcValue() )
446cdf0e10cSrcweir 							CalcValue();
447cdf0e10cSrcweir 						nSz = sal_uInt16(nTokenValue);
448cdf0e10cSrcweir 					}
449cdf0e10cSrcweir 					aUL.SetUpper( nSz );
450cdf0e10cSrcweir 					pSet->Put( aUL );
451cdf0e10cSrcweir 				}
452cdf0e10cSrcweir 				break;
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 			case RTF_SA:
455cdf0e10cSrcweir 				if( PARDID->nULSpace )
456cdf0e10cSrcweir 				{
457cdf0e10cSrcweir 					SvxULSpaceItem aUL( GetULSpace(*pSet, PARDID->nULSpace ));
458cdf0e10cSrcweir 					sal_uInt16 nSz = 0;
459cdf0e10cSrcweir 					if( 0 < nTokenValue )
460cdf0e10cSrcweir 					{
461cdf0e10cSrcweir 						if( IsCalcValue() )
462cdf0e10cSrcweir 							CalcValue();
463cdf0e10cSrcweir 						nSz = sal_uInt16(nTokenValue);
464cdf0e10cSrcweir 					}
465cdf0e10cSrcweir 					aUL.SetLower( nSz );
466cdf0e10cSrcweir 					pSet->Put( aUL );
467cdf0e10cSrcweir 				}
468cdf0e10cSrcweir 				break;
469cdf0e10cSrcweir 
470cdf0e10cSrcweir 			case RTF_SLMULT:
471cdf0e10cSrcweir 				if( PARDID->nLinespacing && 1 == nTokenValue )
472cdf0e10cSrcweir 				{
473cdf0e10cSrcweir 					// dann wird auf mehrzeilig umgeschaltet!
474cdf0e10cSrcweir 					SvxLineSpacingItem aLSpace( GetLineSpacing( *pSet,
475cdf0e10cSrcweir 												PARDID->nLinespacing, sal_False ));
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 					// wieviel bekommt man aus dem LineHeight Wert heraus
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 					// Proportionale-Groesse:
480cdf0e10cSrcweir 					// D.H. das Verhaeltnis ergibt sich aus ( n / 240 ) Twips
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 					nTokenValue = 240;
483cdf0e10cSrcweir 					if( IsCalcValue() )
484cdf0e10cSrcweir 						CalcValue();
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 					nTokenValue = short( 100L * aLSpace.GetLineHeight()
487cdf0e10cSrcweir 											/ long( nTokenValue ) );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 					if( nTokenValue > 200 )		// Datenwert fuer PropLnSp
490cdf0e10cSrcweir 						nTokenValue = 200;		// ist ein sal_uInt8 !!!
491cdf0e10cSrcweir 
492cdf0e10cSrcweir 					aLSpace.SetPropLineSpace( (const sal_uInt8)nTokenValue );
493cdf0e10cSrcweir 					aLSpace.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 					pSet->Put( aLSpace );
496cdf0e10cSrcweir 				}
497cdf0e10cSrcweir 				break;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 			case RTF_SL:
500cdf0e10cSrcweir 				if( PARDID->nLinespacing )
501cdf0e10cSrcweir 				{
502cdf0e10cSrcweir 					// errechne das Verhaeltnis aus dem default Font zu der
503cdf0e10cSrcweir 					// Size Angabe. Der Abstand besteht aus der Zeilenhoehe
504cdf0e10cSrcweir 					// (100%) und dem Leerraum ueber der Zeile (20%).
505cdf0e10cSrcweir 					SvxLineSpacingItem aLSpace(0, PARDID->nLinespacing);
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 					nTokenValue = !bTokenHasValue ? 0 : nTokenValue;
508cdf0e10cSrcweir 					if (1000 == nTokenValue )
509cdf0e10cSrcweir 						nTokenValue = 240;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 					SvxLineSpace eLnSpc;
512cdf0e10cSrcweir 					if (nTokenValue < 0)
513cdf0e10cSrcweir 					{
514cdf0e10cSrcweir 						eLnSpc = SVX_LINE_SPACE_FIX;
515cdf0e10cSrcweir 						nTokenValue = -nTokenValue;
516cdf0e10cSrcweir 					}
517cdf0e10cSrcweir 					else if (nTokenValue == 0)
518cdf0e10cSrcweir                     {
519cdf0e10cSrcweir                         //if \sl0 is used, the line spacing is automatically
520cdf0e10cSrcweir                         //determined
521cdf0e10cSrcweir                         eLnSpc = SVX_LINE_SPACE_AUTO;
522cdf0e10cSrcweir                     }
523cdf0e10cSrcweir                     else
524cdf0e10cSrcweir 						eLnSpc = SVX_LINE_SPACE_MIN;
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 					if (IsCalcValue())
527cdf0e10cSrcweir 						CalcValue();
528cdf0e10cSrcweir 
529cdf0e10cSrcweir                     if (eLnSpc != SVX_LINE_SPACE_AUTO)
530cdf0e10cSrcweir 					    aLSpace.SetLineHeight( (const sal_uInt16)nTokenValue );
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 					aLSpace.GetLineSpaceRule() = eLnSpc;
533cdf0e10cSrcweir 					pSet->Put(aLSpace);
534cdf0e10cSrcweir 				}
535cdf0e10cSrcweir 				break;
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 			case RTF_NOCWRAP:
538cdf0e10cSrcweir 				if( PARDID->nForbRule )
539cdf0e10cSrcweir 				{
540cdf0e10cSrcweir 					pSet->Put( SvxForbiddenRuleItem( sal_False,
541cdf0e10cSrcweir 													PARDID->nForbRule ));
542cdf0e10cSrcweir 				}
543cdf0e10cSrcweir 				break;
544cdf0e10cSrcweir 			case RTF_NOOVERFLOW:
545cdf0e10cSrcweir 				if( PARDID->nHangPunct )
546cdf0e10cSrcweir 				{
547cdf0e10cSrcweir 					pSet->Put( SvxHangingPunctuationItem( sal_False,
548cdf0e10cSrcweir 													PARDID->nHangPunct ));
549cdf0e10cSrcweir 				}
550cdf0e10cSrcweir 				break;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 			case RTF_ASPALPHA:
553cdf0e10cSrcweir 				if( PARDID->nScriptSpace )
554cdf0e10cSrcweir 				{
555cdf0e10cSrcweir 					pSet->Put( SvxScriptSpaceItem( sal_True,
556cdf0e10cSrcweir 												PARDID->nScriptSpace ));
557cdf0e10cSrcweir 				}
558cdf0e10cSrcweir 				break;
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 			case RTF_FAFIXED:
561cdf0e10cSrcweir 			case RTF_FAAUTO:	nFontAlign = SvxParaVertAlignItem::AUTOMATIC;
562cdf0e10cSrcweir 								goto SET_FONTALIGNMENT;
563cdf0e10cSrcweir 			case RTF_FAHANG:	nFontAlign = SvxParaVertAlignItem::TOP;
564cdf0e10cSrcweir 								goto SET_FONTALIGNMENT;
565cdf0e10cSrcweir 			case RTF_FAVAR:     nFontAlign = SvxParaVertAlignItem::BOTTOM;
566cdf0e10cSrcweir 								goto SET_FONTALIGNMENT;
567cdf0e10cSrcweir 			case RTF_FACENTER:  nFontAlign = SvxParaVertAlignItem::CENTER;
568cdf0e10cSrcweir 								goto SET_FONTALIGNMENT;
569cdf0e10cSrcweir 			case RTF_FAROMAN:   nFontAlign = SvxParaVertAlignItem::BASELINE;
570cdf0e10cSrcweir 								goto SET_FONTALIGNMENT;
571cdf0e10cSrcweir SET_FONTALIGNMENT:
572cdf0e10cSrcweir 			if( PARDID->nFontAlign )
573cdf0e10cSrcweir 			{
574cdf0e10cSrcweir 				pSet->Put( SvxParaVertAlignItem( nFontAlign,
575cdf0e10cSrcweir 												PARDID->nFontAlign ));
576cdf0e10cSrcweir 			}
577cdf0e10cSrcweir 			break;
578cdf0e10cSrcweir 
579cdf0e10cSrcweir /*  */
580cdf0e10cSrcweir 			case RTF_B:
581cdf0e10cSrcweir 			case RTF_AB:
582cdf0e10cSrcweir 				if( IsAttrSttPos() )	// nicht im Textfluss ?
583cdf0e10cSrcweir 				{
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 					SvxWeightItem aTmpItem(
586cdf0e10cSrcweir 									nTokenValue ? WEIGHT_BOLD : WEIGHT_NORMAL,
587cdf0e10cSrcweir 									SID_ATTR_CHAR_WEIGHT );
588cdf0e10cSrcweir 					SetScriptAttr( eCharType, *pSet, aTmpItem);
589cdf0e10cSrcweir 				}
590cdf0e10cSrcweir 				break;
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 			case RTF_CAPS:
593cdf0e10cSrcweir 			case RTF_SCAPS:
594cdf0e10cSrcweir 				if( PLAINID->nCaseMap &&
595cdf0e10cSrcweir 					IsAttrSttPos() )		// nicht im Textfluss ?
596cdf0e10cSrcweir 				{
597cdf0e10cSrcweir 					SvxCaseMap eCaseMap;
598cdf0e10cSrcweir 					if( !nTokenValue )
599cdf0e10cSrcweir 						eCaseMap = SVX_CASEMAP_NOT_MAPPED;
600cdf0e10cSrcweir 					else if( RTF_CAPS == nToken )
601cdf0e10cSrcweir 						eCaseMap = SVX_CASEMAP_VERSALIEN;
602cdf0e10cSrcweir 					else
603cdf0e10cSrcweir 						eCaseMap = SVX_CASEMAP_KAPITAELCHEN;
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 					pSet->Put( SvxCaseMapItem( eCaseMap, PLAINID->nCaseMap ));
606cdf0e10cSrcweir 				}
607cdf0e10cSrcweir 				break;
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 			case RTF_DN:
610cdf0e10cSrcweir 			case RTF_SUB:
611cdf0e10cSrcweir 				if( PLAINID->nEscapement )
612cdf0e10cSrcweir 				{
613cdf0e10cSrcweir 					const sal_uInt16 nEsc = PLAINID->nEscapement;
614cdf0e10cSrcweir 					if( -1 == nTokenValue || RTF_SUB == nToken )
615cdf0e10cSrcweir 						nTokenValue = 6;
616cdf0e10cSrcweir 					if( IsCalcValue() )
617cdf0e10cSrcweir 						CalcValue();
618cdf0e10cSrcweir 					const SvxEscapementItem& rOld = GetEscapement( *pSet, nEsc, sal_False );
619cdf0e10cSrcweir 					short nEs;
620cdf0e10cSrcweir 					sal_uInt8 nProp;
621cdf0e10cSrcweir 					if( DFLT_ESC_AUTO_SUPER == rOld.GetEsc() )
622cdf0e10cSrcweir 					{
623cdf0e10cSrcweir 						nEs = DFLT_ESC_AUTO_SUB;
624cdf0e10cSrcweir 						nProp = rOld.GetProp();
625cdf0e10cSrcweir 					}
626cdf0e10cSrcweir 					else
627cdf0e10cSrcweir 					{
628cdf0e10cSrcweir 						nEs = (short)-nTokenValue;
629cdf0e10cSrcweir 						nProp = (nToken == RTF_SUB) ? DFLT_ESC_PROP : 100;
630cdf0e10cSrcweir 					}
631cdf0e10cSrcweir 					pSet->Put( SvxEscapementItem( nEs, nProp, nEsc ));
632cdf0e10cSrcweir 				}
633cdf0e10cSrcweir 				break;
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 			case RTF_NOSUPERSUB:
636cdf0e10cSrcweir 				if( PLAINID->nEscapement )
637cdf0e10cSrcweir 				{
638cdf0e10cSrcweir 					const sal_uInt16 nEsc = PLAINID->nEscapement;
639cdf0e10cSrcweir 					pSet->Put( SvxEscapementItem( nEsc ));
640cdf0e10cSrcweir 				}
641cdf0e10cSrcweir 				break;
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 			case RTF_EXPND:
644cdf0e10cSrcweir 				if( PLAINID->nKering )
645cdf0e10cSrcweir 				{
646cdf0e10cSrcweir 					if( -1 == nTokenValue )
647cdf0e10cSrcweir 						nTokenValue = 0;
648cdf0e10cSrcweir 					else
649cdf0e10cSrcweir 						nTokenValue *= 5;
650cdf0e10cSrcweir 					if( IsCalcValue() )
651cdf0e10cSrcweir 						CalcValue();
652cdf0e10cSrcweir 					pSet->Put( SvxKerningItem( (short)nTokenValue, PLAINID->nKering ));
653cdf0e10cSrcweir 				}
654cdf0e10cSrcweir 				break;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 			case RTF_KERNING:
657cdf0e10cSrcweir 				if( PLAINID->nAutoKerning )
658cdf0e10cSrcweir 				{
659cdf0e10cSrcweir 					if( -1 == nTokenValue )
660cdf0e10cSrcweir 						nTokenValue = 0;
661cdf0e10cSrcweir 					else
662cdf0e10cSrcweir 						nTokenValue *= 10;
663cdf0e10cSrcweir 					if( IsCalcValue() )
664cdf0e10cSrcweir 						CalcValue();
665cdf0e10cSrcweir 					pSet->Put( SvxAutoKernItem( 0 != nTokenValue,
666cdf0e10cSrcweir 												PLAINID->nAutoKerning ));
667cdf0e10cSrcweir 				}
668cdf0e10cSrcweir 				break;
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 			case RTF_EXPNDTW:
671cdf0e10cSrcweir 				if( PLAINID->nKering )
672cdf0e10cSrcweir 				{
673cdf0e10cSrcweir 					if( -1 == nTokenValue )
674cdf0e10cSrcweir 						nTokenValue = 0;
675cdf0e10cSrcweir 					if( IsCalcValue() )
676cdf0e10cSrcweir 						CalcValue();
677cdf0e10cSrcweir 					pSet->Put( SvxKerningItem( (short)nTokenValue, PLAINID->nKering ));
678cdf0e10cSrcweir 				}
679cdf0e10cSrcweir 				break;
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 			case RTF_F:
682cdf0e10cSrcweir 			case RTF_AF:
683cdf0e10cSrcweir 				{
684cdf0e10cSrcweir 					const Font& rSVFont = GetFont( sal_uInt16(nTokenValue) );
685cdf0e10cSrcweir 					SvxFontItem aTmpItem( rSVFont.GetFamily(),
686cdf0e10cSrcweir 									rSVFont.GetName(), rSVFont.GetStyleName(),
687cdf0e10cSrcweir 									rSVFont.GetPitch(), rSVFont.GetCharSet(),
688cdf0e10cSrcweir 									SID_ATTR_CHAR_FONT );
689cdf0e10cSrcweir 					SetScriptAttr( eCharType, *pSet, aTmpItem );
690cdf0e10cSrcweir 					if( RTF_F == nToken )
691cdf0e10cSrcweir 					{
692cdf0e10cSrcweir 						SetEncoding( rSVFont.GetCharSet() );
693cdf0e10cSrcweir 						RereadLookahead();
694cdf0e10cSrcweir 					}
695cdf0e10cSrcweir 				}
696cdf0e10cSrcweir 				break;
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 			case RTF_FS:
699cdf0e10cSrcweir 			case RTF_AFS:
700cdf0e10cSrcweir 				{
701cdf0e10cSrcweir 					if( -1 == nTokenValue )
702cdf0e10cSrcweir 						nTokenValue = 240;
703cdf0e10cSrcweir 					else
704cdf0e10cSrcweir 						nTokenValue *= 10;
705cdf0e10cSrcweir // #i66167#
706cdf0e10cSrcweir // for the SwRTFParser 'IsCalcValue' will be false and for the EditRTFParser
707cdf0e10cSrcweir // the converiosn takes now place in EditRTFParser since for other reasons
708cdf0e10cSrcweir // the wrong MapUnit might still be use there
709cdf0e10cSrcweir //                   if( IsCalcValue() )
710cdf0e10cSrcweir //                       CalcValue();
711cdf0e10cSrcweir 					SvxFontHeightItem aTmpItem(
712cdf0e10cSrcweir 							(const sal_uInt16)nTokenValue, 100,
713cdf0e10cSrcweir 							SID_ATTR_CHAR_FONTHEIGHT );
714cdf0e10cSrcweir 					SetScriptAttr( eCharType, *pSet, aTmpItem );
715cdf0e10cSrcweir 				}
716cdf0e10cSrcweir 				break;
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 			case RTF_I:
719cdf0e10cSrcweir 			case RTF_AI:
720cdf0e10cSrcweir 				if( IsAttrSttPos() )		// nicht im Textfluss ?
721cdf0e10cSrcweir 				{
722cdf0e10cSrcweir 					SvxPostureItem aTmpItem(
723cdf0e10cSrcweir 							        nTokenValue ? ITALIC_NORMAL : ITALIC_NONE,
724cdf0e10cSrcweir 							        SID_ATTR_CHAR_POSTURE );
725cdf0e10cSrcweir 					SetScriptAttr( eCharType, *pSet, aTmpItem );
726cdf0e10cSrcweir 				}
727cdf0e10cSrcweir 				break;
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 			case RTF_OUTL:
730cdf0e10cSrcweir 				if( PLAINID->nContour &&
731cdf0e10cSrcweir 					IsAttrSttPos() )		// nicht im Textfluss ?
732cdf0e10cSrcweir 				{
733cdf0e10cSrcweir 					pSet->Put( SvxContourItem( nTokenValue ? sal_True : sal_False,
734cdf0e10cSrcweir 								PLAINID->nContour ));
735cdf0e10cSrcweir 				}
736cdf0e10cSrcweir 				break;
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 			case RTF_SHAD:
739cdf0e10cSrcweir 				if( PLAINID->nShadowed &&
740cdf0e10cSrcweir 					IsAttrSttPos() )		// nicht im Textfluss ?
741cdf0e10cSrcweir 				{
742cdf0e10cSrcweir 					pSet->Put( SvxShadowedItem( nTokenValue ? sal_True : sal_False,
743cdf0e10cSrcweir 								PLAINID->nShadowed ));
744cdf0e10cSrcweir 				}
745cdf0e10cSrcweir 				break;
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 			case RTF_STRIKE:
748cdf0e10cSrcweir 				if( PLAINID->nCrossedOut &&
749cdf0e10cSrcweir 					IsAttrSttPos() )		// nicht im Textfluss ?
750cdf0e10cSrcweir 				{
751cdf0e10cSrcweir 					pSet->Put( SvxCrossedOutItem(
752cdf0e10cSrcweir 						nTokenValue ? STRIKEOUT_SINGLE : STRIKEOUT_NONE,
753cdf0e10cSrcweir 						PLAINID->nCrossedOut ));
754cdf0e10cSrcweir 				}
755cdf0e10cSrcweir 				break;
756cdf0e10cSrcweir 
757cdf0e10cSrcweir 			case RTF_STRIKED:
758cdf0e10cSrcweir 				if( PLAINID->nCrossedOut )		// nicht im Textfluss ?
759cdf0e10cSrcweir 				{
760cdf0e10cSrcweir 					pSet->Put( SvxCrossedOutItem(
761cdf0e10cSrcweir 						nTokenValue ? STRIKEOUT_DOUBLE : STRIKEOUT_NONE,
762cdf0e10cSrcweir 						PLAINID->nCrossedOut ));
763cdf0e10cSrcweir 				}
764cdf0e10cSrcweir 				break;
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 			case RTF_UL:
767cdf0e10cSrcweir 				if( !IsAttrSttPos() )
768cdf0e10cSrcweir 					break;
769cdf0e10cSrcweir 				eUnderline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
770cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 			case RTF_ULD:
773cdf0e10cSrcweir 				eUnderline = UNDERLINE_DOTTED;
774cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
775cdf0e10cSrcweir 			case RTF_ULDASH:
776cdf0e10cSrcweir 				eUnderline = UNDERLINE_DASH;
777cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
778cdf0e10cSrcweir 			case RTF_ULDASHD:
779cdf0e10cSrcweir 				eUnderline = UNDERLINE_DASHDOT;
780cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
781cdf0e10cSrcweir 			case RTF_ULDASHDD:
782cdf0e10cSrcweir 				eUnderline = UNDERLINE_DASHDOTDOT;
783cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
784cdf0e10cSrcweir 			case RTF_ULDB:
785cdf0e10cSrcweir 				eUnderline = UNDERLINE_DOUBLE;
786cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
787cdf0e10cSrcweir 			case RTF_ULNONE:
788cdf0e10cSrcweir 				eUnderline = UNDERLINE_NONE;
789cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
790cdf0e10cSrcweir 			case RTF_ULTH:
791cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLD;
792cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
793cdf0e10cSrcweir 			case RTF_ULWAVE:
794cdf0e10cSrcweir 				eUnderline = UNDERLINE_WAVE;
795cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
796cdf0e10cSrcweir 			case RTF_ULTHD:
797cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLDDOTTED;
798cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
799cdf0e10cSrcweir 			case RTF_ULTHDASH:
800cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLDDASH;
801cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
802cdf0e10cSrcweir 			case RTF_ULLDASH:
803cdf0e10cSrcweir 				eUnderline = UNDERLINE_LONGDASH;
804cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
805cdf0e10cSrcweir 			case RTF_ULTHLDASH:
806cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLDLONGDASH;
807cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
808cdf0e10cSrcweir 			case RTF_ULTHDASHD:
809cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLDDASHDOT;
810cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
811cdf0e10cSrcweir 			case RTF_ULTHDASHDD:
812cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLDDASHDOTDOT;
813cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
814cdf0e10cSrcweir 			case RTF_ULHWAVE:
815cdf0e10cSrcweir 				eUnderline = UNDERLINE_BOLDWAVE;
816cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
817cdf0e10cSrcweir 			case RTF_ULULDBWAVE:
818cdf0e10cSrcweir 				eUnderline = UNDERLINE_DOUBLEWAVE;
819cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 			case RTF_ULW:
822cdf0e10cSrcweir 				eUnderline = UNDERLINE_SINGLE;
823cdf0e10cSrcweir 
824cdf0e10cSrcweir 				if( PLAINID->nWordlineMode )
825cdf0e10cSrcweir 				{
826cdf0e10cSrcweir 					pSet->Put( SvxWordLineModeItem( sal_True, PLAINID->nWordlineMode ));
827cdf0e10cSrcweir 				}
828cdf0e10cSrcweir 				goto ATTR_SETUNDERLINE;
829cdf0e10cSrcweir 
830cdf0e10cSrcweir ATTR_SETUNDERLINE:
831cdf0e10cSrcweir 				if( PLAINID->nUnderline )
832cdf0e10cSrcweir 				{
833cdf0e10cSrcweir 					pSet->Put( SvxUnderlineItem( eUnderline, PLAINID->nUnderline ));
834cdf0e10cSrcweir 				}
835cdf0e10cSrcweir 				break;
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 			case RTF_ULC:
838cdf0e10cSrcweir 				if( PLAINID->nUnderline )
839cdf0e10cSrcweir 				{
840cdf0e10cSrcweir 					SvxUnderlineItem aUL( UNDERLINE_SINGLE, PLAINID->nUnderline );
841cdf0e10cSrcweir 					const SfxPoolItem* pItem;
842cdf0e10cSrcweir 					if( SFX_ITEM_SET == pSet->GetItemState(
843cdf0e10cSrcweir 						PLAINID->nUnderline, sal_False, &pItem ) )
844cdf0e10cSrcweir 					{
845cdf0e10cSrcweir 						// is switched off ?
846cdf0e10cSrcweir 						if( UNDERLINE_NONE ==
847cdf0e10cSrcweir 							((SvxUnderlineItem*)pItem)->GetLineStyle() )
848cdf0e10cSrcweir 							break;
849cdf0e10cSrcweir 						aUL = *(SvxUnderlineItem*)pItem;
850cdf0e10cSrcweir 					}
851cdf0e10cSrcweir 					else
852cdf0e10cSrcweir 						aUL = (const SvxUnderlineItem&)pSet->Get( PLAINID->nUnderline, sal_False );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir 					if( UNDERLINE_NONE == aUL.GetLineStyle() )
855cdf0e10cSrcweir 						aUL.SetLineStyle( UNDERLINE_SINGLE );
856cdf0e10cSrcweir 					aUL.SetColor( GetColor( sal_uInt16(nTokenValue) ));
857cdf0e10cSrcweir 					pSet->Put( aUL );
858cdf0e10cSrcweir 				}
859cdf0e10cSrcweir 				break;
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 			case RTF_OL:
862cdf0e10cSrcweir 				if( !IsAttrSttPos() )
863cdf0e10cSrcweir 					break;
864cdf0e10cSrcweir 				eOverline = nTokenValue ? UNDERLINE_SINGLE : UNDERLINE_NONE;
865cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 			case RTF_OLD:
868cdf0e10cSrcweir 				eOverline = UNDERLINE_DOTTED;
869cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
870cdf0e10cSrcweir 			case RTF_OLDASH:
871cdf0e10cSrcweir 				eOverline = UNDERLINE_DASH;
872cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
873cdf0e10cSrcweir 			case RTF_OLDASHD:
874cdf0e10cSrcweir 				eOverline = UNDERLINE_DASHDOT;
875cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
876cdf0e10cSrcweir 			case RTF_OLDASHDD:
877cdf0e10cSrcweir 				eOverline = UNDERLINE_DASHDOTDOT;
878cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
879cdf0e10cSrcweir 			case RTF_OLDB:
880cdf0e10cSrcweir 				eOverline = UNDERLINE_DOUBLE;
881cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
882cdf0e10cSrcweir 			case RTF_OLNONE:
883cdf0e10cSrcweir 				eOverline = UNDERLINE_NONE;
884cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
885cdf0e10cSrcweir 			case RTF_OLTH:
886cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLD;
887cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
888cdf0e10cSrcweir 			case RTF_OLWAVE:
889cdf0e10cSrcweir 				eOverline = UNDERLINE_WAVE;
890cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
891cdf0e10cSrcweir 			case RTF_OLTHD:
892cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLDDOTTED;
893cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
894cdf0e10cSrcweir 			case RTF_OLTHDASH:
895cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLDDASH;
896cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
897cdf0e10cSrcweir 			case RTF_OLLDASH:
898cdf0e10cSrcweir 				eOverline = UNDERLINE_LONGDASH;
899cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
900cdf0e10cSrcweir 			case RTF_OLTHLDASH:
901cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLDLONGDASH;
902cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
903cdf0e10cSrcweir 			case RTF_OLTHDASHD:
904cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLDDASHDOT;
905cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
906cdf0e10cSrcweir 			case RTF_OLTHDASHDD:
907cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLDDASHDOTDOT;
908cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
909cdf0e10cSrcweir 			case RTF_OLHWAVE:
910cdf0e10cSrcweir 				eOverline = UNDERLINE_BOLDWAVE;
911cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
912cdf0e10cSrcweir 			case RTF_OLOLDBWAVE:
913cdf0e10cSrcweir 				eOverline = UNDERLINE_DOUBLEWAVE;
914cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 			case RTF_OLW:
917cdf0e10cSrcweir 				eOverline = UNDERLINE_SINGLE;
918cdf0e10cSrcweir 
919cdf0e10cSrcweir 				if( PLAINID->nWordlineMode )
920cdf0e10cSrcweir 				{
921cdf0e10cSrcweir 					pSet->Put( SvxWordLineModeItem( sal_True, PLAINID->nWordlineMode ));
922cdf0e10cSrcweir 				}
923cdf0e10cSrcweir 				goto ATTR_SETOVERLINE;
924cdf0e10cSrcweir 
925cdf0e10cSrcweir ATTR_SETOVERLINE:
926cdf0e10cSrcweir 				if( PLAINID->nUnderline )
927cdf0e10cSrcweir 				{
928cdf0e10cSrcweir 					pSet->Put( SvxOverlineItem( eOverline, PLAINID->nOverline ));
929cdf0e10cSrcweir 				}
930cdf0e10cSrcweir 				break;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 			case RTF_OLC:
933cdf0e10cSrcweir 				if( PLAINID->nOverline )
934cdf0e10cSrcweir 				{
935cdf0e10cSrcweir 					SvxOverlineItem aOL( UNDERLINE_SINGLE, PLAINID->nOverline );
936cdf0e10cSrcweir 					const SfxPoolItem* pItem;
937cdf0e10cSrcweir 					if( SFX_ITEM_SET == pSet->GetItemState(
938cdf0e10cSrcweir 						PLAINID->nOverline, sal_False, &pItem ) )
939cdf0e10cSrcweir 					{
940cdf0e10cSrcweir 						// is switched off ?
941cdf0e10cSrcweir 						if( UNDERLINE_NONE ==
942cdf0e10cSrcweir 							((SvxOverlineItem*)pItem)->GetLineStyle() )
943cdf0e10cSrcweir 							break;
944cdf0e10cSrcweir 						aOL = *(SvxOverlineItem*)pItem;
945cdf0e10cSrcweir 					}
946cdf0e10cSrcweir 					else
947cdf0e10cSrcweir 						aOL = (const SvxOverlineItem&)pSet->Get( PLAINID->nUnderline, sal_False );
948cdf0e10cSrcweir 
949cdf0e10cSrcweir 					if( UNDERLINE_NONE == aOL.GetLineStyle() )
950cdf0e10cSrcweir 						aOL.SetLineStyle( UNDERLINE_SINGLE );
951cdf0e10cSrcweir 					aOL.SetColor( GetColor( sal_uInt16(nTokenValue) ));
952cdf0e10cSrcweir 					pSet->Put( aOL );
953cdf0e10cSrcweir 				}
954cdf0e10cSrcweir 				break;
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 			case RTF_UP:
957cdf0e10cSrcweir 			case RTF_SUPER:
958cdf0e10cSrcweir 				if( PLAINID->nEscapement )
959cdf0e10cSrcweir 				{
960cdf0e10cSrcweir 					const sal_uInt16 nEsc = PLAINID->nEscapement;
961cdf0e10cSrcweir 					if( -1 == nTokenValue || RTF_SUPER == nToken )
962cdf0e10cSrcweir 						nTokenValue = 6;
963cdf0e10cSrcweir 					if( IsCalcValue() )
964cdf0e10cSrcweir 						CalcValue();
965cdf0e10cSrcweir 					const SvxEscapementItem& rOld = GetEscapement( *pSet, nEsc, sal_False );
966cdf0e10cSrcweir 					short nEs;
967cdf0e10cSrcweir 					sal_uInt8 nProp;
968cdf0e10cSrcweir 					if( DFLT_ESC_AUTO_SUB == rOld.GetEsc() )
969cdf0e10cSrcweir 					{
970cdf0e10cSrcweir 						nEs = DFLT_ESC_AUTO_SUPER;
971cdf0e10cSrcweir 						nProp = rOld.GetProp();
972cdf0e10cSrcweir 					}
973cdf0e10cSrcweir 					else
974cdf0e10cSrcweir 					{
975cdf0e10cSrcweir 						nEs = (short)nTokenValue;
976cdf0e10cSrcweir 						nProp = (nToken == RTF_SUPER) ? DFLT_ESC_PROP : 100;
977cdf0e10cSrcweir 					}
978cdf0e10cSrcweir 					pSet->Put( SvxEscapementItem( nEs, nProp, nEsc ));
979cdf0e10cSrcweir 				}
980cdf0e10cSrcweir 				break;
981cdf0e10cSrcweir 
982cdf0e10cSrcweir 			case RTF_CF:
983cdf0e10cSrcweir 				if( PLAINID->nColor )
984cdf0e10cSrcweir 				{
985cdf0e10cSrcweir 					pSet->Put( SvxColorItem( GetColor( sal_uInt16(nTokenValue) ),
986cdf0e10cSrcweir 								PLAINID->nColor ));
987cdf0e10cSrcweir 				}
988cdf0e10cSrcweir 				break;
989cdf0e10cSrcweir #if 0
990cdf0e10cSrcweir 			//#i12501# While cb is clearly documented in the rtf spec, word
991cdf0e10cSrcweir             //doesn't accept it at all
992cdf0e10cSrcweir 			case RTF_CB:
993cdf0e10cSrcweir 				if( PLAINID->nBgColor )
994cdf0e10cSrcweir 				{
995cdf0e10cSrcweir 					pSet->Put( SvxBrushItem( GetColor( sal_uInt16(nTokenValue) ),
996cdf0e10cSrcweir 								PLAINID->nBgColor ));
997cdf0e10cSrcweir 				}
998cdf0e10cSrcweir 				break;
999cdf0e10cSrcweir #endif
1000cdf0e10cSrcweir 			case RTF_LANG:
1001cdf0e10cSrcweir 				if( PLAINID->nLanguage )
1002cdf0e10cSrcweir 				{
1003cdf0e10cSrcweir 					pSet->Put( SvxLanguageItem( (LanguageType)nTokenValue,
1004cdf0e10cSrcweir 								PLAINID->nLanguage ));
1005cdf0e10cSrcweir 				}
1006cdf0e10cSrcweir 				break;
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir 			case RTF_LANGFE:
1009cdf0e10cSrcweir 				if( PLAINID->nCJKLanguage )
1010cdf0e10cSrcweir 				{
1011cdf0e10cSrcweir 					pSet->Put( SvxLanguageItem( (LanguageType)nTokenValue,
1012cdf0e10cSrcweir 												PLAINID->nCJKLanguage ));
1013cdf0e10cSrcweir 				}
1014cdf0e10cSrcweir 				break;
1015cdf0e10cSrcweir 			case RTF_ALANG:
1016cdf0e10cSrcweir 				{
1017cdf0e10cSrcweir 					SvxLanguageItem aTmpItem( (LanguageType)nTokenValue,
1018cdf0e10cSrcweir 									SID_ATTR_CHAR_LANGUAGE );
1019cdf0e10cSrcweir 					SetScriptAttr( eCharType, *pSet, aTmpItem );
1020cdf0e10cSrcweir 				}
1021cdf0e10cSrcweir 				break;
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 			case RTF_RTLCH:
1024cdf0e10cSrcweir                 bIsLeftToRightDef = sal_False;
1025cdf0e10cSrcweir                 break;
1026cdf0e10cSrcweir 			case RTF_LTRCH:
1027cdf0e10cSrcweir                 bIsLeftToRightDef = sal_True;
1028cdf0e10cSrcweir                 break;
1029cdf0e10cSrcweir             case RTF_RTLPAR:
1030cdf0e10cSrcweir                 if (PARDID->nDirection)
1031cdf0e10cSrcweir                 {
1032cdf0e10cSrcweir                     pSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP,
1033cdf0e10cSrcweir                         PARDID->nDirection));
1034cdf0e10cSrcweir                 }
1035cdf0e10cSrcweir                 break;
1036cdf0e10cSrcweir             case RTF_LTRPAR:
1037cdf0e10cSrcweir                 if (PARDID->nDirection)
1038cdf0e10cSrcweir                 {
1039cdf0e10cSrcweir                     pSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP,
1040cdf0e10cSrcweir                         PARDID->nDirection));
1041cdf0e10cSrcweir                 }
1042cdf0e10cSrcweir                 break;
1043cdf0e10cSrcweir 			case RTF_LOCH:  	eCharType = LOW_CHARTYPE;			break;
1044cdf0e10cSrcweir 			case RTF_HICH:  	eCharType = HIGH_CHARTYPE;			break;
1045cdf0e10cSrcweir 			case RTF_DBCH:  	eCharType = DOUBLEBYTE_CHARTYPE;	break;
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir 			case RTF_ACCNONE:
1049cdf0e10cSrcweir 				eEmphasis = EMPHASISMARK_NONE;
1050cdf0e10cSrcweir 				goto ATTR_SETEMPHASIS;
1051cdf0e10cSrcweir 			case RTF_ACCDOT:
1052cdf0e10cSrcweir 				eEmphasis = EMPHASISMARK_DOTS_ABOVE;
1053cdf0e10cSrcweir 				goto ATTR_SETEMPHASIS;
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 			case RTF_ACCCOMMA:
1056cdf0e10cSrcweir 				eEmphasis = EMPHASISMARK_SIDE_DOTS;
1057cdf0e10cSrcweir ATTR_SETEMPHASIS:
1058cdf0e10cSrcweir 				if( PLAINID->nEmphasis )
1059cdf0e10cSrcweir 				{
1060cdf0e10cSrcweir 					pSet->Put( SvxEmphasisMarkItem( eEmphasis,
1061cdf0e10cSrcweir 											   		PLAINID->nEmphasis ));
1062cdf0e10cSrcweir 				}
1063cdf0e10cSrcweir 				break;
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir 			case RTF_TWOINONE:
1066cdf0e10cSrcweir 				if( PLAINID->nTwoLines )
1067cdf0e10cSrcweir 				{
1068cdf0e10cSrcweir 					sal_Unicode cStt, cEnd;
1069cdf0e10cSrcweir 					switch ( nTokenValue )
1070cdf0e10cSrcweir 					{
1071cdf0e10cSrcweir 					case 1:	cStt = '(', cEnd = ')';	break;
1072cdf0e10cSrcweir 					case 2:	cStt = '[', cEnd = ']';	break;
1073cdf0e10cSrcweir 					case 3:	cStt = '<', cEnd = '>';	break;
1074cdf0e10cSrcweir 					case 4:	cStt = '{', cEnd = '}';	break;
1075cdf0e10cSrcweir 					default: cStt = 0, cEnd = 0; break;
1076cdf0e10cSrcweir 					}
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 					pSet->Put( SvxTwoLinesItem( sal_True, cStt, cEnd,
1079cdf0e10cSrcweir 											   		PLAINID->nTwoLines ));
1080cdf0e10cSrcweir 				}
1081cdf0e10cSrcweir 				break;
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 			case RTF_CHARSCALEX :
1084cdf0e10cSrcweir 				if (PLAINID->nCharScaleX)
1085cdf0e10cSrcweir 				{
1086cdf0e10cSrcweir                     //i21372
1087cdf0e10cSrcweir                     if (nTokenValue < 1 || nTokenValue > 600)
1088cdf0e10cSrcweir                         nTokenValue = 100;
1089cdf0e10cSrcweir 					pSet->Put( SvxCharScaleWidthItem( sal_uInt16(nTokenValue),
1090cdf0e10cSrcweir 											   		PLAINID->nCharScaleX ));
1091cdf0e10cSrcweir 				}
1092cdf0e10cSrcweir 				break;
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 			case RTF_HORZVERT:
1095cdf0e10cSrcweir 				if( PLAINID->nHorzVert )
1096cdf0e10cSrcweir 				{
1097cdf0e10cSrcweir                     // RTF knows only 90deg
1098cdf0e10cSrcweir 					pSet->Put( SvxCharRotateItem( 900, 1 == nTokenValue,
1099cdf0e10cSrcweir 											   		PLAINID->nHorzVert ));
1100cdf0e10cSrcweir 				}
1101cdf0e10cSrcweir 				break;
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 			case RTF_EMBO:
1104cdf0e10cSrcweir 				if (PLAINID->nRelief)
1105cdf0e10cSrcweir 				{
1106cdf0e10cSrcweir 					pSet->Put(SvxCharReliefItem(RELIEF_EMBOSSED,
1107cdf0e10cSrcweir                         PLAINID->nRelief));
1108cdf0e10cSrcweir 				}
1109cdf0e10cSrcweir 				break;
1110cdf0e10cSrcweir 			case RTF_IMPR:
1111cdf0e10cSrcweir 				if (PLAINID->nRelief)
1112cdf0e10cSrcweir 				{
1113cdf0e10cSrcweir 					pSet->Put(SvxCharReliefItem(RELIEF_ENGRAVED,
1114cdf0e10cSrcweir                         PLAINID->nRelief));
1115cdf0e10cSrcweir 				}
1116cdf0e10cSrcweir 				break;
1117cdf0e10cSrcweir 			case RTF_V:
1118cdf0e10cSrcweir 				if (PLAINID->nHidden)
1119cdf0e10cSrcweir                 {
1120cdf0e10cSrcweir 					pSet->Put(SvxCharHiddenItem(nTokenValue != 0,
1121cdf0e10cSrcweir                         PLAINID->nHidden));
1122cdf0e10cSrcweir                 }
1123cdf0e10cSrcweir 				break;
1124cdf0e10cSrcweir 			case RTF_CHBGFDIAG:
1125cdf0e10cSrcweir 			case RTF_CHBGDKVERT:
1126cdf0e10cSrcweir 			case RTF_CHBGDKHORIZ:
1127cdf0e10cSrcweir 			case RTF_CHBGVERT:
1128cdf0e10cSrcweir 			case RTF_CHBGHORIZ:
1129cdf0e10cSrcweir 			case RTF_CHBGDKFDIAG:
1130cdf0e10cSrcweir 			case RTF_CHBGDCROSS:
1131cdf0e10cSrcweir 			case RTF_CHBGCROSS:
1132cdf0e10cSrcweir 			case RTF_CHBGBDIAG:
1133cdf0e10cSrcweir 			case RTF_CHBGDKDCROSS:
1134cdf0e10cSrcweir 			case RTF_CHBGDKCROSS:
1135cdf0e10cSrcweir 			case RTF_CHBGDKBDIAG:
1136cdf0e10cSrcweir 			case RTF_CHCBPAT:
1137cdf0e10cSrcweir 			case RTF_CHCFPAT:
1138cdf0e10cSrcweir 			case RTF_CHSHDNG:
1139cdf0e10cSrcweir 				if( PLAINID->nBgColor )
1140cdf0e10cSrcweir 					ReadBackgroundAttr( nToken, *pSet );
1141cdf0e10cSrcweir 				break;
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir /*  */
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir 			case BRACELEFT:
1147cdf0e10cSrcweir 				{
1148cdf0e10cSrcweir 					// teste auf Swg-Interne Tokens
1149cdf0e10cSrcweir                     bool bHandled = false;
1150cdf0e10cSrcweir 					short nSkip = 0;
1151cdf0e10cSrcweir 					if( RTF_IGNOREFLAG != GetNextToken())
1152cdf0e10cSrcweir 						nSkip = -1;
1153cdf0e10cSrcweir 					else if( (nToken = GetNextToken() ) & RTF_SWGDEFS )
1154cdf0e10cSrcweir 					{
1155cdf0e10cSrcweir                         bHandled = true;
1156cdf0e10cSrcweir 						switch( nToken )
1157cdf0e10cSrcweir 						{
1158cdf0e10cSrcweir 						case RTF_PGDSCNO:
1159cdf0e10cSrcweir 						case RTF_PGBRK:
1160cdf0e10cSrcweir 						case RTF_SOUTLVL:
1161cdf0e10cSrcweir 							UnknownAttrToken( nToken, pSet );
1162cdf0e10cSrcweir 							// ueberlese die schliessende Klammer
1163cdf0e10cSrcweir 							break;
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir 						case RTF_SWG_ESCPROP:
1166cdf0e10cSrcweir 							{
1167cdf0e10cSrcweir 								// prozentuale Veraenderung speichern !
1168cdf0e10cSrcweir 								sal_uInt8 nProp = sal_uInt8( nTokenValue / 100 );
1169cdf0e10cSrcweir 								short nEsc = 0;
1170cdf0e10cSrcweir 								if( 1 == ( nTokenValue % 100 ))
1171cdf0e10cSrcweir 									// Erkennung unseres AutoFlags!
1172cdf0e10cSrcweir 									nEsc = DFLT_ESC_AUTO_SUPER;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 								if( PLAINID->nEscapement )
1175cdf0e10cSrcweir 									pSet->Put( SvxEscapementItem( nEsc, nProp,
1176cdf0e10cSrcweir 											   		PLAINID->nEscapement ));
1177cdf0e10cSrcweir 							}
1178cdf0e10cSrcweir 							break;
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir 						case RTF_HYPHEN:
1181cdf0e10cSrcweir 							{
1182cdf0e10cSrcweir 								SvxHyphenZoneItem aHypenZone(
1183cdf0e10cSrcweir 											(nTokenValue & 1) ? sal_True : sal_False,
1184cdf0e10cSrcweir 												PARDID->nHyphenzone );
1185cdf0e10cSrcweir 								aHypenZone.SetPageEnd(
1186cdf0e10cSrcweir 											(nTokenValue & 2) ? sal_True : sal_False );
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir 								if( PARDID->nHyphenzone &&
1189cdf0e10cSrcweir 									RTF_HYPHLEAD == GetNextToken() &&
1190cdf0e10cSrcweir 									RTF_HYPHTRAIL == GetNextToken() &&
1191cdf0e10cSrcweir 									RTF_HYPHMAX == GetNextToken() )
1192cdf0e10cSrcweir 								{
1193cdf0e10cSrcweir 									aHypenZone.GetMinLead() =
1194cdf0e10cSrcweir 										sal_uInt8(GetStackPtr( -2 )->nTokenValue);
1195cdf0e10cSrcweir 									aHypenZone.GetMinTrail() =
1196cdf0e10cSrcweir 											sal_uInt8(GetStackPtr( -1 )->nTokenValue);
1197cdf0e10cSrcweir 									aHypenZone.GetMaxHyphens() =
1198cdf0e10cSrcweir 											sal_uInt8(nTokenValue);
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 									pSet->Put( aHypenZone );
1201cdf0e10cSrcweir 								}
1202cdf0e10cSrcweir 								else
1203cdf0e10cSrcweir 									SkipGroup();		// ans Ende der Gruppe
1204cdf0e10cSrcweir 							}
1205cdf0e10cSrcweir 							break;
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 						case RTF_SHADOW:
1208cdf0e10cSrcweir 							{
1209cdf0e10cSrcweir 								int bSkip = sal_True;
1210cdf0e10cSrcweir 								do {	// middle check loop
1211cdf0e10cSrcweir 									SvxShadowLocation eSL = SvxShadowLocation( nTokenValue );
1212cdf0e10cSrcweir 									if( RTF_SHDW_DIST != GetNextToken() )
1213cdf0e10cSrcweir 										break;
1214cdf0e10cSrcweir 									sal_uInt16 nDist = sal_uInt16( nTokenValue );
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir 									if( RTF_SHDW_STYLE != GetNextToken() )
1217cdf0e10cSrcweir 										break;
1218cdf0e10cSrcweir 									//! (pb) class Brush removed -> obsolete
1219cdf0e10cSrcweir 									//! BrushStyle eStyle = BrushStyle( nTokenValue );
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir 									if( RTF_SHDW_COL != GetNextToken() )
1222cdf0e10cSrcweir 										break;
1223cdf0e10cSrcweir 									sal_uInt16 nCol = sal_uInt16( nTokenValue );
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir 									if( RTF_SHDW_FCOL != GetNextToken() )
1226cdf0e10cSrcweir 										break;
1227cdf0e10cSrcweir //									sal_uInt16 nFillCol = sal_uInt16( nTokenValue );
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 									Color aColor = GetColor( nCol );
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir 									if( PARDID->nShadow )
1232cdf0e10cSrcweir 										pSet->Put( SvxShadowItem( PARDID->nShadow,
1233cdf0e10cSrcweir 																  &aColor, nDist, eSL ) );
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir 									bSkip = sal_False;
1236cdf0e10cSrcweir 								} while( sal_False );
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir 								if( bSkip )
1239cdf0e10cSrcweir 									SkipGroup();		// ans Ende der Gruppe
1240cdf0e10cSrcweir 							}
1241cdf0e10cSrcweir 							break;
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir 						default:
1244cdf0e10cSrcweir                             bHandled = false;
1245cdf0e10cSrcweir 							if( (nToken & ~(0xff | RTF_SWGDEFS)) == RTF_TABSTOPDEF )
1246cdf0e10cSrcweir 							{
1247cdf0e10cSrcweir 								nToken = SkipToken( -2 );
1248cdf0e10cSrcweir 								ReadTabAttr( nToken, *pSet );
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir                                 /*
1251cdf0e10cSrcweir                                 cmc: #i76140, he who consumed the { must consume the }
1252cdf0e10cSrcweir                                 We rewound to a state of { being the current
1253cdf0e10cSrcweir                                 token so it is our responsibility to consume the }
1254cdf0e10cSrcweir                                 token if we consumed the {. We will not have consumed
1255cdf0e10cSrcweir                                 the { if it belonged to our caller, i.e. if the { we
1256cdf0e10cSrcweir                                 are handling is the "firsttoken" passed to us then
1257cdf0e10cSrcweir                                 the *caller* must consume it, not us. Otherwise *we*
1258cdf0e10cSrcweir                                 should consume it.
1259cdf0e10cSrcweir                                 */
1260cdf0e10cSrcweir                                 if (nToken == BRACELEFT && !bFirstToken)
1261cdf0e10cSrcweir                                 {
1262cdf0e10cSrcweir                                     nToken = GetNextToken();
1263cdf0e10cSrcweir                                     DBG_ASSERT( nToken == BRACERIGHT,
1264cdf0e10cSrcweir                                         "} did not follow { as expected\n");
1265cdf0e10cSrcweir                                 }
1266cdf0e10cSrcweir 							}
1267cdf0e10cSrcweir 							else if( (nToken & ~(0xff| RTF_SWGDEFS)) == RTF_BRDRDEF)
1268cdf0e10cSrcweir 							{
1269cdf0e10cSrcweir 								nToken = SkipToken( -2 );
1270cdf0e10cSrcweir 								ReadBorderAttr( nToken, *pSet );
1271cdf0e10cSrcweir 							}
1272cdf0e10cSrcweir 							else		// also kein Attribut mehr
1273cdf0e10cSrcweir 								nSkip = -2;
1274cdf0e10cSrcweir 							break;
1275cdf0e10cSrcweir 						}
1276cdf0e10cSrcweir 
1277cdf0e10cSrcweir #if 1
1278cdf0e10cSrcweir                         /*
1279cdf0e10cSrcweir                         cmc: #i4727# / #i12713# Who owns this closing bracket?
1280cdf0e10cSrcweir                         If we read the opening one, we must read this one, if
1281cdf0e10cSrcweir                         other is counting the brackets so as to push/pop off
1282cdf0e10cSrcweir                         the correct environment then we will have pushed a new
1283cdf0e10cSrcweir                         environment for the start { of this, but will not see
1284cdf0e10cSrcweir                         the } and so is out of sync for the rest of the
1285cdf0e10cSrcweir                         document.
1286cdf0e10cSrcweir                         */
1287cdf0e10cSrcweir                         if (bHandled && !bFirstToken)
1288cdf0e10cSrcweir                             GetNextToken();
1289cdf0e10cSrcweir #endif
1290cdf0e10cSrcweir 					}
1291cdf0e10cSrcweir 					else
1292cdf0e10cSrcweir 						nSkip = -2;
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir 					if( nSkip )				// alles voellig unbekannt
1295cdf0e10cSrcweir 					{
1296cdf0e10cSrcweir                         if (!bFirstToken)
1297cdf0e10cSrcweir 						    --nSkip;	// BRACELEFT: ist das naechste Token
1298cdf0e10cSrcweir 						SkipToken( nSkip );
1299cdf0e10cSrcweir 						bWeiter = sal_False;
1300cdf0e10cSrcweir 					}
1301cdf0e10cSrcweir 				}
1302cdf0e10cSrcweir 				break;
1303cdf0e10cSrcweir 			default:
1304cdf0e10cSrcweir 				if( (nToken & ~0xff ) == RTF_TABSTOPDEF )
1305cdf0e10cSrcweir 					ReadTabAttr( nToken, *pSet );
1306cdf0e10cSrcweir 				else if( (nToken & ~0xff ) == RTF_BRDRDEF )
1307cdf0e10cSrcweir 					ReadBorderAttr( nToken, *pSet );
1308cdf0e10cSrcweir 				else if( (nToken & ~0xff ) == RTF_SHADINGDEF )
1309cdf0e10cSrcweir 					ReadBackgroundAttr( nToken, *pSet );
1310cdf0e10cSrcweir 				else
1311cdf0e10cSrcweir 				{
1312cdf0e10cSrcweir 					// kenne das Token nicht also das Token "in den Parser zurueck"
1313cdf0e10cSrcweir 					if( !bFirstToken )
1314cdf0e10cSrcweir 						SkipToken( -1 );
1315cdf0e10cSrcweir 					bWeiter = sal_False;
1316cdf0e10cSrcweir 				}
1317cdf0e10cSrcweir 			}
1318cdf0e10cSrcweir 		}
1319cdf0e10cSrcweir 		if( bWeiter )
1320cdf0e10cSrcweir 		{
1321cdf0e10cSrcweir 			nToken = GetNextToken();
1322cdf0e10cSrcweir 		}
1323cdf0e10cSrcweir 		bFirstToken = sal_False;
1324cdf0e10cSrcweir 	}
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir /*
1327cdf0e10cSrcweir 	// teste Attribute gegen ihre Styles
1328cdf0e10cSrcweir 	if( IsChkStyleAttr() && pSet->Count() && !pInsPos->GetCntIdx() )
1329cdf0e10cSrcweir 	{
1330cdf0e10cSrcweir 		SvxRTFStyleType* pStyle = aStyleTbl.Get( nStyleNo );
1331cdf0e10cSrcweir 		if( pStyle && pStyle->aAttrSet.Count() )
1332cdf0e10cSrcweir 		{
1333cdf0e10cSrcweir 			// alle Attribute, die schon vom Style definiert sind, aus dem
1334cdf0e10cSrcweir 			// akt. Set entfernen
1335cdf0e10cSrcweir 			const SfxPoolItem* pItem;
1336cdf0e10cSrcweir 			SfxItemIter aIter( *pSet );
1337cdf0e10cSrcweir 			sal_uInt16 nWhich = aIter.GetCurItem()->Which();
1338cdf0e10cSrcweir 			while( sal_True )
1339cdf0e10cSrcweir 			{
1340cdf0e10cSrcweir 				if( SFX_ITEM_SET == pStyle->aAttrSet.GetItemState(
1341cdf0e10cSrcweir 					nWhich, sal_False, &pItem ) && *pItem == *aIter.GetCurItem())
1342cdf0e10cSrcweir 					pSet->ClearItem( nWhich );		// loeschen
1343cdf0e10cSrcweir 
1344cdf0e10cSrcweir 				if( aIter.IsAtEnd() )
1345cdf0e10cSrcweir 					break;
1346cdf0e10cSrcweir 				nWhich = aIter.NextItem()->Which();
1347cdf0e10cSrcweir 			}
1348cdf0e10cSrcweir 		}
1349cdf0e10cSrcweir 	}
1350cdf0e10cSrcweir */
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir 
ReadTabAttr(int nToken,SfxItemSet & rSet)1353cdf0e10cSrcweir void SvxRTFParser::ReadTabAttr( int nToken, SfxItemSet& rSet )
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir 	bool bMethodOwnsToken = false; // #i52542# patch from cmc.
1356cdf0e10cSrcweir // dann lese doch mal alle TabStops ein
1357cdf0e10cSrcweir 	SvxTabStop aTabStop;
1358cdf0e10cSrcweir 	SvxTabStopItem aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT, PARDID->nTabStop );
1359cdf0e10cSrcweir 	int bWeiter = sal_True;
1360cdf0e10cSrcweir 	do {
1361cdf0e10cSrcweir 		switch( nToken )
1362cdf0e10cSrcweir 		{
1363cdf0e10cSrcweir 		case RTF_TB:		// BarTab ???
1364cdf0e10cSrcweir 		case RTF_TX:
1365cdf0e10cSrcweir 			{
1366cdf0e10cSrcweir 				if( IsCalcValue() )
1367cdf0e10cSrcweir 					CalcValue();
1368cdf0e10cSrcweir 				aTabStop.GetTabPos() = nTokenValue;
1369cdf0e10cSrcweir 				aAttr.Insert( aTabStop );
1370cdf0e10cSrcweir 				aTabStop = SvxTabStop();	// alle Werte default
1371cdf0e10cSrcweir 			}
1372cdf0e10cSrcweir 			break;
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir 		case RTF_TQL:
1375cdf0e10cSrcweir 			aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT;
1376cdf0e10cSrcweir 			break;
1377cdf0e10cSrcweir 		case RTF_TQR:
1378cdf0e10cSrcweir 			aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT;
1379cdf0e10cSrcweir 			break;
1380cdf0e10cSrcweir 		case RTF_TQC:
1381cdf0e10cSrcweir 			aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER;
1382cdf0e10cSrcweir 			break;
1383cdf0e10cSrcweir 		case RTF_TQDEC:
1384cdf0e10cSrcweir 			aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL;
1385cdf0e10cSrcweir 			break;
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir 		case RTF_TLDOT:		aTabStop.GetFill() = '.';	break;
1388cdf0e10cSrcweir 		case RTF_TLHYPH:	aTabStop.GetFill() = ' ';	break;
1389cdf0e10cSrcweir 		case RTF_TLUL:		aTabStop.GetFill() = '_';	break;
1390cdf0e10cSrcweir 		case RTF_TLTH:		aTabStop.GetFill() = '-';	break;
1391cdf0e10cSrcweir 		case RTF_TLEQ:		aTabStop.GetFill() = '=';	break;
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir 		case BRACELEFT:
1394cdf0e10cSrcweir 			{
1395cdf0e10cSrcweir 				// Swg - Kontrol BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT
1396cdf0e10cSrcweir 				short nSkip = 0;
1397cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetNextToken() )
1398cdf0e10cSrcweir 					nSkip = -1;
1399cdf0e10cSrcweir 				else if( RTF_TLSWG != ( nToken = GetNextToken() ))
1400cdf0e10cSrcweir 					nSkip = -2;
1401cdf0e10cSrcweir 				else
1402cdf0e10cSrcweir 				{
1403cdf0e10cSrcweir 					aTabStop.GetDecimal() = sal_uInt8(nTokenValue & 0xff);
1404cdf0e10cSrcweir 					aTabStop.GetFill() = sal_uInt8((nTokenValue >> 8) & 0xff);
1405cdf0e10cSrcweir 					// ueberlese noch die schliessende Klammer
1406cdf0e10cSrcweir 					if (bMethodOwnsToken)
1407cdf0e10cSrcweir 						GetNextToken();
1408cdf0e10cSrcweir 				}
1409cdf0e10cSrcweir 				if( nSkip )
1410cdf0e10cSrcweir 				{
1411cdf0e10cSrcweir 					SkipToken( nSkip );		// Ignore wieder zurueck
1412cdf0e10cSrcweir 					bWeiter = sal_False;
1413cdf0e10cSrcweir 				}
1414cdf0e10cSrcweir 			}
1415cdf0e10cSrcweir 			break;
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 		default:
1418cdf0e10cSrcweir 			bWeiter = sal_False;
1419cdf0e10cSrcweir 		}
1420cdf0e10cSrcweir 		if( bWeiter )
1421cdf0e10cSrcweir 		{
1422cdf0e10cSrcweir 			nToken = GetNextToken();
1423cdf0e10cSrcweir 			bMethodOwnsToken = true;
1424cdf0e10cSrcweir 		}
1425cdf0e10cSrcweir 	} while( bWeiter );
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir 	// mit Defaults aufuellen fehlt noch !!!
1428cdf0e10cSrcweir 	rSet.Put( aAttr );
1429cdf0e10cSrcweir 	SkipToken( -1 );
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir 
SetBorderLine(int nBorderTyp,SvxBoxItem & rItem,const SvxBorderLine & rBorder)1432cdf0e10cSrcweir static void SetBorderLine( int nBorderTyp, SvxBoxItem& rItem,
1433cdf0e10cSrcweir 							const SvxBorderLine& rBorder )
1434cdf0e10cSrcweir {
1435cdf0e10cSrcweir 	switch( nBorderTyp )
1436cdf0e10cSrcweir 	{
1437cdf0e10cSrcweir 	case RTF_BOX:			// alle Stufen durchlaufen
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir 	case RTF_BRDRT:
1440cdf0e10cSrcweir 		rItem.SetLine( &rBorder, BOX_LINE_TOP );
1441cdf0e10cSrcweir 		if( RTF_BOX != nBorderTyp )
1442cdf0e10cSrcweir 			return;
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir 	case RTF_BRDRB:
1445cdf0e10cSrcweir 		rItem.SetLine( &rBorder, BOX_LINE_BOTTOM );
1446cdf0e10cSrcweir 		if( RTF_BOX != nBorderTyp )
1447cdf0e10cSrcweir 			return;
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir 	case RTF_BRDRL:
1450cdf0e10cSrcweir 		rItem.SetLine( &rBorder, BOX_LINE_LEFT );
1451cdf0e10cSrcweir 		if( RTF_BOX != nBorderTyp )
1452cdf0e10cSrcweir 			return;
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir 	case RTF_BRDRR:
1455cdf0e10cSrcweir 		rItem.SetLine( &rBorder, BOX_LINE_RIGHT );
1456cdf0e10cSrcweir 		if( RTF_BOX != nBorderTyp )
1457cdf0e10cSrcweir 			return;
1458cdf0e10cSrcweir 	}
1459cdf0e10cSrcweir }
1460cdf0e10cSrcweir 
ReadBorderAttr(int nToken,SfxItemSet & rSet,int bTableDef)1461cdf0e10cSrcweir void SvxRTFParser::ReadBorderAttr( int nToken, SfxItemSet& rSet,
1462cdf0e10cSrcweir 									int bTableDef )
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir 	// dann lese doch mal das BoderAttribut ein
1465cdf0e10cSrcweir 	SvxBoxItem aAttr( PARDID->nBox );
1466cdf0e10cSrcweir 	const SfxPoolItem* pItem;
1467cdf0e10cSrcweir 	if( SFX_ITEM_SET == rSet.GetItemState( PARDID->nBox, sal_False, &pItem ) )
1468cdf0e10cSrcweir 		aAttr = *(SvxBoxItem*)pItem;
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir 	SvxBorderLine aBrd( 0, DEF_LINE_WIDTH_0, 0, 0 );	// einfache Linien
1471cdf0e10cSrcweir 	int bWeiter = sal_True, nBorderTyp = 0;
1472cdf0e10cSrcweir 
1473cdf0e10cSrcweir 	do {
1474cdf0e10cSrcweir 		switch( nToken )
1475cdf0e10cSrcweir 		{
1476cdf0e10cSrcweir 		case RTF_BOX:
1477cdf0e10cSrcweir 		case RTF_BRDRT:
1478cdf0e10cSrcweir 		case RTF_BRDRB:
1479cdf0e10cSrcweir 		case RTF_BRDRL:
1480cdf0e10cSrcweir 		case RTF_BRDRR:
1481cdf0e10cSrcweir 			nBorderTyp = nToken;
1482cdf0e10cSrcweir 			goto SETBORDER;
1483cdf0e10cSrcweir 
1484cdf0e10cSrcweir 		case RTF_CLBRDRT:
1485cdf0e10cSrcweir 			if( !bTableDef )
1486cdf0e10cSrcweir 				break;
1487cdf0e10cSrcweir 			nBorderTyp = RTF_BRDRT;
1488cdf0e10cSrcweir 			goto SETBORDER;
1489cdf0e10cSrcweir 		case RTF_CLBRDRB:
1490cdf0e10cSrcweir 			if( !bTableDef )
1491cdf0e10cSrcweir 				break;
1492cdf0e10cSrcweir 			nBorderTyp = RTF_BRDRB;
1493cdf0e10cSrcweir 			goto SETBORDER;
1494cdf0e10cSrcweir 		case RTF_CLBRDRL:
1495cdf0e10cSrcweir 			if( !bTableDef )
1496cdf0e10cSrcweir 				break;
1497cdf0e10cSrcweir 			nBorderTyp = RTF_BRDRL;
1498cdf0e10cSrcweir 			goto SETBORDER;
1499cdf0e10cSrcweir 		case RTF_CLBRDRR:
1500cdf0e10cSrcweir 			if( !bTableDef )
1501cdf0e10cSrcweir 				break;
1502cdf0e10cSrcweir 			nBorderTyp = RTF_BRDRR;
1503cdf0e10cSrcweir 			goto SETBORDER;
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir SETBORDER:
1506cdf0e10cSrcweir 			{
1507cdf0e10cSrcweir 				// auf defaults setzen
1508cdf0e10cSrcweir 				aBrd.SetOutWidth( DEF_LINE_WIDTH_0 );
1509cdf0e10cSrcweir 				aBrd.SetInWidth( 0 );
1510cdf0e10cSrcweir 				aBrd.SetDistance( 0 );
1511cdf0e10cSrcweir 				aBrd.SetColor( Color( COL_BLACK ) );
1512cdf0e10cSrcweir 			}
1513cdf0e10cSrcweir 			break;
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir 
1516cdf0e10cSrcweir // werden noch nicht ausgewertet
1517cdf0e10cSrcweir 		case RTF_BRSP:
1518cdf0e10cSrcweir 			{
1519cdf0e10cSrcweir 				switch( nBorderTyp )
1520cdf0e10cSrcweir 				{
1521cdf0e10cSrcweir 				case RTF_BRDRB:
1522cdf0e10cSrcweir 					aAttr.SetDistance( (sal_uInt16)nTokenValue, BOX_LINE_BOTTOM );
1523cdf0e10cSrcweir 					break;
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir 				case RTF_BRDRT:
1526cdf0e10cSrcweir 					aAttr.SetDistance( (sal_uInt16)nTokenValue, BOX_LINE_TOP );
1527cdf0e10cSrcweir 					break;
1528cdf0e10cSrcweir 
1529cdf0e10cSrcweir 				case RTF_BRDRL:
1530cdf0e10cSrcweir 					aAttr.SetDistance( (sal_uInt16)nTokenValue, BOX_LINE_LEFT );
1531cdf0e10cSrcweir 					break;
1532cdf0e10cSrcweir 
1533cdf0e10cSrcweir 				case RTF_BRDRR:
1534cdf0e10cSrcweir 					aAttr.SetDistance( (sal_uInt16)nTokenValue, BOX_LINE_RIGHT );
1535cdf0e10cSrcweir 					break;
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 				case RTF_BOX:
1538cdf0e10cSrcweir 					aAttr.SetDistance( (sal_uInt16)nTokenValue );
1539cdf0e10cSrcweir 					break;
1540cdf0e10cSrcweir 				}
1541cdf0e10cSrcweir 			}
1542cdf0e10cSrcweir 			break;
1543cdf0e10cSrcweir 
1544cdf0e10cSrcweir case RTF_BRDRBTW:
1545cdf0e10cSrcweir case RTF_BRDRBAR:			break;
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir 		case RTF_BRDRCF:
1549cdf0e10cSrcweir 			{
1550cdf0e10cSrcweir 				aBrd.SetColor( GetColor( sal_uInt16(nTokenValue) ) );
1551cdf0e10cSrcweir 				SetBorderLine( nBorderTyp, aAttr, aBrd );
1552cdf0e10cSrcweir 			}
1553cdf0e10cSrcweir 			break;
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir 		case RTF_BRDRTH:
1556cdf0e10cSrcweir 			aBrd.SetOutWidth( DEF_LINE_WIDTH_1 );
1557cdf0e10cSrcweir 			aBrd.SetInWidth( 0 );
1558cdf0e10cSrcweir 			aBrd.SetDistance( 0 );
1559cdf0e10cSrcweir 			goto SETBORDERLINE;
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir 		case RTF_BRDRDB:
1562cdf0e10cSrcweir 			aBrd.SetOutWidth( DEF_DOUBLE_LINE0_OUT );
1563cdf0e10cSrcweir 			aBrd.SetInWidth( DEF_DOUBLE_LINE0_IN );
1564cdf0e10cSrcweir 			aBrd.SetDistance( DEF_DOUBLE_LINE0_DIST );
1565cdf0e10cSrcweir 			goto SETBORDERLINE;
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir 		case RTF_BRDRSH:
1568cdf0e10cSrcweir 			// schattierte Box
1569cdf0e10cSrcweir 			{
1570cdf0e10cSrcweir 				rSet.Put( SvxShadowItem( PARDID->nShadow, (Color*) 0, 60 /*3pt*/,
1571cdf0e10cSrcweir 										SVX_SHADOW_BOTTOMRIGHT ) );
1572cdf0e10cSrcweir 			}
1573cdf0e10cSrcweir 			break;
1574cdf0e10cSrcweir 
1575cdf0e10cSrcweir 		case RTF_BRDRW:
1576cdf0e10cSrcweir 			if( -1 != nTokenValue )
1577cdf0e10cSrcweir 			{
1578cdf0e10cSrcweir 				// sollte es eine "dicke" Linie sein ?
1579cdf0e10cSrcweir 				if( DEF_LINE_WIDTH_0 != aBrd.GetOutWidth() )
1580cdf0e10cSrcweir 					nTokenValue *= 2;
1581cdf0e10cSrcweir 
1582cdf0e10cSrcweir 				// eine Doppelline?
1583cdf0e10cSrcweir 				if( aBrd.GetInWidth() )
1584cdf0e10cSrcweir 				{
1585cdf0e10cSrcweir 					// WinWord - Werte an StarOffice anpassen
1586cdf0e10cSrcweir 					if( nTokenValue < DEF_LINE_WIDTH_1 - (DEF_LINE_WIDTH_1/10))
1587cdf0e10cSrcweir 					{
1588cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_DOUBLE_LINE0_OUT );
1589cdf0e10cSrcweir 						aBrd.SetInWidth( DEF_DOUBLE_LINE0_IN );
1590cdf0e10cSrcweir 						aBrd.SetDistance( DEF_DOUBLE_LINE0_DIST );
1591cdf0e10cSrcweir 					}
1592cdf0e10cSrcweir 					else
1593cdf0e10cSrcweir 					if( nTokenValue < DEF_LINE_WIDTH_2 - (DEF_LINE_WIDTH_2/10))
1594cdf0e10cSrcweir 					{
1595cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_DOUBLE_LINE1_OUT );
1596cdf0e10cSrcweir 						aBrd.SetInWidth( DEF_DOUBLE_LINE1_IN );
1597cdf0e10cSrcweir 						aBrd.SetDistance( DEF_DOUBLE_LINE1_DIST );
1598cdf0e10cSrcweir 					}
1599cdf0e10cSrcweir 					else
1600cdf0e10cSrcweir 					{
1601cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_DOUBLE_LINE2_OUT );
1602cdf0e10cSrcweir 						aBrd.SetInWidth( DEF_DOUBLE_LINE2_IN );
1603cdf0e10cSrcweir 						aBrd.SetDistance( DEF_DOUBLE_LINE2_DIST );
1604cdf0e10cSrcweir 					}
1605cdf0e10cSrcweir 				}
1606cdf0e10cSrcweir 				else
1607cdf0e10cSrcweir 				{
1608cdf0e10cSrcweir 					// WinWord - Werte an StarOffice anpassen
1609cdf0e10cSrcweir 					if( nTokenValue < DEF_LINE_WIDTH_1 - (DEF_LINE_WIDTH_1/10))
1610cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_LINE_WIDTH_0 );
1611cdf0e10cSrcweir 					else
1612cdf0e10cSrcweir 					if( nTokenValue < DEF_LINE_WIDTH_2 - (DEF_LINE_WIDTH_2/10))
1613cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_LINE_WIDTH_1 );
1614cdf0e10cSrcweir 					else
1615cdf0e10cSrcweir 					if( nTokenValue < DEF_LINE_WIDTH_3 - (DEF_LINE_WIDTH_3/10))
1616cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_LINE_WIDTH_2 );
1617cdf0e10cSrcweir 					else
1618cdf0e10cSrcweir 					if( nTokenValue < DEF_LINE_WIDTH_4 )
1619cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_LINE_WIDTH_3 );
1620cdf0e10cSrcweir 					else
1621cdf0e10cSrcweir 						aBrd.SetOutWidth( DEF_LINE_WIDTH_4 );
1622cdf0e10cSrcweir 				}
1623cdf0e10cSrcweir 			}
1624cdf0e10cSrcweir 			goto SETBORDERLINE;
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir 		case RTF_BRDRS:
1627cdf0e10cSrcweir 		case RTF_BRDRDOT:
1628cdf0e10cSrcweir 		case RTF_BRDRHAIR:
1629cdf0e10cSrcweir 		case RTF_BRDRDASH:
1630cdf0e10cSrcweir SETBORDERLINE:
1631cdf0e10cSrcweir 			SetBorderLine( nBorderTyp, aAttr, aBrd );
1632cdf0e10cSrcweir 			break;
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir 		case BRACELEFT:
1635cdf0e10cSrcweir 			{
1636cdf0e10cSrcweir 				short nSkip = 0;
1637cdf0e10cSrcweir 				if( RTF_IGNOREFLAG != GetNextToken() )
1638cdf0e10cSrcweir 					nSkip = -1;
1639cdf0e10cSrcweir 				else
1640cdf0e10cSrcweir 				{
1641cdf0e10cSrcweir 					int bSwgControl = sal_True, bFirstToken = sal_True;
1642cdf0e10cSrcweir 					nToken = GetNextToken();
1643cdf0e10cSrcweir 					do {
1644cdf0e10cSrcweir 						switch( nToken )
1645cdf0e10cSrcweir 						{
1646cdf0e10cSrcweir 						case RTF_BRDBOX:
1647cdf0e10cSrcweir 							aAttr.SetDistance( sal_uInt16(nTokenValue) );
1648cdf0e10cSrcweir 							break;
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir 						case RTF_BRDRT:
1651cdf0e10cSrcweir 						case RTF_BRDRB:
1652cdf0e10cSrcweir 						case RTF_BRDRR:
1653cdf0e10cSrcweir 						case RTF_BRDRL:
1654cdf0e10cSrcweir 							nBorderTyp = nToken;
1655cdf0e10cSrcweir 							bFirstToken = sal_False;
1656cdf0e10cSrcweir 							if( RTF_BRDLINE_COL != GetNextToken() )
1657cdf0e10cSrcweir 							{
1658cdf0e10cSrcweir 								bSwgControl = sal_False;
1659cdf0e10cSrcweir 								break;
1660cdf0e10cSrcweir 							}
1661cdf0e10cSrcweir 							aBrd.SetColor( GetColor( sal_uInt16(nTokenValue) ));
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir 							if( RTF_BRDLINE_IN != GetNextToken() )
1664cdf0e10cSrcweir 							{
1665cdf0e10cSrcweir 								bSwgControl = sal_False;
1666cdf0e10cSrcweir 								break;
1667cdf0e10cSrcweir 							}
1668cdf0e10cSrcweir 							aBrd.SetInWidth( sal_uInt16(nTokenValue));
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir 							if( RTF_BRDLINE_OUT != GetNextToken() )
1671cdf0e10cSrcweir 							{
1672cdf0e10cSrcweir 								bSwgControl = sal_False;
1673cdf0e10cSrcweir 								break;
1674cdf0e10cSrcweir 							}
1675cdf0e10cSrcweir 							aBrd.SetOutWidth( sal_uInt16(nTokenValue));
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir 							if( RTF_BRDLINE_DIST != GetNextToken() )
1678cdf0e10cSrcweir 							{
1679cdf0e10cSrcweir 								bSwgControl = sal_False;
1680cdf0e10cSrcweir 								break;
1681cdf0e10cSrcweir 							}
1682cdf0e10cSrcweir 							aBrd.SetDistance( sal_uInt16(nTokenValue));
1683cdf0e10cSrcweir 							SetBorderLine( nBorderTyp, aAttr, aBrd );
1684cdf0e10cSrcweir 							break;
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir 						default:
1687cdf0e10cSrcweir 							bSwgControl = sal_False;
1688cdf0e10cSrcweir 							break;
1689cdf0e10cSrcweir 						}
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir 						if( bSwgControl )
1692cdf0e10cSrcweir 						{
1693cdf0e10cSrcweir 							nToken = GetNextToken();
1694cdf0e10cSrcweir 							bFirstToken = sal_False;
1695cdf0e10cSrcweir 						}
1696cdf0e10cSrcweir 					} while( bSwgControl );
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir 					// Ende der Swg-Gruppe
1699cdf0e10cSrcweir 					// -> lese noch die schliessende Klammer
1700cdf0e10cSrcweir 					if( BRACERIGHT == nToken )
1701cdf0e10cSrcweir 						;
1702cdf0e10cSrcweir 					else if( !bFirstToken )
1703cdf0e10cSrcweir 					{
1704cdf0e10cSrcweir 						// es ist ein Parser-Fehler, springe zum
1705cdf0e10cSrcweir 						// Ende der Gruppe
1706cdf0e10cSrcweir 						SkipGroup();
1707cdf0e10cSrcweir 						// schliessende BRACERIGHT ueberspringen
1708cdf0e10cSrcweir 						GetNextToken();
1709cdf0e10cSrcweir 					}
1710cdf0e10cSrcweir 					else
1711cdf0e10cSrcweir 						nSkip = -2;
1712cdf0e10cSrcweir 				}
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir 				if( nSkip )
1715cdf0e10cSrcweir 				{
1716cdf0e10cSrcweir 					SkipToken( nSkip );		// Ignore wieder zurueck
1717cdf0e10cSrcweir 					bWeiter = sal_False;
1718cdf0e10cSrcweir 				}
1719cdf0e10cSrcweir 			}
1720cdf0e10cSrcweir 			break;
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir 		default:
1723cdf0e10cSrcweir 			bWeiter = (nToken & ~(0xff| RTF_SWGDEFS)) == RTF_BRDRDEF;
1724cdf0e10cSrcweir 		}
1725cdf0e10cSrcweir 		if( bWeiter )
1726cdf0e10cSrcweir 			nToken = GetNextToken();
1727cdf0e10cSrcweir 	} while( bWeiter );
1728cdf0e10cSrcweir 	rSet.Put( aAttr );
1729cdf0e10cSrcweir 	SkipToken( -1 );
1730cdf0e10cSrcweir }
1731cdf0e10cSrcweir 
CalcShading(sal_uInt32 nColor,sal_uInt32 nFillColor,sal_uInt8 nShading)1732cdf0e10cSrcweir inline sal_uInt32 CalcShading( sal_uInt32 nColor, sal_uInt32 nFillColor, sal_uInt8 nShading )
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir 	nColor = (nColor * nShading) / 100;
1735cdf0e10cSrcweir 	nFillColor = (nFillColor * ( 100 - nShading )) / 100;
1736cdf0e10cSrcweir 	return nColor + nFillColor;
1737cdf0e10cSrcweir }
1738cdf0e10cSrcweir 
ReadBackgroundAttr(int nToken,SfxItemSet & rSet,int bTableDef)1739cdf0e10cSrcweir void SvxRTFParser::ReadBackgroundAttr( int nToken, SfxItemSet& rSet,
1740cdf0e10cSrcweir 										int bTableDef )
1741cdf0e10cSrcweir {
1742cdf0e10cSrcweir 	// dann lese doch mal das BoderAttribut ein
1743cdf0e10cSrcweir 	int bWeiter = sal_True;
1744cdf0e10cSrcweir 	sal_uInt16 nColor = USHRT_MAX, nFillColor = USHRT_MAX;
1745cdf0e10cSrcweir 	sal_uInt8 nFillValue = 0;
1746cdf0e10cSrcweir 
1747cdf0e10cSrcweir 	sal_uInt16 nWh = ( nToken & ~0xff ) == RTF_CHRFMT
1748cdf0e10cSrcweir 					? PLAINID->nBgColor
1749cdf0e10cSrcweir 					: PARDID->nBrush;
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir 	do {
1752cdf0e10cSrcweir 		switch( nToken )
1753cdf0e10cSrcweir 		{
1754cdf0e10cSrcweir 		case RTF_CLCBPAT:
1755cdf0e10cSrcweir 		case RTF_CHCBPAT:
1756cdf0e10cSrcweir 		case RTF_CBPAT:
1757cdf0e10cSrcweir 			nFillColor = sal_uInt16( nTokenValue );
1758cdf0e10cSrcweir 			break;
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir 		case RTF_CLCFPAT:
1761cdf0e10cSrcweir 		case RTF_CHCFPAT:
1762cdf0e10cSrcweir 		case RTF_CFPAT:
1763cdf0e10cSrcweir 			nColor = sal_uInt16( nTokenValue );
1764cdf0e10cSrcweir 			break;
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir 		case RTF_CLSHDNG:
1767cdf0e10cSrcweir 		case RTF_CHSHDNG:
1768cdf0e10cSrcweir 		case RTF_SHADING:
1769cdf0e10cSrcweir 			nFillValue = (sal_uInt8)( nTokenValue / 100 );
1770cdf0e10cSrcweir 			break;
1771cdf0e10cSrcweir 
1772cdf0e10cSrcweir 		case RTF_CLBGDKHOR:
1773cdf0e10cSrcweir 		case RTF_CHBGDKHORIZ:
1774cdf0e10cSrcweir 		case RTF_BGDKHORIZ:
1775cdf0e10cSrcweir 		case RTF_CLBGDKVERT:
1776cdf0e10cSrcweir 		case RTF_CHBGDKVERT:
1777cdf0e10cSrcweir 		case RTF_BGDKVERT:
1778cdf0e10cSrcweir 		case RTF_CLBGDKBDIAG:
1779cdf0e10cSrcweir 		case RTF_CHBGDKBDIAG:
1780cdf0e10cSrcweir 		case RTF_BGDKBDIAG:
1781cdf0e10cSrcweir 		case RTF_CLBGDKFDIAG:
1782cdf0e10cSrcweir 		case RTF_CHBGDKFDIAG:
1783cdf0e10cSrcweir 		case RTF_BGDKFDIAG:
1784cdf0e10cSrcweir 		case RTF_CLBGDKCROSS:
1785cdf0e10cSrcweir 		case RTF_CHBGDKCROSS:
1786cdf0e10cSrcweir 		case RTF_BGDKCROSS:
1787cdf0e10cSrcweir 		case RTF_CLBGDKDCROSS:
1788cdf0e10cSrcweir 		case RTF_CHBGDKDCROSS:
1789cdf0e10cSrcweir 		case RTF_BGDKDCROSS:
1790cdf0e10cSrcweir 			// dark -> 60%
1791cdf0e10cSrcweir 			nFillValue = 60;
1792cdf0e10cSrcweir 			break;
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir 		case RTF_CLBGHORIZ:
1795cdf0e10cSrcweir 		case RTF_CHBGHORIZ:
1796cdf0e10cSrcweir 		case RTF_BGHORIZ:
1797cdf0e10cSrcweir 		case RTF_CLBGVERT:
1798cdf0e10cSrcweir 		case RTF_CHBGVERT:
1799cdf0e10cSrcweir 		case RTF_BGVERT:
1800cdf0e10cSrcweir 		case RTF_CLBGBDIAG:
1801cdf0e10cSrcweir 		case RTF_CHBGBDIAG:
1802cdf0e10cSrcweir 		case RTF_BGBDIAG:
1803cdf0e10cSrcweir 		case RTF_CLBGFDIAG:
1804cdf0e10cSrcweir 		case RTF_CHBGFDIAG:
1805cdf0e10cSrcweir 		case RTF_BGFDIAG:
1806cdf0e10cSrcweir 		case RTF_CLBGCROSS:
1807cdf0e10cSrcweir 		case RTF_CHBGCROSS:
1808cdf0e10cSrcweir 		case RTF_BGCROSS:
1809cdf0e10cSrcweir 		case RTF_CLBGDCROSS:
1810cdf0e10cSrcweir 		case RTF_CHBGDCROSS:
1811cdf0e10cSrcweir 		case RTF_BGDCROSS:
1812cdf0e10cSrcweir 			// light -> 20%
1813cdf0e10cSrcweir 			nFillValue = 20;
1814cdf0e10cSrcweir 			break;
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 		default:
1817cdf0e10cSrcweir 			if( bTableDef )
1818cdf0e10cSrcweir 				bWeiter = (nToken & ~(0xff | RTF_TABLEDEF) ) == RTF_SHADINGDEF;
1819cdf0e10cSrcweir 			else
1820cdf0e10cSrcweir 				bWeiter = (nToken & ~0xff) == RTF_SHADINGDEF;
1821cdf0e10cSrcweir 		}
1822cdf0e10cSrcweir 		if( bWeiter )
1823cdf0e10cSrcweir 			nToken = GetNextToken();
1824cdf0e10cSrcweir 	} while( bWeiter );
1825cdf0e10cSrcweir 
1826cdf0e10cSrcweir 	Color aCol( COL_WHITE ), aFCol;
1827cdf0e10cSrcweir 	if( !nFillValue )
1828cdf0e10cSrcweir 	{
1829cdf0e10cSrcweir 		// es wurde nur eine von beiden Farben angegeben oder kein BrushTyp
1830cdf0e10cSrcweir 		if( USHRT_MAX != nFillColor )
1831cdf0e10cSrcweir 		{
1832cdf0e10cSrcweir 			nFillValue = 100;
1833cdf0e10cSrcweir 			aCol = GetColor( nFillColor );
1834cdf0e10cSrcweir 		}
1835cdf0e10cSrcweir 		else if( USHRT_MAX != nColor )
1836cdf0e10cSrcweir 			aFCol = GetColor( nColor );
1837cdf0e10cSrcweir 	}
1838cdf0e10cSrcweir 	else
1839cdf0e10cSrcweir 	{
1840cdf0e10cSrcweir 		if( USHRT_MAX != nColor )
1841cdf0e10cSrcweir 			aCol = GetColor( nColor );
1842cdf0e10cSrcweir 		else
1843cdf0e10cSrcweir 			aCol = Color( COL_BLACK );
1844cdf0e10cSrcweir 
1845cdf0e10cSrcweir 		if( USHRT_MAX != nFillColor )
1846cdf0e10cSrcweir 			aFCol = GetColor( nFillColor );
1847cdf0e10cSrcweir 		else
1848cdf0e10cSrcweir 			aFCol = Color( COL_WHITE );
1849cdf0e10cSrcweir 	}
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir 	Color aColor;
1852cdf0e10cSrcweir 	if( 0 == nFillValue || 100 == nFillValue )
1853cdf0e10cSrcweir 		aColor = aCol;
1854cdf0e10cSrcweir 	else
1855cdf0e10cSrcweir 		aColor = Color(
1856cdf0e10cSrcweir 			(sal_uInt8)CalcShading( aCol.GetRed(), aFCol.GetRed(), nFillValue ),
1857cdf0e10cSrcweir 			(sal_uInt8)CalcShading( aCol.GetGreen(), aFCol.GetGreen(), nFillValue ),
1858cdf0e10cSrcweir 			(sal_uInt8)CalcShading( aCol.GetBlue(), aFCol.GetBlue(), nFillValue ) );
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir 	rSet.Put( SvxBrushItem( aColor, nWh ) );
1861cdf0e10cSrcweir 	SkipToken( -1 );
1862cdf0e10cSrcweir }
1863cdf0e10cSrcweir 
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir // pard / plain abarbeiten
RTFPardPlain(int bPard,SfxItemSet ** ppSet)1866cdf0e10cSrcweir void SvxRTFParser::RTFPardPlain( int bPard, SfxItemSet** ppSet )
1867cdf0e10cSrcweir {
1868cdf0e10cSrcweir 	if( !bNewGroup && !aAttrStack.empty() )	// not at the beginning of a new group
1869cdf0e10cSrcweir 	{
1870cdf0e10cSrcweir         SvxRTFItemStackType* pAkt = aAttrStack.back();
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir 		int nLastToken = GetStackPtr(-1)->nTokenId;
1873cdf0e10cSrcweir 		int bNewStkEntry = sal_True;
1874cdf0e10cSrcweir 		if( RTF_PARD != nLastToken &&
1875cdf0e10cSrcweir 			RTF_PLAIN != nLastToken &&
1876cdf0e10cSrcweir 			BRACELEFT != nLastToken )
1877cdf0e10cSrcweir 		{
1878cdf0e10cSrcweir 			if( pAkt->aAttrSet.Count() || pAkt->pChildList || pAkt->nStyleNo )
1879cdf0e10cSrcweir 			{
1880cdf0e10cSrcweir 				// eine neue Gruppe aufmachen
1881cdf0e10cSrcweir 				SvxRTFItemStackType* pNew = new SvxRTFItemStackType( *pAkt, *pInsPos, sal_True );
1882cdf0e10cSrcweir 				pNew->SetRTFDefaults( GetRTFDefaults() );
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir 				// alle bis hierher gueltigen Attribute "setzen"
1885cdf0e10cSrcweir 				AttrGroupEnd();
1886cdf0e10cSrcweir 				pAkt = aAttrStack.empty() ? 0 : aAttrStack.back();  // can be changed after AttrGroupEnd!
1887cdf0e10cSrcweir 				pNew->aAttrSet.SetParent( pAkt ? &pAkt->aAttrSet : 0 );
1888cdf0e10cSrcweir 				aAttrStack.push_back( pNew );
1889cdf0e10cSrcweir 				pAkt = pNew;
1890cdf0e10cSrcweir 			}
1891cdf0e10cSrcweir 			else
1892cdf0e10cSrcweir 			{
1893cdf0e10cSrcweir 				// diesen Eintrag als neuen weiterbenutzen
1894cdf0e10cSrcweir 				pAkt->SetStartPos( *pInsPos );
1895cdf0e10cSrcweir 				bNewStkEntry = sal_False;
1896cdf0e10cSrcweir 			}
1897cdf0e10cSrcweir 		}
1898cdf0e10cSrcweir 
1899cdf0e10cSrcweir 		// jetzt noch alle auf default zuruecksetzen
1900cdf0e10cSrcweir 		if( bNewStkEntry &&
1901cdf0e10cSrcweir 			( pAkt->aAttrSet.GetParent() || pAkt->aAttrSet.Count() ))
1902cdf0e10cSrcweir 		{
1903cdf0e10cSrcweir 			const SfxPoolItem *pItem, *pDef;
1904cdf0e10cSrcweir 			const sal_uInt16* pPtr;
1905cdf0e10cSrcweir 			sal_uInt16 nCnt;
1906cdf0e10cSrcweir 			const SfxItemSet* pDfltSet = &GetRTFDefaults();
1907cdf0e10cSrcweir 			if( bPard )
1908cdf0e10cSrcweir 			{
1909cdf0e10cSrcweir 				pAkt->nStyleNo = 0;
1910cdf0e10cSrcweir 				pPtr = aPardMap.GetData();
1911cdf0e10cSrcweir 				nCnt = aPardMap.Count();
1912cdf0e10cSrcweir 			}
1913cdf0e10cSrcweir 			else
1914cdf0e10cSrcweir 			{
1915cdf0e10cSrcweir 				pPtr = aPlainMap.GetData();
1916cdf0e10cSrcweir 				nCnt = aPlainMap.Count();
1917cdf0e10cSrcweir 			}
1918cdf0e10cSrcweir 
1919cdf0e10cSrcweir 			for( sal_uInt16 n = 0; n < nCnt; ++n, ++pPtr )
1920cdf0e10cSrcweir 			{
1921cdf0e10cSrcweir 				// Item gesetzt und unterschiedlich -> das Pooldefault setzen
1922cdf0e10cSrcweir 				//JP 06.04.98: bei Items die nur SlotItems sind, darf nicht
1923cdf0e10cSrcweir 				//				auf das Default zugefriffen werden. Diese
1924cdf0e10cSrcweir 				//				werden gecleart
1925cdf0e10cSrcweir 				if( !*pPtr )
1926cdf0e10cSrcweir 					;
1927cdf0e10cSrcweir 				else if( SFX_WHICH_MAX < *pPtr )
1928cdf0e10cSrcweir 					pAkt->aAttrSet.ClearItem( *pPtr );
1929cdf0e10cSrcweir 				else if( IsChkStyleAttr() )
1930cdf0e10cSrcweir 					pAkt->aAttrSet.Put( pDfltSet->Get( *pPtr ) );
1931cdf0e10cSrcweir 				else if( !pAkt->aAttrSet.GetParent() )
1932cdf0e10cSrcweir 				{
1933cdf0e10cSrcweir 					if( SFX_ITEM_SET ==
1934cdf0e10cSrcweir 						pDfltSet->GetItemState( *pPtr, sal_False, &pDef ))
1935cdf0e10cSrcweir 						pAkt->aAttrSet.Put( *pDef );
1936cdf0e10cSrcweir 					else
1937cdf0e10cSrcweir 						pAkt->aAttrSet.ClearItem( *pPtr );
1938cdf0e10cSrcweir 				}
1939cdf0e10cSrcweir 				else if( SFX_ITEM_SET == pAkt->aAttrSet.GetParent()->
1940cdf0e10cSrcweir 							GetItemState( *pPtr, sal_True, &pItem ) &&
1941cdf0e10cSrcweir 						*( pDef = &pDfltSet->Get( *pPtr )) != *pItem )
1942cdf0e10cSrcweir 					pAkt->aAttrSet.Put( *pDef );
1943cdf0e10cSrcweir 				else
1944cdf0e10cSrcweir 				{
1945cdf0e10cSrcweir 					if( SFX_ITEM_SET ==
1946cdf0e10cSrcweir 						pDfltSet->GetItemState( *pPtr, sal_False, &pDef ))
1947cdf0e10cSrcweir 						pAkt->aAttrSet.Put( *pDef );
1948cdf0e10cSrcweir 					else
1949cdf0e10cSrcweir 						pAkt->aAttrSet.ClearItem( *pPtr );
1950cdf0e10cSrcweir 				}
1951cdf0e10cSrcweir 			}
1952cdf0e10cSrcweir 		}
1953cdf0e10cSrcweir 		else if( bPard )
1954cdf0e10cSrcweir 			pAkt->nStyleNo = 0;		// Style-Nummer zuruecksetzen
1955cdf0e10cSrcweir 
1956cdf0e10cSrcweir 		*ppSet = &pAkt->aAttrSet;
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir 		if (!bPard)
1959cdf0e10cSrcweir         {
1960cdf0e10cSrcweir             //Once we have a default font, then any text without a font specifier is
1961cdf0e10cSrcweir             //in the default font, and thus has the default font charset, otherwise
1962cdf0e10cSrcweir             //we can fall back to the ansicpg set codeset
1963cdf0e10cSrcweir             if (nDfltFont != -1)
1964cdf0e10cSrcweir             {
1965cdf0e10cSrcweir                 const Font& rSVFont = GetFont(sal_uInt16(nDfltFont));
1966cdf0e10cSrcweir                 SetEncoding(rSVFont.GetCharSet());
1967cdf0e10cSrcweir             }
1968cdf0e10cSrcweir             else
1969cdf0e10cSrcweir 			    SetEncoding(GetCodeSet());
1970cdf0e10cSrcweir         }
1971cdf0e10cSrcweir 	}
1972cdf0e10cSrcweir }
1973cdf0e10cSrcweir 
SetDefault(int nToken,int nValue)1974cdf0e10cSrcweir void SvxRTFParser::SetDefault( int nToken, int nValue )
1975cdf0e10cSrcweir {
1976cdf0e10cSrcweir 	if( !bNewDoc )
1977cdf0e10cSrcweir 		return;
1978cdf0e10cSrcweir 
1979cdf0e10cSrcweir 	SfxItemSet aTmp( *pAttrPool, aWhichMap.GetData() );
1980cdf0e10cSrcweir 	sal_Bool bOldFlag = bIsLeftToRightDef;
1981cdf0e10cSrcweir 	bIsLeftToRightDef = sal_True;
1982cdf0e10cSrcweir 	switch( nToken )
1983cdf0e10cSrcweir 	{
1984cdf0e10cSrcweir 	case RTF_ADEFF:	bIsLeftToRightDef = sal_False;  // no break!
1985cdf0e10cSrcweir 	case RTF_DEFF:
1986cdf0e10cSrcweir 		{
1987cdf0e10cSrcweir 			if( -1 == nValue )
1988cdf0e10cSrcweir 				nValue = 0;
1989cdf0e10cSrcweir 			const Font& rSVFont = GetFont( sal_uInt16(nValue) );
1990cdf0e10cSrcweir 			SvxFontItem aTmpItem(
1991cdf0e10cSrcweir 								rSVFont.GetFamily(), rSVFont.GetName(),
1992cdf0e10cSrcweir 								rSVFont.GetStyleName(),	rSVFont.GetPitch(),
1993cdf0e10cSrcweir 								rSVFont.GetCharSet(), SID_ATTR_CHAR_FONT );
1994cdf0e10cSrcweir 			SetScriptAttr( NOTDEF_CHARTYPE, aTmp, aTmpItem );
1995cdf0e10cSrcweir 		}
1996cdf0e10cSrcweir 		break;
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir 	case RTF_ADEFLANG:	bIsLeftToRightDef = sal_False;  // no break!
1999cdf0e10cSrcweir 	case RTF_DEFLANG:
2000cdf0e10cSrcweir 		// default Language merken
2001cdf0e10cSrcweir 		if( -1 != nValue )
2002cdf0e10cSrcweir 		{
2003cdf0e10cSrcweir 			SvxLanguageItem aTmpItem( (const LanguageType)nValue,
2004cdf0e10cSrcweir 									    SID_ATTR_CHAR_LANGUAGE );
2005cdf0e10cSrcweir 			SetScriptAttr( NOTDEF_CHARTYPE, aTmp, aTmpItem );
2006cdf0e10cSrcweir 		}
2007cdf0e10cSrcweir 		break;
2008cdf0e10cSrcweir 
2009cdf0e10cSrcweir 	case RTF_DEFTAB:
2010cdf0e10cSrcweir 		if( PARDID->nTabStop )
2011cdf0e10cSrcweir 		{
2012cdf0e10cSrcweir 			// RTF definiert 720 twips als default
2013cdf0e10cSrcweir 			bIsSetDfltTab = sal_True;
2014cdf0e10cSrcweir 			if( -1 == nValue || !nValue )
2015cdf0e10cSrcweir 				nValue = 720;
2016cdf0e10cSrcweir 
2017cdf0e10cSrcweir 			// wer keine Twips haben moechte ...
2018cdf0e10cSrcweir 			if( IsCalcValue() )
2019cdf0e10cSrcweir 			{
2020cdf0e10cSrcweir 				nTokenValue = nValue;
2021cdf0e10cSrcweir 				CalcValue();
2022cdf0e10cSrcweir 				nValue = nTokenValue;
2023cdf0e10cSrcweir 			}
2024cdf0e10cSrcweir #if 1
2025cdf0e10cSrcweir             /*
2026cdf0e10cSrcweir             cmc:
2027cdf0e10cSrcweir              This stuff looks a little hairy indeed, this should be totally
2028cdf0e10cSrcweir              unnecessary where default tabstops are understood. Just make one
2029cdf0e10cSrcweir              tabstop and stick the value in there, the first one is all that
2030cdf0e10cSrcweir              matters.
2031cdf0e10cSrcweir 
2032cdf0e10cSrcweir              e.g.
2033cdf0e10cSrcweir 
2034cdf0e10cSrcweir             SvxTabStopItem aNewTab(1, sal_uInt16(nValue), SVX_TAB_ADJUST_DEFAULT,
2035cdf0e10cSrcweir                 PARDID->nTabStop);
2036cdf0e10cSrcweir             ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
2037cdf0e10cSrcweir 
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir              It must exist as a foul hack to support somebody that does not
2040cdf0e10cSrcweir              have a true concept of default tabstops by making a tabsetting
2041cdf0e10cSrcweir              result from the default tabstop, creating a lot of them all at
2042cdf0e10cSrcweir              the default locations to give the effect of the first real
2043cdf0e10cSrcweir              default tabstop being in use just in case the receiving
2044cdf0e10cSrcweir              application doesn't do that for itself.
2045cdf0e10cSrcweir              */
2046cdf0e10cSrcweir #endif
2047cdf0e10cSrcweir 
2048cdf0e10cSrcweir 			// Verhaeltnis der def. TabWidth / Tabs errechnen und
2049cdf0e10cSrcweir 			// enstsprechend die neue Anzahl errechnen.
2050cdf0e10cSrcweir /*-----------------14.12.94 19:32-------------------
2051cdf0e10cSrcweir  ?? wie kommt man auf die 13 ??
2052cdf0e10cSrcweir --------------------------------------------------*/
2053cdf0e10cSrcweir 			sal_uInt16 nAnzTabs = (SVX_TAB_DEFDIST * 13 ) / sal_uInt16(nValue);
2054cdf0e10cSrcweir             /*
2055cdf0e10cSrcweir              cmc, make sure we have at least one, or all hell breaks loose in
2056cdf0e10cSrcweir              everybodies exporters, #i8247#
2057cdf0e10cSrcweir             */
2058cdf0e10cSrcweir             if (nAnzTabs < 1)
2059cdf0e10cSrcweir                 nAnzTabs = 1;
2060cdf0e10cSrcweir 
2061cdf0e10cSrcweir 			// wir wollen Defaulttabs
2062cdf0e10cSrcweir 			SvxTabStopItem aNewTab( nAnzTabs, sal_uInt16(nValue),
2063cdf0e10cSrcweir 								SVX_TAB_ADJUST_DEFAULT, PARDID->nTabStop );
2064cdf0e10cSrcweir 			while( nAnzTabs )
2065cdf0e10cSrcweir 				((SvxTabStop&)aNewTab[ --nAnzTabs ]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
2066cdf0e10cSrcweir 
2067cdf0e10cSrcweir 			pAttrPool->SetPoolDefaultItem( aNewTab );
2068cdf0e10cSrcweir 		}
2069cdf0e10cSrcweir 		break;
2070cdf0e10cSrcweir 	}
2071cdf0e10cSrcweir 	bIsLeftToRightDef = bOldFlag;
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir 	if( aTmp.Count() )
2074cdf0e10cSrcweir 	{
2075cdf0e10cSrcweir 		SfxItemIter aIter( aTmp );
2076cdf0e10cSrcweir 		const SfxPoolItem* pItem = aIter.GetCurItem();
2077cdf0e10cSrcweir 		while( sal_True )
2078cdf0e10cSrcweir 		{
2079cdf0e10cSrcweir 			pAttrPool->SetPoolDefaultItem( *pItem );
2080cdf0e10cSrcweir 			if( aIter.IsAtEnd() )
2081cdf0e10cSrcweir 				break;
2082cdf0e10cSrcweir 			pItem = aIter.NextItem();
2083cdf0e10cSrcweir 		}
2084cdf0e10cSrcweir 	}
2085cdf0e10cSrcweir }
2086cdf0e10cSrcweir 
2087cdf0e10cSrcweir // default: keine Umrechnung, alles bei Twips lassen.
CalcValue()2088cdf0e10cSrcweir void SvxRTFParser::CalcValue()
2089cdf0e10cSrcweir {
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir 	// fuer Tokens, die im ReadAttr nicht ausgewertet werden
UnknownAttrToken(int,SfxItemSet *)2093cdf0e10cSrcweir void SvxRTFParser::UnknownAttrToken( int, SfxItemSet* )
2094cdf0e10cSrcweir {
2095cdf0e10cSrcweir }
2096cdf0e10cSrcweir 
2097cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */
2098