summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-09-29 10:05:34 +0200
committerVladimir Glazunov <vg@openoffice.org>2010-09-29 10:05:34 +0200
commit03aa7ab71b66b63704a3dd1a98e024fd97c5ff6b (patch)
treee0c7c0b26c4233fe00681f80e8835eb331b2b893 /svl
parentfdd560163ef33ffec53b8cd559014a1b40958df0 (diff)
parent4e690b6439201fd2280081d42455d9daae70666d (diff)
CWS-TOOLING: integrate CWS tl82
Diffstat (limited to 'svl')
-rwxr-xr-x[-rw-r--r--]svl/inc/lngmisc.hxx3
-rwxr-xr-x[-rw-r--r--]svl/source/misc/lngmisc.cxx33
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