Commit Graph
2253 Commits
Author SHA1 Message Date
Julien Nabet e808025d6f tdf#146404: Fix number Format Code when reopen ods/fods
As Eike indicated in https://bugs.documentfoundation.org/show_bug.cgi?id=146404#c4
COLOR format codes are preserved in ods/fods format.
The pb was the missing map back.
Indeed, we had the mapping for [COLOR<something>] => Color value (eg: "ffaa16")
but not the reverse mapping Color value => [COLOR<something>]

Eike had provided the right code pointer in xmlnumfi.cxx.
First, I thought using PaletteManager but this one is in svx and svx shouldn't be used in xmloff
(dependency pb).
Then I used ChatGpt (GPT-5.6 Luna) and it pointed the right process.
It just consisted to use a similar callback system (DECL_LINK, IMPL_LINK, LINK) of GetUserDefinedColor.

In addition, by testing all this, I noticed that maList in XColorList::GetIndexOfColor was empty.
So I added the Load call in case mbListDirty is true.

Change-Id: I0ef6b5901f2e4c757e88994412dbf79a13100ffd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210518
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
2026-09-07 10:17:29 +02:00
Tomaž Vajngerl 1d475cdae0 Keep a shape's color and its theme reference in step
The default drawing style names a theme color now, and a PPTX saved
to ODF and back came out with every shape green. A shape that really
did name a theme color lost the reference and came back plain.

A color item holds the color and the theme reference together.
Setting a plain color started from the item the shape inherits from
its style and overwrote the color alone, so the inherited reference
won. Clear the reference, which is what an explicit color means.

The ODF export repeats each shape's fill on a paragraph style,
applied after the graphic style, and the paragraph properties had no
complex color. Carry it there too.

A style's graphic properties took a complex color only when it was
the character one, matched by element name. Match on the context id,
which the fill and stroke colors share.

Add a round trip test through ODF and PPTX with a plain shape, a
themed one, and a themed one with a luminance modulation.

Signed-off-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>
Change-Id: Ia9550222d18a243287240e4184666d78d0abdd22
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10060
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 07cf37b104983f765d3e1005f677e0058df12026)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210510
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-06 21:22:35 +02:00
Noel Grandin c877de09f1 std::map->std:unordered_map in XMLPropertyHandlerFactory
This map does not need ordering. std::unordered_map is faster
and more memory-dense.
Also avoid double-lookup in GetHdlCache()

Change-Id: I0aea9eabe660b110e24dbec9ee523d217e4183f8
Signed-off-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10124
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit c2a0e2bb613e9ecae177325217cc700d6f4eb73e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210495
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-09-04 19:47:50 +02:00
Khaled Hosny ed9e0a730e tdf#172647: Respect when building embedded font URL
Without that, subfamilies that has the same weight and italic will get
the same file URL.

Change-Id: If698b137d0f9ce478bed99bbc091963b02b82619
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207553
Reviewed-by: Khaled Hosny <khaled@libreoffice.org>
Tested-by: Khaled Hosny <khaled@libreoffice.org>
2026-07-14 00:16:00 +02:00
Samuel Mehrbrodt 28c7d0a4e1 Prevent warnings "special item not handled"
Seen warnings like this:
  warn:legacy.osl:1004123:1003943:xmloff/source/style/xmlexppr.cxx:854: special item not handled in xml
  export

Empty UserDefinedAttributes / ChartUserDefinedAttributes values (VOID Any
 or null XNameContainer) trigger the warning.

Treat both as "nothing to export" and skip silently.

Change-Id: I267b35d92096ad75d0ba87939cb0d17670b72763
Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/1184
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/1452
(cherry picked from commit a92ab8433594d6010bdbbcf6771a49c2d23d1725)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207070
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-06-21 21:33:42 +02:00
Michael Stahl a50e3188a3 svx,sw,xmloff: split no-first-page-header-flag in 2
In Word only the first-page-shared flag is shared between header and
footer, while the existence of header and footer is independent.

Split into core flags `DisableFirstHeader` / `DisableFirstFooter`,
properties `HeaderNoFirst` / `FooterNoFirst` (which allows removing some
special checks as the name prefix checks now cover these).

`SectionPropertyMap::setHeaderFooterProperties()` had some special code
to turn off a header but not a footer, add that to do it consistently.

Also rename the ODF attributes, `is-first-page-header-enabled` better
describes the values than `is-first-page-header-shared`.

