1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <editeng/flstitem.hxx>
31 #include <editeng/fontitem.hxx>
32 #include <editeng/postitem.hxx>
33 #include <editeng/wghtitem.hxx>
34 #include <editeng/fhgtitem.hxx>
35 #include <editeng/fwdtitem.hxx>
36 #include <editeng/udlnitem.hxx>
37 #include <editeng/crsditem.hxx>
38 #include <editeng/shdditem.hxx>
39 #include <editeng/akrnitem.hxx>
40 #include <editeng/wrlmitem.hxx>
41 #include <editeng/cntritem.hxx>
42 #include <editeng/prszitem.hxx>
43 #include <editeng/colritem.hxx>
44 #include <editeng/cscoitem.hxx>
45 #include <editeng/kernitem.hxx>
46 #include <editeng/cmapitem.hxx>
47 #include <editeng/escpitem.hxx>
48 #include <editeng/langitem.hxx>
49 #include <editeng/nlbkitem.hxx>
50 #include <editeng/nhypitem.hxx>
51 #include <editeng/lcolitem.hxx>
52 #include <editeng/blnkitem.hxx>
53 #include <editeng/emphitem.hxx>
54 #include <editeng/twolinesitem.hxx>
55 #include <editeng/pbinitem.hxx>
56 #include <editeng/sizeitem.hxx>
57 #include <editeng/lrspitem.hxx>
58 #include <editeng/ulspitem.hxx>
59 #include <editeng/prntitem.hxx>
60 #include <editeng/opaqitem.hxx>
61 #include <editeng/protitem.hxx>
62 #include <editeng/shaditem.hxx>
63 #include <editeng/boxitem.hxx>
64 #include <editeng/brkitem.hxx>
65 #include <editeng/keepitem.hxx>
66 #include <editeng/bolnitem.hxx>
67 #include <editeng/brshitem.hxx>
68 #include <editeng/lspcitem.hxx>
69 #include <editeng/adjitem.hxx>
70 #include <editeng/orphitem.hxx>
71 #include <editeng/widwitem.hxx>
72 #include <editeng/tstpitem.hxx>
73 #include <editeng/pmdlitem.hxx>
74 #include <editeng/spltitem.hxx>
75 #include <editeng/hyznitem.hxx>
76 #include <editeng/charscaleitem.hxx>
77 #include <editeng/charrotateitem.hxx>
78 #include <editeng/charreliefitem.hxx>
79 #include <editeng/paravertalignitem.hxx>
80 #include <editeng/forbiddenruleitem.hxx>
81 #include <editeng/hngpnctitem.hxx>
82 #include <editeng/scriptspaceitem.hxx>
83 #include <editeng/frmdiritem.hxx>
84 #include <editeng/charhiddenitem.hxx>
86 #include <svtools/rtftoken.h>
87 #include <svl/itempool.hxx>
88 #include <svl/itemiter.hxx>
90 #include <editeng/svxrtf.hxx>
91 #include <editeng/editids.hrc>
94 #define BRACERIGHT '}'
96 using namespace ::com::sun::star
;
97 using namespace editeng
;
99 // Some helper functions
101 inline const SvxEscapementItem
& GetEscapement(const SfxItemSet
& rSet
,sal_uInt16 nId
,sal_Bool bInP
=sal_True
)
102 { return (const SvxEscapementItem
&)rSet
.Get( nId
,bInP
); }
103 inline const SvxLineSpacingItem
& GetLineSpacing(const SfxItemSet
& rSet
,sal_uInt16 nId
,sal_Bool bInP
=sal_True
)
104 { return (const SvxLineSpacingItem
&)rSet
.Get( nId
,bInP
); }
106 inline const SvxLRSpaceItem
& GetLRSpace(const SfxItemSet
& rSet
,sal_uInt16 nId
,sal_Bool bInP
=sal_True
)
107 { return (const SvxLRSpaceItem
&)rSet
.Get( nId
,bInP
); }
108 inline const SvxULSpaceItem
& GetULSpace(const SfxItemSet
& rSet
,sal_uInt16 nId
,sal_Bool bInP
=sal_True
)
109 { return (const SvxULSpaceItem
&)rSet
.Get( nId
,bInP
); }
111 #define PARDID ((RTFPardAttrMapIds*)&aPardMap[0])
112 #define PLAINID ((RTFPlainAttrMapIds*)&aPlainMap[0])
114 void SvxRTFParser::SetScriptAttr( RTF_CharTypeDef eType
, SfxItemSet
& rSet
,
117 const sal_uInt16
*pNormal
= 0, *pCJK
= 0, *pCTL
= 0;
118 const RTFPlainAttrMapIds
* pIds
= (RTFPlainAttrMapIds
*)&aPlainMap
[0];
119 switch( rItem
.Which() )
121 case SID_ATTR_CHAR_FONT
:
122 pNormal
= &pIds
->nFont
;
123 pCJK
= &pIds
->nCJKFont
;
124 pCTL
= &pIds
->nCTLFont
;
127 case SID_ATTR_CHAR_FONTHEIGHT
:
128 pNormal
= &pIds
->nFontHeight
;
129 pCJK
= &pIds
->nCJKFontHeight
;
130 pCTL
= &pIds
->nCTLFontHeight
;
133 case SID_ATTR_CHAR_POSTURE
:
134 pNormal
= &pIds
->nPosture
;
135 pCJK
= &pIds
->nCJKPosture
;
136 pCTL
= &pIds
->nCTLPosture
;
139 case SID_ATTR_CHAR_WEIGHT
:
140 pNormal
= &pIds
->nWeight
;
141 pCJK
= &pIds
->nCJKWeight
;
142 pCTL
= &pIds
->nCTLWeight
;
145 case SID_ATTR_CHAR_LANGUAGE
:
146 pNormal
= &pIds
->nLanguage
;
147 pCJK
= &pIds
->nCJKLanguage
;
148 pCTL
= &pIds
->nCTLLanguage
;
152 // it exist no WhichId - don't set this item
161 if( DOUBLEBYTE_CHARTYPE
== eType
)
163 if( bIsLeftToRightDef
&& *pCJK
)
165 rItem
.SetWhich( *pCJK
);
169 else if( !bIsLeftToRightDef
)
173 rItem
.SetWhich( *pCTL
);
179 if( LOW_CHARTYPE
== eType
)
183 rItem
.SetWhich( *pNormal
);
187 else if( HIGH_CHARTYPE
== eType
)
191 rItem
.SetWhich( *pCTL
);
199 rItem
.SetWhich( *pCJK
);
204 rItem
.SetWhich( *pCTL
);
209 rItem
.SetWhich( *pNormal
);
216 // --------------------
218 void SvxRTFParser::ReadAttr( int nToken
, SfxItemSet
* pSet
)
220 DBG_ASSERT( pSet
, "A SfxItemSet has to be provided as argument!" );
221 int bFirstToken
= sal_True
, bWeiter
= sal_True
;
222 sal_uInt16 nStyleNo
= 0; // default
223 FontUnderline eUnderline
;
224 FontUnderline eOverline
;
225 FontEmphasisMark eEmphasis
;
226 bPardTokenRead
= sal_False
;
227 RTF_CharTypeDef eCharType
= NOTDEF_CHARTYPE
;
228 sal_uInt16 nFontAlign
;
230 int bChkStkPos
= !bNewGroup
&& !aAttrStack
.empty();
232 while( bWeiter
&& IsParserWorking() ) // as long as known Attribute are recognized
237 RTFPardPlain( sal_True
, &pSet
);
240 bPardTokenRead
= sal_True
;
244 RTFPardPlain( sal_False
, &pSet
);
248 do { // middle checked loop
252 SvxRTFItemStackType
* pAkt
= aAttrStack
.empty() ? 0 : aAttrStack
.back();
253 if( !pAkt
|| (pAkt
->pSttNd
->GetIdx() == pInsPos
->GetNodeIdx() &&
254 pAkt
->nSttCnt
== pInsPos
->GetCntIdx() ))
257 int nLastToken
= GetStackPtr(-1)->nTokenId
;
258 if( RTF_PARD
== nLastToken
|| RTF_PLAIN
== nLastToken
)
261 if( pAkt
->aAttrSet
.Count() || pAkt
->pChildList
||
265 SvxRTFItemStackType
* pNew
= new SvxRTFItemStackType(
266 *pAkt
, *pInsPos
, sal_True
);
267 pNew
->SetRTFDefaults( GetRTFDefaults() );
269 // "Set" all valid attributes up until this point
271 pAkt
= aAttrStack
.empty() ? 0 : aAttrStack
.back(); // can be changed after AttrGroupEnd!
272 pNew
->aAttrSet
.SetParent( pAkt
? &pAkt
->aAttrSet
: 0 );
274 aAttrStack
.push_back( pNew
);
278 // continue to use this entry as a new one
279 pAkt
->SetStartPos( *pInsPos
);
281 pSet
= &pAkt
->aAttrSet
;
282 } while( sal_False
);
292 UnknownAttrToken( nToken
, pSet
);
296 if( bIsInReadStyleTab
)
304 nStyleNo
= -1 == nTokenValue
? 0 : sal_uInt16(nTokenValue
);
305 // setze am akt. auf dem AttrStack stehenden Style die
307 SvxRTFItemStackType
* pAkt
= aAttrStack
.empty() ? 0 : aAttrStack
.back();
311 pAkt
->nStyleNo
= sal_uInt16( nStyleNo
);
319 pSet
->Put( SvxFmtSplitItem( sal_False
, PARDID
->nSplit
));
326 pSet
->Put( SvxFmtKeepItem( sal_True
, PARDID
->nKeep
));
331 if( PARDID
->nOutlineLvl
)
333 pSet
->Put( SfxUInt16Item( PARDID
->nOutlineLvl
,
334 (sal_uInt16
)nTokenValue
));
339 if( PARDID
->nAdjust
)
341 pSet
->Put( SvxAdjustItem( SVX_ADJUST_LEFT
, PARDID
->nAdjust
));
345 if( PARDID
->nAdjust
)
347 pSet
->Put( SvxAdjustItem( SVX_ADJUST_RIGHT
, PARDID
->nAdjust
));
351 if( PARDID
->nAdjust
)
353 pSet
->Put( SvxAdjustItem( SVX_ADJUST_BLOCK
, PARDID
->nAdjust
));
357 if( PARDID
->nAdjust
)
359 pSet
->Put( SvxAdjustItem( SVX_ADJUST_CENTER
, PARDID
->nAdjust
));
364 if( PARDID
->nLRSpace
)
366 SvxLRSpaceItem
aLR( GetLRSpace(*pSet
, PARDID
->nLRSpace
));
368 if( -1 != nTokenValue
)
372 nSz
= sal_uInt16(nTokenValue
);
374 aLR
.SetTxtFirstLineOfst( nSz
);
381 if( PARDID
->nLRSpace
)
383 SvxLRSpaceItem
aLR( GetLRSpace(*pSet
, PARDID
->nLRSpace
));
385 if( 0 < nTokenValue
)
389 nSz
= sal_uInt16(nTokenValue
);
391 aLR
.SetTxtLeft( nSz
);
398 if( PARDID
->nLRSpace
)
400 SvxLRSpaceItem
aLR( GetLRSpace(*pSet
, PARDID
->nLRSpace
));
402 if( 0 < nTokenValue
)
406 nSz
= sal_uInt16(nTokenValue
);
414 if( PARDID
->nULSpace
)
416 SvxULSpaceItem
aUL( GetULSpace(*pSet
, PARDID
->nULSpace
));
418 if( 0 < nTokenValue
)
422 nSz
= sal_uInt16(nTokenValue
);
430 if( PARDID
->nULSpace
)
432 SvxULSpaceItem
aUL( GetULSpace(*pSet
, PARDID
->nULSpace
));
434 if( 0 < nTokenValue
)
438 nSz
= sal_uInt16(nTokenValue
);
446 if( PARDID
->nLinespacing
&& 1 == nTokenValue
)
448 // then switches to multi-line!
449 SvxLineSpacingItem
aLSpace( GetLineSpacing( *pSet
,
450 PARDID
->nLinespacing
, sal_False
));
452 // how much do you get from the line height value?
454 // Proportional-Size:
455 // Ie, the ratio is (n / 240) twips
461 nTokenValue
= short( 100L * aLSpace
.GetLineHeight()
462 / long( nTokenValue
) );
464 if( nTokenValue
> 200 ) // Data value for PropLnSp
465 nTokenValue
= 200; // is one BYTE !!!
467 aLSpace
.SetPropLineSpace( (const sal_uInt8
)nTokenValue
);
468 aLSpace
.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO
;
470 pSet
->Put( aLSpace
);
475 if( PARDID
->nLinespacing
)
477 // Calculate the ratio between the default font and the
478 // specified size. The distance consists of the line height
479 // (100%) and the space above the line (20%).
480 SvxLineSpacingItem
aLSpace(0, PARDID
->nLinespacing
);
482 nTokenValue
= !bTokenHasValue
? 0 : nTokenValue
;
483 if (1000 == nTokenValue
)
489 eLnSpc
= SVX_LINE_SPACE_FIX
;
490 nTokenValue
= -nTokenValue
;
492 else if (nTokenValue
== 0)
494 //if \sl0 is used, the line spacing is automatically
496 eLnSpc
= SVX_LINE_SPACE_AUTO
;
499 eLnSpc
= SVX_LINE_SPACE_MIN
;
504 if (eLnSpc
!= SVX_LINE_SPACE_AUTO
)
505 aLSpace
.SetLineHeight( (const sal_uInt16
)nTokenValue
);
507 aLSpace
.GetLineSpaceRule() = eLnSpc
;
513 if( PARDID
->nForbRule
)
515 pSet
->Put( SvxForbiddenRuleItem( sal_False
,
516 PARDID
->nForbRule
));
520 if( PARDID
->nHangPunct
)
522 pSet
->Put( SvxHangingPunctuationItem( sal_False
,
523 PARDID
->nHangPunct
));
528 if( PARDID
->nScriptSpace
)
530 pSet
->Put( SvxScriptSpaceItem( sal_True
,
531 PARDID
->nScriptSpace
));
536 case RTF_FAAUTO
: nFontAlign
= SvxParaVertAlignItem::AUTOMATIC
;
537 goto SET_FONTALIGNMENT
;
538 case RTF_FAHANG
: nFontAlign
= SvxParaVertAlignItem::TOP
;
539 goto SET_FONTALIGNMENT
;
540 case RTF_FAVAR
: nFontAlign
= SvxParaVertAlignItem::BOTTOM
;
541 goto SET_FONTALIGNMENT
;
542 case RTF_FACENTER
: nFontAlign
= SvxParaVertAlignItem::CENTER
;
543 goto SET_FONTALIGNMENT
;
544 case RTF_FAROMAN
: nFontAlign
= SvxParaVertAlignItem::BASELINE
;
545 goto SET_FONTALIGNMENT
;
547 if( PARDID
->nFontAlign
)
549 pSet
->Put( SvxParaVertAlignItem( nFontAlign
,
550 PARDID
->nFontAlign
));
556 if( IsAttrSttPos() ) // not in the text flow?
559 SvxWeightItem
aTmpItem(
560 nTokenValue
? WEIGHT_BOLD
: WEIGHT_NORMAL
,
561 SID_ATTR_CHAR_WEIGHT
);
562 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
568 if( PLAINID
->nCaseMap
&&
569 IsAttrSttPos() ) // not in the text flow?
573 eCaseMap
= SVX_CASEMAP_NOT_MAPPED
;
574 else if( RTF_CAPS
== nToken
)
575 eCaseMap
= SVX_CASEMAP_VERSALIEN
;
577 eCaseMap
= SVX_CASEMAP_KAPITAELCHEN
;
579 pSet
->Put( SvxCaseMapItem( eCaseMap
, PLAINID
->nCaseMap
));
585 if( PLAINID
->nEscapement
)
587 const sal_uInt16 nEsc
= PLAINID
->nEscapement
;
588 if( -1 == nTokenValue
|| RTF_SUB
== nToken
)
592 const SvxEscapementItem
& rOld
= GetEscapement( *pSet
, nEsc
, sal_False
);
595 if( DFLT_ESC_AUTO_SUPER
== rOld
.GetEsc() )
597 nEs
= DFLT_ESC_AUTO_SUB
;
598 nProp
= rOld
.GetProp();
602 nEs
= (short)-nTokenValue
;
603 nProp
= (nToken
== RTF_SUB
) ? DFLT_ESC_PROP
: 100;
605 pSet
->Put( SvxEscapementItem( nEs
, nProp
, nEsc
));
610 if( PLAINID
->nEscapement
)
612 const sal_uInt16 nEsc
= PLAINID
->nEscapement
;
613 pSet
->Put( SvxEscapementItem( nEsc
));
618 if( PLAINID
->nKering
)
620 if( -1 == nTokenValue
)
626 pSet
->Put( SvxKerningItem( (short)nTokenValue
, PLAINID
->nKering
));
631 if( PLAINID
->nAutoKerning
)
633 if( -1 == nTokenValue
)
639 pSet
->Put( SvxAutoKernItem( 0 != nTokenValue
,
640 PLAINID
->nAutoKerning
));
645 if( PLAINID
->nKering
)
647 if( -1 == nTokenValue
)
651 pSet
->Put( SvxKerningItem( (short)nTokenValue
, PLAINID
->nKering
));
658 const Font
& rSVFont
= GetFont( sal_uInt16(nTokenValue
) );
659 SvxFontItem
aTmpItem( rSVFont
.GetFamily(),
660 rSVFont
.GetName(), rSVFont
.GetStyleName(),
661 rSVFont
.GetPitch(), rSVFont
.GetCharSet(),
662 SID_ATTR_CHAR_FONT
);
663 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
664 if( RTF_F
== nToken
)
666 SetEncoding( rSVFont
.GetCharSet() );
675 if( -1 == nTokenValue
)
680 // for the SwRTFParser 'IsCalcValue' will be false and for the EditRTFParser
681 // the converiosn takes now place in EditRTFParser since for other reasons
682 // the wrong MapUnit might still be use there
683 // if( IsCalcValue() )
685 SvxFontHeightItem
aTmpItem(
686 (const sal_uInt16
)nTokenValue
, 100,
687 SID_ATTR_CHAR_FONTHEIGHT
);
688 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
694 if( IsAttrSttPos() ) // not in the text flow?
696 SvxPostureItem
aTmpItem(
697 nTokenValue
? ITALIC_NORMAL
: ITALIC_NONE
,
698 SID_ATTR_CHAR_POSTURE
);
699 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
704 if( PLAINID
->nContour
&&
705 IsAttrSttPos() ) // not in the text flow?
707 pSet
->Put( SvxContourItem( nTokenValue
? sal_True
: sal_False
,
708 PLAINID
->nContour
));
713 if( PLAINID
->nShadowed
&&
714 IsAttrSttPos() ) // not in the text flow?
716 pSet
->Put( SvxShadowedItem( nTokenValue
? sal_True
: sal_False
,
717 PLAINID
->nShadowed
));
722 if( PLAINID
->nCrossedOut
&&
723 IsAttrSttPos() ) // not in the text flow?
725 pSet
->Put( SvxCrossedOutItem(
726 nTokenValue
? STRIKEOUT_SINGLE
: STRIKEOUT_NONE
,
727 PLAINID
->nCrossedOut
));
732 if( PLAINID
->nCrossedOut
) // not in the text flow?
734 pSet
->Put( SvxCrossedOutItem(
735 nTokenValue
? STRIKEOUT_DOUBLE
: STRIKEOUT_NONE
,
736 PLAINID
->nCrossedOut
));
741 if( !IsAttrSttPos() )
743 eUnderline
= nTokenValue
? UNDERLINE_SINGLE
: UNDERLINE_NONE
;
744 goto ATTR_SETUNDERLINE
;
747 eUnderline
= UNDERLINE_DOTTED
;
748 goto ATTR_SETUNDERLINE
;
750 eUnderline
= UNDERLINE_DASH
;
751 goto ATTR_SETUNDERLINE
;
753 eUnderline
= UNDERLINE_DASHDOT
;
754 goto ATTR_SETUNDERLINE
;
756 eUnderline
= UNDERLINE_DASHDOTDOT
;
757 goto ATTR_SETUNDERLINE
;
759 eUnderline
= UNDERLINE_DOUBLE
;
760 goto ATTR_SETUNDERLINE
;
762 eUnderline
= UNDERLINE_NONE
;
763 goto ATTR_SETUNDERLINE
;
765 eUnderline
= UNDERLINE_BOLD
;
766 goto ATTR_SETUNDERLINE
;
768 eUnderline
= UNDERLINE_WAVE
;
769 goto ATTR_SETUNDERLINE
;
771 eUnderline
= UNDERLINE_BOLDDOTTED
;
772 goto ATTR_SETUNDERLINE
;
774 eUnderline
= UNDERLINE_BOLDDASH
;
775 goto ATTR_SETUNDERLINE
;
777 eUnderline
= UNDERLINE_LONGDASH
;
778 goto ATTR_SETUNDERLINE
;
780 eUnderline
= UNDERLINE_BOLDLONGDASH
;
781 goto ATTR_SETUNDERLINE
;
783 eUnderline
= UNDERLINE_BOLDDASHDOT
;
784 goto ATTR_SETUNDERLINE
;
786 eUnderline
= UNDERLINE_BOLDDASHDOTDOT
;
787 goto ATTR_SETUNDERLINE
;
789 eUnderline
= UNDERLINE_BOLDWAVE
;
790 goto ATTR_SETUNDERLINE
;
792 eUnderline
= UNDERLINE_DOUBLEWAVE
;
793 goto ATTR_SETUNDERLINE
;
796 eUnderline
= UNDERLINE_SINGLE
;
798 if( PLAINID
->nWordlineMode
)
800 pSet
->Put( SvxWordLineModeItem( sal_True
, PLAINID
->nWordlineMode
));
802 goto ATTR_SETUNDERLINE
;
805 if( PLAINID
->nUnderline
)
807 pSet
->Put( SvxUnderlineItem( eUnderline
, PLAINID
->nUnderline
));
812 if( PLAINID
->nUnderline
)
814 SvxUnderlineItem
aUL( UNDERLINE_SINGLE
, PLAINID
->nUnderline
);
815 const SfxPoolItem
* pItem
;
816 if( SFX_ITEM_SET
== pSet
->GetItemState(
817 PLAINID
->nUnderline
, sal_False
, &pItem
) )
820 if( UNDERLINE_NONE
==
821 ((SvxUnderlineItem
*)pItem
)->GetLineStyle() )
823 aUL
= *(SvxUnderlineItem
*)pItem
;
826 aUL
= (const SvxUnderlineItem
&)pSet
->Get( PLAINID
->nUnderline
, sal_False
);
828 if( UNDERLINE_NONE
== aUL
.GetLineStyle() )
829 aUL
.SetLineStyle( UNDERLINE_SINGLE
);
830 aUL
.SetColor( GetColor( sal_uInt16(nTokenValue
) ));
836 if( !IsAttrSttPos() )
838 eOverline
= nTokenValue
? UNDERLINE_SINGLE
: UNDERLINE_NONE
;
839 goto ATTR_SETOVERLINE
;
842 eOverline
= UNDERLINE_DOTTED
;
843 goto ATTR_SETOVERLINE
;
845 eOverline
= UNDERLINE_DASH
;
846 goto ATTR_SETOVERLINE
;
848 eOverline
= UNDERLINE_DASHDOT
;
849 goto ATTR_SETOVERLINE
;
851 eOverline
= UNDERLINE_DASHDOTDOT
;
852 goto ATTR_SETOVERLINE
;
854 eOverline
= UNDERLINE_DOUBLE
;
855 goto ATTR_SETOVERLINE
;
857 eOverline
= UNDERLINE_NONE
;
858 goto ATTR_SETOVERLINE
;
860 eOverline
= UNDERLINE_BOLD
;
861 goto ATTR_SETOVERLINE
;
863 eOverline
= UNDERLINE_WAVE
;
864 goto ATTR_SETOVERLINE
;
866 eOverline
= UNDERLINE_BOLDDOTTED
;
867 goto ATTR_SETOVERLINE
;
869 eOverline
= UNDERLINE_BOLDDASH
;
870 goto ATTR_SETOVERLINE
;
872 eOverline
= UNDERLINE_LONGDASH
;
873 goto ATTR_SETOVERLINE
;
875 eOverline
= UNDERLINE_BOLDLONGDASH
;
876 goto ATTR_SETOVERLINE
;
878 eOverline
= UNDERLINE_BOLDDASHDOT
;
879 goto ATTR_SETOVERLINE
;
881 eOverline
= UNDERLINE_BOLDDASHDOTDOT
;
882 goto ATTR_SETOVERLINE
;
884 eOverline
= UNDERLINE_BOLDWAVE
;
885 goto ATTR_SETOVERLINE
;
887 eOverline
= UNDERLINE_DOUBLEWAVE
;
888 goto ATTR_SETOVERLINE
;
891 eOverline
= UNDERLINE_SINGLE
;
893 if( PLAINID
->nWordlineMode
)
895 pSet
->Put( SvxWordLineModeItem( sal_True
, PLAINID
->nWordlineMode
));
897 goto ATTR_SETOVERLINE
;
900 if( PLAINID
->nUnderline
)
902 pSet
->Put( SvxOverlineItem( eOverline
, PLAINID
->nOverline
));
907 if( PLAINID
->nOverline
)
909 SvxOverlineItem
aOL( UNDERLINE_SINGLE
, PLAINID
->nOverline
);
910 const SfxPoolItem
* pItem
;
911 if( SFX_ITEM_SET
== pSet
->GetItemState(
912 PLAINID
->nOverline
, sal_False
, &pItem
) )
915 if( UNDERLINE_NONE
==
916 ((SvxOverlineItem
*)pItem
)->GetLineStyle() )
918 aOL
= *(SvxOverlineItem
*)pItem
;
921 aOL
= (const SvxOverlineItem
&)pSet
->Get( PLAINID
->nUnderline
, sal_False
);
923 if( UNDERLINE_NONE
== aOL
.GetLineStyle() )
924 aOL
.SetLineStyle( UNDERLINE_SINGLE
);
925 aOL
.SetColor( GetColor( sal_uInt16(nTokenValue
) ));
932 if( PLAINID
->nEscapement
)
934 const sal_uInt16 nEsc
= PLAINID
->nEscapement
;
935 if( -1 == nTokenValue
|| RTF_SUPER
== nToken
)
939 const SvxEscapementItem
& rOld
= GetEscapement( *pSet
, nEsc
, sal_False
);
942 if( DFLT_ESC_AUTO_SUB
== rOld
.GetEsc() )
944 nEs
= DFLT_ESC_AUTO_SUPER
;
945 nProp
= rOld
.GetProp();
949 nEs
= (short)nTokenValue
;
950 nProp
= (nToken
== RTF_SUPER
) ? DFLT_ESC_PROP
: 100;
952 pSet
->Put( SvxEscapementItem( nEs
, nProp
, nEsc
));
957 if( PLAINID
->nColor
)
959 pSet
->Put( SvxColorItem( GetColor( sal_uInt16(nTokenValue
) ),
963 //#i12501# While cb is clearly documented in the rtf spec, word
964 //doesn't accept it at all
967 if( PLAINID
->nBgColor
)
969 pSet
->Put( SvxBrushItem( GetColor( sal_uInt16(nTokenValue
) ),
970 PLAINID
->nBgColor
));
976 if( PLAINID
->nLanguage
)
978 pSet
->Put( SvxLanguageItem( (LanguageType
)nTokenValue
,
979 PLAINID
->nLanguage
));
984 if( PLAINID
->nCJKLanguage
)
986 pSet
->Put( SvxLanguageItem( (LanguageType
)nTokenValue
,
987 PLAINID
->nCJKLanguage
));
992 SvxLanguageItem
aTmpItem( (LanguageType
)nTokenValue
,
993 SID_ATTR_CHAR_LANGUAGE
);
994 SetScriptAttr( eCharType
, *pSet
, aTmpItem
);
999 bIsLeftToRightDef
= sal_False
;
1002 bIsLeftToRightDef
= sal_True
;
1005 if (PARDID
->nDirection
)
1007 pSet
->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP
,
1008 PARDID
->nDirection
));
1012 if (PARDID
->nDirection
)
1014 pSet
->Put(SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP
,
1015 PARDID
->nDirection
));
1018 case RTF_LOCH
: eCharType
= LOW_CHARTYPE
; break;
1019 case RTF_HICH
: eCharType
= HIGH_CHARTYPE
; break;
1020 case RTF_DBCH
: eCharType
= DOUBLEBYTE_CHARTYPE
; break;
1024 eEmphasis
= EMPHASISMARK_NONE
;
1025 goto ATTR_SETEMPHASIS
;
1027 eEmphasis
= EMPHASISMARK_DOTS_ABOVE
;
1028 goto ATTR_SETEMPHASIS
;
1031 eEmphasis
= EMPHASISMARK_SIDE_DOTS
;
1033 if( PLAINID
->nEmphasis
)
1035 pSet
->Put( SvxEmphasisMarkItem( eEmphasis
,
1036 PLAINID
->nEmphasis
));
1041 if( PLAINID
->nTwoLines
)
1043 sal_Unicode cStt
, cEnd
;
1044 switch ( nTokenValue
)
1046 case 1: cStt
= '(', cEnd
= ')'; break;
1047 case 2: cStt
= '[', cEnd
= ']'; break;
1048 case 3: cStt
= '<', cEnd
= '>'; break;
1049 case 4: cStt
= '{', cEnd
= '}'; break;
1050 default: cStt
= 0, cEnd
= 0; break;
1053 pSet
->Put( SvxTwoLinesItem( sal_True
, cStt
, cEnd
,
1054 PLAINID
->nTwoLines
));
1058 case RTF_CHARSCALEX
:
1059 if (PLAINID
->nCharScaleX
)
1062 if (nTokenValue
< 1 || nTokenValue
> 600)
1064 pSet
->Put( SvxCharScaleWidthItem( sal_uInt16(nTokenValue
),
1065 PLAINID
->nCharScaleX
));
1070 if( PLAINID
->nHorzVert
)
1072 // RTF knows only 90deg
1073 pSet
->Put( SvxCharRotateItem( 900, 1 == nTokenValue
,
1074 PLAINID
->nHorzVert
));
1079 if (PLAINID
->nRelief
)
1081 pSet
->Put(SvxCharReliefItem(RELIEF_EMBOSSED
,
1086 if (PLAINID
->nRelief
)
1088 pSet
->Put(SvxCharReliefItem(RELIEF_ENGRAVED
,
1093 if (PLAINID
->nHidden
)
1095 pSet
->Put(SvxCharHiddenItem(nTokenValue
!= 0,
1100 case RTF_CHBGDKVERT
:
1101 case RTF_CHBGDKHORIZ
:
1104 case RTF_CHBGDKFDIAG
:
1105 case RTF_CHBGDCROSS
:
1108 case RTF_CHBGDKDCROSS
:
1109 case RTF_CHBGDKCROSS
:
1110 case RTF_CHBGDKBDIAG
:
1114 if( PLAINID
->nBgColor
)
1115 ReadBackgroundAttr( nToken
, *pSet
);
1120 // tests on Swg internal tokens
1121 bool bHandled
= false;
1123 if( RTF_IGNOREFLAG
!= GetNextToken())
1125 else if( (nToken
= GetNextToken() ) & RTF_SWGDEFS
)
1133 UnknownAttrToken( nToken
, pSet
);
1134 // overwrite the closing parenthesis
1137 case RTF_SWG_ESCPROP
:
1139 // Store percentage change!
1140 sal_uInt8 nProp
= sal_uInt8( nTokenValue
/ 100 );
1142 if( 1 == ( nTokenValue
% 100 ))
1143 // Recognize own auto-flags!
1144 nEsc
= DFLT_ESC_AUTO_SUPER
;
1146 if( PLAINID
->nEscapement
)
1147 pSet
->Put( SvxEscapementItem( nEsc
, nProp
,
1148 PLAINID
->nEscapement
));
1154 SvxHyphenZoneItem
aHypenZone(
1155 (nTokenValue
& 1) ? sal_True
: sal_False
,
1156 PARDID
->nHyphenzone
);
1157 aHypenZone
.SetPageEnd(
1158 (nTokenValue
& 2) ? sal_True
: sal_False
);
1160 if( PARDID
->nHyphenzone
&&
1161 RTF_HYPHLEAD
== GetNextToken() &&
1162 RTF_HYPHTRAIL
== GetNextToken() &&
1163 RTF_HYPHMAX
== GetNextToken() )
1165 aHypenZone
.GetMinLead() =
1166 sal_uInt8(GetStackPtr( -2 )->nTokenValue
);
1167 aHypenZone
.GetMinTrail() =
1168 sal_uInt8(GetStackPtr( -1 )->nTokenValue
);
1169 aHypenZone
.GetMaxHyphens() =
1170 sal_uInt8(nTokenValue
);
1172 pSet
->Put( aHypenZone
);
1175 SkipGroup(); // at the end of the group
1181 int bSkip
= sal_True
;
1182 do { // middle check loop
1183 SvxShadowLocation eSL
= SvxShadowLocation( nTokenValue
);
1184 if( RTF_SHDW_DIST
!= GetNextToken() )
1186 sal_uInt16 nDist
= sal_uInt16( nTokenValue
);
1188 if( RTF_SHDW_STYLE
!= GetNextToken() )
1191 if( RTF_SHDW_COL
!= GetNextToken() )
1193 sal_uInt16 nCol
= sal_uInt16( nTokenValue
);
1195 if( RTF_SHDW_FCOL
!= GetNextToken() )
1198 Color aColor
= GetColor( nCol
);
1200 if( PARDID
->nShadow
)
1201 pSet
->Put( SvxShadowItem( PARDID
->nShadow
,
1202 &aColor
, nDist
, eSL
) );
1205 } while( sal_False
);
1208 SkipGroup(); // at the end of the group
1214 if( (nToken
& ~(0xff | RTF_SWGDEFS
)) == RTF_TABSTOPDEF
)
1216 nToken
= SkipToken( -2 );
1217 ReadTabAttr( nToken
, *pSet
);
1220 cmc: #i76140, he who consumed the { must consume the }
1221 We rewound to a state of { being the current
1222 token so it is our responsibility to consume the }
1223 token if we consumed the {. We will not have consumed
1224 the { if it belonged to our caller, i.e. if the { we
1225 are handling is the "firsttoken" passed to us then
1226 the *caller* must consume it, not us. Otherwise *we*
1229 if (nToken
== BRACELEFT
&& !bFirstToken
)
1231 nToken
= GetNextToken();
1232 DBG_ASSERT( nToken
== BRACERIGHT
,
1233 "} did not follow { as expected\n");
1236 else if( (nToken
& ~(0xff| RTF_SWGDEFS
)) == RTF_BRDRDEF
)
1238 nToken
= SkipToken( -2 );
1239 ReadBorderAttr( nToken
, *pSet
);
1241 else // so no more attribute
1248 cmc: #i4727# / #i12713# Who owns this closing bracket?
1249 If we read the opening one, we must read this one, if
1250 other is counting the brackets so as to push/pop off
1251 the correct environment then we will have pushed a new
1252 environment for the start { of this, but will not see
1253 the } and so is out of sync for the rest of the
1256 if (bHandled
&& !bFirstToken
)
1263 if( nSkip
) // all completely unknown
1266 --nSkip
; // BRACELEFT: is the next token
1268 bWeiter
= sal_False
;
1273 if( (nToken
& ~0xff ) == RTF_TABSTOPDEF
)
1274 ReadTabAttr( nToken
, *pSet
);
1275 else if( (nToken
& ~0xff ) == RTF_BRDRDEF
)
1276 ReadBorderAttr( nToken
, *pSet
);
1277 else if( (nToken
& ~0xff ) == RTF_SHADINGDEF
)
1278 ReadBackgroundAttr( nToken
, *pSet
);
1281 // unknown token, so token "returned in Parser"
1284 bWeiter
= sal_False
;
1290 nToken
= GetNextToken();
1292 bFirstToken
= sal_False
;
1296 void SvxRTFParser::ReadTabAttr( int nToken
, SfxItemSet
& rSet
)
1298 bool bMethodOwnsToken
= false; // #i52542# patch from cmc.
1299 // then read all the TabStops
1300 SvxTabStop aTabStop
;
1301 SvxTabStopItem
aAttr( 0, 0, SVX_TAB_ADJUST_DEFAULT
, PARDID
->nTabStop
);
1302 int bWeiter
= sal_True
;
1306 case RTF_TB
: // BarTab ???
1311 aTabStop
.GetTabPos() = nTokenValue
;
1312 aAttr
.Insert( aTabStop
);
1313 aTabStop
= SvxTabStop(); // all values default
1318 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_LEFT
;
1321 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_RIGHT
;
1324 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_CENTER
;
1327 aTabStop
.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL
;
1330 case RTF_TLDOT
: aTabStop
.GetFill() = '.'; break;
1331 case RTF_TLHYPH
: aTabStop
.GetFill() = ' '; break;
1332 case RTF_TLUL
: aTabStop
.GetFill() = '_'; break;
1333 case RTF_TLTH
: aTabStop
.GetFill() = '-'; break;
1334 case RTF_TLEQ
: aTabStop
.GetFill() = '='; break;
1338 // Swg - control BRACELEFT RTF_IGNOREFLAG RTF_TLSWG BRACERIGHT
1340 if( RTF_IGNOREFLAG
!= GetNextToken() )
1342 else if( RTF_TLSWG
!= ( nToken
= GetNextToken() ))
1346 aTabStop
.GetDecimal() = sal_uInt8(nTokenValue
& 0xff);
1347 aTabStop
.GetFill() = sal_uInt8((nTokenValue
>> 8) & 0xff);
1348 // overwrite the closing parenthesis
1349 if (bMethodOwnsToken
)
1354 SkipToken( nSkip
); // Ignore back again
1355 bWeiter
= sal_False
;
1361 bWeiter
= sal_False
;
1365 nToken
= GetNextToken();
1366 bMethodOwnsToken
= true;
1370 // Fill with defaults is still missing!
1375 static void SetBorderLine( int nBorderTyp
, SvxBoxItem
& rItem
,
1376 const SvxBorderLine
& rBorder
)
1378 switch( nBorderTyp
)
1380 case RTF_BOX
: // run through all levels
1383 rItem
.SetLine( &rBorder
, BOX_LINE_TOP
);
1384 if( RTF_BOX
!= nBorderTyp
)
1388 rItem
.SetLine( &rBorder
, BOX_LINE_BOTTOM
);
1389 if( RTF_BOX
!= nBorderTyp
)
1393 rItem
.SetLine( &rBorder
, BOX_LINE_LEFT
);
1394 if( RTF_BOX
!= nBorderTyp
)
1398 rItem
.SetLine( &rBorder
, BOX_LINE_RIGHT
);
1399 if( RTF_BOX
!= nBorderTyp
)
1404 void SvxRTFParser::ReadBorderAttr( int nToken
, SfxItemSet
& rSet
,
1407 // then read the border attribute
1408 SvxBoxItem
aAttr( PARDID
->nBox
);
1409 const SfxPoolItem
* pItem
;
1410 if( SFX_ITEM_SET
== rSet
.GetItemState( PARDID
->nBox
, sal_False
, &pItem
) )
1411 aAttr
= *(SvxBoxItem
*)pItem
;
1413 SvxBorderLine
aBrd( 0, DEF_LINE_WIDTH_0
); // Simple plain line
1414 int bWeiter
= sal_True
, nBorderTyp
= 0;
1417 bool bDoubleWidth
= false;
1427 nBorderTyp
= nToken
;
1430 case RTF_CLBRDRT
: // Cell top border
1434 if (nBorderTyp
!= 0)
1435 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1436 nBorderTyp
= RTF_BRDRT
;
1440 case RTF_CLBRDRB
: // Cell bottom border
1444 if (nBorderTyp
!= 0)
1445 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1446 nBorderTyp
= RTF_BRDRB
;
1450 case RTF_CLBRDRL
: // Cell left border
1454 if (nBorderTyp
!= 0)
1455 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1456 nBorderTyp
= RTF_BRDRL
;
1460 case RTF_CLBRDRR
: // Cell right border
1464 if (nBorderTyp
!= 0)
1465 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1466 nBorderTyp
= RTF_BRDRR
;
1471 case RTF_BRDRDOT
: // dotted border
1472 aBrd
.SetBorderLineStyle(table::BorderLineStyle::DOTTED
);
1474 case RTF_BRDRDASH
: // dashed border
1475 aBrd
.SetBorderLineStyle(table::BorderLineStyle::DASHED
);
1477 case RTF_BRDRHAIR
: // hairline border
1479 aBrd
.SetBorderLineStyle( table::BorderLineStyle::SOLID
);
1480 aBrd
.SetWidth( DEF_LINE_WIDTH_0
);
1483 case RTF_BRDRDB
: // Double border
1484 aBrd
.SetBorderLineStyle(table::BorderLineStyle::DOUBLE
);
1486 case RTF_BRDRINSET
: // inset border
1487 aBrd
.SetBorderLineStyle(table::BorderLineStyle::INSET
);
1489 case RTF_BRDROUTSET
: // outset border
1490 aBrd
.SetBorderLineStyle(table::BorderLineStyle::OUTSET
);
1492 case RTF_BRDRTNTHSG
: // ThinThick Small gap
1493 aBrd
.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_SMALLGAP
);
1495 case RTF_BRDRTNTHMG
: // ThinThick Medium gap
1496 aBrd
.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_MEDIUMGAP
);
1498 case RTF_BRDRTNTHLG
: // ThinThick Large gap
1499 aBrd
.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_LARGEGAP
);
1501 case RTF_BRDRTHTNSG
: // ThickThin Small gap
1502 aBrd
.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_SMALLGAP
);
1504 case RTF_BRDRTHTNMG
: // ThickThin Medium gap
1505 aBrd
.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_MEDIUMGAP
);
1507 case RTF_BRDRTHTNLG
: // ThickThin Large gap
1508 aBrd
.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_LARGEGAP
);
1510 case RTF_BRDREMBOSS
: // Embossed border
1511 aBrd
.SetBorderLineStyle(table::BorderLineStyle::EMBOSSED
);
1513 case RTF_BRDRENGRAVE
: // Engraved border
1514 aBrd
.SetBorderLineStyle(table::BorderLineStyle::ENGRAVED
);
1517 case RTF_BRDRS
: // single thickness border
1518 bDoubleWidth
= false;
1520 case RTF_BRDRTH
: // double thickness border width*2
1521 bDoubleWidth
= true;
1523 case RTF_BRDRW
: // border width <255
1524 nWidth
= nTokenValue
;
1527 case RTF_BRDRCF
: // Border color
1528 aBrd
.SetColor( GetColor( sal_uInt16(nTokenValue
) ) );
1531 case RTF_BRDRSH
: // Shadowed border
1532 rSet
.Put( SvxShadowItem( PARDID
->nShadow
, (Color
*) 0, 60 /*3pt*/,
1533 SVX_SHADOW_BOTTOMRIGHT
) );
1536 case RTF_BRSP
: // Spacing to content in twip
1538 switch( nBorderTyp
)
1541 aAttr
.SetDistance( (sal_uInt16
)nTokenValue
, BOX_LINE_BOTTOM
);
1545 aAttr
.SetDistance( (sal_uInt16
)nTokenValue
, BOX_LINE_TOP
);
1549 aAttr
.SetDistance( (sal_uInt16
)nTokenValue
, BOX_LINE_LEFT
);
1553 aAttr
.SetDistance( (sal_uInt16
)nTokenValue
, BOX_LINE_RIGHT
);
1557 aAttr
.SetDistance( (sal_uInt16
)nTokenValue
);
1563 case RTF_BRDRBTW
: // Border formatting group
1564 case RTF_BRDRBAR
: // Border outside
1565 // TODO unhandled ATM
1569 bWeiter
= (nToken
& ~(0xff| RTF_SWGDEFS
)) == RTF_BRDRDEF
;
1572 nToken
= GetNextToken();
1575 // Finally compute the border width
1576 if ( bDoubleWidth
) nWidth
*= 2;
1577 aBrd
.SetWidth( nWidth
);
1579 SetBorderLine( nBorderTyp
, aAttr
, aBrd
);
1585 inline sal_uInt32
CalcShading( sal_uInt32 nColor
, sal_uInt32 nFillColor
, sal_uInt8 nShading
)
1587 nColor
= (nColor
* nShading
) / 100;
1588 nFillColor
= (nFillColor
* ( 100 - nShading
)) / 100;
1589 return nColor
+ nFillColor
;
1592 void SvxRTFParser::ReadBackgroundAttr( int nToken
, SfxItemSet
& rSet
,
1595 // then read the border attribute
1596 int bWeiter
= sal_True
;
1597 sal_uInt16 nColor
= USHRT_MAX
, nFillColor
= USHRT_MAX
;
1598 sal_uInt8 nFillValue
= 0;
1600 sal_uInt16 nWh
= ( nToken
& ~0xff ) == RTF_CHRFMT
1610 nFillColor
= sal_uInt16( nTokenValue
);
1616 nColor
= sal_uInt16( nTokenValue
);
1622 nFillValue
= (sal_uInt8
)( nTokenValue
/ 100 );
1626 case RTF_CHBGDKHORIZ
:
1628 case RTF_CLBGDKVERT
:
1629 case RTF_CHBGDKVERT
:
1631 case RTF_CLBGDKBDIAG
:
1632 case RTF_CHBGDKBDIAG
:
1634 case RTF_CLBGDKFDIAG
:
1635 case RTF_CHBGDKFDIAG
:
1637 case RTF_CLBGDKCROSS
:
1638 case RTF_CHBGDKCROSS
:
1640 case RTF_CLBGDKDCROSS
:
1641 case RTF_CHBGDKDCROSS
:
1642 case RTF_BGDKDCROSS
:
1662 case RTF_CLBGDCROSS
:
1663 case RTF_CHBGDCROSS
:
1671 bWeiter
= (nToken
& ~(0xff | RTF_TABLEDEF
) ) == RTF_SHADINGDEF
;
1673 bWeiter
= (nToken
& ~0xff) == RTF_SHADINGDEF
;
1676 nToken
= GetNextToken();
1679 Color
aCol( COL_WHITE
), aFCol
;
1682 // there was only one of two colors specified or no BrushTyp
1683 if( USHRT_MAX
!= nFillColor
)
1686 aCol
= GetColor( nFillColor
);
1688 else if( USHRT_MAX
!= nColor
)
1689 aFCol
= GetColor( nColor
);
1693 if( USHRT_MAX
!= nColor
)
1694 aCol
= GetColor( nColor
);
1696 aCol
= Color( COL_BLACK
);
1698 if( USHRT_MAX
!= nFillColor
)
1699 aFCol
= GetColor( nFillColor
);
1701 aFCol
= Color( COL_WHITE
);
1705 if( 0 == nFillValue
|| 100 == nFillValue
)
1709 (sal_uInt8
)CalcShading( aCol
.GetRed(), aFCol
.GetRed(), nFillValue
),
1710 (sal_uInt8
)CalcShading( aCol
.GetGreen(), aFCol
.GetGreen(), nFillValue
),
1711 (sal_uInt8
)CalcShading( aCol
.GetBlue(), aFCol
.GetBlue(), nFillValue
) );
1713 rSet
.Put( SvxBrushItem( aColor
, nWh
) );
1718 // pard / plain abarbeiten
1719 void SvxRTFParser::RTFPardPlain( int bPard
, SfxItemSet
** ppSet
)
1721 if( !bNewGroup
&& !aAttrStack
.empty() ) // not at the beginning of a new group
1723 SvxRTFItemStackType
* pAkt
= aAttrStack
.back();
1725 int nLastToken
= GetStackPtr(-1)->nTokenId
;
1726 int bNewStkEntry
= sal_True
;
1727 if( RTF_PARD
!= nLastToken
&&
1728 RTF_PLAIN
!= nLastToken
&&
1729 BRACELEFT
!= nLastToken
)
1731 if( pAkt
->aAttrSet
.Count() || pAkt
->pChildList
|| pAkt
->nStyleNo
)
1734 SvxRTFItemStackType
* pNew
= new SvxRTFItemStackType( *pAkt
, *pInsPos
, sal_True
);
1735 pNew
->SetRTFDefaults( GetRTFDefaults() );
1737 // Set all until here valid attributes
1739 pAkt
= aAttrStack
.empty() ? 0 : aAttrStack
.back(); // can be changed after AttrGroupEnd!
1740 pNew
->aAttrSet
.SetParent( pAkt
? &pAkt
->aAttrSet
: 0 );
1741 aAttrStack
.push_back( pNew
);
1746 // continue to use this entry as new
1747 pAkt
->SetStartPos( *pInsPos
);
1748 bNewStkEntry
= sal_False
;
1752 // now reset all to default
1754 ( pAkt
->aAttrSet
.GetParent() || pAkt
->aAttrSet
.Count() ))
1756 const SfxPoolItem
*pItem
, *pDef
;
1757 const sal_uInt16
* pPtr
;
1759 const SfxItemSet
* pDfltSet
= &GetRTFDefaults();
1763 pPtr
= &aPardMap
[0];
1764 nCnt
= aPardMap
.size();
1768 pPtr
= &aPlainMap
[0];
1769 nCnt
= aPlainMap
.size();
1772 for( sal_uInt16 n
= 0; n
< nCnt
; ++n
, ++pPtr
)
1774 // Item set and different -> Set the Default Pool
1777 else if( SFX_WHICH_MAX
< *pPtr
)
1778 pAkt
->aAttrSet
.ClearItem( *pPtr
);
1779 else if( IsChkStyleAttr() )
1780 pAkt
->aAttrSet
.Put( pDfltSet
->Get( *pPtr
) );
1781 else if( !pAkt
->aAttrSet
.GetParent() )
1784 pDfltSet
->GetItemState( *pPtr
, sal_False
, &pDef
))
1785 pAkt
->aAttrSet
.Put( *pDef
);
1787 pAkt
->aAttrSet
.ClearItem( *pPtr
);
1789 else if( SFX_ITEM_SET
== pAkt
->aAttrSet
.GetParent()->
1790 GetItemState( *pPtr
, sal_True
, &pItem
) &&
1791 *( pDef
= &pDfltSet
->Get( *pPtr
)) != *pItem
)
1792 pAkt
->aAttrSet
.Put( *pDef
);
1796 pDfltSet
->GetItemState( *pPtr
, sal_False
, &pDef
))
1797 pAkt
->aAttrSet
.Put( *pDef
);
1799 pAkt
->aAttrSet
.ClearItem( *pPtr
);
1804 pAkt
->nStyleNo
= 0; // reset Style number
1806 *ppSet
= &pAkt
->aAttrSet
;
1810 //Once we have a default font, then any text without a font specifier is
1811 //in the default font, and thus has the default font charset, otherwise
1812 //we can fall back to the ansicpg set codeset
1813 if (nDfltFont
!= -1)
1815 const Font
& rSVFont
= GetFont(sal_uInt16(nDfltFont
));
1816 SetEncoding(rSVFont
.GetCharSet());
1819 SetEncoding(GetCodeSet());
1824 void SvxRTFParser::SetDefault( int nToken
, int nValue
)
1829 SfxItemSet
aTmp( *pAttrPool
, &aWhichMap
[0] );
1830 sal_Bool bOldFlag
= bIsLeftToRightDef
;
1831 bIsLeftToRightDef
= sal_True
;
1834 case RTF_ADEFF
: bIsLeftToRightDef
= sal_False
; // no break!
1839 const Font
& rSVFont
= GetFont( sal_uInt16(nValue
) );
1840 SvxFontItem
aTmpItem(
1841 rSVFont
.GetFamily(), rSVFont
.GetName(),
1842 rSVFont
.GetStyleName(), rSVFont
.GetPitch(),
1843 rSVFont
.GetCharSet(), SID_ATTR_CHAR_FONT
);
1844 SetScriptAttr( NOTDEF_CHARTYPE
, aTmp
, aTmpItem
);
1848 case RTF_ADEFLANG
: bIsLeftToRightDef
= sal_False
; // no break!
1850 // store default Language
1853 SvxLanguageItem
aTmpItem( (const LanguageType
)nValue
,
1854 SID_ATTR_CHAR_LANGUAGE
);
1855 SetScriptAttr( NOTDEF_CHARTYPE
, aTmp
, aTmpItem
);
1860 if( PARDID
->nTabStop
)
1862 // RTF defines 720 twips as default
1863 bIsSetDfltTab
= sal_True
;
1864 if( -1 == nValue
|| !nValue
)
1867 // who would like to have no twips ...
1870 nTokenValue
= nValue
;
1872 nValue
= nTokenValue
;
1875 // Calculate the ratio of default TabWidth / Tabs and
1876 // calculate the corresponding new number.
1877 // ?? how did one come up with 13 ??
1878 sal_uInt16 nAnzTabs
= (SVX_TAB_DEFDIST
* 13 ) / sal_uInt16(nValue
);
1880 cmc, make sure we have at least one, or all hell breaks loose in
1881 everybodies exporters, #i8247#
1886 // we want Defaulttabs
1887 SvxTabStopItem
aNewTab( nAnzTabs
, sal_uInt16(nValue
),
1888 SVX_TAB_ADJUST_DEFAULT
, PARDID
->nTabStop
);
1890 ((SvxTabStop
&)aNewTab
[ --nAnzTabs
]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT
;
1892 pAttrPool
->SetPoolDefaultItem( aNewTab
);
1896 bIsLeftToRightDef
= bOldFlag
;
1900 SfxItemIter
aIter( aTmp
);
1901 const SfxPoolItem
* pItem
= aIter
.GetCurItem();
1904 pAttrPool
->SetPoolDefaultItem( *pItem
);
1905 if( aIter
.IsAtEnd() )
1907 pItem
= aIter
.NextItem();
1912 // default: no conversion, leaving everything in twips.
1913 void SvxRTFParser::CalcValue()
1917 // for tokens that are not evaluated in ReadAttr
1918 void SvxRTFParser::UnknownAttrToken( int, SfxItemSet
* )
1922 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */