Are there AutoCorrect or AutoComplete services?
Are there AutoCorrect or AutoComplete services?
There are services for the Spellchecker, Thesaurus and AutoText. Is there any similar services for the AutoCorrect or AutoComplete entries? Perhaps undocumented?
I've looked long and hard. I'd like to add the functionality of all these to textboxes in dialogue. I have workarounds - I can load the AutoCorrect file and parse it myself - but that's not simple. And create my own code for AutoComplete in textboxes - but it wouldn't be the same list as in the main document.
Any proper access to these please?
I've looked long and hard. I'd like to add the functionality of all these to textboxes in dialogue. I have workarounds - I can load the AutoCorrect file and parse it myself - but that's not simple. And create my own code for AutoComplete in textboxes - but it wouldn't be the same list as in the main document.
Any proper access to these please?
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Are there AutoCorrect or AutoComplete services?
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: Are there AutoCorrect or AutoComplete services?
Thanks. That gets me the path to the folder with the autocorrect file
oPathSettings = CreateUnoService( "com.sun.star.util.PathSettings" )
msgbox oPathSettings.AutoCorrect
I don't know OO very well. I know I can find the file and write code myself to parse it and so on. What I'm wondering is if there's a service to get/set Autocorrect entries in that file?
oPathSettings = CreateUnoService( "com.sun.star.util.PathSettings" )
msgbox oPathSettings.AutoCorrect
I don't know OO very well. I know I can find the file and write code myself to parse it and so on. What I'm wondering is if there's a service to get/set Autocorrect entries in that file?
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Are there AutoCorrect or AutoComplete services?
One of my autocorrect entries is "abotu" whic is corrected to "about". Is there a way of querying the word "abotu" to see whether its an autocorrect entry? Without writing code to examine the autocorrect file myself - I know I can do that but its complicated.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Are there AutoCorrect or AutoComplete services?
I've thought of creating a hidden docment and entering the word - then a space - but autocorrect isn't invoked then. Just when the space is entered manually.
oCursor = thisComponent.getText.createTextCursor
oText = thisComponent.getText
otext.string ="abotu"
ocursor.collapseToEnd(false)
ocursor.string =" "
Doesn't invoke autocorrect. Sendkeys might work but that's just Windows and anyway this wouldn't be efficient even if it worked.
oCursor = thisComponent.getText.createTextCursor
oText = thisComponent.getText
otext.string ="abotu"
ocursor.collapseToEnd(false)
ocursor.string =" "
Doesn't invoke autocorrect. Sendkeys might work but that's just Windows and anyway this wouldn't be efficient even if it worked.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Are there AutoCorrect or AutoComplete services?
There is a sample database with the LibreOffice 5 Base documentation that has an example of AutoComplete macro in formatted text boxes. I would guess it is similar to OpenOffice. I don't have the link handy, but a quick search of their site should get you there.
LibreOffice 5.4.5.1 on Linux Mint 18.3
Re: Are there AutoCorrect or AutoComplete services?
See [Tutorial] Automatic functions in Writer - enable / disable.
AutoHotKey is an extremely powerful tool which recognises text the user types and replaces it with pre-defined text or commands. AutoHotKey typed the above line for me when I typed zztutaut, my shortcut for zz_tut[orial]_aut[omatic functions]. zzsol gets ...
If this solves the problem, please click the Edit button on your original post and add [Solved] in front of your subject.
AutoHotKey is an extremely powerful tool which recognises text the user types and replaces it with pre-defined text or commands. AutoHotKey typed the above line for me when I typed zztutaut, my shortcut for zz_tut[orial]_aut[omatic functions]. zzsol gets ...
If this solves the problem, please click the Edit button on your original post and add [Solved] in front of your subject.
LO 6.4.4.2, Windows 10 Home 64 bit
See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.
Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.
Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Re: Are there AutoCorrect or AutoComplete services?
Thanks for the two new replies/tries. All I could find for AutoComplete macros in LibreOffice is...
What I'll probably have to settle for is
Thesausus/Spelling/find and replace - I can access all those features in code fine.
Autocomplete - do a seperate implementation of that for textboxes. The word list just won't be the same as for documents.
Autotext - instead of trying to use that, do a similar but separate text-clips thing for textboxes
Autocorrect - I can read in the autocorrect list from the text file and use that without trying to make any changes to it.
https://help.libreoffice.org/Common/Gen ... ut_Keys_in"LibreOffice has an AutoComplete function which activates itself in some text and list boxes. For example, enter ~/a into the URL field and the AutoComplete function displays the first file or first directory found in your home folder that starts with the letter "a"."
What I'll probably have to settle for is
Thesausus/Spelling/find and replace - I can access all those features in code fine.
Autocomplete - do a seperate implementation of that for textboxes. The word list just won't be the same as for documents.
Autotext - instead of trying to use that, do a similar but separate text-clips thing for textboxes
Autocorrect - I can read in the autocorrect list from the text file and use that without trying to make any changes to it.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: Are there AutoCorrect or AutoComplete services?
I don't know if "Autotext" is exactly what you are looking for. The example I referred to earlier is for LO5 and is in a base file named: Example_Autotext_Searchmark_Spelling.odb.
It is included in a zip file https://wiki.documentfoundation.org/ima ... abases.zip The code snippet below works with a textbox:
It is included in a zip file https://wiki.documentfoundation.org/ima ... abases.zip The code snippet below works with a textbox:
Code: Select all
SUB Autotext(oEvent AS OBJECT) 'Properties: TextBox → Events → Text modified
DIM arText()
DIM stText AS STRING
DIM oSelection AS NEW com.sun.star.awt.Selection
DIM oField AS OBJECT
DIM oAutotexts AS OBJECT
DIM oRange AS OBJECT
DIM oCursor AS OBJECT
oField = oEvent.Source
IF oField.text <> "" THEN
arText = Split(oField.text)
stText = arText(Ubound(arText))
oAutotexts = createunoservice("com.sun.star.text.AutoTextContainer")
oRange = oAutotexts.getByName("standard") 'template, standard, crdbus50, mytexts - Autotext will be started in Writer by shortcut and F3.
IF oRange.hasByName(stText) THEN
oAutotext = oRange.getByName(stText) 'Example: DMS is the shortcut for "Dear Madam or Sir" (Writer → Edit → AutoText)
oCursor = oField.Model.createTextCursor()
oCursor.gotoEnd(true)
oCursor.goLeft(len(stText),true)
oField.Model.insertString(oCursor,oAutotext.String,true)
oSelection.Min = len(oField.Text)
oSelection.Max = len(oField.Text)
oField.setFocus
oField.Selection = oSelection
END IF
END IF
END SUB
LibreOffice 5.4.5.1 on Linux Mint 18.3
Re: Are there AutoCorrect or AutoComplete services?
Brilliant thanks... that helps with the Autotext bit. I've used a little of that to write autotext for a dialog textbox which will work on the F3 keypress.
Code: Select all
sub keyPress(oEvt)'call this from dialog textbox keyPress event
dim sel as new com.sun.star.awt.Selection
Dim aLocale As New com.sun.star.lang.Locale
dim a as new com.sun.star.i18n.Boundary
dim testwd as string,c as object,BI
dim oAutotexts,oAutotext,AutoTextGroup
if oEvt.keycode = 770 then 'f3
c=oEvt.source
sel =c.getSelection()
'Set the locale - would do something less ad hoc for a final version.
aLocale.Language = "en" 'Use the English language
aLocale.Country = "US" 'Use the United States as the country
'We could search backwards for a breakchar ourselves but xBreakIterator will get the word boundary for the locale
BI = CreateUnoService("com.sun.star.i18n.BreakIterator")
a =BI.getwordboundary(c.gettext,sel.max,aLocale,0,false)
testwd= mid(c.gettext,a.startPos+1,a.endpos - a.startpos)
oAutotexts = createunoservice("com.sun.star.text.AutoTextContainer")
AutoTextGroup = oAutotexts.getByName("standard") 'template, standard, crdbus50, mytexts - Autotext will be started in Writer by shortcut and F3.
IF AutoTextGroup.hasByName(testwd) THEN
oAutotext = AutoTextGroup.getByName(testwd) 'Example: DMS is the shortcut for "Dear Madam or Sir" (Writer → Edit → AutoText)
sel.min = a.startpos
c.insertText sel,oAutotext.string
end if
end if
end sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)