Page 1 of 1
OpenOffice Smarttags
Posted: Sun May 15, 2016 8:25 am
by RoryOF
Has anyone discovered a method of accessing the OpenOffice Smarttags functionality from OO BASIC?
https://www.openoffice.org/api/docs/com ... le-ix.html
Re: OpenOffice Smarttags
Posted: Sun May 15, 2016 9:15 am
by RPG
Hello
Did you have found this:
Writer/Smart Tags - Apache OpenOffice Wiki.
I did never heard about the smart tags.
Romke
Re: OpenOffice Smarttags
Posted: Sun May 15, 2016 9:50 am
by RoryOF
Yes, I found that, Romke.
For benefit of those who don't know what Smarttags are (sometimes: Smart Tags), in very rough outline they are a form of automatically recognised hyperlink in a document, which pops up a (user defined) menu of user defined actions. They were a Microsoft invention of about 2001 which didn't catch on well, as far as I know. But I can see some uses for them in my writing process - for example, a character name could pop up a reminder of the characteristics of that character, without cluttering the document with side Comments.
Re: OpenOffice Smarttags
Posted: Fri May 27, 2016 7:10 pm
by hanya
I've tried to make small extension which uses SmartTags function in Python. It requires component impolementations, so it can not be implemented only with Basic.
Re: OpenOffice Smarttags
Posted: Fri May 27, 2016 7:13 pm
by RoryOF
I'm offine for the next week, hanya, so I'll come back to playing with smarttags when I return, unless there is too much piled up for me. I will have to refresh my Python knowledge.
Re: OpenOffice Smarttags
Posted: Fri May 27, 2016 7:46 pm
by hanya
I tried to imagin a wrapper component of the smarttags for the Basic, but it would not so interesting. Because all smarttags require own registration of the component with own implementation name under smart tag service in the office component registry. The wrapper installed from an extension package can not be reused among the Basic macros.
And also, recognition is hard task to match with complicated strings for Basic macros. It is better to work with regular expression for such task. css.util.TextSearch is not fun.
Re: OpenOffice Smarttags
Posted: Fri May 27, 2016 9:17 pm
by hanya
Here is an example extension written in Python.
- Install through the extension manager.
- Restart your office.
- Create new Writer document.
- Choose Tools - AutoCorrect Options... in the main menu. You can see Smart Tags tab in the opened dialog. You can switch to use or not to use registered recognizer and actions.
- Type somting like "hoge $(LANG)" in the document. The recognizer finds $(text_without_spaces) and marks with red dotted line.
- Ctrl+click to open smarttag menu and choose Environmental Variable to substitute the text with the related environmental variable on the document.
I noticed that a recognizer can have multiple smarttag. So I can create wrapper which calls subcontract macros according to some settings.
But still there is a problem about recognition speed. When you open some document, whole content of the document will be passed to the recognizer. And also, if you type some characters in your document, whole paragraph is passed to the recognizer on each single character change.
It looks css.text.XTextMarkup.commitTextMarkup method used in the example of the wiki page has been renamed to commitStringMarkup.
Re: OpenOffice Smarttags
Posted: Fri May 27, 2016 9:31 pm
by RoryOF
Thank you, Hanya. Downloaded and instructions printed out, but I won't touch it for about ten days as I'm in going away mode - tickets to collect, bag to pack, currency to change etc.