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

## Unreleased

- Python `Frame.line()` returns a bound `DrawingLine` with its endpoints instead
of raising a conversion error.

- Spreadsheet rendering bounds columns as well as rows by the cell budget and
avoids rescanning blank spans for every empty cell.

Expand Down
7 changes: 7 additions & 0 deletions python/src/bind_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,13 @@ void odr_python::bind_document(py::module_ &m) {
.def_readwrite("width", &odr::DrawingPath::width)
.def_readwrite("height", &odr::DrawingPath::height);

py::class_<odr::DrawingLine>(m, "DrawingLine")
.def(py::init<>())
.def_readwrite("x1", &odr::DrawingLine::x1)
.def_readwrite("y1", &odr::DrawingLine::y1)
.def_readwrite("x2", &odr::DrawingLine::x2)
.def_readwrite("y2", &odr::DrawingLine::y2);

py::class_<odr::DrawingTransform>(m, "DrawingTransform")
.def(py::init<>())
.def_readwrite("a", &odr::DrawingTransform::a)
Expand Down
23 changes: 23 additions & 0 deletions python/tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,26 @@ def test_recalculate_computes_the_stale_formulas(tmp_path):
assert result.changed()[0].column == 1
assert repr(result.changed()[0]) == "SheetPosition(0!B1)"
assert document.recalculate().changed() == []


def test_frame_line_exposes_its_endpoints():
source = b"""<office:document
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
office:mimetype="application/vnd.oasis.opendocument.graphics">
<office:body><office:drawing><draw:page>
<draw:line svg:x1="1cm" svg:y1="2cm" svg:x2="3cm" svg:y2="4cm"/>
<draw:rect svg:width="1cm" svg:height="1cm"/>
</draw:page></office:drawing></office:body>
</office:document>"""
document = pyodr.open(pyodr.File.from_memory(source)).as_document_file().document()
frames = list(document.root_element().first_child())
line = frames[0].as_frame().line()
assert [str(line.x1), str(line.y1), str(line.x2), str(line.y2)] == [
"1cm",
"2cm",
"3cm",
"4cm",
]
assert frames[1].as_frame().line() is None
Loading