diff options
author | Noel Grandin <noel@peralex.com> | 2015-04-08 11:05:34 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-04-08 11:40:15 +0200 |
commit | 704edbf7dc844e52404bf52f9d5dc768cfd024d0 (patch) | |
tree | a5697b9e255707f911a966d67dd1bbd7586b9176 | |
parent | 6bf94344723146d64092b7beba93fe78e7119029 (diff) |
convert DIC_ERR_ constants to scoped enum
Change-Id: I083f1b7f21b18c5067b01c82fa8fec467a3d0c50
-rw-r--r-- | cui/source/dialogs/SpellDialog.cxx | 23 | ||||
-rw-r--r-- | cui/source/options/optdict.cxx | 7 | ||||
-rw-r--r-- | editeng/source/misc/unolingu.cxx | 8 | ||||
-rw-r--r-- | include/editeng/unolingu.hxx | 3 | ||||
-rw-r--r-- | include/linguistic/misc.hxx | 11 | ||||
-rw-r--r-- | linguistic/source/misc.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/lingu/olmenu.cxx | 8 |
7 files changed, 37 insertions, 35 deletions
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 38bfb82c4730..1aa1613b286f 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -64,6 +64,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::linguistic2; +using namespace linguistic; // struct SpellDialog_Impl --------------------------------------------- @@ -249,7 +250,7 @@ SpellDialog::~SpellDialog() Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() ); if (xDicList.is()) { - linguistic::SaveDictionaries( xDicList ); + SaveDictionaries( xDicList ); } delete pImpl; @@ -577,11 +578,11 @@ IMPL_LINK_NOARG(SpellDialog, ChangeAllHdl) OUString aOldWord( m_pSentenceED->GetErrorText() ); SvxPrepareAutoCorrect( aOldWord, aString ); Reference<XDictionary> aXDictionary( SvxGetChangeAllList(), UNO_QUERY ); - sal_uInt8 nAdded = linguistic::AddEntryToDic( aXDictionary, + DictionaryError nAdded = AddEntryToDic( aXDictionary, aOldWord, true, aString, eLang ); - if(nAdded == DIC_ERR_NONE) + if(nAdded == DictionaryError::NONE) { SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); @@ -626,10 +627,10 @@ IMPL_LINK( SpellDialog, IgnoreAllHdl, Button *, pButton ) else { OUString sErrorText(m_pSentenceED->GetErrorText()); - sal_uInt8 nAdded = linguistic::AddEntryToDic( aXDictionary, + DictionaryError nAdded = AddEntryToDic( aXDictionary, sErrorText, false, OUString(), LANGUAGE_NONE ); - if(nAdded == DIC_ERR_NONE) + if(nAdded == DictionaryError::NONE) { SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); @@ -910,16 +911,16 @@ int SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu *pMenu ) if (xDicList.is()) xDic = xDicList->getDictionaryByName( aDicName ); - sal_Int16 nAddRes = DIC_ERR_UNKNOWN; + DictionaryError nAddRes = DictionaryError::UNKNOWN; if (xDic.is()) { - nAddRes = linguistic::AddEntryToDic( xDic, aNewWord, false, OUString(), LANGUAGE_NONE ); + nAddRes = AddEntryToDic( xDic, aNewWord, false, OUString(), LANGUAGE_NONE ); // save modified user-dictionary if it is persistent uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); if (xSavDic.is()) xSavDic->store(); - if (nAddRes == DIC_ERR_NONE) + if (nAddRes == DictionaryError::NONE) { SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); @@ -928,10 +929,10 @@ int SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu *pMenu ) m_pSentenceED->AddUndoAction( pAction ); } // failed because there is already an entry? - if (DIC_ERR_NONE != nAddRes && xDic->getEntry( aNewWord ).is()) - nAddRes = DIC_ERR_NONE; + if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is()) + nAddRes = DictionaryError::NONE; } - if (DIC_ERR_NONE != nAddRes) + if (DictionaryError::NONE != nAddRes) { SvxDicError( this, nAddRes ); return 0; // don't continue diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx index e936a87d98bb..f30171a278d2 100644 --- a/cui/source/options/optdict.cxx +++ b/cui/source/options/optdict.cxx @@ -39,6 +39,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::linguistic2; +using namespace linguistic; // static ---------------------------------------------------------------- @@ -597,7 +598,7 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn) OUString sEntry(aNewWord); OUString aReplaceStr(pReplaceED->GetText()); - sal_Int16 nAddRes = DIC_ERR_UNKNOWN; + DictionaryError nAddRes = DictionaryError::UNKNOWN; sal_Int32 nPos = pAllDictsLB->GetSelectEntryPos(); if ( nPos != LISTBOX_ENTRY_NOTFOUND && !aNewWord.isEmpty()) { @@ -624,10 +625,10 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn) aRplcText, LanguageTag( xDic->getLocale() ).getLanguageType(), false ); } } - if (DIC_ERR_NONE != nAddRes) + if (DictionaryError::NONE != nAddRes) SvxDicError( this, nAddRes ); - if(DIC_ERR_NONE == nAddRes && !sEntry.isEmpty()) + if(DictionaryError::NONE == nAddRes && !sEntry.isEmpty()) { // insert new entry in list-box etc... diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx index de31456c8586..d3a10720fada 100644 --- a/editeng/source/misc/unolingu.cxx +++ b/editeng/source/misc/unolingu.cxx @@ -822,16 +822,16 @@ SvxDicListChgClamp::~SvxDicListChgClamp() } } -short SvxDicError( vcl::Window *pParent, sal_Int16 nError ) +short SvxDicError( vcl::Window *pParent, linguistic::DictionaryError nError ) { short nRes = 0; - if (DIC_ERR_NONE != nError) + if (linguistic::DictionaryError::NONE != nError) { int nRid; switch (nError) { - case DIC_ERR_FULL : nRid = RID_SVXSTR_DIC_ERR_FULL; break; - case DIC_ERR_READONLY : nRid = RID_SVXSTR_DIC_ERR_READONLY; break; + case linguistic::DictionaryError::FULL : nRid = RID_SVXSTR_DIC_ERR_FULL; break; + case linguistic::DictionaryError::READONLY : nRid = RID_SVXSTR_DIC_ERR_READONLY; break; default: nRid = RID_SVXSTR_DIC_ERR_UNKNOWN; SAL_WARN("editeng", "unexpected case"); diff --git a/include/editeng/unolingu.hxx b/include/editeng/unolingu.hxx index 2b35bed79c3d..06e890081bd4 100644 --- a/include/editeng/unolingu.hxx +++ b/include/editeng/unolingu.hxx @@ -35,6 +35,7 @@ class LinguMgrExitLstnr; namespace vcl { class Window; } +namespace linguistic { enum class DictionaryError; } @@ -181,7 +182,7 @@ EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference< // misc functions -EDITENG_DLLPUBLIC short SvxDicError( vcl::Window *pParent, sal_Int16 nError ); +EDITENG_DLLPUBLIC short SvxDicError( vcl::Window *pParent, linguistic::DictionaryError nError ); #endif diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx index 4c6df31d61ca..2e0b7ff8e725 100644 --- a/include/linguistic/misc.hxx +++ b/include/linguistic/misc.hxx @@ -63,11 +63,10 @@ namespace linguistic // AddEntryToDic return values -#define DIC_ERR_NONE 0 -#define DIC_ERR_FULL 1 -#define DIC_ERR_READONLY 2 -#define DIC_ERR_UNKNOWN 3 -#define DIC_ERR_NOT_EXISTS 4 +enum class DictionaryError +{ + NONE, FULL, READONLY, UNKNOWN, NOT_EXISTS +}; // values asigned to capitalization types enum CapType @@ -166,7 +165,7 @@ bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rPrope const OUString& rWord, sal_Int16 nLanguage, bool bSearchPosDics, bool bSearchSpellEntry ); -LNG_DLLPUBLIC sal_uInt8 AddEntryToDic( +LNG_DLLPUBLIC DictionaryError AddEntryToDic( ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > &rxDic, const OUString &rWord, bool bIsNeg, const OUString &rRplcTxt, sal_Int16 nRplcLang, diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx index db7d0300121f..0903a35fda51 100644 --- a/linguistic/source/misc.cxx +++ b/linguistic/source/misc.cxx @@ -350,14 +350,14 @@ bool SaveDictionaries( const uno::Reference< XSearchableDictionaryList > &xDicLi return bRet; } -sal_uInt8 AddEntryToDic( +DictionaryError AddEntryToDic( uno::Reference< XDictionary > &rxDic, const OUString &rWord, bool bIsNeg, const OUString &rRplcTxt, sal_Int16 /* nRplcLang */, bool bStripDot ) { if (!rxDic.is()) - return DIC_ERR_NOT_EXISTS; + return DictionaryError::NOT_EXISTS; OUString aTmp( rWord ); if (bStripDot) @@ -372,18 +372,18 @@ sal_uInt8 AddEntryToDic( } bool bAddOk = rxDic->add( aTmp, bIsNeg, rRplcTxt ); - sal_uInt8 nRes = DIC_ERR_NONE; + DictionaryError nRes = DictionaryError::NONE; if (!bAddOk) { if (rxDic->isFull()) - nRes = DIC_ERR_FULL; + nRes = DictionaryError::FULL; else { uno::Reference< frame::XStorable > xStor( rxDic, UNO_QUERY ); if (xStor.is() && xStor->isReadonly()) - nRes = DIC_ERR_READONLY; + nRes = DictionaryError::READONLY; else - nRes = DIC_ERR_UNKNOWN; + nRes = DictionaryError::UNKNOWN; } } diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx index 9b9b17baf741..e4edd46a7112 100644 --- a/sw/source/uibase/lingu/olmenu.cxx +++ b/sw/source/uibase/lingu/olmenu.cxx @@ -749,9 +749,9 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) } } else { OUString sWord(m_xSpellAlt->getWord()); - sal_Int16 nAddRes = linguistic::AddEntryToDic( xDictionary, + linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary, sWord, false, OUString(), LANGUAGE_NONE ); - if (DIC_ERR_NONE != nAddRes && !xDictionary->getEntry(sWord).is()) + if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is()) { SvxDicError(&m_pSh->GetView().GetViewFrame()->GetWindow(), nAddRes); } @@ -777,13 +777,13 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) if (xDic.is()) { - sal_Int16 nAddRes = linguistic::AddEntryToDic(xDic, sWord, false, OUString(), LANGUAGE_NONE); + linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic(xDic, sWord, false, OUString(), LANGUAGE_NONE); // save modified user-dictionary if it is persistent uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); if (xSavDic.is()) xSavDic->store(); - if (DIC_ERR_NONE != nAddRes && !xDic->getEntry(sWord).is()) + if (linguistic::DictionaryError::NONE != nAddRes && !xDic->getEntry(sWord).is()) { SvxDicError(&m_pSh->GetView().GetViewFrame()->GetWindow(), nAddRes); } |