[Libreoffice-commits] .: 2 commits - editeng/inc editeng/source
Ivan Timofeev
ivantimofeev at kemper.freedesktop.org
Wed Feb 15 09:41:18 PST 2012
editeng/inc/editeng/forbiddencharacterstable.hxx | 27 +++++-------
editeng/source/misc/forbiddencharacterstable.cxx | 50 +++++------------------
editeng/source/uno/UnoForbiddenCharsTable.cxx | 7 +--
3 files changed, 27 insertions(+), 57 deletions(-)
New commits:
commit 843eafc765a3d1d0ea4c9a89855c73e81784aa8b
Author: Ivan Timofeev <timofeev.i.s at gmail.com>
Date: Wed Feb 15 20:44:26 2012 +0400
tweak "Convert tools/table.hxx in editeng/forbiddencharacterstable.hxx..."
* remove 'const' from GetForbiddenCharacters
* CharInfoMap -> Map
* pInf -> pForbiddenCharacters
* remove 'inline' from the function defined within the class definition
* some code simplifications
diff --git a/editeng/inc/editeng/forbiddencharacterstable.hxx b/editeng/inc/editeng/forbiddencharacterstable.hxx
index afe6d5b..55db6db 100644
--- a/editeng/inc/editeng/forbiddencharacterstable.hxx
+++ b/editeng/inc/editeng/forbiddencharacterstable.hxx
@@ -45,17 +45,17 @@ namespace lang {
class EDITENG_DLLPUBLIC SvxForbiddenCharactersTable : public salhelper::SimpleReferenceObject
{
public:
- typedef std::map<sal_uInt16, com::sun::star::i18n::ForbiddenCharacters> CharInfoMap;
+ typedef std::map<sal_uInt16, com::sun::star::i18n::ForbiddenCharacters> Map;
private:
- mutable CharInfoMap maCharInfoMap;
+ Map maMap;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
public:
SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF);
~SvxForbiddenCharactersTable() {}
- inline CharInfoMap& Map() { return maCharInfoMap; }
- const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) const;
+ Map& GetMap() { return maMap; }
+ const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault );
void SetForbiddenCharacters( sal_uInt16 nLanguage , const com::sun::star::i18n::ForbiddenCharacters& );
void ClearForbiddenCharacters( sal_uInt16 nLanguage );
};
diff --git a/editeng/source/misc/forbiddencharacterstable.cxx b/editeng/source/misc/forbiddencharacterstable.cxx
index e809282..9760b0f 100644
--- a/editeng/source/misc/forbiddencharacterstable.cxx
+++ b/editeng/source/misc/forbiddencharacterstable.cxx
@@ -39,31 +39,29 @@ SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno:
mxMSF = xMSF;
}
-const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) const
+const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault )
{
- com::sun::star::i18n::ForbiddenCharacters* pInf = NULL;
- CharInfoMap::iterator it = maCharInfoMap.find( nLanguage );
- if ( it != maCharInfoMap.end() )
- pInf = &(it->second);
- if ( !pInf && bGetDefault && mxMSF.is() )
+ com::sun::star::i18n::ForbiddenCharacters* pForbiddenCharacters = NULL;
+ Map::iterator it = maMap.find( nLanguage );
+ if ( it != maMap.end() )
+ pForbiddenCharacters = &(it->second);
+ else if ( bGetDefault && mxMSF.is() )
{
LocaleDataWrapper aWrapper( mxMSF, SvxCreateLocale( nLanguage ) );
- maCharInfoMap[ nLanguage ] = aWrapper.getForbiddenCharacters();
- pInf = &maCharInfoMap[ nLanguage ];
+ maMap[ nLanguage ] = aWrapper.getForbiddenCharacters();
+ pForbiddenCharacters = &maMap[ nLanguage ];
}
- return pInf;
+ return pForbiddenCharacters;
}
void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage, const com::sun::star::i18n::ForbiddenCharacters& rForbiddenChars )
{
- maCharInfoMap[ nLanguage ] = rForbiddenChars;
+ maMap[ nLanguage ] = rForbiddenChars;
}
void SvxForbiddenCharactersTable::ClearForbiddenCharacters( sal_uInt16 nLanguage )
{
- CharInfoMap::iterator it = maCharInfoMap.find( nLanguage );
- if ( it != maCharInfoMap.end() )
- maCharInfoMap.erase( it );
+ maMap.erase( nLanguage );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/uno/UnoForbiddenCharsTable.cxx b/editeng/source/uno/UnoForbiddenCharsTable.cxx
index 5d2c79e..5957520 100644
--- a/editeng/source/uno/UnoForbiddenCharsTable.cxx
+++ b/editeng/source/uno/UnoForbiddenCharsTable.cxx
@@ -117,15 +117,15 @@ Sequence< Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
{
SolarMutexGuard aGuard;
- const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->Map().size() : 0;
+ const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->GetMap().size() : 0;
Sequence< Locale > aLocales( nCount );
if( nCount )
{
Locale* pLocales = aLocales.getArray();
- for( SvxForbiddenCharactersTable::CharInfoMap::iterator it = mxForbiddenChars->Map().begin();
- it != mxForbiddenChars->Map().end(); ++it )
+ for( SvxForbiddenCharactersTable::Map::iterator it = mxForbiddenChars->GetMap().begin();
+ it != mxForbiddenChars->GetMap().end(); ++it )
{
const sal_uLong nLanguage = it->first;
SvxLanguageToLocale ( *pLocales++, static_cast < LanguageType > (nLanguage) );
commit 9d4b0c25a598a53601e2bd337443728f17f8296a
Author: Noel Grandin <noel at peralex.com>
Date: Wed Feb 15 20:06:28 2012 +0400
Convert tools/table.hxx in editeng/forbiddencharacterstable.hxx to std::map
diff --git a/editeng/inc/editeng/forbiddencharacterstable.hxx b/editeng/inc/editeng/forbiddencharacterstable.hxx
index 5d499e8..afe6d5b 100644
--- a/editeng/inc/editeng/forbiddencharacterstable.hxx
+++ b/editeng/inc/editeng/forbiddencharacterstable.hxx
@@ -29,12 +29,11 @@
#ifndef _FORBIDDENCHARACTERSTABLE_HXX
#define _FORBIDDENCHARACTERSTABLE_HXX
-#include <tools/table.hxx>
-
#include <salhelper/simplereferenceobject.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/i18n/ForbiddenCharacters.hpp>
#include "editeng/editengdllapi.h"
+#include <map>
namespace com {
namespace sun {
@@ -43,26 +42,22 @@ namespace lang {
class XMultiServiceFactory;
}}}}
-struct ForbiddenCharactersInfo
-{
- com::sun::star::i18n::ForbiddenCharacters aForbiddenChars;
- sal_Bool bTemporary;
-};
-
-DECLARE_TABLE( SvxForbiddenCharactersTableImpl, ForbiddenCharactersInfo* )
-
-class EDITENG_DLLPUBLIC SvxForbiddenCharactersTable : public SvxForbiddenCharactersTableImpl, public salhelper::SimpleReferenceObject
+class EDITENG_DLLPUBLIC SvxForbiddenCharactersTable : public salhelper::SimpleReferenceObject
{
+public:
+ typedef std::map<sal_uInt16, com::sun::star::i18n::ForbiddenCharacters> CharInfoMap;
private:
+ mutable CharInfoMap maCharInfoMap;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
public:
- SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF, sal_uInt16 nISize = 4, sal_uInt16 nGrow = 4 );
- ~SvxForbiddenCharactersTable();
+ SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF);
+ ~SvxForbiddenCharactersTable() {}
- const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( sal_uInt16 nLanuage, sal_Bool bGetDefault ) const;
- void SetForbiddenCharacters( sal_uInt16 nLanuage , const com::sun::star::i18n::ForbiddenCharacters& );
- void ClearForbiddenCharacters( sal_uInt16 nLanuage );
+ inline CharInfoMap& Map() { return maCharInfoMap; }
+ const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) const;
+ void SetForbiddenCharacters( sal_uInt16 nLanguage , const com::sun::star::i18n::ForbiddenCharacters& );
+ void ClearForbiddenCharacters( sal_uInt16 nLanguage );
};
#endif // _FORBIDDENCHARACTERSTABLE_HXX
diff --git a/editeng/source/misc/forbiddencharacterstable.cxx b/editeng/source/misc/forbiddencharacterstable.cxx
index deb8d4d..e809282 100644
--- a/editeng/source/misc/forbiddencharacterstable.cxx
+++ b/editeng/source/misc/forbiddencharacterstable.cxx
@@ -34,60 +34,36 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF, sal_uInt16 nISize, sal_uInt16 nGrow )
- : SvxForbiddenCharactersTableImpl( nISize, nGrow )
+SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF)
{
mxMSF = xMSF;
}
-
-SvxForbiddenCharactersTable::~SvxForbiddenCharactersTable()
-{
- for ( sal_uLong n = Count(); n; )
- delete GetObject( --n );
-}
-
-
-
const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) const
{
- ForbiddenCharactersInfo* pInf = Get( nLanguage );
+ com::sun::star::i18n::ForbiddenCharacters* pInf = NULL;
+ CharInfoMap::iterator it = maCharInfoMap.find( nLanguage );
+ if ( it != maCharInfoMap.end() )
+ pInf = &(it->second);
if ( !pInf && bGetDefault && mxMSF.is() )
{
- const SvxForbiddenCharactersTableImpl *pConstImpl = dynamic_cast<const SvxForbiddenCharactersTableImpl*>(this);
- SvxForbiddenCharactersTableImpl* pImpl = const_cast<SvxForbiddenCharactersTableImpl*>(pConstImpl);
- pInf = new ForbiddenCharactersInfo;
- pImpl->Insert( nLanguage, pInf );
-
- pInf->bTemporary = sal_True;
LocaleDataWrapper aWrapper( mxMSF, SvxCreateLocale( nLanguage ) );
- pInf->aForbiddenChars = aWrapper.getForbiddenCharacters();
+ maCharInfoMap[ nLanguage ] = aWrapper.getForbiddenCharacters();
+ pInf = &maCharInfoMap[ nLanguage ];
}
- return pInf ? &pInf->aForbiddenChars : NULL;
+ return pInf;
}
-
-
void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage, const com::sun::star::i18n::ForbiddenCharacters& rForbiddenChars )
{
- ForbiddenCharactersInfo* pInf = Get( nLanguage );
- if ( !pInf )
- {
- pInf = new ForbiddenCharactersInfo;
- Insert( nLanguage, pInf );
- }
- pInf->bTemporary = sal_False;
- pInf->aForbiddenChars = rForbiddenChars;
+ maCharInfoMap[ nLanguage ] = rForbiddenChars;
}
void SvxForbiddenCharactersTable::ClearForbiddenCharacters( sal_uInt16 nLanguage )
{
- ForbiddenCharactersInfo* pInf = Get( nLanguage );
- if ( pInf )
- {
- Remove( nLanguage );
- delete pInf;
- }
+ CharInfoMap::iterator it = maCharInfoMap.find( nLanguage );
+ if ( it != maCharInfoMap.end() )
+ maCharInfoMap.erase( it );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/uno/UnoForbiddenCharsTable.cxx b/editeng/source/uno/UnoForbiddenCharsTable.cxx
index 5bcbf35..5d2c79e 100644
--- a/editeng/source/uno/UnoForbiddenCharsTable.cxx
+++ b/editeng/source/uno/UnoForbiddenCharsTable.cxx
@@ -117,16 +117,17 @@ Sequence< Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales()
{
SolarMutexGuard aGuard;
- const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->Count() : 0;
+ const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->Map().size() : 0;
Sequence< Locale > aLocales( nCount );
if( nCount )
{
Locale* pLocales = aLocales.getArray();
- for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ for( SvxForbiddenCharactersTable::CharInfoMap::iterator it = mxForbiddenChars->Map().begin();
+ it != mxForbiddenChars->Map().end(); ++it )
{
- const sal_uLong nLanguage = mxForbiddenChars->GetObjectKey( nIndex );
+ const sal_uLong nLanguage = it->first;
SvxLanguageToLocale ( *pLocales++, static_cast < LanguageType > (nLanguage) );
}
}
More information about the Libreoffice-commits
mailing list