mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-10 20:51:50 +00:00
ODT: text can turn off what its style turns on (gap 19) (#5724)
* ODT gap 19: text can turn off what its style turns on A word not bold in a bold heading showed bold on screen, and came back bold in LibreOffice after a save: an "off" on a run was dropped because the run's own formatting said nothing, so the paragraph's or character style's showed through. Keep it on the run for bold, italic, underline, strike-through, capitals and small capitals, and write it back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: an Asian or complex normal says nothing of Latin text (gap 19) With "off" now kept on the text, `style:font-weight-complex="normal"` alone took a word's bold in a bold heading, and saved it as `fo:font-weight="normal"`. Those attributes stay fallbacks only to turn it on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: strike-through turned off over a double one stays off (gap 19) A style or span saying line-through none over a double strike still showed the double strike, on screen and after a save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Docs: a missing full stop in the ODT revision row (gap 19) Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ODT: a span's character style wins over its paragraph turning off (gap 19) A paragraph saying not bold made a span in a bold character style not bold too, on screen and after a save. The span's style now wins, for bold, italic, underline, strike-through and capitals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Gap 19: docs status lines are main's, with this change in front Merging main had kept this branch's older status lines in ROADMAP.md and docs/file-format-parity.md, which set main's 2026-11-08 date back and dropped main's newer entries and the parity doc's CLI path note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: FredApps <FredApps@users.noreply.github.com>
This commit is contained in:
8 files changed
+233
-36
No files matched your search
+3
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
**Stage: alpha** · next: beta, ~15 points (60% → 75% ready for real work) and ~150–230 h away
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-08 · **Change:** trivial (progress log: edited ODT paragraphs keep custom styles with an outline level); previously trivial (progress log: ODT pictures keep the size their file gives); previously trivial (progress log: ODT frames keep the page they are anchored to); previously trivial (pointer zoom stretches page rasters until it stops); previously trivial (dark-theme interface text on Linux no longer looks semi-bold); previously trivial (Control/MCP #2596 review: partial-write outcomes, path-bearing image exports, accept-thread startup cleanup and malformed UTF-8 handling); previously trivial (progress log: a turned inline picture whose file keeps no room for the turn keeps its line to its frame); previously trivial (progress log: the Arabic interface's Styles gallery reads from the right (#5566)); previously trivial (progress log: ODT pictures offered in several formats); previously trivial (progress log: ODT heading text of another size); previously trivial (Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged; previously trivial: progress log: Custom document properties dialog, #2982; previously trivial: progress log: View › New Window; previously trivial: progress log: interface translations come from storytold/craft-i18n through the `craft-i18n` crate; previously trivial: progress log: disabled-control reasons translated in every interface language, #2678; previously trivial: progress log: mail merge record navigation and record ranges for printing, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: group connector rerouting preserves rotated and flipped free or unresolved endpoints under nonuniform group scaling; readiness estimates unchanged; previously trivial: progress log: a word with no break opportunity in it no longer makes the layout quadratic, #3412; previously trivial: progress log: a relationship the markup names without the prefix is read as it wrote, and an ordinary `id` names no part; previously trivial: progress log: a document with many relationships opens in the time its part takes, and an id the text only mentions is not a reference, #3411; previously trivial: progress log: read only and comments-only protection grey out edits; previously trivial: progress log: an empty paragraph with a hidden mark shows nothing, not even its list number, #3982; previously trivial: progress log: "NaN" in the Font dialog's Size box no longer closes the app, #3663; previously trivial: progress log: a table cell span from a `.json` file no longer overflows, #3637; previously trivial: progress log: a click in the footer while editing the header moves there; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Slovenian interface catalog, 2,614 entries; previously trivial: Insert Table of Figures dialog for any caption label, #3013; previously trivial: progress log: Home › Underline drop-down, #2738; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: progress log: the scrollbar page tip stays on one line, #3341; previously trivial: progress log: forms protection greys out the control buttons; previously trivial: progress log: a document with many content controls saves in the time the controls take, #13; previously trivial: progress log: Word signature lines kept on save; previously trivial: a Thai run with Latin finds one installed font covering it all on Linux too, #1549; previously trivial: progress log: closing the header returns to the body selection, #3331; previously trivial: progress log: saving to a NAS share mounted by GVFS, #3003; previously trivial: progress log: a picture dragged near the bottom of a page lands there, #3169; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: progress log: inline pictures drag to an insertion cursor and stay inline, #2233, #2234; previously trivial: progress log: a text file saved over itself closes without asking, #2376; previously trivial: progress log: a text frame in the paragraph defaults frames nothing, #2360; previously trivial: fixed font inputs in four layout controls; previously trivial: typing no longer starts render threads on every repaint, #3027; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: progress log: banded rows shade as in Word, #3415; previously trivial: progress log: the table handles show while the caret is in the table, #2428; previously trivial: progress log: a click below a floating table reaches the text after it, #2038; previously trivial: progress log: Delete on selected table cells leaves one empLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-08 · **Change:** trivial (progress log: ODT text turning off what its style turns on); previously trivial (progress log: edited ODT paragraphs keep custom styles with an outline level); previously trivial (progress log: ODT pictures keep the size their file gives); previously trivial (progress log: ODT frames keep the page they are anchored to); previously trivial (pointer zoom stretches page rasters until it stops); previously trivial (dark-theme interface text on Linux no longer looks semi-bold); previously trivial (Control/MCP #2596 review: partial-write outcomes, path-bearing image exports, accept-thread startup cleanup and malformed UTF-8 handling); previously trivial (progress log: a turned inline picture whose file keeps no room for the turn keeps its line to its frame); previously trivial (progress log: the Arabic interface's Styles gallery reads from the right (#5566)); previously trivial (progress log: ODT pictures offered in several formats); previously trivial (progress log: ODT heading text of another size); previously trivial (Protected typing boundary lookup counts preceding objects once and indexes editable permission IDs (#3614); caret movement and enforcement policy are unchanged; previously trivial: progress log: Custom document properties dialog, #2982; previously trivial: progress log: View › New Window; previously trivial: progress log: interface translations come from storytold/craft-i18n through the `craft-i18n` crate; previously trivial: progress log: disabled-control reasons translated in every interface language, #2678; previously trivial: progress log: mail merge record navigation and record ranges for printing, #3028; previously trivial: selection bar for right-to-left paragraphs and table rows; previously trivial: group connector rerouting preserves rotated and flipped free or unresolved endpoints under nonuniform group scaling; readiness estimates unchanged; previously trivial: progress log: a word with no break opportunity in it no longer makes the layout quadratic, #3412; previously trivial: progress log: a relationship the markup names without the prefix is read as it wrote, and an ordinary `id` names no part; previously trivial: progress log: a document with many relationships opens in the time its part takes, and an id the text only mentions is not a reference, #3411; previously trivial: progress log: read only and comments-only protection grey out edits; previously trivial: progress log: an empty paragraph with a hidden mark shows nothing, not even its list number, #3982; previously trivial: progress log: "NaN" in the Font dialog's Size box no longer closes the app, #3663; previously trivial: progress log: a table cell span from a `.json` file no longer overflows, #3637; previously trivial: progress log: a click in the footer while editing the header moves there; previously trivial: explicit documents keep the editor when recovery discovery finishes; readable recovery controls; previously trivial: Slovenian interface catalog, 2,614 entries; previously trivial: Insert Table of Figures dialog for any caption label, #3013; previously trivial: progress log: Home › Underline drop-down, #2738; previously trivial: personal templates in File › New and Save as Word Template, #2852; previously trivial: progress log: the scrollbar page tip stays on one line, #3341; previously trivial: progress log: forms protection greys out the control buttons; previously trivial: progress log: a document with many content controls saves in the time the controls take, #13; previously trivial: progress log: Word signature lines kept on save; previously trivial: a Thai run with Latin finds one installed font covering it all on Linux too, #1549; previously trivial: progress log: closing the header returns to the body selection, #3331; previously trivial: progress log: saving to a NAS share mounted by GVFS, #3003; previously trivial: progress log: a picture dragged near the bottom of a page lands there, #3169; previously trivial: centred list labels after leading page breaks, #2964; previously trivial: progress log: inline pictures drag to an insertion cursor and stay inline, #2233, #2234; previously trivial: progress log: a text file saved over itself closes without asking, #2376; previously trivial: progress log: a text frame in the paragraph defaults frames nothing, #2360; previously trivial: fixed font inputs in four layout controls; previously trivial: typing no longer starts render threads on every repaint, #3027; previously trivial: a right, centre or decimal tab whose text doesn't fit, or a left tab past the right indent, goes to the next line with its text, #1840; previously trivial: progress log: banded rows shade as in Word, #3415; previously trivial: progress log: the table handles show while the caret is in the table, #2428; previously trivial: progress log: a click below a floating table reaches the text after it, #2038Line truncated
|
||||
>
|
||||
> **Recipient CSV update:** 2026-10-27 · Complete quoted header records choose the delimiter (#4249); detection and regressions follow the current mailings module split. Recipient limits and readiness estimates are unchanged.
|
||||
>
|
||||
@@ -150,6 +150,7 @@ Ranked, to beta (detail and remaining milestones in [docs/roadmap.md](docs/roadm
|
||||
|
||||
## Progress log
|
||||
|
||||
- 2026-11-05: ODT text can turn off what its style turns on (gap 19): a word not bold in a bold heading showed bold, and came back bold in LibreOffice after a save.
|
||||
- 2026-11-06: An edited ODT paragraph keeps its custom paragraph style when that style has an outline level, or is based on a heading, Title, Quotations or Preformatted Text (gap 19). It was saved under the built-in style instead, such as WordCraft's blue Heading 1, and looked wrong in LibreOffice; a style with an outline level also drew that way in WordCraft. The style's outline level and numbering still work in WordCraft.
|
||||
- 2026-11-05: ODT pictures keep the size their file gives (gap 19): opening a file shrank ones wider than the text, so a save with no edit to them changed how LibreOffice laid them out.
|
||||
- 2026-11-05: ODT frames keep the page they are anchored to (gap 19): written without its number, a frame on page 3 came back on page 1 in LibreOffice after a save.
|
||||
@@ -931,6 +932,7 @@ MATH glyphs that reference the same construction now share its immutable variant
|
||||
| 2026-11-05 | trivial | DOCX paragraph `w:adjustRightInd` is preserved with true, false and absent values; OOXML properties follow schema order. Grid layout remains open. |
|
||||
| 2026-11-04 | trivial | Progress log: RTF Unicode fallback counts; readiness estimates unchanged |
|
||||
| 2026-10-28 | trivial | Per-page ink object lookups, #3614. Drawing order, geometry and saved data retain their behavior; no readiness estimate change |
|
||||
| 2026-11-05 | trivial | Progress log: ODT text turning off what its style turns on (gap 19) |
|
||||
| 2026-11-05 | trivial | Progress log: ODT pictures keep the size their file gives (gap 19) |
|
||||
| 2026-11-05 | trivial | Progress log: ODT frames keep the page they are anchored to (gap 19) |
|
||||
| 2026-11-05 | trivial | Progress log: ODT table and row backgrounds (gap 19) |
|
||||
|
||||
@@ -116,11 +116,15 @@ fn run_fmt(doc: &Document, props: &CharProps, in_code: bool, opts: FlowOpts) ->
|
||||
fn extra_of(e: &CharProps) -> Option<Box<CharProps>> {
|
||||
let set = |v: Option<bool>| v.filter(|b| *b);
|
||||
let x = CharProps {
|
||||
underline: e.underline.filter(|u| !matches!(u, Underline::None | Underline::Single)),
|
||||
// What it turns off, over what the style of its paragraph or span turns on, too.
|
||||
bold: e.bold.filter(|b| !*b),
|
||||
italic: e.italic.filter(|b| !*b),
|
||||
strike: e.strike.filter(|b| !*b),
|
||||
underline: e.underline.filter(|u| *u != Underline::Single),
|
||||
underline_color: e.underline_color,
|
||||
double_strike: set(e.double_strike),
|
||||
caps: set(e.caps),
|
||||
small_caps: set(e.small_caps),
|
||||
caps: e.caps,
|
||||
small_caps: e.small_caps,
|
||||
hidden: set(e.hidden),
|
||||
spacing: e.spacing.filter(|v| *v != 0.0 && v.is_finite()),
|
||||
scale: e.scale.filter(|v| *v != 100.0 && v.is_finite()),
|
||||
|
||||
@@ -50,6 +50,20 @@ impl WithExtra for CharProps {
|
||||
if f.underline {
|
||||
self.underline_color = x.underline_color;
|
||||
}
|
||||
// Turned off on the text, over what the style of its paragraph or span turns on.
|
||||
if !f.bold && x.bold == Some(false) {
|
||||
self.bold = Some(false);
|
||||
}
|
||||
if !f.italic && x.italic == Some(false) {
|
||||
self.italic = Some(false);
|
||||
}
|
||||
if !f.strike && x.strike == Some(false) {
|
||||
// A double strike under it goes too.
|
||||
(self.strike, self.double_strike) = (Some(false), Some(false));
|
||||
}
|
||||
if !f.underline && x.underline == Some(Underline::None) {
|
||||
self.underline = Some(Underline::None);
|
||||
}
|
||||
if x.double_strike == Some(true) {
|
||||
(self.strike, self.double_strike) = (None, Some(true));
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ fn turned_off(mut chr: wordcraft_doc::props::CharProps, off: [bool; 4]) -> wordc
|
||||
chr.underline = Some(wordcraft_doc::props::Underline::None);
|
||||
}
|
||||
if strike {
|
||||
chr.strike = Some(false);
|
||||
(chr.strike, chr.double_strike) = (Some(false), Some(false));
|
||||
}
|
||||
chr
|
||||
}
|
||||
|
||||
@@ -39,6 +39,26 @@ impl FmtDelta {
|
||||
($($k:ident),*) => { $( if let Some(v) = self.$k.clone() { f.$k = v; } )* };
|
||||
}
|
||||
set!(bold, italic, underline, strike, sup, sub, code);
|
||||
// What this turns off stays said on the text, or the style of its paragraph or span would
|
||||
// show through; turned back on, it no longer is.
|
||||
if self.bold.is_some() || self.italic.is_some() || self.underline.is_some() || self.strike.is_some() {
|
||||
use wordcraft_doc::props::Underline;
|
||||
let mut x = f.extra.take().map(|b| *b).unwrap_or_default();
|
||||
if self.strike == Some(false) {
|
||||
x.double_strike = None;
|
||||
}
|
||||
for (state, said) in [(self.bold, &mut x.bold), (self.italic, &mut x.italic), (self.strike, &mut x.strike)] {
|
||||
if let Some(on) = state {
|
||||
*said = (!on).then_some(false);
|
||||
}
|
||||
}
|
||||
match self.underline {
|
||||
Some(false) => x.underline = Some(Underline::None),
|
||||
Some(true) if x.underline == Some(Underline::None) => x.underline = None,
|
||||
_ => {}
|
||||
}
|
||||
f.extra = (x != wordcraft_doc::props::CharProps::default()).then(|| Box::new(x));
|
||||
}
|
||||
if self.color.is_some() {
|
||||
f.color = self.color;
|
||||
}
|
||||
@@ -61,10 +81,12 @@ impl FmtDelta {
|
||||
let size = f.size.unwrap_or(12.0);
|
||||
x.position = Some((r / 100.0 * size).clamp(-1584.0, 1584.0)).filter(|p| *p != 0.0);
|
||||
}
|
||||
// An explicit "off" only cancels what a parent style set.
|
||||
for b in
|
||||
[&mut x.double_strike, &mut x.caps, &mut x.small_caps, &mut x.hidden, &mut x.outline, &mut x.shadow, &mut x.emboss, &mut x.engrave]
|
||||
{
|
||||
// An explicit "off" only cancels what a parent style set (capitals are kept: a
|
||||
// paragraph's or span's style may set them too).
|
||||
if self.strike == Some(false) {
|
||||
x.double_strike = None;
|
||||
}
|
||||
for b in [&mut x.double_strike, &mut x.hidden, &mut x.outline, &mut x.shadow, &mut x.emboss, &mut x.engrave] {
|
||||
if *b == Some(false) {
|
||||
*b = None;
|
||||
}
|
||||
@@ -812,13 +834,18 @@ fn text_properties(a: &Attrs, style: &mut StyleInfo, faces: &HashMap<String, Str
|
||||
let weight = weight.trim();
|
||||
weight.eq_ignore_ascii_case("bold") || weight.parse::<u32>().is_ok_and(|n| n >= 600)
|
||||
};
|
||||
// Latin attributes take precedence; Asian and complex-script attributes are fallbacks.
|
||||
if let Some(weight) = get(a, "fo:font-weight").or_else(|| get(a, "style:font-weight-asian")).or_else(|| get(a, "style:font-weight-complex")) {
|
||||
// Latin attributes take precedence; Asian and complex-script attributes are fallbacks, to turn
|
||||
// it on: one of those saying normal says nothing of Latin text.
|
||||
if let Some(weight) = get(a, "fo:font-weight") {
|
||||
fmt.bold = Some(is_bold(weight));
|
||||
} else if get(a, "style:font-weight-asian").or_else(|| get(a, "style:font-weight-complex")).is_some_and(is_bold) {
|
||||
fmt.bold = Some(true);
|
||||
}
|
||||
let is_italic = |value: &str| value.trim().eq_ignore_ascii_case("italic") || value.trim().eq_ignore_ascii_case("oblique");
|
||||
if let Some(value) = get(a, "fo:font-style").or_else(|| get(a, "style:font-style-asian")).or_else(|| get(a, "style:font-style-complex")) {
|
||||
if let Some(value) = get(a, "fo:font-style") {
|
||||
fmt.italic = Some(is_italic(value));
|
||||
} else if get(a, "style:font-style-asian").or_else(|| get(a, "style:font-style-complex")).is_some_and(is_italic) {
|
||||
fmt.italic = Some(true);
|
||||
}
|
||||
let is_not_none = |value: &str| !value.trim().eq_ignore_ascii_case("none");
|
||||
if let Some(value) = get(a, "style:text-underline-style").or_else(|| get(a, "style:text-underline-type")) {
|
||||
@@ -1326,6 +1353,32 @@ impl Styles {
|
||||
let chain = self.chain(name);
|
||||
let Some(at) = chain.iter().position(|(n, _)| self.is_named_text(n)) else { return self.text_fmt(name, base) };
|
||||
let mut f = base.clone();
|
||||
// What the span's character style says is its own: its paragraph turning that off doesn't
|
||||
// reach past it (ODF: the span's style wins).
|
||||
if let Some(x) = f.extra.as_deref_mut() {
|
||||
use wordcraft_doc::props::Underline;
|
||||
for (_, s) in chain.iter().skip(at) {
|
||||
let (d, e) = (&s.fmt, &s.fmt.extra);
|
||||
if d.bold.is_some() && x.bold == Some(false) {
|
||||
x.bold = None;
|
||||
}
|
||||
if d.italic.is_some() && x.italic == Some(false) {
|
||||
x.italic = None;
|
||||
}
|
||||
if d.underline.is_some() && x.underline == Some(Underline::None) {
|
||||
x.underline = None;
|
||||
}
|
||||
if (d.strike.is_some() || e.double_strike.is_some()) && x.strike == Some(false) {
|
||||
(x.strike, x.double_strike) = (None, None);
|
||||
}
|
||||
if e.caps.is_some() && x.caps == Some(false) {
|
||||
x.caps = None;
|
||||
}
|
||||
if e.small_caps.is_some() && x.small_caps == Some(false) {
|
||||
x.small_caps = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (_, s) in chain.iter().take(at).rev() {
|
||||
s.fmt.apply(&mut f);
|
||||
}
|
||||
|
||||
@@ -285,6 +285,128 @@ fn objects_in_hidden_text_are_kept() {
|
||||
assert!(p.objects.iter().any(|o| matches!(o, wordcraft_doc::para::InlineObject::BookmarkStart { name } if name == "Secret")), "{:?}", p.objects);
|
||||
}
|
||||
|
||||
/// A paragraph in style `style` holding `span`, with `auto` among its automatic styles.
|
||||
fn off_doc(styles: &str, style: &str, auto: &str, span: &str) -> Document {
|
||||
let content = format!(
|
||||
r#"<office:document-content {NS_T}><office:automatic-styles>{auto}</office:automatic-styles><office:body><office:text><text:p text:style-name="{style}">{span}</text:p></office:text></office:body></office:document-content>"#
|
||||
);
|
||||
let styles = format!("<office:document-styles {NS_T}><office:styles>{styles}</office:styles></office:document-styles>");
|
||||
import(&crate::odt::tests::package(&content, Some(&styles))).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_turning_off_what_its_style_turns_on_stays_off() {
|
||||
// A word not bold in a bold heading: it showed bold, on screen and after a save.
|
||||
let on = r#"fo:font-weight="bold" fo:font-style="italic" style:text-underline-style="solid" style:text-line-through-style="solid" fo:font-variant="small-caps" fo:text-transform="uppercase""#;
|
||||
let off = r#"fo:font-weight="normal" fo:font-style="normal" style:text-underline-style="none" style:text-line-through-style="none" fo:font-variant="normal" fo:text-transform="none""#;
|
||||
let styles = format!(r#"<style:style style:name="Laut" style:family="paragraph"><style:text-properties {on}/></style:style>"#);
|
||||
let auto = format!(r#"<style:style style:name="T1" style:family="text"><style:text-properties {off}/></style:style>"#);
|
||||
let check = |d: &Document, what: &str| {
|
||||
let p = d.body[0].as_para().unwrap();
|
||||
let shown = |run: usize| d.styles.resolve_char(p.props.style.as_deref(), &p.runs[run].props);
|
||||
assert_eq!(p.text, "onoff", "{what}");
|
||||
let (a, b) = (shown(0), shown(1));
|
||||
assert_eq!((a.bold, a.italic, a.strike, a.small_caps, a.caps), (true, true, true, true, true), "{what}: the style's");
|
||||
assert!(a.underline != Underline::None, "{what}");
|
||||
assert_eq!((b.bold, b.italic, b.strike, b.small_caps, b.caps), (false, false, false, false, false), "{what}: turned off");
|
||||
assert_eq!(b.underline, Underline::None, "{what}");
|
||||
};
|
||||
let d = off_doc(&styles, "Laut", &auto, r#"on<text:span text:style-name="T1">off</text:span>"#);
|
||||
check(&d, "read");
|
||||
check(&import(&crate::odt::tests::export_model(&d).unwrap()).unwrap(), "written from the model");
|
||||
check(&import(&export(&d).unwrap()).unwrap(), "written as read");
|
||||
// Turned back on inside it: on.
|
||||
let auto = format!(
|
||||
r#"{auto}<style:style style:name="T2" style:family="text"><style:text-properties fo:font-weight="bold" style:text-underline-style="solid"/></style:style>"#
|
||||
);
|
||||
let d = off_doc(&styles, "Laut", &auto, r#"<text:span text:style-name="T1"><text:span text:style-name="T2">x</text:span></text:span>"#);
|
||||
let p = d.body[0].as_para().unwrap();
|
||||
let x = d.styles.resolve_char(p.props.style.as_deref(), &p.runs[0].props);
|
||||
assert!(x.bold);
|
||||
assert!(x.underline != Underline::None, "{x:?}");
|
||||
assert!(!x.italic, "still off");
|
||||
// A character style's: off in the automatic style based on it.
|
||||
let styles = r#"<style:style style:name="Zeichen" style:family="text"><style:text-properties fo:font-weight="bold" style:text-underline-style="solid"/></style:style>"#;
|
||||
let auto = r#"<style:style style:name="T3" style:family="text" style:parent-style-name="Zeichen"><style:text-properties fo:font-weight="normal" style:text-underline-style="none"/></style:style>"#;
|
||||
let d = off_doc(styles, "Standard", auto, r#"<text:span text:style-name="T3">x</text:span>"#);
|
||||
let p = d.body[0].as_para().unwrap();
|
||||
let x = d.styles.resolve_char(p.props.style.as_deref(), &p.runs[0].props);
|
||||
assert_eq!((x.bold, x.underline), (false, Underline::None), "{x:?}");
|
||||
// Text nothing turned on says nothing.
|
||||
let d = off_doc("", "Standard", "", "plain");
|
||||
let c = crate::odt::tests::content_of(&crate::odt::tests::export_model(&d).unwrap());
|
||||
assert!(!c.contains(r#"fo:font-weight="normal""#) && !c.contains(r#"style:text-underline-style="none""#), "{c}");
|
||||
}
|
||||
|
||||
/// A weight or slant only for Asian or complex-script text says nothing of Latin text when it is
|
||||
/// normal: the heading's bold stays, on screen and saved. Latin text's own "normal" still counts.
|
||||
#[test]
|
||||
fn an_asian_or_complex_normal_doesnt_turn_latin_text_off() {
|
||||
let styles = format!(
|
||||
r#"<office:document-styles {NS_T}><office:styles><style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:default-outline-level="1"><style:text-properties fo:font-weight="bold" fo:font-style="italic"/></style:style></office:styles></office:document-styles>"#
|
||||
);
|
||||
let open = |attr: &str| {
|
||||
let content = format!(
|
||||
r#"<office:document-content {NS_T}><office:automatic-styles><style:style style:name="T1" style:family="text"><style:text-properties {attr}/></style:style></office:automatic-styles><office:body><office:text><text:h text:style-name="Heading_20_1" text:outline-level="1">Bold <text:span text:style-name="T1">word</text:span></text:h></office:text></office:body></office:document-content>"#
|
||||
);
|
||||
import(&package(&content, Some(&styles))).unwrap()
|
||||
};
|
||||
let run = |d: &Document| d.body[0].as_para().unwrap().runs.last().unwrap().props.clone();
|
||||
for attr in [
|
||||
r#"style:font-weight-complex="normal""#,
|
||||
r#"style:font-weight-asian="normal""#,
|
||||
r#"style:font-style-complex="normal""#,
|
||||
r#"style:font-style-asian="normal""#,
|
||||
] {
|
||||
let d = open(attr);
|
||||
assert_eq!((run(&d).bold, run(&d).italic), (None, None), "{attr}");
|
||||
let saved = crate::odt::tests::content_of(&crate::odt::tests::export_model(&d).unwrap());
|
||||
assert!(!saved.contains(r#"fo:font-weight="normal""#) && !saved.contains(r#"fo:font-style="normal""#), "{attr}: {saved}");
|
||||
}
|
||||
assert_eq!(run(&open(r#"fo:font-weight="normal""#)).bold, Some(false));
|
||||
assert_eq!(run(&open(r#"fo:font-style="normal""#)).italic, Some(false));
|
||||
}
|
||||
|
||||
/// Strike-through turned off over a double one is off, not the double one again.
|
||||
#[test]
|
||||
fn strike_turned_off_over_a_double_strike_stays_off() {
|
||||
let double = r#"<style:text-properties style:text-line-through-style="solid" style:text-line-through-type="double"/>"#;
|
||||
let none = r#"<style:text-properties style:text-line-through-style="none"/>"#;
|
||||
let check = |d: &Document, what: &str| {
|
||||
let p = d.body[0].as_para().unwrap();
|
||||
let c = d.styles.resolve_char(p.props.style.as_deref(), &p.runs.last().unwrap().props);
|
||||
assert_eq!((c.strike, c.double_strike), (false, false), "{what}");
|
||||
};
|
||||
// A style over its parent.
|
||||
let styles = format!(
|
||||
r#"<style:style style:name="Parent" style:family="paragraph">{double}</style:style><style:style style:name="Kid" style:family="paragraph" style:parent-style-name="Parent">{none}</style:style>"#
|
||||
);
|
||||
let d = off_doc(&styles, "Kid", "", "One");
|
||||
check(&d, "a style, read");
|
||||
check(&import(&crate::odt::tests::export_model(&d).unwrap()).unwrap(), "a style, written from the model");
|
||||
// A span over its paragraph's style.
|
||||
let styles = format!(r#"<style:style style:name="Parent" style:family="paragraph">{double}</style:style>"#);
|
||||
let auto = format!(r#"<style:style style:name="T1" style:family="text">{none}</style:style>"#);
|
||||
let d = off_doc(&styles, "Parent", &auto, r#"<text:span text:style-name="T1">One</text:span>"#);
|
||||
check(&d, "a span, read");
|
||||
check(&import(&crate::odt::tests::export_model(&d).unwrap()).unwrap(), "a span, written from the model");
|
||||
}
|
||||
|
||||
/// A span's character style is its own: a paragraph turning bold or italic off doesn't reach past it.
|
||||
#[test]
|
||||
fn a_spans_character_style_wins_over_its_paragraph_turning_off() {
|
||||
let styles = r#"<style:style style:name="Standard" style:family="paragraph"/><style:style style:name="Strong_20_Emphasis" style:display-name="Strong Emphasis" style:family="text"><style:text-properties fo:font-weight="bold" fo:font-style="italic"/></style:style>"#;
|
||||
let auto = r#"<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"><style:text-properties fo:font-weight="normal" fo:font-style="normal"/></style:style>"#;
|
||||
let d = off_doc(styles, "P1", auto, r#"<text:span text:style-name="Strong_20_Emphasis">One</text:span>"#);
|
||||
let check = |d: &Document, what: &str| {
|
||||
let p = d.body[0].as_para().unwrap();
|
||||
let c = d.styles.resolve_char(p.props.style.as_deref(), &p.runs.last().unwrap().props);
|
||||
assert_eq!((c.bold, c.italic), (true, true), "{what}: {:?}", p.runs.last().unwrap().props);
|
||||
};
|
||||
check(&d, "read");
|
||||
check(&import(&crate::odt::tests::export_model(&d).unwrap()).unwrap(), "written from the model");
|
||||
}
|
||||
|
||||
/// `default` as a document's default paragraph style's text properties, with `standard` as its
|
||||
/// Standard style's.
|
||||
fn with_default_text(default: &str, standard: &str) -> Vec<u8> {
|
||||
|
||||
@@ -10,9 +10,13 @@ pub(in crate::odt) fn extra_props(x: &wordcraft_doc::props::CharProps, size: Opt
|
||||
let on = |v: Option<bool>| v == Some(true);
|
||||
if on(x.caps) {
|
||||
p.push_str(" fo:text-transform=\"uppercase\"");
|
||||
} else if x.caps == Some(false) {
|
||||
p.push_str(" fo:text-transform=\"none\"");
|
||||
}
|
||||
if on(x.small_caps) {
|
||||
p.push_str(" fo:font-variant=\"small-caps\"");
|
||||
} else if x.small_caps == Some(false) {
|
||||
p.push_str(" fo:font-variant=\"normal\"");
|
||||
}
|
||||
if on(x.hidden) {
|
||||
p.push_str(" text:display=\"none\"");
|
||||
@@ -78,28 +82,7 @@ pub(in crate::odt) fn props_text(cp: &wordcraft_doc::props::CharProps) -> String
|
||||
extra: Some(Box::new(cp.clone())),
|
||||
..Default::default()
|
||||
};
|
||||
let mut p = text_props(&f);
|
||||
// What a style turns off that the style it is based on may turn on: said so, or the parent's
|
||||
// bold, italic, underline or strike-through would show through.
|
||||
if cp.bold == Some(false) {
|
||||
p.push_str(" fo:font-weight=\"normal\" style:font-weight-asian=\"normal\"");
|
||||
if cp.bold_cs.is_none() {
|
||||
p.push_str(" style:font-weight-complex=\"normal\"");
|
||||
}
|
||||
}
|
||||
if cp.italic == Some(false) {
|
||||
p.push_str(" fo:font-style=\"normal\" style:font-style-asian=\"normal\"");
|
||||
if cp.italic_cs.is_none() {
|
||||
p.push_str(" style:font-style-complex=\"normal\"");
|
||||
}
|
||||
}
|
||||
if cp.underline == Some(Underline::None) {
|
||||
p.push_str(" style:text-underline-style=\"none\"");
|
||||
}
|
||||
if cp.strike == Some(false) && cp.double_strike != Some(true) {
|
||||
p.push_str(" style:text-line-through-style=\"none\"");
|
||||
}
|
||||
p
|
||||
text_props(&f)
|
||||
}
|
||||
|
||||
/// `fo:text-align` for `a` (ODF 1.3 §20.223).
|
||||
@@ -171,19 +154,32 @@ pub(in crate::odt) fn text_props(f: &Fmt) -> String {
|
||||
let mut p = String::new();
|
||||
// Complex-script weight and posture of their own are written with the other script extras.
|
||||
let own_cs = |pick: fn(&wordcraft_doc::props::CharProps) -> Option<bool>| f.extra.as_deref().and_then(pick).is_some();
|
||||
let extra = f.extra.as_deref();
|
||||
// What it turns off that its style, or the style that is based on, may turn on: said so, or
|
||||
// that bold, italic, underline or strike-through would show through.
|
||||
let off = |pick: fn(&wordcraft_doc::props::CharProps) -> Option<bool>| extra.and_then(pick) == Some(false);
|
||||
if f.bold {
|
||||
p.push_str(" fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"");
|
||||
if !own_cs(|x| x.bold_cs) {
|
||||
p.push_str(" style:font-weight-complex=\"bold\"");
|
||||
}
|
||||
} else if off(|x| x.bold) {
|
||||
p.push_str(" fo:font-weight=\"normal\" style:font-weight-asian=\"normal\"");
|
||||
if !own_cs(|x| x.bold_cs) {
|
||||
p.push_str(" style:font-weight-complex=\"normal\"");
|
||||
}
|
||||
}
|
||||
if f.italic {
|
||||
p.push_str(" fo:font-style=\"italic\" style:font-style-asian=\"italic\"");
|
||||
if !own_cs(|x| x.italic_cs) {
|
||||
p.push_str(" style:font-style-complex=\"italic\"");
|
||||
}
|
||||
} else if off(|x| x.italic) {
|
||||
p.push_str(" fo:font-style=\"normal\" style:font-style-asian=\"normal\"");
|
||||
if !own_cs(|x| x.italic_cs) {
|
||||
p.push_str(" style:font-style-complex=\"normal\"");
|
||||
}
|
||||
}
|
||||
let extra = f.extra.as_deref();
|
||||
if f.underline {
|
||||
use wordcraft_doc::props::Underline as U;
|
||||
let (style, kind, width, mode) = match extra.and_then(|e| e.underline) {
|
||||
@@ -204,11 +200,16 @@ pub(in crate::odt) fn text_props(f: &Fmt) -> String {
|
||||
" style:text-underline-style=\"{style}\" style:text-underline-type=\"{kind}\" style:text-underline-width=\"{width}\" style:text-underline-color=\"{color}\"{mode}"
|
||||
));
|
||||
}
|
||||
if !f.underline && extra.is_some_and(|e| e.underline == Some(wordcraft_doc::props::Underline::None)) {
|
||||
p.push_str(" style:text-underline-style=\"none\"");
|
||||
}
|
||||
if f.strike || extra.is_some_and(|e| e.double_strike == Some(true)) {
|
||||
p.push_str(" style:text-line-through-style=\"solid\"");
|
||||
if extra.is_some_and(|e| e.double_strike == Some(true)) {
|
||||
p.push_str(" style:text-line-through-type=\"double\"");
|
||||
}
|
||||
} else if off(|x| x.strike) {
|
||||
p.push_str(" style:text-line-through-style=\"none\"");
|
||||
}
|
||||
if let Some(e) = extra {
|
||||
if (f.sup || f.sub) && e.position.is_some() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
> **2026-11-05:** DOCX paragraph `w:adjustRightInd` keeps its default and explicit values through style resolution and schema-ordered repeated saves.
|
||||
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-08 · **Change:** trivial (ODT custom styles with an outline level); previously trivial (ODT pictures keep the size their file gives); previously trivial (ODT frames keep the page they are anchored to); previously trivial (ODT: a document's language kept when its styles are written from the model); previously trivial (ODT table and row backgrounds); previously trivial (ODT row: how tab stops are saved, corrected); previously trivial (RTF footnotes, endnotes and comments, #1053); previously trivial (XML line ends in text normalised, #5897); previously trivial (ODT pictures offered in several formats); previously trivial (ODT heading text of another size); previously trivial (built-in citation source lookups, #4888; current-main progress records retained); previously trivial (ODT: no settings for what the standard leaves open); previously trivial (picture brightness, contrast and transparency); previously trivial (ODT paragraph groups kept as read); previously trivial (ODT paragraphs with charts kept as read); previously trivial (ODT sections in cells and at empty paragraphs); previously trivial (ODT element audit); previously trivial (ODT reference marks written as such); previously trivial (ODT hidden sections stay hidden; lists kept as read); previously trivial (ODT manifest lists every file); previously trivial (ODT paragraphs with bookmarks, notes, objects and page-anchored frames written as read); previously trivial (ODT paragraphs with text boxes written as read); previously trivial (ODT paragraphs with comments and tracked changes written as read); previously trivial (ODT paragraphs with pictures and shapes written as read); previously trivial (ODT sections inside text boxes); previously trivial (ODT definitions sharing a name, sections around tables, chart replacement pictures, note citations, stacking order); previously trivial (ODT form definitions and indexes written as read); previously trivial (ODT gradient angles by the file's version; deviation documented); previously minor (ODT: unedited tables, pages, sections, properties and declarations written as read; no-edit loss gate); previously minor (ODT: unedited paragraphs and style definitions written as read); previously trivial (ODT author fields said not fixed); previously trivial (ODT default text colour; covered cells' content); previously trivial (ODT widow control profile case; tabs from the indent kept); previously trivial (ODT span kerning; note reference formatting; notes starting with a tab); previously trivial (ODT fixed and sender fields); previously trivial (ODT: table styles saved into their cells; ODT tables carry no Word table style; section column balance); previously trivial (ODT interpretation profile: the standard is law, what it leaves open (including unstated page margins) follows WordCraft, LibreOffice or custom settings); previously trivial (ODT form controls keep their place on the line and text areas their lines; custom shapes keep their geometry); previously trivial (ODT in-line frames placed against the text; in-line pictures saved standing on the baseline); previously trivial (ODT charts written back as they were while unchanged; frames' drawn outline; default header height); previously trivial (ODT header rows only where they repeat); previously trivial (ODT padding without a border; unequal columns; column breaks); previously trivial (ODT lines of only pictures laid out as LibreOffice does; default page without a layout); previously trivial (ODT pictures alone in a paragraph keep its size; in-line frames raised under an inherited paragraph relation); previously trivial (ODT tables fit the margins and keep their space above and below; header spacing kept); previously trivial (ODT frames anchored and placed by their style); previously trivial (ODT default font size saved; page-anchored frames placed from the page; text box paragraph styles kept; empty paragraphs keep their size); previously trivial (ODT default font size; locale-ordered dates); previously trivial (ODT page background pictures); previously trivial (ODT tables fixed layout; tables starting a page); previously trivial (emphasis marks: model, layout, DOCX `w:em`, ODT `style:text-emphasize`, `format.emphasisMark`); previously trivial (ODT variables as SET/REF fields; character styles keep what they turn off); previously trivial (ODT styles keep what they turn off; WMF/EMF pictures kept; pictures in text boxes shown by LibreOffice); previously trivial (ODT unstated page margins are LibreOffice's 2 cm; drawings outside a paragraph join the next one); previously trivial (ODT placeholders as content controls, template dates, user name fields, unsized pages, style-only templates, found with LibreOffice's own templates); previously trivial (ODT hidden form controls kept; `.ott` templates opened and saved); previously trivial (ODT fidelity re-estimated at ~90%; a kept form control made another kind isLine truncated
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-08 · **Change:** trivial (ODT text turning off what its style turns on); previously trivial (ODT custom styles with an outline level); previously trivial (ODT pictures keep the size their file gives); previously trivial (ODT frames keep the page they are anchored to); previously trivial (ODT: a document's language kept when its styles are written from the model); previously trivial (ODT table and row backgrounds); previously trivial (ODT row: how tab stops are saved, corrected); previously trivial (RTF footnotes, endnotes and comments, #1053); previously trivial (XML line ends in text normalised, #5897); previously trivial (ODT pictures offered in several formats); previously trivial (ODT heading text of another size); previously trivial (built-in citation source lookups, #4888; current-main progress records retained); previously trivial (ODT: no settings for what the standard leaves open); previously trivial (picture brightness, contrast and transparency); previously trivial (ODT paragraph groups kept as read); previously trivial (ODT paragraphs with charts kept as read); previously trivial (ODT sections in cells and at empty paragraphs); previously trivial (ODT element audit); previously trivial (ODT reference marks written as such); previously trivial (ODT hidden sections stay hidden; lists kept as read); previously trivial (ODT manifest lists every file); previously trivial (ODT paragraphs with bookmarks, notes, objects and page-anchored frames written as read); previously trivial (ODT paragraphs with text boxes written as read); previously trivial (ODT paragraphs with comments and tracked changes written as read); previously trivial (ODT paragraphs with pictures and shapes written as read); previously trivial (ODT sections inside text boxes); previously trivial (ODT definitions sharing a name, sections around tables, chart replacement pictures, note citations, stacking order); previously trivial (ODT form definitions and indexes written as read); previously trivial (ODT gradient angles by the file's version; deviation documented); previously minor (ODT: unedited tables, pages, sections, properties and declarations written as read; no-edit loss gate); previously minor (ODT: unedited paragraphs and style definitions written as read); previously trivial (ODT author fields said not fixed); previously trivial (ODT default text colour; covered cells' content); previously trivial (ODT widow control profile case; tabs from the indent kept); previously trivial (ODT span kerning; note reference formatting; notes starting with a tab); previously trivial (ODT fixed and sender fields); previously trivial (ODT: table styles saved into their cells; ODT tables carry no Word table style; section column balance); previously trivial (ODT interpretation profile: the standard is law, what it leaves open (including unstated page margins) follows WordCraft, LibreOffice or custom settings); previously trivial (ODT form controls keep their place on the line and text areas their lines; custom shapes keep their geometry); previously trivial (ODT in-line frames placed against the text; in-line pictures saved standing on the baseline); previously trivial (ODT charts written back as they were while unchanged; frames' drawn outline; default header height); previously trivial (ODT header rows only where they repeat); previously trivial (ODT padding without a border; unequal columns; column breaks); previously trivial (ODT lines of only pictures laid out as LibreOffice does; default page without a layout); previously trivial (ODT pictures alone in a paragraph keep its size; in-line frames raised under an inherited paragraph relation); previously trivial (ODT tables fit the margins and keep their space above and below; header spacing kept); previously trivial (ODT frames anchored and placed by their style); previously trivial (ODT default font size saved; page-anchored frames placed from the page; text box paragraph styles kept; empty paragraphs keep their size); previously trivial (ODT default font size; locale-ordered dates); previously trivial (ODT page background pictures); previously trivial (ODT tables fixed layout; tables starting a page); previously trivial (emphasis marks: model, layout, DOCX `w:em`, ODT `style:text-emphasize`, `format.emphasisMark`); previously trivial (ODT variables as SET/REF fields; character styles keep what they turn off); previously trivial (ODT styles keep what they turn off; WMF/EMF pictures kept; pictures in text boxes shown by LibreOffice); previously trivial (ODT unstated page margins are LibreOffice's 2 cm; drawings outside a paragraph join the next one); previously trivial (ODT placeholders as content controls, template dates, user name fields, unsized pages, style-only templates, found with LibreOffice's own templates); previously trivial (ODT hidden form controls kept; `.ott` templates opened and saved); previously trivial (ODT fideLine truncated
|
||||
> **CLI path update:** 2026-11-04 · Options before a non-Unicode input filename no longer make the CLI reject that filename; text option values still require Unicode; `run --file` and `run --script` retain native paths. No ranked gap or readiness estimate changes.
|
||||
|
||||
> **Legacy form update:** 2026-10-22 · trivial: field names and selected drop-down labels decode numeric XML character references once.
|
||||
@@ -335,6 +335,7 @@ For field results, the engine parser treats a backslash in quoted arguments as e
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-08 | trivial | ODT row corrected: a file whose tab stops are measured from the indent is saved measuring from it, not always from the margin (the 2026-11-03 change); the default stops are counted from the indent |
|
||||
| 2026-11-05 | trivial | ODT: text turning off bold, italic, underline, strike-through, capitals or small capitals that its paragraph or character style turns on stays off, read and written. It showed the style's, on screen and in LibreOffice after a save. An Asian or complex-script weight or slant of normal says nothing of Latin text. Strike-through turned off over a double one is off. A span's character style wins over its paragraph turning bold, italic, underline, strike-through or capitals off. |
|
||||
| 2026-11-06 | trivial | ODT: a custom paragraph style with an outline level (`style:default-outline-level`) stays the paragraph's style. It draws with the file's look, is a heading at that level and is numbered with the outline, and an edited paragraph is saved under its own name (`<text:h text:style-name="Head" text:outline-level="1">`). It became WordCraft's Heading 1, on screen and in LibreOffice after an edit. Custom styles based on a heading, Title, Quotations or Preformatted Text also keep their name when edited A heading's own `text:outline-level` gives its number, as in LibreOffice. A style at a level the outline doesn't number takes no number from its parent. A heading past level six numbered through its style keeps its list too. |
|
||||
| 2026-11-05 | trivial | ODT: a picture keeps the size its frame states. Opening a file fitted one wider than the text to it, and any wider than 6.5 in to that, which took its paragraph off being written as read and moved things in LibreOffice after a save Stated on one side, the other follows its proportions. In line with no size stated, it is fitted to the text when read, an object's picture too. A frame stating a width of nothing states no size. A picture in line that is raised, turned or mirrored is fitted too. |
|
||||
| 2026-11-05 | trivial | ODT: a frame or shape anchored to a page keeps its page number (`text:anchor-page-number`). It was written without one, so a frame on page 3 came back on page 1 in LibreOffice after a save. WordCraft's own layout still places it on its anchor paragraph's page. Groups keep theirs too, and a number on another anchor is ignored, as LibreOffice does. Moved in WordCraft onto a spot where a paragraph starts, a frame is placed by that paragraph and its page number is removed, not only hidden. Dropped where no paragraph starts, it stays anchored to the page and its number becomes the new page's. |
|
||||
|
||||
Reference in new issue
Block a user