Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/bugfixes/issue-618/after.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bugfixes/issue-618/before.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bugfixes/issue-618/gt.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bugfixes/issue-709/compare.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bugfixes/issue-710/compare.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions crates/office2pdf/src/ir/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ pub struct Table {
/// Excel prints cells bottom-aligned by default; Word/PowerPoint keep
/// the renderer default (top).
pub default_vertical_align: Option<CellVerticalAlign>,
/// When true, a bottom-aligned cell rests its last line's descender on the
/// row's bottom inset edge, as Excel prints. Only spreadsheet tables set
/// this: Word's and PowerPoint's bottom-cell seating is unverified against
/// native GT, so their emission must not change (issue #618).
pub seats_bottom_aligned_text_on_descender: bool,
}

/// A table row.
Expand Down
2 changes: 2 additions & 0 deletions crates/office2pdf/src/parser/docx_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ pub(super) fn convert_table(
default_cell_padding,
use_content_driven_row_heights: false,
default_vertical_align: None,
// Word GT has not verified descender seating for bottom cells (#618).
seats_bottom_aligned_text_on_descender: false,
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/office2pdf/src/parser/pptx_table_style_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ fn test_apply_table_style_first_row_gets_header_fill_and_text_color() {
default_cell_padding: None,
use_content_driven_row_heights: true,
default_vertical_align: None,
seats_bottom_aligned_text_on_descender: false,
};

table_styles::apply_table_style(&mut table, &props, &styles);
Expand Down Expand Up @@ -280,6 +281,7 @@ fn test_apply_table_style_banded_rows_skip_first_row() {
default_cell_padding: None,
use_content_driven_row_heights: true,
default_vertical_align: None,
seats_bottom_aligned_text_on_descender: false,
};

table_styles::apply_table_style(&mut table, &props, &styles);
Expand Down Expand Up @@ -352,6 +354,7 @@ fn test_apply_table_style_explicit_cell_fill_not_overridden() {
default_cell_padding: None,
use_content_driven_row_heights: true,
default_vertical_align: None,
seats_bottom_aligned_text_on_descender: false,
};

table_styles::apply_table_style(&mut table, &props, &styles);
Expand Down Expand Up @@ -395,6 +398,7 @@ fn test_apply_table_style_missing_style_id_is_noop() {
default_cell_padding: None,
use_content_driven_row_heights: true,
default_vertical_align: None,
seats_bottom_aligned_text_on_descender: false,
};

table_styles::apply_table_style(&mut table, &props, &styles);
Expand Down
3 changes: 3 additions & 0 deletions crates/office2pdf/src/parser/pptx_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ impl<'a> PptxTableParser<'a> {
default_cell_padding: Some(default_pptx_table_cell_padding()),
use_content_driven_row_heights: true,
default_vertical_align: None,
// PowerPoint GT has not verified descender seating for bottom
// cells (#618).
seats_bottom_aligned_text_on_descender: false,
};
table_styles::apply_table_style(&mut table, &self.table_props, self.table_styles);
table
Expand Down
3 changes: 3 additions & 0 deletions crates/office2pdf/src/parser/xlsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ impl XlsxParser {
default_cell_padding: Some(xlsx_cells::XLSX_CELL_PADDING),
use_content_driven_row_heights: false,
default_vertical_align: Some(crate::ir::CellVerticalAlign::Bottom),
seats_bottom_aligned_text_on_descender: true,
},
header: sheet_header.clone(),
footer: sheet_footer.clone(),
Expand Down Expand Up @@ -669,6 +670,7 @@ impl Parser for XlsxParser {
default_cell_padding: Some(xlsx_cells::XLSX_CELL_PADDING),
use_content_driven_row_heights: false,
default_vertical_align: Some(crate::ir::CellVerticalAlign::Bottom),
seats_bottom_aligned_text_on_descender: true,
},
header: sheet_header.clone(),
footer: sheet_footer.clone(),
Expand Down Expand Up @@ -744,6 +746,7 @@ impl Parser for XlsxParser {
default_vertical_align: Some(
crate::ir::CellVerticalAlign::Bottom,
),
seats_bottom_aligned_text_on_descender: true,
},
header: sheet_header.clone(),
footer: sheet_footer.clone(),
Expand Down
1 change: 1 addition & 0 deletions crates/office2pdf/src/parser/xlsx_pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ fn slice_table_columns(table: &Table, start: usize, end: usize) -> Table {
default_cell_padding: table.default_cell_padding,
use_content_driven_row_heights: table.use_content_driven_row_heights,
default_vertical_align: table.default_vertical_align,
seats_bottom_aligned_text_on_descender: table.seats_bottom_aligned_text_on_descender,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/office2pdf/src/parser/xlsx_pagination_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn make_page(column_widths: Vec<f64>, rows: Vec<TableRow>) -> SheetPage {
default_cell_padding: None,
use_content_driven_row_heights: false,
default_vertical_align: None,
seats_bottom_aligned_text_on_descender: false,
},
header: None,
footer: None,
Expand Down
17 changes: 17 additions & 0 deletions crates/office2pdf/src/render/typst_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ struct GenCtx {
/// line box. Decided once per row so every cell in it shares a baseline,
/// which reading each cell's own text could not guarantee (issue #498).
row_has_east_asian_text: bool,
/// The enclosing table's default vertical alignment: a cell that declares
/// none takes this, and its paragraph codegen must know the effective
/// answer to seat the line box (issue #618).
table_default_vertical_align: Option<CellVerticalAlign>,
/// Whether the enclosing table rests bottom-aligned text on the descender
/// line, i.e. is a spreadsheet ([`Table::seats_bottom_aligned_text_on_descender`]).
table_seats_bottom_aligned_text_on_descender: bool,
/// Whether the cell being generated seats its line box on the descender:
/// the enclosing table is a spreadsheet and the cell's effective vertical
/// alignment is bottom (issue #618).
cell_seats_text_on_descender: bool,
/// Numerals the active section's `PAGE` fields render in. A header is
/// generated as part of its page's setup, so the section's `w:pgNumType
/// w:fmt` reaches the field through the context rather than through the
Expand All @@ -139,6 +150,9 @@ impl GenCtx {
table_depth: 0,
line_grid_pitch: None,
row_has_east_asian_text: false,
table_default_vertical_align: None,
table_seats_bottom_aligned_text_on_descender: false,
cell_seats_text_on_descender: false,
page_number_format: PageNumberFormat::default(),
document_default_text: None,
document_default_tab_stop_pt: None,
Expand Down Expand Up @@ -644,6 +658,8 @@ fn generate_table_with_anchors(
default_cell_padding: table.default_cell_padding,
use_content_driven_row_heights: table.use_content_driven_row_heights,
default_vertical_align: table.default_vertical_align,
seats_bottom_aligned_text_on_descender: table
.seats_bottom_aligned_text_on_descender,
};
generate_table(out, &segment, ctx)?;
out.push('\n');
Expand Down Expand Up @@ -680,6 +696,7 @@ fn generate_table_with_anchors(
default_cell_padding: table.default_cell_padding,
use_content_driven_row_heights: table.use_content_driven_row_heights,
default_vertical_align: table.default_vertical_align,
seats_bottom_aligned_text_on_descender: table.seats_bottom_aligned_text_on_descender,
};
generate_table(out, &segment, ctx)?;
out.push('\n');
Expand Down
Loading
Loading