Skip to content

Commit

Permalink
[macos] support for pdf editor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadushkin committed Sep 26, 2023
1 parent 62a210f commit 93907d3
Show file tree
Hide file tree
Showing 22 changed files with 160 additions and 80 deletions.
18 changes: 8 additions & 10 deletions macos/ONLYOFFICE.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
FC0BD6A1258B63F700C47F95 /* ASCPopoverLightView.m in Sources */ = {isa = PBXBuildFile; fileRef = FC1127581BBAAC8000AA3648 /* ASCPopoverLightView.m */; };
FC0BD6A2258B63F700C47F95 /* NSCefView.mm in Sources */ = {isa = PBXBuildFile; fileRef = FC98BAD51BAC43B400747944 /* NSCefView.mm */; };
FC0BD6A3258B63F700C47F95 /* ASCTabsControl.m in Sources */ = {isa = PBXBuildFile; fileRef = FCC77C8C206CEE85001B7837 /* ASCTabsControl.m */; };
FC0BD6A4258B63F700C47F95 /* ASCTitleBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.m */; };
FC0BD6A4258B63F700C47F95 /* ASCTitleBarController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.mm */; };
FC0BD6A5258B63F700C47F95 /* SFBPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3BFDFB1BBE83AB0040C904 /* SFBPopover.m */; };
FC0BD6A6258B63F700C47F95 /* ASCEventsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FC3B77841BB2A94300DB9705 /* ASCEventsController.mm */; };
FC0BD6A7258B63F700C47F95 /* ASCAboutController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC659BF81C75EE8B00C99776 /* ASCAboutController.m */; };
Expand Down Expand Up @@ -221,7 +221,7 @@
FCA3F3102570EC9500DCAB12 /* file-epub.icns in Resources */ = {isa = PBXBuildFile; fileRef = FCA3F3062570EC9500DCAB12 /* file-epub.icns */; };
FCA4502E1C2063460007134D /* ASCSharedSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA4502D1C2063460007134D /* ASCSharedSettings.m */; };
FCA9A1901BA6DC6000ABF3AB /* ASCCommonViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A18F1BA6DC6000ABF3AB /* ASCCommonViewController.mm */; };
FCA9A1951BA6DE2700ABF3AB /* ASCTitleBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.m */; };
FCA9A1951BA6DE2700ABF3AB /* ASCTitleBarController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.mm */; };
FCA9A1961BA6DE2700ABF3AB /* ASCTitleWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1941BA6DE2700ABF3AB /* ASCTitleWindowController.mm */; };
FCAA9A3E1BBA802100F3C47F /* ASCDownloadCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAA9A3D1BBA802100F3C47F /* ASCDownloadCellView.m */; };
FCAA9A441BBA817B00F3C47F /* ASCDownloadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCAA9A431BBA817B00F3C47F /* ASCDownloadViewController.m */; };
Expand Down Expand Up @@ -260,7 +260,7 @@
FCB4C6DA26DD018B0012C20D /* ASCPopoverLightView.m in Sources */ = {isa = PBXBuildFile; fileRef = FC1127581BBAAC8000AA3648 /* ASCPopoverLightView.m */; };
FCB4C6DB26DD018B0012C20D /* NSCefView.mm in Sources */ = {isa = PBXBuildFile; fileRef = FC98BAD51BAC43B400747944 /* NSCefView.mm */; };
FCB4C6DC26DD018B0012C20D /* ASCTabsControl.m in Sources */ = {isa = PBXBuildFile; fileRef = FCC77C8C206CEE85001B7837 /* ASCTabsControl.m */; };
FCB4C6DD26DD018B0012C20D /* ASCTitleBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.m */; };
FCB4C6DD26DD018B0012C20D /* ASCTitleBarController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.mm */; };
FCB4C6DE26DD018B0012C20D /* SFBPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3BFDFB1BBE83AB0040C904 /* SFBPopover.m */; };
FCB4C6DF26DD018B0012C20D /* ASCEventsController.mm in Sources */ = {isa = PBXBuildFile; fileRef = FC3B77841BB2A94300DB9705 /* ASCEventsController.mm */; };
FCB4C6E026DD018B0012C20D /* ASCAboutController.m in Sources */ = {isa = PBXBuildFile; fileRef = FC659BF81C75EE8B00C99776 /* ASCAboutController.m */; };
Expand Down Expand Up @@ -786,7 +786,6 @@
BE95F0A623E9FF590045E0CB /* mac_cefview.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mac_cefview.h; sourceTree = "<group>"; };
FC033D251BB13B9900F6C55F /* mac_application.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mac_application.h; sourceTree = "<group>"; };
FC035A5B24855E8C00AF820F /* ASCTabViewType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASCTabViewType.h; sourceTree = "<group>"; };
FC035A5C2485625400AF820F /* ASCDocumentType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASCDocumentType.h; sourceTree = "<group>"; };
FC09073D1C1855A400D9E881 /* editors */ = {isa = PBXFileReference; lastKnownFileType = folder; name = editors; path = Vendor/ONLYOFFICE/editors; sourceTree = SOURCE_ROOT; };
FC0907401C186A7A00D9E881 /* converter */ = {isa = PBXFileReference; lastKnownFileType = folder; name = converter; path = Vendor/ONLYOFFICE/converter; sourceTree = SOURCE_ROOT; };
FC0BD6FB258B63F700C47F95 /* ONLYOFFICE.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ONLYOFFICE.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -937,7 +936,7 @@
FCA9A18E1BA6DC6000ABF3AB /* ASCCommonViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCCommonViewController.h; sourceTree = "<group>"; };
FCA9A18F1BA6DC6000ABF3AB /* ASCCommonViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASCCommonViewController.mm; sourceTree = "<group>"; };
FCA9A1911BA6DE2700ABF3AB /* ASCTitleBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCTitleBarController.h; sourceTree = "<group>"; };
FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASCTitleBarController.m; sourceTree = "<group>"; };
FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASCTitleBarController.mm; sourceTree = "<group>"; };
FCA9A1931BA6DE2700ABF3AB /* ASCTitleWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCTitleWindowController.h; sourceTree = "<group>"; };
FCA9A1941BA6DE2700ABF3AB /* ASCTitleWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASCTitleWindowController.mm; sourceTree = "<group>"; };
FCAA9A3C1BBA802100F3C47F /* ASCDownloadCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCDownloadCellView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1147,7 +1146,6 @@
isa = PBXGroup;
children = (
FC035A5B24855E8C00AF820F /* ASCTabViewType.h */,
FC035A5C2485625400AF820F /* ASCDocumentType.h */,
);
path = Enums;
sourceTree = "<group>";
Expand Down Expand Up @@ -1717,7 +1715,7 @@
FCA0B33E1B9EB5960073EDD4 /* ASCTitleWindow.h */,
FCA0B33F1B9EB5960073EDD4 /* ASCTitleWindow.m */,
FCA9A1911BA6DE2700ABF3AB /* ASCTitleBarController.h */,
FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.m */,
FCA9A1921BA6DE2700ABF3AB /* ASCTitleBarController.mm */,
FCA9A1931BA6DE2700ABF3AB /* ASCTitleWindowController.h */,
FCA9A1941BA6DE2700ABF3AB /* ASCTitleWindowController.mm */,
FC25A1A51C2E844800063A42 /* ASCTabViewController.h */,
Expand Down Expand Up @@ -2305,7 +2303,7 @@
FC0BD6A1258B63F700C47F95 /* ASCPopoverLightView.m in Sources */,
FC0BD6A2258B63F700C47F95 /* NSCefView.mm in Sources */,
FC0BD6A3258B63F700C47F95 /* ASCTabsControl.m in Sources */,
FC0BD6A4258B63F700C47F95 /* ASCTitleBarController.m in Sources */,
FC0BD6A4258B63F700C47F95 /* ASCTitleBarController.mm in Sources */,
FC0BD6A5258B63F700C47F95 /* SFBPopover.m in Sources */,
FC0BD6A6258B63F700C47F95 /* ASCEventsController.mm in Sources */,
FC0BD6A7258B63F700C47F95 /* ASCAboutController.m in Sources */,
Expand Down Expand Up @@ -2380,7 +2378,7 @@
FCB4C6DA26DD018B0012C20D /* ASCPopoverLightView.m in Sources */,
FCB4C6DB26DD018B0012C20D /* NSCefView.mm in Sources */,
FCB4C6DC26DD018B0012C20D /* ASCTabsControl.m in Sources */,
FCB4C6DD26DD018B0012C20D /* ASCTitleBarController.m in Sources */,
FCB4C6DD26DD018B0012C20D /* ASCTitleBarController.mm in Sources */,
FCB4C6DE26DD018B0012C20D /* SFBPopover.m in Sources */,
FCB4C6DF26DD018B0012C20D /* ASCEventsController.mm in Sources */,
FCB4C6E026DD018B0012C20D /* ASCAboutController.m in Sources */,
Expand Down Expand Up @@ -2455,7 +2453,7 @@
FC1127591BBAAC8000AA3648 /* ASCPopoverLightView.m in Sources */,
FC98BAD61BAC43B400747944 /* NSCefView.mm in Sources */,
FCC77C94206CEE85001B7837 /* ASCTabsControl.m in Sources */,
FCA9A1951BA6DE2700ABF3AB /* ASCTitleBarController.m in Sources */,
FCA9A1951BA6DE2700ABF3AB /* ASCTitleBarController.mm in Sources */,
FC3BFE001BBE83AB0040C904 /* SFBPopover.m in Sources */,
FC3B77851BB2A94300DB9705 /* ASCEventsController.mm in Sources */,
FC659BFA1C75EE8B00C99776 /* ASCAboutController.m in Sources */,
Expand Down
33 changes: 17 additions & 16 deletions macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#import "ASCThemesController.h"
#import "ASCEditorJSVariables.h"
#import "ASCPresentationReporter.h"
#import "ASCDocumentType.h"
#import <Carbon/Carbon.h>

