INTEGRATION: CWS ooo20030412 (1.1.36); FILE MERGED
2003/03/25 21:07:20 khendricks 1.1.36.1: minor updates and fixes for lingucomponent includes a bug fix for issue 9887 Kevin
This commit is contained in:
parent
ade4f564dc
commit
d896a36bb6
@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: spelldta.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: hr $ $Date: 2003-03-26 13:03:02 $
|
||||
* last change: $Author: hr $ $Date: 2003-04-28 17:05:22 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@ -64,6 +64,7 @@
|
||||
#endif
|
||||
|
||||
#include <com/sun/star/linguistic2/SpellFailure.hpp>
|
||||
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
|
||||
|
||||
#ifndef _TOOLS_DEBUG_HXX //autogen wg. DBG_ASSERT
|
||||
#include <tools/debug.hxx>
|
||||
@ -146,6 +147,92 @@ Reference< XSpellAlternatives > MergeProposals(
|
||||
}
|
||||
|
||||
|
||||
BOOL SeqHasEntry(
|
||||
const Sequence< OUString > &rSeq,
|
||||
const OUString &rTxt)
|
||||
{
|
||||
BOOL bRes = FALSE;
|
||||
INT32 nLen = rSeq.getLength();
|
||||
const OUString *pEntry = rSeq.getConstArray();
|
||||
for (INT32 i = 0; i < nLen && !bRes; ++i)
|
||||
{
|
||||
if (rTxt == pEntry[i])
|
||||
bRes = TRUE;
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
|
||||
|
||||
void SeqRemoveNegEntries( Sequence< OUString > &rSeq,
|
||||
Reference< XDictionaryList > &rxDicList,
|
||||
INT16 nLanguage )
|
||||
{
|
||||
static const OUString aEmpty;
|
||||
BOOL bSthRemoved = FALSE;
|
||||
INT32 nLen = rSeq.getLength();
|
||||
OUString *pEntries = rSeq.getArray();
|
||||
for (INT32 i = 0; i < nLen; ++i)
|
||||
{
|
||||
Reference< XDictionaryEntry > xNegEntry( SearchDicList( rxDicList,
|
||||
pEntries[i], nLanguage, FALSE, TRUE ) );
|
||||
if (xNegEntry.is())
|
||||
{
|
||||
pEntries[i] = aEmpty;
|
||||
bSthRemoved = TRUE;
|
||||
}
|
||||
}
|
||||
if (bSthRemoved)
|
||||
{
|
||||
Sequence< OUString > aNew;
|
||||
// merge sequence without duplicates and empty strings in new empty sequence
|
||||
aNew = MergeProposalSeqs( aNew, rSeq, FALSE );
|
||||
rSeq = aNew;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Sequence< OUString > MergeProposalSeqs(
|
||||
Sequence< OUString > &rAlt1,
|
||||
Sequence< OUString > &rAlt2,
|
||||
BOOL bAllowDuplicates )
|
||||
{
|
||||
Sequence< OUString > aMerged;
|
||||
|
||||
if (0 == rAlt1.getLength() && bAllowDuplicates)
|
||||
aMerged = rAlt2;
|
||||
else if (0 == rAlt2.getLength() && bAllowDuplicates)
|
||||
aMerged = rAlt1;
|
||||
else
|
||||
{
|
||||
INT32 nAltCount1 = rAlt1.getLength();
|
||||
const OUString *pAlt1 = rAlt1.getConstArray();
|
||||
INT32 nAltCount2 = rAlt2.getLength();
|
||||
const OUString *pAlt2 = rAlt2.getConstArray();
|
||||
|
||||
INT32 nCountNew = Min( nAltCount1 + nAltCount2, (INT32) MAX_PROPOSALS );
|
||||
aMerged.realloc( nCountNew );
|
||||
OUString *pMerged = aMerged.getArray();
|
||||
|
||||
INT32 nIndex = 0;
|
||||
INT32 i = 0;
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
INT32 nCount = j == 0 ? nAltCount1 : nAltCount2;
|
||||
const OUString *pAlt = j == 0 ? pAlt1 : pAlt2;
|
||||
for (i = 0; i < nCount && nIndex < MAX_PROPOSALS; i++)
|
||||
{
|
||||
if (pAlt[i].getLength() &&
|
||||
(bAllowDuplicates || !SeqHasEntry(aMerged, pAlt[i] )))
|
||||
pMerged[ nIndex++ ] = pAlt[ i ];
|
||||
}
|
||||
}
|
||||
//DBG_ASSERT(nIndex == nCountNew, "wrong number of proposals");
|
||||
aMerged.realloc( nIndex );
|
||||
}
|
||||
|
||||
return aMerged;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@ -171,6 +258,17 @@ SpellAlternatives::SpellAlternatives(
|
||||
}
|
||||
|
||||
|
||||
SpellAlternatives::SpellAlternatives(
|
||||
const OUString &rWord, INT16 nLang, INT16 nFailureType,
|
||||
const Sequence< OUString > &rAlternatives ) :
|
||||
aWord (rWord),
|
||||
nLanguage (nLang),
|
||||
nType (nFailureType),
|
||||
aAlt (rAlternatives)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SpellAlternatives::~SpellAlternatives()
|
||||
{
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: spelldta.hxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: hr $ $Date: 2003-03-26 13:03:02 $
|
||||
* last change: $Author: hr $ $Date: 2003-04-28 17:05:31 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@ -72,6 +72,12 @@
|
||||
#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
|
||||
#include <cppuhelper/implbase1.hxx> // helper for implementations
|
||||
|
||||
namespace com { namespace sun { namespace star {
|
||||
namespace linguistic2 {
|
||||
class XDictionaryList;
|
||||
}
|
||||
} } }
|
||||
|
||||
|
||||
namespace linguistic
|
||||
{
|
||||
@ -86,6 +92,22 @@ namespace linguistic
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::linguistic2::XSpellAlternatives > &rxAlt2 );
|
||||
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString >
|
||||
MergeProposalSeqs(
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlt1,
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlt2,
|
||||
BOOL bAllowDuplicates );
|
||||
|
||||
void SeqRemoveNegEntries(
|
||||
::com::sun::star::uno::Sequence< ::rtl::OUString > &rSeq,
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::linguistic2::XDictionaryList > &rxDicList,
|
||||
INT16 nLanguage );
|
||||
|
||||
BOOL SeqHasEntry(
|
||||
const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rSeq,
|
||||
const ::rtl::OUString &rTxt);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@ -108,6 +130,8 @@ public:
|
||||
SpellAlternatives();
|
||||
SpellAlternatives(const ::rtl::OUString &rWord, INT16 nLang, INT16 nFailureType,
|
||||
const ::rtl::OUString &rRplcWord );
|
||||
SpellAlternatives(const ::rtl::OUString &rWord, INT16 nLang, INT16 nFailureType,
|
||||
const ::com::sun::star::uno::Sequence< ::rtl::OUString > &rAlternatives );
|
||||
virtual ~SpellAlternatives();
|
||||
|
||||
// XSpellAlternatives
|
||||
|
Loading…
x
Reference in New Issue
Block a user