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