diff options
author | Noel Grandin <noel@peralex.com> | 2015-05-13 10:53:15 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-05-14 12:00:40 +0200 |
commit | 19a32ddfd2b9c1beb17641e99f139ac0d3dcaf96 (patch) | |
tree | e2895b10ec66bae2ec47da748cf2848dea0bffa9 | |
parent | 3c0805e1f4f4d14e92c7e655d59c87de5c207e48 (diff) |
convert KERNING_ constants to scoped enum
Change-Id: I58031485aaa9ebdeb986a3ee0376f36a9f667947
-rw-r--r-- | editeng/source/editeng/editattr.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 4 | ||||
-rw-r--r-- | editeng/source/uno/unofdesc.cxx | 2 | ||||
-rw-r--r-- | include/vcl/fntstyle.hxx | 14 | ||||
-rw-r--r-- | svx/source/fmcomp/fmgridif.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/swfont.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/text/atrstck.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 12 | ||||
-rw-r--r-- | toolkit/source/helper/vclunohelper.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/font.cxx | 10 | ||||
-rw-r--r-- | vcl/source/outdev/font.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 2 |
14 files changed, 44 insertions, 36 deletions
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx index 3076eade5aad..dcb9fa014b87 100644 --- a/editeng/source/editeng/editattr.cxx +++ b/editeng/source/editeng/editattr.cxx @@ -411,7 +411,7 @@ EditCharAttribPairKerning::EditCharAttribPairKerning( const SvxAutoKernItem& rAt void EditCharAttribPairKerning::SetFont( SvxFont& rFont, OutputDevice* ) { - rFont.SetKerning( static_cast<const SvxAutoKernItem*>(GetItem())->GetValue() ? KERNING_FONTSPECIFIC : 0 ); + rFont.SetKerning( static_cast<const SvxAutoKernItem*>(GetItem())->GetValue() ? FontKerning::FontSpecific : FontKerning::NONE ); } diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 33ea25b6e134..c9fe9755005f 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -2083,7 +2083,7 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent, S rFont.SetEscapement( nEsc ); } if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_PAIRKERNING ) == SfxItemState::SET ) ) - rFont.SetKerning( static_cast<const SvxAutoKernItem&>(rSet.Get( EE_CHAR_PAIRKERNING )).GetValue() ? KERNING_FONTSPECIFIC : 0 ); + rFont.SetKerning( static_cast<const SvxAutoKernItem&>(rSet.Get( EE_CHAR_PAIRKERNING )).GetValue() ? FontKerning::FontSpecific : FontKerning::NONE ); if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_KERNING ) == SfxItemState::SET ) ) rFont.SetFixKerning( static_cast<const SvxKerningItem&>(rSet.Get( EE_CHAR_KERNING )).GetValue() ); if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_WLM ) == SfxItemState::SET ) ) diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 7685e316d084..1a8ac4d5918b 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2646,8 +2646,8 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo rFont.SetCJKContextLanguage( pCJKLanguageItem->GetLanguage() ); - if ( rFont.GetKerning() && IsKernAsianPunctuation() && ( nScriptTypeI18N == i18n::ScriptType::ASIAN ) ) - rFont.SetKerning( rFont.GetKerning() | KERNING_ASIAN ); + if ( (rFont.GetKerning() != FontKerning::NONE) && IsKernAsianPunctuation() && ( nScriptTypeI18N == i18n::ScriptType::ASIAN ) ) + rFont.SetKerning( rFont.GetKerning() | FontKerning::Asian ); if ( aStatus.DoNotUseColors() ) { diff --git a/editeng/source/uno/unofdesc.cxx b/editeng/source/uno/unofdesc.cxx index c9555ccbe72c..c5d85a19a8a8 100644 --- a/editeng/source/uno/unofdesc.cxx +++ b/editeng/source/uno/unofdesc.cxx @@ -47,7 +47,7 @@ void SvxUnoFontDescriptor::ConvertToFont( const awt::FontDescriptor& rDesc, vcl: rFont.SetCharSet( (rtl_TextEncoding)rDesc.CharSet ); rFont.SetPitch( (FontPitch)rDesc.Pitch ); rFont.SetOrientation( (short)(rDesc.Orientation*10) ); - rFont.SetKerning( rDesc.Kerning ); + rFont.SetKerning( rDesc.Kerning ? FontKerning::FontSpecific : FontKerning::NONE ); rFont.SetWeight( VCLUnoHelper::ConvertFontWeight(rDesc.Weight) ); rFont.SetItalic( (FontItalic)rDesc.Slant ); rFont.SetUnderline( (FontUnderline)rDesc.Underline ); diff --git a/include/vcl/fntstyle.hxx b/include/vcl/fntstyle.hxx index e2fc652cd900..481d0a2ff9cf 100644 --- a/include/vcl/fntstyle.hxx +++ b/include/vcl/fntstyle.hxx @@ -21,12 +21,20 @@ #define INCLUDED_VCL_FNTSTYLE_HXX #include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> enum FontRelief { RELIEF_NONE, RELIEF_EMBOSSED, RELIEF_ENGRAVED, FontRelief_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; -typedef sal_uInt8 FontKerning; -#define KERNING_FONTSPECIFIC ((FontKerning)0x01) -#define KERNING_ASIAN ((FontKerning)0x02) +enum class FontKerning +{ + NONE = 0x00, + FontSpecific = 0x01, + Asian = 0x02, +}; +namespace o3tl +{ + template<> struct typed_flags<FontKerning> : is_typed_flags<FontKerning, 0x03> {}; +} #endif // INCLUDED_VCL_FNTSTYLE_HXX diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 35b992a787ec..e78f3a85c910 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -117,7 +117,7 @@ vcl::Font ImplCreateFont( const ::com::sun::star::awt::FontDescriptor& rDescr ) aFont.SetUnderline( (::FontUnderline)rDescr.Underline ); aFont.SetStrikeout( (::FontStrikeout)rDescr.Strikeout ); aFont.SetOrientation( (sal_Int16)rDescr.Orientation ); - aFont.SetKerning( rDescr.Kerning ); + aFont.SetKerning( static_cast<FontKerning>(rDescr.Kerning) ); aFont.SetWordLineMode( rDescr.WordLineMode ); return aFont; } diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index 14cb4c8169fd..266c5c5ffd37 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -98,7 +98,7 @@ class SwSubFont : public SvxFont inline void SetOutline( const bool bOutline ); inline void SetVertical( const sal_uInt16 nDir, const bool bVertFormat ); inline void SetShadow( const bool bShadow ); - inline void SetAutoKern( const sal_uInt8 nAutoKern ); + inline void SetAutoKern( FontKerning nAutoKern ); inline void SetWordLineMode( const bool bWordLineMode ); inline void SetEmphasisMark( const FontEmphasisMark eValue ); inline void SetRelief( const FontRelief eNew ); @@ -224,7 +224,7 @@ public: inline void SetOutline( const bool bOutline ); void SetVertical( sal_uInt16 nDir, const bool nVertLayout = false ); inline void SetShadow( const bool bShadow ); - inline void SetAutoKern( sal_uInt8 nAutoKern ); + inline void SetAutoKern( FontKerning nAutoKern ); inline void SetTransparent( const bool bTrans ); inline void SetWordLineMode( const bool bWordLineMode ); inline void SetFixKerning( const short nNewKern ); @@ -668,18 +668,18 @@ inline void SwFont::SetShadow( const bool bShadow ) } // encapsulated SV-Font-method -inline void SwSubFont::SetAutoKern( const sal_uInt8 nAutoKern ) +inline void SwSubFont::SetAutoKern( FontKerning nAutoKern ) { pMagic = 0; Font::SetKerning( nAutoKern ); } -inline void SwFont::SetAutoKern( sal_uInt8 nAutoKern ) +inline void SwFont::SetAutoKern( FontKerning nAutoKern ) { bFntChg = true; aSub[1].SetAutoKern( nAutoKern ); - if( nAutoKern ) - nAutoKern = KERNING_FONTSPECIFIC; + if( nAutoKern != FontKerning::NONE ) + nAutoKern = FontKerning::FontSpecific; aSub[0].SetAutoKern( nAutoKern ); aSub[2].SetAutoKern( nAutoKern ); } diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index 80f2dee123f4..e3cbe00f99be 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -727,11 +727,11 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush ) { rFnt.SetAutoKern( ( !mpIDocumentSettingAccess || !mpIDocumentSettingAccess->get(DocumentSettingId::KERN_ASIAN_PUNCTUATION) ) ? - KERNING_FONTSPECIFIC : - KERNING_ASIAN ); + FontKerning::FontSpecific : + FontKerning::Asian ); } else - rFnt.SetAutoKern( 0 ); + rFnt.SetAutoKern( FontKerning::NONE ); break; case RES_CHRATR_BLINK : rFnt.SetBlink( static_cast<const SvxBlinkItem&>(rItem).GetValue() ); diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index a344a7e956da..0bf13ebfaeab 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1574,7 +1574,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) // In case of Pair Kerning the printer influence on the positioning // grows - const int nMul = pPrtFont->GetKerning() ? 1 : 3; + const int nMul = pPrtFont->GetKerning() != FontKerning::NONE ? 1 : 3; const int nDiv = nMul+1; // nSpaceSum contains the sum of the intermediate space distributed @@ -1927,7 +1927,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) // In case of Pair Kerning the printer influence on the positioning // grows - const int nMul = pPrtFont->GetKerning() ? 1 : 3; + const int nMul = pPrtFont->GetKerning() != FontKerning::NONE ? 1 : 3; const int nDiv = nMul+1; for( sal_Int32 i = 1; i<nCnt; i++ ) { diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 4849954ba3c8..c79495621574 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -626,11 +626,11 @@ void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet, { SetAutoKern( ( !pIDocumentSettingAccess || !pIDocumentSettingAccess->get(DocumentSettingId::KERN_ASIAN_PUNCTUATION) ) ? - KERNING_FONTSPECIFIC : - KERNING_ASIAN ); + FontKerning::FontSpecific : + FontKerning::Asian ); } else - SetAutoKern( 0 ); + SetAutoKern( FontKerning::NONE ); } if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_WORDLINEMODE, true, &pItem )) @@ -826,11 +826,11 @@ SwFont::SwFont( const SwAttrSet* pAttrSet, { SetAutoKern( ( !pIDocumentSettingAccess || !pIDocumentSettingAccess->get(DocumentSettingId::KERN_ASIAN_PUNCTUATION) ) ? - KERNING_FONTSPECIFIC : - KERNING_ASIAN ); + FontKerning::FontSpecific : + FontKerning::Asian ); } else - SetAutoKern( 0 ); + SetAutoKern( FontKerning::NONE ); SetWordLineMode( pAttrSet->GetWordLineMode().GetValue() ); const SvxEscapementItem &rEsc = pAttrSet->GetEscapement(); SetEscapement( rEsc.GetEsc() ); diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx index 005caccf8871..d8245c88fcaf 100644 --- a/toolkit/source/helper/vclunohelper.cxx +++ b/toolkit/source/helper/vclunohelper.cxx @@ -412,7 +412,7 @@ vcl::Font VCLUnoHelper::CreateFont( const ::com::sun::star::awt::FontDescriptor& // Kein DONTKNOW aFont.SetOrientation( (short)rDescr.Orientation ); - aFont.SetKerning( rDescr.Kerning ); + aFont.SetKerning( static_cast<FontKerning>(rDescr.Kerning) ); aFont.SetWordLineMode( rDescr.WordLineMode ); return aFont; diff --git a/vcl/source/gdi/font.cxx b/vcl/source/gdi/font.cxx index 5dd22f3e0645..f8a1c831ac16 100644 --- a/vcl/source/gdi/font.cxx +++ b/vcl/source/gdi/font.cxx @@ -56,7 +56,7 @@ Impl_Font::Impl_Font() : meRelief = RELIEF_NONE; meEmphasisMark = EMPHASISMARK_NONE; mnOrientation = 0; - mnKerning = 0; + mnKerning = FontKerning::NONE; mbWordLine = false; mbOutline = false; mbShadow = false; @@ -450,7 +450,7 @@ void Font::SetKerning( FontKerning nKerning ) bool Font::IsKerning() const { - return (mpImplFont->mnKerning & KERNING_FONTSPECIFIC) != 0; + return bool(mpImplFont->mnKerning & FontKerning::FontSpecific); } void Font::SetWeight( FontWeight eWeight ) @@ -637,7 +637,7 @@ void Font::Merge( const vcl::Font& rFont ) SetOrientation( rFont.GetOrientation() ); SetVertical( rFont.IsVertical() ); SetEmphasisMark( rFont.GetEmphasisMark() ); - SetKerning( rFont.IsKerning() ? KERNING_FONTSPECIFIC : 0 ); + SetKerning( rFont.IsKerning() ? FontKerning::FontSpecific : FontKerning::NONE ); SetOutline( rFont.IsOutline() ); SetShadow( rFont.IsShadow() ); SetRelief( rFont.GetRelief() ); @@ -681,7 +681,7 @@ SvStream& ReadImpl_Font( SvStream& rIStm, Impl_Font& rImpl_Font ) rIStm.ReadCharAsBool( bTmp ); rImpl_Font.mbWordLine = bTmp; rIStm.ReadCharAsBool( bTmp ); rImpl_Font.mbOutline = bTmp; rIStm.ReadCharAsBool( bTmp ); rImpl_Font.mbShadow = bTmp; - rIStm.ReadUChar( nTmp8 ); rImpl_Font.mnKerning = nTmp8; + rIStm.ReadUChar( nTmp8 ); rImpl_Font.mnKerning = static_cast<FontKerning>(nTmp8); if( aCompat.GetVersion() >= 2 ) { @@ -722,7 +722,7 @@ SvStream& WriteImpl_Font( SvStream& rOStm, const Impl_Font& rImpl_Font ) rOStm.WriteBool( rImpl_Font.mbWordLine ); rOStm.WriteBool( rImpl_Font.mbOutline ); rOStm.WriteBool( rImpl_Font.mbShadow ); - rOStm.WriteUChar( rImpl_Font.mnKerning ); + rOStm.WriteUChar( static_cast<sal_uInt8>(rImpl_Font.mnKerning) ); // new in version 2 rOStm.WriteUChar( rImpl_Font.meRelief ); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 2d9dd97cde74..eefa320c8434 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -207,7 +207,7 @@ FontMetric OutputDevice::GetFontMetric() const else aMetric.SetOrientation( pMetric->mnOrientation ); if( !pEntry->maMetric.mbKernableFont ) - aMetric.SetKerning( maFont.GetKerning() & ~KERNING_FONTSPECIFIC ); + aMetric.SetKerning( maFont.GetKerning() & ~FontKerning::FontSpecific ); // set remaining metric fields aMetric.mpImplMetric->mnMiscFlags = 0; @@ -1584,7 +1584,7 @@ bool OutputDevice::ImplNewFont() const } // enable kerning array if requested - if ( maFont.GetKerning() & KERNING_FONTSPECIFIC ) + if ( maFont.GetKerning() & FontKerning::FontSpecific ) { // TODO: test if physical font supports kerning and disable if not if( pFontEntry->maMetric.mbKernableFont ) @@ -1592,7 +1592,7 @@ bool OutputDevice::ImplNewFont() const } else mbKerning = false; - if ( maFont.GetKerning() & KERNING_ASIAN ) + if ( maFont.GetKerning() & FontKerning::Asian ) mbKerning = true; // calculate EmphasisArea diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 9dc3aa5213af..d371f8ec8d95 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1229,7 +1229,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, if( mbKerning ) nLayoutFlags |= SAL_LAYOUT_KERNING_PAIRS; - if( maFont.GetKerning() & KERNING_ASIAN ) + if( maFont.GetKerning() & FontKerning::Asian ) nLayoutFlags |= SAL_LAYOUT_KERNING_ASIAN; if( maFont.IsVertical() ) nLayoutFlags |= SAL_LAYOUT_VERTICAL; |