Re: [PATCH] convert table.hxx use in editeng/inc/editeng/forbiddencharacterstable.hxx

2012-02-15 Thread Noel Grandin

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::mapsal_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::mapsal_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;
-voidSetForbiddenCharacters(  sal_uInt16 nLanuage , const 
com::sun::star::i18n::ForbiddenCharacters );
-voidClearForbiddenCharacters( sal_uInt16 nLanuage );
+inline CharInfoMap Map() { return maCharInfoMap; }
+const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( 
sal_uInt16 nLanguage, sal_Bool bGetDefault ) const;
+voidSetForbiddenCharacters(  sal_uInt16 nLanguage , const 
com::sun::star::i18n::ForbiddenCharacters );
+voidClearForbiddenCharacters( 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_castconst 
SvxForbiddenCharactersTableImpl*(this);
-SvxForbiddenCharactersTableImpl* pImpl = 

Re: [PATCH] convert table.hxx use in editeng/inc/editeng/forbiddencharacterstable.hxx

2012-02-12 Thread Ivan Timofeev

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::mapsal_uInt16, 
ForbiddenCharacters. What do you think?


Best Regards,
Ivan
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: [PATCH] convert table.hxx use in editeng/inc/editeng/forbiddencharacterstable.hxx

2012-02-12 Thread Noel Grandin
Sure, sounds like a good idea, Will do.

-- Noel grandin

On Sun, Feb 12, 2012 at 12:08, Ivan Timofeev timofeev@gmail.com 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::mapsal_uInt16, ForbiddenCharacters. What do you think?

 Best Regards,
 Ivan
 ___
 LibreOffice mailing list
 LibreOffice@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/libreoffice
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice