OOBasic Date Picker dialog

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 section is not for asking questions about writing your own macros.
Post Reply
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

OOBasic Date Picker dialog

Post by JeJe »

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 928 times
Last edited by JeJe on Fri Nov 25, 2016 9:05 pm, edited 4 times in total.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: OOBasic Date Picker dialog

Post by RusselB »

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.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
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.
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Post by JeJe »

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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OOBasic Date Picker dialog

Post by Villeroy »

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 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Post by JeJe »

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.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: OOBasic Date Picker dialog

Post by Villeroy »

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 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: OOBasic Date Picker dialog

Post by JeJe »

Thanks for the info.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
DatFrame
Posts: 10
Joined: Mon Feb 20, 2017 10:39 pm

Re: OOBasic Date Picker dialog

Post by DatFrame »

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

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

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