From dcd3eb00173dbf0f1644dcb6a3302a4665517f65 Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Tue, 27 Oct 2020 09:39:21 +0300 Subject: [PATCH] [macos] Fixed bug #47069 --- .../Common/ASCCommonViewController.mm | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm index 593e9c710..59c8d851c 100644 --- a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm +++ b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm @@ -1085,18 +1085,21 @@ [openPanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result){ [openPanel orderOut:self]; + CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager]; + + NSEditorApi::CAscLocalOpenFileDialog * imageInfo = new NSEditorApi::CAscLocalOpenFileDialog(); + imageInfo->put_Id((int)fileId); + if (result == NSFileHandlingPanelOKButton) { - CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager]; - - NSEditorApi::CAscLocalOpenFileDialog * imageInfo = new NSEditorApi::CAscLocalOpenFileDialog(); - imageInfo->put_Id((int)fileId); imageInfo->put_Path([[[openPanel URL] path] stdwstring]); - - NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_CEF_LOCALFILE_ADDIMAGE); - pEvent->m_pData = imageInfo; - - appManager->Apply(pEvent); + } else { + imageInfo->put_Path(L""); } + + NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_CEF_LOCALFILE_ADDIMAGE); + pEvent->m_pData = imageInfo; + + appManager->Apply(pEvent); }]; } } @@ -1144,23 +1147,26 @@ [openPanel beginSheetModalForWindow:[NSApp mainWindow] completionHandler:^(NSInteger result){ [openPanel orderOut:self]; + CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager]; + + NSEditorApi::CAscLocalOpenFileDialog * imageInfo = new NSEditorApi::CAscLocalOpenFileDialog(); + imageInfo->put_Id((int)fileId); + imageInfo->put_Filter([fileTypes stdwstring]); + if (result == NSFileHandlingPanelOKButton) { - CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager]; - - NSEditorApi::CAscLocalOpenFileDialog * imageInfo = new NSEditorApi::CAscLocalOpenFileDialog(); - imageInfo->put_Id((int)fileId); - imageInfo->put_Filter([fileTypes stdwstring]); imageInfo->put_Path([[[openPanel URL] path] stdwstring]); - - if (isMulti) { - imageInfo->put_IsMultiselect(true); - } - - NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_DOCUMENTEDITORS_OPENFILENAME_DIALOG); - pEvent->m_pData = imageInfo; - - appManager->Apply(pEvent); + } else { + imageInfo->put_Path(L""); } + + if (isMulti) { + imageInfo->put_IsMultiselect(true); + } + + NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_DOCUMENTEDITORS_OPENFILENAME_DIALOG); + pEvent->m_pData = imageInfo; + + appManager->Apply(pEvent); }]; } }