diff options
author | Noel Grandin <noel@peralex.com> | 2015-04-15 09:36:39 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-04-17 07:21:08 +0000 |
commit | a7b7c64afc523cfd9ff4e724b3efbec6567fc1c8 (patch) | |
tree | 52fd05ef3292f3dab172864cbc3be96a8d44a9d0 /editeng/source/items | |
parent | add7eeb7dbd0eefa0c5ae5430490864079add801 (diff) |
convert SCRIPTTYPE_ constants to scoped enum
Change-Id: I5be3980ac865162d8d7626556ca47eca4b0ee433
Reviewed-on: https://gerrit.libreoffice.org/15344
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'editeng/source/items')
-rw-r--r-- | editeng/source/items/textitem.cxx | 80 |
1 files changed, 23 insertions, 57 deletions
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 5209e55e3341..7b3f647d8083 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -3316,13 +3316,13 @@ bool SvxCharReliefItem::QueryValue( com::sun::star::uno::Any& rVal, |* class SvxScriptTypeItemItem *************************************************************************/ -SvxScriptTypeItem::SvxScriptTypeItem( sal_uInt16 nType ) - : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE, nType ) +SvxScriptTypeItem::SvxScriptTypeItem( SvtScriptType nType ) + : SfxUInt16Item( SID_ATTR_CHAR_SCRIPTTYPE, static_cast<sal_uInt16>(nType) ) { } SfxPoolItem* SvxScriptTypeItem::Clone( SfxItemPool * ) const { - return new SvxScriptTypeItem( GetValue() ); + return new SvxScriptTypeItem( static_cast<SvtScriptType>(GetValue()) ); } /************************************************************************* @@ -3363,80 +3363,73 @@ const SfxPoolItem* SvxScriptSetItem::GetItemOfScriptSet( return pI; } -const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId, const SfxItemSet& rSet, sal_uInt16 nScript ) +const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nSlotId, const SfxItemSet& rSet, SvtScriptType nScript ) { sal_uInt16 nLatin, nAsian, nComplex; GetWhichIds( nSlotId, rSet, nLatin, nAsian, nComplex ); const SfxPoolItem *pRet, *pAsn, *pCmplx; - switch( nScript ) + if (nScript == SvtScriptType::ASIAN) { - default: //no one valid -> match to latin - // case SCRIPTTYPE_LATIN: - pRet = GetItemOfScriptSet( rSet, nLatin ); - break; - case SCRIPTTYPE_ASIAN: pRet = GetItemOfScriptSet( rSet, nAsian ); - break; - case SCRIPTTYPE_COMPLEX: + } else if (nScript == SvtScriptType::COMPLEX) + { pRet = GetItemOfScriptSet( rSet, nComplex ); - break; - - case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN: + } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::ASIAN)) + { if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) || 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) || *pRet != *pAsn ) pRet = 0; - break; - - case SCRIPTTYPE_LATIN|SCRIPTTYPE_COMPLEX: + } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::COMPLEX)) + { if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) || 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) || *pRet != *pCmplx ) pRet = 0; - break; - - case SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX: + } else if (nScript == (SvtScriptType::ASIAN|SvtScriptType::COMPLEX)) + { if( 0 == (pRet = GetItemOfScriptSet( rSet, nAsian )) || 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) || *pRet != *pCmplx ) pRet = 0; - break; - - case SCRIPTTYPE_LATIN|SCRIPTTYPE_ASIAN|SCRIPTTYPE_COMPLEX: + } else if (nScript == (SvtScriptType::LATIN|SvtScriptType::ASIAN|SvtScriptType::COMPLEX)) + { if( 0 == (pRet = GetItemOfScriptSet( rSet, nLatin )) || 0 == (pAsn = GetItemOfScriptSet( rSet, nAsian )) || 0 == (pCmplx = GetItemOfScriptSet( rSet, nComplex )) || *pRet != *pAsn || *pRet != *pCmplx ) pRet = 0; - break; + } else { + //no one valid -> match to latin + pRet = GetItemOfScriptSet( rSet, nLatin ); } return pRet; } -const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( sal_uInt16 nScript ) const +const SfxPoolItem* SvxScriptSetItem::GetItemOfScript( SvtScriptType nScript ) const { return GetItemOfScript( Which(), GetItemSet(), nScript ); } -void SvxScriptSetItem::PutItemForScriptType( sal_uInt16 nScriptType, +void SvxScriptSetItem::PutItemForScriptType( SvtScriptType nScriptType, const SfxPoolItem& rItem ) { sal_uInt16 nLatin, nAsian, nComplex; GetWhichIds( nLatin, nAsian, nComplex ); SfxPoolItem* pCpy = rItem.Clone(); - if( SCRIPTTYPE_LATIN & nScriptType ) + if( SvtScriptType::LATIN & nScriptType ) { pCpy->SetWhich( nLatin ); GetItemSet().Put( *pCpy ); } - if( SCRIPTTYPE_ASIAN & nScriptType ) + if( SvtScriptType::ASIAN & nScriptType ) { pCpy->SetWhich( nAsian ); GetItemSet().Put( *pCpy ); } - if( SCRIPTTYPE_COMPLEX & nScriptType ) + if( SvtScriptType::COMPLEX & nScriptType ) { pCpy->SetWhich( nComplex ); GetItemSet().Put( *pCpy ); @@ -3539,33 +3532,6 @@ void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rCo } -sal_uInt16 GetI18NScriptTypeOfLanguage( sal_uInt16 nLang ) -{ - return GetI18NScriptType( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) ); -} - -sal_uInt16 GetItemScriptType( short nI18NType ) -{ - switch ( nI18NType ) - { - case i18n::ScriptType::LATIN: return SCRIPTTYPE_LATIN; - case i18n::ScriptType::ASIAN: return SCRIPTTYPE_ASIAN; - case i18n::ScriptType::COMPLEX: return SCRIPTTYPE_COMPLEX; - } - return 0; -} - -short GetI18NScriptType( sal_uInt16 nItemType ) -{ - switch ( nItemType ) - { - case SCRIPTTYPE_LATIN: return i18n::ScriptType::LATIN; - case SCRIPTTYPE_ASIAN: return i18n::ScriptType::ASIAN; - case SCRIPTTYPE_COMPLEX: return i18n::ScriptType::COMPLEX; - } - return 0; -} - bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const { rVal <<= ( (sal_uInt32)GetValue() ); |