OOBasic Date Picker dialog

Creating Extension - Shared Libraries
Forum rules
For sharing working examples of macros / scripts. These can be in any script language supported by OpenOffice.org [Basic, Python, Netbean] or as source code files in Java or C# even - but requires the actual source code listing. This forum is not for asking questions about writing your own macros.

OOBasic Date Picker dialog

Postby JeJe » Fri Nov 25, 2016 2:17 am

OOBasic Date Picker dialog

version 25 11 16 (trivial update spelled Calendar wrong in title ha)
version 25 11 16.2 Put in different library as per comments below
version 25 11 16.3 Put in loadlibrary
version 25 11 16.4 Moved mouseover frame to front
Attachments
Date Picker.odt
(15.04 KiB) Downloaded 86 times
Last edited by JeJe on Fri Nov 25, 2016 9:05 pm, edited 4 times in total.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 116
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Postby RusselB » Fri Nov 25, 2016 4:57 am

Why does the .zip file contain a .odt, which is an Open Office Writer file, rather than a .oxt, which is used for extensions and add-ons?
OpenOffice 4.1.3 and LibreOffice 5.1.3.2 on Windows 7 Pro & Ultimate
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
RusselB
Volunteer
 
Posts: 3899
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: OOBasic Date Picker dialog

Postby JeJe » Fri Nov 25, 2016 12:09 pm

I wrote it for something I'm doing with Writer. You could make it an extension if you want but its intended as use-how-you-want date picker, giving you the basic code for that.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 116
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Postby Villeroy » Fri Nov 25, 2016 1:56 pm

Any ODF document is a zipped archive already. No need to zip it again.
In order to make the code more accessible, do not distribute the modules in a "Standard" library. Create a lib with a unique name. Then you can use the macro organizer to import the lib into any document or to the global container "My Macros".
Tools>Macros>Organize>Basic...
[Organize ...]
Tab libraries.
Under "Location" select MyMacros or some target document.
[Import...] point to your Date_Picker.ods

The [Export...] button creates a distributable extension (*.oxt, zip archive as well) from a selected non-Standard library.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24080
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OOBasic Date Picker dialog

Postby JeJe » Fri Nov 25, 2016 8:09 pm

Thanks for the comments. I've put it in its own library. Its too lame to be an extension on its own. The idea is someone doing some coding might want a date picker as part of their project. I couldn't find one yesterday so made my own.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 116
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Postby Villeroy » Fri Nov 25, 2016 8:33 pm

JeJe wrote:'ve put it in its own library. Its too lame to be an extension on its own.

Such extension that contains nothing but a Basic library is just a simple way to add and remove Basic code through the extension manager.
There are similar extensions for templates, auto-text, spell check dictionaries. No GUI, no component registration, just put this stuff in the profile folder where it belongs.
If you want the code beeing embedded in a document, call the library organizer select your document and import from the extension file or any document having the library
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24080
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OOBasic Date Picker dialog

Postby JeJe » Fri Nov 25, 2016 9:06 pm

Thanks for the info.
Openoffice 4.1.2
Windows 8
JeJe
 
Posts: 116
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Postby DatFrame » Thu Aug 10, 2017 1:25 am

For anyone attempting to use this date picker in their own BASIC code, I have some notes and additions that may be helpful for others:

To incorporate the Picker library into my own collection of Basic libraries I:
- created a new library called "Pickers" and named with module within it "CalM" and then copied and pasted the contents of the "CalM" from JeJe's document into the module I just created.
- exported the "PCalD" dialog from the document into the folder created for my new "Pickers" library. If you have not knowingly changed the location of the libraries in MyMacros, then these will be in the user-specific application data folder, under ".../user/basic/Pickers"
- opened the "PCalD.xdl" file in a text editor and replaced all instances of "location=document" with "location=application", and saved. Doing this will make sure that all event handles (like mouse click events) call the new "Pickers" library instead of the old one in the Writer document.
- imported the "PCalD" dialog I just edited into the the new "Pickers" library

I also made a couple code changes to improve the usability: I changed the DayClick routine so that it does not close the dialog if a blank day was clicked, and have it updating the title of the dialog so that after closing you can check the Title of the dialog to see if it was closed via a date click OR via the close (X) button.
Code: Select all   Expand viewCollapse view
sub DayClick(oEvt) 'day button click
   If oEvt.Source.Text = "" Then
      Exit Sub
   End If
   popUPCal.endexecute
   popUPCal.setTitle("Date Picked")
end sub


Code to check if the dialog was closed with the close button or not:
Code: Select all   Expand viewCollapse view
dDate = ShowDatePicker()
If popUPCal.Title = "Date Picked" Then
    MsgBox "Picker closed upon selecting " & dDate
Else
    MsgBox "Picker closed without selecting a date"
End If
LibreOffice 5.2 on Windows 10
DatFrame
 
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 2 guests