List Info

Thread: Is there an example for packaging macros as an extension somewhere




Is there an example for packaging macros as an extension somewhere
user name
2007-07-13 03:43:31
Hi Samuel,
>>
>> > It is even packaged as an extension
>> >
>> > http://wiki.services.openoffice.org/wiki/Extensions_
Packager
>> >
>> > So, imho, it is the way to go. Just enhance
it
>>
>> Thank you for this hint. I did install the
extension, but do not see any
>> add-on-entry, nor an entry on the export drop-down
(neither in the OOo
>> Basic IDE, nor in the document's file menu). So I
assume that I am
>> overseeing the obvious.
>
> If you installed the extension there should be a new
button somewhere
> on the toolbar. i think for me it was top left-hand
corner near the
> new document button.
Yes, thank you!

After reading the text you pointed me to and looking once
more to the
BasicAddonBuilder I finally looked through the "View
-> Toolbars" and
saw there was a Basic Addon Toolbar, which I found
afterwards, and as
you write, consists of one entry.

In the meantime I looked over the code which is really
impressive ans
shows the high command Paolo has gained over that area of
OOo!

Unfortunately, at the moment it would be a little bit too
much time
consuming research effort to try to extend it to cater
generically for
all macro languages that happen to be installed on the
system.

Things like:

    * how to get a list of the installed macro languages,
          o what is the exact spelling of a macro language
(E.g. "java"
            vs. "Java"),
          o what is the URL to indicate a specific macro
from a specific
            macro language should be used (with or without
arguments),
    * how to get a list of existing macro libraries
          o "user-home"/user/Scripts
          o "shared-hoome"/shared/Scripts
    * how to get a list of
          o existing macro files (in the Python case there
are macros
            right in "./Scripts/python", i.e., the
home of macro
            language directory contains already scripts.

These questions are probably easy to answer by those in the
know, which
would help save quite some research time. (Maybe someone who
knows could
just give hints/pointers where to look into?)

Once this knowledge is available, one could start to try to
generalize
the current BasicAddonBuilder to become a true
"MacroAddonBuilder" (like
having a choice for the desired macro language initially,
and maybe even
allow to pick any macro from any macro language to execute,
if a toolbar
button or menu option got chosen)?

Regards,

---rony

Re: Is there an example for packaging macros as an extension somewh
user name
2007-07-14 09:36:00
Hello Rony,

Alle 10:43, venerd́ 13 luglio 2007, Rony G. Flatscher ha
scritto:
[...]
> After reading the text you pointed me to and looking
once more to the
> BasicAddonBuilder I finally looked through the
"View -> Toolbars" and
> saw there was a Basic Addon Toolbar, which I found
afterwards, and as
> you write, consists of one entry.

In effect the small toolbar is not easily visible because it
initially appears 
docked in the top-left corner. I'll put it floating in a 
next version of the package


>
> In the meantime I looked over the code which is really
impressive ans
> shows the high command Paolo has gained over that area
of OOo!
>
> Unfortunately, at the moment it would be a little bit
too much time
> consuming research effort to try to extend it to cater
generically for
> all macro languages that happen to be installed on the
system.
>
> Things like:
>
>     * how to get a list of the installed macro
languages,
>           o what is the exact spelling of a macro
language (E.g. "java"
>             vs. "Java"),
>           o what is the URL to indicate a specific
macro from a specific
>             macro language should be used (with or
without arguments),
>     * how to get a list of existing macro libraries
>           o "user-home"/user/Scripts
>           o "shared-hoome"/shared/Scripts
>     * how to get a list of
>           o existing macro files (in the Python case
there are macros
>             right in "./Scripts/python",
i.e., the home of macro
>             language directory contains already
scripts.
>
> These questions are probably easy to answer by those in
the know, which
> would help save quite some research time. (Maybe
someone who knows could
> just give hints/pointers where to look into?)

All these information are accessible through the singleton:
"com.sun.star.script.browse.theBrowseNodeFactory"

I've put a basic example at the end of this post.
Copy the source in your StarBasic IDE and run the first
macro.
It should create a spreadsheet with a hierarchical list of
the macros for all 
supported languages. (it may take some time...)

>
> Once this knowledge is available, one could start to
try to generalize
> the current BasicAddonBuilder to become a true
"MacroAddonBuilder" (like
> having a choice for the desired macro language
initially, and maybe even
> allow to pick any macro from any macro language to
execute, if a toolbar
> button or menu option got chosen)?


All the necessary code is (more or less) already in the
BasicAddonBuilder, but 
I've deliberately limited the choice to Starbasic only. Not
only, I've used 
the old style macro URL's in the generated addons.xcu.
("macro:" protocol 
instead of the new and language agnostic
"vnd.sun.star.script:" protocol)

This is because in my first experiments I got errors trying
to install an 
addons.xcu with commands specified with the
"vnd.sun.star.script:" protocol.

Anyway I think that it would be possibile (even if not so
trivial) to make the 
BasicAddonBuilder language agnostic, removing limitations to
basic only that 
I've introduced, but this would work only in the scripting
domain, and not 
for deployng UNO components.
A more generic solution was suggested from Mathias Bauer in
this post:
http://extensions.openoffice.org/servlet
s/ReadMsg?list=dev&msgNo=513

Until now I was oriented in this direction, but I'm open to
any suggestions 
and contributions.
But, before to add new features I would like to finish my
todo list:
- Localization of UI items in the generated Addons.xcu 
- Versioning support
- Licensing support
- Dependances support

and I really need help for the first entry! 
I've posted my question here some days ago but I didn't
receive any reply 
http://api.openoffice.org/servlets/ReadMsg?li
st=dev&msgNo=17858

Perhaps my question was not well explained?

ciao
Paolo M

-------------------------8<-------------------------


REM  *****  BASIC  *****

Dim oSheet As Object
Dim iRow As Integer

sub BrowseMacrosExample
  oDoc = StarDesktop.loadComponentFromUrl( _
   
"private:factory/scalc","_default",0,Arr
ay())
  oSheet = oDoc.Sheets(0)
  
  oBrowseNodeFactory = GetDefaultContext.getValueByName( _
   
"/singletons/com.sun.star.script.browse.theBrowseNodeFa
ctory")
    
  iViewType = _
   
com.sun.star.script.browse.BrowseNodeFactoryViewTypes.MACROO
RGANIZER
  aMasterProviders() =
oBrowseNodeFactory.createView(iViewType).ChildNodes()
  
  iLevel = 0
  iRow = 0
  For Each oMasterProvider in aMasterProviders()
    oSheet.getCellByPosition(iLevel, iRow).String =
oMasterProvider.Name
    PrintChildNodes(oMasterProvider, iLevel+1)
    iRow = iRow+1
  Next oMasterProvider

end sub

Sub PrintChildNodes(oParent, iLevel)
On error resume next
  For Each oChild In oParent.ChildNodes()
    iRow = iRow+1
    oSheet.getCellByPosition(iLevel, iRow).String =
oChild.Name
    If HasUnoInterfaces(oChild,
"com.sun.star.beans.XPropertySet") Then
      If
oChild.PropertySetInfo.hasPropertyByName("URI")
Then
        oSheet.getCellByPosition(iLevel+1, iRow).String =
oChild.URI
      End If
    End If    
    If oChild.hasChildNodes() Then
      PrintChildNodes(oChild, iLevel+1)
    End If
  Next oChild

End Sub



------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )