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

## Unreleased

- **Breaking**: `DocumentPath`, `Element::document_path()` and
`Element::navigate_path()` are gone, with their python and Java mirrors.
An element is addressed by `Element::identifier()` and
`Document::element_by_id()`, which is what the edit envelope uses.

- **Breaking**: `ValueType` gains `boolean`, `date`, `time` and `error`, and
the odf and xlsx readers report them; a boolean states 1 or 0 as its number.
`Sheet::set_cell` writes a boolean and refuses the other three. The enum
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ set(ODR_SOURCE_FILES
"src/odr/archive.cpp"
"src/odr/document.cpp"
"src/odr/document_element.cpp"
"src/odr/document_path.cpp"
"src/odr/error_code.cpp"
"src/odr/exceptions.cpp"
"src/odr/file.cpp"
Expand Down Expand Up @@ -343,7 +342,6 @@ set(ODR_SOURCE_FILES
"src/odr/internal/util/byte_util.cpp"
"src/odr/internal/util/byte_stream_util.cpp"
"src/odr/internal/util/byte_string.cpp"
"src/odr/internal/util/document_util.cpp"
"src/odr/internal/util/file_util.cpp"
"src/odr/internal/util/hash_util.cpp"
"src/odr/internal/util/number_util.cpp"
Expand Down
1 change: 0 additions & 1 deletion docs/design/spreadsheet-editing.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ results go stale the moment an input changes.
| Browser: text editor | `html/frontend/document.js` | The skeleton, attached to the mode: the whole view editable, runs keyed by `data-odr-id`, one `setText` op per changed run. No undo |
| Browser: sheet editor | `html/frontend/sheet-editing.js` | The cell overlay, the locks and the position map (steps 1.1 to 1.4, landed), attached to the mode as one editor |
| Wire format | `document.cpp::Document::edit` | The op envelope, `setCell` and `setText` (step 0.4, landed) |
| Addressing | `DocumentPath` | Already spells a cell by position: `/child:0/cell:A1/...` |
| Capabilities | `file_type_table.cpp` | `ods` and `xlsx` declare `edit` and `save` (step 0.2, landed); `csv` declares neither. `odr_test` checks the declaration against `Document::is_editable` |

## Decisions
Expand Down
1 change: 0 additions & 1 deletion jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ add_jar(odr_java
"java/app/opendocument/core/DirectionalString.java"
"java/app/opendocument/core/Document.java"
"java/app/opendocument/core/DocumentFile.java"
"java/app/opendocument/core/DocumentPath.java"
"java/app/opendocument/core/DocumentType.java"
"java/app/opendocument/core/DrawingLine.java"
"java/app/opendocument/core/DrawingPath.java"
Expand Down
59 changes: 0 additions & 59 deletions jni/java/app/opendocument/core/DocumentPath.java

This file was deleted.

16 changes: 0 additions & 16 deletions jni/java/app/opendocument/core/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ public long identifier() {
return identifierNative(handle());
}

public DocumentPath documentPath() {
return new DocumentPath(documentPathNative(handle()));
}

public Element navigatePath(DocumentPath path) {
try {
return wrap(navigatePathNative(handle(), path.handle()));
} finally {
path.keepAlive();
}
}

public List<Element> children() {
List<Element> result = new ArrayList<>();
for (Element child = firstChild(); child != null; child = child.nextSibling()) {
Expand Down Expand Up @@ -215,10 +203,6 @@ final List<Element> wrapAll(long[] handles) {

private native long identifierNative(long handle);

private native long documentPathNative(long handle);

private native long navigatePathNative(long handle, long pathHandle);

private native long asTextRootNative(long handle);

private native long asSlideNative(long handle);
Expand Down
69 changes: 0 additions & 69 deletions jni/src/jni_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <odr/document.hpp>
#include <odr/document_element.hpp>
#include <odr/document_path.hpp>
#include <odr/filesystem.hpp>
#include <odr/html.hpp>

Expand Down Expand Up @@ -245,57 +244,6 @@ Java_app_opendocument_core_Document_asFilesystemNative(JNIEnv *env, jobject,
});
}

// app.opendocument.core.DocumentPath

extern "C" JNIEXPORT jlong JNICALL
Java_app_opendocument_core_DocumentPath_create(JNIEnv *env, jclass,
jstring path) {
return guarded(env, [&] {
return make_handle(odr::DocumentPath(to_string(env, path)));
});
}

extern "C" JNIEXPORT void JNICALL
Java_app_opendocument_core_DocumentPath_destroy(JNIEnv *env, jclass,
jlong handle) {
destroy_handle<odr::DocumentPath>(env, handle);
}

extern "C" JNIEXPORT jboolean JNICALL
Java_app_opendocument_core_DocumentPath_emptyNative(JNIEnv *env, jobject,
jlong handle) {
return guarded(env, [&] {
return static_cast<jboolean>(
from_handle<odr::DocumentPath>(handle)->empty());
});
}

extern "C" JNIEXPORT jlong JNICALL
Java_app_opendocument_core_DocumentPath_parentNative(JNIEnv *env, jobject,
jlong handle) {
return guarded(env, [&] {
return make_handle(from_handle<odr::DocumentPath>(handle)->parent());
});
}

extern "C" JNIEXPORT jlong JNICALL
Java_app_opendocument_core_DocumentPath_joinNative(JNIEnv *env, jobject,
jlong handle,
jlong other_handle) {
return guarded(env, [&] {
return make_handle(from_handle<odr::DocumentPath>(handle)->join(
*from_handle<odr::DocumentPath>(other_handle)));
});
}

extern "C" JNIEXPORT jstring JNICALL
Java_app_opendocument_core_DocumentPath_toStringNative(JNIEnv *env, jobject,
jlong handle) {
return guarded(env, [&] {
return to_jstring(env, from_handle<odr::DocumentPath>(handle)->to_string());
});
}

// app.opendocument.core.Element

extern "C" JNIEXPORT void JNICALL
Expand Down Expand Up @@ -375,23 +323,6 @@ Java_app_opendocument_core_Element_isSameNative(JNIEnv *env, jobject,
});
}

extern "C" JNIEXPORT jlong JNICALL
Java_app_opendocument_core_Element_documentPathNative(JNIEnv *env, jobject,
jlong handle) {
return guarded(env,
[&] { return make_handle(element(handle).document_path()); });
}

extern "C" JNIEXPORT jlong JNICALL
Java_app_opendocument_core_Element_navigatePathNative(JNIEnv *env, jobject,
jlong handle,
jlong path_handle) {
return guarded(env, [&] {
return wrap_element(element(handle).navigate_path(
*from_handle<odr::DocumentPath>(path_handle)));
});
}

// The typed accessors return a fresh `odr::Element` copy when the element
// supports the typed view, 0 otherwise.
#define ODR_JNI_ELEMENT_AS(java_name, method) \
Expand Down
15 changes: 0 additions & 15 deletions jni/tests/app/opendocument/core/DocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,6 @@ void documentFilesystem() throws IOException {
assertTrue(filesystem.isFile("/content.xml"));
}

@Test
void documentPath() throws IOException {
Document document = openDocument();
Element first = document.rootElement().firstChild();
DocumentPath path = first.documentPath();
assertNotNull(path.toString());
assertEquals(path, first.documentPath());

// join() and navigatePath() take another wrapper's handle as an argument
DocumentPath rejoined = path.parent().join(path);
assertTrue(path.parent().empty());
assertEquals(path, rejoined);
assertTrue(document.rootElement().navigatePath(rejoined).isSame(first));
}

@Test
void editAppliesADiff() throws IOException {
Document document = openDocument();
Expand Down
21 changes: 0 additions & 21 deletions python/src/bind_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <odr/document.hpp>
#include <odr/document_element.hpp>
#include <odr/document_path.hpp>
#include <odr/file.hpp>
#include <odr/filesystem.hpp>
#include <odr/style.hpp>
Expand Down Expand Up @@ -123,23 +122,6 @@ void odr_python::bind_document(py::module_ &m) {
.def_static("to_row_string", &odr::TablePosition::to_row_string,
py::arg("row"));

py::class_<odr::DocumentPath>(m, "DocumentPath")
.def(py::init<>())
.def(py::init<const std::string &>(), py::arg("string"))
.def("empty", &odr::DocumentPath::empty)
.def("parent", &odr::DocumentPath::parent)
.def("join", &odr::DocumentPath::join, py::arg("other"))
.def(
"__eq__",
[](const odr::DocumentPath &lhs, const odr::DocumentPath &rhs) {
return lhs == rhs;
},
py::is_operator())
.def("__str__", &odr::DocumentPath::to_string)
.def("__repr__", [](const odr::DocumentPath &path) {
return "DocumentPath('" + path.to_string() + "')";
});

py::class_<odr::Element>(m, "Element")
.def(py::init<>())
.def("__bool__", &odr::Element::operator bool)
Expand All @@ -158,9 +140,6 @@ void odr_python::bind_document(py::module_ &m) {
.def("is_unique", &odr::Element::is_unique)
.def("is_self_locatable", &odr::Element::is_self_locatable)
.def("is_editable", &odr::Element::is_editable)
.def("document_path", &odr::Element::document_path)
.def("navigate_path", &odr::Element::navigate_path, py::arg("path"),
keep_self_alive)
.def("children", &make_children_iterator, keep_self_alive)
.def("__iter__", &make_children_iterator, keep_self_alive)
.def("as_text_root", &odr::Element::as_text_root, keep_self_alive)
Expand Down
13 changes: 0 additions & 13 deletions src/odr/document_element.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <odr/document_element.hpp>

#include <odr/document_path.hpp>
#include <odr/exceptions.hpp>
#include <odr/file.hpp>
#include <odr/style.hpp>
Expand Down Expand Up @@ -143,18 +142,6 @@ bool Element::is_editable() const {
return exists_() ? m_adapter->element_is_editable(m_identifier) : false;
}

DocumentPath Element::document_path() const {
return exists_() ? m_adapter->element_document_path(m_identifier)
: DocumentPath();
}

Element Element::navigate_path(const DocumentPath &path) const {
return exists_()
? Element(m_adapter,
m_adapter->element_navigate_path(m_identifier, path))
: Element();
}

TextRoot Element::as_text_root() const {
if (!exists_()) {
return {};
Expand Down
3 changes: 0 additions & 3 deletions src/odr/document_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace odr {
struct TablePosition;
struct TableDimensions;
class DocumentPath;
class File;
struct TextStyle;
struct ParagraphStyle;
Expand Down Expand Up @@ -224,8 +223,6 @@ class Element {
[[nodiscard]] bool is_unique() const;
[[nodiscard]] bool is_self_locatable() const;
[[nodiscard]] bool is_editable() const;
[[nodiscard]] DocumentPath document_path() const;
[[nodiscard]] Element navigate_path(const DocumentPath &path) const;

[[nodiscard]] ElementRange children() const;

Expand Down
Loading
Loading