From d434fb172df3e59095c4f0c865ed8b0839a4b638 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Sun, 17 Apr 2022 16:39:40 +0300 Subject: [PATCH] [macos] fix bug 54685 --- macos/ONLYOFFICE/AppDelegate.mm | 16 ++++++++++++++++ .../Common/ASCCommonViewController.mm | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/macos/ONLYOFFICE/AppDelegate.mm b/macos/ONLYOFFICE/AppDelegate.mm index cf47f12c1..8d118a0ee 100644 --- a/macos/ONLYOFFICE/AppDelegate.mm +++ b/macos/ONLYOFFICE/AppDelegate.mm @@ -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:) diff --git a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm index 11c043efe..e82fc6e40 100644 --- a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm +++ b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm @@ -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) {