Spaces:
Sleeping
Sleeping
File size: 1,120 Bytes
097eaf0 | 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 | use super::doc::DocProvider;
use super::docx::DocxProvider;
use super::odt::OdtProvider;
use super::rtf::RtfProvider;
use super::DocumentProvider;
use super::xlsx::XlsxProvider;
use napi_derive::napi;
#[napi]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DocumentType {
Doc,
Docx,
Rtf,
Odt,
Xlsx,
}
pub struct ProviderFactory {
doc_provider: DocProvider,
docx_provider: DocxProvider,
rtf_provider: RtfProvider,
odt_provider: OdtProvider,
xlsx_provider: XlsxProvider,
}
impl ProviderFactory {
pub fn new() -> Self {
Self {
doc_provider: DocProvider::new(),
docx_provider: DocxProvider::new(),
rtf_provider: RtfProvider::new(),
odt_provider: OdtProvider::new(),
xlsx_provider: XlsxProvider::new(),
}
}
pub fn get_provider(&self, doc_type: DocumentType) -> &dyn DocumentProvider {
match doc_type {
DocumentType::Doc => &self.doc_provider,
DocumentType::Docx => &self.docx_provider,
DocumentType::Rtf => &self.rtf_provider,
DocumentType::Odt => &self.odt_provider,
DocumentType::Xlsx => &self.xlsx_provider,
}
}
}
|