diff options
author | Michael Meeks <michael.meeks@novell.com> | 2011-06-10 15:32:51 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@novell.com> | 2011-06-10 15:43:05 +0100 |
commit | 10d5d09f7b801a0657bbcba0f396c81207f37085 (patch) | |
tree | d8a83a6b38e58cc5ef1a9cae49ba05e3f66803a8 /cui | |
parent | 72e6d5504a52715fe3eb304baf8dcf37a4442281 (diff) |
move font itemset handling down into the fontpreview widget
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/chardlg.hxx | 8 | ||||
-rw-r--r-- | cui/source/tabpages/chardlg.cxx | 288 |
2 files changed, 5 insertions, 291 deletions
diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index 04b807760..ab9abba1e 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -66,12 +66,8 @@ protected: sal_uInt16 nResIdPrewievWin, sal_uInt16 nResIdFontTypeFT ); virtual ~SvxCharBasePage(); - void SetPrevFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ); - void SetPrevFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ); - void SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nSlotPosture, sal_uInt16 nSlotWeight, SvxFont& rFont ); // posture/weight - void SetPrevFontWidthScale( const SfxItemSet& rSet ); - - void SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); + void SetPrevFontWidthScale( const SfxItemSet& rSet ); + void SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); inline SvxFont& GetPreviewFont(); inline SvxFont& GetPreviewCJKFont(); diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 8ca643514..3bdb44528 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -207,302 +207,20 @@ SvxCharBasePage::~SvxCharBasePage() // ----------------------------------------------------------------------- -//void SvxCharBasePage::SetPrevFontAttributes( const SfxItemSet& rSet ) void SvxCharBasePage::ActivatePage( const SfxItemSet& rSet ) { - SvxFont& rFont = GetPreviewFont(); - SvxFont& rCJKFont = GetPreviewCJKFont(); - SvxFont& rCTLFont = GetPreviewCTLFont(); - sal_uInt16 nWhich; - - nWhich = GetWhich( SID_CHAR_DLG_PREVIEW_STRING ); - if( ISITEMSET ) - { - const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich ); - ::rtl::OUString aString = rItem.GetValue(); - if( aString.getLength() != 0 ) - m_aPreviewWin.SetPreviewText( aString ); - else - m_aPreviewWin.SetFontNameAsPreviewText(); - } - - // Underline - FontUnderline eUnderline; - nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE ); - if( ISITEMSET ) - { - const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich ); - eUnderline = ( FontUnderline ) rItem.GetValue(); - m_aPreviewWin.SetTextLineColor( rItem.GetColor() ); - } - else - eUnderline = UNDERLINE_NONE; - - rFont.SetUnderline( eUnderline ); - rCJKFont.SetUnderline( eUnderline ); - rCTLFont.SetUnderline( eUnderline ); - - // Overline - FontUnderline eOverline; - nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE ); - if( ISITEMSET ) - { - const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich ); - eOverline = ( FontUnderline ) rItem.GetValue(); - m_aPreviewWin.SetOverlineColor( rItem.GetColor() ); - } - else - eOverline = UNDERLINE_NONE; - - rFont.SetOverline( eOverline ); - rCJKFont.SetOverline( eOverline ); - rCTLFont.SetOverline( eOverline ); - - // Strikeout - FontStrikeout eStrikeout; - nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT ); - if( ISITEMSET ) - { - const SvxCrossedOutItem& rItem = ( SvxCrossedOutItem& ) rSet.Get( nWhich ); - eStrikeout = ( FontStrikeout ) rItem.GetValue(); - } - else - eStrikeout = STRIKEOUT_NONE; - - rFont.SetStrikeout( eStrikeout ); - rCJKFont.SetStrikeout( eStrikeout ); - rCTLFont.SetStrikeout( eStrikeout ); - - // WordLineMode - nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE ); - if( ISITEMSET ) - { - const SvxWordLineModeItem& rItem = ( SvxWordLineModeItem& ) rSet.Get( nWhich ); - rFont.SetWordLineMode( rItem.GetValue() ); - rCJKFont.SetWordLineMode( rItem.GetValue() ); - rCTLFont.SetWordLineMode( rItem.GetValue() ); - } - - // Emphasis - nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK ); - if( ISITEMSET ) - { - const SvxEmphasisMarkItem& rItem = ( SvxEmphasisMarkItem& ) rSet.Get( nWhich ); - FontEmphasisMark eMark = rItem.GetEmphasisMark(); - rFont.SetEmphasisMark( eMark ); - rCJKFont.SetEmphasisMark( eMark ); - rCTLFont.SetEmphasisMark( eMark ); - } - - // Relief - nWhich = GetWhich( SID_ATTR_CHAR_RELIEF ); - if( ISITEMSET ) - { - const SvxCharReliefItem& rItem = ( SvxCharReliefItem& ) rSet.Get( nWhich ); - FontRelief eFontRelief = ( FontRelief ) rItem.GetValue(); - rFont.SetRelief( eFontRelief ); - rCJKFont.SetRelief( eFontRelief ); - rCTLFont.SetRelief( eFontRelief ); - } - - // Effects - nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP ); - if( ISITEMSET ) - { - const SvxCaseMapItem& rItem = ( SvxCaseMapItem& ) rSet.Get( nWhich ); - SvxCaseMap eCaseMap = ( SvxCaseMap ) rItem.GetValue(); - rFont.SetCaseMap( eCaseMap ); - rCJKFont.SetCaseMap( eCaseMap ); - // #i78474# small caps do not exist in CTL fonts - rCTLFont.SetCaseMap( eCaseMap == SVX_CASEMAP_KAPITAELCHEN ? SVX_CASEMAP_NOT_MAPPED : eCaseMap ); - } - - // Outline - nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR ); - if( ISITEMSET ) - { - const SvxContourItem& rItem = ( SvxContourItem& ) rSet.Get( nWhich ); - sal_Bool bOutline = rItem.GetValue(); - rFont.SetOutline( bOutline ); - rCJKFont.SetOutline( bOutline ); - rCTLFont.SetOutline( bOutline ); - } - - // Shadow - nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED ); - if( ISITEMSET ) - { - const SvxShadowedItem& rItem = ( SvxShadowedItem& ) rSet.Get( nWhich ); - sal_Bool bShadow = rItem.GetValue(); - rFont.SetShadow( bShadow ); - rCJKFont.SetShadow( bShadow ); - rCTLFont.SetShadow( bShadow ); - } - - // Background - sal_Bool bTransparent; - nWhich = GetWhich( m_bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR ); - if( ISITEMSET ) - { - const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich ); - const Color& rColor = rBrush.GetColor(); - bTransparent = rColor.GetTransparency() > 0; - rFont.SetFillColor( rColor ); - rCJKFont.SetFillColor( rColor ); - rCTLFont.SetFillColor( rColor ); - } - else - bTransparent = sal_True; - - rFont.SetTransparent( bTransparent ); - rCJKFont.SetTransparent( bTransparent ); - rCTLFont.SetTransparent( bTransparent ); - - Color aBackCol( COL_TRANSPARENT ); - if( !m_bPreviewBackgroundToCharacter ) - { - nWhich = GetWhich( SID_ATTR_BRUSH ); - if( ISITEMSET ) - { - const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich ); - if( GPOS_NONE == rBrush.GetGraphicPos() ) - aBackCol = rBrush.GetColor(); - } - } - m_aPreviewWin.SetBackColor( aBackCol ); - - // Font - SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont ); - SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont ); - SetPrevFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont ); - - // Style - SetPrevFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont ); - SetPrevFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont ); - SetPrevFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont ); - - // Size - SetPrevFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont ); - SetPrevFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont ); - SetPrevFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont ); - - // Color - nWhich = GetWhich( SID_ATTR_CHAR_COLOR ); - if( ISITEMSET ) - { - const SvxColorItem& rItem = ( SvxColorItem& ) rSet.Get( nWhich ); - Color aCol( rItem.GetValue() ); - rFont.SetColor( aCol ); - rCJKFont.SetColor( aCol ); - rCTLFont.SetColor( aCol ); - - m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO - } - - // Kerning - nWhich = GetWhich( SID_ATTR_CHAR_KERNING ); - if( ISITEMSET ) - { - const SvxKerningItem& rItem = ( SvxKerningItem& ) rSet.Get( nWhich ); - short nKern = ( short ) - LogicToLogic( rItem.GetValue(), ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), MAP_TWIP ); - rFont.SetFixKerning( nKern ); - rCJKFont.SetFixKerning( nKern ); - rCTLFont.SetFixKerning( nKern ); - } - - // Escapement - nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT ); - const sal_uInt8 nProp = 100; - short nEsc; - sal_uInt8 nEscProp; - if( ISITEMSET ) - { - const SvxEscapementItem& rItem = ( SvxEscapementItem& ) rSet.Get( nWhich ); - nEsc = rItem.GetEsc(); - nEscProp = rItem.GetProp(); - - if( nEsc == DFLT_ESC_AUTO_SUPER ) - nEsc = DFLT_ESC_SUPER; - else if( nEsc == DFLT_ESC_AUTO_SUB ) - nEsc = DFLT_ESC_SUB; - } - else - { - nEsc = 0; - nEscProp = 100; - } - - SetPrevFontEscapement( nProp, nEscProp, nEsc ); - - // Font width scale - SetPrevFontWidthScale( rSet ); - - m_aPreviewWin.Invalidate(); + m_aPreviewWin.SetFromItemSet( rSet, m_bPreviewBackgroundToCharacter ); } -// ----------------------------------------------------------------------- - -void SvxCharBasePage::SetPrevFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) -{ - sal_uInt16 nWhich = GetWhich( nSlot ); - long nH; - if( rSet.GetItemState( nWhich ) >= SFX_ITEM_SET ) - { - nH = LogicToLogic( ( ( SvxFontHeightItem& ) rSet.Get( nWhich ) ).GetHeight(), - ( MapUnit ) rSet.GetPool()->GetMetric( nWhich ), - MAP_TWIP ); - } - else - nH = 240; // as default 12pt - - rFont.SetSize( Size( 0, nH ) ); -} - -// ----------------------------------------------------------------------- - -void SvxCharBasePage::SetPrevFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) -{ - sal_uInt16 nWhich = GetWhich( nSlot ); - if( ISITEMSET ) - { - const SvxFontItem& rFontItem = ( SvxFontItem& ) rSet.Get( nWhich ); - rFont.SetFamily( rFontItem.GetFamily() ); - rFont.SetName( rFontItem.GetFamilyName() ); - rFont.SetPitch( rFontItem.GetPitch() ); - rFont.SetCharSet( rFontItem.GetCharSet() ); - rFont.SetStyleName( rFontItem.GetStyleName() ); - } -} - -// ----------------------------------------------------------------------- - -void SvxCharBasePage::SetPrevFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont ) -{ - sal_uInt16 nWhich = GetWhich( nPosture ); - if( ISITEMSET ) - { - const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich ); - rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE ); - } - - nWhich = GetWhich( nWeight ); - if( ISITEMSET ) - { - SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich ); - rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL ); - } -} // ----------------------------------------------------------------------- void SvxCharBasePage::SetPrevFontWidthScale( const SfxItemSet& rSet ) { - sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); + sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); if( ISITEMSET ) { - const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich ); - + const SvxCharScaleWidthItem &rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich ); m_aPreviewWin.SetFontWidthScale( rItem.GetValue() ); } } |