Signed-off-by: Michael Stahl <michael.stahl@collabora.com>
Change-Id: Ieee9cb7a8f7b4fb7e66352c95142d8ccb06f9cb5
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4383
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit a443891f1a6480421fa08c311526c1a9d4bdd642)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206703
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-18 12:17:26 +02:00
Michael Stahl de4a472a86 sw,xmloff: DOCX: improve Word page margin compatibility
The problem with not having some but not all headers enabled on a page
style is that Word does page margins differently than Writer, and this
causes `testTdf116486` and `testFdo44176` to fail.

In Writer, it's always additive: page `fo:margin-top` + header
`fo:margin-bottom` gives the spacing from the top of the page to the
body text.

In Word, there is a `w:header` (from top of page to header) and `w:top`
(from top of page to body text) and the problem is, they're not
additive, both are measured from top of page.

If all headers are enabled,
`SectionPropertyMap::PrepareHeaderFooterProperties()` can map this to
`HeaderHeight` and `HeaderBodyDistance` properties, but of course those
won't be used if there's no header on the page.

So import `w:top` as a new property "MinTopBodyDistance" (and also
"MinBottomBodyDistance") implemented as new item
`RES_FRMATR_PAGE_MIN_TOP` (and also `RES_FRMATR_PAGE_MIN_BOTTOM`).

Use it in `SwLayoutFrame::Format()` to set the page frame margins, but
only if there is no header; else rely on the existing header properties.

Export this to ODF as
`coext:min-page-margin-top` and `coext:min-page-margin-bottom`.

Signed-off-by: Michael Stahl <michael.stahl@collabora.com>
Change-Id: I9d98bbf7138c9ef04d4ab1ddcb4c3183a12d9b11
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/4310
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit e065ba01c029cd01c9128afccdc953e2e3a49e65)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206702
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-06-18 12:17:15 +02:00
Oliver Specht 5dd328effe Support of page styles without header/footer on first page
Import/export to/from docx/rtf supported.
Unit test available.

