Modules vs. BASIC number format codes
Devansh Varshney
varshney.devansh614 at gmail.com
Mon Apr 14 16:50:42 UTC 2025
Hi Olivier, Eike, All,
Thanks, Olivier, for pointing out this documentation discrepancy between
the general number format codes and the Basic Format() function regarding
the number of sections. And thanks, Eike, for clarifying the current
implementation detail that causes this difference (use of SvNumberFormatter
vs. the specific handling in SbxBasicFormater for predefined formats).
This discussion is highly relevant as this exact inconsistency is something
we are actively working to resolve in tdf#143193 - Clean up Basic 'Format'
implementation.
[Link to the bug: https://bugs.documentfoundation.org/show_bug.cgi?id=143193
]
The goal of this task is precisely to refactor SbxValue::Format to remove
the legacy SbxBasicFormater (which Eike mentioned) and rely solely on the
standard SvNumberFormatter for all applicable cases handled by Basic's
Format.
A patch is currently under review ([Link to Gerrit:
https://gerrit.libreoffice.org/c/core/+/183575]). Feedback or review on the
patch would be welcome :)
Once tdf#143193 is merged, the documentation for Basic's Format() function
will indeed need updating to reflect the unified behavior, aligning it
more closely with the general number formatting rules.
On Mon, 14 Apr 2025 at 20:44, Eike Rathke <erack at redhat.com> wrote:
> Hi Olivier,
>
> On Thursday, 2025-04-10 10:08:10 -0300, Olivier Hallot wrote:
>
> > For modules we have
> > "Number format codes can consist of up to four sections separated by a
> > semicolon (;)."
> >
> > https://help.libreoffice.org/latest/en-US/text/shared/01/05020301.html
> >
> > But for BASIC we have for function Format()
> >
> > "A format code can be divided into three sections that are separated by
> > semicolons. The first part defines the format for positive values, the
> > second part for negative values, and the third part for zero. If you only
> > specify one format code, it applies to all numbers."
> >
> >
> https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03120301.html
> >
> > Both <modules> and BASIC share much common formats so is there a reason
> for
> > the difference (to be documented) or this difference is a mistake?
>
> It depends ... if the format code is not (does not contain) one of the
> "Predefined format" strings (or maybe other formats specifically
> handled) then the general number formatter is used, for which there is
> no difference regarding the number of sub-format sections. It is four
> possible sub-formats. For "Predefined format" placeholders it is three
> possible sub-format sections.
>
> For implementation see basic/source/sbx/sbxscan.cxx SbxValue::Format()
> and (via BasicFormatNum()) basic/source/sbx/sbxform.cxx
> SbxBasicFormater::BasicFormat()
>
> Eike
>
> --
> GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563
> 2D3A
>
--
*Regards,*
*Devansh*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20250414/ca673681/attachment.htm>
More information about the LibreOffice
mailing list