/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
if (aInsPair.second)
{
bRet = true; if (m_aLRUList.size() >= m_nMaxCount)
{ // the last one needs to be removed // so that there is space for the first one
SwAutoCompleteString* pDel = m_aLRUList.back();
m_aLRUList.pop_back();
m_WordList.erase(pDel); delete pDel;
}
m_aLRUList.push_front(pNew);
} else
{ delete pNew; // then move "up"
pNew = static_cast<SwAutoCompleteString*>(*aInsPair.first);
// 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( m_aLRUList.begin(), m_aLRUList.end(), pNew );
OSL_ENSURE( m_aLRUList.end() != it, "String not found" ); if ( m_aLRUList.begin() != it && m_aLRUList.end() != it )
{
m_aLRUList.erase( it );
m_aLRUList.push_front( pNew );
}
}
} return bRet;
}
void SwAutoCompleteWord::SetMinWordLen( sal_uInt16 n )
{ // Do you really want to remove all words that are less than the minWrdLen? if( n < m_nMinWordLen )
{
size_t nPos = 0; while (nPos < m_WordList.size())
{ if (m_WordList[ nPos ]->GetAutoCompleteString().getLength() < n)
{
SwAutoCompleteString *const pDel = dynamic_cast<SwAutoCompleteString*>(m_WordList[nPos]);
m_WordList.erase_at(nPos);
SwAutoCompleteStringPtrDeque::iterator it = std::find( m_aLRUList.begin(), m_aLRUList.end(), pDel );
OSL_ENSURE( m_aLRUList.end() != it, "String not found" );
m_aLRUList.erase( it ); delete pDel; continue;
}
++nPos;
}
}
m_nMinWordLen = n;
}
/** Return all words matching a given prefix * * @param aMatch the prefix to search for * @param rWords the words found matching
*/ bool SwAutoCompleteWord::GetWordsMatching(std::u16string_view aMatch, std::vector<OUString>& rWords) const
{
assert(rWords.empty());
m_LookupTree.findSuggestions(aMatch, rWords); return !rWords.empty();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.