forked from balisujohn/localwriter
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwriteragent_api.py
More file actions
1245 lines (917 loc) · 66.4 KB
/
Copy pathwriteragent_api.py
File metadata and controls
1245 lines (917 loc) · 66.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Auto-generated WriterAgent tool proxy API.
Generated by scripts/generate_tool_proxies.py — DO NOT EDIT.
Provides Python-native access to WriterAgent tools from venv subprocess scripts.
"""
import os
import sys
import threading
import uuid
from plugin.scripting.ipc import read_pickle_frame, write_pickle_frame
# Detect if running in-process (LibreOffice host) or out-of-process (Venv worker)
IS_WORKER = os.environ.get("WRITERAGENT_IS_WORKER") == "1"
# ── RPC transport ──────────────────────────────────────────────
_lock = threading.Lock()
def _rpc_call(tool_name: str, **kwargs) -> dict:
"""Send a tool call to the LibreOffice host and block for the result."""
if not IS_WORKER:
try:
from plugin.framework.uno_context import get_ctx, get_active_document
from plugin.doc.document_helpers import is_calc, is_writer, is_draw
from plugin.main import get_tools
from plugin.framework.tool import ToolContext
uno_ctx = get_ctx()
doc = get_active_document(uno_ctx)
if not doc:
raise RuntimeError("No active document found to run tool")
if is_calc(doc):
doc_type = "calc"
elif is_writer(doc):
doc_type = "writer"
elif is_draw(doc):
doc_type = "draw"
else:
doc_type = ""
registry = get_tools()
tctx = ToolContext(
doc=doc,
ctx=uno_ctx,
doc_type=doc_type,
services=registry._services,
caller="script"
)
return registry.execute(tool_name, tctx, **kwargs)
except Exception as e:
raise RuntimeError(f"Failed to execute tool in-process: {e}")
call_id = str(uuid.uuid4())
request = {"type": "tool_call", "id": call_id, "tool": tool_name, "args": kwargs}
with _lock:
write_pickle_frame(sys.stdout.buffer, request)
# Block and read the response frame from the host on stdin
response = read_pickle_frame(sys.stdin.buffer, require_dict=True)
if response is None:
raise ConnectionError("Lost connection to LibreOffice host during tool call")
if response.get("status") == "error":
raise RuntimeError(response.get("message", response.get("error", "Unknown error")))
return response.get("result", {})
def get_active_document_type() -> str:
"""Return the active document's type ('writer', 'calc', 'draw', or 'unknown')."""
try:
res = _rpc_call("list_open_documents")
for doc in res.get("documents", []):
if doc.get("is_active"):
return doc.get("doc_type", "unknown")
except Exception:
pass
return "unknown"
DOMAIN_TOOLS = { 'analysi': [ 'analyze_data',
'calc_goal_seek',
'calc_solver',
'forecast_data',
'optimize_data',
'plot_data',
'query_folder_sql'],
'bookmark': [ 'cleanup_bookmarks',
'create_bookmark',
'delete_bookmark',
'get_bookmark',
'list_bookmarks',
'rename_bookmark',
'resolve_bookmark'],
'brainstorming': ['brainstorm_research_web', 'save_design_spec'],
'calc': [ 'delegate_to_specialized_calc_toolset',
'delete_structure',
'get_sheet_summary',
'insert_cell_html',
'list_calc_functions',
'merge_cells',
'read_cell_range',
'set_style',
'write_formula_range'],
'chart': ['delete_chart', 'get_chart_info', 'list_charts', 'manage_charts', 'upsert_chart'],
'comment': [ 'add_cell_comment',
'delete_cell_comment',
'delete_comment',
'list_cell_comments',
'list_comments',
'resolve_comment',
'workflow'],
'conditional_formatting': ['add_conditional_format', 'list_conditional_formats', 'remove_conditional_formats'],
'core': [ 'find_tools',
'get_guidance',
'list_open_documents',
'redo',
'report_bug',
'specialized_workflow_finished',
'undo',
'upsert_memory',
'web_research'],
'deep_research': ['deep_research_web'],
'document_research': ['delegate_read_document', 'grep_nearby_files', 'list_nearby_files', 'search_nearby_files'],
'draw': [ 'add_slide',
'delegate_to_specialized_draw_toolset',
'delete_slide',
'get_draw_tree',
'get_placeholder_text',
'get_presentation_info',
'list_pages',
'list_placeholders',
'read_slide_text',
'set_active_page',
'set_placeholder_text'],
'embedded': ['embedded_edit', 'embedded_insert'],
'error': ['detect_and_explain_errors', 'evaluate_formula'],
'field': ['fields_delete', 'fields_insert', 'fields_list', 'fields_update_all', 'update_fields'],
'footnote': [ 'footnotes_delete',
'footnotes_edit',
'footnotes_insert',
'footnotes_list',
'footnotes_settings_get',
'footnotes_settings_update'],
'forms': [ 'create_form',
'create_form_control',
'delete_form_control',
'edit_form_control',
'generate_form',
'list_form_controls'],
'headers_footer': ['get_headers_footers', 'set_headers_footers'],
'images': [ 'delete_image',
'download_image',
'generate_image',
'get_image_info',
'insert_image',
'list_images',
'list_nearby_image_files',
'replace_image',
'set_image_properties'],
'indexe': ['indexes_add_mark', 'indexes_create', 'indexes_list', 'indexes_update_all', 'refresh_indexes'],
'math': ['insert_math'],
'page': [ 'get_header_footer_text',
'get_page_columns',
'get_page_style_properties',
'insert_page_break',
'set_header_footer_text',
'set_page_columns',
'set_page_style_properties'],
'pivot_table': ['create_pivot_table', 'list_pivot_tables', 'refresh_pivot_table'],
'ppt-master': [ 'apply_ppt_master_native_enhance',
'apply_ppt_master_template_fill',
'export_presentation_project',
'validate_ppt_master_project'],
'python': ['run_venv_python_script', 'symbolic_math'],
'range': ['add_named_range', 'delete_named_range', 'list_named_ranges', 'sort_range'],
'search': ['replace_in_spreadsheet', 'search_in_spreadsheet'],
'shape': [ 'delete_shape',
'get_draw_summary',
'list_writer_images',
'shapes_connect',
'shapes_group',
'upsert_shape'],
'sheet': [ 'apply_sheet_filter',
'clear_sheet_filter',
'create_sheet',
'delete_sheet',
'get_sheet_filter',
'list_sheets',
'protect_sheet',
'rename_sheet',
'switch_sheet'],
'slide_master': ['get_slide_master', 'list_master_slides', 'set_slide_master'],
'slide_transition': ['get_slide_layout', 'get_slide_transition', 'set_slide_layout', 'set_slide_transition'],
'speaker_note': ['get_speaker_notes', 'set_speaker_notes'],
'structural': [ 'get_heading_children',
'get_surroundings',
'goto_page',
'list_sections',
'navigate_heading',
'read_section'],
'styles': ['create_style', 'get_style_info', 'import_styles', 'list_styles', 'update_style'],
'table': [ 'delete_table_column',
'delete_table_row',
'get_table_cells',
'insert_table_column',
'insert_table_row',
'list_tables',
'set_table_cell'],
'textframe': ['get_text_frame_info', 'list_text_frames', 'set_text_frame_properties'],
'tracking': [ 'track_changes_accept',
'track_changes_accept_all',
'track_changes_comment_delete',
'track_changes_comment_insert',
'track_changes_comment_list',
'track_changes_list',
'track_changes_reject',
'track_changes_reject_all',
'track_changes_show',
'track_changes_start',
'track_changes_stop'],
'vision': ['extract_text_from_image'],
'writer': [ 'add_comment',
'apply_document_content',
'apply_style',
'delegate_to_specialized_writer_toolset',
'get_document_content',
'get_document_tree',
'get_image',
'get_page_objects',
'search_in_document',
'set_selection'],
'writing_plan': ['write_document_section', 'writing_research_web']}
class _AnalysiProxy:
"""Proxy for analysi tools."""
def analyze_data(self, helper: str, *, params: dict = {}, data_range: str = "", output_range: str = "", headers: bool = True, task_hint: str = "", auto_plot: bool = True) -> dict:
"""Run a trusted numpy/pandas analysis helper on spreadsheet data."""
return _rpc_call("analyze_data", helper=helper, params=params, data_range=data_range, output_range=output_range, headers=headers, task_hint=task_hint, auto_plot=auto_plot)
def calc_goal_seek(self, formula_cell: str, variable_cell: str, target_value: float, *, apply_result: bool = True) -> dict:
"""Finds the value for a variable cell that makes a formula cell reach a target value.."""
return _rpc_call("calc_goal_seek", formula_cell=formula_cell, variable_cell=variable_cell, target_value=target_value, apply_result=apply_result)
def calc_solver(self, objective_cell: str, variables: list, *, maximize: bool = True, constraints: list = [], engine: str = "") -> dict:
"""Solves an optimization problem to maximize, minimize, or reach a value for an objective cell by changing multiple variable cells subject to constraints.."""
return _rpc_call("calc_solver", objective_cell=objective_cell, variables=variables, maximize=maximize, constraints=constraints, engine=engine)
def forecast_data(self, helper: str, *, params: dict = {}, data_range: str = "", output_range: str = "", headers: bool = True, task_hint: str = "") -> dict:
"""Run a trusted time-series forecasting helper on spreadsheet data."""
return _rpc_call("forecast_data", helper=helper, params=params, data_range=data_range, output_range=output_range, headers=headers, task_hint=task_hint)
def optimize_data(self, helper: str, *, params: dict = {}, data_range: str = "", output_range: str = "", headers: bool = True, task_hint: str = "") -> dict:
"""Run a trusted optimization helper on spreadsheet data."""
return _rpc_call("optimize_data", helper=helper, params=params, data_range=data_range, output_range=output_range, headers=headers, task_hint=task_hint)
def plot_data(self, helper: str, *, params: dict = {}, data_range: str = "", headers: bool = True, task_hint: str = "") -> dict:
"""Run a trusted visualization helper on spreadsheet data."""
return _rpc_call("plot_data", helper=helper, params=params, data_range=data_range, headers=headers, task_hint=task_hint)
def query_folder_sql(self, sql: str, *, files: list = [], data_range: str = "", headers: bool = True, tables: dict = {}, task_hint: str = "") -> dict:
"""Run read-only SQL (via DuckDB) against folder files and/or live Calc ranges (Phase C multi-table)."""
return _rpc_call("query_folder_sql", sql=sql, files=files, data_range=data_range, headers=headers, tables=tables, task_hint=task_hint)
analysi = _AnalysiProxy()
class _BookmarkProxy:
"""Proxy for bookmark tools."""
def cleanup_bookmarks(self) -> dict:
"""Remove all _mcp_* bookmarks from the document."""
return _rpc_call("cleanup_bookmarks")
def create_bookmark(self, name: str) -> dict:
"""Create a new bookmark at the current cursor or selection in Writer."""
return _rpc_call("create_bookmark", name=name)
def delete_bookmark(self, name: str) -> dict:
"""Delete an existing bookmark by its name.."""
return _rpc_call("delete_bookmark", name=name)
def get_bookmark(self, name: str) -> dict:
"""Get details about a specific bookmark, including the text it spans.."""
return _rpc_call("get_bookmark", name=name)
def list_bookmarks(self) -> dict:
"""List all bookmarks in the document with their anchor text preview."""
return _rpc_call("list_bookmarks")
def rename_bookmark(self, old_name: str, new_name: str) -> dict:
"""Rename an existing bookmark.."""
return _rpc_call("rename_bookmark", old_name=old_name, new_name=new_name)
def resolve_bookmark(self, bookmark_name: str) -> dict:
"""Resolve a bookmark to its current paragraph index and text."""
return _rpc_call("resolve_bookmark", bookmark_name=bookmark_name)
bookmark = _BookmarkProxy()
class _BrainstormingProxy:
"""Proxy for brainstorming tools."""
def brainstorm_research_web(self, query: str) -> dict:
"""Search the public web for context during brainstorming."""
return _rpc_call("brainstorm_research_web", query=query)
def save_design_spec(self, content: list, *, target: str = "") -> dict:
"""Save the approved design spec to the active Writer document."""
return _rpc_call("save_design_spec", content=content, target=target)
brainstorming = _BrainstormingProxy()
class _CalcProxy:
"""Proxy for calc tools."""
def delegate_to_specialized_calc_toolset(self, domain: str, task: str) -> dict:
"""Delegates a specialized Calc task."""
return _rpc_call("delegate_to_specialized_calc_toolset", domain=domain, task=task)
def delete_structure(self, structure_type: str, start: str, *, count: int = 0) -> dict:
"""Deletes rows or columns."""
return _rpc_call("delete_structure", structure_type=structure_type, start=start, count=count)
def get_sheet_summary(self, *, sheet_name: str = "") -> dict:
"""Returns a comprehensive summary of the active or specified sheet: used area, column headers, charts, merged cells, annotations, and shapes.."""
return _rpc_call("get_sheet_summary", sheet_name=sheet_name)
def insert_cell_html(self, cell_address: str, html: str) -> dict:
"""Parses HTML with the same filter as Writer and pastes rich text into one cell on the active sheet (e.g."""
return _rpc_call("insert_cell_html", cell_address=cell_address, html=html)
def list_calc_functions(self, *, filter: str = "") -> dict:
"""Lists available Calc spreadsheet functions."""
return _rpc_call("list_calc_functions", filter=filter)
def merge_cells(self, range_name: list, *, center: bool = True) -> dict:
"""Merges the specified cell range(s)."""
return _rpc_call("merge_cells", range_name=range_name, center=center)
def read_cell_range(self, range_name: list) -> dict:
"""Reads values from the specified cell range(s)."""
return _rpc_call("read_cell_range", range_name=range_name)
def set_style(self, range_name: list, *, bold: bool = True, italic: bool = True, font_size: float = 0.0, bg_color: str = "", font_color: str = "", h_align: str = "", v_align: str = "", wrap_text: bool = True, border_color: str = "", number_format: str = "") -> dict:
"""Applies style and formatting to the specified cell(s) or range(s)."""
return _rpc_call("set_style", range_name=range_name, bold=bold, italic=italic, font_size=font_size, bg_color=bg_color, font_color=font_color, h_align=h_align, v_align=v_align, wrap_text=wrap_text, border_color=border_color, number_format=number_format)
def write_formula_range(self, range_name: list, formula_or_values: str) -> dict:
"""Writes formulas or values to a cell range(s) efficiently."""
return _rpc_call("write_formula_range", range_name=range_name, formula_or_values=formula_or_values)
calc = _CalcProxy()
class _ChartProxy:
"""Proxy for chart tools."""
def delete_chart(self, chart_name: str) -> dict:
"""Delete a chart by name.."""
return _rpc_call("delete_chart", chart_name=chart_name)
def get_chart_info(self, chart_name: str) -> dict:
"""Get detailed info about a chart: type, title, ranges (if Calc), axis titles, and legend properties.."""
return _rpc_call("get_chart_info", chart_name=chart_name)
def list_charts(self) -> dict:
"""List all charts in the current context (active sheet, document, or slide) with name, title, and type.."""
return _rpc_call("list_charts")
def manage_charts(self, action: str, *, chart_name: str = "", data_range: str = "", headers: list = [], rows: list = [], chart_type: str = "", title: str = "", subtitle: str = "", is_3d: bool = True, stacked: bool = True, percent: bool = True, x_axis_title: str = "", y_axis_title: str = "", legend_position: str = "", has_legend: bool = True, position: str = "", bg_color: str = "", colors: list = []) -> dict:
"""Manage charts: list, get_info, create, edit, or delete a chart in the current context (active sheet, document, or slide).."""
return _rpc_call("manage_charts", action=action, chart_name=chart_name, data_range=data_range, headers=headers, rows=rows, chart_type=chart_type, title=title, subtitle=subtitle, is_3d=is_3d, stacked=stacked, percent=percent, x_axis_title=x_axis_title, y_axis_title=y_axis_title, legend_position=legend_position, has_legend=has_legend, position=position, bg_color=bg_color, colors=colors)
def upsert_chart(self, action: str, *, chart_name: str = "", data_range: str = "", headers: list = [], rows: list = [], chart_type: str = "", title: str = "", is_3d: bool = True, stacked: bool = True, percent: bool = True, x_axis_title: str = "", y_axis_title: str = "", legend_position: str = "", has_legend: bool = True, subtitle: str = "", position: str = "", bg_color: str = "", colors: list = []) -> dict:
"""Creates a new chart or modifies an existing chart on a sheet, document, or slide.."""
return _rpc_call("upsert_chart", action=action, chart_name=chart_name, data_range=data_range, headers=headers, rows=rows, chart_type=chart_type, title=title, is_3d=is_3d, stacked=stacked, percent=percent, x_axis_title=x_axis_title, y_axis_title=y_axis_title, legend_position=legend_position, has_legend=has_legend, subtitle=subtitle, position=position, bg_color=bg_color, colors=colors)
chart = _ChartProxy()
class _CommentProxy:
"""Proxy for comment tools."""
def add_cell_comment(self, cell: str, text: str, *, sheet_name: str = "") -> dict:
"""Add a comment (annotation) to a specific cell in a Calc sheet.."""
return _rpc_call("add_cell_comment", cell=cell, text=text, sheet_name=sheet_name)
def delete_cell_comment(self, cell: str, *, sheet_name: str = "") -> dict:
"""Delete the comment (annotation) from a specific cell.."""
return _rpc_call("delete_cell_comment", cell=cell, sheet_name=sheet_name)
def delete_comment(self, *, comment_name: str = "", author: str = "") -> dict:
"""Delete comments by name or author."""
return _rpc_call("delete_comment", comment_name=comment_name, author=author)
def list_cell_comments(self, *, sheet_name: str = "") -> dict:
"""List all cell comments (annotations) in a Calc sheet."""
return _rpc_call("list_cell_comments", sheet_name=sheet_name)
def list_comments(self, *, author_filter: str = "") -> dict:
"""List all comments/annotations in the document, including author, content, date, resolved status, and anchor preview."""
return _rpc_call("list_comments", author_filter=author_filter)
def resolve_comment(self, comment_name: str, *, resolution: str = "", author: str = "") -> dict:
"""Resolve a comment with an optional reason."""
return _rpc_call("resolve_comment", comment_name=comment_name, resolution=resolution, author=author)
def workflow(self, action: str, *, unresolved_only: bool = True, prefix_filter: str = "", content: str = "") -> dict:
"""Workflow and task operations."""
return _rpc_call("workflow", action=action, unresolved_only=unresolved_only, prefix_filter=prefix_filter, content=content)
comment = _CommentProxy()
class _ConditionalFormattingProxy:
"""Proxy for conditional_formatting tools."""
def add_conditional_format(self, range_name: str, operator: str, style_name: str, *, formula1: str = "", formula2: str = "") -> dict:
"""Add a conditional formatting rule to a Calc cell range."""
return _rpc_call("add_conditional_format", range_name=range_name, operator=operator, formula1=formula1, formula2=formula2, style_name=style_name)
def list_conditional_formats(self, *, range_name: str = "") -> dict:
"""List conditional formatting rules on a Calc cell range."""
return _rpc_call("list_conditional_formats", range_name=range_name)
def remove_conditional_formats(self, range_name: str, *, rule_index: int = 0) -> dict:
"""Remove a conditional formatting rule from a Calc cell range by index, or clear all rules if no index is provided."""
return _rpc_call("remove_conditional_formats", range_name=range_name, rule_index=rule_index)
conditional_formatting = _ConditionalFormattingProxy()
class _CoreProxy:
"""Proxy for core tools."""
def find_tools(self, *, domain: str = "") -> dict:
"""Discover additional tools that are available but not listed here."""
return _rpc_call("find_tools", domain=domain)
def get_guidance(self, *, topic: str = "") -> dict:
"""Read WriterAgent's how-to-use manual on demand."""
return _rpc_call("get_guidance", topic=topic)
def list_open_documents(self) -> dict:
"""List all currently open documents in LibreOffice."""
return _rpc_call("list_open_documents")
def redo(self, *, steps: int = 0) -> dict:
"""Redo the last undone change(s) in the document (all document types)."""
return _rpc_call("redo", steps=steps)
def report_bug(self, summary: str, *, details: str = "", category: str = "") -> dict:
"""Report a WriterAgent bug or bad experience — the agent itself may call this when a tool misbehaves, returns a confusing result, or the workflow felt wrong."""
return _rpc_call("report_bug", summary=summary, details=details, category=category)
def specialized_workflow_finished(self, answer: str) -> dict:
"""Provides a final answer to the given task and exits the specialized toolset mode.."""
return _rpc_call("specialized_workflow_finished", answer=answer)
def undo(self, *, steps: int = 0) -> dict:
"""Undo the last change(s) in the document (all document types)."""
return _rpc_call("undo", steps=steps)
def upsert_memory(self, key: str, content: str) -> dict:
"""Persistent memory for the agent."""
return _rpc_call("upsert_memory", key=key, content=content)
def web_research(self, query: str, *, history_text: str = "") -> dict:
"""Perform deep web research to answer complex questions."""
return _rpc_call("web_research", query=query, history_text=history_text)
core = _CoreProxy()
class _DeepResearchProxy:
"""Proxy for deep_research tools."""
def web(self, query: str) -> dict:
"""Run breadth/depth public web research on a topic."""
return _rpc_call("deep_research_web", query=query)
deep_research = _DeepResearchProxy()
class _DocumentResearchProxy:
"""Proxy for document_research tools."""
def delegate_read_document(self, path_or_name: str, task: str) -> dict:
"""Open a nearby file by path or basename (read-only, hidden) and run a read-only sub-agent with production read tools for that file type."""
return _rpc_call("delegate_read_document", path_or_name=path_or_name, task=task)
def grep_nearby_files(self, pattern: str, *, file_subset: str = "", regex: bool = True, case_sensitive: bool = True) -> dict:
"""Search nearby LibreOffice files for text and return snippet previews per matching file."""
return _rpc_call("grep_nearby_files", pattern=pattern, file_subset=file_subset, regex=regex, case_sensitive=case_sensitive)
def list_nearby_files(self, *, filter: str = "", file_kind: str = "") -> dict:
"""List files in the same folder as the active document (newest first)."""
return _rpc_call("list_nearby_files", filter=filter, file_kind=file_kind)
def search_nearby_files(self, query: str, *, k: int = 0, near_slop: int = 0, file_subset: str = "") -> dict:
"""Search the active folder index (keyword BM25/NEAR + semantic embeddings, fused ranking)."""
return _rpc_call("search_nearby_files", query=query, k=k, near_slop=near_slop, file_subset=file_subset)
document_research = _DocumentResearchProxy()
class _DrawProxy:
"""Proxy for draw tools."""
def add_slide(self, *, page_index: int = 0, switch_to_new_slide: bool = True) -> dict:
"""Inserts a new slide (page) at the specified index.."""
return _rpc_call("add_slide", page_index=page_index, switch_to_new_slide=switch_to_new_slide)
def delegate_to_specialized_draw_toolset(self, domain: str, task: str) -> dict:
"""Delegates a specialized Draw task."""
return _rpc_call("delegate_to_specialized_draw_toolset", domain=domain, task=task)
def delete_slide(self, page_index: int) -> dict:
"""Deletes the slide (page) at the specified index.."""
return _rpc_call("delete_slide", page_index=page_index)
def get_draw_tree(self, *, page_index: int = 0) -> dict:
"""Returns a semantic tree (DOM) of the shapes on the active or specified draw page."""
return _rpc_call("get_draw_tree", page_index=page_index)
def get_placeholder_text(self, *, role: str = "", shape_index: int = 0, page_index: int = 0) -> dict:
"""Get text from a slide placeholder."""
return _rpc_call("get_placeholder_text", role=role, shape_index=shape_index, page_index=page_index)
def get_presentation_info(self) -> dict:
"""Get presentation metadata: slide count, dimensions, master slide names, and whether it is an Impress document.."""
return _rpc_call("get_presentation_info")
def list_pages(self) -> dict:
"""Lists all pages (slides) in the document.."""
return _rpc_call("list_pages")
def list_placeholders(self, *, page_index: int = 0) -> dict:
"""List all text placeholders on a slide with their role (title, subtitle, body), text content, and shape index.."""
return _rpc_call("list_placeholders", page_index=page_index)
def read_slide_text(self, *, page_index: int = 0) -> dict:
"""Read all text content from a slide (shapes text) and speaker notes."""
return _rpc_call("read_slide_text", page_index=page_index)
def set_active_page(self, page_index: int) -> dict:
"""Changes the currently active slide (page) in Draw/Impress.."""
return _rpc_call("set_active_page", page_index=page_index)
def set_placeholder_text(self, text: str, *, role: str = "", shape_index: int = 0, page_index: int = 0) -> dict:
"""Set text on a slide placeholder."""
return _rpc_call("set_placeholder_text", text=text, role=role, shape_index=shape_index, page_index=page_index)
draw = _DrawProxy()
class _EmbeddedProxy:
"""Proxy for embedded tools."""
def edit(self, *, name: str = "") -> dict:
"""Activate or edit an embedded OLE object (planned).."""
return _rpc_call("embedded_edit", name=name)
def insert(self, *, object_type: str = "", target: str = "", old_content: str = "") -> dict:
"""Insert an embedded object (e.g."""
return _rpc_call("embedded_insert", object_type=object_type, target=target, old_content=old_content)
embedded = _EmbeddedProxy()
class _ErrorProxy:
"""Proxy for error tools."""
def detect_and_explain_errors(self, *, range_name: list = []) -> dict:
"""Detects formula errors in the specified range(s) and provides an explanation and fix suggestion."""
return _rpc_call("detect_and_explain_errors", range_name=range_name)
def evaluate_formula(self, formula: str, *, cell: str = "") -> dict:
"""Evaluates a Calc formula on a temporary duplicate sheet and returns the result or error, without modifying the active sheets.."""
return _rpc_call("evaluate_formula", formula=formula, cell=cell)
error = _ErrorProxy()
class _FieldProxy:
"""Proxy for field tools."""
def delete(self, ids: list) -> dict:
"""Deletes one or more text fields from the document by their 1-based ID."""
return _rpc_call("fields_delete", ids=ids)
def insert(self, field_type: str, *, properties: dict = {}, target: str = "", old_content: str = "") -> dict:
"""Insert a text field at the specified target position."""
return _rpc_call("fields_insert", field_type=field_type, properties=properties, target=target, old_content=old_content)
def list(self) -> dict:
"""List all text fields in the document."""
return _rpc_call("fields_list")
def update_all(self) -> dict:
"""Refresh all text fields (dates, page numbers, cross-references)."""
return _rpc_call("fields_update_all")
def update_fields(self) -> dict:
"""Refresh all text fields."""
return _rpc_call("update_fields")
field = _FieldProxy()
class _FootnoteProxy:
"""Proxy for footnote tools."""
def delete(self, note_type: str, index: int) -> dict:
"""Deletes an existing footnote or endnote based on its index (from footnotes_list).."""
return _rpc_call("footnotes_delete", note_type=note_type, index=index)
def edit(self, note_type: str, index: int, *, text: str = "", label: str = "") -> dict:
"""Edits an existing footnote or endnote."""
return _rpc_call("footnotes_edit", note_type=note_type, index=index, text=text, label=label)
def insert(self, note_type: str, text: str, *, label: str = "", insert_after_text: str = "", occurrence: int = 0, case_sensitive: bool = True) -> dict:
"""Inserts a new footnote or endnote."""
return _rpc_call("footnotes_insert", note_type=note_type, text=text, label=label, insert_after_text=insert_after_text, occurrence=occurrence, case_sensitive=case_sensitive)
def list(self, note_type: str) -> dict:
"""Lists all existing footnotes or endnotes in the document, including their indices, labels (if custom), and text content."""
return _rpc_call("footnotes_list", note_type=note_type)
def settings_get(self, note_type: str) -> dict:
"""Gets the current formatting and numbering settings for footnotes or endnotes."""
return _rpc_call("footnotes_settings_get", note_type=note_type)
def settings_update(self, note_type: str, properties: dict) -> dict:
"""Updates the formatting and numbering settings for footnotes or endnotes."""
return _rpc_call("footnotes_settings_update", note_type=note_type, properties=properties)
footnote = _FootnoteProxy()
class _FormsProxy:
"""Proxy for forms tools."""
def create_form(self, fields: list) -> dict:
"""Creates multiple form controls at once from a list of field definitions."""
return _rpc_call("create_form", fields=fields)
def create_form_control(self, type: str, name: str, *, label: str = "", group_name: str = "", items: list = [], placeholder: str = "", default_value: str = "", width: int = 0, height: int = 0) -> dict:
"""Creates a single interactive form control (checkbox, text field, radio button, date field, combobox, or button)."""
return _rpc_call("create_form_control", type=type, label=label, name=name, group_name=group_name, items=items, placeholder=placeholder, default_value=default_value, width=width, height=height)
def delete_form_control(self, shape_index: int) -> dict:
"""Deletes a form control by shape index (Calc: active sheet draw page).."""
return _rpc_call("delete_form_control", shape_index=shape_index)
def edit_form_control(self, shape_index: int, *, name: str = "", label: str = "", text: str = "", items: list = [], x: int = 0, y: int = 0, width: int = 0, height: int = 0) -> dict:
"""Modifies an existing form control by index (from list_form_controls)."""
return _rpc_call("edit_form_control", shape_index=shape_index, name=name, label=label, text=text, items=items, x=x, y=y, width=width, height=height)
def generate_form(self, description: str) -> dict:
"""Generates a document or sheet layout with interactive form fields from a description."""
return _rpc_call("generate_form", description=description)
def list_form_controls(self) -> dict:
"""Lists interactive form controls (checkboxes, text fields, etc.) with indices and values."""
return _rpc_call("list_form_controls")
forms = _FormsProxy()
class _HeadersFooterProxy:
"""Proxy for headers_footer tools."""
def get_headers_footers(self, page_index: int, *, is_master_page: bool = True) -> dict:
"""Retrieves header, footer, date/time, and slide number configuration for a specific slide or master page in a presentation.."""
return _rpc_call("get_headers_footers", page_index=page_index, is_master_page=is_master_page)
def set_headers_footers(self, page_index: int, *, is_master_page: bool = True, header_text: str = "", footer_text: str = "", date_time_text: str = "", is_header_visible: bool = True, is_footer_visible: bool = True, is_page_number_visible: bool = True, is_date_time_visible: bool = True, is_date_time_fixed: bool = True) -> dict:
"""Updates header, footer, date/time, and slide number configuration for a specific slide or master page in a presentation.."""
return _rpc_call("set_headers_footers", page_index=page_index, is_master_page=is_master_page, header_text=header_text, footer_text=footer_text, date_time_text=date_time_text, is_header_visible=is_header_visible, is_footer_visible=is_footer_visible, is_page_number_visible=is_page_number_visible, is_date_time_visible=is_date_time_visible, is_date_time_fixed=is_date_time_fixed)
headers_footer = _HeadersFooterProxy()
class _ImagesProxy:
"""Proxy for images tools."""
def delete_image(self, image_name: str, *, remove_frame: bool = True) -> dict:
"""Delete an image from the document.."""
return _rpc_call("delete_image", image_name=image_name, remove_frame=remove_frame)
def download_image(self, url: str, *, verify_ssl: bool = True, force: bool = True) -> dict:
"""Download an image from URL to local cache."""
return _rpc_call("download_image", url=url, verify_ssl=verify_ssl, force=force)
def generate_image(self, prompt: str, *, source_image: str = "", strength: float = 0.75, aspect_ratio: str = 'square', base_size: int = 512, width: int = 0, height: int = 0, provider: str = "", image_model: str = "") -> dict:
"""Generate an image from a text prompt and insert it."""
return _rpc_call("generate_image", prompt=prompt, source_image=source_image, strength=strength, aspect_ratio=aspect_ratio, base_size=base_size, width=width, height=height, provider=provider, image_model=image_model)
def get_image_info(self, image_name: str) -> dict:
"""Get detailed info about a specific image: URL, dimensions, anchor type, orientation, crop (crop_mm, mm trimmed per edge), and paragraph index.."""
return _rpc_call("get_image_info", image_name=image_name)
def insert_image(self, image_path: str, *, locator: str = "", paragraph_index: int = 0, width_mm: int = 0, height_mm: int = 0) -> dict:
"""Insert an image from local path or URL into the document."""
return _rpc_call("insert_image", image_path=image_path, locator=locator, paragraph_index=paragraph_index, width_mm=width_mm, height_mm=height_mm)
def list_images(self) -> dict:
"""List all images/graphic objects in the document with name, dimensions, title, and description.."""
return _rpc_call("list_images")
def list_nearby_image_files(self, *, filter: str = "") -> dict:
"""List image files (.png, .jpg, .jpeg, .gif, .webp, .bmp, .svg) in the same folder as the active document (newest first)."""
return _rpc_call("list_nearby_image_files", filter=filter)
def replace_image(self, image_name: str, new_image_path: str, *, width_mm: float = 0.0, height_mm: float = 0.0) -> dict:
"""Replace an image's source file keeping position and frame.."""
return _rpc_call("replace_image", image_name=image_name, new_image_path=new_image_path, width_mm=width_mm, height_mm=height_mm)
def set_image_properties(self, image_name: str, *, width_mm: float = 0.0, height_mm: float = 0.0, title: str = "", description: str = "", anchor_type: int = 0, hori_orient: str = "", vert_orient: str = "", crop_top_mm: float = 0.0, crop_bottom_mm: float = 0.0, crop_left_mm: float = 0.0, crop_right_mm: float = 0.0) -> dict:
"""Resize, reposition, crop, or update caption/alt-text for an image."""
return _rpc_call("set_image_properties", image_name=image_name, width_mm=width_mm, height_mm=height_mm, title=title, description=description, anchor_type=anchor_type, hori_orient=hori_orient, vert_orient=vert_orient, crop_top_mm=crop_top_mm, crop_bottom_mm=crop_bottom_mm, crop_left_mm=crop_left_mm, crop_right_mm=crop_right_mm)
images = _ImagesProxy()
class _IndexeProxy:
"""Proxy for indexe tools."""
def add_mark(self, mark_text: str, *, index_kind: str = "", primary_key: str = "", secondary_key: str = "", target: str = "", old_content: str = "") -> dict:
"""Add an index mark (e.g."""
return _rpc_call("indexes_add_mark", mark_text=mark_text, index_kind=index_kind, primary_key=primary_key, secondary_key=secondary_key, target=target, old_content=old_content)
def create(self, index_kind: str, *, title: str = "", create_from_outline: bool = True, target: str = "", old_content: str = "") -> dict:
"""Create a new document index (e.g."""
return _rpc_call("indexes_create", index_kind=index_kind, title=title, create_from_outline=create_from_outline, target=target, old_content=old_content)
def list(self) -> dict:
"""List all document indexes (table of contents, alphabetical index, bibliography, etc.).."""
return _rpc_call("indexes_list")
def refresh_indexes(self) -> dict:
"""Refresh all document indexes (TOC, bibliography, etc.)."""
return _rpc_call("refresh_indexes")
def update_all(self) -> dict:
"""Refresh/update all document indexes (table of contents, bibliography, etc.).."""
return _rpc_call("indexes_update_all")
indexe = _IndexeProxy()
class _MathProxy:
"""Proxy for math tools."""
def insert_math(self, formula_type: str, formula: str, page_index: int, x: int, y: int) -> dict:
"""Inserts an editable LibreOffice Math formula on a Draw or Impress page."""
return _rpc_call("insert_math", formula_type=formula_type, formula=formula, page_index=page_index, x=x, y=y)
math = _MathProxy()
class _PageProxy:
"""Proxy for page tools."""
def get_header_footer_text(self, region: str, *, style_name: str = "") -> dict:
"""Retrieve the text content of a page style's header or footer.."""
return _rpc_call("get_header_footer_text", style_name=style_name, region=region)
def get_page_columns(self, *, style_name: str = "") -> dict:
"""Get the column layout for a page style.."""
return _rpc_call("get_page_columns", style_name=style_name)
def get_page_style_properties(self, *, style_name: str = "") -> dict:
"""Get dimensions, margins, and header/footer states of a page style.."""
return _rpc_call("get_page_style_properties", style_name=style_name)
def insert_page_break(self, *, before_text: str = "", after_text: str = "", occurrence: int = 0, case_sensitive: bool = True) -> dict:
"""Start a new page."""
return _rpc_call("insert_page_break", before_text=before_text, after_text=after_text, occurrence=occurrence, case_sensitive=case_sensitive)
def set_header_footer_text(self, region: str, content: str, *, style_name: str = "") -> dict:
"""Set the text content of a page style's header or footer."""
return _rpc_call("set_header_footer_text", style_name=style_name, region=region, content=content)
def set_page_columns(self, column_count: int, *, style_name: str = "", spacing_mm: float = 0.0) -> dict:
"""Set the number of columns and spacing for a page style.."""
return _rpc_call("set_page_columns", style_name=style_name, column_count=column_count, spacing_mm=spacing_mm)
def set_page_style_properties(self, *, style_name: str = "", width_mm: float = 0.0, height_mm: float = 0.0, is_landscape: bool = True, left_margin_mm: float = 0.0, right_margin_mm: float = 0.0, top_margin_mm: float = 0.0, bottom_margin_mm: float = 0.0, gutter_margin_mm: float = 0.0, header_is_on: bool = True, footer_is_on: bool = True, header_is_shared: bool = True, footer_is_shared: bool = True, header_height_mm: float = 0.0, footer_height_mm: float = 0.0, header_body_distance_mm: float = 0.0, footer_body_distance_mm: float = 0.0, back_color: int = 0, back_transparent: bool = True, numbering_type: int = 0, footnote_height_mm: float = 0.0, register_paragraph_style: str = "", page_style_layout: int = 0) -> dict:
"""Modify dimensions, margins, and header/footer toggles of a page style.."""
return _rpc_call("set_page_style_properties", style_name=style_name, width_mm=width_mm, height_mm=height_mm, is_landscape=is_landscape, left_margin_mm=left_margin_mm, right_margin_mm=right_margin_mm, top_margin_mm=top_margin_mm, bottom_margin_mm=bottom_margin_mm, gutter_margin_mm=gutter_margin_mm, header_is_on=header_is_on, footer_is_on=footer_is_on, header_is_shared=header_is_shared, footer_is_shared=footer_is_shared, header_height_mm=header_height_mm, footer_height_mm=footer_height_mm, header_body_distance_mm=header_body_distance_mm, footer_body_distance_mm=footer_body_distance_mm, back_color=back_color, back_transparent=back_transparent, numbering_type=numbering_type, footnote_height_mm=footnote_height_mm, register_paragraph_style=register_paragraph_style, page_style_layout=page_style_layout)
page = _PageProxy()
class _PivotTableProxy:
"""Proxy for pivot_table tools."""
def create_pivot_table(self, pivot_table_name: str, source_range: str, destination_cell: str, data_fields: list, *, source_sheet_name: str = "", destination_sheet_name: str = "", row_fields: list = [], column_fields: list = [], page_fields: list = []) -> dict:
"""Create a pivot table (DataPilot) from a source data range."""
return _rpc_call("create_pivot_table", pivot_table_name=pivot_table_name, source_range=source_range, source_sheet_name=source_sheet_name, destination_cell=destination_cell, destination_sheet_name=destination_sheet_name, row_fields=row_fields, column_fields=column_fields, data_fields=data_fields, page_fields=page_fields)
def list_pivot_tables(self, *, sheet_name: str = "") -> dict:
"""List pivot tables in the spreadsheet, optionally limited to one sheet.."""
return _rpc_call("list_pivot_tables", sheet_name=sheet_name)
def refresh_pivot_table(self, pivot_table_name: str, *, sheet_name: str = "") -> dict:
"""Reload pivot table data from the source range."""
return _rpc_call("refresh_pivot_table", pivot_table_name=pivot_table_name, sheet_name=sheet_name)
pivot_table = _PivotTableProxy()
class _PptMasterProxy:
"""Proxy for ppt-master tools."""
def apply_ppt_master_native_enhance(self, project_path: str) -> dict:
"""Apply ppt-master native enhancement (notes, transitions) from a project folder.."""
return _rpc_call("apply_ppt_master_native_enhance", project_path=project_path)
def apply_ppt_master_template_fill(self, fill_plan_path: str) -> dict:
"""Apply a ppt-master fill_plan.json to the active presentation (template-fill route).."""
return _rpc_call("apply_ppt_master_template_fill", fill_plan_path=fill_plan_path)
def export_presentation_project(self, project_path: str) -> dict:
"""Export a ppt-master project folder into the active Impress/Draw document by building or loading exports/*.pptx and importing via LibreOffice's native PPTX filter.."""
return _rpc_call("export_presentation_project", project_path=project_path)
def validate_ppt_master_project(self, project_path: str) -> dict:
"""Check that a ppt-master project folder has expected artifacts (SVG slides, design spec).."""
return _rpc_call("validate_ppt_master_project", project_path=project_path)
ppt_master = _PptMasterProxy()
class _PythonProxy:
"""Proxy for python tools."""
def run_venv_python_script(self, code: str, *, data_range: str = "", data: list = []) -> dict:
"""Run Python code."""
return _rpc_call("run_venv_python_script", code=code, data_range=data_range, data=data)
def symbolic_math(self, helper: str, *, params: dict = {}, task_hint: str = "", display_block: bool = True) -> dict:
"""Run a trusted SymPy symbolic math helper."""
return _rpc_call("symbolic_math", helper=helper, params=params, task_hint=task_hint, display_block=display_block)
python = _PythonProxy()
class _RangeProxy:
"""Proxy for range tools."""
def add_named_range(self, name: str, content: str) -> dict:
"""Defines a new named range in the workbook.."""
return _rpc_call("add_named_range", name=name, content=content)
def delete_named_range(self, name: str) -> dict:
"""Deletes an existing named range by name.."""
return _rpc_call("delete_named_range", name=name)
def list_named_ranges(self) -> dict:
"""Lists all named ranges in the workbook and their reference contents.."""
return _rpc_call("list_named_ranges")
def sort_range(self, range_name: list, *, sort_column: int = 0, ascending: bool = True, has_header: bool = True) -> dict:
"""Sorts the specified range(s) by a column."""
return _rpc_call("sort_range", range_name=range_name, sort_column=sort_column, ascending=ascending, has_header=has_header)
range = _RangeProxy()
class _SearchProxy:
"""Proxy for search tools."""
def in_spreadsheet(self, pattern: str, *, regex: bool = True, case_sensitive: bool = True, max_results: int = 0, sheet_name: str = "", all_sheets: bool = True) -> dict:
"""Search for text or values in a Calc spreadsheet."""
return _rpc_call("search_in_spreadsheet", pattern=pattern, regex=regex, case_sensitive=case_sensitive, max_results=max_results, sheet_name=sheet_name, all_sheets=all_sheets)
def replace_in_spreadsheet(self, search: str, replace: str, *, regex: bool = True, case_sensitive: bool = True, sheet_name: str = "", all_sheets: bool = True) -> dict:
"""Find and replace text or values in a Calc spreadsheet."""
return _rpc_call("replace_in_spreadsheet", search=search, replace=replace, regex=regex, case_sensitive=case_sensitive, sheet_name=sheet_name, all_sheets=all_sheets)
search = _SearchProxy()
class _ShapeProxy:
"""Proxy for shape tools."""
def connect(self, start_shape_index: int, end_shape_index: int, *, page_index: int = 0, line_color: str = "", line_width: int = 0) -> dict:
"""Connect two shapes on the same page with a connector.."""
return _rpc_call("shapes_connect", start_shape_index=start_shape_index, end_shape_index=end_shape_index, page_index=page_index, line_color=line_color, line_width=line_width)
def delete_shape(self, shape_index: int, *, page_index: int = 0) -> dict:
"""Deletes a shape by index.."""
return _rpc_call("delete_shape", shape_index=shape_index, page_index=page_index)
def get_draw_summary(self, *, page_index: int = 0) -> dict:
"""Returns a summary of shapes on the active or specified page.."""
return _rpc_call("get_draw_summary", page_index=page_index)
def group(self, shape_indices: list, *, page_index: int = 0) -> dict:
"""Groups multiple shapes together on the same page.."""
return _rpc_call("shapes_group", shape_indices=shape_indices, page_index=page_index)
def list_writer_images(self) -> dict:
"""List images and graphic objects in the Writer document (names, sizes, titles)."""
return _rpc_call("list_writer_images")
def upsert_shape(self, action: str, *, shape_index: int = 0, page_index: int = 0, shape_type: str = "", x: int = 0, y: int = 0, width: int = 0, height: int = 0, text: str = "", bg_color: str = "", fill_color: str = "", fill_style: str = "", line_color: str = "", line_width: int = 0, text_color: str = "", font_size: float = 0.0, font_name: str = "", rotation_angle: float = 0.0) -> dict:
"""Creates a new shape or modifies an existing shape on a page.."""
return _rpc_call("upsert_shape", action=action, shape_index=shape_index, page_index=page_index, shape_type=shape_type, x=x, y=y, width=width, height=height, text=text, bg_color=bg_color, fill_color=fill_color, fill_style=fill_style, line_color=line_color, line_width=line_width, text_color=text_color, font_size=font_size, font_name=font_name, rotation_angle=rotation_angle)
shape = _ShapeProxy()
class _SheetProxy:
"""Proxy for sheet tools."""
def apply_sheet_filter(self, range_name: str, criteria: list, *, contains_header: bool = True) -> dict:
"""Hide rows that do not match a standard Calc filter (not conditional formatting)."""
return _rpc_call("apply_sheet_filter", range_name=range_name, contains_header=contains_header, criteria=criteria)
def clear_sheet_filter(self, range_name: str, *, contains_header: bool = True) -> dict:
"""Remove the active standard sheet filter on a range so all rows show again."""
return _rpc_call("clear_sheet_filter", range_name=range_name, contains_header=contains_header)
def create_sheet(self, sheet_name: str, *, position: int = 0) -> dict:
"""Creates a new sheet.."""
return _rpc_call("create_sheet", sheet_name=sheet_name, position=position)
def delete_sheet(self, sheet_name: str) -> dict:
"""Deletes an existing sheet by name.."""
return _rpc_call("delete_sheet", sheet_name=sheet_name)
def get_sheet_filter(self, range_name: str) -> dict:
"""Return active filter criteria and contains_header for a range, or empty if none."""
return _rpc_call("get_sheet_filter", range_name=range_name)
def list_sheets(self) -> dict:
"""Lists all sheet names in the workbook.."""
return _rpc_call("list_sheets")
def protect_sheet(self, *, sheet_name: str = "", protect: bool = True) -> dict:
"""Protects or unprotects a sheet."""
return _rpc_call("protect_sheet", sheet_name=sheet_name, protect=protect)
def rename_sheet(self, old_name: str, new_name: str) -> dict:
"""Renames an existing sheet.."""
return _rpc_call("rename_sheet", old_name=old_name, new_name=new_name)
def switch_sheet(self, sheet_name: str) -> dict:
"""Switches to the specified sheet (makes it active).."""
return _rpc_call("switch_sheet", sheet_name=sheet_name)
sheet = _SheetProxy()
class _SlideMasterProxy:
"""Proxy for slide_master tools."""
def get_slide_master(self, *, page_index: int = 0) -> dict:
"""Get the master slide assigned to a specific slide."""
return _rpc_call("get_slide_master", page_index=page_index)
def list_master_slides(self) -> dict:
"""List all master slides (master pages) in the document with name and dimensions.."""
return _rpc_call("list_master_slides")
def set_slide_master(self, master_name: str, *, page_index: int = 0) -> dict:
"""Assign a master slide to a specific slide by master name."""
return _rpc_call("set_slide_master", page_index=page_index, master_name=master_name)
slide_master = _SlideMasterProxy()
class _SlideTransitionProxy:
"""Proxy for slide_transition tools."""
def get_slide_layout(self, *, page_index: int = 0) -> dict:
"""Get the layout type of an Impress slide."""
return _rpc_call("get_slide_layout", page_index=page_index)
def get_slide_transition(self, *, page_index: int = 0) -> dict:
"""Get the transition effect, speed, duration, and advance mode for an Impress slide.."""
return _rpc_call("get_slide_transition", page_index=page_index)
def set_slide_layout(self, layout: str, *, page_index: int = 0) -> dict:
"""Set the layout of an Impress slide."""
return _rpc_call("set_slide_layout", page_index=page_index, layout=layout)
def set_slide_transition(self, *, page_index: int = 0, effect: str = "", speed: str = "", duration: int = 0, transition_duration: float = 0.0, advance: str = "") -> dict:
"""Set the transition effect on an Impress slide."""
return _rpc_call("set_slide_transition", page_index=page_index, effect=effect, speed=speed, duration=duration, transition_duration=transition_duration, advance=advance)