| View previous topic :: View next topic |
| Author |
Message |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Sat Nov 29, 2003 12:27 pm Post subject: |
|
|
I now have an elegant technique to install and remove add on menus.
You can see it here....
http://kosh.datateamsys.com/~danny/OOo/Experiments/
download the document named LibraryInstaller.
As you can see in this code, it is fairly easy to use the configuration manager to create a new hierarchy of sub menus on the AddOn menu. Also easy to remove them. In this code, I create an Apple menu and an Orange menu, both with sub menus.
What I am not having success doing is creating a new top-level menu on the menu bar. Any ideas anyone? _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Mon Dec 01, 2003 1:20 pm Post subject: |
|
|
Okay, got that working.
I can now install top level menus to the menu bar. I can also install AddOn menu items and submenus. (And remove all of the former, of course.)
All of this is done in Basic code. No need to use try to get a user to run pkgchk.
Get latest working code from here.
http://kosh.datateamsys.com/~danny/OOo/Experiments/
1. Download document.
2. Open it.
3. Click either or both Install buttons.
4. Quit out of OOo.
5. Re-launch OOo, and either or both an AddOn set of sub-menus, and/or a new top level menu appears.
Later on...
6. Click either or both Remove buttons to remove these new menus from OOo.
(Or you can hand edit your Addons.xcu file
OOo\user\registry\data\org\openoffice\Office\Addons.xcu
back to its original state.)
You'll notice that if you pick any of these menu commands, that they fire a URL to try to run a macro. If you want this to work, then be sure you create a Library named "DannysLibrary" under soffice. Then within that library, create a module named "Conversion". Then within the Conversion module, be sure there is a function....
| Code: | Sub test( cArg )
Print "|"+cArg+"|"
End Sub
|
If you study how the macro code works, you'll begin to understand how the Configuration Manager modifies the various XCU files.
These previous messages are relevant...
http://www.oooforum.org/forum/viewtopic.php?t=3754
http://www.oooforum.org/forum/viewtopic.php?t=3559
http://www.oooforum.org/forum/viewtopic.php?t=4028
to understanding the configuration manager.
So how, exactly you may ask, do you understand what you can modify in, say, the Addons.xcu file? See this file...
OOo\share\registry\schema\org\openoffice\Office\Addons.xcs
Similarly, to understand how the Recent Files List Enlarger works, see the file...
OOo\share\registry\schema\org\openoffice\Common.xcu
and its corresponding xcs file.
To understand how the UNO Connection Listener works...
OOo\share\registry\schema\org\openoffice\Setup.xcu
and its corresponding xcs file.
I hope the information in this message is helpful for others to learn how the configuration manager works, and how to install and remove Add On menus and Top Level menus.
Next, I'll be playing with modifying Toolbars from Basic code.
I'll post a more complete working example soon that shows all of the techniques working together within one document. A single button will install a Basic program and dialog box, along with both a top level and add on menu to activate the dialog and program. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
maxqnz Super User


Joined: 24 Mar 2003 Posts: 1294 Location: Te Ika a Maui, Aotearoa
|
Posted: Mon Dec 01, 2003 6:31 pm Post subject: |
|
|
Danny, I'm no coder, and won't pretend to understand half ofthis thread, but I would like to ask: Will this lead to a solution that will make it easy for non-clueful users like me to install complex macros, like the ExtendedPDF macro? At the moment, the work involved in installing such macros is probably off-putting to many users. I know enough to be able to follow the instruction given for installing the PDF macro, but if this project of yours makes integrating such macros into OOo easier, then you're going right to to the top of my Xmas card list, for sure! _________________ Noho ora mai, ka kite ano.
What Is A Pieriansipist?
OOo 2.4/XP Pro SP2 / OOo 2.3.0.1/OpenSuse 10.3 |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Tue Dec 02, 2003 7:39 am Post subject: |
|
|
| maxqnz wrote: | | Will this lead to a solution that will make it easy for non-clueful users like me to install complex macros, like the ExtendedPDF macro? |
That is the goal, and the indirect result of the code I am posting.
The more direct result (but not end goal) is to provide code for developers that illustrates how to create menus directly from Basic. Thus you will see more self-installing (and uninstalling) macros, easily distributed as documents with Install / Uninstall buttons. No need to use command line tools like pkgchk, which is a great developer tool, but not a good end user tool.
| Quote: | | I'm no coder, and won't pretend to understand half ofthis thread, but ..... At the moment, the work involved in installing such macros is probably off-putting to many users. |
This statement from a self-proclaimed end user reinforces the opinion I already held. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Didier Guest
|
Posted: Tue Dec 02, 2003 8:25 am Post subject: |
|
|
| maxqnz wrote: | | At the moment, the work involved in installing such macros is probably off-putting to many users. |
If you want to have an idea of how macro installation can be mode easier the calc2qif macro on http://www.ooomacros.org
I've implemented an install/uninstall technique based on DannyB's excellent work.
As a end-user your feedbacks on usability are very valuable for code writters ...
Didier |
|
| Back to top |
|
 |
