summaryrefslogtreecommitdiff
path: root/linguistic/source/spelldta.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2016-02-23 19:41:53 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-04-01 07:33:32 +0000
commit46b4634de93bdda2a8427c6c545dc6160d5201d0 (patch)
tree4c6245229f65d9a96bbc7f098767b392e86629ae /linguistic/source/spelldta.cxx
parent9f6e6fabcd5718e0b65437c5ce398e520f47aae1 (diff)
sequence->vector in linguistic
Change-Id: I28ed0b4bb2a140493fca693807011b91b3569986 Reviewed-on: https://gerrit.libreoffice.org/23695 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'linguistic/source/spelldta.cxx')
-rw-r--r--linguistic/source/spelldta.cxx55
1 files changed, 25 insertions, 30 deletions
diff --git a/linguistic/source/spelldta.cxx b/linguistic/source/spelldta.cxx
index 001fbe9ece69..6a0a93891581 100644
--- a/linguistic/source/spelldta.cxx
+++ b/linguistic/source/spelldta.cxx
@@ -46,15 +46,14 @@ namespace linguistic
#define MAX_PROPOSALS 40
bool SeqHasEntry(
- const Sequence< OUString > &rSeq,
+ const std::vector< OUString > &rSeq,
const OUString &rTxt)
{
bool bRes = false;
- sal_Int32 nLen = rSeq.getLength();
- const OUString *pEntry = rSeq.getConstArray();
- for (sal_Int32 i = 0; i < nLen && !bRes; ++i)
+ sal_Int32 nLen = rSeq.size();
+ for (sal_Int32 i = 0; i < nLen && !bRes; ++i)
{
- if (rTxt == pEntry[i])
+ if (rTxt == rSeq[i])
bRes = true;
}
return bRes;
@@ -107,26 +106,25 @@ void SearchSimilarText( const OUString &rText, sal_Int16 nLanguage,
}
-void SeqRemoveNegEntries( Sequence< OUString > &rSeq,
+void SeqRemoveNegEntries( std::vector< OUString > &rSeq,
Reference< XSearchableDictionaryList > &rxDicList,
sal_Int16 nLanguage )
{
bool bSthRemoved = false;
- sal_Int32 nLen = rSeq.getLength();
- OUString *pEntries = rSeq.getArray();
+ sal_Int32 nLen = rSeq.size();
for (sal_Int32 i = 0; i < nLen; ++i)
{
Reference< XDictionaryEntry > xNegEntry( SearchDicList( rxDicList,
- pEntries[i], nLanguage, false, true ) );
+ rSeq[i], nLanguage, false, true ) );
if (xNegEntry.is())
{
- pEntries[i].clear();
+ rSeq[i].clear();
bSthRemoved = true;
}
}
if (bSthRemoved)
{
- Sequence< OUString > aNew;
+ std::vector< OUString > aNew;
// merge sequence without duplicates and empty strings in new empty sequence
aNew = MergeProposalSeqs( aNew, rSeq, false );
rSeq = aNew;
@@ -134,42 +132,39 @@ void SeqRemoveNegEntries( Sequence< OUString > &rSeq,
}
-Sequence< OUString > MergeProposalSeqs(
- Sequence< OUString > &rAlt1,
- Sequence< OUString > &rAlt2,
+std::vector< OUString > MergeProposalSeqs(
+ std::vector< OUString > &rAlt1,
+ std::vector< OUString > &rAlt2,
bool bAllowDuplicates )
{
- Sequence< OUString > aMerged;
+ std::vector< OUString > aMerged;
- if (0 == rAlt1.getLength() && bAllowDuplicates)
+ if (rAlt1.empty() && bAllowDuplicates)
aMerged = rAlt2;
- else if (0 == rAlt2.getLength() && bAllowDuplicates)
+ else if (rAlt2.empty() && bAllowDuplicates)
aMerged = rAlt1;
else
{
- sal_Int32 nAltCount1 = rAlt1.getLength();
- const OUString *pAlt1 = rAlt1.getConstArray();
- sal_Int32 nAltCount2 = rAlt2.getLength();
- const OUString *pAlt2 = rAlt2.getConstArray();
+ size_t nAltCount1 = rAlt1.size();
+ size_t nAltCount2 = rAlt2.size();
- sal_Int32 nCountNew = std::min( nAltCount1 + nAltCount2, (sal_Int32) MAX_PROPOSALS );
- aMerged.realloc( nCountNew );
- OUString *pMerged = aMerged.getArray();
+ sal_Int32 nCountNew = std::min<sal_Int32>( nAltCount1 + nAltCount2, (sal_Int32) MAX_PROPOSALS );
+ aMerged.resize( nCountNew );
sal_Int32 nIndex = 0;
sal_Int32 i = 0;
for (int j = 0; j < 2; j++)
{
- sal_Int32 nCount = j == 0 ? nAltCount1 : nAltCount2;
- const OUString *pAlt = j == 0 ? pAlt1 : pAlt2;
+ sal_Int32 nCount = j == 0 ? nAltCount1 : nAltCount2;
+ std::vector< OUString >& rAlt = j == 0 ? rAlt1 : rAlt2;
for (i = 0; i < nCount && nIndex < MAX_PROPOSALS; i++)
{
- if (!pAlt[i].isEmpty() &&
- (bAllowDuplicates || !SeqHasEntry(aMerged, pAlt[i] )))
- pMerged[ nIndex++ ] = pAlt[ i ];
+ if (!rAlt[i].isEmpty() &&
+ (bAllowDuplicates || !SeqHasEntry(aMerged, rAlt[i] )))
+ aMerged[ nIndex++ ] = rAlt[ i ];
}
}
- aMerged.realloc( nIndex );
+ aMerged.resize( nIndex );
}
return aMerged;