use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFPrintScalingMode(pub NSInteger);
impl PDFPrintScalingMode {
#[doc(alias = "kPDFPrintPageScaleNone")]
pub const PageScaleNone: Self = Self(0);
#[doc(alias = "kPDFPrintPageScaleToFit")]
pub const PageScaleToFit: Self = Self(1);
#[doc(alias = "kPDFPrintPageScaleDownToFit")]
pub const PageScaleDownToFit: Self = Self(2);
}
unsafe impl Encode for PDFPrintScalingMode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for PDFPrintScalingMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFDocumentPermissions(pub NSInteger);
impl PDFDocumentPermissions {
#[doc(alias = "kPDFDocumentPermissionsNone")]
pub const None: Self = Self(0);
#[doc(alias = "kPDFDocumentPermissionsUser")]
pub const User: Self = Self(1);
#[doc(alias = "kPDFDocumentPermissionsOwner")]
pub const Owner: Self = Self(2);
}
unsafe impl Encode for PDFDocumentPermissions {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for PDFDocumentPermissions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static PDFDocumentDidUnlockNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidBeginFindNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidEndFindNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidBeginPageFindNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidEndPageFindNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidFindMatchNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidBeginWriteNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidEndWriteNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidBeginPageWriteNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentDidEndPageWriteNotification: &'static NSNotificationName;
}
extern "C" {
pub static PDFDocumentFoundSelectionKey: &'static NSString;
}
extern "C" {
pub static PDFDocumentPageIndexKey: &'static NSString;
}
pub type PDFDocumentAttribute = NSString;
extern "C" {
pub static PDFDocumentTitleAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentAuthorAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentSubjectAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentCreatorAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentProducerAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentCreationDateAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentModificationDateAttribute: &'static PDFDocumentAttribute;
}
extern "C" {
pub static PDFDocumentKeywordsAttribute: &'static PDFDocumentAttribute;
}
pub type PDFDocumentWriteOption = NSString;
extern "C" {
pub static PDFDocumentOwnerPasswordOption: &'static PDFDocumentWriteOption;
}
extern "C" {
pub static PDFDocumentUserPasswordOption: &'static PDFDocumentWriteOption;
}
extern "C" {
pub static PDFDocumentAccessPermissionsOption: &'static PDFDocumentWriteOption;
}
extern "C" {
pub static PDFDocumentBurnInAnnotationsOption: &'static PDFDocumentWriteOption;
}
extern "C" {
pub static PDFDocumentSaveTextFromOCROption: &'static PDFDocumentWriteOption;
}
extern "C" {
pub static PDFDocumentSaveImagesAsJPEGOption: &'static PDFDocumentWriteOption;
}
extern "C" {
pub static PDFDocumentOptimizeImagesForScreenOption: &'static PDFDocumentWriteOption;
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFAccessPermissions(pub NSUInteger);
impl PDFAccessPermissions {
#[doc(alias = "PDFAllowsLowQualityPrinting")]
pub const AllowsLowQualityPrinting: Self = Self(1 << 0);
#[doc(alias = "PDFAllowsHighQualityPrinting")]
pub const AllowsHighQualityPrinting: Self = Self(1 << 1);
#[doc(alias = "PDFAllowsDocumentChanges")]
pub const AllowsDocumentChanges: Self = Self(1 << 2);
#[doc(alias = "PDFAllowsDocumentAssembly")]
pub const AllowsDocumentAssembly: Self = Self(1 << 3);
#[doc(alias = "PDFAllowsContentCopying")]
pub const AllowsContentCopying: Self = Self(1 << 4);
#[doc(alias = "PDFAllowsContentAccessibility")]
pub const AllowsContentAccessibility: Self = Self(1 << 5);
#[doc(alias = "PDFAllowsCommenting")]
pub const AllowsCommenting: Self = Self(1 << 6);
#[doc(alias = "PDFAllowsFormFieldEntry")]
pub const AllowsFormFieldEntry: Self = Self(1 << 7);
}
unsafe impl Encode for PDFAccessPermissions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for PDFAccessPermissions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct PDFDocument;
);
extern_conformance!(
unsafe impl NSCopying for PDFDocument {}
);
unsafe impl CopyingHelper for PDFDocument {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for PDFDocument {}
);
impl PDFDocument {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(initWithURL:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
#[unsafe(method(initWithData:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithData(this: Allocated<Self>, data: &NSData) -> Option<Retained<Self>>;
#[unsafe(method(documentURL))]
#[unsafe(method_family = none)]
pub unsafe fn documentURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "objc2-core-graphics")]
#[unsafe(method(documentRef))]
#[unsafe(method_family = none)]
pub unsafe fn documentRef(&self) -> Option<Retained<CGPDFDocument>>;
#[unsafe(method(documentAttributes))]
#[unsafe(method_family = none)]
pub unsafe fn documentAttributes(&self) -> Option<Retained<NSDictionary>>;
#[unsafe(method(setDocumentAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn setDocumentAttributes(&self, document_attributes: Option<&NSDictionary>);
#[unsafe(method(majorVersion))]
#[unsafe(method_family = none)]
pub unsafe fn majorVersion(&self) -> NSInteger;
#[unsafe(method(minorVersion))]
#[unsafe(method_family = none)]
pub unsafe fn minorVersion(&self) -> NSInteger;
#[unsafe(method(isEncrypted))]
#[unsafe(method_family = none)]
pub unsafe fn isEncrypted(&self) -> bool;
#[unsafe(method(isLocked))]
#[unsafe(method_family = none)]
pub unsafe fn isLocked(&self) -> bool;
#[unsafe(method(unlockWithPassword:))]
#[unsafe(method_family = none)]
pub unsafe fn unlockWithPassword(&self, password: &NSString) -> bool;
#[unsafe(method(allowsPrinting))]
#[unsafe(method_family = none)]
pub unsafe fn allowsPrinting(&self) -> bool;
#[unsafe(method(allowsCopying))]
#[unsafe(method_family = none)]
pub unsafe fn allowsCopying(&self) -> bool;
#[unsafe(method(allowsDocumentChanges))]
#[unsafe(method_family = none)]
pub unsafe fn allowsDocumentChanges(&self) -> bool;
#[unsafe(method(allowsDocumentAssembly))]
#[unsafe(method_family = none)]
pub unsafe fn allowsDocumentAssembly(&self) -> bool;
#[unsafe(method(allowsContentAccessibility))]
#[unsafe(method_family = none)]
pub unsafe fn allowsContentAccessibility(&self) -> bool;
#[unsafe(method(allowsCommenting))]
#[unsafe(method_family = none)]
pub unsafe fn allowsCommenting(&self) -> bool;
#[unsafe(method(allowsFormFieldEntry))]
#[unsafe(method_family = none)]
pub unsafe fn allowsFormFieldEntry(&self) -> bool;
#[unsafe(method(accessPermissions))]
#[unsafe(method_family = none)]
pub unsafe fn accessPermissions(&self) -> PDFAccessPermissions;
#[unsafe(method(permissionsStatus))]
#[unsafe(method_family = none)]
pub unsafe fn permissionsStatus(&self) -> PDFDocumentPermissions;
#[unsafe(method(string))]
#[unsafe(method_family = none)]
pub unsafe fn string(&self) -> Option<Retained<NSString>>;
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn PDFDocumentDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn PDFDocumentDelegate>>,
);
#[unsafe(method(dataRepresentation))]
#[unsafe(method_family = none)]
pub unsafe fn dataRepresentation(&self) -> Option<Retained<NSData>>;
#[unsafe(method(dataRepresentationWithOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn dataRepresentationWithOptions(
&self,
options: &NSDictionary,
) -> Option<Retained<NSData>>;
#[unsafe(method(writeToFile:))]
#[unsafe(method_family = none)]
pub unsafe fn writeToFile(&self, path: &NSString) -> bool;
#[unsafe(method(writeToFile:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn writeToFile_withOptions(
&self,
path: &NSString,
options: Option<&NSDictionary<PDFDocumentWriteOption, AnyObject>>,
) -> bool;
#[unsafe(method(writeToURL:))]
#[unsafe(method_family = none)]
pub unsafe fn writeToURL(&self, url: &NSURL) -> bool;
#[unsafe(method(writeToURL:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn writeToURL_withOptions(
&self,
url: &NSURL,
options: Option<&NSDictionary<PDFDocumentWriteOption, AnyObject>>,
) -> bool;
#[cfg(feature = "PDFOutline")]
#[unsafe(method(outlineRoot))]
#[unsafe(method_family = none)]
pub unsafe fn outlineRoot(&self) -> Option<Retained<PDFOutline>>;
#[cfg(feature = "PDFOutline")]
#[unsafe(method(setOutlineRoot:))]
#[unsafe(method_family = none)]
pub unsafe fn setOutlineRoot(&self, outline_root: Option<&PDFOutline>);
#[cfg(all(feature = "PDFOutline", feature = "PDFSelection"))]
#[unsafe(method(outlineItemForSelection:))]
#[unsafe(method_family = none)]
pub unsafe fn outlineItemForSelection(
&self,
selection: &PDFSelection,
) -> Option<Retained<PDFOutline>>;
#[unsafe(method(pageCount))]
#[unsafe(method_family = none)]
pub unsafe fn pageCount(&self) -> NSUInteger;
#[cfg(feature = "PDFPage")]
#[unsafe(method(pageAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn pageAtIndex(&self, index: NSUInteger) -> Option<Retained<PDFPage>>;
#[cfg(feature = "PDFPage")]
#[unsafe(method(indexForPage:))]
#[unsafe(method_family = none)]
pub unsafe fn indexForPage(&self, page: &PDFPage) -> NSUInteger;
#[cfg(feature = "PDFPage")]
#[unsafe(method(insertPage:atIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn insertPage_atIndex(&self, page: &PDFPage, index: NSUInteger);
#[unsafe(method(removePageAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn removePageAtIndex(&self, index: NSUInteger);
#[unsafe(method(exchangePageAtIndex:withPageAtIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn exchangePageAtIndex_withPageAtIndex(
&self,
index_a: NSUInteger,
index_b: NSUInteger,
);
#[unsafe(method(pageClass))]
#[unsafe(method_family = none)]
pub unsafe fn pageClass(&self) -> &'static AnyClass;
#[cfg(feature = "PDFSelection")]
#[unsafe(method(findString:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn findString_withOptions(
&self,
string: &NSString,
options: NSStringCompareOptions,
) -> Retained<NSArray<PDFSelection>>;
#[unsafe(method(beginFindString:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn beginFindString_withOptions(
&self,
string: &NSString,
options: NSStringCompareOptions,
);
#[unsafe(method(beginFindStrings:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn beginFindStrings_withOptions(
&self,
strings: &NSArray<NSString>,
options: NSStringCompareOptions,
);
#[cfg(feature = "PDFSelection")]
#[unsafe(method(findString:fromSelection:withOptions:))]
#[unsafe(method_family = none)]
pub unsafe fn findString_fromSelection_withOptions(
&self,
string: &NSString,
selection: Option<&PDFSelection>,
options: NSStringCompareOptions,
) -> Option<Retained<PDFSelection>>;
#[unsafe(method(isFinding))]
#[unsafe(method_family = none)]
pub unsafe fn isFinding(&self) -> bool;
#[unsafe(method(cancelFindString))]
#[unsafe(method_family = none)]
pub unsafe fn cancelFindString(&self);
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
#[unsafe(method(printOperationForPrintInfo:scalingMode:autoRotate:))]
#[unsafe(method_family = none)]
pub unsafe fn printOperationForPrintInfo_scalingMode_autoRotate(
&self,
print_info: Option<&NSPrintInfo>,
scale_mode: PDFPrintScalingMode,
do_rotate: bool,
mtm: MainThreadMarker,
) -> Option<Retained<NSPrintOperation>>;
#[cfg(feature = "PDFSelection")]
#[unsafe(method(selectionForEntireDocument))]
#[unsafe(method_family = none)]
pub unsafe fn selectionForEntireDocument(&self) -> Option<Retained<PDFSelection>>;
#[cfg(all(feature = "PDFPage", feature = "PDFSelection"))]
#[unsafe(method(selectionFromPage:atPoint:toPage:atPoint:))]
#[unsafe(method_family = none)]
pub unsafe fn selectionFromPage_atPoint_toPage_atPoint(
&self,
start_page: &PDFPage,
start_point: NSPoint,
end_page: &PDFPage,
end_point: NSPoint,
) -> Option<Retained<PDFSelection>>;
#[cfg(all(feature = "PDFPage", feature = "PDFSelection"))]
#[unsafe(method(selectionFromPage:atPoint:toPage:atPoint:withGranularity:))]
#[unsafe(method_family = none)]
pub unsafe fn selectionFromPage_atPoint_toPage_atPoint_withGranularity(
&self,
start_page: &PDFPage,
start_point: NSPoint,
end_page: &PDFPage,
end_point: NSPoint,
granularity: PDFSelectionGranularity,
) -> Option<Retained<PDFSelection>>;
#[cfg(all(feature = "PDFPage", feature = "PDFSelection"))]
#[unsafe(method(selectionFromPage:atCharacterIndex:toPage:atCharacterIndex:))]
#[unsafe(method_family = none)]
pub unsafe fn selectionFromPage_atCharacterIndex_toPage_atCharacterIndex(
&self,
start_page: &PDFPage,
start_character: NSUInteger,
end_page: &PDFPage,
end_character: NSUInteger,
) -> Option<Retained<PDFSelection>>;
);
}
impl PDFDocument {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_protocol!(
pub unsafe trait PDFDocumentDelegate: NSObjectProtocol {
#[optional]
#[unsafe(method(documentDidUnlock:))]
#[unsafe(method_family = none)]
unsafe fn documentDidUnlock(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(documentDidBeginDocumentFind:))]
#[unsafe(method_family = none)]
unsafe fn documentDidBeginDocumentFind(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(documentDidEndDocumentFind:))]
#[unsafe(method_family = none)]
unsafe fn documentDidEndDocumentFind(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(documentDidBeginPageFind:))]
#[unsafe(method_family = none)]
unsafe fn documentDidBeginPageFind(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(documentDidEndPageFind:))]
#[unsafe(method_family = none)]
unsafe fn documentDidEndPageFind(&self, notification: &NSNotification);
#[optional]
#[unsafe(method(documentDidFindMatch:))]
#[unsafe(method_family = none)]
unsafe fn documentDidFindMatch(&self, notification: &NSNotification);
#[cfg(feature = "PDFSelection")]
#[optional]
#[unsafe(method(didMatchString:))]
#[unsafe(method_family = none)]
unsafe fn didMatchString(&self, instance: &PDFSelection);
#[optional]
#[unsafe(method(classForPage))]
#[unsafe(method_family = none)]
unsafe fn classForPage(&self) -> &'static AnyClass;
#[optional]
#[unsafe(method(classForAnnotationType:))]
#[unsafe(method_family = none)]
unsafe fn classForAnnotationType(&self, annotation_type: &NSString) -> &'static AnyClass;
#[deprecated]
#[optional]
#[unsafe(method(classForAnnotationClass:))]
#[unsafe(method_family = none)]
unsafe fn classForAnnotationClass(&self, annotation_class: &AnyClass) -> &'static AnyClass;
}
);