Change-Id: I12065ba4fb050d7dfc013eda704ebe2acb53c88e
Signed-off-by: Oliver Specht <oliver.specht@cib.de>
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/3580
Tested-by: Michael Stahl <michael.stahl@collabora.com>
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
(cherry picked from commit b8af8f046a098c67d7caf44dc70d1db5cabf24e2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206698
Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-18 12:17:01 +02:00
Méven Car 0b27b1bc69 xmloff: recover missing draw:fill-image from style:background-image on import
A broken ODF document may have draw:fill-image-name on the page layout
or drawing-page properties referencing a name with no matching
<draw:fill-image> element in <office:styles>. When the same page layout
also has a style:background-image with actual image data (the old
mechanism), recover the missing bitmap table entry from it.

This is done before deactivateOldFillStyleDefinitions so the
BackGraphic property indices are still valid. The recovered bitmap is
inserted into the BitmapTable so the draw:fill-image-name reference
resolves correctly, making the background image visible in the page
setup dialog (Area tab) and in Collabora Online.

Change-Id: I5c1b658621f288af026c57e69d13363fbc1fe45a
Reviewed-on: https://gerrit.collaboraoffice.com/c/core/+/1142
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Tomaž Vajngerl <tomaz.vajngerl@collabora.com>
(cherry picked from commit b370baba6ac0daa31395f47b80bc5c11cc561b1e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206429
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-06-17 16:29:17 +02:00
Caolán McNamara ae59bf7e83 process loext:blank-width-char better
Change-Id: Iea005facd85443091c5144a0a0f8f15fa995dbf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203576
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2026-04-15 12:39:27 +02:00
Noel Grandin 6993d54041 std::lround is unnecessary here
because we are then casting to a type <=32 bits

Change-Id: Ief4a93724ccbae8d697edbd40e4085389d74473f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202156
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-03-19 15:27:43 +01:00
Noel Grandin 4b10710e09 loplugin:passstuffbyref
Change-Id: I559d246b25c99e5cb7a28ba94e04a2acedd3e720
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200943
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2026-03-04 19:22:19 +01:00
Caolán McNamara ba2fb4af99 ofz#421997573 Timeout
clip nNumDisplayLevels import like export does in
SvxXMLNumRuleExport::exportLevelStyle

Change-Id: I1ddc49a9c70155b9ac6f218cc9d453c36302302f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200732
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2026-03-02 09:12:01 +01:00
Gabor Kelemen 0a42ddbdf1 tdf#146619 Use more forward declarations in include/xmloff
Change-Id: I49e39d669ba77a99b77322275d2e54e211da5b11
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199386
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
2026-02-22 10:42:36 +01:00
Laurent Balland fb07ca38af tdf#170670 NumberFormat: fix blank width string treatment
In case of 2 characters string text,
with a delimiter as text and a blank width string like
"-"_)
the delimiter is now treated as text

Add qa test with format of bug report:
[>0]#,##0_);[<0](#,##0);"-"_)

Change-Id: Idd4542bd186c6b6b348f6716bee2fd5055f2c83f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199314
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2026-02-15 18:22:33 +01:00
Gabor Kelemen 0bdcfc2900 tdf#146619 Use more forward declarations in include/unotools/
This shaves off some 40M of input

Change-Id: I12e10deb87ceea1f7a23f3de4ea624befe187c3f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198238
Reviewed-by: Gabor Kelemen <gabor.kelemen@collabora.com>
Tested-by: Jenkins
2026-02-05 17:35:46 +01:00
Karthik 513bfbd476 Writer: Adapt 'SvxAutoFormat'
Adapt Writer to use new 'SvxAutoFormat' and retire Writer specific
'AutoFormat' dialog and preview.

Change-Id: I272ff0d4415d9f13402374c8ad7b6721ed749931
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190027
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
2026-02-04 14:02:26 +01:00
Noel Grandin 38b239c8bc mso-test: import data has bad percentage value
found by converting tdf34406-1.odp to pptx and running officeotron on the output

INFO - Validating part "/ppt/slides/slide4.xml" using schema "29500T/pml.xsd" ...
ERROR      - (slides/slide4.xml:2 col:24,296) cvc-datatype-valid.1.2.3:
'-4900000' is not a valid value of union type 'ST_PositiveFixedPercentage'.

The import data in content.xml looks like:

  <style:style style:name="ce8" style:family="table-cell">
    <style:graphic-properties draw:fill="solid" draw:fill-color="#808080"
      draw:opacity="-4900%"

where the opacity value is wildly out of range. So validate on input.

Change-Id: I1d9146a3f38f975a5e229f63e17fca6fb435439b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194950
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Stahl <michael.stahl@collabora.com>
(cherry picked from commit 80c58f15baf79f19b954b1199cbca9c2f3dcf8bf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194952
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-12-03 12:50:56 +01:00
Jonathan Clark 5d1b2baaa9 tdf#118350 [API CHANGE] Implement start and end paragraph alignment
Implements support for ODF fo:text-align start and end in paragraph
styles. The new alignment options can be selected in the paragraph
dialog. Further user interface changes are tracked as separate bugs.

This change also adds START and END to css.style.ParagraphAdjust, which
is flagged as an incompatible UNO API change.

Change-Id: I2ee57f0029de7b794bc1ecd3eddbbd90af5dfdb9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192932
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2025-10-24 13:07:10 +02:00
Jonathan Clark a01051d04a tdf#37128 xmloff: remove incorrect emit of start/end for ParagraphAdjust
Currently, we do not correctly implement fo:text-align "start" or "end".
Support for these attribute values is faked at the parser level by
always treating "start" to mean "left", and "end" to mean "right".

In addition to this, previously, the ODF serializer always printed
"start" for left alignment, and "end" for right alignment. This behavior
is harmless for documents that only contain LTR paragraphs, but mirrors
the alignment of all RTL paragraphs per the ODF standard. Other programs
cannot view these documents as intended.

This change updates the ODF serializer to instead print "left" for left
alignment, and "right" for right alignment, reflecting our actual
document layout.

Change-Id: I3a1134924f4adf71b7a0ea3f672e8c1580770841
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192858
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2025-10-24 11:49:56 +02:00
Caolán McNamara 8c93dc9f99 add extra pdf shape fonts to export
extract a separate XMLFontAutoStylePool::addModelFonts
and reuse it to add additional fonts

Change-Id: Id08b185baaca9fd38ca24e2284b27a74ef8eacfb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192438
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-10-17 23:00:01 +02:00
Caolán McNamara 3a38bcbc8a we surely mean name-[asian/complex] and not weight-[asian/complex]
Change-Id: Ib1adf05c1e39f23dddb777473123fc1db565c41b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192395
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-10-14 20:37:29 +02:00
Caolán McNamara 2df2cf1b6e ofz: attempt to get abs of -2147483648
What is actually reported is Use-of-uninitialized-value but I don't see
a problem of an uninitialized value. But I do see that nVal is -2147483648
so presumably that's the actual problem.

Change-Id: I9e5bdcb0e8fdfc6274888c1d7f1c94a65a8613d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192238
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-10-12 16:47:15 +02:00
László Németh 45ec7bd761 tdf#168251 cui offapi xmloff sw glyph scaling: extend UNO/UX/ODF
Add new paragraph justification options "Minimum glyph scaling"
and "Maximum glyph scaling" to improve typography, like DTP software
do, allowing to typeset visually better paragraphs, especially narrow
columns without unacceptably big word spacing.

* Add spin boxes to Alignment in paragraph formatting dialog window;

* Store properties in paragraph model:

  css::style::ParagraphProperties::ParaPropScaleWidthMinimum

  css::style::ParagraphProperties::ParaPropScaleWidthMaximum

  Note: desired glyph scaling is already supported by ODF/UNO,
  see css::style::CharacterProperties::CharScaleWidth.

* Implement visual layout of minimum and maximum glyph scaling,
  limited by the available extra word spacing and letter spacing,
  too.

  Note: last line can exceed the paragraph width, because minimum
  glyph scaling, also minimum letter scaling of the last line
  haven't been applied there, yet.

* Add ODF import/export (loext:text-scale-maximum and
  loext:text-scale-minimum, where style:text-scale is for the
  desired text scaling).

* Add ODF unit test.

Note: hyphenated lines, lines with multiple portions haven't
been using custom glyph scaling, yet.

Note: resolution of glyph scaling is 1 percent, which will
avoid of overgeneration of font types using variable fonts.

Change-Id: I9b4576dde4303437b64e37202c47f888f94c3f67
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190534
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
2025-09-03 15:22:37 +02:00
Mike Kaganski 631b1d4917 Optimize some code that uses O(U)String::number
Use the returned object directly, instead of creating an O(U)String.
Concatenate with adjacent appends.

Change-Id: Id84563876bbb0df50d9e0bfc0b0c033630d4be81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190351
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-08-29 10:49:57 +02:00
Mike Kaganski 1f0d2531db Use RepeatedUChar in vcl and xmloff
Change-Id: I4c59d50766f6c695ae0b492f458f3ad152598020
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190345
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-08-29 06:11:54 +02:00
Caolán McNamara 7841de4bf7 drop outdated coverity directives
Change-Id: Icbe3f0bb9433cfcf08efd28bc4eab1ba82efab74
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189850
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-08-18 12:40:58 +02:00
Mike Kaganski e8d0ab587b EmbeddedFontsHelper -> EmbeddedFontsManager
It is not just a helper anymore, the rename reflects its function better.

Change-Id: I11bf130eb34ba90841b550ab2a1fd1b3d9831b72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189350
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-08-12 14:14:45 +02:00
Mike Kaganski 086f3adda1 Don't write multiple copies of identical embedded font files
Before the change, ODF import created unique font name every time,
using '?' as extra; that meant that every document with embedded
fonts would create and register its fonts, even when it was already
registered by a different document. On the other hand, OOXML import
would rely on file name match, which might not guarantee that the
files were actually identical.

This change compares the existing file content, which would only
happen when the files are of the same size. This also writes the
file only after doing all the checks.

Change-Id: I2377bd6c24291d9b4113607b4d48a223187b635c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189270
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-08-10 10:04:02 +02:00
Mike Kaganski a0ae1b0cf2 ODF embedded fonts - skip common fonts
Similar to commit 0e9091b6db
  2025-05-26
  sd: PPTX embedded fonts - skip common fonts

Tests for font embedding were modified to embed fonts not in the
common font list.

Change-Id: Ia0d95bc8be7cf6b590f8074cabe3568271ef18f9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188989
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-08-07 06:28:22 +02:00
László Németh f83a04c510 tdf#167648 cui offapi xmloff sw: add DTP-feature maximum letter spacing
Add new paragraph justification option "Maximum letter spacing"
to distribute letters on (part of) the available blank area of the
justified line instead of overstretching word spacing, like DTP
software do.

This improves typography a lot, allowing typesetting visually better
i.e. more readable paragraphs, minimizing or removing rivers and
too big word spacing (which was common in columns or text without
hyphenation).

* Add spin box to Alignment in paragraph formatting dialog window,
  (also add spin boxes for future Minimum and the alternative
  percent-based Desired letter spacing, see CharKerning);

  For example (only ASCII visualization!), 100% maximum letter
  spacing adds a space character-width blank space between the
  characters, including the original space:

  0%:

  Lorem          ipsum
  pellentesque dolores
  vitae.

  100%:

  L o r e m  i p s u m
  pellentesque dolores
  vitae.

  Normal value: 3%-5% (or more for very narrow columns), which means
  e.g. 1-2 twips (twip = 1/20 pt) letter spacing in a ~12 pt text.

  Note: resolution of the custom letter spacing is only 1 twip yet.

* Store properties in paragraph model:

  css::style::ParagraphProperties::ParaPropLetterSpacingMaximum

  css::style::ParagraphProperties::ParaPropLetterSpacingMinimum

  Note: desired letter spacing is already supported by ODF/UNO,
  see css::style::CharacterProperties::CharKerning.

* Implement visual layout of maximum letter spacing.

  Note: after the last character of the line, there is an
  unwanted letter-spacing, yet (which is visible only with
  big letter-spacing values).

* Add ODF import/export (loext:letter-spacing-maximum and
  loext:letter-spacing-minimum)

* Add ODF unit test.

Note: hyphenated lines and lines with multiple portions do not
yet use custom letter spacing, yet.

Change-Id: Ieac9f21631b90ae46bed4501f12da0d15ed84d63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188653
Tested-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
2025-08-01 11:51:04 +02:00
Noel Grandin 9b79ae1161 loplugin:blockblock
found with a modified copy of this plugin

Change-Id: Ib2ca97c7479abdf1a375e2700f9c947e1101f0e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188065
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-07-19 19:11:16 +02:00
Caolán McNamara b80cd12449 const up some more pieces
Change-Id: Ib85b8b4b3a2d00e7ef0ecb354fba0b862d60abdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187749
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-07-12 01:16:21 +02:00
Caolán McNamara 6489a5bd3b const some more things
Change-Id: Iebd34475da0d005fe3e5fee8554133b448f46cca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187617
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-07-11 22:05:47 +02:00
Justin Luth 0ad0fc985c tdf#167358 Revert "tdf#156707 xmloff import: always provide ControlBorder
... property #2"

This reverts my 25.2 commits d4dad2e181
and 5a617f77ee.

Obviously this entire thing is just too broken
for a simple guy like me to fix.

It seems like each kind of control has its own definition
of what should happen if the border is not specified.
So much for ODF standardization of default style values...

This makes it virtually impossible to force a setting at import time,
and since styles (without specified fo:borders)
could theoretically be shared between the different control types,
it might also make it impossible to force an export as well?

make CppunitTest_xmloff_style

Change-Id: I0182878a16213ad2c7f06524fe85388aae86551f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187654
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
2025-07-11 13:45:35 +02:00
Mike Kaganski 35256f5b36 Let Hash take const void* instead of const unsigned char*
It makes no sense to insist on a random type, only to reinterpret_cast
it everywhere. An opaque void fits the case perfectly.

Change-Id: If945b1c59d98c5f561350db649f29fe8036e7cdb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186982
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-06-26 06:38:59 +02:00
Simon Chenery 02eac74063 tdf#145538: Use range based for loop in prstylecond.cxx
Change-Id: Id97859d6923e02ea16ac860dff2081809870b04b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186783
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
2025-06-23 17:10:28 +02:00
Caolán McNamara b6d240c4ba ofz#426843907 Stack-overflow
Change-Id: I03f10968aaa32960bc6dfd2175a582ec1dd30918
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186815
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-06-23 12:01:09 +02:00
Mike Kaganski 31a9739f51 tdf#167018: throwing out of a dtor is fatal
The exception was thrown with this stack:

  comphelper.dll!com::sun::star::lang::IllegalArgumentException::IllegalArgumentException(const rtl::OUString & Message_, const com::sun::star::uno::Reference<com::sun::star::uno::XInterface> & Context_, const short & ArgumentPosition_, std::source_location location) Line 39
  comphelper.dll!comphelper::SequenceAsHashMap::operator<<(const com::sun::star::uno::Any & aSource) Line 151
  comphelper.dll!comphelper::SequenceAsHashMap::SequenceAsHashMap(const com::sun::star::uno::Any & aSource) Line 109
  docmodello.dll!model::Theme::FromAny(const com::sun::star::uno::Any & rVal) Line 86
  sdlo.dll!SdXImpressDocument::setPropertyValue(const rtl::OUString & aPropertyName, const com::sun::star::uno::Any & aValue) Line 2879
  xolo.dll!XMLThemeContext::~XMLThemeContext() Line 57
  xolo.dll!XMLThemeContext::`scalar deleting destructor'(unsigned int)
  xolo.dll!SvXMLImportContext::release() Line 106
  xolo.dll!rtl::Reference<SvXMLImportContext>::~Reference<SvXMLImportContext>() Line 126
  xolo.dll!SvXMLImport::endFastElement(long Element) Line 889
  saxlo.dll!`anonymous namespace'::Entity::endElement() Line 515
  saxlo.dll!sax_fastparser::FastSaxParserImpl::consume(`anonymous-namespace'::EventList & rEventList) Line 1021
  saxlo.dll!sax_fastparser::FastSaxParserImpl::parseStream(const com::sun::star::xml::sax::InputSource & rStructSource) Line 860
  saxlo.dll!sax_fastparser::FastSaxParser::parseStream(const com::sun::star::xml::sax::InputSource & aInputSource) Line 1479
  xolo.dll!SvXMLImport::parseStream(const com::sun::star::xml::sax::InputSource & aInputSource) Line 528
  sdlo.dll!`anonymous namespace'::ReadThroughComponent(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream> & xInputStream, const com::sun::star::uno::Reference<com::sun::star::lang::XComponent> & xModelComponent, const rtl::OUString & rStreamName, const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> & rxContext, const char * pFilterName, const com::sun::star::uno::Sequence<com::sun::star::uno::Any> & rFilterArguments, const rtl::OUString & rName, bool bMustBeSuccessful, bool bEncrypted) Line 226
  sdlo.dll!`anonymous namespace'::ReadThroughComponent(const com::sun::star::uno::Reference<com::sun::star::embed::XStorage> & xStorage, const com::sun::star::uno::Reference<com::sun::star::lang::XComponent> & xModelComponent, const char * pStreamName, const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> & rxContext, const char * pFilterName, const com::sun::star::uno::Sequence<com::sun::star::uno::Any> & rFilterArguments, const rtl::OUString & rName, bool bMustBeSuccessful) Line 369
  sdlo.dll!SdXMLFilter::Import(ErrCode & nError) Line 615
  sdlo.dll!sd::DrawDocShell::Load(SfxMedium & rMedium) Line 295
  sfxlo.dll!SfxObjectShell::LoadOwnFormat(SfxMedium & rMedium) Line 3611
  sfxlo.dll!SfxObjectShell::DoLoad(SfxMedium * pMed) Line 712
  sdlo.dll!sd::slidesorter::controller::Clipboard::PasteSlidesFromSystemClipboard() Line 965
  sdlo.dll!sd::View::InsertData(const TransferableDataHelper & rDataHelper, const Point & rPos, char & rDnDAction, bool bDrag, SotClipboardFormatId nFormat, unsigned short nPage, o3tl::strong_int<short,SdrLayerIDTag> nLayer) Line 711
  sdlo.dll!sd::View::DoPaste(sd::Window * pWindow, bool __formal) Line 329

Change-Id: I5eca1088c75aafd0151d778c4fc16becb1e579dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186507
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-06-15 10:48:34 +02:00
Jonathan Clark 1df13d7ff1 tdf#166012 Implemented GUI support for style:script-type
Previously, when authoring documents containing multiple languages,
certain characters (e.g. smart quotes) could use the wrong/undesired
font. For example, if a Chinese word is quoted inside English text, the
right quotation mark would use the Chinese font rather than the
intuitively-expected English font. Users had no way to control this
behavior.

With this change, Writer will now set an appropriate style:script-type
hint when the user manually specifies a language for a selection in the
user interface. This can be used to quickly correct instances of the
above problem.

Change-Id: I6f8c924d230e3518272e2abb1cbea5e0e7451e9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186394
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Tested-by: Jenkins
2025-06-12 04:54:55 +02:00
Khaled Hosny b2b31dd8be tdf#166357: Fix saving font weight to documents
Several font weights (Ultra Light, Light, and Medium) were incorrectly
saved to file.

ULTRALIGHT and LIGHT were saved as fo:font-weight 150 and 250,
respectively. But, according to ODF spec, the values of the
fo:font-weight attribute are normal, bold, 100, 200, 300, 400, 500, 600,
700, 800 or 900:

https://docs.oasis-open.org/office/v1.2/cd05/OpenDocument-v1.2-cd05-part1.html#a_20_184_fo_font-weight

This change fixes ULTRALIGHT and LIGHT to map to 200 and 300,
respectively.

This change also introduces awt::FontWeight::MEDIUM and gives it an
arbitrary 105% value (the percentage values in awt::FontWeight make no
sense at all, THIN numeric value is 100, so it should be 25% of NORMAL
whose numeric value is 400, but it is 50% in awt::FontWeight), and fix
the mapping to and from awt::FontWeight to handle medium weight
properly, and fixes the numeric weight values saved to file.

The backward compatibility for this change are likely negligible since
we don’t support extended font families on Windows, or Linux for
non-variable fonts.

Change-Id: I80ece7bb05462b0f3aceb7f39409f8135f63e94d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186128
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Khaled Hosny <khaled@libreoffice.org>
2025-06-10 18:26:22 +02:00
Jonathan Clark 0b979c50b6 tdf#166011 Implemented style:script-type
Implemented the ODF 1.0 style:script-type text property. This property
can be used by documents to influence which script type-dependent
attributes are used when rendering certain characters.

This implementation uses the following semantics:

- If unset, the behavior is as it was in previous versions.
- If set to latin, asian, or complex, those characters not mapped by the
  ODF standard to a script type are treated as latin, asian, or complex,
  respectively.
- If set to ignore, all characters will be treated as latin. This value
  is intended to be used for interoperability with file formats that
  don't implement script types (e.g. HTML).

Change-Id: If81a1390ee455fd971dea655d161d9c3f44fd08a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186309
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
2025-06-10 07:09:17 +02:00
Mike Kaganski 8ebe1e51ea Related: tdf#166627 Write font-face-src for each mention of embedded font
Before commit e61a179b4f (tdf#166627: embed
fonts everywhere we emit font data, 2025-05-23),  embedding of fonts only
happened during export of content.xml, to avoid complexity of shared data
between different instances of SvXMLExport, created separately per stream.

The said commit introduced a way to pass the data between these instances,
and embedding now is done by any SvXMLExport instance  that needs to emit
font-face-decls. Currently, only the first declaration of a used embedded
font gets its font-face-src.

But this is wrong, when the same embedded font in another stream, where it
is also used, does not reference its files.  This patch allows all streams
to emit font-face-src for all fonts used in it. File duplication in ZIP is
avoided by passing the embedded file information between SvXMLExport, with
font file hash and its path in ZIP, instead of font names.

Change-Id: I7a62e50c086d8741dbc8aadf61d0f008bad916ff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185720
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-05-23 23:58:36 +02:00
Mike Kaganski e61a179b4f tdf#166627: embed fonts everywhere we emit font data
Commit 69ed893087 (tdf#160253: fix list
identifier export decision code) made a large change to the autostyle
collection procedure, which became more precise. It turns out, that
before that change, exporting content.xml gathered autostyles from
page definitions, too, meaning that the fonts used there were marked
as used in that pass. After the change, that pass doesn't look into
the page styles and their content, and the fonts that are only used
in headers/footers aren't seen as used in that pass.

The font embedding procedure was previously implemented to only do
the embedding during content.xml export, to avoid duplicating font
files from each pass. Since each stream was exported by a separate
instance of SvXMLExport, it was considered difficult to maintain the
already embedded fonts list across all passes. It assumed that the
export of content.xml sees all used fonts.

But after the described change, this assumption doesn't hold anymore.
We need to make sure to embed all fonts found in all passes.

This change introduces such state, implemented as set of font names
maintained in the object that exports all the streams, creating an
exporter for each. Using a new set of function to set and get the
"already embedded" font list in SvXMLExport, the outer object passes
that list to each created SvXMLExport instance, and after the call
to `filter`, retrieves the updated list, to pass it to the next one.

The change required to move some members from XMLFontAutoStylePool
to SvXMLExport, to avoid additional complexity of passing the list
from SvXMLExport to XMLFontAutoStylePool. The implementations of
the moved methods are kept in XMLFontAutoStylePool.cxx, because the
internal structs used in the methods are defined there.

After the change, some of the embedded font file references, that
previously appeared in content.xml, will now be in styles.xml.

Change-Id: Iaa26f1d1d623dee5a5c43600ea5fd2af1d04b46f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185704
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-05-23 22:48:56 +02:00
Gabor Kelemen 0b71553e9a Remove obsolete fw declarations from xmloff/
found with bin/find-unneeded-includes --fwdecl

Change-Id: Ic1d7679fc60fb41df351cc849c2e35517b3f0e36
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184010
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
2025-05-23 19:36:14 +02:00
Justin Luth d4dad2e181 tdf#156707 xmloff import: always provide ControlBorder property #2
In LO 7.5, ORichTextModel changed the app default to use a flat border
(in order to better match how PDF/print looks)
while the file-spec's default for undefined borders is 3d,
so during import time we ALWAYS need to specify 3d as the border.

The patch replaces 25.2 commit 5a617f77ee
    tdf#156707 xmloff import: always provide ControlBorder property
which wasn't wrong, but just was incomplete.
It only handled the situation where there was a fo:border element
which didn't specify 3d/flat/none,
but didn't handle the situation where there was no fo:border at all
in style:graphic-properties.

[On export, since the 3d property is the default value,
fo:border is not even provided as something to be exported,
and therefore only "solid" and "none"
are ever exported as fo:border qualifiers.]

I modified the unit test to remove the fo:border
by clearing the unused-by-3d green border colour
(although the green was seen if the wrong flat border was assigned).

make CppunitTest_xmloff_style CPPUNIT_TEST_NAME=testTdf156707

Change-Id: I70718fe964a7c3578f8edbf8591fe2e3417ec60b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185619
Reviewed-by: Justin Luth <jluth@mail.com>
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2025-05-22 08:39:20 +02:00
László Németh 5a48070f59 tdf#126154 sw offapi xmloff cui: add min/max word spacing
To avoid of rivers and too much hyphenation, add minimum
and maximum word spacing options, similar to XSL-FO/CSS
and DTP software.

Only limiting hyphenation was implemented: hyphenation
of the words are disabled, if it's possible to expand
or shrink the spaces of the line within the values specified
by the maximum and minimum word spacing. First try to apply
the minimum word spacing, and if not possible, then the
maximum word spacing.

Note: maximum allowed shrinking has been applied for the
hyphenated lines instead of the minimum to remove the
hyphenation, yet. With the suggested default word spacing
values, this results no or minimal differences.

New UNO paragraph properties:

  com::sun::star::text::ParaWordSpacingMinimum

  com::sun::star::text::ParaWordSpacingMaximum

New ODF paragraph attributes:

  loext:word-spacing-minimum

  loext:word-spacing-maximum

New paragraph settings on Text Align pane:

  Minimum word spacing

  Maximum word spacing

While the desired word spacing got "Desired" label.

Note: suggested values of minimum, desired and
maximum word spacing are 80%, 100% and 133% (default
values e.g. in Adobe InDesign), in narrow columns e.g.
60%, 100% and 150%.

Follow-up to commit 7d6696757d
"tdf#159923 sw cui offapi xmloff: add custom word spacing".

Change-Id: I7f2a07f7fdb634cb16cdd8c2c937ca911b968405
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184595
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
2025-04-25 09:54:28 +02:00
László Németh 7d6696757d tdf#159923 sw cui offapi xmloff: add custom word spacing
Add com::sun::star::text::ParaWordSpacing UNO
and loext:word-spacing ODF extensions to set
desired word spacing of a justified paragraph
relative to the width of the space character,
like DTP software do.

Add Justification section and "Word spacing"
spin box to the Text Align pane of paragraph settings.

This extends not only the smart justify interoperability
feature for custom shrinking (until 0%), but for custom
expansion, too, until 1000%, like Adobe InDesign do.

Note: this value hasn't been applied in the last
paragraph line, yet.

See also XSL-FO/CSS word-spacing and
commit 7d08767b89
"tdf#130088 tdf#119908 smart justify: fix DOCX line count + compat opt."

Change-Id: I06f771335135e4682a1d1abfc9a247dbe4bc6b66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184187
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: Jenkins
2025-04-15 22:40:12 +02:00
Noel Grandin 1fc3b3198c loplugin:unusedfields
Change-Id: I2bbf1c093c5aed75939e9cc51935c8febd9aff04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184160
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
2025-04-15 08:10:29 +02:00
Noel Grandin 8009183a7a tdf#151876 shave some time off chart load (2)
manage SvXMLImportPropertyMapper with unique_ptr instead
of rtl::Reference, which avoids a bunch of ref-counting
traffic

Change-Id: I1e0e95408cdd5dc4271fa72178e57087737eb062
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183751
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-04-06 14:25:02 +02:00