Ely Office: six offline-first desktop apps in Rust and GPUI
ElyDoc, ElyTable, ElyShow (LibreOfficeKit), ElyPDF (MuPDF), ElyTree (Git), ElyMark (Milkdown and CodeMirror in CEF). ElyMail and ElyAgent follow.
This commit is contained in:
817 files changed
+143101
No files matched your search
@@ -0,0 +1,19 @@
|
||||
Snapshots keep the incremental sections: undo works after a save.
|
||||
|
||||
pdf_save_snapshot promises the document stays unchanged, yet the
|
||||
write marked every incremental section saved; undoing an earlier
|
||||
step then restored nothing (Ely's PDF save and extract).
|
||||
|
||||
--- a/source/pdf/pdf-write.c 2026-10-06 09:03:50
|
||||
+++ b/source/pdf/pdf-write.c 2026-10-06 09:03:50
|
||||
@@ -2869,7 +2869,9 @@
|
||||
pdf_sync_open_pages(ctx, doc);
|
||||
|
||||
// mark incremental sections as having been saved
|
||||
- doc->num_incremental_sections = 0;
|
||||
+ // A snapshot keeps them, and the undo history.
|
||||
+ if (!in_opts->do_snapshot)
|
||||
+ doc->num_incremental_sections = 0;
|
||||
|
||||
pdf_end_operation(ctx, doc);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
Embedding a file ends its operation; a new link target drops /Dest.
|
||||
|
||||
pdf_add_embedded_file began an operation and never ended it on
|
||||
success; the journal stayed inside it and later undo, redo or
|
||||
state reads threw (Ely attachments).
|
||||
|
||||
pdf_set_link_uri wrote /A but kept an old /Dest, which readers
|
||||
take first; the link kept its old target (Ely link editing).
|
||||
|
||||
--- a/source/pdf/pdf-link.c 2026-10-06 15:47:19
|
||||
+++ b/source/pdf/pdf-link.c 2026-10-06 15:47:47
|
||||
@@ -506,6 +506,7 @@
|
||||
}
|
||||
|
||||
filespec = pdf_add_filespec(ctx, doc, filename, file);
|
||||
+ pdf_end_operation(ctx, doc);
|
||||
}
|
||||
fz_always(ctx)
|
||||
pdf_drop_obj(ctx, file);
|
||||
@@ -630,6 +631,7 @@
|
||||
{
|
||||
pdf_dict_put_drop(ctx, link->obj, PDF_NAME(A),
|
||||
pdf_new_action_from_link(ctx, link->page->doc, uri));
|
||||
+ pdf_dict_del(ctx, link->obj, PDF_NAME(Dest));
|
||||
fz_free(ctx, link->super.uri);
|
||||
link->super.uri = fz_strdup(ctx, uri);
|
||||
pdf_end_operation(ctx, link->page->doc);
|
||||
@@ -0,0 +1,29 @@
|
||||
OCR fails when a requested language does not load.
|
||||
|
||||
Tesseract initialises with the languages it can load and drops the
|
||||
rest; a page asked for in eng+chi_sim was read in English alone and
|
||||
reported as a success (Ely OCR).
|
||||
|
||||
--- a/source/fitz/tessocr.cpp 2026-10-06 16:20:56
|
||||
+++ b/source/fitz/tessocr.cpp 2026-10-06 16:20:56
|
||||
@@ -144,6 +144,20 @@
|
||||
delete api;
|
||||
fz_clear_leptonica_mem(ctx);
|
||||
fz_throw(ctx, FZ_ERROR_LIBRARY, "Tesseract language initialisation failed");
|
||||
+ }
|
||||
+
|
||||
+ {
|
||||
+ std::vector<std::string> loaded;
|
||||
+ int wanted = 1;
|
||||
+ for (const char *s = language; *s; s++)
|
||||
+ wanted += *s == '+';
|
||||
+ api->GetLoadedLanguagesAsVector(&loaded);
|
||||
+ if ((int)loaded.size() < wanted)
|
||||
+ {
|
||||
+ delete api;
|
||||
+ fz_clear_leptonica_mem(ctx);
|
||||
+ fz_throw(ctx, FZ_ERROR_LIBRARY, "Tesseract loaded %d of %d languages in %s", (int)loaded.size(), wanted, language);
|
||||
+ }
|
||||
}
|
||||
|
||||
n = fz_count_options(ctx, options);
|
||||
@@ -0,0 +1,83 @@
|
||||
A signature records its reason and location.
|
||||
|
||||
pdf_sign_signature drew the reason and location into the appearance
|
||||
only; readers look for them in the signature dictionary. Set after
|
||||
signing, they land in a second update and break the byte range, so
|
||||
they are written with the value (Ely signing).
|
||||
|
||||
--- a/include/mupdf/pdf/form.h 2026-10-06 18:45:38
|
||||
+++ b/include/mupdf/pdf/form.h 2026-10-06 18:45:38
|
||||
@@ -252,6 +252,8 @@
|
||||
|
||||
int pdf_signature_is_signed(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime);
|
||||
+/* Also records reason and location; NULL or empty skips. */
|
||||
+void pdf_signature_set_value_said(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime, const char *reason, const char *location);
|
||||
|
||||
int pdf_count_signatures(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
--- a/source/pdf/pdf-form.c 2026-10-06 18:45:38
|
||||
+++ b/source/pdf/pdf-form.c 2026-10-06 18:45:49
|
||||
@@ -1923,6 +1923,11 @@
|
||||
|
||||
void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime)
|
||||
{
|
||||
+ pdf_signature_set_value_said(ctx, doc, field, signer, stime, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+void pdf_signature_set_value_said(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime, const char *reason, const char *location)
|
||||
+{
|
||||
pdf_obj *v = NULL;
|
||||
pdf_obj *o = NULL;
|
||||
pdf_obj *r = NULL;
|
||||
@@ -1966,6 +1971,11 @@
|
||||
pdf_dict_put(ctx, v, PDF_NAME(SubFilter), PDF_NAME(adbe_pkcs7_detached));
|
||||
pdf_dict_put(ctx, v, PDF_NAME(Type), PDF_NAME(Sig));
|
||||
pdf_dict_put_date(ctx, v, PDF_NAME(M), stime);
|
||||
+ /* Before storing: later edits open a new section. */
|
||||
+ if (reason && *reason)
|
||||
+ pdf_dict_put_text_string(ctx, v, PDF_NAME(Reason), reason);
|
||||
+ if (location && *location)
|
||||
+ pdf_dict_put_text_string(ctx, v, PDF_NAME(Location), location);
|
||||
|
||||
o = pdf_dict_put_array(ctx, v, PDF_NAME(Reference), 1);
|
||||
r = pdf_array_put_dict(ctx, o, 0, 4);
|
||||
--- a/source/pdf/pdf-signature.c 2026-10-06 18:45:38
|
||||
+++ b/source/pdf/pdf-signature.c 2026-10-06 18:45:49
|
||||
@@ -233,9 +233,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
+static void
|
||||
+sign_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t t, fz_display_list *disp_list, const char *reason, const char *location);
|
||||
+
|
||||
void
|
||||
pdf_sign_signature_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t t, fz_display_list *disp_list)
|
||||
{
|
||||
+ sign_with_appearance(ctx, widget, signer, t, disp_list, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+sign_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t t, fz_display_list *disp_list, const char *reason, const char *location)
|
||||
+{
|
||||
pdf_document *doc;
|
||||
|
||||
if (pdf_dict_get_inheritable(ctx, widget->obj, PDF_NAME(FT)) != PDF_NAME(Sig))
|
||||
@@ -273,7 +282,7 @@
|
||||
if ((sf & (PDF_SIGFLAGS_SIGSEXIST | PDF_SIGFLAGS_APPENDONLY)) != (PDF_SIGFLAGS_SIGSEXIST | PDF_SIGFLAGS_APPENDONLY))
|
||||
pdf_dict_put_int(ctx, form, PDF_NAME(SigFlags), sf | PDF_SIGFLAGS_SIGSEXIST | PDF_SIGFLAGS_APPENDONLY);
|
||||
|
||||
- pdf_signature_set_value(ctx, doc, wobj, signer, t);
|
||||
+ pdf_signature_set_value_said(ctx, doc, wobj, signer, t, reason, location);
|
||||
end_widget_op(ctx, widget);
|
||||
}
|
||||
fz_catch(ctx)
|
||||
@@ -359,7 +368,7 @@
|
||||
else
|
||||
dlist = pdf_signature_appearance_signed(ctx, rect, lang, NULL, NULL, info, logo);
|
||||
}
|
||||
- pdf_sign_signature_with_appearance(ctx, widget, signer, now, dlist);
|
||||
+ sign_with_appearance(ctx, widget, signer, now, dlist, reason, location);
|
||||
}
|
||||
fz_always(ctx)
|
||||
{
|
||||
@@ -0,0 +1,46 @@
|
||||
A save that cannot open its file still journals later edits.
|
||||
|
||||
prepare_for_save sets save_in_progress and only the writer clears
|
||||
it; when the output file cannot be opened, the flag stayed set and
|
||||
every later change bypassed the journal: edits made no undo step
|
||||
(Ely save to a missing folder).
|
||||
|
||||
--- a/source/pdf/pdf-write.c 2026-10-06 19:50:43
|
||||
+++ b/source/pdf/pdf-write.c 2026-10-06 19:50:43
|
||||
@@ -2186,7 +2186,15 @@
|
||||
doc->save_in_progress = 1;
|
||||
|
||||
if (!in_opts->do_snapshot)
|
||||
- presize_unsaved_signature_byteranges(ctx, doc);
|
||||
+ {
|
||||
+ fz_try(ctx)
|
||||
+ presize_unsaved_signature_byteranges(ctx, doc);
|
||||
+ fz_catch(ctx)
|
||||
+ {
|
||||
+ doc->save_in_progress = 0;
|
||||
+ fz_rethrow(ctx);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
static pdf_obj *
|
||||
@@ -3021,13 +3029,13 @@
|
||||
|
||||
prepare_for_save(ctx, doc, in_opts);
|
||||
|
||||
- if (in_opts->do_incremental)
|
||||
+ fz_try(ctx)
|
||||
+ opts.out = fz_new_output_with_path(ctx, filename, in_opts->do_incremental ? 1 : 0);
|
||||
+ fz_catch(ctx)
|
||||
{
|
||||
- opts.out = fz_new_output_with_path(ctx, filename, 1);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- opts.out = fz_new_output_with_path(ctx, filename, 0);
|
||||
+ /* No write follows to clear it; edits stay journalled. */
|
||||
+ doc->save_in_progress = 0;
|
||||
+ fz_rethrow(ctx);
|
||||
}
|
||||
fz_try(ctx)
|
||||
{
|
||||
Reference in new issue
Block a user