Skip to content

New documents carry a 636 KB word/styles.xml (127 built-in table styles serialized unused) #77

Description

@delmarguillen

Describe the bug

A new document containing only "ABC" is saved with a word/styles.xml of over 600 KB. 94% of it is 127 built-in table styles (Plain Table 1-5, Grid Table 1-7, List Table 1-7 and their "- Accent 1..6" variants), none of which the document uses.

From reading the code, this probably comes from CStyles(bCreateDefault) (word/Editor/Styles.js:7243), which instantiates the full default set, and Document.js:10887, which calls it for every document, so the serializer should end up writing all of them out. I may be misreading the save path, so please correct me if the origin is elsewhere. Line numbers are from sdkjs at v9.3.1-27-gab0a5cf561. For comparison, Word keeps these styles latent and only materializes the ones a document actually uses; its styles.xml for a comparable document is 33,884 bytes.

Measured (same "ABC" document, two independent products):

ONLYOFFICE Desktop Editors 8.2.0-143 (official .deb, Ubuntu 22.04) Euro-Office Lite, x2t 9.4.0.129 (Windows)
word/styles.xml uncompressed 636,797 B 636,515 B
table styles 127 (601,268 B) 127 (601,142 B)
final .docx 25,578 B 25,278 B
same document as .rtf 860,783 B n/a

In the .rtf saved by the official desktop editor, 99.6% of the file is the {\stylesheet} block (857,680 bytes, 1,651 \tsrowd occurrences).

I searched the existing issues here and in the ONLYOFFICE repositories, plus the community forum, and could not find a previous report of this, so apologies if I missed one.

Impact

In .docx the zip hides most of it (636 KB deflates to 16 KB), but formats without compression pay the full price: the same one-word document saved as .rtf is over 800 KB.

To reproduce

  1. Create a new document, type "ABC".
  2. Save as .docx, then unzip -v file.docx and look at word/styles.xml.
  3. Save the same document as .rtf and compare sizes.

Environment

Reproduced with ONLYOFFICE Desktop Editors 8.2.0 (official amd64 .deb) on Ubuntu 22.04, and with engine 9.4.0.129 bundled in Euro-Office Lite on Windows. Code references from sdkjs v9.3.1-27-gab0a5cf561. Reported downstream at delmarguillen/euro-office-lite#39.

Question

Is writing the full default table style set on every save intended, or could unused table styles stay latent as Word does? If the latter sounds acceptable as a direction, I could try to put together a patch, though you probably know better where such a change should live.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions