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 | |
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')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 18 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.hxx | 5 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 6 | ||||
-rw-r--r-- | editeng/source/editeng/editobj.cxx | 12 | ||||
-rw-r--r-- | editeng/source/editeng/editobj2.hxx | 13 | ||||
-rw-r--r-- | editeng/source/editeng/editview.cxx | 10 | ||||
-rw-r--r-- | editeng/source/editeng/impedit.hxx | 7 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 12 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 9 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 22 | ||||
-rw-r--r-- | editeng/source/items/textitem.cxx | 80 | ||||
-rw-r--r-- | editeng/source/outliner/outlin2.cxx | 2 | ||||
-rw-r--r-- | editeng/source/outliner/outlvw.cxx | 10 |
13 files changed, 91 insertions, 115 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index faa6825d0aa1..a1651abb2bc0 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -74,29 +74,29 @@ using namespace ::com::sun::star; -sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType ) +sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, SvtScriptType nScriptType ) { sal_uInt16 nId = nItemId; - if ( ( nScriptType == i18n::ScriptType::ASIAN ) || - ( nScriptType == i18n::ScriptType::COMPLEX ) ) + if ( ( nScriptType == SvtScriptType::ASIAN ) || + ( nScriptType == SvtScriptType::COMPLEX ) ) { switch ( nItemId ) { case EE_CHAR_LANGUAGE: - nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_LANGUAGE_CJK : EE_CHAR_LANGUAGE_CTL; + nId = ( nScriptType == SvtScriptType::ASIAN ) ? EE_CHAR_LANGUAGE_CJK : EE_CHAR_LANGUAGE_CTL; break; case EE_CHAR_FONTINFO: - nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_FONTINFO_CJK : EE_CHAR_FONTINFO_CTL; + nId = ( nScriptType == SvtScriptType::ASIAN ) ? EE_CHAR_FONTINFO_CJK : EE_CHAR_FONTINFO_CTL; break; case EE_CHAR_FONTHEIGHT: - nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_FONTHEIGHT_CJK : EE_CHAR_FONTHEIGHT_CTL; + nId = ( nScriptType == SvtScriptType::ASIAN ) ? EE_CHAR_FONTHEIGHT_CJK : EE_CHAR_FONTHEIGHT_CTL; break; case EE_CHAR_WEIGHT: - nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_WEIGHT_CJK : EE_CHAR_WEIGHT_CTL; + nId = ( nScriptType == SvtScriptType::ASIAN ) ? EE_CHAR_WEIGHT_CJK : EE_CHAR_WEIGHT_CTL; break; case EE_CHAR_ITALIC: - nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_ITALIC_CJK : EE_CHAR_ITALIC_CTL; + nId = ( nScriptType == SvtScriptType::ASIAN ) ? EE_CHAR_ITALIC_CJK : EE_CHAR_ITALIC_CTL; break; } } @@ -2024,7 +2024,7 @@ void EditDoc::RemoveItemsFromPool(const ContentNode& rNode) } } -void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent, short nScriptType ) +void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent, SvtScriptType nScriptType ) { vcl::Font aPrevFont( rFont ); rFont.SetAlign( ALIGN_BASELINE ); diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 5d120972a13a..61e8a34854cd 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -28,6 +28,7 @@ #include <svl/itemset.hxx> #include <svl/style.hxx> #include <svl/itempool.hxx> +#include <svl/languageoptions.hxx> #include <tools/lineend.hxx> #include <vector> @@ -44,8 +45,8 @@ class SvxTabStop; #define CHARPOSGROW 16 #define DEFTAB 720 -void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, short nScriptType = 0 ); -sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, short nScriptType ); +void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent = true, SvtScriptType nScriptType = SvtScriptType::NONE ); +sal_uInt16 GetScriptItemId( sal_uInt16 nItemId, SvtScriptType nScriptType ); bool IsScriptItemValid( sal_uInt16 nItemId, short nScriptType ); EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sal_Int32 nS, sal_Int32 nE ); diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index eec5cb9771ea..70a012bb85e8 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -459,7 +459,7 @@ EEHorizontalTextDirection EditEngine::GetDefaultHorizontalTextDirection() const return pImpEditEngine->GetDefaultHorizontalTextDirection(); } -sal_uInt16 EditEngine::GetScriptType( const ESelection& rSelection ) const +SvtScriptType EditEngine::GetScriptType( const ESelection& rSelection ) const { EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) ); return pImpEditEngine->GetItemScriptType( aSel ); @@ -666,7 +666,7 @@ const ParaPortion* EditEngine::GetPrevVisPortion(const ParaPortion* pCurPortion) return pImpEditEngine->GetPrevVisPortion(pCurPortion); } -sal_uInt16 EditEngine::GetScriptType(const EditSelection& rSel) const +SvtScriptType EditEngine::GetScriptType(const EditSelection& rSel) const { return pImpEditEngine->GetItemScriptType(rSel); } @@ -2598,7 +2598,7 @@ void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const SvxFont& rFont ) rSet.Put( SvxCharReliefItem( rFont.GetRelief(), EE_CHAR_RELIEF ) ); } -vcl::Font EditEngine::CreateFontFromItemSet( const SfxItemSet& rItemSet, sal_uInt16 nScriptType ) +vcl::Font EditEngine::CreateFontFromItemSet( const SfxItemSet& rItemSet, SvtScriptType nScriptType ) { SvxFont aFont; CreateFont( aFont, rItemSet, true, nScriptType ); diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx index 03b7f04ae84e..2f4c3d4a2062 100644 --- a/editeng/source/editeng/editobj.cxx +++ b/editeng/source/editeng/editobj.cxx @@ -368,7 +368,7 @@ void EditTextObject::SetVertical( bool bVertical ) return mpImpl->SetVertical(bVertical); } -sal_uInt16 EditTextObject::GetScriptType() const +SvtScriptType EditTextObject::GetScriptType() const { return mpImpl->GetScriptType(); } @@ -569,7 +569,7 @@ EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, SfxItemPool* pP bVertical = false; bStoreUnicodeStrings = false; - nScriptType = 0; + nScriptType = SvtScriptType::NONE; } EditTextObjectImpl::EditTextObjectImpl( EditTextObject* pFront, const EditTextObjectImpl& r ) : @@ -672,7 +672,7 @@ void EditTextObjectImpl::SetVertical( bool b ) } -void EditTextObjectImpl::SetScriptType( sal_uInt16 nType ) +void EditTextObjectImpl::SetScriptType( SvtScriptType nType ) { nScriptType = nType; } @@ -1244,7 +1244,7 @@ void EditTextObjectImpl::StoreData( SvStream& rOStream ) const rOStream.WriteUInt32( nObjSettings ); rOStream.WriteUChar( bVertical ); - rOStream.WriteUInt16( nScriptType ); + rOStream.WriteUInt16( static_cast<sal_uInt16>(nScriptType) ); rOStream.WriteUChar( bStoreUnicodeStrings ); if ( bStoreUnicodeStrings ) @@ -1503,7 +1503,9 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream ) if ( nVersion >= 602 ) { - rIStream.ReadUInt16( nScriptType ); + sal_uInt16 aTmp16; + rIStream.ReadUInt16( aTmp16 ); + nScriptType = static_cast<SvtScriptType>(aTmp16); bool bUnicodeStrings(false); rIStream.ReadCharAsBool( bUnicodeStrings ); diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx index 57725bced441..fe1fcf30972f 100644 --- a/editeng/source/editeng/editobj2.hxx +++ b/editeng/source/editeng/editobj2.hxx @@ -26,6 +26,7 @@ #include <unotools/fontcvt.hxx> #include "svl/sharedstring.hxx" +#include <svl/languageoptions.hxx> #include <boost/ptr_container/ptr_vector.hpp> #include <boost/noncopyable.hpp> @@ -185,10 +186,10 @@ private: XParaPortionList* pPortionInfo; sal_uInt32 nObjSettings; - sal_uInt16 nMetric; - sal_uInt16 nVersion; - sal_uInt16 nUserType; - sal_uInt16 nScriptType; + sal_uInt16 nMetric; + sal_uInt16 nVersion; + sal_uInt16 nUserType; + SvtScriptType nScriptType; bool bOwnerOfPool:1; bool bVertical:1; @@ -214,8 +215,8 @@ public: bool IsVertical() const { return bVertical;} void SetVertical( bool b ); - sal_uInt16 GetScriptType() const { return nScriptType;} - void SetScriptType( sal_uInt16 nType ); + SvtScriptType GetScriptType() const { return nScriptType;} + void SetScriptType( SvtScriptType nType ); ContentInfo* CreateAndInsertContent(); XEditAttribute* CreateAttrib( const SfxPoolItem& rItem, sal_uInt16 nStart, sal_uInt16 nEnd ); diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index d407e4e26402..4d96e64c8a4b 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -259,7 +259,7 @@ void EditView::DeleteSelected() pImpEditView->DeleteSelected(); } -sal_uInt16 EditView::GetSelectedScriptType() const +SvtScriptType EditView::GetSelectedScriptType() const { return pImpEditView->pEditEngine->GetScriptType( pImpEditView->GetEditSelection() ); } @@ -945,14 +945,14 @@ void EditView::ExecuteSpellPopup( const Point& rPosPixel, Link* pCallBack ) else if ( ( nId == MN_WORDLANGUAGE ) || ( nId == MN_PARALANGUAGE ) ) { LanguageType nLangToUse = (nId == MN_WORDLANGUAGE) ? nGuessLangWord : nGuessLangPara; - sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse ); + SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse ); SfxItemSet aAttrs = GetEditEngine()->GetEmptyItemSet(); - if (nScriptType == SCRIPTTYPE_LATIN) + if (nScriptType == SvtScriptType::LATIN) aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE ) ); - if (nScriptType == SCRIPTTYPE_COMPLEX) + if (nScriptType == SvtScriptType::COMPLEX) aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CTL ) ); - if (nScriptType == SCRIPTTYPE_ASIAN) + if (nScriptType == SvtScriptType::ASIAN) aAttrs.Put( SvxLanguageItem( nLangToUse, EE_CHAR_LANGUAGE_CJK ) ); if ( nId == MN_PARALANGUAGE ) { diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 92e7f274302b..45dc28a27123 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -37,6 +37,7 @@ #include <vcl/dndhelp.hxx> #include <svl/ondemand.hxx> +#include <svl/languageoptions.hxx> #include <com/sun/star/linguistic2/XSpellAlternatives.hpp> #include <com/sun/star/linguistic2/SpellFailure.hpp> #include <com/sun/star/linguistic2/XSpellChecker.hpp> @@ -608,9 +609,9 @@ private: void InitScriptTypes( sal_Int32 nPara ); sal_uInt16 GetI18NScriptType( const EditPaM& rPaM, sal_Int32* pEndPos = NULL ) const; - sal_uInt16 GetItemScriptType( const EditSelection& rSel ) const; - bool IsScriptChange( const EditPaM& rPaM ) const; - bool HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const; + SvtScriptType GetItemScriptType( const EditSelection& rSel ) const; + bool IsScriptChange( const EditPaM& rPaM ) const; + bool HasScriptType( sal_Int32 nPara, sal_uInt16 nType ) const; bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos, long* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 7d4f1c8a2b92..b0593cde7b6b 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -1686,7 +1686,7 @@ void ImpEditEngine::InitScriptTypes( sal_Int32 nPara ) } if ( rTypes[0].nScriptType == i18n::ScriptType::WEAK ) - rTypes[0].nScriptType = ( rTypes.size() > 1 ) ? rTypes[1].nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); + rTypes[0].nScriptType = ( rTypes.size() > 1 ) ? rTypes[1].nScriptType : SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); // create writing direction information: if ( pParaPortion->aWritingDirectionInfos.empty() ) @@ -1776,15 +1776,15 @@ sal_uInt16 ImpEditEngine::GetI18NScriptType( const EditPaM& rPaM, sal_Int32* pEn *pEndPos = itr->nEndPos; } } - return nScriptType ? nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); + return nScriptType ? nScriptType : SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); } -sal_uInt16 ImpEditEngine::GetItemScriptType( const EditSelection& rSel ) const +SvtScriptType ImpEditEngine::GetItemScriptType( const EditSelection& rSel ) const { EditSelection aSel( rSel ); aSel.Adjust( aEditDoc ); - short nScriptType = 0; + SvtScriptType nScriptType = SvtScriptType::NONE; sal_Int32 nStartPara = GetEditDoc().GetPos( aSel.Min().GetNode() ); sal_Int32 nEndPara = GetEditDoc().GetPos( aSel.Max().GetNode() ); @@ -1821,11 +1821,11 @@ sal_uInt16 ImpEditEngine::GetItemScriptType( const EditSelection& rSel ) const if (bStartInRange || bEndInRange) { if ( rTypes[n].nScriptType != i18n::ScriptType::WEAK ) - nScriptType |= ::GetItemScriptType( rTypes[n].nScriptType ); + nScriptType |= SvtLanguageOptions::FromI18NToSvtScriptType( rTypes[n].nScriptType ); } } } - return nScriptType ? nScriptType : SvtLanguageOptions::GetScriptTypeOfLanguage( GetDefaultLanguage() ); + return bool(nScriptType) ? nScriptType : SvtLanguageOptions::GetScriptTypeOfLanguage( GetDefaultLanguage() ); } bool ImpEditEngine::IsScriptChange( const EditPaM& rPaM ) const diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 5157b8b95708..eb9f2ebb9265 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2564,8 +2564,9 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo /* * Set attributes for script types Asian and Complex */ - short nScriptType = GetI18NScriptType( EditPaM( pNode, nPos ) ); - if ( ( nScriptType == i18n::ScriptType::ASIAN ) || ( nScriptType == i18n::ScriptType::COMPLEX ) ) + short nScriptTypeI18N = GetI18NScriptType( EditPaM( pNode, nPos ) ); + SvtScriptType nScriptType = SvtLanguageOptions::FromI18NToSvtScriptType(nScriptTypeI18N); + if ( ( nScriptTypeI18N == i18n::ScriptType::ASIAN ) || ( nScriptTypeI18N == i18n::ScriptType::COMPLEX ) ) { const SvxFontItem& rFontItem = static_cast<const SvxFontItem&>(pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_FONTINFO, nScriptType ) )); rFont.SetName( rFontItem.GetFamilyName() ); @@ -2624,7 +2625,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo || ( !pNode->Len() ) ) ) { DBG_ASSERT( ( pAttrib->Which() >= EE_CHAR_START ) && ( pAttrib->Which() <= EE_FEATURE_END ), "Invalid Attribute in Seek() " ); - if ( IsScriptItemValid( pAttrib->Which(), nScriptType ) ) + if ( IsScriptItemValid( pAttrib->Which(), nScriptTypeI18N ) ) { pAttrib->SetFont( rFont, pOut ); // #i1550# hard color attrib should win over text color from field @@ -2649,7 +2650,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo rFont.SetCJKContextLanguage( pCJKLanguageItem->GetLanguage() ); - if ( rFont.GetKerning() && IsKernAsianPunctuation() && ( nScriptType == i18n::ScriptType::ASIAN ) ) + if ( rFont.GetKerning() && IsKernAsianPunctuation() && ( nScriptTypeI18N == i18n::ScriptType::ASIAN ) ) rFont.SetKerning( rFont.GetKerning() | KERNING_ASIAN ); if ( aStatus.DoNotUseColors() ) diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 37d0b2080cc4..6067a908d88c 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -641,7 +641,8 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) else { aAttribItems.Clear(); - sal_uInt16 nScriptType = GetI18NScriptType( EditPaM( pNode, nIndex+1 ) ); + sal_uInt16 nScriptTypeI18N = GetI18NScriptType( EditPaM( pNode, nIndex+1 ) ); + SvtScriptType nScriptType = SvtLanguageOptions::FromI18NToSvtScriptType(nScriptTypeI18N); if ( !n || IsScriptChange( EditPaM( pNode, nIndex ) ) ) { SfxItemSet aAttribs = GetAttribs( nNode, nIndex+1, nIndex+1 ); @@ -652,7 +653,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) aAttribItems.Insert( &aAttribs.Get( GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ) ) ); } // Insert hard attribs AFTER CJK attribs... - lcl_FindValidAttribs( aAttribItems, pNode, nIndex, nScriptType ); + lcl_FindValidAttribs( aAttribItems, pNode, nIndex, nScriptTypeI18N ); rOutput.WriteChar( '{' ); if ( WriteItemListAsRTF( aAttribItems, rOutput, nNode, nIndex, aFontTable, aColorList ) ) @@ -1421,7 +1422,8 @@ void ImpEditEngine::SetAllMisspellRanges( const std::vector<editeng::MisspellRan LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, sal_Int32* pEndPos ) const { - short nScriptType = GetI18NScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen + short nScriptTypeI18N = GetI18NScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen + SvtScriptType nScriptType = SvtLanguageOptions::FromI18NToSvtScriptType(nScriptTypeI18N); sal_uInt16 nLangId = GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ); const SvxLanguageItem* pLangItem = &static_cast<const SvxLanguageItem&>(rPaM.GetNode()->GetContentAttribs().GetItem( nLangId )); const EditCharAttrib* pAttr = rPaM.GetNode()->GetCharAttribs().FindAttrib( nLangId, rPaM.GetIndex() ); @@ -2146,12 +2148,13 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, rEditView.pImpEditView->SetEditSelection( aCurrentOldPosition->Max() ); } - sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); + SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE; switch(nScriptType) { - case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; - case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + case SvtScriptType::ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; + case SvtScriptType::COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + default: break; } if(aCurrentNewPortion->sText != aCurrentOldPortion->sText) { @@ -2193,12 +2196,13 @@ void ImpEditEngine::ApplyChangedSentence(EditView& rEditView, LanguageType eCurLanguage = GetLanguage( aCurrentPaM ); if(eCurLanguage != aCurrentNewPortion->eLanguage) { - sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); + SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage ); sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE; switch(nScriptType) { - case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; - case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + case SvtScriptType::ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; + case SvtScriptType::COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; + default: break; } SfxItemSet aSet( aEditDoc.GetItemPool(), nLangWhichId, nLangWhichId); aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId)); 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() ); diff --git a/editeng/source/outliner/outlin2.cxx b/editeng/source/outliner/outlin2.cxx index 9f3defc4d765..13b17442bdbe 100644 --- a/editeng/source/outliner/outlin2.cxx +++ b/editeng/source/outliner/outlin2.cxx @@ -552,7 +552,7 @@ EEHorizontalTextDirection Outliner::GetDefaultHorizontalTextDirection() const return pEditEngine->GetDefaultHorizontalTextDirection(); } -sal_uInt16 Outliner::GetScriptType( const ESelection& rSelection ) const +SvtScriptType Outliner::GetScriptType( const ESelection& rSelection ) const { return pEditEngine->GetScriptType( rSelection ); } diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index 09d1341ec691..a41059595a5b 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -1440,7 +1440,7 @@ SfxItemSet OutlinerView::GetAttribs() return pEditView->GetAttribs(); } -sal_uInt16 OutlinerView::GetSelectedScriptType() const +SvtScriptType OutlinerView::GetSelectedScriptType() const { return pEditView->GetSelectedScriptType(); } @@ -1462,15 +1462,15 @@ Selection OutlinerView::GetSurroundingTextSelection() const namespace { -bool isSingleScriptType( sal_uInt16 nScriptType ) +bool isSingleScriptType( SvtScriptType nScriptType ) { sal_uInt8 nScriptCount = 0; - if (nScriptType & SCRIPTTYPE_LATIN) + if (nScriptType & SvtScriptType::LATIN) ++nScriptCount; - if (nScriptType & SCRIPTTYPE_ASIAN) + if (nScriptType & SvtScriptType::ASIAN) ++nScriptCount; - if (nScriptType & SCRIPTTYPE_COMPLEX) + if (nScriptType & SvtScriptType::COMPLEX) ++nScriptCount; return nScriptCount == 1; |