OpenOffice Smarttags

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

OpenOffice Smarttags

Post 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
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: OpenOffice Smarttags

Post by RPG »

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 7.1.4.2 on openSUSE Leap 15.2
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice Smarttags

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: OpenOffice Smarttags

Post 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.
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
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice Smarttags

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: OpenOffice Smarttags

Post 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.
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

Post 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.
Attachments
SmartTagExample.oxt
Extension package contains small example of SmartTag
(2.69 KiB) Downloaded 306 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
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: OpenOffice Smarttags

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply