diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-04-28 16:05:31 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-04-28 16:05:31 +0000 |
commit | d896a36bb6479f74a925fc3f784452cff762e67d (patch) | |
tree | a803e0715f9725d30d2a3229fdee8a264cbe7250 /lingucomponent | |
parent | ade4f564dc563a8154cf0455ad5ba61b888cd164 (diff) |
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
Diffstat (limited to 'lingucomponent')
-rw-r--r-- | lingucomponent/source/spellcheck/spell/spelldta.cxx | 102 | ||||
-rw-r--r-- | lingucomponent/source/spellcheck/spell/spelldta.hxx | 36 |
2 files changed, 130 insertions, 8 deletions
diff --git a/lingucomponent/source/spellcheck/spell/spelldta.cxx b/lingucomponent/source/spellcheck/spell/spelldta.cxx index 16ca02576fd5..c70a02aea43b 100644 --- a/lingucomponent/source/spellcheck/spell/spelldta.cxx +++ b/lingucomponent/source/spellcheck/spell/spelldta.cxx @@ -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() { } diff --git a/lingucomponent/source/spellcheck/spell/spelldta.hxx b/lingucomponent/source/spellcheck/spell/spelldta.hxx index 703b3603d012..a9272ea21911 100644 --- a/lingucomponent/source/spellcheck/spell/spelldta.hxx +++ b/lingucomponent/source/spellcheck/spell/spelldta.hxx @@ -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 { @@ -81,10 +87,26 @@ namespace linguistic ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellAlternatives > MergeProposals( - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XSpellAlternatives > &rxAlt1, - ::com::sun::star::uno::Reference< - ::com::sun::star::linguistic2::XSpellAlternatives > &rxAlt2 ); + ::com::sun::star::uno::Reference< + ::com::sun::star::linguistic2::XSpellAlternatives > &rxAlt1, + ::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 |