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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The release run heads these entries with the version and opens a fresh

## Unreleased

- A printed sheet drops our row/column ruler and is capped to the page width
rather than cut off at the right edge. Print only; the on-screen view is
unchanged. Towards #816.

- New `File::name()`: the file name on disk, the entry name inside an archive,
or the name `File::from_memory(data, name)` was given. A named in-memory file
gets the same name-derived type candidate a path does, so `notes.md` bytes
Expand Down
11 changes: 11 additions & 0 deletions src/odr/internal/html/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ body{margin:0;background:var(--odr-sheet-canvas)}
.odr-sheet-sort:hover{background:var(--odr-sheet-wash-ruler)}
.odr-sheet-sort::after{content:"\25BE";font-size:15px;line-height:1}
.odr-sheet-sort-asc::after{content:"\25B4"}
/* Paper cannot scroll, so a sheet wider than the page is cut off; only
`!important` beats the inline column width. The ruler collapses rather than
`display:none`, which would take the cells out of their rows and shift every
column left. */
@media print{
.odr-sheet thead{display:none}
.odr-sheet-gutter{visibility:collapse;width:0}
.odr-sheet-row-header{visibility:collapse;padding:0;box-shadow:none}
.odr-sheet{max-width:100%}
.odr-sheet col{min-width:0!important}
}
)css";

constexpr std::string_view spreadsheet_dark_css = R"css(
Expand Down
18 changes: 18 additions & 0 deletions test/src/html_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,24 @@ TEST(html, the_cell_budget_bounds_the_rows_by_the_width) {
EXPECT_EQ(rendered(30, 3).rows, 5);
}

// #816
TEST(html, a_printed_sheet_drops_the_ruler_and_fits_the_page) {
const std::string sheet =
render("odr-public/ods/file_example_ODS_10.ods", HtmlConfig());

// on screen the sheet keeps its stated width and its ruler
EXPECT_NE(sheet.find("<col style=\"width:"), std::string::npos);
EXPECT_NE(sheet.find("table-layout:fixed"), std::string::npos);
EXPECT_NE(sheet.find("class=\"odr-sheet-column-header\""), std::string::npos);

EXPECT_NE(sheet.find(".odr-sheet thead{display:none}"), std::string::npos);
EXPECT_NE(sheet.find(".odr-sheet-gutter{visibility:collapse"),
std::string::npos);
EXPECT_NE(sheet.find(".odr-sheet{max-width:100%}"), std::string::npos);
EXPECT_NE(sheet.find(".odr-sheet col{min-width:0!important}"),
std::string::npos);
}

TEST(html, a_view_that_renders_no_sheet_has_no_cut) {
const DecodedFile file(File::from_memory("<a><b>c</b></a>"), FileType::xml);
const HtmlService service = html::translate(file, HtmlConfig());
Expand Down
Loading