Kaydet (Commit) 704edbf7 authored tarafından Noel Grandin's avatar Noel Grandin

convert DIC_ERR_ constants to scoped enum

Change-Id: I083f1b7f21b18c5067b01c82fa8fec467a3d0c50
üst 6bf94344
...@@ -64,6 +64,7 @@ using namespace ::com::sun::star; ...@@ -64,6 +64,7 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::linguistic2; using namespace ::com::sun::star::linguistic2;
using namespace linguistic;
// struct SpellDialog_Impl --------------------------------------------- // struct SpellDialog_Impl ---------------------------------------------
...@@ -249,7 +250,7 @@ SpellDialog::~SpellDialog() ...@@ -249,7 +250,7 @@ SpellDialog::~SpellDialog()
Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() ); Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
if (xDicList.is()) if (xDicList.is())
{ {
linguistic::SaveDictionaries( xDicList ); SaveDictionaries( xDicList );
} }
delete pImpl; delete pImpl;
...@@ -577,11 +578,11 @@ IMPL_LINK_NOARG(SpellDialog, ChangeAllHdl) ...@@ -577,11 +578,11 @@ IMPL_LINK_NOARG(SpellDialog, ChangeAllHdl)
OUString aOldWord( m_pSentenceED->GetErrorText() ); OUString aOldWord( m_pSentenceED->GetErrorText() );
SvxPrepareAutoCorrect( aOldWord, aString ); SvxPrepareAutoCorrect( aOldWord, aString );
Reference<XDictionary> aXDictionary( SvxGetChangeAllList(), UNO_QUERY ); Reference<XDictionary> aXDictionary( SvxGetChangeAllList(), UNO_QUERY );
sal_uInt8 nAdded = linguistic::AddEntryToDic( aXDictionary, DictionaryError nAdded = AddEntryToDic( aXDictionary,
aOldWord, true, aOldWord, true,
aString, eLang ); aString, eLang );
if(nAdded == DIC_ERR_NONE) if(nAdded == DictionaryError::NONE)
{ {
SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink);
...@@ -626,10 +627,10 @@ IMPL_LINK( SpellDialog, IgnoreAllHdl, Button *, pButton ) ...@@ -626,10 +627,10 @@ IMPL_LINK( SpellDialog, IgnoreAllHdl, Button *, pButton )
else else
{ {
OUString sErrorText(m_pSentenceED->GetErrorText()); OUString sErrorText(m_pSentenceED->GetErrorText());
sal_uInt8 nAdded = linguistic::AddEntryToDic( aXDictionary, DictionaryError nAdded = AddEntryToDic( aXDictionary,
sErrorText, false, sErrorText, false,
OUString(), LANGUAGE_NONE ); OUString(), LANGUAGE_NONE );
if(nAdded == DIC_ERR_NONE) if(nAdded == DictionaryError::NONE)
{ {
SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink);
...@@ -910,16 +911,16 @@ int SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu *pMenu ) ...@@ -910,16 +911,16 @@ int SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu *pMenu )
if (xDicList.is()) if (xDicList.is())
xDic = xDicList->getDictionaryByName( aDicName ); xDic = xDicList->getDictionaryByName( aDicName );
sal_Int16 nAddRes = DIC_ERR_UNKNOWN; DictionaryError nAddRes = DictionaryError::UNKNOWN;
if (xDic.is()) 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 // save modified user-dictionary if it is persistent
uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
if (xSavDic.is()) if (xSavDic.is())
xSavDic->store(); xSavDic->store();
if (nAddRes == DIC_ERR_NONE) if (nAddRes == DictionaryError::NONE)
{ {
SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl( SpellUndoAction_Impl* pAction = new SpellUndoAction_Impl(
SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink); SPELLUNDO_CHANGE_ADD_TO_DICTIONARY, aDialogUndoLink);
...@@ -928,10 +929,10 @@ int SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu *pMenu ) ...@@ -928,10 +929,10 @@ int SpellDialog::AddToDictionaryExecute( sal_uInt16 nItemId, PopupMenu *pMenu )
m_pSentenceED->AddUndoAction( pAction ); m_pSentenceED->AddUndoAction( pAction );
} }
// failed because there is already an entry? // failed because there is already an entry?
if (DIC_ERR_NONE != nAddRes && xDic->getEntry( aNewWord ).is()) if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is())
nAddRes = DIC_ERR_NONE; nAddRes = DictionaryError::NONE;
} }
if (DIC_ERR_NONE != nAddRes) if (DictionaryError::NONE != nAddRes)
{ {
SvxDicError( this, nAddRes ); SvxDicError( this, nAddRes );
return 0; // don't continue return 0; // don't continue
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::linguistic2; using namespace ::com::sun::star::linguistic2;
using namespace linguistic;
// static ---------------------------------------------------------------- // static ----------------------------------------------------------------
...@@ -597,7 +598,7 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn) ...@@ -597,7 +598,7 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn)
OUString sEntry(aNewWord); OUString sEntry(aNewWord);
OUString aReplaceStr(pReplaceED->GetText()); OUString aReplaceStr(pReplaceED->GetText());
sal_Int16 nAddRes = DIC_ERR_UNKNOWN; DictionaryError nAddRes = DictionaryError::UNKNOWN;
sal_Int32 nPos = pAllDictsLB->GetSelectEntryPos(); sal_Int32 nPos = pAllDictsLB->GetSelectEntryPos();
if ( nPos != LISTBOX_ENTRY_NOTFOUND && !aNewWord.isEmpty()) if ( nPos != LISTBOX_ENTRY_NOTFOUND && !aNewWord.isEmpty())
{ {
...@@ -624,10 +625,10 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn) ...@@ -624,10 +625,10 @@ IMPL_LINK(SvxEditDictionaryDialog, NewDelHdl, PushButton*, pBtn)
aRplcText, LanguageTag( xDic->getLocale() ).getLanguageType(), false ); aRplcText, LanguageTag( xDic->getLocale() ).getLanguageType(), false );
} }
} }
if (DIC_ERR_NONE != nAddRes) if (DictionaryError::NONE != nAddRes)
SvxDicError( this, nAddRes ); SvxDicError( this, nAddRes );
if(DIC_ERR_NONE == nAddRes && !sEntry.isEmpty()) if(DictionaryError::NONE == nAddRes && !sEntry.isEmpty())
{ {
// insert new entry in list-box etc... // insert new entry in list-box etc...
......
...@@ -822,16 +822,16 @@ SvxDicListChgClamp::~SvxDicListChgClamp() ...@@ -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; short nRes = 0;
if (DIC_ERR_NONE != nError) if (linguistic::DictionaryError::NONE != nError)
{ {
int nRid; int nRid;
switch (nError) switch (nError)
{ {
case DIC_ERR_FULL : nRid = RID_SVXSTR_DIC_ERR_FULL; break; case linguistic::DictionaryError::FULL : nRid = RID_SVXSTR_DIC_ERR_FULL; break;
case DIC_ERR_READONLY : nRid = RID_SVXSTR_DIC_ERR_READONLY; break; case linguistic::DictionaryError::READONLY : nRid = RID_SVXSTR_DIC_ERR_READONLY; break;
default: default:
nRid = RID_SVXSTR_DIC_ERR_UNKNOWN; nRid = RID_SVXSTR_DIC_ERR_UNKNOWN;
SAL_WARN("editeng", "unexpected case"); SAL_WARN("editeng", "unexpected case");
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
class LinguMgrExitLstnr; class LinguMgrExitLstnr;
namespace vcl { class Window; } namespace vcl { class Window; }
namespace linguistic { enum class DictionaryError; }
...@@ -181,7 +182,7 @@ EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference< ...@@ -181,7 +182,7 @@ EDITENG_DLLPUBLIC ::com::sun::star::uno::Reference<
// misc functions // misc functions
EDITENG_DLLPUBLIC short SvxDicError( vcl::Window *pParent, sal_Int16 nError ); EDITENG_DLLPUBLIC short SvxDicError( vcl::Window *pParent, linguistic::DictionaryError nError );
#endif #endif
......
...@@ -63,11 +63,10 @@ namespace linguistic ...@@ -63,11 +63,10 @@ namespace linguistic
// AddEntryToDic return values // AddEntryToDic return values
#define DIC_ERR_NONE 0 enum class DictionaryError
#define DIC_ERR_FULL 1 {
#define DIC_ERR_READONLY 2 NONE, FULL, READONLY, UNKNOWN, NOT_EXISTS
#define DIC_ERR_UNKNOWN 3 };
#define DIC_ERR_NOT_EXISTS 4
// values asigned to capitalization types // values asigned to capitalization types
enum CapType enum CapType
...@@ -166,7 +165,7 @@ bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rPrope ...@@ -166,7 +165,7 @@ bool IsIgnoreControlChars( const ::com::sun::star::beans::PropertyValues &rPrope
const OUString& rWord, sal_Int16 nLanguage, const OUString& rWord, sal_Int16 nLanguage,
bool bSearchPosDics, bool bSearchSpellEntry ); bool bSearchPosDics, bool bSearchSpellEntry );
LNG_DLLPUBLIC sal_uInt8 AddEntryToDic( LNG_DLLPUBLIC DictionaryError AddEntryToDic(
::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > &rxDic, ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XDictionary > &rxDic,
const OUString &rWord, bool bIsNeg, const OUString &rWord, bool bIsNeg,
const OUString &rRplcTxt, sal_Int16 nRplcLang, const OUString &rRplcTxt, sal_Int16 nRplcLang,
......
...@@ -350,14 +350,14 @@ bool SaveDictionaries( const uno::Reference< XSearchableDictionaryList > &xDicLi ...@@ -350,14 +350,14 @@ bool SaveDictionaries( const uno::Reference< XSearchableDictionaryList > &xDicLi
return bRet; return bRet;
} }
sal_uInt8 AddEntryToDic( DictionaryError AddEntryToDic(
uno::Reference< XDictionary > &rxDic, uno::Reference< XDictionary > &rxDic,
const OUString &rWord, bool bIsNeg, const OUString &rWord, bool bIsNeg,
const OUString &rRplcTxt, sal_Int16 /* nRplcLang */, const OUString &rRplcTxt, sal_Int16 /* nRplcLang */,
bool bStripDot ) bool bStripDot )
{ {
if (!rxDic.is()) if (!rxDic.is())
return DIC_ERR_NOT_EXISTS; return DictionaryError::NOT_EXISTS;
OUString aTmp( rWord ); OUString aTmp( rWord );
if (bStripDot) if (bStripDot)
...@@ -372,18 +372,18 @@ sal_uInt8 AddEntryToDic( ...@@ -372,18 +372,18 @@ sal_uInt8 AddEntryToDic(
} }
bool bAddOk = rxDic->add( aTmp, bIsNeg, rRplcTxt ); bool bAddOk = rxDic->add( aTmp, bIsNeg, rRplcTxt );
sal_uInt8 nRes = DIC_ERR_NONE; DictionaryError nRes = DictionaryError::NONE;
if (!bAddOk) if (!bAddOk)
{ {
if (rxDic->isFull()) if (rxDic->isFull())
nRes = DIC_ERR_FULL; nRes = DictionaryError::FULL;
else else
{ {
uno::Reference< frame::XStorable > xStor( rxDic, UNO_QUERY ); uno::Reference< frame::XStorable > xStor( rxDic, UNO_QUERY );
if (xStor.is() && xStor->isReadonly()) if (xStor.is() && xStor->isReadonly())
nRes = DIC_ERR_READONLY; nRes = DictionaryError::READONLY;
else else
nRes = DIC_ERR_UNKNOWN; nRes = DictionaryError::UNKNOWN;
} }
} }
......
...@@ -749,9 +749,9 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) ...@@ -749,9 +749,9 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
} }
} else { } else {
OUString sWord(m_xSpellAlt->getWord()); OUString sWord(m_xSpellAlt->getWord());
sal_Int16 nAddRes = linguistic::AddEntryToDic( xDictionary, linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic( xDictionary,
sWord, false, OUString(), LANGUAGE_NONE ); 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); SvxDicError(&m_pSh->GetView().GetViewFrame()->GetWindow(), nAddRes);
} }
...@@ -777,13 +777,13 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) ...@@ -777,13 +777,13 @@ void SwSpellPopup::Execute( sal_uInt16 nId )
if (xDic.is()) 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 // save modified user-dictionary if it is persistent
uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
if (xSavDic.is()) if (xSavDic.is())
xSavDic->store(); 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); SvxDicError(&m_pSh->GetView().GetViewFrame()->GetWindow(), nAddRes);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment