[Solved] Where to find number and date format definitions?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
riddellg
Posts: 6
Joined: Mon Jan 15, 2018 5:45 pm

[Solved] Where to find number and date format definitions?

Post by riddellg »

Where can I find definitions of the number formats such as N2, N30, N75 etc?

Background - When I declare user variables as a date or number and choose a specific format strings, eg M/D/YY then the user variable gets stored in the content.xml as a text-user-field-decl (with value = number of days since 1900) and for each placement of the variable in the doc it is tagged as a text-user-field-get along with its format, the format being N2, N30, N75 etc. Eg if I choose a date format of "M/D/YY" then the format in the text-user-field-get is tagged as N30. I'm unable to find anywhere that these N2 N75 etc formats are defined. I can determine them one by one by defining them and opening up the content xml, but that's a bit tedious. Is there a spec where these formats (and hopefully their equivalent Java format patterns :) ) are defined?

thanks,
-gr
Last edited by riddellg on Mon Jan 15, 2018 11:08 pm, edited 1 time in total.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Where to find number and date format definitions?

Post by Villeroy »

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
riddellg
Posts: 6
Joined: Mon Jan 15, 2018 5:45 pm

Re: Where to find number and date format definitions?

Post by riddellg »

Thankyou!

In doing more research I also noticed there are additional constructs in the content xml in the "automatic-styles" section that define N3, N75 etc similar to the below. I had not noticed that before. Very interesting in the above link that "N75" might not mean the same thing in different documents!

Code: Select all

<number:date-style style:name="N76" number:automatic-order="true">
<number:month number:style="long" number:textual="true"/>
<number:text> </number:text>
<number:day/>
<number:text>, </number:text>
<number:year number:style="long"/>
</number:date-style>
OpenOffice 4.1 on Windows
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Where to find number and date format definition

Post by Villeroy »

Very interesting in the above link that "N75" might not mean the same thing in different documents!
ODF is one document format for arbitrary (future, yet unknown) software programs. Every implementation of the ODF standard can declare its own set of number formats. Nevertheless, they should look the same with any application.
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
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Where to find number and date format definition

Post by Lupp »

There are infinitely many different number formats based on the syntax (and the needed locale information in addition).

The style actually used in a cell and probably in many cells, is therefore not given by the very complicated direct definition, and can, on the other hand, not be given in short by an identifier known to the softawre itself. Each document has its own space of named number formats (roughly), explicitly described in the styles.xml subdocument and only referenced in the content.xml.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Where to find number and date format definition

Post by Lupp »

I did not yet clearly understand for what reason the OQ ("riddellg") was analysing the content.xml. It may be interst and curiosity, but a kind of research for actual application as well.

In the latter case the very concise code from Lising 5.38 in chapter 5.14 of the "Useful Macro Information" by Andrew Pitonyak may help a lot.
See http://www.pitonyak.org/AndrewMacro.odt, also available as pdf.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply