Page 1 of 1

Calendar date extension for Calc - Update to version 2.60

Posted: Wed May 26, 2021 2:22 pm
by ggeerits
 Edit: This topic is a continuation of two earlier topics:
Example: Calendar date selection dialog
Update for Calendar.ods
-- MrProgrammer, forum moderator 
The Calendar.ods spreadsheet has been replaced with an extension:

- OpenOffice:
ggCalendar-260-OO.oxt
(43.85 KiB) Downloaded 585 times
- LibreOffice:
ggCalendar-260-LO.oxt
(48.73 KiB) Downloaded 573 times
Calendar Help is located in the help menu of OpenOffice / LibreOffice

Version 2.60
- Change and save settings.
- Frame around date in calendar when mouse hovers over them.
- Remove all date buttons at once (created since version 2.60).
- Make a choice via menu Tools - Add-Ons.

Version 2.50
- If the cell already contains a date, the date picker will open with the existing date, otherwise with the current date
(only for cells associated with date buttons and one or more selected cells in a continuous range).
- It is possible to change the year by 1 or 10 years forward or backwards. The year can also be entered.
- The months can also be selected from a list.
- It is no longer possible to place multiple buttons on 1 cell.

Toolbar buttons:
- Date: the date will be inserted in the selected cell / cells.
- Date <-Button: A button is created in the selected cell, the date is inserted in the cell to the left of the button.
- Button-> Date: A button is created in the selected cell, the date is inserted in the cell to the right of the button.

The calendar automatically places itself under the button.

Install the extension with the Extension Manager.

Re: Calendar extension

Posted: Wed Jun 02, 2021 7:48 pm
by JohnSUN-Pensioner
You should add a check after each .getCurrentSelection. Current Selection does not have to be a cell or a range. It can be, for example, a graphic element on a sheet. See chapter 6.5. Selected text, what is it?

Re: Calendar extension

Posted: Wed Jun 02, 2021 8:12 pm
by Villeroy
There is always one active cell for a controller independently from the current selection:

Code: Select all

Function getActiveCell(oView)
Dim as1(), lSheet&,lCol&,lRow$, sDum as String,bErr as Boolean
   as1()  = Split(oView.ViewData, ";")
   lSheet = CLng(as1(1))
   sDum = as1(lSheet +3)
   as1() = Split(sDum, "/")
   on error goto errSlash
      lCol = CLng(as1(0))
      lRow = CLng(as1(1))
   on error goto 0
   getActiveCell = oView.Model.getSheets.getByIndex(lSheet).getcellByPosition(lCol,lRow)
exit Function
errSlash:
   if NOT(bErr) then
      bErr = True
      as1() = Split(sDum, "+")
      resume
   endif
End Function

Re: Calendar extension

Posted: Thu Jun 03, 2021 6:14 am
by JohnSUN-Pensioner
Yes, but Geert Geerits announced that the date will also be inserted into the range of selected cells.

By the way, more than 10 years have passed since you posted this code on this forum (and UROS published it even earlier), and the getActiveCell method did not appear in the API. (It's already been 10 years ?! :shock: )

Re: Calendar extension

Posted: Thu Jun 03, 2021 1:34 pm
by Villeroy
I posted the function 13 years ago to this forum copied from the old oooforum.org. It might be 15 or 16 years old.

May this snippet help to write a bullet proof selection macro:

Code: Select all

view = ThisComponent.getCurrentController()
oSel = view.getSelection()
If oSel.supportsService("com.sun.star.sheet.SheetCellRanges") then
	oEnum = oSel.createEnumeration()
ElseIf oSel.supportsService("com.sun.star.sheet.SheetCellRange") then
	oEnum = oSel.queryIntersection(oSel.getRangeAddress).createEnumeration()
else
	oSel = getActiveCell(view)
	oEnum = oSel.queryIntersection(oSel.getRangeAddress).createEnumeration()
endif
while oEnum.hasMoreElements()
	oNext = oEnum.nextElement()
	' do_stuff
wend
If the selection is a multiple range selection, create an enumeration of single ranges.
If it is a single range, create an enumeration with this range as only member.
If it is not anything like that (an object selection), get the active cell and create an enumeration with this range as only member.
Then loop throught the enumeration calling working routine.

Re: Calendar extension

Posted: Thu Jun 03, 2021 1:47 pm
by Bidouille
Hello,

I suggest some enhancements. :)
Text localisation is not effective on tooltip buttons and "Today" button.
These 3 buttons on toolbar are not present as items in Insert menu
When I hit "Date" button on a cell contains a specific date, dialogbox not remains this date (always on today's date).

Re: Calendar extension

Posted: Thu Jun 03, 2021 1:51 pm
by JohnSUN-Pensioner
Yes, and this is not the only remark. Perhaps they should be collected in one place - either here or there.

Re: Calendar extension

Posted: Thu Jun 03, 2021 2:01 pm
by Bidouille
We must be sign in to do this :(

And this thread should be moved in dedicated section ;)
 Edit: Done on 2021-06-06 by MrProgrammer 

Re: Calendar date extension for Calc

Posted: Thu Jun 10, 2021 7:29 am
by ggeerits
There is an update of the date-picker calendar to version 2.50.
See the first message.

Re: Calendar date extension for Calc - Update to version 2.5

Posted: Thu Jun 10, 2021 3:43 pm
by JohnSUN-Pensioner
Yes, that's much better.

Re: Calendar date extension for Calc - Update to version 2.5

Posted: Sun Jun 13, 2021 2:10 pm
by JeJe
What I do with these things is use the mouse inside event to position a frame around (or other method of indication) to show which date is going to be clicked on.

Re: Calendar date extension for Calc - Update to version 2.5

Posted: Mon Jun 21, 2021 8:32 am
by ggeerits
JeJe wrote:What I do with these things is use the mouse inside event to position a frame around (or other method of indication) to show which date is going to be clicked on.
Thanks for the tip.
There is an update to version 2.60.