 | OO-Snippets: Deactivate text locale (language check)Commons| Keywords | change, deactivate, text, locale, language, check |
|---|
| Language | ooRexx |
|---|
| Application | Writer |
|---|
| Authors | Josef Frysak (initial)
|
|---|
| Supported Versions | 2.4.1 |
|---|
| Supported OS | All |
|---|
| Question | How to deactivate the language check of a Writer document?
|
|---|
| Answer | To deactivate the language check of the text, the language description of all text parts must be set to "unknown". Therefore prepare a "Locale" structure with Language and Country properties set to "unknown". Next create a text cursur and get its "XParagraphCursor" interface. Now iterate trough all paragraphs and set their "CharLocale" property to the locale structure created before. For further details see http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2008/200809_Frysak/200809_Frysak_Automating_OOo_ooRexx_Nutshells.pdf. |
|---|
x_ScriptContext = uno.getScriptContext()
if (x_ScriptContext <> .nil) then
do
x_ComponentContext = x_ScriptContext~getComponentContext
x_Desktop = x_ScriptContext~getDesktop
x_Document = x_ScriptContext~getDocument
end
else
do
x_ComponentContext = UNO.connect()
service = "com.sun.star.frame.Desktop"
s_Desktop = x_ComponentContext~getServiceManager~XMultiServiceFactory~createInstance(service)
x_Desktop = s_Desktop~XDesktop
x_Document = x_Desktop~getCurrentComponent()
end
st_Locale = .bsf~new("com.sun.star.lang.Locale")
st_Locale~bsf.setFieldValue("Language", "unknown")
st_Locale~bsf.setFieldValue("Country", "unknown")
x_TextDocument = x_Document~XTextDocument
x_Text = x_TextDocument~getText
x_TextCursor = x_Text~createTextCursor()
x_ParagraphCursor = x_TextCursor~XParagraphCursor
x_TextCursor~gotoStart(.false)
do while x_ParagraphCursor~gotoNextParagraph(.true)
x_PropertySet = x_TextCursor~XPropertySet
x_PropertySet~setPropertyValue("CharLocale", st_Locale)
x_ParagraphCursor~goRight(0, .false)
end
if x_ParagraphCursor~gotoEndOfParagraph(.false) then
do
x_ParagraphCursor~goRight(1, .false)
x_ParagraphCursor~gotoEnd(.true)
x_PropertySet = x_TextCursor~XPropertySet
x_PropertySet~setPropertyValue("CharLocale", st_Locale)
x_ParagraphCursor~goRight(0, .false)
end
::requires UNO.CLS
|
Changelog| Date | User | Modification |
|---|
| 2008-10-14 | 1 | Initial version |
|