Skip to main content

spreadsheet_kit/recalc/
macro_uri.rs

1use crate::security::basic_string_literal;
2use anyhow::Result;
3
4/// Build a LibreOffice `macro:///...` URI for `Standard.Module1.ExportScreenshot`.
5///
6/// Arguments are escaped for Basic string literal context to prevent injection.
7pub fn export_screenshot_uri(
8    workbook_path: &str,
9    output_path: &str,
10    sheet_name: &str,
11    range: &str,
12) -> Result<String> {
13    Ok(format!(
14        "macro:///Standard.Module1.ExportScreenshot({},{},{},{})",
15        basic_string_literal("workbook_path", workbook_path)?,
16        basic_string_literal("output_path", output_path)?,
17        basic_string_literal("sheet_name", sheet_name)?,
18        basic_string_literal("range", range)?,
19    ))
20}
21
22/// Build a LibreOffice `macro:///...` URI for `Standard.Module1.RecalculateAndSave`.
23///
24/// Arguments are escaped for Basic string literal context to prevent injection.
25pub fn recalc_and_save_uri(workbook_path: &str) -> Result<String> {
26    Ok(format!(
27        "macro:///Standard.Module1.RecalculateAndSave({})",
28        basic_string_literal("workbook_path", workbook_path)?,
29    ))
30}