Files
libreoffice/sw/source/core/doc/acmplwrd.cxx

470 lines
15 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 23:08:29 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 23:08:29 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 23:08:29 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 23:08:29 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 23:08:29 +00:00
*
************************************************************************/
2011-11-18 21:03:31 +00:00
#include <comphelper/string.hxx>
#include <tools/urlobj.hxx>
2000-09-18 23:08:29 +00:00
#include <hintids.hxx>
#include <hints.hxx>
#include <unotools/transliterationwrapper.hxx>
2000-09-18 23:08:29 +00:00
#include <acmplwrd.hxx>
#include <doc.hxx>
#include <ndindex.hxx>
#include <docary.hxx>
#include <ndtxt.hxx>
#include <pam.hxx>
#include <pagedesc.hxx>
#include <poolfmt.hxx>
#include <calbck.hxx>
#include <editeng/svxacorr.hxx>
#include <editeng/acorrcfg.hxx>
CWS-TOOLING: integrate CWS os121 2008-11-28 13:44:51 +0100 os r264551 : Copy Hyperlink Location added 2008-11-28 13:36:20 +0100 os r264547 : Copy Hyperlink Location added 2008-11-25 15:43:53 +0100 os r264311 : label of EditHyperlink fixed 2008-11-25 15:42:42 +0100 os r264310 : use ResetAttr to remove hyperlink 2008-11-25 10:08:02 +0100 os r264276 : edit/remove hyperlink names fixed 2008-11-11 15:47:22 +0100 os r263565 : typo fixed 2008-11-10 18:46:00 +0100 os r263536 : CWS-TOOLING: rebase CWS os121 to trunk@263288 (milestone: DEV300:m35) 2008-11-07 15:34:41 +0100 os r263422 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-07 15:34:05 +0100 os r263421 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-06 17:26:18 +0100 os r263402 : #i43971# words from online help documents must not be added to AutoCompletion 2008-11-06 16:08:27 +0100 os r263397 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:49 +0100 os r263396 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:16 +0100 os r263395 : #i6191# accept/reject changes added to context menu 2008-11-06 16:06:18 +0100 os r263394 : #i6191# accept/reject changes added to context menu 2008-10-30 14:31:32 +0100 os r262826 : #i84980# less options changed to fewer options 2008-10-30 11:44:41 +0100 os r262824 : #i95624# don't add paragraph numbering in getString() 2008-10-27 10:46:04 +0100 os r262665 : #i88235# SvCheckListBox::SelectEntryPos() paints a CheckBox to the wrong device if page is not visible, yet - call moved to ::Reset() 2008-10-24 15:49:27 +0200 os r262648 : #i77230# make repeating headers the default 2008-10-23 16:49:42 +0200 os r262625 : #i95350# RTL output of table window fixed 2008-10-23 15:37:40 +0200 os r262623 : #i76723# RTL related patch removed - it is now done by vcl 2008-10-22 14:05:58 +0200 os r262601 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-22 14:05:17 +0200 os r262600 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-20 15:39:18 +0200 os r262323 : #i95059# border attribute: which id of SID_ATTR_BORDER_INNER fixed 2008-10-20 09:30:28 +0200 os r262305 : #i95123# conflict css::util::Color and ::Color solved 2008-10-17 11:44:16 +0200 os r262280 : #i93714# merge to PDF: convert fields to text before export 2008-10-17 10:30:11 +0200 os r262275 : #i94364# 2008-10-17 10:11:56 +0200 os r262274 : +i94536# default font ListBoxes: prevent entry duplication if 'Back' button is pressed
2008-12-09 07:49:49 +00:00
#include <sfx2/docfile.hxx>
#include <docsh.hxx>
#include <vector>
2000-09-18 23:08:29 +00:00
class SwAutoCompleteClient : public SwClient
{
SwAutoCompleteWord* pAutoCompleteWord;
SwDoc* pDoc;
#if OSL_DEBUG_LEVEL > 0
static sal_uLong nSwAutoCompleteClientCount;
#endif
public:
SwAutoCompleteClient(SwAutoCompleteWord& rToTell, SwDoc& rSwDoc);
SwAutoCompleteClient(const SwAutoCompleteClient& rClient);
~SwAutoCompleteClient();
SwAutoCompleteClient& operator=(const SwAutoCompleteClient& rClient);
const SwDoc& GetDoc(){return *pDoc;}
#if OSL_DEBUG_LEVEL > 0
static sal_uLong GetElementCount() {return nSwAutoCompleteClientCount;}
#endif
protected:
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
};
typedef std::vector<SwAutoCompleteClient> SwAutoCompleteClientVector;
class SwAutoCompleteWord_Impl
{
SwAutoCompleteClientVector aClientVector;
SwAutoCompleteWord& rAutoCompleteWord;
public:
SwAutoCompleteWord_Impl(SwAutoCompleteWord& rParent) :
rAutoCompleteWord(rParent){}
void AddDocument(SwDoc& rDoc);
void RemoveDocument(const SwDoc& rDoc);
};
typedef const SwDoc* SwDocPtr;
typedef std::vector<SwDocPtr> SwDocPtrVector;
class SwAutoCompleteString
: public editeng::IAutoCompleteString
{
#if OSL_DEBUG_LEVEL > 0
static sal_uLong nSwAutoCompleteStringCount;
#endif
SwDocPtrVector aSourceDocs;
public:
SwAutoCompleteString(const String& rStr, xub_StrLen nPos, xub_StrLen nLen);
~SwAutoCompleteString();
void AddDocument(const SwDoc& rDoc);
//returns true if last document reference has been removed
bool RemoveDocument(const SwDoc& rDoc);
#if OSL_DEBUG_LEVEL > 0
static sal_uLong GetElementCount() {return nSwAutoCompleteStringCount;}
#endif
};
#if OSL_DEBUG_LEVEL > 0
sal_uLong SwAutoCompleteClient::nSwAutoCompleteClientCount = 0;
sal_uLong SwAutoCompleteString::nSwAutoCompleteStringCount = 0;
#endif
SwAutoCompleteClient::SwAutoCompleteClient(SwAutoCompleteWord& rToTell, SwDoc& rSwDoc) :
pAutoCompleteWord(&rToTell),
pDoc(&rSwDoc)
{
pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
#if OSL_DEBUG_LEVEL > 0
++nSwAutoCompleteClientCount;
#endif
}
SwAutoCompleteClient::SwAutoCompleteClient(const SwAutoCompleteClient& rClient) :
SwClient(),
pAutoCompleteWord(rClient.pAutoCompleteWord),
pDoc(rClient.pDoc)
{
pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
#if OSL_DEBUG_LEVEL > 0
++nSwAutoCompleteClientCount;
#endif
}
SwAutoCompleteClient::~SwAutoCompleteClient()
{
#if OSL_DEBUG_LEVEL > 0
--nSwAutoCompleteClientCount;
#endif
}
SwAutoCompleteClient& SwAutoCompleteClient::operator=(const SwAutoCompleteClient& rClient)
{
pAutoCompleteWord = rClient.pAutoCompleteWord;
pDoc = rClient.pDoc;
if(rClient.GetRegisteredIn())
((SwModify*)rClient.GetRegisteredIn())->Add(this);
else if(GetRegisteredIn())
GetRegisteredInNonConst()->Remove(this);
return *this;
}
void SwAutoCompleteClient::Modify( const SfxPoolItem* pOld, const SfxPoolItem *)
{
switch( pOld ? pOld->Which() : 0 )
{
case RES_REMOVE_UNO_OBJECT:
case RES_OBJECTDYING:
if( (void*)GetRegisteredIn() == ((SwPtrMsgPoolItem *)pOld)->pObject )
((SwModify*)GetRegisteredIn())->Remove(this);
pAutoCompleteWord->DocumentDying(*pDoc);
break;
}
}
void SwAutoCompleteWord_Impl::AddDocument(SwDoc& rDoc)
{
SwAutoCompleteClientVector::iterator aIt;
2010-12-23 15:07:14 +00:00
for(aIt = aClientVector.begin(); aIt != aClientVector.end(); ++aIt)
{
if(&aIt->GetDoc() == &rDoc)
return;
}
aClientVector.push_back(SwAutoCompleteClient(rAutoCompleteWord, rDoc));
}
2000-09-18 23:08:29 +00:00
void SwAutoCompleteWord_Impl::RemoveDocument(const SwDoc& rDoc)
{
SwAutoCompleteClientVector::iterator aIt;
2010-12-23 15:07:14 +00:00
for(aIt = aClientVector.begin(); aIt != aClientVector.end(); ++aIt)
{
if(&aIt->GetDoc() == &rDoc)
{
aClientVector.erase(aIt);
return;
}
}
}
SwAutoCompleteString::SwAutoCompleteString(
const String& rStr, xub_StrLen const nPos, xub_StrLen const nLen)
: editeng::IAutoCompleteString(String(rStr, nPos, nLen))
{
#if OSL_DEBUG_LEVEL > 0
++nSwAutoCompleteStringCount;
#endif
}
SwAutoCompleteString::~SwAutoCompleteString()
{
#if OSL_DEBUG_LEVEL > 0
--nSwAutoCompleteStringCount;
#endif
}
void SwAutoCompleteString::AddDocument(const SwDoc& rDoc)
{
for(SwDocPtrVector::iterator aIt = aSourceDocs.begin(); aIt != aSourceDocs.end(); ++aIt)
{
if( *aIt == &rDoc )
return;
}
aSourceDocs.push_back(&rDoc);
}
bool SwAutoCompleteString::RemoveDocument(const SwDoc& rDoc)
{
for(SwDocPtrVector::iterator aIt = aSourceDocs.begin(); aIt != aSourceDocs.end(); ++aIt)
{
if( *aIt == &rDoc )
{
aSourceDocs.erase(aIt);
return aSourceDocs.empty();
}
}
return false;
}
SwAutoCompleteWord::SwAutoCompleteWord( sal_uInt16 nWords, sal_uInt16 nMWrdLen ) :
pImpl(new SwAutoCompleteWord_Impl(*this)),
2000-09-18 23:08:29 +00:00
nMaxCount( nWords ),
nMinWrdLen( nMWrdLen ),
bLockWordLst( sal_False )
2000-09-18 23:08:29 +00:00
{
m_LookupTree = new LatinLookupTree(OUString("default"));
2000-09-18 23:08:29 +00:00
}
SwAutoCompleteWord::~SwAutoCompleteWord()
{
m_WordList.DeleteAndDestroyAll(); // so the assertion below works
delete m_LookupTree;
delete pImpl;
#if OSL_DEBUG_LEVEL > 0
sal_uLong nStrings = SwAutoCompleteString::GetElementCount();
sal_uLong nClients = SwAutoCompleteClient::GetElementCount();
2011-03-15 13:50:53 +00:00
OSL_ENSURE(!nStrings && !nClients, "AutoComplete: clients or string count mismatch");
#endif
2000-09-18 23:08:29 +00:00
}
bool SwAutoCompleteWord::InsertWord( const String& rWord, SwDoc& rDoc )
2000-09-18 23:08:29 +00:00
{
CWS-TOOLING: integrate CWS os121 2008-11-28 13:44:51 +0100 os r264551 : Copy Hyperlink Location added 2008-11-28 13:36:20 +0100 os r264547 : Copy Hyperlink Location added 2008-11-25 15:43:53 +0100 os r264311 : label of EditHyperlink fixed 2008-11-25 15:42:42 +0100 os r264310 : use ResetAttr to remove hyperlink 2008-11-25 10:08:02 +0100 os r264276 : edit/remove hyperlink names fixed 2008-11-11 15:47:22 +0100 os r263565 : typo fixed 2008-11-10 18:46:00 +0100 os r263536 : CWS-TOOLING: rebase CWS os121 to trunk@263288 (milestone: DEV300:m35) 2008-11-07 15:34:41 +0100 os r263422 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-07 15:34:05 +0100 os r263421 : #i6191# accept/reject changes;#i7311# remove hyperlink 2008-11-06 17:26:18 +0100 os r263402 : #i43971# words from online help documents must not be added to AutoCompletion 2008-11-06 16:08:27 +0100 os r263397 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:49 +0100 os r263396 : #i6191# accept/reject changes added to context menu 2008-11-06 16:07:16 +0100 os r263395 : #i6191# accept/reject changes added to context menu 2008-11-06 16:06:18 +0100 os r263394 : #i6191# accept/reject changes added to context menu 2008-10-30 14:31:32 +0100 os r262826 : #i84980# less options changed to fewer options 2008-10-30 11:44:41 +0100 os r262824 : #i95624# don't add paragraph numbering in getString() 2008-10-27 10:46:04 +0100 os r262665 : #i88235# SvCheckListBox::SelectEntryPos() paints a CheckBox to the wrong device if page is not visible, yet - call moved to ::Reset() 2008-10-24 15:49:27 +0200 os r262648 : #i77230# make repeating headers the default 2008-10-23 16:49:42 +0200 os r262625 : #i95350# RTL output of table window fixed 2008-10-23 15:37:40 +0200 os r262623 : #i76723# RTL related patch removed - it is now done by vcl 2008-10-22 14:05:58 +0200 os r262601 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-22 14:05:17 +0200 os r262600 : #b6297019#,#i49754# LoadStyles: restore outline settings 2008-10-20 15:39:18 +0200 os r262323 : #i95059# border attribute: which id of SID_ATTR_BORDER_INNER fixed 2008-10-20 09:30:28 +0200 os r262305 : #i95123# conflict css::util::Color and ::Color solved 2008-10-17 11:44:16 +0200 os r262280 : #i93714# merge to PDF: convert fields to text before export 2008-10-17 10:30:11 +0200 os r262275 : #i94364# 2008-10-17 10:11:56 +0200 os r262274 : +i94536# default font ListBoxes: prevent entry duplication if 'Back' button is pressed
2008-12-09 07:49:49 +00:00
SwDocShell* pDocShell = rDoc.GetDocShell();
SfxMedium* pMedium = pDocShell ? pDocShell->GetMedium() : 0;
// strings from help module should not be added
if( pMedium )
{
const INetURLObject& rURL = pMedium->GetURLObject();
if ( rURL.GetProtocol() == INET_PROT_VND_SUN_STAR_HELP )
return sal_False;
}
String aNewWord(rWord);
2011-11-18 21:03:31 +00:00
aNewWord = comphelper::string::remove(aNewWord, CH_TXTATR_INWORD);
aNewWord = comphelper::string::remove(aNewWord, CH_TXTATR_BREAKWORD);
pImpl->AddDocument(rDoc);
bool bRet = false;
xub_StrLen nWrdLen = aNewWord.Len();
while( nWrdLen && '.' == aNewWord.GetChar( nWrdLen-1 ))
2000-09-18 23:08:29 +00:00
--nWrdLen;
if( !bLockWordLst && nWrdLen >= nMinWrdLen )
2000-09-18 23:08:29 +00:00
{
SwAutoCompleteString* pNew = new SwAutoCompleteString( aNewWord, 0, nWrdLen );
pNew->AddDocument(rDoc);
std::pair<editeng::SortedAutoCompleteStrings::const_iterator, bool>
aInsPair = m_WordList.insert(pNew);
m_LookupTree->insert( OUString(aNewWord) );
if (aInsPair.second)
2000-09-18 23:08:29 +00:00
{
bRet = true;
if (aLRULst.size() >= nMaxCount)
2000-09-18 23:08:29 +00:00
{
2011-10-28 02:23:02 +02:00
// the last one needs to be removed
// so that there is space for the first one
SwAutoCompleteString* pDel = aLRULst.back();
aLRULst.pop_back();
m_WordList.erase(pDel);
delete pDel;
2000-09-18 23:08:29 +00:00
}
aLRULst.push_front(pNew);
2000-09-18 23:08:29 +00:00
}
else
{
delete pNew;
2011-10-28 02:23:02 +02:00
// then move "up"
pNew = (SwAutoCompleteString*)(*aInsPair.first);
2011-10-28 02:23:02 +02:00
// add the document to the already inserted string
pNew->AddDocument(rDoc);
// move pNew to the front of the LRU list
SwAutoCompleteStringPtrDeque::iterator it = std::find( aLRULst.begin(), aLRULst.end(), pNew );
OSL_ENSURE( aLRULst.end() != it, "String not found" );
if ( aLRULst.begin() != it && aLRULst.end() != it )
2000-09-18 23:08:29 +00:00
{
aLRULst.erase( it );
aLRULst.push_front( pNew );
2000-09-18 23:08:29 +00:00
}
}
}
return bRet;
}
void SwAutoCompleteWord::SetMaxCount( sal_uInt16 nNewMax )
2000-09-18 23:08:29 +00:00
{
if( nNewMax < nMaxCount && aLRULst.size() > nNewMax )
2000-09-18 23:08:29 +00:00
{
2011-10-28 02:23:02 +02:00
// remove the trailing ones
sal_uInt16 nLRUIndex = nNewMax-1;
while (nNewMax < m_WordList.size() && nLRUIndex < aLRULst.size())
2000-09-18 23:08:29 +00:00
{
editeng::SortedAutoCompleteStrings::const_iterator it =
m_WordList.find(aLRULst[ nLRUIndex++ ]);
OSL_ENSURE( m_WordList.end() != it, "String not found" );
editeng::IAutoCompleteString *const pDel = *it;
m_WordList.erase(it - m_WordList.begin());
delete pDel;
2000-09-18 23:08:29 +00:00
}
aLRULst.erase( aLRULst.begin() + nNewMax - 1, aLRULst.end() );
2000-09-18 23:08:29 +00:00
}
nMaxCount = nNewMax;
}
void SwAutoCompleteWord::SetMinWordLen( sal_uInt16 n )
2000-09-18 23:08:29 +00:00
{
2011-10-28 02:23:02 +02:00
// Do you really want to remove all words that are less than the minWrdLen?
2000-09-18 23:08:29 +00:00
if( n < nMinWrdLen )
{
for (size_t nPos = 0; nPos < m_WordList.size(); ++nPos)
if (m_WordList[ nPos ]->GetAutoCompleteString().Len() < n)
2000-09-18 23:08:29 +00:00
{
SwAutoCompleteString *const pDel =
dynamic_cast<SwAutoCompleteString*>(m_WordList[nPos]);
m_WordList.erase(nPos);
2000-09-18 23:08:29 +00:00
SwAutoCompleteStringPtrDeque::iterator it = std::find( aLRULst.begin(), aLRULst.end(), pDel );
OSL_ENSURE( aLRULst.end() != it, "String not found" );
aLRULst.erase( it );
2000-09-18 23:08:29 +00:00
--nPos;
delete pDel;
2000-09-18 23:08:29 +00:00
}
}
nMinWrdLen = n;
}
// Resets the current position within the tree to its root node.
void SwAutoCompleteWord::returnToRoot()
2000-09-18 23:08:29 +00:00
{
m_LookupTree->returnToRoot();
}
// Advances to a given node within the AutoComplete tree.
void SwAutoCompleteWord::gotoNode(OUString sNode)
{
m_LookupTree->gotoNode( sNode );
}
// Advances from the current position towards the node keyed with cKey.
void SwAutoCompleteWord::advance(const sal_Unicode cKey)
{
m_LookupTree->advance( cKey );
}
// Goes back one char within the tree, except if the current node is already the root node.
void SwAutoCompleteWord::goBack()
{
m_LookupTree->goBack();
}
// Returns all words matching a given prefix aMatch. If bIgnoreCurrentPos is set, the current
// position within the tree is ignored and replaced by aMatch.
bool SwAutoCompleteWord::GetWordsMatching(String aMatch, std::vector<String>& aWords, bool bIgnoreCurrentPos) const
{
OUString aStringRoot = OUString( aMatch );
// The lookup tree already contains the information about the root keyword in most cases. Only if we don't trust that
// information (e.g. if we need some autocompletion for a place other than the main writing area), the location within
// the tree needs to be refreshed.
if (bIgnoreCurrentPos)
{
m_LookupTree->gotoNode( aStringRoot );
}
OUString aAutocompleteWord = m_LookupTree->suggestAutoCompletion();
if (aAutocompleteWord.isEmpty())
{
return false;
}
OUString aCompleteWord = aStringRoot + aAutocompleteWord;
aWords.push_back( String(aCompleteWord) );
return true;
2000-09-18 23:08:29 +00:00
}
void SwAutoCompleteWord::CheckChangedList(
const editeng::SortedAutoCompleteStrings& rNewLst)
2000-09-18 23:08:29 +00:00
{
size_t nMyLen = m_WordList.size(), nNewLen = rNewLst.size();
size_t nMyPos = 0, nNewPos = 0;
2000-09-18 23:08:29 +00:00
for( ; nMyPos < nMyLen && nNewPos < nNewLen; ++nMyPos, ++nNewPos )
{
const editeng::IAutoCompleteString * pStr = rNewLst[ nNewPos ];
while (m_WordList[nMyPos] != pStr)
2000-09-18 23:08:29 +00:00
{
SwAutoCompleteString *const pDel =
dynamic_cast<SwAutoCompleteString*>(m_WordList[nMyPos]);
m_WordList.erase(nMyPos);
SwAutoCompleteStringPtrDeque::iterator it = std::find( aLRULst.begin(), aLRULst.end(), pDel );
OSL_ENSURE( aLRULst.end() != it, "String not found" );
aLRULst.erase( it );
delete pDel;
2000-09-18 23:08:29 +00:00
if( nMyPos >= --nMyLen )
break;
}
}
2011-10-28 02:23:02 +02:00
// remove the elements at the end of the array
2000-09-18 23:08:29 +00:00
if( nMyPos < nMyLen )
{
2011-10-28 02:23:02 +02:00
// clear LRU array first then delete the string object
2000-09-18 23:08:29 +00:00
for( ; nNewPos < nMyLen; ++nNewPos )
{
SwAutoCompleteString *const pDel =
dynamic_cast<SwAutoCompleteString*>(m_WordList[nNewPos]);
SwAutoCompleteStringPtrDeque::iterator it = std::find( aLRULst.begin(), aLRULst.end(), pDel );
OSL_ENSURE( aLRULst.end() != it, "String not found" );
aLRULst.erase( it );
delete pDel;
2000-09-18 23:08:29 +00:00
}
2011-10-28 02:23:02 +02:00
// remove from array
m_WordList.erase(m_WordList.begin() + nMyPos,
m_WordList.begin() + nMyLen);
2000-09-18 23:08:29 +00:00
}
}
void SwAutoCompleteWord::DocumentDying(const SwDoc& rDoc)
{
pImpl->RemoveDocument(rDoc);
2000-09-18 23:08:29 +00:00
2011-05-20 09:06:56 +01:00
SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect();
const sal_Bool bDelete = !pACorr->GetSwFlags().bAutoCmpltKeepList;
for (size_t nPos = m_WordList.size(); nPos; nPos--)
{
SwAutoCompleteString *const pCurrent =
dynamic_cast<SwAutoCompleteString*>(m_WordList[nPos - 1]);
if(pCurrent->RemoveDocument(rDoc) && bDelete)
{
m_WordList.erase(nPos - 1);
SwAutoCompleteStringPtrDeque::iterator it = std::find( aLRULst.begin(), aLRULst.end(), pCurrent );
OSL_ENSURE( aLRULst.end() != it, "word not found in LRU list" );
aLRULst.erase( it );
delete pCurrent;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */