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

            Bug ID: 173205
           Summary: Calc: saving to ODF aborts with std::out_of_range when
                    two automatic cell styles have single-character names
                    and are used on more than one sheet
           Product: LibreOffice
           Version: 26.2.5.2 release
          Hardware: x86-64 (AMD64)
                OS: Linux (All)
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Calc
          Assignee: [email protected]
          Reporter: [email protected]

Saving a spreadsheet back to ODF aborts LibreOffice with an uncaught
std::out_of_range.
The document only needs two automatic table-cell styles whose style:name is a
single
character, both used on at least two sheets. Exporting the very same document
to XLSX,
CSV or PDF works, so the import side is fine and only the ODF export path is
affected.

I ran into this with documents produced by odfpy, which writes short automatic
style
names such as "s", "t" or "h". Such a document cannot be saved as ODF at all,
so the
file the user is working on cannot be written back.

A single character is a valid XML NCName, so the document is not malformed.

Steps to Reproduce:

1. Take the attached minimal_repro_short_style_names.ods (956 bytes, three
files in the
   zip, about 20 lines of XML), or generate it with the attached
make_minimal_repro.py.
2. Run:

       soffice --headless --norestore --convert-to ods --outdir out \
               minimal_repro_short_style_names.ods

Actual Results:

    convert .../minimal_repro_short_style_names.ods as a Calc document -> ...
using filter : calc8
    terminate called after throwing an instance of 'std::out_of_range'
      what():  basic_string_view::substr: __pos (which is 2) > __size (which is
1)
    Unspecified Application Error

The process aborts (exit code 134) and no output file is written.
Deterministic,
3 runs out of 3.

Expected Results:

The document is written to out/minimal_repro_short_style_names.ods.

Additional Information:

Variants tested with the same command line. "a", "b", "c" are the names of
automatic
table-cell styles, and unless stated otherwise every listed style is used on
every sheet:

    2 sheets, styles "a", "b"                          crash
    3 sheets, styles "a", "b"                          crash
    2 sheets, styles "a", "b", "c"                     crash
    2 sheets, styles "1", "2"                          crash
    2 sheets, styles "A", "B"                          crash
    1 sheet,  styles "a", "b"                          saved fine
    2 sheets, styles "aa", "bb"                        saved fine
    2 sheets, styles "a", "bb"                         saved fine
    2 sheets, style  "a" only                          saved fine
    2 sheets, "a" on sheet 1 only, "b" on sheet 2 only saved fine
    2 sheets, "a" on both sheets, "b" on sheet 1 only  saved fine

So it takes at least two single-character automatic cell style names, each used
on at
least two sheets. style:display-name, table styles, row and column styles,
master pages,
column definitions and the cell text itself make no difference.

The same exception also reaches the UNO API. With a real-world document
generated by
odfpy (attached as odfpy_two_sheets_repro.ods, two sheets, contents
anonymized), a
freshly loaded document in a headless instance throws on both
XStorable::store() and
XStorable::storeToURL() with FilterName calc8:

    com.sun.star.uno.RuntimeException: C++ code threw St12out_of_range:
    basic_string_view::substr: __pos (which is 2) > __size (which is 1)

With a larger workbook of the same origin (13 sheets) store() succeeded while
storeToURL() threw, and in a GUI session a first save succeeded while a later
save of
the same in-memory document threw. The command line conversion is therefore the
most
reliable trigger, not the only one.

Version: LibreOffice 26.2.5.2 620(Build:2), openSUSE Tumbleweed 20260815,
x86_64,
package libreoffice-calc-26.2.5.2-1.1. Other versions not tested.

No backtrace attached, the machine has no LibreOffice debug symbols installed.
I can
install debuginfo and provide one if that would help.

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

Reply via email to