diff --git a/svx/inc/svx/fntctrl.hxx b/svx/inc/svx/fntctrl.hxx old mode 100755 new mode 100644 index c9a4c34..1251077 --- a/svx/inc/svx/fntctrl.hxx +++ b/svx/inc/svx/fntctrl.hxx @@ -33,6 +33,8 @@ #include #include #include "svx/svxdllapi.h" +#include +#include #include @@ -57,6 +59,8 @@ public: virtual void StateChanged( StateChangedType nStateChange ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); + void Init( const SfxItemSet& rSet ); + // for reasons of efficiency not const SvxFont& GetFont(); const SvxFont& GetFont() const; @@ -70,9 +74,10 @@ public: void ResetColor(); void SetBackColor( const Color& rColor ); void UseResourceText( sal_Bool bUse = sal_True ); + void SetDrawBaseLine( sal_Bool bSet = sal_True ); void Paint( const Rectangle& ); - sal_Bool IsTwoLines() const; + sal_Bool IsTwoLines() const; void SetTwoLines(sal_Bool bSet); void SetBrackets(sal_Unicode cStart, sal_Unicode cEnd); @@ -83,6 +88,12 @@ public: void SetPreviewText( const ::rtl::OUString& rString ); void SetFontNameAsPreviewText(); + + void SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ); + void SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ); + void SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nSlotPosture, sal_uInt16 nSlotWeight, SvxFont& rFont ); // posture/weight + void SetFontWidthScale( const SfxItemSet& rSet ); + void SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); }; #endif // #ifndef _SVX_FNTCTRL_HXX diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx old mode 100755 new mode 100644 index a34cae1..fbe2817 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -54,6 +54,39 @@ #include #define TEXT_WIDTH 20 +// RMQ voir si tous ces include sont indispensables +#include +#include "editeng/fontitem.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "editeng/flstitem.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// define ---------------------------------------------------------------- + +#define ISITEMSET rSet.GetItemState(nWhich)>=SFX_ITEM_DEFAULT + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using ::com::sun::star::i18n::XBreakIterator; @@ -137,6 +170,7 @@ class FontPrevWin_Impl sal_Bool bSelection : 1, bGetSelection : 1, bUseResText : 1, + bDrawBaseLine : 1, bTwoLines : 1, bIsCJKUI : 1, bIsCTLUI : 1, @@ -150,7 +184,7 @@ public: pColor( NULL ), pBackColor( 0 ), nAscent( 0 ), cStartBracket( 0 ), cEndBracket( 0 ), nFontWidthScale( 100 ), bSelection( sal_False ), bGetSelection( sal_False ), bUseResText( sal_False ), - bTwoLines( sal_False ), + bDrawBaseLine( sal_True ), bTwoLines( sal_False ), bIsCJKUI( sal_False ), bIsCTLUI( sal_False ), bUseFontNameAsText( sal_False ), bTextInited( sal_False ) { @@ -646,6 +680,13 @@ void SvxFontPrevWindow::UseResourceText( sal_Bool bUse ) // ----------------------------------------------------------------------- +void SvxFontPrevWindow::SetDrawBaseLine( sal_Bool bSet ) +{ + pImpl->bDrawBaseLine = bSet; +} + +// ----------------------------------------------------------------------- + void SvxFontPrevWindow::Paint( const Rectangle& ) { Printer* pPrinter = pImpl->pPrinter; @@ -761,8 +802,11 @@ void SvxFontPrevWindow::Paint( const Rectangle& ) nResultWidth += nTextWidth; long _nX = (aLogSize.Width() - nResultWidth) / 2; - DrawLine( Point( 0, nY ), Point( _nX, nY ) ); - DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) ); + if ( pImpl->bDrawBaseLine ) + { + DrawLine( Point( 0, nY ), Point( _nX, nY ) ); + DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) ); + } long nSmallAscent = pImpl->nAscent; long nOffset = (nStdAscent - nSmallAscent ) / 2; @@ -793,9 +837,11 @@ void SvxFontPrevWindow::Paint( const Rectangle& ) Color aLineCol = GetLineColor(); SetLineColor( rFont.GetColor() ); - DrawLine( Point( 0, nY ), Point( nX, nY ) ); - DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) ); - + if ( pImpl->bDrawBaseLine ) + { + DrawLine( Point( 0, nY ), Point( nX, nY ) ); + DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) ); + } SetLineColor( aLineCol ); Point aTmpPoint( nX, nY ); @@ -843,4 +889,335 @@ void SvxFontPrevWindow::AutoCorrectFontColor( void ) pImpl->aCTLFont.SetColor( aFontColor ); } +// ----------------------------------------------------------------------- + +void SvxFontPrevWindow::Init( const SfxItemSet& rSet ) +{ + SvxFont& rFont = GetFont(); + SvxFont& rCJKFont = GetCJKFont(); + SvxFont& rCTLFont = GetCTLFont(); + + initFont(rFont); + initFont(rCJKFont); + initFont(rCTLFont); + InitSettings( sal_True, sal_True ); + + sal_uInt16 nWhich; + nWhich = rSet.GetPool()->GetWhich( SID_CHAR_DLG_PREVIEW_STRING ); + if( ISITEMSET ) + { + const SfxStringItem& rItem = ( SfxStringItem& ) rSet.Get( nWhich ); + ::rtl::OUString aString = rItem.GetValue(); + if( aString.getLength() != 0 ) + SetPreviewText( aString ); + else + SetFontNameAsPreviewText(); +// RMQ SetPreviewText( aString ); + } + + // Underline + FontUnderline eUnderline; + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_UNDERLINE ); + if( ISITEMSET ) + { + const SvxUnderlineItem& rItem = ( SvxUnderlineItem& ) rSet.Get( nWhich ); + eUnderline = ( FontUnderline ) rItem.GetValue(); + SetTextLineColor( rItem.GetColor() ); + } + else + eUnderline = UNDERLINE_NONE; + + rFont.SetUnderline( eUnderline ); + rCJKFont.SetUnderline( eUnderline ); + rCTLFont.SetUnderline( eUnderline ); + + // Overline + FontUnderline eOverline; + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_OVERLINE ); + if( ISITEMSET ) + { + const SvxOverlineItem& rItem = ( SvxOverlineItem& ) rSet.Get( nWhich ); + eOverline = ( FontUnderline ) rItem.GetValue(); + SetOverlineColor( rItem.GetColor() ); + } + else + eOverline = UNDERLINE_NONE; + + rFont.SetOverline( eOverline ); + rCJKFont.SetOverline( eOverline ); + rCTLFont.SetOverline( eOverline ); + + // Strikeout + FontStrikeout eStrikeout; + nWhich = rSet.GetPool()->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 = rSet.GetPool()->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 = rSet.GetPool()->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 = rSet.GetPool()->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 = rSet.GetPool()->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 = rSet.GetPool()->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 = rSet.GetPool()->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; +sal_Bool m_bPreviewBackgroundToCharacter = sal_False; // RMQ + nWhich = rSet.GetPool()->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 = rSet.GetPool()->GetWhich( SID_ATTR_BRUSH ); + if( ISITEMSET ) + { + const SvxBrushItem& rBrush = ( SvxBrushItem& ) rSet.Get( nWhich ); + if( GPOS_NONE == rBrush.GetGraphicPos() ) + aBackCol = rBrush.GetColor(); + } + } + SetBackColor( aBackCol ); + + // Font + SetFont( rSet, SID_ATTR_CHAR_FONT, rFont ); + SetFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont ); + SetFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont ); + + // Style + SetFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont ); + SetFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont ); + SetFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont ); + + // Size + SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont ); + SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont ); + SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont ); + + // Color + nWhich = rSet.GetPool()->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 ); + + AutoCorrectFontColor(); // handle color COL_AUTO + } + + // Kerning + nWhich = rSet.GetPool()->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 = rSet.GetPool()->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; + } + + SetFontEscapement( nProp, nEscProp, nEsc ); + + // Font width scale + SetFontWidthScale( rSet ); + + Invalidate(); +} + +// ----------------------------------------------------------------------- + +void SvxFontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) +{ + sal_uInt16 nWhich = rSet.GetPool()->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 SvxFontPrevWindow::SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) +{ + sal_uInt16 nWhich = rSet.GetPool()->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 SvxFontPrevWindow::SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont ) +{ + sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nPosture ); + if( ISITEMSET ) + { + const SvxPostureItem& rItem = ( SvxPostureItem& ) rSet.Get( nWhich ); + rFont.SetItalic( ( FontItalic ) rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE ); + } + + nWhich = rSet.GetPool()->GetWhich( nWeight ); + if( ISITEMSET ) + { + SvxWeightItem& rItem = ( SvxWeightItem& ) rSet.Get( nWhich ); + rFont.SetWeight( ( FontWeight ) rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL ); + } +} + +// ----------------------------------------------------------------------- + +void SvxFontPrevWindow::SetFontWidthScale( const SfxItemSet& rSet ) +{ + sal_uInt16 nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); + if( ISITEMSET ) + { + const SvxCharScaleWidthItem& rItem = ( SvxCharScaleWidthItem& ) rSet.Get( nWhich ); + + SetFontWidthScale( rItem.GetValue() ); + } +} + +// ----------------------------------------------------------------------- +namespace +{ + // ----------------------------------------------------------------------- + void setFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) + { + _rFont.SetPropr( nProp ); + _rFont.SetProprRel( nEscProp ); + _rFont.SetEscapement( nEsc ); + } + // ----------------------------------------------------------------------- + // ----------------------------------------------------------------------- +} +// ----------------------------------------------------------------------- + +void SvxFontPrevWindow::SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) +{ + setFontEscapement(GetFont(),nProp,nEscProp,nEsc); + setFontEscapement(GetCJKFont(),nProp,nEscProp,nEsc); + setFontEscapement(GetCTLFont(),nProp,nEscProp,nEsc); + Invalidate(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */