OpenOffice Smarttags

Keyboard macros or custom scripts

OpenOffice Smarttags

Postby RoryOF » Sun May 15, 2016 8:25 am

Has anyone discovered a method of accessing the OpenOffice Smarttags functionality from OO BASIC?

https://www.openoffice.org/api/docs/common/ref/com/sun/star/smarttags/module-ix.html
Apache OpenOffice 4.1.7 on Xubuntu 20.04.1 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31448
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice Smarttags

Postby RPG » Sun May 15, 2016 9:15 am

Hello

Did you have found this: Writer/Smart Tags - Apache OpenOffice Wiki.

I did never heard about the smart tags.

Romke
Last edited by RPG on Sun May 15, 2016 9:58 am, edited 1 time in total.
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2196
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: OpenOffice Smarttags

Postby RoryOF » Sun May 15, 2016 9:50 am

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.
Apache OpenOffice 4.1.7 on Xubuntu 20.04.1 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31448
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice Smarttags

Postby hanya » Fri May 27, 2016 7:10 pm

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.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: OpenOffice Smarttags

Postby RoryOF » Fri May 27, 2016 7:13 pm

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.
Apache OpenOffice 4.1.7 on Xubuntu 20.04.1 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31448
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice Smarttags

Postby hanya » Fri May 27, 2016 7:46 pm

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.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: OpenOffice Smarttags

Postby hanya » Fri May 27, 2016 9:17 pm

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.
Attachments
SmartTagExample.oxt
Extension package contains small example of SmartTag
(2.69 KiB) Downloaded 109 times
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: OpenOffice Smarttags

Postby RoryOF » Fri May 27, 2016 9:31 pm

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.
Apache OpenOffice 4.1.7 on Xubuntu 20.04.1 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31448
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests