diff options
author | Thomas Lange [tl] <tl@openoffice.org> | 2010-07-26 13:12:35 +0200 |
---|---|---|
committer | Thomas Lange [tl] <tl@openoffice.org> | 2010-07-26 13:12:35 +0200 |
commit | e937a4331fafe99449c42a07cd3ea66ffc3e488a (patch) | |
tree | c6b011e663a57ae368739c1775372f6352a4577f /svl | |
parent | 7f0993d43019a0ccb7f89c11fc23704c063b902f (diff) |
cws tl82: #i106993# thesaurus code clean-up
Diffstat (limited to 'svl')
-rwxr-xr-x[-rw-r--r--] | svl/inc/lngmisc.hxx | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | svl/source/misc/lngmisc.cxx | 33 |
2 files changed, 36 insertions, 0 deletions
diff --git a/svl/inc/lngmisc.hxx b/svl/inc/lngmisc.hxx index d85de673c4c9..5143d147227d 100644..100755 --- a/svl/inc/lngmisc.hxx +++ b/svl/inc/lngmisc.hxx @@ -32,6 +32,7 @@ #include <tools/solar.h> #include <sal/types.h> #include <rtl/ustring.hxx> +#include <tools/string.hxx> /////////////////////////////////////////////////////////////////////////// @@ -68,6 +69,8 @@ SVL_DLLPUBLIC BOOL RemoveControlChars( rtl::OUString &rTxt ); SVL_DLLPUBLIC BOOL ReplaceControlChars( rtl::OUString &rTxt, sal_Char aRplcChar = ' ' ); +SVL_DLLPUBLIC String GetThesaurusReplaceText( const String &rText ); + } // namespace linguistic #endif diff --git a/svl/source/misc/lngmisc.cxx b/svl/source/misc/lngmisc.cxx index 2203cc08458e..488e317c6f58 100644..100755 --- a/svl/source/misc/lngmisc.cxx +++ b/svl/source/misc/lngmisc.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svl.hxx" + #include <lngmisc.hxx> #include <tools/solar.h> #include <tools/string.hxx> @@ -132,6 +133,38 @@ BOOL ReplaceControlChars( rtl::OUString &rTxt, sal_Char /*aRplcChar*/ ) return bModified; } + +String GetThesaurusReplaceText( const String &rText ) +{ + // The strings for synonyms returned by the thesaurus sometimes have some + // explanation text put in between '(' and ')' or a trailing '*'. + // These parts should not be put in the ReplaceEdit Text that may get + // inserted into the document. Thus we strip them from the text. + + String aText( rText ); + + xub_StrLen nPos = aText.Search( sal_Unicode('(') ); + while (STRING_NOTFOUND != nPos) + { + xub_StrLen nEnd = aText.Search( sal_Unicode(')'), nPos ); + if (STRING_NOTFOUND != nEnd) + aText.Erase( nPos, nEnd-nPos+1 ); + else + break; + nPos = aText.Search( sal_Unicode('(') ); + } + + nPos = aText.Search( sal_Unicode('*') ); + if (STRING_NOTFOUND != nPos) + aText.Erase( nPos ); + + // remove any possible remaining ' ' that may confuse the thesaurus + // when it gets called with the text + aText.EraseLeadingAndTrailingChars( sal_Unicode(' ') ); + + return aText; +} + /////////////////////////////////////////////////////////////////////////// } // namespace linguistic |