1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSDocumentChangeType(pub NSUInteger);
15impl NSDocumentChangeType {
16 #[doc(alias = "NSChangeDone")]
17 pub const ChangeDone: Self = Self(0);
18 #[doc(alias = "NSChangeUndone")]
19 pub const ChangeUndone: Self = Self(1);
20 #[doc(alias = "NSChangeRedone")]
21 pub const ChangeRedone: Self = Self(5);
22 #[doc(alias = "NSChangeCleared")]
23 pub const ChangeCleared: Self = Self(2);
24 #[doc(alias = "NSChangeReadOtherContents")]
25 pub const ChangeReadOtherContents: Self = Self(3);
26 #[doc(alias = "NSChangeAutosaved")]
27 pub const ChangeAutosaved: Self = Self(4);
28 #[doc(alias = "NSChangeDiscardable")]
29 pub const ChangeDiscardable: Self = Self(256);
30}
31
32unsafe impl Encode for NSDocumentChangeType {
33 const ENCODING: Encoding = NSUInteger::ENCODING;
34}
35
36unsafe impl RefEncode for NSDocumentChangeType {
37 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40#[repr(transparent)]
43#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
44pub struct NSSaveOperationType(pub NSUInteger);
45impl NSSaveOperationType {
46 #[doc(alias = "NSSaveOperation")]
47 pub const SaveOperation: Self = Self(0);
48 #[doc(alias = "NSSaveAsOperation")]
49 pub const SaveAsOperation: Self = Self(1);
50 #[doc(alias = "NSSaveToOperation")]
51 pub const SaveToOperation: Self = Self(2);
52 #[doc(alias = "NSAutosaveInPlaceOperation")]
53 pub const AutosaveInPlaceOperation: Self = Self(4);
54 #[doc(alias = "NSAutosaveElsewhereOperation")]
55 pub const AutosaveElsewhereOperation: Self = Self(3);
56 #[doc(alias = "NSAutosaveAsOperation")]
57 pub const AutosaveAsOperation: Self = Self(5);
58 #[deprecated = "Use NSAutosaveElsewhereOperation instead"]
59 #[doc(alias = "NSAutosaveOperation")]
60 pub const AutosaveOperation: Self = Self(3);
61}
62
63unsafe impl Encode for NSSaveOperationType {
64 const ENCODING: Encoding = NSUInteger::ENCODING;
65}
66
67unsafe impl RefEncode for NSSaveOperationType {
68 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71extern_class!(
72 #[unsafe(super(NSObject))]
74 #[thread_kind = MainThreadOnly]
75 #[derive(Debug, PartialEq, Eq, Hash)]
76 pub struct NSDocument;
77);
78
79#[cfg(feature = "NSKeyValueBinding")]
80unsafe impl NSEditorRegistration for NSDocument {}
81
82unsafe impl NSFilePresenter for NSDocument {}
83
84#[cfg(feature = "NSMenu")]
85unsafe impl NSMenuItemValidation for NSDocument {}
86
87unsafe impl NSObjectProtocol for NSDocument {}
88
89#[cfg(feature = "NSUserInterfaceValidation")]
90unsafe impl NSUserInterfaceValidations for NSDocument {}
91
92impl NSDocument {
93 extern_methods!(
94 #[unsafe(method(init))]
95 #[unsafe(method_family = init)]
96 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
97
98 #[unsafe(method(initWithType:error:_))]
99 #[unsafe(method_family = init)]
100 pub unsafe fn initWithType_error(
101 this: Allocated<Self>,
102 type_name: &NSString,
103 ) -> Result<Retained<Self>, Retained<NSError>>;
104
105 #[unsafe(method(canConcurrentlyReadDocumentsOfType:))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn canConcurrentlyReadDocumentsOfType(
108 type_name: &NSString,
109 mtm: MainThreadMarker,
110 ) -> bool;
111
112 #[unsafe(method(initWithContentsOfURL:ofType:error:_))]
113 #[unsafe(method_family = init)]
114 pub unsafe fn initWithContentsOfURL_ofType_error(
115 this: Allocated<Self>,
116 url: &NSURL,
117 type_name: &NSString,
118 ) -> Result<Retained<Self>, Retained<NSError>>;
119
120 #[unsafe(method(initForURL:withContentsOfURL:ofType:error:_))]
121 #[unsafe(method_family = init)]
122 pub unsafe fn initForURL_withContentsOfURL_ofType_error(
123 this: Allocated<Self>,
124 url_or_nil: Option<&NSURL>,
125 contents_url: &NSURL,
126 type_name: &NSString,
127 ) -> Result<Retained<Self>, Retained<NSError>>;
128
129 #[unsafe(method(fileType))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn fileType(&self) -> Option<Retained<NSString>>;
132
133 #[unsafe(method(setFileType:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn setFileType(&self, file_type: Option<&NSString>);
137
138 #[unsafe(method(fileURL))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn fileURL(&self) -> Option<Retained<NSURL>>;
141
142 #[unsafe(method(setFileURL:))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn setFileURL(&self, file_url: Option<&NSURL>);
146
147 #[unsafe(method(fileModificationDate))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn fileModificationDate(&self) -> Option<Retained<NSDate>>;
150
151 #[unsafe(method(setFileModificationDate:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn setFileModificationDate(&self, file_modification_date: Option<&NSDate>);
155
156 #[unsafe(method(isDraft))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn isDraft(&self) -> bool;
159
160 #[unsafe(method(setDraft:))]
162 #[unsafe(method_family = none)]
163 pub unsafe fn setDraft(&self, draft: bool);
164
165 #[cfg(feature = "block2")]
166 #[unsafe(method(performActivityWithSynchronousWaiting:usingBlock:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn performActivityWithSynchronousWaiting_usingBlock(
169 &self,
170 wait_synchronously: bool,
171 block: &block2::Block<dyn Fn(NonNull<block2::Block<dyn Fn()>>)>,
172 );
173
174 #[cfg(feature = "block2")]
175 #[unsafe(method(continueActivityUsingBlock:))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn continueActivityUsingBlock(&self, block: &block2::Block<dyn Fn() + '_>);
178
179 #[cfg(feature = "block2")]
180 #[unsafe(method(continueAsynchronousWorkOnMainThreadUsingBlock:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn continueAsynchronousWorkOnMainThreadUsingBlock(
183 &self,
184 block: &block2::Block<dyn Fn()>,
185 );
186
187 #[cfg(feature = "block2")]
188 #[unsafe(method(performSynchronousFileAccessUsingBlock:))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn performSynchronousFileAccessUsingBlock(
191 &self,
192 block: &block2::Block<dyn Fn() + '_>,
193 );
194
195 #[cfg(feature = "block2")]
196 #[unsafe(method(performAsynchronousFileAccessUsingBlock:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn performAsynchronousFileAccessUsingBlock(
199 &self,
200 block: &block2::Block<dyn Fn(NonNull<block2::Block<dyn Fn()>>)>,
201 );
202
203 #[unsafe(method(revertDocumentToSaved:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn revertDocumentToSaved(&self, sender: Option<&AnyObject>);
206
207 #[unsafe(method(revertToContentsOfURL:ofType:error:_))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn revertToContentsOfURL_ofType_error(
210 &self,
211 url: &NSURL,
212 type_name: &NSString,
213 ) -> Result<(), Retained<NSError>>;
214
215 #[unsafe(method(readFromURL:ofType:error:_))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn readFromURL_ofType_error(
218 &self,
219 url: &NSURL,
220 type_name: &NSString,
221 ) -> Result<(), Retained<NSError>>;
222
223 #[unsafe(method(readFromFileWrapper:ofType:error:_))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn readFromFileWrapper_ofType_error(
226 &self,
227 file_wrapper: &NSFileWrapper,
228 type_name: &NSString,
229 ) -> Result<(), Retained<NSError>>;
230
231 #[unsafe(method(readFromData:ofType:error:_))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn readFromData_ofType_error(
234 &self,
235 data: &NSData,
236 type_name: &NSString,
237 ) -> Result<(), Retained<NSError>>;
238
239 #[unsafe(method(isEntireFileLoaded))]
240 #[unsafe(method_family = none)]
241 pub unsafe fn isEntireFileLoaded(&self) -> bool;
242
243 #[unsafe(method(writeToURL:ofType:error:_))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn writeToURL_ofType_error(
246 &self,
247 url: &NSURL,
248 type_name: &NSString,
249 ) -> Result<(), Retained<NSError>>;
250
251 #[unsafe(method(fileWrapperOfType:error:_))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn fileWrapperOfType_error(
254 &self,
255 type_name: &NSString,
256 ) -> Result<Retained<NSFileWrapper>, Retained<NSError>>;
257
258 #[unsafe(method(dataOfType:error:_))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn dataOfType_error(
261 &self,
262 type_name: &NSString,
263 ) -> Result<Retained<NSData>, Retained<NSError>>;
264
265 #[unsafe(method(unblockUserInteraction))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn unblockUserInteraction(&self);
268
269 #[unsafe(method(autosavingIsImplicitlyCancellable))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn autosavingIsImplicitlyCancellable(&self) -> bool;
272
273 #[unsafe(method(writeSafelyToURL:ofType:forSaveOperation:error:_))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn writeSafelyToURL_ofType_forSaveOperation_error(
276 &self,
277 url: &NSURL,
278 type_name: &NSString,
279 save_operation: NSSaveOperationType,
280 ) -> Result<(), Retained<NSError>>;
281
282 #[unsafe(method(writeToURL:ofType:forSaveOperation:originalContentsURL:error:_))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn writeToURL_ofType_forSaveOperation_originalContentsURL_error(
285 &self,
286 url: &NSURL,
287 type_name: &NSString,
288 save_operation: NSSaveOperationType,
289 absolute_original_contents_url: Option<&NSURL>,
290 ) -> Result<(), Retained<NSError>>;
291
292 #[unsafe(method(fileAttributesToWriteToURL:ofType:forSaveOperation:originalContentsURL:error:_))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn fileAttributesToWriteToURL_ofType_forSaveOperation_originalContentsURL_error(
295 &self,
296 url: &NSURL,
297 type_name: &NSString,
298 save_operation: NSSaveOperationType,
299 absolute_original_contents_url: Option<&NSURL>,
300 ) -> Result<Retained<NSDictionary<NSString, AnyObject>>, Retained<NSError>>;
301
302 #[unsafe(method(keepBackupFile))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn keepBackupFile(&self) -> bool;
305
306 #[unsafe(method(backupFileURL))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn backupFileURL(&self) -> Option<Retained<NSURL>>;
309
310 #[unsafe(method(saveDocument:))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn saveDocument(&self, sender: Option<&AnyObject>);
313
314 #[unsafe(method(saveDocumentAs:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn saveDocumentAs(&self, sender: Option<&AnyObject>);
317
318 #[unsafe(method(saveDocumentTo:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn saveDocumentTo(&self, sender: Option<&AnyObject>);
321
322 #[unsafe(method(saveDocumentWithDelegate:didSaveSelector:contextInfo:))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn saveDocumentWithDelegate_didSaveSelector_contextInfo(
325 &self,
326 delegate: Option<&AnyObject>,
327 did_save_selector: Option<Sel>,
328 context_info: *mut c_void,
329 );
330
331 #[unsafe(method(runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn runModalSavePanelForSaveOperation_delegate_didSaveSelector_contextInfo(
334 &self,
335 save_operation: NSSaveOperationType,
336 delegate: Option<&AnyObject>,
337 did_save_selector: Option<Sel>,
338 context_info: *mut c_void,
339 );
340
341 #[unsafe(method(savePanelShowsFileFormatsControl))]
342 #[unsafe(method_family = none)]
343 pub unsafe fn savePanelShowsFileFormatsControl(&self) -> bool;
344
345 #[cfg(all(
346 feature = "NSPanel",
347 feature = "NSResponder",
348 feature = "NSSavePanel",
349 feature = "NSWindow"
350 ))]
351 #[unsafe(method(prepareSavePanel:))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn prepareSavePanel(&self, save_panel: &NSSavePanel) -> bool;
354
355 #[unsafe(method(fileNameExtensionWasHiddenInLastRunSavePanel))]
356 #[unsafe(method_family = none)]
357 pub unsafe fn fileNameExtensionWasHiddenInLastRunSavePanel(&self) -> bool;
358
359 #[unsafe(method(fileTypeFromLastRunSavePanel))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn fileTypeFromLastRunSavePanel(&self) -> Option<Retained<NSString>>;
362
363 #[unsafe(method(saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn saveToURL_ofType_forSaveOperation_delegate_didSaveSelector_contextInfo(
366 &self,
367 url: &NSURL,
368 type_name: &NSString,
369 save_operation: NSSaveOperationType,
370 delegate: Option<&AnyObject>,
371 did_save_selector: Option<Sel>,
372 context_info: *mut c_void,
373 );
374
375 #[cfg(feature = "block2")]
376 #[unsafe(method(saveToURL:ofType:forSaveOperation:completionHandler:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn saveToURL_ofType_forSaveOperation_completionHandler(
379 &self,
380 url: &NSURL,
381 type_name: &NSString,
382 save_operation: NSSaveOperationType,
383 completion_handler: &block2::Block<dyn Fn(*mut NSError)>,
384 );
385
386 #[unsafe(method(canAsynchronouslyWriteToURL:ofType:forSaveOperation:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn canAsynchronouslyWriteToURL_ofType_forSaveOperation(
389 &self,
390 url: &NSURL,
391 type_name: &NSString,
392 save_operation: NSSaveOperationType,
393 ) -> bool;
394
395 #[unsafe(method(checkAutosavingSafetyAndReturnError:_))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn checkAutosavingSafetyAndReturnError(&self) -> Result<(), Retained<NSError>>;
398
399 #[unsafe(method(scheduleAutosaving))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn scheduleAutosaving(&self);
402
403 #[unsafe(method(hasUnautosavedChanges))]
404 #[unsafe(method_family = none)]
405 pub unsafe fn hasUnautosavedChanges(&self) -> bool;
406
407 #[unsafe(method(autosaveDocumentWithDelegate:didAutosaveSelector:contextInfo:))]
408 #[unsafe(method_family = none)]
409 pub unsafe fn autosaveDocumentWithDelegate_didAutosaveSelector_contextInfo(
410 &self,
411 delegate: Option<&AnyObject>,
412 did_autosave_selector: Option<Sel>,
413 context_info: *mut c_void,
414 );
415
416 #[cfg(feature = "block2")]
417 #[unsafe(method(autosaveWithImplicitCancellability:completionHandler:))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn autosaveWithImplicitCancellability_completionHandler(
420 &self,
421 autosaving_is_implicitly_cancellable: bool,
422 completion_handler: &block2::Block<dyn Fn(*mut NSError)>,
423 );
424
425 #[unsafe(method(autosavesInPlace))]
426 #[unsafe(method_family = none)]
427 pub unsafe fn autosavesInPlace(mtm: MainThreadMarker) -> bool;
428
429 #[unsafe(method(preservesVersions))]
430 #[unsafe(method_family = none)]
431 pub unsafe fn preservesVersions(mtm: MainThreadMarker) -> bool;
432
433 #[unsafe(method(browseDocumentVersions:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn browseDocumentVersions(&self, sender: Option<&AnyObject>);
436
437 #[unsafe(method(isBrowsingVersions))]
438 #[unsafe(method_family = none)]
439 pub unsafe fn isBrowsingVersions(&self) -> bool;
440
441 #[cfg(feature = "block2")]
442 #[unsafe(method(stopBrowsingVersionsWithCompletionHandler:))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn stopBrowsingVersionsWithCompletionHandler(
445 &self,
446 completion_handler: Option<&block2::Block<dyn Fn()>>,
447 );
448
449 #[unsafe(method(autosavesDrafts))]
450 #[unsafe(method_family = none)]
451 pub unsafe fn autosavesDrafts(mtm: MainThreadMarker) -> bool;
452
453 #[unsafe(method(autosavingFileType))]
454 #[unsafe(method_family = none)]
455 pub unsafe fn autosavingFileType(&self) -> Option<Retained<NSString>>;
456
457 #[unsafe(method(autosavedContentsFileURL))]
458 #[unsafe(method_family = none)]
459 pub unsafe fn autosavedContentsFileURL(&self) -> Option<Retained<NSURL>>;
460
461 #[unsafe(method(setAutosavedContentsFileURL:))]
463 #[unsafe(method_family = none)]
464 pub unsafe fn setAutosavedContentsFileURL(
465 &self,
466 autosaved_contents_file_url: Option<&NSURL>,
467 );
468
469 #[unsafe(method(canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:))]
470 #[unsafe(method_family = none)]
471 pub unsafe fn canCloseDocumentWithDelegate_shouldCloseSelector_contextInfo(
472 &self,
473 delegate: &AnyObject,
474 should_close_selector: Option<Sel>,
475 context_info: *mut c_void,
476 );
477
478 #[unsafe(method(close))]
479 #[unsafe(method_family = none)]
480 pub unsafe fn close(&self);
481
482 #[unsafe(method(duplicateDocument:))]
483 #[unsafe(method_family = none)]
484 pub unsafe fn duplicateDocument(&self, sender: Option<&AnyObject>);
485
486 #[unsafe(method(duplicateDocumentWithDelegate:didDuplicateSelector:contextInfo:))]
487 #[unsafe(method_family = none)]
488 pub unsafe fn duplicateDocumentWithDelegate_didDuplicateSelector_contextInfo(
489 &self,
490 delegate: Option<&AnyObject>,
491 did_duplicate_selector: Option<Sel>,
492 context_info: *mut c_void,
493 );
494
495 #[unsafe(method(duplicateAndReturnError:_))]
496 #[unsafe(method_family = none)]
497 pub unsafe fn duplicateAndReturnError(
498 &self,
499 ) -> Result<Retained<NSDocument>, Retained<NSError>>;
500
501 #[unsafe(method(renameDocument:))]
502 #[unsafe(method_family = none)]
503 pub unsafe fn renameDocument(&self, sender: Option<&AnyObject>);
504
505 #[unsafe(method(moveDocumentToUbiquityContainer:))]
506 #[unsafe(method_family = none)]
507 pub unsafe fn moveDocumentToUbiquityContainer(&self, sender: Option<&AnyObject>);
508
509 #[unsafe(method(moveDocument:))]
510 #[unsafe(method_family = none)]
511 pub unsafe fn moveDocument(&self, sender: Option<&AnyObject>);
512
513 #[cfg(feature = "block2")]
514 #[unsafe(method(moveDocumentWithCompletionHandler:))]
515 #[unsafe(method_family = none)]
516 pub unsafe fn moveDocumentWithCompletionHandler(
517 &self,
518 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
519 );
520
521 #[cfg(feature = "block2")]
522 #[unsafe(method(moveToURL:completionHandler:))]
523 #[unsafe(method_family = none)]
524 pub unsafe fn moveToURL_completionHandler(
525 &self,
526 url: &NSURL,
527 completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
528 );
529
530 #[unsafe(method(lockDocument:))]
531 #[unsafe(method_family = none)]
532 pub unsafe fn lockDocument(&self, sender: Option<&AnyObject>);
533
534 #[unsafe(method(unlockDocument:))]
535 #[unsafe(method_family = none)]
536 pub unsafe fn unlockDocument(&self, sender: Option<&AnyObject>);
537
538 #[cfg(feature = "block2")]
539 #[unsafe(method(lockDocumentWithCompletionHandler:))]
540 #[unsafe(method_family = none)]
541 pub unsafe fn lockDocumentWithCompletionHandler(
542 &self,
543 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
544 );
545
546 #[cfg(feature = "block2")]
547 #[unsafe(method(lockWithCompletionHandler:))]
548 #[unsafe(method_family = none)]
549 pub unsafe fn lockWithCompletionHandler(
550 &self,
551 completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
552 );
553
554 #[cfg(feature = "block2")]
555 #[unsafe(method(unlockDocumentWithCompletionHandler:))]
556 #[unsafe(method_family = none)]
557 pub unsafe fn unlockDocumentWithCompletionHandler(
558 &self,
559 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
560 );
561
562 #[cfg(feature = "block2")]
563 #[unsafe(method(unlockWithCompletionHandler:))]
564 #[unsafe(method_family = none)]
565 pub unsafe fn unlockWithCompletionHandler(
566 &self,
567 completion_handler: Option<&block2::Block<dyn Fn(*mut NSError)>>,
568 );
569
570 #[unsafe(method(isLocked))]
571 #[unsafe(method_family = none)]
572 pub unsafe fn isLocked(&self) -> bool;
573
574 #[unsafe(method(runPageLayout:))]
575 #[unsafe(method_family = none)]
576 pub unsafe fn runPageLayout(&self, sender: Option<&AnyObject>);
577
578 #[cfg(feature = "NSPrintInfo")]
579 #[unsafe(method(runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:))]
580 #[unsafe(method_family = none)]
581 pub unsafe fn runModalPageLayoutWithPrintInfo_delegate_didRunSelector_contextInfo(
582 &self,
583 print_info: &NSPrintInfo,
584 delegate: Option<&AnyObject>,
585 did_run_selector: Option<Sel>,
586 context_info: *mut c_void,
587 );
588
589 #[cfg(feature = "NSPageLayout")]
590 #[unsafe(method(preparePageLayout:))]
591 #[unsafe(method_family = none)]
592 pub unsafe fn preparePageLayout(&self, page_layout: &NSPageLayout) -> bool;
593
594 #[cfg(feature = "NSPrintInfo")]
595 #[unsafe(method(shouldChangePrintInfo:))]
596 #[unsafe(method_family = none)]
597 pub unsafe fn shouldChangePrintInfo(&self, new_print_info: &NSPrintInfo) -> bool;
598
599 #[cfg(feature = "NSPrintInfo")]
600 #[unsafe(method(printInfo))]
601 #[unsafe(method_family = none)]
602 pub unsafe fn printInfo(&self) -> Retained<NSPrintInfo>;
603
604 #[cfg(feature = "NSPrintInfo")]
605 #[unsafe(method(setPrintInfo:))]
607 #[unsafe(method_family = none)]
608 pub unsafe fn setPrintInfo(&self, print_info: &NSPrintInfo);
609
610 #[unsafe(method(printDocument:))]
611 #[unsafe(method_family = none)]
612 pub unsafe fn printDocument(&self, sender: Option<&AnyObject>);
613
614 #[cfg(feature = "NSPrintInfo")]
615 #[unsafe(method(printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:))]
616 #[unsafe(method_family = none)]
617 pub unsafe fn printDocumentWithSettings_showPrintPanel_delegate_didPrintSelector_contextInfo(
618 &self,
619 print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
620 show_print_panel: bool,
621 delegate: Option<&AnyObject>,
622 did_print_selector: Option<Sel>,
623 context_info: *mut c_void,
624 );
625
626 #[cfg(all(feature = "NSPrintInfo", feature = "NSPrintOperation"))]
627 #[unsafe(method(printOperationWithSettings:error:_))]
628 #[unsafe(method_family = none)]
629 pub unsafe fn printOperationWithSettings_error(
630 &self,
631 print_settings: &NSDictionary<NSPrintInfoAttributeKey, AnyObject>,
632 ) -> Result<Retained<NSPrintOperation>, Retained<NSError>>;
633
634 #[cfg(feature = "NSPrintOperation")]
635 #[unsafe(method(runModalPrintOperation:delegate:didRunSelector:contextInfo:))]
636 #[unsafe(method_family = none)]
637 pub unsafe fn runModalPrintOperation_delegate_didRunSelector_contextInfo(
638 &self,
639 print_operation: &NSPrintOperation,
640 delegate: Option<&AnyObject>,
641 did_run_selector: Option<Sel>,
642 context_info: *mut c_void,
643 );
644
645 #[unsafe(method(saveDocumentToPDF:))]
646 #[unsafe(method_family = none)]
647 pub unsafe fn saveDocumentToPDF(&self, sender: Option<&AnyObject>);
648
649 #[cfg(feature = "NSPrintOperation")]
650 #[unsafe(method(PDFPrintOperation))]
651 #[unsafe(method_family = none)]
652 pub unsafe fn PDFPrintOperation(&self) -> Retained<NSPrintOperation>;
653
654 #[unsafe(method(allowsDocumentSharing))]
655 #[unsafe(method_family = none)]
656 pub unsafe fn allowsDocumentSharing(&self) -> bool;
657
658 #[cfg(all(feature = "NSSharingService", feature = "block2"))]
659 #[unsafe(method(shareDocumentWithSharingService:completionHandler:))]
660 #[unsafe(method_family = none)]
661 pub unsafe fn shareDocumentWithSharingService_completionHandler(
662 &self,
663 sharing_service: &NSSharingService,
664 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
665 );
666
667 #[cfg(feature = "NSSharingService")]
668 #[unsafe(method(prepareSharingServicePicker:))]
669 #[unsafe(method_family = none)]
670 pub unsafe fn prepareSharingServicePicker(
671 &self,
672 sharing_service_picker: &NSSharingServicePicker,
673 );
674
675 #[cfg(feature = "NSPreviewRepresentingActivityItem")]
676 #[unsafe(method(previewRepresentableActivityItems))]
677 #[unsafe(method_family = none)]
678 pub unsafe fn previewRepresentableActivityItems(
679 &self,
680 ) -> Option<Retained<NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>>>;
681
682 #[cfg(feature = "NSPreviewRepresentingActivityItem")]
683 #[unsafe(method(setPreviewRepresentableActivityItems:))]
685 #[unsafe(method_family = none)]
686 pub unsafe fn setPreviewRepresentableActivityItems(
687 &self,
688 preview_representable_activity_items: Option<
689 &NSArray<ProtocolObject<dyn NSPreviewRepresentableActivityItem>>,
690 >,
691 );
692
693 #[unsafe(method(isDocumentEdited))]
694 #[unsafe(method_family = none)]
695 pub unsafe fn isDocumentEdited(&self) -> bool;
696
697 #[unsafe(method(isInViewingMode))]
698 #[unsafe(method_family = none)]
699 pub unsafe fn isInViewingMode(&self) -> bool;
700
701 #[unsafe(method(updateChangeCount:))]
702 #[unsafe(method_family = none)]
703 pub unsafe fn updateChangeCount(&self, change: NSDocumentChangeType);
704
705 #[unsafe(method(changeCountTokenForSaveOperation:))]
706 #[unsafe(method_family = none)]
707 pub unsafe fn changeCountTokenForSaveOperation(
708 &self,
709 save_operation: NSSaveOperationType,
710 ) -> Retained<AnyObject>;
711
712 #[unsafe(method(updateChangeCountWithToken:forSaveOperation:))]
713 #[unsafe(method_family = none)]
714 pub unsafe fn updateChangeCountWithToken_forSaveOperation(
715 &self,
716 change_count_token: &AnyObject,
717 save_operation: NSSaveOperationType,
718 );
719
720 #[unsafe(method(undoManager))]
721 #[unsafe(method_family = none)]
722 pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>;
723
724 #[unsafe(method(setUndoManager:))]
726 #[unsafe(method_family = none)]
727 pub unsafe fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>);
728
729 #[unsafe(method(hasUndoManager))]
730 #[unsafe(method_family = none)]
731 pub unsafe fn hasUndoManager(&self) -> bool;
732
733 #[unsafe(method(setHasUndoManager:))]
735 #[unsafe(method_family = none)]
736 pub unsafe fn setHasUndoManager(&self, has_undo_manager: bool);
737
738 #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
739 #[unsafe(method(presentError:modalForWindow:delegate:didPresentSelector:contextInfo:))]
740 #[unsafe(method_family = none)]
741 pub unsafe fn presentError_modalForWindow_delegate_didPresentSelector_contextInfo(
742 &self,
743 error: &NSError,
744 window: &NSWindow,
745 delegate: Option<&AnyObject>,
746 did_present_selector: Option<Sel>,
747 context_info: *mut c_void,
748 );
749
750 #[unsafe(method(presentError:))]
751 #[unsafe(method_family = none)]
752 pub unsafe fn presentError(&self, error: &NSError) -> bool;
753
754 #[unsafe(method(willPresentError:))]
755 #[unsafe(method_family = none)]
756 pub unsafe fn willPresentError(&self, error: &NSError) -> Retained<NSError>;
757
758 #[unsafe(method(willNotPresentError:))]
759 #[unsafe(method_family = none)]
760 pub unsafe fn willNotPresentError(&self, error: &NSError);
761
762 #[unsafe(method(makeWindowControllers))]
763 #[unsafe(method_family = none)]
764 pub unsafe fn makeWindowControllers(&self);
765
766 #[cfg(feature = "NSNib")]
767 #[unsafe(method(windowNibName))]
768 #[unsafe(method_family = none)]
769 pub unsafe fn windowNibName(&self) -> Option<Retained<NSNibName>>;
770
771 #[cfg(all(feature = "NSResponder", feature = "NSWindowController"))]
772 #[unsafe(method(windowControllerWillLoadNib:))]
773 #[unsafe(method_family = none)]
774 pub unsafe fn windowControllerWillLoadNib(&self, window_controller: &NSWindowController);
775
776 #[cfg(all(feature = "NSResponder", feature = "NSWindowController"))]
777 #[unsafe(method(windowControllerDidLoadNib:))]
778 #[unsafe(method_family = none)]
779 pub unsafe fn windowControllerDidLoadNib(&self, window_controller: &NSWindowController);
780
781 #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
782 #[unsafe(method(setWindow:))]
783 #[unsafe(method_family = none)]
784 pub unsafe fn setWindow(&self, window: Option<&NSWindow>);
785
786 #[cfg(all(feature = "NSResponder", feature = "NSWindowController"))]
787 #[unsafe(method(addWindowController:))]
788 #[unsafe(method_family = none)]
789 pub unsafe fn addWindowController(&self, window_controller: &NSWindowController);
790
791 #[cfg(all(feature = "NSResponder", feature = "NSWindowController"))]
792 #[unsafe(method(removeWindowController:))]
793 #[unsafe(method_family = none)]
794 pub unsafe fn removeWindowController(&self, window_controller: &NSWindowController);
795
796 #[unsafe(method(showWindows))]
797 #[unsafe(method_family = none)]
798 pub unsafe fn showWindows(&self);
799
800 #[cfg(all(feature = "NSResponder", feature = "NSWindowController"))]
801 #[unsafe(method(windowControllers))]
802 #[unsafe(method_family = none)]
803 pub unsafe fn windowControllers(&self) -> Retained<NSArray<NSWindowController>>;
804
805 #[cfg(all(feature = "NSResponder", feature = "NSWindowController"))]
806 #[unsafe(method(shouldCloseWindowController:delegate:shouldCloseSelector:contextInfo:))]
807 #[unsafe(method_family = none)]
808 pub unsafe fn shouldCloseWindowController_delegate_shouldCloseSelector_contextInfo(
809 &self,
810 window_controller: &NSWindowController,
811 delegate: Option<&AnyObject>,
812 should_close_selector: Option<Sel>,
813 context_info: *mut c_void,
814 );
815
816 #[unsafe(method(displayName))]
817 #[unsafe(method_family = none)]
818 pub unsafe fn displayName(&self) -> Retained<NSString>;
819
820 #[unsafe(method(defaultDraftName))]
821 #[unsafe(method_family = none)]
822 pub unsafe fn defaultDraftName(&self) -> Retained<NSString>;
823
824 #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
825 #[unsafe(method(windowForSheet))]
826 #[unsafe(method_family = none)]
827 pub unsafe fn windowForSheet(&self) -> Option<Retained<NSWindow>>;
828
829 #[unsafe(method(readableTypes))]
830 #[unsafe(method_family = none)]
831 pub unsafe fn readableTypes(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>;
832
833 #[unsafe(method(writableTypes))]
834 #[unsafe(method_family = none)]
835 pub unsafe fn writableTypes(mtm: MainThreadMarker) -> Retained<NSArray<NSString>>;
836
837 #[unsafe(method(isNativeType:))]
838 #[unsafe(method_family = none)]
839 pub unsafe fn isNativeType(r#type: &NSString, mtm: MainThreadMarker) -> bool;
840
841 #[unsafe(method(writableTypesForSaveOperation:))]
842 #[unsafe(method_family = none)]
843 pub unsafe fn writableTypesForSaveOperation(
844 &self,
845 save_operation: NSSaveOperationType,
846 ) -> Retained<NSArray<NSString>>;
847
848 #[unsafe(method(fileNameExtensionForType:saveOperation:))]
849 #[unsafe(method_family = none)]
850 pub unsafe fn fileNameExtensionForType_saveOperation(
851 &self,
852 type_name: &NSString,
853 save_operation: NSSaveOperationType,
854 ) -> Option<Retained<NSString>>;
855
856 #[cfg(feature = "NSUserInterfaceValidation")]
857 #[unsafe(method(validateUserInterfaceItem:))]
858 #[unsafe(method_family = none)]
859 pub unsafe fn validateUserInterfaceItem(
860 &self,
861 item: &ProtocolObject<dyn NSValidatedUserInterfaceItem>,
862 ) -> bool;
863
864 #[unsafe(method(usesUbiquitousStorage))]
865 #[unsafe(method_family = none)]
866 pub unsafe fn usesUbiquitousStorage(mtm: MainThreadMarker) -> bool;
867
868 #[unsafe(method(presentedItemURL))]
869 #[unsafe(method_family = none)]
870 pub unsafe fn presentedItemURL(&self) -> Option<Retained<NSURL>>;
871
872 #[unsafe(method(observedPresentedItemUbiquityAttributes))]
873 #[unsafe(method_family = none)]
874 pub unsafe fn observedPresentedItemUbiquityAttributes(
875 &self,
876 ) -> Retained<NSSet<NSURLResourceKey>>;
877
878 #[cfg(feature = "block2")]
879 #[unsafe(method(relinquishPresentedItemToReader:))]
880 #[unsafe(method_family = none)]
881 pub unsafe fn relinquishPresentedItemToReader(
882 &self,
883 reader: &block2::Block<dyn Fn(*mut block2::Block<dyn Fn()>)>,
884 );
885
886 #[cfg(feature = "block2")]
887 #[unsafe(method(relinquishPresentedItemToWriter:))]
888 #[unsafe(method_family = none)]
889 pub unsafe fn relinquishPresentedItemToWriter(
890 &self,
891 writer: &block2::Block<dyn Fn(*mut block2::Block<dyn Fn()>)>,
892 );
893
894 #[cfg(feature = "block2")]
895 #[unsafe(method(savePresentedItemChangesWithCompletionHandler:))]
896 #[unsafe(method_family = none)]
897 pub unsafe fn savePresentedItemChangesWithCompletionHandler(
898 &self,
899 completion_handler: &block2::Block<dyn Fn(*mut NSError)>,
900 );
901
902 #[cfg(feature = "block2")]
903 #[unsafe(method(accommodatePresentedItemDeletionWithCompletionHandler:))]
904 #[unsafe(method_family = none)]
905 pub unsafe fn accommodatePresentedItemDeletionWithCompletionHandler(
906 &self,
907 completion_handler: &block2::Block<dyn Fn(*mut NSError)>,
908 );
909
910 #[unsafe(method(presentedItemDidMoveToURL:))]
911 #[unsafe(method_family = none)]
912 pub unsafe fn presentedItemDidMoveToURL(&self, new_url: &NSURL);
913
914 #[unsafe(method(presentedItemDidChange))]
915 #[unsafe(method_family = none)]
916 pub unsafe fn presentedItemDidChange(&self);
917
918 #[unsafe(method(presentedItemDidChangeUbiquityAttributes:))]
919 #[unsafe(method_family = none)]
920 pub unsafe fn presentedItemDidChangeUbiquityAttributes(
921 &self,
922 attributes: &NSSet<NSURLResourceKey>,
923 );
924
925 #[unsafe(method(presentedItemDidGainVersion:))]
926 #[unsafe(method_family = none)]
927 pub unsafe fn presentedItemDidGainVersion(&self, version: &NSFileVersion);
928
929 #[unsafe(method(presentedItemDidLoseVersion:))]
930 #[unsafe(method_family = none)]
931 pub unsafe fn presentedItemDidLoseVersion(&self, version: &NSFileVersion);
932
933 #[unsafe(method(presentedItemDidResolveConflictVersion:))]
934 #[unsafe(method_family = none)]
935 pub unsafe fn presentedItemDidResolveConflictVersion(&self, version: &NSFileVersion);
936 );
937}
938
939impl NSDocument {
941 extern_methods!(
942 #[unsafe(method(new))]
943 #[unsafe(method_family = new)]
944 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
945 );
946}
947
948impl NSDocument {
950 extern_methods!(
951 #[deprecated]
952 #[unsafe(method(shouldRunSavePanelWithAccessoryView))]
953 #[unsafe(method_family = none)]
954 pub unsafe fn shouldRunSavePanelWithAccessoryView(&self) -> bool;
955
956 #[deprecated = "Use -saveToURL:ofType:forSaveOperation:completionHandler: instead"]
957 #[unsafe(method(saveToURL:ofType:forSaveOperation:error:_))]
958 #[unsafe(method_family = none)]
959 pub unsafe fn saveToURL_ofType_forSaveOperation_error(
960 &self,
961 url: &NSURL,
962 type_name: &NSString,
963 save_operation: NSSaveOperationType,
964 ) -> Result<(), Retained<NSError>>;
965
966 #[deprecated]
967 #[unsafe(method(dataRepresentationOfType:))]
968 #[unsafe(method_family = none)]
969 pub unsafe fn dataRepresentationOfType(
970 &self,
971 r#type: &NSString,
972 ) -> Option<Retained<NSData>>;
973
974 #[deprecated]
975 #[unsafe(method(fileAttributesToWriteToFile:ofType:saveOperation:))]
976 #[unsafe(method_family = none)]
977 pub unsafe fn fileAttributesToWriteToFile_ofType_saveOperation(
978 &self,
979 full_document_path: &NSString,
980 document_type_name: &NSString,
981 save_operation_type: NSSaveOperationType,
982 ) -> Option<Retained<NSDictionary>>;
983
984 #[deprecated]
985 #[unsafe(method(fileName))]
986 #[unsafe(method_family = none)]
987 pub unsafe fn fileName(&self) -> Option<Retained<NSString>>;
988
989 #[deprecated]
990 #[unsafe(method(fileWrapperRepresentationOfType:))]
991 #[unsafe(method_family = none)]
992 pub unsafe fn fileWrapperRepresentationOfType(
993 &self,
994 r#type: &NSString,
995 ) -> Option<Retained<NSFileWrapper>>;
996
997 #[deprecated]
998 #[unsafe(method(initWithContentsOfFile:ofType:))]
999 #[unsafe(method_family = init)]
1000 pub unsafe fn initWithContentsOfFile_ofType(
1001 this: Allocated<Self>,
1002 absolute_path: &NSString,
1003 type_name: &NSString,
1004 ) -> Option<Retained<Self>>;
1005
1006 #[deprecated]
1007 #[unsafe(method(initWithContentsOfURL:ofType:))]
1008 #[unsafe(method_family = init)]
1009 pub unsafe fn initWithContentsOfURL_ofType(
1010 this: Allocated<Self>,
1011 url: &NSURL,
1012 type_name: &NSString,
1013 ) -> Option<Retained<Self>>;
1014
1015 #[deprecated]
1016 #[unsafe(method(loadDataRepresentation:ofType:))]
1017 #[unsafe(method_family = none)]
1018 pub unsafe fn loadDataRepresentation_ofType(
1019 &self,
1020 data: &NSData,
1021 r#type: &NSString,
1022 ) -> bool;
1023
1024 #[deprecated]
1025 #[unsafe(method(loadFileWrapperRepresentation:ofType:))]
1026 #[unsafe(method_family = none)]
1027 pub unsafe fn loadFileWrapperRepresentation_ofType(
1028 &self,
1029 wrapper: &NSFileWrapper,
1030 r#type: &NSString,
1031 ) -> bool;
1032
1033 #[deprecated]
1034 #[unsafe(method(printShowingPrintPanel:))]
1035 #[unsafe(method_family = none)]
1036 pub unsafe fn printShowingPrintPanel(&self, flag: bool);
1037
1038 #[deprecated]
1039 #[unsafe(method(readFromFile:ofType:))]
1040 #[unsafe(method_family = none)]
1041 pub unsafe fn readFromFile_ofType(&self, file_name: &NSString, r#type: &NSString) -> bool;
1042
1043 #[deprecated]
1044 #[unsafe(method(readFromURL:ofType:))]
1045 #[unsafe(method_family = none)]
1046 pub unsafe fn readFromURL_ofType(&self, url: &NSURL, r#type: &NSString) -> bool;
1047
1048 #[deprecated]
1049 #[unsafe(method(revertToSavedFromFile:ofType:))]
1050 #[unsafe(method_family = none)]
1051 pub unsafe fn revertToSavedFromFile_ofType(
1052 &self,
1053 file_name: &NSString,
1054 r#type: &NSString,
1055 ) -> bool;
1056
1057 #[deprecated]
1058 #[unsafe(method(revertToSavedFromURL:ofType:))]
1059 #[unsafe(method_family = none)]
1060 pub unsafe fn revertToSavedFromURL_ofType(&self, url: &NSURL, r#type: &NSString) -> bool;
1061
1062 #[cfg(feature = "NSPrintInfo")]
1063 #[deprecated]
1064 #[unsafe(method(runModalPageLayoutWithPrintInfo:))]
1065 #[unsafe(method_family = none)]
1066 pub unsafe fn runModalPageLayoutWithPrintInfo(&self, print_info: &NSPrintInfo)
1067 -> NSInteger;
1068
1069 #[deprecated]
1070 #[unsafe(method(saveToFile:saveOperation:delegate:didSaveSelector:contextInfo:))]
1071 #[unsafe(method_family = none)]
1072 pub unsafe fn saveToFile_saveOperation_delegate_didSaveSelector_contextInfo(
1073 &self,
1074 file_name: &NSString,
1075 save_operation: NSSaveOperationType,
1076 delegate: Option<&AnyObject>,
1077 did_save_selector: Option<Sel>,
1078 context_info: *mut c_void,
1079 );
1080
1081 #[deprecated]
1082 #[unsafe(method(setFileName:))]
1083 #[unsafe(method_family = none)]
1084 pub unsafe fn setFileName(&self, file_name: Option<&NSString>);
1085
1086 #[deprecated]
1087 #[unsafe(method(writeToFile:ofType:))]
1088 #[unsafe(method_family = none)]
1089 pub unsafe fn writeToFile_ofType(&self, file_name: &NSString, r#type: &NSString) -> bool;
1090
1091 #[deprecated]
1092 #[unsafe(method(writeToFile:ofType:originalFile:saveOperation:))]
1093 #[unsafe(method_family = none)]
1094 pub unsafe fn writeToFile_ofType_originalFile_saveOperation(
1095 &self,
1096 full_document_path: &NSString,
1097 document_type_name: &NSString,
1098 full_original_document_path: Option<&NSString>,
1099 save_operation_type: NSSaveOperationType,
1100 ) -> bool;
1101
1102 #[deprecated]
1103 #[unsafe(method(writeToURL:ofType:))]
1104 #[unsafe(method_family = none)]
1105 pub unsafe fn writeToURL_ofType(&self, url: &NSURL, r#type: &NSString) -> bool;
1106
1107 #[deprecated]
1108 #[unsafe(method(writeWithBackupToFile:ofType:saveOperation:))]
1109 #[unsafe(method_family = none)]
1110 pub unsafe fn writeWithBackupToFile_ofType_saveOperation(
1111 &self,
1112 full_document_path: &NSString,
1113 document_type_name: &NSString,
1114 save_operation_type: NSSaveOperationType,
1115 ) -> bool;
1116 );
1117}