use wincom::{ComObject, Variant};
use windows::Win32::System::Com::IDispatch;
pub struct IvgPrnDocuments {
disp: ComObject,
}
impl IvgPrnDocuments {
pub fn new(disp: IDispatch) -> Self {
Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
}
fn prop_i64(&self, name: &str) -> Option<i64> {
self.disp.get_property(name).ok()?.to_i64().ok()
}
pub fn count(&self) -> Option<i64> { self.prop_i64("Count") }
pub fn item(&self, index: i32) -> Option<IvgPrnDocument> {
let args = vec![Variant::from_i64(index as i64)];
self.disp
.invoke_method("Item", args)
.ok()?
.to_idispatch()
.ok()
.map(IvgPrnDocument::new)
}
}
pub struct IvgPrnDocument {
disp: ComObject,
}
impl IvgPrnDocument {
pub fn new(disp: IDispatch) -> Self {
Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
}
pub fn raw(&self) -> &ComObject {
&self.disp
}
pub fn internal_ptr(&self) -> Option<i64> {
self.disp.invoke_method("_GetPrintDocument", vec![]).ok()?.to_i64().ok()
}
}
pub struct IvgPrnPages {
disp: ComObject,
}
impl IvgPrnPages {
pub fn new(disp: IDispatch) -> Self {
Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
}
fn prop_i64(&self, name: &str) -> Option<i64> {
self.disp.get_property(name).ok()?.to_i64().ok()
}
pub fn count(&self) -> Option<i64> { self.prop_i64("Count") }
pub fn item(&self, index: i32) -> Option<IvgPrnPage> {
let args = vec![Variant::from_i64(index as i64)];
self.disp
.invoke_method("Item", args)
.ok()?
.to_idispatch()
.ok()
.map(IvgPrnPage::new)
}
}
pub struct IvgPrnPage {
disp: ComObject,
}
impl IvgPrnPage {
pub fn new(disp: IDispatch) -> Self {
Self { disp: ComObject::from_dispatch(disp, crate::types::IID_IDISPATCH) }
}
pub fn raw(&self) -> &ComObject {
&self.disp
}
pub fn internal_document_ptr(&self) -> Option<i64> {
self.disp.invoke_method("_GetPrintDocument", vec![]).ok()?.to_i64().ok()
}
pub fn internal_page_index(&self) -> Option<i64> {
self.disp.invoke_method("_GetPrintPage", vec![]).ok()?.to_i64().ok()
}
}