Added rudimentary export plugin support

This commit is contained in:
Michael Starke
2019-08-26 17:25:25 +02:00
parent 3b7bf0d77b
commit 2103eb8875
8 changed files with 75 additions and 14 deletions

View File

@@ -279,7 +279,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
}];
}
- (void)importFromPlugin:(id)sender {
- (void)importWithPlugin:(id)sender {
if(![sender isKindOfClass:NSMenuItem.class]) {
return;
}
@@ -304,6 +304,30 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
}];
}
- (void)exportWithPlugin:(id)sender {
if(![sender isKindOfClass:NSMenuItem.class]) {
return;
}
NSMenuItem *menuItem = sender;
if(![menuItem.representedObject isKindOfClass:NSString.class]) {
return;
}
NSWindow *sheetWindow = ((MPDocument *)self.document).windowForSheet;
if(!sheetWindow) {
return;
}
NSString *bundleIdentifier = menuItem.representedObject;
MPPlugin<MPExportPlugin> *exportPlugin = (MPPlugin<MPExportPlugin> *)[MPPluginHost.sharedHost pluginWithBundleIdentifier:bundleIdentifier];
NSSavePanel *savePanel = NSSavePanel.savePanel;
[exportPlugin prepareSavePanel:savePanel];
[savePanel beginSheetModalForWindow:sheetWindow completionHandler:^(NSModalResponse result) {
if(result == NSModalResponseOK) {
[exportPlugin exportTree:((MPDocument *)self.document).tree forRunningSavePanel:savePanel];
}
}];
}
- (void)mergeWithOther:(id)sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
MPDocument *document = self.document;