#define rootTabId @"1CEF624D-9FF3-432B-9967-61361B5BFE8B"
Expand Down Expand Up @@ -397,23 +396,23 @@ - (void)onTouchBarItemTap:(id)sender senderId:(NSString *)senderId {
object:nil
userInfo:@{
@"action" : @(ASCTabActionCreateLocalFile),
@"type" : @(CEFDocumentDocument),
@"type" : @(int(AscEditorType::etDocument)),
@"active" : @(YES)
}];
} else if ([senderId isEqualToString:[NSString stringWithFormat:kCreationButtonIdentifier, @"spreadsheet"]]) {
[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameCreateTab
object:nil
userInfo:@{
@"action" : @(ASCTabActionCreateLocalFile),
@"type" : @(CEFDocumentSpreadsheet),
@"type" : @(int(AscEditorType::etSpreadsheet)),
@"active" : @(YES)
}];
} else if ([senderId isEqualToString:[NSString stringWithFormat:kCreationButtonIdentifier, @"presentation"]]) {
[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameCreateTab
object:nil
userInfo:@{
@"action" : @(ASCTabActionCreateLocalFile),
@"type" : @(CEFDocumentPresentation),
@"type" : @(int(AscEditorType::etPresentation)),
@"active" : @(YES)
}];
} else {
Expand Down Expand Up @@ -743,9 +742,9 @@ - (void)onCEFCreateTab:(NSNotification *)notification {
NSOpenPanel * openPanel = [NSOpenPanel openPanel];
NSMutableArray * filter = [NSMutableArray array];

if ( [params[@"type"] isEqualToNumber:@(ASCDocumentTypePresentation)] ) {
if ( [params[@"type"] isEqualToNumber:@((int)AscEditorType::etPresentation)] ) {
[filter addObjectsFromArray:@[@"potx", @"otp"]];
} else if ( [params[@"type"] isEqualToNumber:@(ASCDocumentTypeSpreadsheet)] ) {
} else if ( [params[@"type"] isEqualToNumber:@((int)AscEditorType::etSpreadsheet)] ) {
[filter addObjectsFromArray:@[@"xltx", @"xltm", @"ots"]];
} else {
[filter addObjectsFromArray:@[@"dotx", @"ott"]];
Expand Down Expand Up @@ -1820,30 +1819,32 @@ - (void)tabs:(ASCTabsControl *)control didAddTab:(ASCTabView *)tab {

case ASCTabActionCreateLocalFileFromTemplate:
case ASCTabActionCreateLocalFile: {
int docType = CEFDocumentDocument;
AscEditorType docType = AscEditorType::etDocument;
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];
if ([param isEqualToString:@"cell"]) docType = AscEditorType::etSpreadsheet;
else if ([param isEqualToString:@"slide"]) docType = AscEditorType::etPresentation;
else if ([param isEqualToString:@"form"]) docType = AscEditorType::etDocumentMasterForm;
// else /*if ([param isEqualToString:@"word"])*/ docType = AscEditorType::etDocument;
} else docType = (AscEditorType)[tab.params[@"type"] intValue];

NSString * docName = NSLocalizedString(@"Untitled", nil);

switch (docType) {
case CEFDocumentDocument:
case AscEditorType::etDocument:
docName = [NSString stringWithFormat:NSLocalizedString(@"Document %ld.docx", nil), ++documentNameCounter];
break;
case CEFDocumentSpreadsheet:
case AscEditorType::etSpreadsheet:
docName = [NSString stringWithFormat:NSLocalizedString(@"Spreadsheet %ld.xlsx", nil), ++spreadsheetNameCounter];
break;
case CEFDocumentPresentation:
case AscEditorType::etPresentation:
docName = [NSString stringWithFormat:NSLocalizedString(@"Presentation %ld.pptx", nil), ++presentationNameCounter];
break;
case CEFDocumentForm:
case AscEditorType::etDocumentMasterOForm:
case AscEditorType::etDocumentMasterForm:
docName = [NSString stringWithFormat:NSLocalizedString(@"Document %ld.docxf", nil), ++documentNameCounter];
break;
default: break;
}

if (action == ASCTabActionCreateLocalFile ) {
Expand Down
23 changes: 11 additions & 12 deletions macos/ONLYOFFICE/Code/Controllers/Common/ASCEventsController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#import "ASCEventsController.h"
#import "ASCConstants.h"
#import "ASCDocumentType.h"
#import "ASCExternalController.h"
#import "ASCPresentationReporter.h"
#import "ASCSharedSettings.h"
Expand Down Expand Up @@ -680,43 +679,43 @@ virtual void OnEvent(NSEditorApi::CAscCefMenuEvent* pRawEvent)
/// Create local files

NSString * nsParam = (NSString *)[NSString stringWithstdwstring:param];
ASCDocumentType docType = ASCDocumentTypeUnknown;
AscEditorType docType = AscEditorType::etUndefined;

if ([nsParam hasPrefix:@"template:"]) {
if ([nsParam hasSuffix:@"word"]) {
docType = ASCDocumentTypeDocument;
docType = AscEditorType::etDocument;
} else
if ([nsParam hasSuffix:@"slide"]) {
docType = ASCDocumentTypePresentation;
docType = AscEditorType::etPresentation;
} else
if ([nsParam hasSuffix:@"cell"]) {
docType = ASCDocumentTypeSpreadsheet;
docType = AscEditorType::etSpreadsheet;
}

[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameCreateTab
object:nil
userInfo:@{
@"action" : @(ASCTabActionCreateLocalFileFromTemplate),
@"type" : @(docType),
@"type" : @(int(docType)),
@"active" : @(YES)
}];
} else {
if ([nsParam isEqualToString:@"word"]) {
docType = ASCDocumentTypeDocument;
docType = AscEditorType::etDocument;
} else if ([nsParam isEqualToString:@"cell"]) {
docType = ASCDocumentTypeSpreadsheet;
docType = AscEditorType::etSpreadsheet;
} else if ([nsParam isEqualToString:@"slide"]) {
docType = ASCDocumentTypePresentation;
docType = AscEditorType::etPresentation;
} else if ([nsParam isEqualToString:@"form"]) {
docType = ASCDocumentTypeForm;
docType = AscEditorType::etDocumentMasterForm;
}

if (docType != ASCDocumentTypeUnknown) {
if ( docType != AscEditorType::etUndefined ) {
[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameCreateTab
object:nil
userInfo:@{
@"action" : @(ASCTabActionCreateLocalFile),
@"type" : @(docType),
@"type" : @(int(docType)),
@"active" : @(YES)
}];
}
Expand Down
Loading

0 comments on commit 93907d3

Please sign in to comment.