[macos] fix bug 54685

This commit is contained in:
maxkadushkin
2022-04-17 16:39:40 +03:00
parent 91ea69a1cf
commit d434fb172d
2 changed files with 25 additions and 2 deletions

View File

@ -90,6 +90,22 @@
//
// return event;
// }];
NSArray * arguments = [[NSProcessInfo processInfo] arguments];
for (NSString * arg in arguments) {
if ( [arg hasPrefix:@"--new:"] || [arg hasPrefix:@"--new="] ) {
NSString * param = [arg substringFromIndex:6];
NSLog(@"input arg new: %@", param);
if ( [@[@"word",@"cell",@"slide",@"form"] containsObject:param] ) {
[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameCreateTab
object:nil
userInfo:@{ @"action" : @(ASCTabActionCreateLocalFile),
@"type" : param,
@"active" : @(YES) }];
}
}
}
}
/// If your delegate implements this method, AppKit does not call the application(_:openFile:)

View File

@ -1674,8 +1674,15 @@
}
case ASCTabActionCreateLocalFile: {
int docType = [tab.params[@"type"] intValue];
int docType = CEFDocumentDocument;
if ( [tab.params[@"type"] isKindOfClass:[NSString class]] ) {
NSString * param = tab.params[@"type"];
if ([param isEqualToString:@"cell"]) docType = CEFDocumentSpreadsheet;
else if ([param isEqualToString:@"slide"]) docType = CEFDocumentPresentation;
else if ([param isEqualToString:@"form"]) docType = CEFDocumentForm;
else /*if ([param isEqualToString:@"word"])*/ docType = CEFDocumentDocument;
} else docType = [tab.params[@"type"] intValue];
NSString * docName = NSLocalizedString(@"Untitled", nil);
switch (docType) {