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

434 lines
13 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
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 OUString& rStr, sal_Int32 nPos, sal_Int32 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 OUString& rStr, sal_Int32 const nPos, sal_Int32 const nLen)
: editeng::IAutoCompleteString(rStr.copy(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
{
}
SwAutoCompleteWord::~SwAutoCompleteWord()
{
m_WordList.DeleteAndDestroyAll(); // so the assertion below works
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 OUString& 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;
}
OUString 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;
sal_Int32 nWrdLen = aNewWord.getLength();
while( nWrdLen && '.' == aNewWord[ 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).copy(0, nWrdLen) );
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().getLength() < 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;
}
/** Return all words matching a given prefix
*
* @param aMatch the prefix to search for
* @param aWords the words to search in
*/
bool SwAutoCompleteWord::GetWordsMatching(OUString aMatch, std::vector<OUString>& aWords) const
{
OUString aStringRoot = aMatch;
std::vector<OUString> suggestions;
m_LookupTree.findSuggestions(aStringRoot, suggestions);
if (suggestions.empty())
{
return false;
}
for (size_t i = 0; i < suggestions.size(); i++)
{
aWords.push_back( suggestions[i] );
}
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: */