Struct Document

Source
pub struct Document { /* private fields */ }
Expand description

A Wrapper for the LibreOfficeKitDocument C API.

Implementations§

Source§

impl Document

Source

pub fn save_as(&mut self, url: &str, format: &str, filter: Option<&str>) -> bool

Stores the document’s persistent data to a URL and continues to be a representation of the old URL.

If the result is not true, then there’s an error (possibly unsupported format or other errors)

§Arguments
  • url - the location where to store the document
  • format - the format to use while exporting, when omitted, then deducted from pURL’s extension
  • filter - options for the export filter, e.g. SkipImages.Another useful FilterOption is “TakeOwnership”. It is consumed by the saveAs() itself, and when provided, the document identity changes to the provided pUrl - meaning that ‘.uno:ModifiedStatus’ is triggered as with the “Save As…” in the UI. “TakeOwnership” mode must not be used when saving to PNG or PDF.
§Example
use libreoffice_rs::Office;
use libreoffice_rs::urls;

let mut office = Office::new("/usr/lib/libreoffice/program")?;
let doc_url = urls::local_into_abs("./test_data/test.odt")?;
let mut doc = office.document_load(doc_url)?;
let output_path = std::env::temp_dir().join("libreoffice_rs_save_as.png");
let output_location = output_path.display().to_string();
let previously_saved = doc.save_as(&output_location, "png", None);
let _ = std::fs::remove_file(&output_path);

assert!(previously_saved, "{}", office.get_error());

Trait Implementations§

Source§

impl Drop for Document

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T