summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-11-22 13:23:44 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-11-22 13:28:52 -0500
commit3980fc115d4c816c3dca449752a151f7b1effea4 (patch)
treeb7aa8635219706fe0608c639a4adf499ca61b4df
parent05e01bad5d5387ec551dd8ef50be7197df518504 (diff)
Apply pimpl to SvxAutocorrWordList.
And remove <set> and <boost/unordered_map.hpp> header includes from its public header. Change-Id: I7e748009f718f4195bec2348383df07dc67600cd
-rw-r--r--editeng/source/misc/svxacorr.cxx75
-rw-r--r--include/editeng/svxacorr.hxx13
2 files changed, 51 insertions, 37 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 0f4d2574d67d..931c42a0c5b9 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2691,34 +2691,55 @@ bool CompareSvxAutocorrWordList::operator()( SvxAutocorrWord* const& lhs, SvxAut
return rCmp.compareString( lhs->GetShort(), rhs->GetShort() ) < 0;
}
-SvxAutocorrWordList::SvxAutocorrWordList() {}
+namespace {
+
+typedef std::set<SvxAutocorrWord*, CompareSvxAutocorrWordList> AutocorrWordSetType;
+typedef boost::unordered_map<OUString, SvxAutocorrWord*, OUStringHash> AutocorrWordHashType;
+
+}
+
+struct SvxAutocorrWordList::Impl
+{
+
+ // only one of these contains the data
+ mutable AutocorrWordSetType maSet;
+ mutable AutocorrWordHashType maHash; // key is 'Short'
+
+ void DeleteAndDestroyAll()
+ {
+ for (AutocorrWordHashType::const_iterator it = maHash.begin(); it != maHash.end(); ++it)
+ delete it->second;
+ maHash.clear();
+
+ for (AutocorrWordSetType::const_iterator it2 = maSet.begin(); it2 != maSet.end(); ++it2)
+ delete *it2;
+ maSet.clear();
+ }
+};
+
+SvxAutocorrWordList::SvxAutocorrWordList() : mpImpl(new Impl) {}
SvxAutocorrWordList::~SvxAutocorrWordList()
{
- DeleteAndDestroyAll();
+ mpImpl->DeleteAndDestroyAll();
+ delete mpImpl;
}
void SvxAutocorrWordList::DeleteAndDestroyAll()
{
- for( SvxAutocorrWordList_Hash::const_iterator it = maHash.begin(); it != maHash.end(); ++it )
- delete it->second;
- maHash.clear();
-
- for( SvxAutocorrWordList_Set::const_iterator it2 = maSet.begin(); it2 != maSet.end(); ++it2 )
- delete *it2;
- maSet.clear();
+ mpImpl->DeleteAndDestroyAll();
}
// returns true if inserted
bool SvxAutocorrWordList::Insert(SvxAutocorrWord *pWord) const
{
- if ( maSet.empty() ) // use the hash
+ if ( mpImpl->maSet.empty() ) // use the hash
{
OUString aShort( pWord->GetShort() );
- return maHash.insert( std::pair<OUString, SvxAutocorrWord *>( aShort, pWord ) ).second;
+ return mpImpl->maHash.insert( std::pair<OUString, SvxAutocorrWord *>( aShort, pWord ) ).second;
}
else
- return maSet.insert( pWord ).second;
+ return mpImpl->maSet.insert( pWord ).second;
}
void SvxAutocorrWordList::LoadEntry(const OUString& sWrong, const OUString& sRight, bool bOnlyTxt)
@@ -2730,29 +2751,29 @@ void SvxAutocorrWordList::LoadEntry(const OUString& sWrong, const OUString& sRig
bool SvxAutocorrWordList::empty() const
{
- return maHash.empty() && maSet.empty();
+ return mpImpl->maHash.empty() && mpImpl->maSet.empty();
}
SvxAutocorrWord *SvxAutocorrWordList::FindAndRemove(SvxAutocorrWord *pWord)
{
SvxAutocorrWord *pMatch = NULL;
- if ( maSet.empty() ) // use the hash
+ if ( mpImpl->maSet.empty() ) // use the hash
{
- SvxAutocorrWordList_Hash::iterator it = maHash.find( pWord->GetShort() );
- if( it != maHash.end() )
+ AutocorrWordHashType::iterator it = mpImpl->maHash.find( pWord->GetShort() );
+ if( it != mpImpl->maHash.end() )
{
pMatch = it->second;
- maHash.erase (it);
+ mpImpl->maHash.erase (it);
}
}
else
{
- SvxAutocorrWordList_Set::iterator it = maSet.find( pWord );
- if( it != maSet.end() )
+ AutocorrWordSetType::iterator it = mpImpl->maSet.find( pWord );
+ if( it != mpImpl->maSet.end() )
{
pMatch = *it;
- maSet.erase (it);
+ mpImpl->maSet.erase (it);
}
}
return pMatch;
@@ -2764,14 +2785,14 @@ SvxAutocorrWordList::Content SvxAutocorrWordList::getSortedContent() const
Content aContent;
// convert from hash to set permanantly
- if ( maSet.empty() )
+ if ( mpImpl->maSet.empty() )
{
// This beasty has some O(N log(N)) in a terribly slow ICU collate fn.
- for( SvxAutocorrWordList_Hash::const_iterator it = maHash.begin(); it != maHash.end(); ++it )
- maSet.insert( it->second );
- maHash.clear();
+ for (AutocorrWordHashType::const_iterator it = mpImpl->maHash.begin(); it != mpImpl->maHash.end(); ++it)
+ mpImpl->maSet.insert( it->second );
+ mpImpl->maHash.clear();
}
- for( SvxAutocorrWordList_Set::const_iterator it = maSet.begin(); it != maSet.end(); ++it )
+ for (AutocorrWordSetType::const_iterator it = mpImpl->maSet.begin(); it != mpImpl->maSet.end(); ++it)
aContent.push_back( *it );
return aContent;
@@ -2888,13 +2909,13 @@ const SvxAutocorrWord* SvxAutocorrWordList::WordMatches(const SvxAutocorrWord *p
const SvxAutocorrWord* SvxAutocorrWordList::SearchWordsInList(const OUString& rTxt, sal_Int32& rStt,
sal_Int32 nEndPos) const
{
- for( SvxAutocorrWordList_Hash::const_iterator it = maHash.begin(); it != maHash.end(); ++it )
+ for (AutocorrWordHashType::const_iterator it = mpImpl->maHash.begin(); it != mpImpl->maHash.end(); ++it)
{
if( const SvxAutocorrWord *aTmp = WordMatches( it->second, rTxt, rStt, nEndPos ) )
return aTmp;
}
- for( SvxAutocorrWordList_Set::const_iterator it2 = maSet.begin(); it2 != maSet.end(); ++it2 )
+ for (AutocorrWordSetType::const_iterator it2 = mpImpl->maSet.begin(); it2 != mpImpl->maSet.end(); ++it2)
{
if( const SvxAutocorrWord *aTmp = WordMatches( *it2, rTxt, rStt, nEndPos ) )
return aTmp;
diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx
index 7e7886cc58d1..9e5f5da0f4b0 100644
--- a/include/editeng/svxacorr.hxx
+++ b/include/editeng/svxacorr.hxx
@@ -32,8 +32,6 @@
#include <editeng/editengdllapi.h>
#include <map>
-#include <set>
-#include <boost/unordered_map.hpp>
#include <boost/ptr_container/ptr_map.hpp>
class CharClass;
@@ -137,19 +135,14 @@ struct CompareSvxAutocorrWordList
bool operator()( SvxAutocorrWord* const& lhs, SvxAutocorrWord* const& rhs ) const;
};
-typedef std::set<SvxAutocorrWord*, CompareSvxAutocorrWordList> SvxAutocorrWordList_Set;
-typedef ::boost::unordered_map< OUString, SvxAutocorrWord *,
- OUStringHash > SvxAutocorrWordList_Hash;
-
class EDITENG_DLLPUBLIC SvxAutocorrWordList
{
+ struct Impl;
+ Impl* mpImpl;
+
SvxAutocorrWordList( const SvxAutocorrWordList& ); // disabled
const SvxAutocorrWordList& operator= ( const SvxAutocorrWordList& ); // disabled
- // only one of these contains the data
- mutable SvxAutocorrWordList_Set maSet;
- mutable SvxAutocorrWordList_Hash maHash; // key is 'Short'
-
const SvxAutocorrWord* WordMatches(const SvxAutocorrWord *pFnd,
const OUString &rTxt,
sal_Int32 &rStt,