Hi
Convert tools/table.hxx usage in
editeng/inc/editeng/forbiddencharacterstable.hxx to boost::ptr_map
Contributed under LGPLv3+ / MPL 1.1 or later.
(And my license statement is on file in the wiki)
Regards, Noel Grandin
Disclaimer: http://www.peralex.com/disclaimer.html
diff --git a/editeng/inc/editeng/forbiddencharacterstable.hxx
b/editeng/inc/editeng/forbiddencharacterstable.hxx
index 5d499e8..c571e22 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 "boost/ptr_container/ptr_map.hpp"
namespace com {
namespace sun {
@@ -49,17 +48,21 @@ struct ForbiddenCharactersInfo
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 boost::ptr_map<sal_uInt16, ForbiddenCharactersInfo> CharInfoMap;
private:
+ mutable CharInfoMap maCharInfoMap;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+ ForbiddenCharactersInfo* GetCharInfo( sal_uInt16 nLanguage );
+
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() {}
+ inline CharInfoMap& Map() { return maCharInfoMap; }
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 );
diff --git a/editeng/source/misc/forbiddencharacterstable.cxx
b/editeng/source/misc/forbiddencharacterstable.cxx
index deb8d4d..4f7f7c9 100644
--- a/editeng/source/misc/forbiddencharacterstable.cxx
+++ b/editeng/source/misc/forbiddencharacterstable.cxx
@@ -34,30 +34,20 @@
#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 );
+ ForbiddenCharactersInfo* pInf = NULL;
+ if ( maCharInfoMap.find( nLanguage ) != maCharInfoMap.end() )
+ pInf = &maCharInfoMap[ nLanguage ];
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 = new ForbiddenCharactersInfo;
+ maCharInfoMap.insert( nLanguage, pInf );
pInf->bTemporary = sal_True;
LocaleDataWrapper aWrapper( mxMSF, SvxCreateLocale( nLanguage ) );
@@ -70,11 +60,11 @@ const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::Ge
void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage, const
com::sun::star::i18n::ForbiddenCharacters& rForbiddenChars )
{
- ForbiddenCharactersInfo* pInf = Get( nLanguage );
+ ForbiddenCharactersInfo* pInf = GetCharInfo( nLanguage );
if ( !pInf )
{
pInf = new ForbiddenCharactersInfo;
- Insert( nLanguage, pInf );
+ maCharInfoMap.insert( nLanguage, pInf );
}
pInf->bTemporary = sal_False;
pInf->aForbiddenChars = rForbiddenChars;
@@ -82,12 +72,20 @@ void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage,
void SvxForbiddenCharactersTable::ClearForbiddenCharacters( sal_uInt16 nLanguage )
{
- ForbiddenCharactersInfo* pInf = Get( nLanguage );
+ ForbiddenCharactersInfo* pInf = GetCharInfo( nLanguage );
if ( pInf )
{
- Remove( nLanguage );
- delete pInf;
+ maCharInfoMap.erase( nLanguage );
}
}
+ForbiddenCharactersInfo* SvxForbiddenCharactersTable::GetCharInfo( sal_uInt16 nLanguage )
+{
+ CharInfoMap::const_iterator it = maCharInfoMap.find( nLanguage );
+ if ( it == maCharInfoMap.end() )
+ return NULL;
+ return &maCharInfoMap[ nLanguage ];
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/uno/UnoForbiddenCharsTable.cxx
b/editeng/source/uno/UnoForbiddenCharsTable.cxx
index 5bcbf35..0b228da 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) );
}
}
Context
- [PATCH] convert table.hxx use in editeng/inc/editeng/forbiddencharacterstable.hxx · Noel Grandin
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.