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