maxqnz Super User


Joined: 24 Mar 2003 Posts: 1294 Location: Te Ika a Maui, Aotearoa
|
Posted: Tue Dec 02, 2003 11:01 am Post subject: |
|
|
| Didier wrote: | | maxqnz wrote: | | At the moment, the work involved in installing such macros is probably off-putting to many users. |
If you want to have an idea of how macro installation can be mode easier the calc2qif macro on http://www.ooomacros.org
I've implemented an install/uninstall technique based on DannyB's excellent work.
As a end-user your feedbacks on usability are very valuable for code writters ...
Didier |
Thanks, Didier, and Danny. I can follow the instructions for installing the macros, and know where to find my PATH, in both W2K and Linux, but even so, I find the idea of having to do so somewhat tedious. I can easily see that such instructions could be a little confusing, and perhaps a little scary, for some users _________________ Noho ora mai, ka kite ano.
What Is A Pieriansipist?
OOo 2.4/XP Pro SP2 / OOo 2.3.0.1/OpenSuse 10.3 |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Tue Dec 02, 2003 11:10 am Post subject: |
|
|
| Didier wrote: | | If you want to have an idea of how macro installation can be mode easier the calc2qif macro on http://www.ooomacros.org |
I am delighted to see the first of, what I believe will be many macros that are easy for end users to install, and that include direct menu commands to invoke them.
Looking at your code, I noticed several things.
In the Sub RemoveMenu, the three lines beginning with "oNewMenu" appear to be unnecessary.
I like your technique to save a config file (.ini file) in Sub SetIniFile. I may do this in the future. I may save a config file as a "spreadsheet" in order to have structure. One could save a "config" set of data, as a file named "DDPT.config", yet it be a true SXC file even though the extension doesn't indicate this.
I like how you localized strings, menu titles, etc. What might be really cold is if we can build a subroutine that localizes all text in a dialog box prior to installation. In fact, I would like to ask the user which language at Install time, rather than Run time. Then only install the specific language. It may only be possible to localize a dialog box at runtime -- which means that multiple localizations would have to be installed.
There is one concern I've had for weeks and weeks, but I've never bothered to voice it until now.
What happens when we have hundreds of add on macros, each wanting their own top level menu?
Another thing. When Apple released HyperCard in 1987, something happened. Suddenly. Overnight. There were hundreds of new downloads available as HyperCard stacks. The programming quality varied greatly. Then later on, when Visual Basic appeared on Windows (Microsoft's answer to HyperCard?) I wonder if the same phenomena happened?
I suppose it is like Setup programs installing things onto your computer. Until there were only a few fairly standard, and trustworthy installers, people had an uneasy feeling about whether the Setup (i.e. installation) procedure was very well programmed. Whether a given package would follow existing conventions. (Such conventions do not yet exist here.)
After all, there is no central control. It is just anarchy.
It would be good if all self-installing macros started the precedent of having an install dialog box that asked whether the user wants the new menu choices to be...
1. A single submenu under AddOn's, containing the new menu commands.
2. New menu commands added directly under AddOn's.
3. A new top level menu containing the new menu commands.
If the earliest self installing macros exhibit good behavior on end user's systems, then macros which follow are more likely to do so. Partly because users will demand that the good example of others be followed, and partly because there will be abundant example code to copy & paste that exhibits the good-citizen behavior.
There are other "installer" issues I would like to explore.
1. Icons on menu items! This may prove to be a tough nut to crack without using pkgchk. But we'll see.
2. Manipulating toolbars. I can't tell you how excited I was yesterday to have Basic code that added a top level menu and then removed it. I'm sure doing Toolbars, or merely toolbar buttons will be similarly exciting. At this point, I suspect that yourself and others can figure out the toolbars by looking at the Addons.xcs file. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Didier Guest
|
Posted: Wed Dec 03, 2003 7:38 am Post subject: |
|
|
| DannyB wrote: | Looking at your code, I noticed several things.
In the Sub RemoveMenu, the three lines beginning with "oNewMenu" appear to be unnecessary. |
You're right, it seems my code need some clean-up...
| DannyB wrote: |
[..]It would be good if all self-installing macros started the precedent of having an install dialog box that asked whether the user wants the new menu choices to be...
1. A single submenu under AddOn's, containing the new menu commands.
2. New menu commands added directly under AddOn's.
3. A new top level menu containing the new menu commands.
If the earliest self installing macros exhibit good behavior on end user's systems, then macros which follow are more likely to do so. Partly because users will demand that the good example of others be followed, and partly because there will be abundant example code to copy & paste that exhibits the good-citizen behavior. |
I fully agree with you, I was already thinking about offering the choice between MenuBar and Addon for menu implementation at installation.
Regarding good practices I'm also planning to add an "Uninstall" submenu item, so that the macro could be removed at any time without the need of the original installation file.
So for the next version I plan to implement:
- menu location choice (Top MenuBar, Addon single menu, Addon menu commands, Toolbar?)
- Uninstall submenu item
- Usage of your InstallerLibrary procedures for standardisation
If you have any other suggestions they are welcome.
Didier |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Wed Dec 03, 2003 8:06 am Post subject: |
|
|
| Didier wrote: | | You're right, it seems my code need some clean-up... |
You should see some of the code I posted last summer that I just commented on in another thread about Calendars.
| Didier wrote: | | Regarding good practices I'm also planning to add an "Uninstall" submenu item, so that the macro could be removed at any time without the need of the original installation file. |
I had thought about that one too. I didn't know if it was possible to do, and I have not had time to try it. Can you delete a library which has code that is actively executing?
Maybe you could create a new document, move a module into the macros under that document and then transfer execution to there, and then that untitled document's newly created macro code deletes the menu items and soffice library modules. But then how does this untitled document go away? Maybe if you just create it Hidden and leave it hanging around until the user quits OOo? But what if they leave OOo open for weeks at a time as I do on Linux at home? I would hate to have a small invisible untitled document hanging around. Can a macro from within a document close the document that contains it?
| Didier wrote: | | So for the next version I plan to implement: |
Excellent. Very cold!
| Didier wrote: | | If you have any other suggestions they are welcome. |
And vice versa, of course. Please alter, augment, improve, add to the library installer routines and post them. No reason I should develop such a thing alone.
I may get distracted from the task at hand to work on the Calendar thread. It is that time of year. There is probably some interest there by others, and I had neglected to think of it earlier. Although I did put up a random Christmas tree generator on OOoMacros.org in plenty of time.
Where I am at, or left off, is I have written routines in Basic that do Base64 Encode and Decode according to RFC 1521. If you want to see them, in their current state, go to my sig, go up to the OOo directory, get DannysLibrary, then look in the OOoLib library, in the General Utils module, towards the bottom. The idea is to take a binary file of a bitmap, Base64 encode it as printable text, that can be included in a Basic subroutine that reconstructs an arbitrary binary string in order to plug the binary icon value into the right place in the configuration data to give you icons for your menus. (How's that for a run on sentence?) I still need a few more subroutines to do the heavy lifting.
The technique you use to save an ini file, which I described using a spreadsheet for structure, could be written up and documented. This could be a useful technique in the toolbox of anyone building a macro installer. The more I think about it, I think I may grow to prefer this technique to the way that Xray, for example, stores its "configuration data" as a set of special "functions" in an XrayDyn module. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
MartinWBrown General User

Joined: 26 Nov 2003 Posts: 27
|
Posted: Thu Dec 04, 2003 12:23 am Post subject: Scope of function and variable names |
|
|
Hi,
Further to the subject of "well-behaved macros"; are macro function and variable names global? There doesn't seem to be a mechanism for resolving names to the local library if other libraries are loaded. This would imply that all function and variable names should be prefixed with something unique to that macro. Or does Starbasic have a mechanism for dealing with this?
Thanks
Martin |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Dec 04, 2003 12:44 am Post subject: |
|
|
| DannyB wrote: | | I had thought about that one too. I didn't know if it was possible to do, and I have not had time to try it. Can you delete a library which has code that is actively executing? |
I'll try, I don't know what happens in this case ...
| DannyB wrote: | | Can a macro from within a document close the document that contains it? |
Yes, here is the code from Andrew Pitonyak document (AndrewMacro.sxw) to close a document without saving:
| Code: | oDocument = StarDesktop.getCurrentComponent
If HasUnoInterfaces(oDocument, "com.sun.star.util.XCloseable") Then
oDocument.close(true)
Else
oDocument.dispose
End If |
I've tested it in my installer to close the installation document when installation is done. |
|
| Back to top |
|
 |
avantman42 Super User


Joined: 28 Jul 2003 Posts: 760 Location: Staffordshire, UK
|
Posted: Thu Dec 04, 2003 4:10 am Post subject: |
|
|
I've tried the installer in the file LibraryInstaller-2003-12-01-02.sxd, and I thought I'd post my experiences.
This first point isn't related specifically to this file, but I thought it's an interesting point. When installing libraries manually, .sxd files don't appear in the 'Append Libraries' dialogue box. .sxw & .sxc files do. (I haven't tried .sxi files)
Using sub InstallGlobalModule, if I only passed the cGlobalLibName parameter, no modules were installed, but the (empty) library was created. If I passed all three parameters (ie including the optional ones), it worked the first time. Interestingly, subsequent tries (after removing the library) don't seem to work. It just creates an empty library.
I've managed to remove a module, but I can't remove the library using these routines. Am I missing something?
On a positive note, the code to add/remove items to the Add-In menu works a treat, every time. I haven't tried adding top-level menus.
Russ _________________ Users reporting "the thingy-wotsit went bing"? Panic over |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Thu Dec 04, 2003 6:33 am Post subject: |
|
|
| Anonymous wrote: | | Yes, here is the code from Andrew Pitonyak document (AndrewMacro.sxw) to close a document without saving: |
Closing a document without saving is one thing, and an easy one. Closing a document that contains the currently running macro is what I'm talking about. Is it possible?
Closing the desktop's current component is still not necessarily closing the document that the macro is running from.
Is it possible to close "ThisComponent" ? I believe that ThisComponent would always be the document the macro is running from.
What I would be looking for is definitive experimental evidence that you can either...
1. close the document that contains the currently executing macro
2. delete a global soffice library (or just a module) that contains the currently executing macro. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 4021 Location: Lawrence, Kansas, USA
|
Posted: Thu Dec 04, 2003 6:38 am Post subject: |
|
|
| avantman42 wrote: | | When installing libraries manually, .sxd files don't appear in the 'Append Libraries' dialogue box. .sxw & .sxc files do. (I haven't tried .sxi files) |
That is an interesting new fact. I never use the Append Libraries dialog box, and so have never noticed this.
| avantman42 wrote: | | I've managed to remove a module, but I can't remove the library using these routines. Am I missing something? |
You may not be missing anything. My code simply may not work to do this. It is not extensively tested. (Which is why it is in my Experimental.)
The InstallGlobalModule, when given only the global library name tries to install all modules of a library of the same name from the document into that global libarary name. Was that clear? Maybe it just doesn't work with only one parameter (a bug)? _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|