https://bugs.documentfoundation.org/show_bug.cgi?id=173737

            Bug ID: 173737
           Summary: UNO Add-In functions cannot set the number format of
                    their results
           Product: LibreOffice
           Version: unspecified
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: medium
         Component: Calc
          Assignee: [email protected]
          Reporter: [email protected]

Description:
A spreadsheet function implemented as a UNO Add-In (com.sun.star.sheet.AddIn)
can return numbers, text and arrays, but it cannot say how its numbers should
be shown. A function that returns a date shows its serial number, such as
46290, until the user formats the cell by hand.

Built-in and Basic functions do not have this problem: DATE() and a Basic
function returning a Date give their result a format type, so a cell in the
default format shows a date. For an Add-In, ScInterpreter::ScExternal pushes
only the value.

The case that prompted this is an extension that runs GNU Octave functions from
Calc formulas. Its results carry dates, durations, logical values and
percentages, often mixed in one array, and all of that is lost at the Add-In
boundary. The only workaround is for the extension to search the document for
its own cells and format them.

Proposal: a new struct, com.sun.star.sheet.FormattedResult, which an Add-In
returns in place of its plain value:

    struct FormattedResult
    {
        any Value;
        sequence< sequence< short > > NumberFormatTypes;
        sequence< sequence< string > > NumberFormatCodes;
    };

The types are com.sun.star.util.NumberFormat constants; the codes are format
codes with en-US keywords and take precedence over the types. Each is empty,
one entry for the whole result, or one entry per value, so each cell of an
array formula gets its own format. A format the user applied is kept.

Steps to Reproduce:
1. Install a UNO Add-In whose function returns a date as a double, for example
46290.
2. Enter the function in a cell with the default format.

Actual Results:
the cell shows 46290.

Expected Results:
the Add-In can mark the result as a date, and the cell shows 25/09/26, as a
Basic function returning a Date would.


Reproducible: Always


User Profile Reset: No

Additional Info:
A patch implementing this follows on Gerrit.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to