[macos] fix bug 65972

This commit is contained in:
maxkadushkin
2024-02-09 16:24:14 +03:00
parent 7be81adb35
commit 406d7b60bb
4 changed files with 29 additions and 3 deletions

View File

@ -583,14 +583,15 @@
[self.tabsControl selectTab:tab];
__block NSInteger fileType = [params[@"fileType"] intValue];
// __block NSInteger fileType = [params[@"fileType"] intValue];
__block ASCSavePanelWithFormatController * saveController = [ASCSavePanelWithFormatController new];
NSSavePanel * savePanel = [saveController savePanel];
saveController.filters = formats;
saveController.filterType = fileType;
saveController.original = params[@"original"];
// saveController.filterType = fileType;
if (!path || path.length < 1) {
path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];

View File

@ -330,11 +330,18 @@ public:
// End hotfix ODP presentation
NSDictionary * formatInfo = [ASCConstants ascFormatsInfo][@(pData->get_FileType())];
NSDictionary * originalFileInfo = @{
@"type" : @(pData->get_FileType()),
@"typeInfo" : formatInfo ? formatInfo : @{}
};
[[NSNotificationCenter defaultCenter] postNotificationName:CEFEventNameSaveLocal
object:nil
userInfo:@{
@"path" : [NSString stringWithstdwstring:pData->get_Path()],
@"fileType": @(pData->get_FileType()),
// @"fileType": @(pData->get_FileType()),
@"original": originalFileInfo,
@"supportedFormats" : supportFormats,
@"viewId" : [NSString stringWithFormat:@"%d", pData->get_Id()]
}];

View File

@ -44,4 +44,5 @@
@property (nonatomic) NSSavePanel *savePanel;
@property (nonatomic) NSArray * filters;
@property (nonatomic) NSInteger filterType;
@property (nonatomic) NSDictionary * original;
@end

View File

@ -109,6 +109,18 @@
}];
if (NSNotFound == index) {
if ( _original ) {
NSString * postfix = _original[@"typeInfo"][@"extension"];
if ( postfix ) {
predicate = [NSPredicate predicateWithFormat:@"self.extension == %@", postfix];
index = [_filters indexOfObjectPassingTest:^BOOL(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
return [predicate evaluateWithObject:obj];
}];
}
}
}
if ( NSNotFound == index ) {
NSInteger selectIndex = MAX([_popupFormats indexOfSelectedItem], 0);
_filterType = [_filters[selectIndex][@"type"] intValue];
} else {
@ -117,4 +129,9 @@
}
}
- (void)setOriginal:(NSDictionary *)original {
_original = original;
[self setFilterType:[original[@"type"] intValue]];
}
@end