Date: prev next · Thread: first prev next last
2014 Archives by date, by thread · List index


I got a PM from Johnny feeling sorry that his German couldn't be profound enough to follow a lengthy course of explanations.

So it's my turn to feel sorry for taking it for given that my post could suffice. I will be more precise.

I need to explain why I consider it more expensive to control the code by the product name than by an error handler. The format change of the date *and time* controls started with LO 4.1 as far as I know. Maybe you can rely on this. But who knows at which point of time the AOO developers will decide to follow their colleagues and likewise change their API? And what about some other OpenOffices? (I don't know anything about them.)

This is the listing in question with the comments in English:

Listing 534. Initialize a date control to today’s date (works with all versions of AOO and LO).
  REM Initialize the date control.
  REM Set the initial date to TODAY.
  Dim tToday As Date
  tToday = Date()

  On Error Goto LO
  REM Try to initialize the control with a Long Integer.
  REM This is the correct format for AOO and for older versions of LO.
  oOOMEDlg.getModel().getByName("MyDateField").Date = CdateToIso(tToday)
  On Error Goto 0  'Clear the error handler.
  Goto GoOn

  LO:
  REM On Error the control is initialized using a structure.
  REM  This is the correct format for newer versions of LO.
  On Error Goto 0  'Clear the error handler to prevent an infinite loop,
                   'in case the macro runs into some other runtime error.
  Dim oToday As New com.sun.star.util.Date
  oToday.Year =  Year(tToday)
  oToday.Month = Month(tToday)
  oToday.Day =   Day(tToday)
  oOOMEDlg.getModel().getByName("MyDateField").Date = oToday

  GoOn:

Greetings
Volker

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.