change deactivate text locale language check Josef Frysak How to deactivate the language check of a Writer document?

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.

-- try to get a script context, will be .nil, if script was not invoked by OOo x_ScriptContext = uno.getScriptContext() if (x_ScriptContext <> .nil) then do -- invoked by OOo as a macro -- get context x_ComponentContext = x_ScriptContext~getComponentContext -- get desktop (an XDesktop) x_Desktop = x_ScriptContext~getDesktop -- get current document x_Document = x_ScriptContext~getDocument end else do -- called from outside of OOo, create a connection -- connect to Open Office and get component context x_ComponentContext = UNO.connect() -- create a desktop service and its interface service = "{%see com.sun.star.frame.Desktop}" s_Desktop = x_ComponentContext~getServiceManager~{%see com.sun.star.lang.XMultiServiceFactory%XMultiServiceFactory}~createInstance(service) x_Desktop = s_Desktop~{%see com.sun.star.frame.XDesktop%XDesktop} -- get the last active document x_Document = x_Desktop~getCurrentComponent() end -- first we define a locale entry that is unknown st_Locale = .bsf~new("{%see com.sun.star.lang.Locale}") st_Locale~bsf.setFieldValue("Language", "unknown") st_Locale~bsf.setFieldValue("Country", "unknown") -- next we get the text interface of the document x_TextDocument = x_Document~{%see com.sun.star.text.XTextDocument%XTextDocument} x_Text = x_TextDocument~getText -- now we create a virtual text cursor and a paragraphcursor interface of it. x_TextCursor = x_Text~createTextCursor() x_ParagraphCursor = x_TextCursor~{%see com.sun.star.text.XParagraphCursor%XParagraphCursor} -- here we go to the start of the document x_TextCursor~gotoStart(.false) -- now we jump from one paragraph to the next one and change its locale entry do while x_ParagraphCursor~gotoNextParagraph(.true) x_PropertySet = x_TextCursor~{%see com.sun.star.beans.XPropertySet%XPropertySet} x_PropertySet~setPropertyValue("CharLocale", st_Locale) x_ParagraphCursor~goRight(0, .false) end -- finally we check if there is also text behind the last paragraph. -- their language also must be changed if x_ParagraphCursor~gotoEndOfParagraph(.false) then do x_ParagraphCursor~goRight(1, .false) x_ParagraphCursor~gotoEnd(.true) x_PropertySet = x_TextCursor~{%see com.sun.star.beans.XPropertySet%XPropertySet} x_PropertySet~setPropertyValue("CharLocale", st_Locale) x_ParagraphCursor~goRight(0, .false) end ::requires UNO.CLS
Initial version