1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rtfitem.cxx,v $
10 * $Revision: 1.35.212.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
36 #include "flstitem.hxx"
37 #include "fontitem.hxx"
38 #include <svx/postitem.hxx>
39 #include <svx/wghtitem.hxx>
40 #include <svx/fhgtitem.hxx>
41 #include "fwdtitem.hxx"
42 #include <svx/udlnitem.hxx>
43 #include <svx/crsditem.hxx>
44 #include <svx/shdditem.hxx>
45 #include <svx/akrnitem.hxx>
46 #include <svx/wrlmitem.hxx>
47 #include <svx/cntritem.hxx>
48 #include <svx/prszitem.hxx>
49 #include <svx/colritem.hxx>
50 #include <svx/cscoitem.hxx>
51 #include <svx/kernitem.hxx>
52 #include <svx/cmapitem.hxx>
53 #include <svx/escpitem.hxx>
54 #include <svx/langitem.hxx>
55 #include "nlbkitem.hxx"
56 #include <svx/nhypitem.hxx>
57 #include <svx/lcolitem.hxx>
58 #include <svx/blnkitem.hxx>
59 #include <svx/emphitem.hxx>
60 #include <svx/twolinesitem.hxx>
62 #include <svx/pbinitem.hxx>
63 #include <svx/sizeitem.hxx>
64 #include <svx/lrspitem.hxx>
65 #include <svx/ulspitem.hxx>
66 #include "prntitem.hxx"
67 #include "opaqitem.hxx"
68 #include "protitem.hxx"
69 #include <svx/shaditem.hxx>
70 #include <svx/boxitem.hxx>
71 #include <svx/brkitem.hxx>
72 #include <svx/keepitem.hxx>
73 #include "bolnitem.hxx"
74 #include <svx/brshitem.hxx>
75 #include <svx/lspcitem.hxx>
76 #include <svx/adjitem.hxx>
77 #include <svx/orphitem.hxx>
78 #include <svx/widwitem.hxx>
79 #include <svx/tstpitem.hxx>
80 #include <svx/pmdlitem.hxx>
81 #include <svx/spltitem.hxx>
82 #include <svx/hyznitem.hxx>
83 #include <svx/charscaleitem.hxx>
84 #include <svx/charrotateitem.hxx>
85 #include <svx/charreliefitem.hxx>
86 #include <svx/paravertalignitem.hxx>
87 #include <svx/forbiddenruleitem.hxx>
88 #include <svx/hngpnctitem.hxx>
89 #include <svx/scriptspaceitem.hxx>
90 #include <svx/frmdiritem.hxx>
91 #include "charhiddenitem.hxx"
94 #include <svtools/rtftoken.h>
95 #include <svtools/itempool.hxx>
96 #include <svtools/itemiter.hxx>
101 #define BRACELEFT '{'
102 #define BRACERIGHT '}'
105 // einige Hilfs-Funktionen
107 inline const SvxEscapementItem
& GetEscapement(const SfxItemSet
& rSet
,USHORT nId
,BOOL bInP
=TRUE
)
108 { return (const SvxEscapementItem
&)rSet
.Get( nId
,bInP
); }
109 inline const SvxLineSpacingItem
& GetLineSpacing(const SfxItemSet
& rSet
,USHORT nId
,BOOL bInP
=TRUE
)
110 { return (const SvxLineSpacingItem
&)rSet
.Get( nId
,bInP
); }
112 inline const SvxLRSpaceItem
& GetLRSpace(const SfxItemSet
& rSet
,USHORT nId
,BOOL bInP
=TRUE
)
113 { return (const SvxLRSpaceItem
&)rSet
.Get( nId
,bInP
); }
114 inline const SvxULSpaceItem
& GetULSpace(const SfxItemSet
& rSet
,USHORT nId
,BOOL bInP
=TRUE
)
115 { return (const SvxULSpaceItem
&)rSet
.Get( nId
,bInP
); }
117 #define PARDID ((RTFPardAttrMapIds*)aPardMap.GetData())
118 #define PLAINID ((RTFPlainAttrMapIds*)aPlainMap.GetData())
120 void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType
, SfxItemSet
& rSet
,
123 const USHORT
*pNormal
= 0, *pCJK
= 0, *pCTL
= 0;
124 const RTFPlainAttrMapIds
* pIds
= (RTFPlainAttrMapIds
*)aPlainMap
.GetData();
125 switch( rItem
.Which() )
127 case SID_ATTR_CHAR_FONT
:
128 pNormal
= &pIds
->nFont
;
129 pCJK
= &pIds
->nCJKFont
;
130 pCTL
= &pIds
->nCTLFont
;
133 case SID_ATTR_CHAR_FONTHEIGHT
:
134 pNormal
= &pIds
->nFontHeight
;
135 pCJK
= &pIds
->nCJKFontHeight
;
136 pCTL
= &pIds
->nCTLFontHeight
;
139 case SID_ATTR_CHAR_POSTURE
:
140 pNormal
= &pIds
->nPosture
;
141 pCJK
= &pIds
->nCJKPosture
;
142 pCTL
= &pIds
->nCTLPosture
;
145 case SID_ATTR_CHAR_WEIGHT
:
146 pNormal
= &pIds
->nWeight
;
147 pCJK
= &pIds
->nCJKWeight
;
148 pCTL
= &pIds
->nCTLWeight
;
151 case SID_ATTR_CHAR_LANGUAGE
:
152 pNormal
= &pIds
->nLanguage
;
153 pCJK
= &pIds
->nCJKLanguage
;
154 pCTL
= &pIds
->nCTLLanguage
;
158 // it exist no WhichId - don't set this item
167 if( DOUBLEBYTE_CHARTYPE
== eType
)
169 if( bIsLeftToRightDef
&& *pCJK
)
171 rItem
.SetWhich( *pCJK
);
175 else if( !bIsLeftToRightDef
)
179 rItem
.SetWhich( *pCTL
);
185 if( LOW_CHARTYPE
== eType
)
189 rItem
.SetWhich( *pNormal
);
193 else if( HIGH_CHARTYPE
== eType
)
197 rItem
.SetWhich( *pCTL
);
205 rItem
.SetWhich( *pCJK
);
210 rItem
.SetWhich( *pCTL
);
215 rItem
.SetWhich( *pNormal
);
222 // --------------------
224 void SvxRTFParser::ReadAttr( int nToken
, SfxItemSet
* pSet
)
226 DBG_ASSERT( pSet
, "Es muss ein SfxItemSet uebergeben werden!" );
227 int bFirstToken
= TRUE
, bWeiter
= TRUE
;
228 USHORT nStyleNo
= 0; // default
229 FontUnderline eUnderline
;
230 FontUnderline eOverline
;
231 FontEmphasisMark eEmphasis
;
232 bPardTokenRead
= FALSE
;
233 RTF_CharTypeDef eCharType
= NOTDEF_CHARTYPE
;
236 int bChkStkPos
= !bNewGroup
&& aAttrStack
.Top();
238 while( bWeiter
&& IsParserWorking() ) // solange bekannte Attribute erkannt werden
243 RTFPardPlain( TRUE
, &pSet
);
246 bPardTokenRead
= TRUE
;
250 RTFPardPlain( FALSE
, &pSet
);
254 do { // middle checked loop
258 SvxRTFItemStackType
* pAkt
= aAttrStack
.Top();
259 if( !pAkt
|| (pAkt
->pSttNd
->GetIdx() == pInsPos
->GetNodeIdx() &&
260 pAkt
->nSttCnt
== pInsPos
->GetCntIdx() ))
263 int nLastToken
= GetStackPtr(-1)->nTokenId
;
264 if( RTF_PARD
== nLastToken
|| RTF_PLAIN
== nLastToken
)
267 if( pAkt
->aAttrSet
.Count() || pAkt
->pChildList
||
270 // eine neue Gruppe aufmachen
271 SvxRTFItemStackType
* pNew
= new SvxRTFItemStackType(
272 *pAkt
, *pInsPos
, TRUE
);
273 pNew
->SetRTFDefaults( GetRTFDefaults() );
275 // alle bis hierher gueltigen Attribute "setzen"
277 pAkt
= aAttrStack
.Top(); // can be changed after AttrGroupEnd!
278 pNew
->aAttrSet
.SetParent( pAkt
? &pAkt
->aAttrSet
: 0 );
280 aAttrStack
.Push( pNew
);
284 // diesen Eintrag als neuen weiterbenutzen
285 pAkt
->SetStartPos( *pInsPos
);
287 pSet
= &pAkt
->aAttrSet
;
298 UnknownAttrToken( nToken
, pSet
);
302 if( bIsInReadStyleTab
)
310 nStyleNo
= -1 == nTokenValue
? 0 : USHORT(nTokenValue
);
311 // setze am akt. auf dem AttrStack stehenden Style die
313 SvxRTFItemStackType
* pAkt
= aAttrStack
.Top();
317 pAkt
->nStyleNo
= USHORT( nStyleNo
);
320 // JP 05.09.95: zuruecksetzen der Style-Attribute fuehrt nur zu Problemen.
321 // Es muss reichen, wenn das ueber pard/plain erfolgt
322 // ansonsten Bugdoc 15304.rtf - nach nur "\pard" falscher Font !!
324 SvxRTFStyleType
* pStyle
= aStyleTbl
.Get( pAkt
->nStyleNo
);
325 if( pStyle
&& pStyle
->aAttrSet
.Count() )
328 // alle Attribute, die in der Vorlage gesetzt werden
329 // auf defaults setzen. In RTF werden die Attribute
330 // der Vorlage danach ja wiederholt.
331 // WICHTIG: Attribute die in der Vorlage definiert
332 // sind, werden zurueckgesetzt !!!!
333 // pAkt->aAttrSet.Put( pStyle->aAttrSet );
335 SfxItemIter
aIter( pStyle
->aAttrSet
);
336 SfxItemPool
* pPool
= pStyle
->aAttrSet
.GetPool();
337 USHORT nWh
= aIter
.GetCurItem()->Which();
340 pAkt
->aAttrSet
.Put( pPool
->GetDefaultItem( nWh
));
341 if( aIter
.IsAtEnd() )
343 nWh
= aIter
.NextItem()->Which();
353 pSet
->Put( SvxFmtSplitItem( FALSE
, PARDID
->nSplit
));
360 pSet
->Put( SvxFmtKeepItem( TRUE
, PARDID
->nKeep
));
365 if( PARDID
->nOutlineLvl
)
367 pSet
->Put( SfxUInt16Item( PARDID
->nOutlineLvl
,
368 (UINT16
)nTokenValue
));
373 if( PARDID
->nAdjust
)
375 pSet
->Put( SvxAdjustItem( SVX_ADJUST_LEFT
, PARDID
->nAdjust
));
379 if( PARDID
->nAdjust
)
381 pSet
->Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, PARDID
->nAdjust
));
385 if( PARDID
->nAdjust
)
387 pSet
->Put( SvxAdjustItem( SVX_ADJUST_BLOCK
, PARDID
->nAdjust
));
391 if( PARDID
->nAdjust
)
393 pSet
->Put( SvxAdjustItem( SVX_ADJUST_CENTER
, PARDID
->nAdjust
));
398 if( PARDID
->nLRSpace
)
400 SvxLRSpaceItem
aLR( GetLRSpace(*pSet
, PARDID
->nLRSpace
));
402 if( -1 != nTokenValue
)
406 nSz
= USHORT(nTokenValue
);
408 aLR
.SetTxtFirstLineOfst( nSz
);
415 if( PARDID
->nLRSpace
)
417 SvxLRSpaceItem
aLR( GetLRSpace(*pSet
, PARDID
->nLRSpace
));
419 if( 0 < nTokenValue
)
423 nSz
= USHORT(nTokenValue
);
425 aLR
.SetTxtLeft( nSz
);
432 if( PARDID
->nLRSpace
)
434 SvxLRSpaceItem
aLR( GetLRSpace(*pSet
, PARDID
->nLRSpace
));
436 if( 0 < nTokenValue
)
440 nSz
= USHORT(nTokenValue
);
448 if( PARDID
->nULSpace
)
450 SvxULSpaceItem
aUL( GetULSpace(*pSet
, PARDID
->nULSpace
));
452 if( 0 < nTokenValue
)
456 nSz
= USHORT(nTokenValue
);
464 if( PARDID
->nULSpace
)
466 SvxULSpaceItem
aUL( GetULSpace(*pSet
, PARDID
->nULSpace
));
468 if( 0 < nTokenValue
)
472 nSz
= USHORT(nTokenValue
);
480 if( PARDID
->nLinespacing
&& 1 == nTokenValue
)
482 // dann wird auf mehrzeilig umgeschaltet!
483 SvxLineSpacingItem
aLSpace( GetLineSpacing( *pSet
,
484 PARDID
->nLinespacing
, FALSE
));
486 // wieviel bekommt man aus dem LineHeight Wert heraus
488 // Proportionale-Groesse:
489 // D.H. das Verhaeltnis ergibt sich aus ( n / 240 ) Twips
495 nTokenValue
= short( 100L * aLSpace
.GetLineHeight()
496 / long( nTokenValue
) );
498 if( nTokenValue
> 200 ) // Datenwert fuer PropLnSp
499 nTokenValue
= 200; // ist ein BYTE !!!
501 aLSpace
.SetPropLineSpace( (const BYTE
)nTokenValue
);
502 aLSpace
.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO
;
504 pSet
->Put( aLSpace
);
509 if( PARDID
->nLinespacing
)
511 // errechne das Verhaeltnis aus dem default Font zu der
512 // Size Angabe. Der Abstand besteht aus der Zeilenhoehe
513 // (100%) und dem Leerraum ueber der Zeile (20%).
514 SvxLineSpacingItem
aLSpace(0, PARDID
->nLinespacing
);
516 nTokenValue
= !bTokenHasValue
? 0 : nTokenValue
;
517 if (1000 == nTokenValue
)
523 eLnSpc
= SVX_LINE_SPACE_FIX
;
524 nTokenValue
= -nTokenValue
;
526 else if (nTokenValue
== 0)
528 //if \sl0 is used, the line spacing is automatically
530 eLnSpc
= SVX_LINE_SPACE_AUTO
;
533 eLnSpc
= SVX_LINE_SPACE_MIN
;
538 if (eLnSpc
!= SVX_LINE_SPACE_AUTO
)
539 aLSpace
.SetLineHeight( (const USHORT
)nTokenValue
);
541 aLSpace
.GetLineSpaceRule() = eLnSpc
;
547 if( PARDID
->nForbRule
)
549 pSet
->Put( SvxForbiddenRuleItem( FALSE
,
550 PARDID
->nForbRule
));
554 if( PARDID
->nHangPunct
)
556 pSet
->Put( SvxHangingPunctuationItem( FALSE
,
557 PARDID
->nHangPunct
));
562 if( PARDID
->nScriptSpace
)
564 pSet
->Put( SvxScriptSpaceItem( TRUE
,
565 PARDID
->nScriptSpace
));
570 case RTF_FAAUTO
: nFontAlign
= SvxParaVertAlignItem::AUTOMATIC
;
571 goto SET_FONTALIGNMENT
;
572 case RTF_FAHANG
: nFontAlign
= SvxParaVertAlignItem::TOP
;
573 goto SET_FONTALIGNMENT
;
574 case RTF_FAVAR
: nFontAlign
= SvxParaVertAlignItem::BOTTOM
;
575 goto SET_FONTALIGNMENT
;
576 case RTF_FACENTER
: nFontAlign
= SvxParaVertAlignItem::CENTER
;
577 goto SET_FONTALIGNMENT
;
578 case RTF_FAROMAN
: nFontAlign
= SvxParaVertAlignItem::BASELINE
;
579 goto SET_FONTALIGNMENT
;
581 if( PARDID
->nFontAlign
)
583 pSet
->Put( SvxParaVertAlignItem( nFontAlign
,
584 PARDID
->nFontAlign
));
591 if( IsAttrSttPos() ) // nicht im Textfluss ?
594 SvxWeightItem
aTmpItem(
595 nTokenValue
? WEIGHT_BOLD
: WEIGHT_NORMAL
,
596 SID_ATTR_CHAR_WEIGHT
);
597 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
603 if( PLAINID
->nCaseMap
&&
604 IsAttrSttPos() ) // nicht im Textfluss ?
608 eCaseMap
= SVX_CASEMAP_NOT_MAPPED
;
609 else if( RTF_CAPS
== nToken
)
610 eCaseMap
= SVX_CASEMAP_VERSALIEN
;
612 eCaseMap
= SVX_CASEMAP_KAPITAELCHEN
;
614 pSet
->Put( SvxCaseMapItem( eCaseMap
, PLAINID
->nCaseMap
));
620 if( PLAINID
->nEscapement
)
622 const USHORT nEsc
= PLAINID
->nEscapement
;
623 if( -1 == nTokenValue
|| RTF_SUB
== nToken
)
627 const SvxEscapementItem
& rOld
= GetEscapement( *pSet
, nEsc
, FALSE
);
630 if( DFLT_ESC_AUTO_SUPER
== rOld
.GetEsc() )
632 nEs
= DFLT_ESC_AUTO_SUB
;
633 nProp
= rOld
.GetProp();
637 nEs
= (short)-nTokenValue
;
638 nProp
= (nToken
== RTF_SUB
) ? DFLT_ESC_PROP
: 100;
640 pSet
->Put( SvxEscapementItem( nEs
, nProp
, nEsc
));
645 if( PLAINID
->nEscapement
)
647 const USHORT nEsc
= PLAINID
->nEscapement
;
648 pSet
->Put( SvxEscapementItem( nEsc
));
653 if( PLAINID
->nKering
)
655 if( -1 == nTokenValue
)
661 pSet
->Put( SvxKerningItem( (short)nTokenValue
, PLAINID
->nKering
));
666 if( PLAINID
->nAutoKerning
)
668 if( -1 == nTokenValue
)
674 pSet
->Put( SvxAutoKernItem( 0 != nTokenValue
,
675 PLAINID
->nAutoKerning
));
680 if( PLAINID
->nKering
)
682 if( -1 == nTokenValue
)
686 pSet
->Put( SvxKerningItem( (short)nTokenValue
, PLAINID
->nKering
));
693 const Font
& rSVFont
= GetFont( USHORT(nTokenValue
) );
694 SvxFontItem
aTmpItem( rSVFont
.GetFamily(),
695 rSVFont
.GetName(), rSVFont
.GetStyleName(),
696 rSVFont
.GetPitch(), rSVFont
.GetCharSet(),
697 SID_ATTR_CHAR_FONT
);
698 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
699 if( RTF_F
== nToken
)
701 SetEncoding( rSVFont
.GetCharSet() );
710 if( -1 == nTokenValue
)
715 // for the SwRTFParser 'IsCalcValue' will be false and for the EditRTFParser
716 // the converiosn takes now place in EditRTFParser since for other reasons
717 // the wrong MapUnit might still be use there
718 // if( IsCalcValue() )
720 SvxFontHeightItem
aTmpItem(
721 (const USHORT
)nTokenValue
, 100,
722 SID_ATTR_CHAR_FONTHEIGHT
);
723 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
729 if( IsAttrSttPos() ) // nicht im Textfluss ?
731 SvxPostureItem
aTmpItem(
732 nTokenValue
? ITALIC_NORMAL
: ITALIC_NONE
,
733 SID_ATTR_CHAR_POSTURE
);
734 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
739 if( PLAINID
->nContour
&&
740 IsAttrSttPos() ) // nicht im Textfluss ?
742 pSet
->Put( SvxContourItem( nTokenValue
? TRUE
: FALSE
,
743 PLAINID
->nContour
));
748 if( PLAINID
->nShadowed
&&
749 IsAttrSttPos() ) // nicht im Textfluss ?
751 pSet
->Put( SvxShadowedItem( nTokenValue
? TRUE
: FALSE
,
752 PLAINID
->nShadowed
));
757 if( PLAINID
->nCrossedOut
&&
758 IsAttrSttPos() ) // nicht im Textfluss ?
760 pSet
->Put( SvxCrossedOutItem(
761 nTokenValue
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
,
762 PLAINID
->nCrossedOut
));
767 if( PLAINID
->nCrossedOut
) // nicht im Textfluss ?
769 pSet
->Put( SvxCrossedOutItem(
770 nTokenValue
? STRIKEOUT_DOUBLE
: STRIKEOUT_NONE
,
771 PLAINID
->nCrossedOut
));
776 if( !IsAttrSttPos() )
778 eUnderline
= nTokenValue
? UNDERLINE_SINGLE
: UNDERLINE_NONE
;
779 goto ATTR_SETUNDERLINE
;
782 eUnderline
= UNDERLINE_DOTTED
;
783 goto ATTR_SETUNDERLINE
;
785 eUnderline
= UNDERLINE_DASH
;
786 goto ATTR_SETUNDERLINE
;
788 eUnderline
= UNDERLINE_DASHDOT
;
789 goto ATTR_SETUNDERLINE
;
791 eUnderline
= UNDERLINE_DASHDOTDOT
;
792 goto ATTR_SETUNDERLINE
;
794 eUnderline
= UNDERLINE_DOUBLE
;
795 goto ATTR_SETUNDERLINE
;
797 eUnderline
= UNDERLINE_NONE
;
798 goto ATTR_SETUNDERLINE
;
800 eUnderline
= UNDERLINE_BOLD
;
801 goto ATTR_SETUNDERLINE
;
803 eUnderline
= UNDERLINE_WAVE
;
804 goto ATTR_SETUNDERLINE
;
806 eUnderline
= UNDERLINE_BOLDDOTTED
;
807 goto ATTR_SETUNDERLINE
;
809 eUnderline
= UNDERLINE_BOLDDASH
;
810 goto ATTR_SETUNDERLINE
;
812 eUnderline
= UNDERLINE_LONGDASH
;
813 goto ATTR_SETUNDERLINE
;
815 eUnderline
= UNDERLINE_BOLDLONGDASH
;
816 goto ATTR_SETUNDERLINE
;
818 eUnderline
= UNDERLINE_BOLDDASHDOT
;
819 goto ATTR_SETUNDERLINE
;
821 eUnderline
= UNDERLINE_BOLDDASHDOTDOT
;
822 goto ATTR_SETUNDERLINE
;
824 eUnderline
= UNDERLINE_BOLDWAVE
;
825 goto ATTR_SETUNDERLINE
;
827 eUnderline
= UNDERLINE_DOUBLEWAVE
;
828 goto ATTR_SETUNDERLINE
;
831 eUnderline
= UNDERLINE_SINGLE
;
833 if( PLAINID
->nWordlineMode
)
835 pSet
->Put( SvxWordLineModeItem( TRUE
, PLAINID
->nWordlineMode
));
837 goto ATTR_SETUNDERLINE
;
840 if( PLAINID
->nUnderline
)
842 pSet
->Put( SvxUnderlineItem( eUnderline
, PLAINID
->nUnderline
));
847 if( PLAINID
->nUnderline
)
849 SvxUnderlineItem
aUL( UNDERLINE_SINGLE
, PLAINID
->nUnderline
);
850 const SfxPoolItem
* pItem
;
851 if( SFX_ITEM_SET
== pSet
->GetItemState(
852 PLAINID
->nUnderline
, FALSE
, &pItem
) )
855 if( UNDERLINE_NONE
==
856 ((SvxUnderlineItem
*)pItem
)->GetLineStyle() )
858 aUL
= *(SvxUnderlineItem
*)pItem
;
861 aUL
= (const SvxUnderlineItem
&)pSet
->Get( PLAINID
->nUnderline
, FALSE
);
863 if( UNDERLINE_NONE
== aUL
.GetLineStyle() )
864 aUL
.SetLineStyle( UNDERLINE_SINGLE
);
865 aUL
.SetColor( GetColor( USHORT(nTokenValue
) ));
871 if( !IsAttrSttPos() )
873 eOverline
= nTokenValue
? UNDERLINE_SINGLE
: UNDERLINE_NONE
;
874 goto ATTR_SETOVERLINE
;
877 eOverline
= UNDERLINE_DOTTED
;
878 goto ATTR_SETOVERLINE
;
880 eOverline
= UNDERLINE_DASH
;
881 goto ATTR_SETOVERLINE
;
883 eOverline
= UNDERLINE_DASHDOT
;
884 goto ATTR_SETOVERLINE
;
886 eOverline
= UNDERLINE_DASHDOTDOT
;
887 goto ATTR_SETOVERLINE
;
889 eOverline
= UNDERLINE_DOUBLE
;
890 goto ATTR_SETOVERLINE
;
892 eOverline
= UNDERLINE_NONE
;
893 goto ATTR_SETOVERLINE
;
895 eOverline
= UNDERLINE_BOLD
;
896 goto ATTR_SETOVERLINE
;
898 eOverline
= UNDERLINE_WAVE
;
899 goto ATTR_SETOVERLINE
;
901 eOverline
= UNDERLINE_BOLDDOTTED
;
902 goto ATTR_SETOVERLINE
;
904 eOverline
= UNDERLINE_BOLDDASH
;
905 goto ATTR_SETOVERLINE
;
907 eOverline
= UNDERLINE_LONGDASH
;
908 goto ATTR_SETOVERLINE
;
910 eOverline
= UNDERLINE_BOLDLONGDASH
;
911 goto ATTR_SETOVERLINE
;
913 eOverline
= UNDERLINE_BOLDDASHDOT
;
914 goto ATTR_SETOVERLINE
;
916 eOverline
= UNDERLINE_BOLDDASHDOTDOT
;
917 goto ATTR_SETOVERLINE
;
919 eOverline
= UNDERLINE_BOLDWAVE
;
920 goto ATTR_SETOVERLINE
;
922 eOverline
= UNDERLINE_DOUBLEWAVE
;
923 goto ATTR_SETOVERLINE
;
926 eOverline
= UNDERLINE_SINGLE
;
928 if( PLAINID
->nWordlineMode
)
930 pSet
->Put( SvxWordLineModeItem( TRUE
, PLAINID
->nWordlineMode
));
932 goto ATTR_SETOVERLINE
;
935 if( PLAINID
->nUnderline
)
937 pSet
->Put( SvxOverlineItem( eOverline
, PLAINID
->nOverline
));
942 if( PLAINID
->nOverline
)
944 SvxOverlineItem
aOL( UNDERLINE_SINGLE
, PLAINID
->nOverline
);
945 const SfxPoolItem
* pItem
;
946 if( SFX_ITEM_SET
== pSet
->GetItemState(
947 PLAINID
->nOverline
, FALSE
, &pItem
) )
950 if( UNDERLINE_NONE
==
951 ((SvxOverlineItem
*)pItem
)->GetLineStyle() )
953 aOL
= *(SvxOverlineItem
*)pItem
;
956 aOL
= (const SvxOverlineItem
&)pSet
->Get( PLAINID
->nUnderline
, FALSE
);
958 if( UNDERLINE_NONE
== aOL
.GetLineStyle() )
959 aOL
.SetLineStyle( UNDERLINE_SINGLE
);
960 aOL
.SetColor( GetColor( USHORT(nTokenValue
) ));
967 if( PLAINID
->nEscapement
)
969 const USHORT nEsc
= PLAINID
->nEscapement
;
970 if( -1 == nTokenValue
|| RTF_SUPER
== nToken
)
974 const SvxEscapementItem
& rOld
= GetEscapement( *pSet
, nEsc
, FALSE
);
977 if( DFLT_ESC_AUTO_SUB
== rOld
.GetEsc() )
979 nEs
= DFLT_ESC_AUTO_SUPER
;
980 nProp
= rOld
.GetProp();
984 nEs
= (short)nTokenValue
;
985 nProp
= (nToken
== RTF_SUPER
) ? DFLT_ESC_PROP
: 100;
987 pSet
->Put( SvxEscapementItem( nEs
, nProp
, nEsc
));
992 if( PLAINID
->nColor
)
994 pSet
->Put( SvxColorItem( GetColor( USHORT(nTokenValue
) ),
999 //#i12501# While cb is clearly documented in the rtf spec, word
1000 //doesn't accept it at all
1002 if( PLAINID
->nBgColor
)
1004 pSet
->Put( SvxBrushItem( GetColor( USHORT(nTokenValue
) ),
1005 PLAINID
->nBgColor
));
1010 if( PLAINID
->nLanguage
)
1012 pSet
->Put( SvxLanguageItem( (LanguageType
)nTokenValue
,
1013 PLAINID
->nLanguage
));
1018 if( PLAINID
->nCJKLanguage
)
1020 pSet
->Put( SvxLanguageItem( (LanguageType
)nTokenValue
,
1021 PLAINID
->nCJKLanguage
));
1026 SvxLanguageItem
aTmpItem( (LanguageType
)nTokenValue
,
1027 SID_ATTR_CHAR_LANGUAGE
);
1028 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
1033 bIsLeftToRightDef
= FALSE
;
1036 bIsLeftToRightDef
= TRUE
;
1039 if (PARDID
->nDirection
)
1041 pSet
->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP
,
1042 PARDID
->nDirection
));
1046 if (PARDID
->nDirection
)
1048 pSet
->Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP
,
1049 PARDID
->nDirection
));
1052 case RTF_LOCH
: eCharType
= LOW_CHARTYPE
; break;
1053 case RTF_HICH
: eCharType
= HIGH_CHARTYPE
; break;
1054 case RTF_DBCH
: eCharType
= DOUBLEBYTE_CHARTYPE
; break;
1058 eEmphasis
= EMPHASISMARK_NONE
;
1059 goto ATTR_SETEMPHASIS
;
1061 eEmphasis
= EMPHASISMARK_DOTS_ABOVE
;
1062 goto ATTR_SETEMPHASIS
;
1065 eEmphasis
= EMPHASISMARK_SIDE_DOTS
;
1067 if( PLAINID
->nEmphasis
)
1069 pSet
->Put( SvxEmphasisMarkItem( eEmphasis
,
1070 PLAINID
->nEmphasis
));
1075 if( PLAINID
->nTwoLines
)
1077 sal_Unicode cStt
, cEnd
;
1078 switch ( nTokenValue
)
1080 case 1: cStt
= '(', cEnd
= ')'; break;
1081 case 2: cStt
= '[', cEnd
= ']'; break;
1082 case 3: cStt
= '<', cEnd
= '>'; break;
1083 case 4: cStt
= '{', cEnd
= '}'; break;
1084 default: cStt
= 0, cEnd
= 0; break;
1087 pSet
->Put( SvxTwoLinesItem( TRUE
, cStt
, cEnd
,
1088 PLAINID
->nTwoLines
));
1092 case RTF_CHARSCALEX
:
1093 if (PLAINID
->nCharScaleX
)
1096 if (nTokenValue
< 1 || nTokenValue
> 600)
1098 pSet
->Put( SvxCharScaleWidthItem( USHORT(nTokenValue
),
1099 PLAINID
->nCharScaleX
));
1104 if( PLAINID
->nHorzVert
)
1106 // RTF knows only 90deg
1107 pSet
->Put( SvxCharRotateItem( 900, 1 == nTokenValue
,
1108 PLAINID
->nHorzVert
));
1113 if (PLAINID
->nRelief
)
1115 pSet
->Put(SvxCharReliefItem(RELIEF_EMBOSSED
,
1120 if (PLAINID
->nRelief
)
1122 pSet
->Put(SvxCharReliefItem(RELIEF_ENGRAVED
,
1127 if (PLAINID
->nHidden
)
1129 pSet
->Put(SvxCharHiddenItem(nTokenValue
!= 0,
1134 case RTF_CHBGDKVERT
:
1135 case RTF_CHBGDKHORIZ
:
1138 case RTF_CHBGDKFDIAG
:
1139 case RTF_CHBGDCROSS
:
1142 case RTF_CHBGDKDCROSS
:
1143 case RTF_CHBGDKCROSS
:
1144 case RTF_CHBGDKBDIAG
:
1148 if( PLAINID
->nBgColor
)
1149 ReadBackgroundAttr( nToken
, *pSet
);
1157 // teste auf Swg-Interne Tokens
1158 bool bHandled
= false;
1160 if( RTF_IGNOREFLAG
!= GetNextToken())
1162 else if( (nToken
= GetNextToken() ) & RTF_SWGDEFS
)
1170 UnknownAttrToken( nToken
, pSet
);
1171 // ueberlese die schliessende Klammer
1174 case RTF_SWG_ESCPROP
:
1176 // prozentuale Veraenderung speichern !
1177 BYTE nProp
= BYTE( nTokenValue
/ 100 );
1179 if( 1 == ( nTokenValue
% 100 ))
1180 // Erkennung unseres AutoFlags!
1181 nEsc
= DFLT_ESC_AUTO_SUPER
;
1183 if( PLAINID
->nEscapement
)
1184 pSet
->Put( SvxEscapementItem( nEsc
, nProp
,
1185 PLAINID
->nEscapement
));
1191 SvxHyphenZoneItem
aHypenZone(
1192 (nTokenValue
& 1) ? TRUE
: FALSE
,
1193 PARDID
->nHyphenzone
);
1194 aHypenZone
.SetPageEnd(
1195 (nTokenValue
& 2) ? TRUE
: FALSE
);
1197 if( PARDID
->nHyphenzone
&&
1198 RTF_HYPHLEAD
== GetNextToken() &&
1199 RTF_HYPHTRAIL
== GetNextToken() &&
1200 RTF_HYPHMAX
== GetNextToken() )
1202 aHypenZone
.GetMinLead() =
1203 BYTE(GetStackPtr( -2 )->nTokenValue
);
1204 aHypenZone
.GetMinTrail() =
1205 BYTE(GetStackPtr( -1 )->nTokenValue
);
1206 aHypenZone
.GetMaxHyphens() =
1209 pSet
->Put( aHypenZone
);
1212 SkipGroup(); // ans Ende der Gruppe
1219 do { // middle check loop
1220 SvxShadowLocation eSL
= SvxShadowLocation( nTokenValue
);
1221 if( RTF_SHDW_DIST
!= GetNextToken() )
1223 USHORT nDist
= USHORT( nTokenValue
);
1225 if( RTF_SHDW_STYLE
!= GetNextToken() )
1227 //! (pb) class Brush removed -> obsolete
1228 //! BrushStyle eStyle = BrushStyle( nTokenValue );
1230 if( RTF_SHDW_COL
!= GetNextToken() )
1232 USHORT nCol
= USHORT( nTokenValue
);
1234 if( RTF_SHDW_FCOL
!= GetNextToken() )
1236 // USHORT nFillCol = USHORT( nTokenValue );
1238 Color aColor
= GetColor( nCol
);
1240 if( PARDID
->nShadow
)
1241 pSet
->Put( SvxShadowItem( PARDID
->nShadow
,
1242 &aColor
, nDist
, eSL
) );
1248 SkipGroup(); // ans Ende der Gruppe
1254 if( (nToken
& ~(0xff | RTF_SWGDEFS
)) == RTF_TABSTOPDEF
)
1256 nToken
= SkipToken( -2 );
1257 ReadTabAttr( nToken
, *pSet
);
1260 cmc: #i76140, he who consumed the { must consume the }
1261 We rewound to a state of { being the current
1262 token so it is our responsibility to consume the }
1263 token if we consumed the {. We will not have consumed
1264 the { if it belonged to our caller, i.e. if the { we
1265 are handling is the "firsttoken" passed to us then
1266 the *caller* must consume it, not us. Otherwise *we*
1269 if (nToken
== BRACELEFT
&& !bFirstToken
)
1271 nToken
= GetNextToken();
1272 DBG_ASSERT( nToken
== BRACERIGHT
,
1273 "} did not follow { as expected\n");
1276 else if( (nToken
& ~(0xff| RTF_SWGDEFS
)) == RTF_BRDRDEF
)
1278 nToken
= SkipToken( -2 );
1279 ReadBorderAttr( nToken
, *pSet
);
1281 else // also kein Attribut mehr
1288 cmc: #i4727# / #i12713# Who owns this closing bracket?
1289 If we read the opening one, we must read this one, if
1290 other is counting the brackets so as to push/pop off
1291 the correct environment then we will have pushed a new
1292 environment for the start { of this, but will not see
1293 the } and so is out of sync for the rest of the
1296 if (bHandled
&& !bFirstToken
)
1303 if( nSkip
) // alles voellig unbekannt
1306 --nSkip
; // BRACELEFT: ist das naechste Token
1313 if( (nToken
& ~0xff ) == RTF_TABSTOPDEF
)
1314 ReadTabAttr( nToken
, *pSet
);
1315 else if( (nToken
& ~0xff ) == RTF_BRDRDEF
)
1316 ReadBorderAttr( nToken
, *pSet
);
1317 else if( (nToken
& ~0xff ) == RTF_SHADINGDEF
)
1318 ReadBackgroundAttr( nToken
, *pSet
);
1321 // kenne das Token nicht also das Token "in den Parser zurueck"
1330 nToken
= GetNextToken();
1332 bFirstToken
= FALSE
;
1336 // teste Attribute gegen ihre Styles
1337 if( IsChkStyleAttr() && pSet->Count() && !pInsPos->GetCntIdx() )
1339 SvxRTFStyleType* pStyle = aStyleTbl.Get( nStyleNo );
1340 if( pStyle && pStyle->aAttrSet.Count() )
1342 // alle Attribute, die schon vom Style definiert sind, aus dem
1343 // akt. Set entfernen
1344 const SfxPoolItem* pItem;
1345 SfxItemIter aIter( *pSet );
1346 USHORT nWhich = aIter.GetCurItem()->Which();
1349 if( SFX_ITEM_SET == pStyle->aAttrSet.GetItemState(
1350 nWhich, FALSE, &pItem ) && *pItem == *aIter.GetCurItem())
1351 pSet->ClearItem( nWhich ); // loeschen
1353 if( aIter.IsAtEnd() )
1355 nWhich = aIter.NextItem()->Which();
1362 void SvxRTFParser::ReadTabAttr( int nToken
, SfxItemSet
& rSet
)
1364 bool bMethodOwnsToken
= false; // #i52542# patch from cmc.
1365 // dann lese doch mal alle TabStops ein
1366 SvxTabStop aTabStop
;
1367 SvxTabStopItem
aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT
, PARDID
->nTabStop
);
1372 case RTF_TB
: // BarTab ???
1377 aTabStop
.GetTabPos() = nTokenValue
;
1378 aAttr
.Insert( aTabStop
);
1379 aTabStop
= SvxTabStop(); // alle Werte default
1384 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_LEFT
;
1387 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_RIGHT
;
1390 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_CENTER
;
1393 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL
;
1396 case RTF_TLDOT
: aTabStop
.GetFill() = '.'; break;
1397 case RTF_TLHYPH
: aTabStop
.GetFill() = ' '; break;
1398 case RTF_TLUL
: aTabStop
.GetFill() = '_'; break;
1399 case RTF_TLTH
: aTabStop
.GetFill() = '-'; break;
1400 case RTF_TLEQ
: aTabStop
.GetFill() = '='; break;
1404 // Swg - Kontrol BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT
1406 if( RTF_IGNOREFLAG
!= GetNextToken() )
1408 else if( RTF_TLSWG
!= ( nToken
= GetNextToken() ))
1412 aTabStop
.GetDecimal() = BYTE(nTokenValue
& 0xff);
1413 aTabStop
.GetFill() = BYTE((nTokenValue
>> 8) & 0xff);
1414 // ueberlese noch die schliessende Klammer
1415 if (bMethodOwnsToken
)
1420 SkipToken( nSkip
); // Ignore wieder zurueck
1431 nToken
= GetNextToken();
1432 bMethodOwnsToken
= true;
1436 // mit Defaults aufuellen fehlt noch !!!
1441 static void SetBorderLine( int nBorderTyp
, SvxBoxItem
& rItem
,
1442 const SvxBorderLine
& rBorder
)
1444 switch( nBorderTyp
)
1446 case RTF_BOX
: // alle Stufen durchlaufen
1449 rItem
.SetLine( &rBorder
, BOX_LINE_TOP
);
1450 if( RTF_BOX
!= nBorderTyp
)
1454 rItem
.SetLine( &rBorder
, BOX_LINE_BOTTOM
);
1455 if( RTF_BOX
!= nBorderTyp
)
1459 rItem
.SetLine( &rBorder
, BOX_LINE_LEFT
);
1460 if( RTF_BOX
!= nBorderTyp
)
1464 rItem
.SetLine( &rBorder
, BOX_LINE_RIGHT
);
1465 if( RTF_BOX
!= nBorderTyp
)
1470 void SvxRTFParser::ReadBorderAttr( int nToken
, SfxItemSet
& rSet
,
1473 // dann lese doch mal das BoderAttribut ein
1474 SvxBoxItem
aAttr( PARDID
->nBox
);
1475 const SfxPoolItem
* pItem
;
1476 if( SFX_ITEM_SET
== rSet
.GetItemState( PARDID
->nBox
, FALSE
, &pItem
) )
1477 aAttr
= *(SvxBoxItem
*)pItem
;
1479 SvxBorderLine
aBrd( 0, DEF_LINE_WIDTH_0
, 0, 0 ); // einfache Linien
1480 int bWeiter
= TRUE
, nBorderTyp
= 0;
1490 nBorderTyp
= nToken
;
1496 nBorderTyp
= RTF_BRDRT
;
1501 nBorderTyp
= RTF_BRDRB
;
1506 nBorderTyp
= RTF_BRDRL
;
1511 nBorderTyp
= RTF_BRDRR
;
1516 // auf defaults setzen
1517 aBrd
.SetOutWidth( DEF_LINE_WIDTH_0
);
1518 aBrd
.SetInWidth( 0 );
1519 aBrd
.SetDistance( 0 );
1520 aBrd
.SetColor( Color( COL_BLACK
) );
1525 // werden noch nicht ausgewertet
1528 switch( nBorderTyp
)
1531 aAttr
.SetDistance( (USHORT
)nTokenValue
, BOX_LINE_BOTTOM
);
1535 aAttr
.SetDistance( (USHORT
)nTokenValue
, BOX_LINE_TOP
);
1539 aAttr
.SetDistance( (USHORT
)nTokenValue
, BOX_LINE_LEFT
);
1543 aAttr
.SetDistance( (USHORT
)nTokenValue
, BOX_LINE_RIGHT
);
1547 aAttr
.SetDistance( (USHORT
)nTokenValue
);
1554 case RTF_BRDRBAR
: break;
1559 aBrd
.SetColor( GetColor( USHORT(nTokenValue
) ) );
1560 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1565 aBrd
.SetOutWidth( DEF_LINE_WIDTH_1
);
1566 aBrd
.SetInWidth( 0 );
1567 aBrd
.SetDistance( 0 );
1571 aBrd
.SetOutWidth( DEF_DOUBLE_LINE0_OUT
);
1572 aBrd
.SetInWidth( DEF_DOUBLE_LINE0_IN
);
1573 aBrd
.SetDistance( DEF_DOUBLE_LINE0_DIST
);
1579 rSet
.Put( SvxShadowItem( PARDID
->nShadow
, (Color
*) 0, 60 /*3pt*/,
1580 SVX_SHADOW_BOTTOMRIGHT
) );
1585 if( -1 != nTokenValue
)
1587 // sollte es eine "dicke" Linie sein ?
1588 if( DEF_LINE_WIDTH_0
!= aBrd
.GetOutWidth() )
1592 if( aBrd
.GetInWidth() )
1594 // WinWord - Werte an StarOffice anpassen
1595 if( nTokenValue
< DEF_LINE_WIDTH_1
- (DEF_LINE_WIDTH_1
/10))
1597 aBrd
.SetOutWidth( DEF_DOUBLE_LINE0_OUT
);
1598 aBrd
.SetInWidth( DEF_DOUBLE_LINE0_IN
);
1599 aBrd
.SetDistance( DEF_DOUBLE_LINE0_DIST
);
1602 if( nTokenValue
< DEF_LINE_WIDTH_2
- (DEF_LINE_WIDTH_2
/10))
1604 aBrd
.SetOutWidth( DEF_DOUBLE_LINE1_OUT
);
1605 aBrd
.SetInWidth( DEF_DOUBLE_LINE1_IN
);
1606 aBrd
.SetDistance( DEF_DOUBLE_LINE1_DIST
);
1610 aBrd
.SetOutWidth( DEF_DOUBLE_LINE2_OUT
);
1611 aBrd
.SetInWidth( DEF_DOUBLE_LINE2_IN
);
1612 aBrd
.SetDistance( DEF_DOUBLE_LINE2_DIST
);
1617 // WinWord - Werte an StarOffice anpassen
1618 if( nTokenValue
< DEF_LINE_WIDTH_1
- (DEF_LINE_WIDTH_1
/10))
1619 aBrd
.SetOutWidth( DEF_LINE_WIDTH_0
);
1621 if( nTokenValue
< DEF_LINE_WIDTH_2
- (DEF_LINE_WIDTH_2
/10))
1622 aBrd
.SetOutWidth( DEF_LINE_WIDTH_1
);
1624 if( nTokenValue
< DEF_LINE_WIDTH_3
- (DEF_LINE_WIDTH_3
/10))
1625 aBrd
.SetOutWidth( DEF_LINE_WIDTH_2
);
1627 if( nTokenValue
< DEF_LINE_WIDTH_4
)
1628 aBrd
.SetOutWidth( DEF_LINE_WIDTH_3
);
1630 aBrd
.SetOutWidth( DEF_LINE_WIDTH_4
);
1640 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1646 if( RTF_IGNOREFLAG
!= GetNextToken() )
1650 int bSwgControl
= TRUE
, bFirstToken
= TRUE
;
1651 nToken
= GetNextToken();
1656 aAttr
.SetDistance( USHORT(nTokenValue
) );
1663 nBorderTyp
= nToken
;
1664 bFirstToken
= FALSE
;
1665 if( RTF_BRDLINE_COL
!= GetNextToken() )
1667 bSwgControl
= FALSE
;
1670 aBrd
.SetColor( GetColor( USHORT(nTokenValue
) ));
1672 if( RTF_BRDLINE_IN
!= GetNextToken() )
1674 bSwgControl
= FALSE
;
1677 aBrd
.SetInWidth( USHORT(nTokenValue
));
1679 if( RTF_BRDLINE_OUT
!= GetNextToken() )
1681 bSwgControl
= FALSE
;
1684 aBrd
.SetOutWidth( USHORT(nTokenValue
));
1686 if( RTF_BRDLINE_DIST
!= GetNextToken() )
1688 bSwgControl
= FALSE
;
1691 aBrd
.SetDistance( USHORT(nTokenValue
));
1692 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1696 bSwgControl
= FALSE
;
1702 nToken
= GetNextToken();
1703 bFirstToken
= FALSE
;
1705 } while( bSwgControl
);
1707 // Ende der Swg-Gruppe
1708 // -> lese noch die schliessende Klammer
1709 if( BRACERIGHT
== nToken
)
1711 else if( !bFirstToken
)
1713 // es ist ein Parser-Fehler, springe zum
1716 // schliessende BRACERIGHT ueberspringen
1725 SkipToken( nSkip
); // Ignore wieder zurueck
1732 bWeiter
= (nToken
& ~(0xff| RTF_SWGDEFS
)) == RTF_BRDRDEF
;
1735 nToken
= GetNextToken();
1741 inline ULONG
CalcShading( ULONG nColor
, ULONG nFillColor
, BYTE nShading
)
1743 nColor
= (nColor
* nShading
) / 100;
1744 nFillColor
= (nFillColor
* ( 100 - nShading
)) / 100;
1745 return nColor
+ nFillColor
;
1748 void SvxRTFParser::ReadBackgroundAttr( int nToken
, SfxItemSet
& rSet
,
1751 // dann lese doch mal das BoderAttribut ein
1753 USHORT nColor
= USHRT_MAX
, nFillColor
= USHRT_MAX
;
1754 BYTE nFillValue
= 0;
1756 USHORT nWh
= ( nToken
& ~0xff ) == RTF_CHRFMT
1766 nFillColor
= USHORT( nTokenValue
);
1772 nColor
= USHORT( nTokenValue
);
1778 nFillValue
= (BYTE
)( nTokenValue
/ 100 );
1782 case RTF_CHBGDKHORIZ
:
1784 case RTF_CLBGDKVERT
:
1785 case RTF_CHBGDKVERT
:
1787 case RTF_CLBGDKBDIAG
:
1788 case RTF_CHBGDKBDIAG
:
1790 case RTF_CLBGDKFDIAG
:
1791 case RTF_CHBGDKFDIAG
:
1793 case RTF_CLBGDKCROSS
:
1794 case RTF_CHBGDKCROSS
:
1796 case RTF_CLBGDKDCROSS
:
1797 case RTF_CHBGDKDCROSS
:
1798 case RTF_BGDKDCROSS
:
1818 case RTF_CLBGDCROSS
:
1819 case RTF_CHBGDCROSS
:
1827 bWeiter
= (nToken
& ~(0xff | RTF_TABLEDEF
) ) == RTF_SHADINGDEF
;
1829 bWeiter
= (nToken
& ~0xff) == RTF_SHADINGDEF
;
1832 nToken
= GetNextToken();
1835 Color
aCol( COL_WHITE
), aFCol
;
1838 // es wurde nur eine von beiden Farben angegeben oder kein BrushTyp
1839 if( USHRT_MAX
!= nFillColor
)
1842 aCol
= GetColor( nFillColor
);
1844 else if( USHRT_MAX
!= nColor
)
1845 aFCol
= GetColor( nColor
);
1849 if( USHRT_MAX
!= nColor
)
1850 aCol
= GetColor( nColor
);
1852 aCol
= Color( COL_BLACK
);
1854 if( USHRT_MAX
!= nFillColor
)
1855 aFCol
= GetColor( nFillColor
);
1857 aFCol
= Color( COL_WHITE
);
1861 if( 0 == nFillValue
|| 100 == nFillValue
)
1865 (BYTE
)CalcShading( aCol
.GetRed(), aFCol
.GetRed(), nFillValue
),
1866 (BYTE
)CalcShading( aCol
.GetGreen(), aFCol
.GetGreen(), nFillValue
),
1867 (BYTE
)CalcShading( aCol
.GetBlue(), aFCol
.GetBlue(), nFillValue
) );
1869 rSet
.Put( SvxBrushItem( aColor
, nWh
) );
1874 // pard / plain abarbeiten
1875 void SvxRTFParser::RTFPardPlain( int bPard
, SfxItemSet
** ppSet
)
1877 if( !bNewGroup
&& aAttrStack
.Top() ) // nicht am Anfang einer neuen Gruppe
1879 SvxRTFItemStackType
* pAkt
= aAttrStack
.Top();
1881 int nLastToken
= GetStackPtr(-1)->nTokenId
;
1882 int bNewStkEntry
= TRUE
;
1883 if( RTF_PARD
!= nLastToken
&&
1884 RTF_PLAIN
!= nLastToken
&&
1885 BRACELEFT
!= nLastToken
)
1887 if( pAkt
->aAttrSet
.Count() || pAkt
->pChildList
|| pAkt
->nStyleNo
)
1889 // eine neue Gruppe aufmachen
1890 SvxRTFItemStackType
* pNew
= new SvxRTFItemStackType( *pAkt
, *pInsPos
, TRUE
);
1891 pNew
->SetRTFDefaults( GetRTFDefaults() );
1893 // alle bis hierher gueltigen Attribute "setzen"
1895 pAkt
= aAttrStack
.Top(); // can be changed after AttrGroupEnd!
1896 pNew
->aAttrSet
.SetParent( pAkt
? &pAkt
->aAttrSet
: 0 );
1897 aAttrStack
.Push( pNew
);
1902 // diesen Eintrag als neuen weiterbenutzen
1903 pAkt
->SetStartPos( *pInsPos
);
1904 bNewStkEntry
= FALSE
;
1908 // jetzt noch alle auf default zuruecksetzen
1910 ( pAkt
->aAttrSet
.GetParent() || pAkt
->aAttrSet
.Count() ))
1912 const SfxPoolItem
*pItem
, *pDef
;
1915 const SfxItemSet
* pDfltSet
= &GetRTFDefaults();
1919 pPtr
= aPardMap
.GetData();
1920 nCnt
= aPardMap
.Count();
1924 pPtr
= aPlainMap
.GetData();
1925 nCnt
= aPlainMap
.Count();
1928 for( USHORT n
= 0; n
< nCnt
; ++n
, ++pPtr
)
1930 // Item gesetzt und unterschiedlich -> das Pooldefault setzen
1931 //JP 06.04.98: bei Items die nur SlotItems sind, darf nicht
1932 // auf das Default zugefriffen werden. Diese
1936 else if( SFX_WHICH_MAX
< *pPtr
)
1937 pAkt
->aAttrSet
.ClearItem( *pPtr
);
1938 else if( IsChkStyleAttr() )
1939 pAkt
->aAttrSet
.Put( pDfltSet
->Get( *pPtr
) );
1940 else if( !pAkt
->aAttrSet
.GetParent() )
1943 pDfltSet
->GetItemState( *pPtr
, FALSE
, &pDef
))
1944 pAkt
->aAttrSet
.Put( *pDef
);
1946 pAkt
->aAttrSet
.ClearItem( *pPtr
);
1948 else if( SFX_ITEM_SET
== pAkt
->aAttrSet
.GetParent()->
1949 GetItemState( *pPtr
, TRUE
, &pItem
) &&
1950 *( pDef
= &pDfltSet
->Get( *pPtr
)) != *pItem
)
1951 pAkt
->aAttrSet
.Put( *pDef
);
1955 pDfltSet
->GetItemState( *pPtr
, FALSE
, &pDef
))
1956 pAkt
->aAttrSet
.Put( *pDef
);
1958 pAkt
->aAttrSet
.ClearItem( *pPtr
);
1963 pAkt
->nStyleNo
= 0; // Style-Nummer zuruecksetzen
1965 *ppSet
= &pAkt
->aAttrSet
;
1969 //Once we have a default font, then any text without a font specifier is
1970 //in the default font, and thus has the default font charset, otherwise
1971 //we can fall back to the ansicpg set codeset
1972 if (nDfltFont
!= -1)
1974 const Font
& rSVFont
= GetFont(USHORT(nDfltFont
));
1975 SetEncoding(rSVFont
.GetCharSet());
1978 SetEncoding(GetCodeSet());
1983 void SvxRTFParser::SetDefault( int nToken
, int nValue
)
1988 SfxItemSet
aTmp( *pAttrPool
, aWhichMap
.GetData() );
1989 BOOL bOldFlag
= bIsLeftToRightDef
;
1990 bIsLeftToRightDef
= TRUE
;
1993 case RTF_ADEFF
: bIsLeftToRightDef
= FALSE
; // no break!
1998 const Font
& rSVFont
= GetFont( USHORT(nValue
) );
1999 SvxFontItem
aTmpItem(
2000 rSVFont
.GetFamily(), rSVFont
.GetName(),
2001 rSVFont
.GetStyleName(), rSVFont
.GetPitch(),
2002 rSVFont
.GetCharSet(), SID_ATTR_CHAR_FONT
);
2003 SetScriptAttr( NOTDEF_CHARTYPE
, aTmp
, aTmpItem
);
2007 case RTF_ADEFLANG
: bIsLeftToRightDef
= FALSE
; // no break!
2009 // default Language merken
2012 SvxLanguageItem
aTmpItem( (const LanguageType
)nValue
,
2013 SID_ATTR_CHAR_LANGUAGE
);
2014 SetScriptAttr( NOTDEF_CHARTYPE
, aTmp
, aTmpItem
);
2019 if( PARDID
->nTabStop
)
2021 // RTF definiert 720 twips als default
2022 bIsSetDfltTab
= TRUE
;
2023 if( -1 == nValue
|| !nValue
)
2026 // wer keine Twips haben moechte ...
2029 nTokenValue
= nValue
;
2031 nValue
= nTokenValue
;
2036 This stuff looks a little hairy indeed, this should be totally
2037 unnecessary where default tabstops are understood. Just make one
2038 tabstop and stick the value in there, the first one is all that
2043 SvxTabStopItem aNewTab(1, USHORT(nValue), SVX_TAB_ADJUST_DEFAULT,
2045 ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT;
2048 It must exist as a foul hack to support somebody that does not
2049 have a true concept of default tabstops by making a tabsetting
2050 result from the default tabstop, creating a lot of them all at
2051 the default locations to give the effect of the first real
2052 default tabstop being in use just in case the receiving
2053 application doesn't do that for itself.
2057 // Verhaeltnis der def. TabWidth / Tabs errechnen und
2058 // enstsprechend die neue Anzahl errechnen.
2059 /*-----------------14.12.94 19:32-------------------
2060 ?? wie kommt man auf die 13 ??
2061 --------------------------------------------------*/
2062 USHORT nAnzTabs
= (SVX_TAB_DEFDIST
* 13 ) / USHORT(nValue
);
2064 cmc, make sure we have at least one, or all hell breaks loose in
2065 everybodies exporters, #i8247#
2070 // wir wollen Defaulttabs
2071 SvxTabStopItem
aNewTab( nAnzTabs
, USHORT(nValue
),
2072 SVX_TAB_ADJUST_DEFAULT
, PARDID
->nTabStop
);
2074 ((SvxTabStop
&)aNewTab
[ --nAnzTabs
]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT
;
2076 pAttrPool
->SetPoolDefaultItem( aNewTab
);
2080 bIsLeftToRightDef
= bOldFlag
;
2084 SfxItemIter
aIter( aTmp
);
2085 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
2088 pAttrPool
->SetPoolDefaultItem( *pItem
);
2089 if( aIter
.IsAtEnd() )
2091 pItem
= aIter
.NextItem();
2096 // default: keine Umrechnung, alles bei Twips lassen.
2097 void SvxRTFParser::CalcValue()
2101 // fuer Tokens, die im ReadAttr nicht ausgewertet werden
2102 void SvxRTFParser::UnknownAttrToken( int, SfxItemSet
* )
2106 /* vi:set tabstop=4 shiftwidth=4 expandtab: */