[Libreoffice-commits] core.git: 4 commits - cui/source editeng/source include/editeng include/linguistic include/vbahelper lingucomponent/source linguistic/source sw/source vbahelper/source
Noel Grandin
noel at peralex.com
Wed Apr 8 02:40:45 PDT 2015
cui/source/dialogs/SpellDialog.cxx | 23 ++++-----
cui/source/options/optdict.cxx | 7 +-
editeng/source/misc/unolingu.cxx | 8 +--
include/editeng/unolingu.hxx | 3 -
include/linguistic/misc.hxx | 32 ++++--------
include/vbahelper/vbafontbase.hxx | 46 +++++++++---------
lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx | 6 +-
lingucomponent/source/thesaurus/libnth/nthesimp.cxx | 10 +--
linguistic/source/misc.cxx | 22 ++++----
linguistic/source/misc2.cxx | 29 ++++++++---
linguistic/source/spelldsp.cxx | 12 ++--
sw/source/uibase/lingu/olmenu.cxx | 8 +--
vbahelper/source/vbahelper/vbafontbase.cxx | 1
13 files changed, 109 insertions(+), 98 deletions(-)
New commits:
commit fcaad6576dde81fa9f500138e7c8c0ae2afcac6d
Author: Noel Grandin <noel at peralex.com>
Date: Wed Apr 8 11:39:49 2015 +0200
fix shadow error
introduced by my commit 216fdcbdb4c17f349ffd68abd1f372bea3287fad
"convert RECALCMODE_ constants to scoped enum"
Change-Id: Ie7db053741205faeac70e3d21757774567f43ce0
diff --git a/include/vbahelper/vbafontbase.hxx b/include/vbahelper/vbafontbase.hxx
index 9601f6f..8c759ea 100644
--- a/include/vbahelper/vbafontbase.hxx
+++ b/include/vbahelper/vbafontbase.hxx
@@ -25,29 +25,6 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <vbahelper/vbahelperinterface.hxx>
-// use local constants there is no need to expose these constants
-// externally. Looking at the Format->Character dialog it seem that
-// these may infact be even be calculated. Leave hardcoded for now
-// #FIXEME #TBD investigate the code for dialog mentioned above
-
-// The font baseline is not specified.
-const short NORMAL = 0;
-
-// specifies a superscripted.
-const short SUPERSCRIPT = 33;
-
-// specifies a subscripted.
-const short SUBSCRIPT = -33;
-
-// specifies a hight of superscripted font
- const sal_Int8 SUPERSCRIPTHEIGHT = 58;
-
-// specifies a hight of subscripted font
-const sal_Int8 SUBSCRIPTHEIGHT = 58;
-
-// specifies a hight of normal font
-const short NORMALHEIGHT = 100;
-
typedef InheritedHelperInterfaceImpl1< ov::XFontBase > VbaFontBase_BASE;
class VBAHELPER_DLLPUBLIC VbaFontBase : public VbaFontBase_BASE
@@ -58,6 +35,29 @@ protected:
bool mbFormControl;
public:
+ // use local constants there is no need to expose these constants
+ // externally. Looking at the Format->Character dialog it seem that
+ // these may in fact even be calculated. Leave hardcoded for now
+ // #FIXEME #TBD investigate the code for dialog mentioned above
+
+ // The font baseline is not specified.
+ static const short NORMAL = 0;
+
+ // specifies a superscripted.
+ static const short SUPERSCRIPT = 33;
+
+ // specifies a subscripted.
+ static const short SUBSCRIPT = -33;
+
+ // specifies a hight of superscripted font
+ static const sal_Int8 SUPERSCRIPTHEIGHT = 58;
+
+ // specifies a hight of subscripted font
+ static const sal_Int8 SUBSCRIPTHEIGHT = 58;
+
+ // specifies a hight of normal font
+ static const short NORMALHEIGHT = 100;
+
VbaFontBase(
const css::uno::Reference< ov::XHelperInterface >& xParent,
const css::uno::Reference< css::uno::XComponentContext >& xContext,
diff --git a/vbahelper/source/vbahelper/vbafontbase.cxx b/vbahelper/source/vbahelper/vbafontbase.cxx
index 8b6384d..94ae3be 100644
--- a/vbahelper/source/vbahelper/vbafontbase.cxx
+++ b/vbahelper/source/vbahelper/vbafontbase.cxx
@@ -27,6 +27,7 @@
using namespace ::ooo::vba;
using namespace ::com::sun::star;
+
// form controls use other property name as the remaining OOo API
#define VBAFONTBASE_PROPNAME( ascii_normal, ascii_control ) \
mbFormControl ? OUString( ascii_control ) : OUString( ascii_normal )
commit 79b2059fa8e3c69088532f0ce521a285af5455cf
Author: Noel Grandin <noel at peralex.com>
Date: Wed Apr 8 11:28:10 2015 +0200
convert CapType to scoped enum
Change-Id: I88fa3672a1f933ae818368c9bc400c6a845babb6
diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx
index 2e0b7ff..56e7cb2 100644
--- a/include/linguistic/misc.hxx
+++ b/include/linguistic/misc.hxx
@@ -69,13 +69,13 @@ enum class DictionaryError
};
// values asigned to capitalization types
-enum CapType
+enum class CapType
{
- CAPTYPE_UNKNOWN,
- CAPTYPE_NOCAP,
- CAPTYPE_INITCAP,
- CAPTYPE_ALLCAP,
- CAPTYPE_MIXED
+ UNKNOWN,
+ NOCAP,
+ INITCAP,
+ ALLCAP,
+ MIXED
};
LNG_DLLPUBLIC ::osl::Mutex& GetLinguMutex();
diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
index d561fd0..435e9fb 100644
--- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
@@ -319,7 +319,7 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
if (eEnc == RTL_TEXTENCODING_DONTKNOW)
return NULL;
- sal_uInt16 ct = capitalType(aWord, pCC);
+ CapType ct = capitalType(aWord, pCC);
// first convert any smart quotes or apostrophes to normal ones
OUStringBuffer rBuf(aWord);
@@ -444,12 +444,12 @@ Reference< XHyphenatedWord > SAL_CALL Hyphenator::hyphenate( const OUString& aWo
OUString repHyph;
switch (ct)
{
- case CAPTYPE_ALLCAP:
+ case CapType::ALLCAP:
{
repHyph = makeUpperCase(repHyphlow, pCC);
break;
}
- case CAPTYPE_INITCAP:
+ case CapType::INITCAP:
{
if (nHyphenationPosAlt == -1)
repHyph = makeInitCap(repHyphlow, pCC);
diff --git a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx
index 7ab514c..6eab10c 100644
--- a/lingucomponent/source/thesaurus/libnth/nthesimp.cxx
+++ b/lingucomponent/source/thesaurus/libnth/nthesimp.cxx
@@ -285,7 +285,7 @@ Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL Thes
OUString rTerm(qTerm);
OUString pTerm(qTerm);
- sal_uInt16 ct = CAPTYPE_UNKNOWN;
+ CapType ct = CapType::UNKNOWN;
sal_Int32 stem = 0;
sal_Int32 stem2 = 0;
@@ -424,16 +424,16 @@ Sequence < Reference < ::com::sun::star::linguistic2::XMeaning > > SAL_CALL Thes
}
}
- sal_uInt16 ct1 = capitalType(sTerm, pCC);
- if (CAPTYPE_MIXED == ct1)
+ CapType ct1 = capitalType(sTerm, pCC);
+ if (CapType::MIXED == ct1)
ct = ct1;
OUString cTerm;
switch (ct)
{
- case CAPTYPE_ALLCAP:
+ case CapType::ALLCAP:
cTerm = makeUpperCase(sTerm, pCC);
break;
- case CAPTYPE_INITCAP:
+ case CapType::INITCAP:
cTerm = makeInitCap(sTerm, pCC);
break;
default:
diff --git a/linguistic/source/misc.cxx b/linguistic/source/misc.cxx
index 0903a35..bd1bdc8 100644
--- a/linguistic/source/misc.cxx
+++ b/linguistic/source/misc.cxx
@@ -622,16 +622,16 @@ CapType SAL_CALL capitalType(const OUString& aTerm, CharClass * pCC)
}
if (nc == 0)
- return CAPTYPE_NOCAP;
+ return CapType::NOCAP;
if (nc == tlen)
- return CAPTYPE_ALLCAP;
+ return CapType::ALLCAP;
if ((nc == 1) && (pCC->getCharacterType(aStr,0) &
::com::sun::star::i18n::KCharacterType::UPPER))
- return CAPTYPE_INITCAP;
+ return CapType::INITCAP;
- return CAPTYPE_MIXED;
+ return CapType::MIXED;
}
- return CAPTYPE_UNKNOWN;
+ return CapType::UNKNOWN;
}
OUString ToLower( const OUString &rText, sal_Int16 nLanguage )
diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index c3b3282..89d4190 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -428,8 +428,8 @@ bool SpellCheckerDispatcher::isValid_Impl(
bRes = !xTmp->isNegative();
} else {
setCharClass(LanguageTag(nLanguage));
- sal_uInt16 ct = capitalType(aChkWord, pCharClass);
- if (ct == CAPTYPE_INITCAP || ct == CAPTYPE_ALLCAP) {
+ CapType ct = capitalType(aChkWord, pCharClass);
+ if (ct == CapType::INITCAP || ct == CapType::ALLCAP) {
Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, pCharClass), nLanguage ) );
if (xTmp2.is()) {
bRes = !xTmp2->isNegative();
@@ -672,8 +672,8 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
else
{
setCharClass(LanguageTag(nLanguage));
- sal_uInt16 ct = capitalType(aChkWord, pCharClass);
- if (ct == CAPTYPE_INITCAP || ct == CAPTYPE_ALLCAP)
+ CapType ct = capitalType(aChkWord, pCharClass);
+ if (ct == CapType::INITCAP || ct == CapType::ALLCAP)
{
Reference< XDictionaryEntry > xTmp2( lcl_GetRulingDictionaryEntry( makeLowerCase(aChkWord, pCharClass), nLanguage ) );
if (xTmp2.is())
@@ -691,10 +691,10 @@ Reference< XSpellAlternatives > SpellCheckerDispatcher::spell_Impl(
{
switch ( ct )
{
- case CAPTYPE_INITCAP:
+ case CapType::INITCAP:
aProposalList.Prepend( pCharClass->titlecase(aAddRplcTxt) );
break;
- case CAPTYPE_ALLCAP:
+ case CapType::ALLCAP:
aProposalList.Prepend( pCharClass->uppercase(aAddRplcTxt) );
break;
default:
commit 704edbf7dc844e52404bf52f9d5dc768cfd024d0
Author: Noel Grandin <noel at peralex.com>
Date: Wed Apr 8 11:05:34 2015 +0200
convert DIC_ERR_ constants to scoped enum
Change-Id: I083f1b7f21b18c5067b01c82fa8fec467a3d0c50
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 38bfb82..1aa1613 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 e936a87..f30171a 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 de31456..d3a1072 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 2b35bed..06e8900 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 4c6df31..2e0b7ff 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 db7d030..0903a35 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 9b9b17b..e4edd46 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);
}
commit 6bf94344723146d64092b7beba93fe78e7119029
Author: Noel Grandin <noel at peralex.com>
Date: Wed Apr 8 10:43:11 2015 +0200
convert PATH_FLAG to scoped enum
and move it inside the linguistic module, since it is not used
externally
Change-Id: I5e405bd921c090277e75e3bcff81638af0845ece
diff --git a/include/linguistic/misc.hxx b/include/linguistic/misc.hxx
index 84f4360..4c6df31 100644
--- a/include/linguistic/misc.hxx
+++ b/include/linguistic/misc.hxx
@@ -61,13 +61,6 @@ class LocaleDataWrapper;
namespace linguistic
{
-/// Flags to be used with the multi-path related functions
-/// @see GetDictionaryPaths
-#define PATH_FLAG_INTERNAL 0x01
-#define PATH_FLAG_USER 0x02
-#define PATH_FLAG_WRITABLE 0x04
-#define PATH_FLAG_ALL (PATH_FLAG_INTERNAL | PATH_FLAG_USER | PATH_FLAG_WRITABLE)
-
// AddEntryToDic return values
#define DIC_ERR_NONE 0
@@ -127,7 +120,7 @@ bool FileExists( const OUString &rURL );
OUString GetDictionaryWriteablePath();
-::com::sun::star::uno::Sequence< OUString > GetDictionaryPaths( sal_Int16 nPathFlags = PATH_FLAG_ALL );
+::com::sun::star::uno::Sequence< OUString > GetDictionaryPaths();
/// @returns an URL for a new and writable dictionary rDicName.
/// The URL will point to the path given by 'GetDictionaryWriteablePath'
diff --git a/linguistic/source/misc2.cxx b/linguistic/source/misc2.cxx
index 64fed55..eeee5ca 100644
--- a/linguistic/source/misc2.cxx
+++ b/linguistic/source/misc2.cxx
@@ -31,11 +31,26 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/util/thePathSettings.hpp>
+#include <o3tl/typed_flags_set.hxx>
#include "linguistic/misc.hxx"
using namespace com::sun::star;
+/// Flags to be used with the multi-path related functions
+/// @see GetDictionaryPaths
+enum class DictionaryPathFlags
+{
+ INTERNAL = 0x01,
+ USER = 0x02,
+ WRITABLE = 0x04
+};
+namespace o3tl
+{
+ template<> struct typed_flags<DictionaryPathFlags> : is_typed_flags<DictionaryPathFlags, 0x07> {};
+}
+#define PATH_FLAG_ALL (DictionaryPathFlags::INTERNAL | DictionaryPathFlags::USER | DictionaryPathFlags::WRITABLE)
+
namespace linguistic
{
@@ -61,7 +76,7 @@ bool FileExists( const OUString &rMainURL )
static uno::Sequence< OUString > GetMultiPaths_Impl(
const OUString &rPathPrefix,
- sal_Int16 nPathFlags )
+ DictionaryPathFlags nPathFlags )
{
uno::Sequence< OUString > aRes;
uno::Sequence< OUString > aInternalPaths;
@@ -98,7 +113,7 @@ static uno::Sequence< OUString > GetMultiPaths_Impl(
aRes.realloc( nMaxEntries );
OUString *pRes = aRes.getArray();
sal_Int32 nCount = 0; // number of actually added entries
- if ((nPathFlags & PATH_FLAG_WRITABLE) && !aWritablePath.isEmpty())
+ if ((nPathFlags & DictionaryPathFlags::WRITABLE) && !aWritablePath.isEmpty())
pRes[ nCount++ ] = aWritablePath;
for (int i = 0; i < 2; ++i)
{
@@ -106,8 +121,8 @@ static uno::Sequence< OUString > GetMultiPaths_Impl(
const OUString *pPathSeq = rPathSeq.getConstArray();
for (sal_Int32 k = 0; k < rPathSeq.getLength(); ++k)
{
- const bool bAddUser = &rPathSeq == &aUserPaths && (nPathFlags & PATH_FLAG_USER);
- const bool bAddInternal = &rPathSeq == &aInternalPaths && (nPathFlags & PATH_FLAG_INTERNAL);
+ const bool bAddUser = &rPathSeq == &aUserPaths && (nPathFlags & DictionaryPathFlags::USER);
+ const bool bAddInternal = &rPathSeq == &aInternalPaths && (nPathFlags & DictionaryPathFlags::INTERNAL);
if ((bAddUser || bAddInternal) && !pPathSeq[k].isEmpty())
pRes[ nCount++ ] = pPathSeq[k];
}
@@ -120,7 +135,7 @@ static uno::Sequence< OUString > GetMultiPaths_Impl(
OUString GetDictionaryWriteablePath()
{
- uno::Sequence< OUString > aPaths( GetMultiPaths_Impl( "Dictionary", PATH_FLAG_WRITABLE ) );
+ uno::Sequence< OUString > aPaths( GetMultiPaths_Impl( "Dictionary", DictionaryPathFlags::WRITABLE ) );
DBG_ASSERT( aPaths.getLength() == 1, "Dictionary_writable path corrupted?" );
OUString aRes;
if (aPaths.getLength() > 0)
@@ -128,9 +143,9 @@ OUString GetDictionaryWriteablePath()
return aRes;
}
-uno::Sequence< OUString > GetDictionaryPaths( sal_Int16 nPathFlags )
+uno::Sequence< OUString > GetDictionaryPaths()
{
- return GetMultiPaths_Impl( "Dictionary", nPathFlags );
+ return GetMultiPaths_Impl( "Dictionary", PATH_FLAG_ALL );
}
OUString GetWritableDictionaryURL( const OUString &rDicName )
More information about the Libreoffice-commits
mailing list