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;
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
......
......@@ -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...
......
......@@ -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");
......
......@@ -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
......
......@@ -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,
......
......@@ -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;
}
}
......
......@@ -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);
}
......
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