Hi
Updated patch implementing Ivan's suggestion. Passes make and make check.
Convert tools/table.hxx usage in  
editeng/inc/editeng/forbiddencharacterstable.hxx to std::map
Contributed under LGPLv3+ / MPL 1.1 or later.
(And my license statement is on file in the wiki)
Regards, Noel.
On 2012-02-12 12:08, Ivan Timofeev wrote:
Hi Noel,
On 10.02.2012 10:56, Noel Grandin wrote:
Convert tools/table.hxx usage in
editeng/inc/editeng/forbiddencharacterstable.hxx to boost::ptr_map
ForbiddenCharactersInfo is simple wrapper for ForbiddenCharacters. It 
only adds the bTemporary flag. But bTemporary seems to be write-only, 
i.e unused. So, I'd suggest to remove bTemporary & 
ForbiddenCharactersInfo, and then convert to std::map<sal_uInt16, 
ForbiddenCharacters>. What do you think?
Best Regards,
Ivan
Disclaimer: http://www.peralex.com/disclaimer.html
diff --git a/editeng/inc/editeng/forbiddencharacterstable.hxx 
b/editeng/inc/editeng/forbiddencharacterstable.hxx
index 5d499e8..3b73eb3 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,24 @@ 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;
 
+    com::sun::star::i18n::ForbiddenCharacters* 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() {}
 
-    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..30aed79 100644
--- a/editeng/source/misc/forbiddencharacterstable.cxx
+++ b/editeng/source/misc/forbiddencharacterstable.cxx
@@ -34,60 +34,45 @@
 
 #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 );
 }
 
+com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetCharInfo( sal_uInt16 
nLanguage )
+{
+    CharInfoMap::iterator it = maCharInfoMap.find( nLanguage );
+    if ( it == maCharInfoMap.end() )
+        return NULL;
+    return &(it->second);
+}
+
+
 /* 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
   
 
  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.