/* -*- 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 the GroupName is already known, then only rShortName // will be filled. Otherwise also rGroupName will be set and // on demand asked for the right group.
// Give back all (not exceeding FIND_MAX_GLOS) found modules // with matching beginning.
void SwGlossaryList::HasLongName(const std::vector<OUString>& rBeginCandidates,
std::vector<std::pair<OUString, sal_uInt16>>& rLongNames)
{ if(!m_bFilled)
Update(); const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); // We store results for all candidate words in separate lists, so that later // we can sort them according to the candidate position
std::vector<std::vector<OUString>> aResults(rBeginCandidates.size());
// We can't break after FIND_MAX_GLOS items found, since first items may have ended up in // lower-priority lists, and those from higher-priority lists are yet to come. So process all. for (constauto& pGroup : m_aGroupArr)
{
sal_Int32 nIdx{ 0 }; for(sal_uInt16 j = 0; j < pGroup->nCount; j++)
{
OUString sBlock = pGroup->sLongNames.getToken(0, STRING_DELIM, nIdx); for (size_t i = 0; i < rBeginCandidates.size(); ++i)
{ const OUString& s = rBeginCandidates[i]; if (s.getLength() + 1 < sBlock.getLength()
&& rSCmp.isEqual(sBlock.copy(0, s.getLength()), s))
{
aResults[i].push_back(sBlock);
}
}
}
}
std::vector<std::pair<OUString, sal_uInt16>> aAllResults; // Sort and concatenate all result lists. See QuickHelpData::SortAndFilter for (size_t i = 0; i < rBeginCandidates.size(); ++i)
{
std::sort(aResults[i].begin(), aResults[i].end(),
[origWord = rBeginCandidates[i]](const OUString& s1, const OUString& s2) { int nRet = s1.compareToIgnoreAsciiCase(s2); if (nRet == 0)
{ // fdo#61251 sort stuff that starts with the exact rOrigWord before // another ignore-case candidate int n1StartsWithOrig = s1.startsWith(origWord) ? 0 : 1; int n2StartsWithOrig = s2.startsWith(origWord) ? 0 : 1; return n1StartsWithOrig < n2StartsWithOrig;
} return nRet < 0;
}); // All suggestions must be accompanied with length of the text they would replace
std::transform(aResults[i].begin(), aResults[i].end(), std::back_inserter(aAllResults),
[nLen = sal_uInt16(rBeginCandidates[i].getLength())](const OUString& s) { return std::make_pair(s, nLen);
});
}
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.