Merge pull request #63 from gnustep/NSPersistentDocument_branch

NSPersistentDocument branch
This commit is contained in:
Gregory Casamento 2020-05-09 14:40:31 -04:00 committed by GitHub
commit 7fbf0bb067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 248 additions and 1 deletions

View file

@ -192,6 +192,7 @@
#import <AppKit/NSOpenGLView.h>
#import <AppKit/NSOutlineView.h>
#import <AppKit/NSParagraphStyle.h>
#import <AppKit/NSPersistentDocument.h>
#import <AppKit/NSPathControl.h>
#import <AppKit/NSPathCell.h>
#import <AppKit/NSPathComponentCell.h>

View file

@ -0,0 +1,99 @@
/* Definition of class NSPersistentDocument
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Thu May 7 00:04:09 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#ifndef _NSPersistentDocument_h_GNUSTEP_GUI_INCLUDE
#define _NSPersistentDocument_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/NSDocument.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
#if defined(__cplusplus)
extern "C" {
#endif
@class NSManagedObjectContext;
@class NSManagedObjectModel;
@class NSError;
@class NSURL;
@class NSString;
@class NSDictionary;
@class NSUndoManager;
@interface NSPersistentDocument : NSDocument
{
NSManagedObjectContext *_managedObjectContext;
NSManagedObjectModel *_managedObjectModel;
}
- (NSManagedObjectContext *) managedObjectContext;
- (NSManagedObjectModel *) managedObjectModel;
- (BOOL) configurePersistentStoreCoordinatorForURL: (NSURL *)url
ofType: (NSString *)fileType
modelConfiguration: (NSString *)config
storeOptions: (NSDictionary *)options
error: (NSError **)err;
- (NSString *) persistentStoreTypeForFileType: (NSString *)fileType;
- (BOOL)hasUndoManager;
- (void) setHasUndoManager: (BOOL)flag;
- (void) setUndoManager: (NSUndoManager *)manager;
- (BOOL) isDocumentEdited;
- (BOOL)readFromURL: (NSURL *)absoluteURL
ofType: (NSString *)typeName
error: (NSError **)err;
- (BOOL)revertToContentsOfURL: (NSURL *)url
ofType: (NSString *)type
error: (NSError **)outErr;
- (BOOL) writeToURL: (NSURL *)url
ofType: (NSString *)type
forSaveOperation: (NSSaveOperationType)saveOp
originalContentsURL: (NSURL *)originalContents
error: (NSError **)err;
- (BOOL)canAsynchronouslyWriteToURL: (NSURL *)url
ofType: (NSString *)type
forSaveOperation: (NSSaveOperationType)saveOp;
- (BOOL)configurePersistentStoreCoordinatorForURL: (NSURL *)url
ofType: (NSString *)fileType
error: (NSError **)err;
@end
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSPersistentDocument_h_GNUSTEP_GUI_INCLUDE */

View file

@ -24,7 +24,6 @@ MISSING HEADERS
> NSMenuToolbarItem.h
> NSOpenGLLayer.h
> NSPageController.h
> NSPersistentDocument.h
> NSRuleEditor.h
> NSSliderAccessory.h
> NSSplitViewController.h

View file

@ -190,6 +190,7 @@ NSPasteboardItem.m \
NSPDFInfo.m \
NSPDFImageRep.m \
NSPDFPanel.m \
NSPersistentDocument.m \
NSPICTImageRep.m \
NSPopover.m \
NSPopUpButton.m \
@ -464,6 +465,7 @@ NSPasteboardItem.h \
NSPDFInfo.h \
NSPDFImageRep.h \
NSPDFPanel.h \
NSPersistentDocument.h \
NSPICTImageRep.h \
NSPickerTouchBarItem.h \
NSPopoverTouchBarItem.h \

View file

@ -955,7 +955,9 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
- (IBAction) openDocument: (id)sender
{
#if !__has_feature(blocks)
NSError *err = nil;
#endif
NSEnumerator *urlEnum;
NSURL *url;

View file

@ -0,0 +1,144 @@
/* Implementation of class NSPersistentDocument
Copyright (C) 2020 Free Software Foundation, Inc.
By: Gregory John Casamento
Date: Thu May 7 00:04:09 EDT 2020
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/
#import <Foundation/NSURL.h>
#import <Foundation/NSString.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSError.h>
#import <Foundation/NSException.h>
#import <Foundation/NSUndoManager.h>
#import "AppKit/NSPersistentDocument.h"
static Class persistentDocumentClass = nil;
@implementation NSPersistentDocument
+ (void) initialize
{
if (self == [NSPersistentDocument class])
{
[self setVersion: 1];
[self setPersistentDocumentClass: [NSPersistentDocument class]];
}
}
+ (void) setPersistentDocumentClass: (Class)clz
{
persistentDocumentClass = clz;
}
+ (id) allocWithZone: (NSZone *)z
{
if (persistentDocumentClass == self)
{
NSAssert(persistentDocumentClass != self,
@"NSPersistentDocument error: Concrete class not set");
}
return NSAllocateObject(persistentDocumentClass, 0, z);
}
- (NSManagedObjectContext *) managedObjectContext
{
return _managedObjectContext;
}
- (NSManagedObjectModel *) managedObjectModel
{
return _managedObjectModel;
}
- (BOOL) configurePersistentStoreCoordinatorForURL: (NSURL *)url
ofType: (NSString *)fileType
modelConfiguration: (NSString *)config
storeOptions: (NSDictionary *)options
error: (NSError **)err
{
return NO;
}
- (NSString *) persistentStoreTypeForFileType: (NSString *)fileType
{
return nil;
}
- (BOOL)hasUndoManager
{
return YES; // overridden since uses stores undo manager
}
- (void) setHasUndoManager: (BOOL)flag
{
// Implemented as NO-OP per documentation
}
- (void) setUndoManager: (NSUndoManager *)manager
{
// implemented as NO-OP per documentation.
}
- (BOOL) isDocumentEdited
{
return NO;
}
- (BOOL)readFromURL: (NSURL *)absoluteURL
ofType: (NSString *)typeName
error: (NSError **)err
{
return NO;
}
- (BOOL)revertToContentsOfURL: (NSURL *)url
ofType: (NSString *)type
error: (NSError **)outErr
{
return NO;
}
- (BOOL) writeToURL: (NSURL *)url
ofType: (NSString *)type
forSaveOperation: (NSSaveOperationType)saveOp
originalContentsURL: (NSURL *)originalContents
error: (NSError **)err
{
return NO;
}
- (BOOL)canAsynchronouslyWriteToURL: (NSURL *)url
ofType: (NSString *)type
forSaveOperation: (NSSaveOperationType)saveOp
{
return NO;
}
- (BOOL)configurePersistentStoreCoordinatorForURL: (NSURL *)url
ofType: (NSString *)fileType
error: (NSError **)err
{
return NO;
}
@end