Index: WinNSOpenPanel.m =================================================================== --- WinNSOpenPanel.m (revisión: 37516) +++ WinNSOpenPanel.m (copia de trabajo) @@ -111,28 +111,20 @@ return L"All (*.*)\0*.*\0"; } - NSMutableSet *set = [NSMutableSet set]; NSEnumerator *en = nil; id type = nil; NSDocumentController *dc = [NSDocumentController sharedDocumentController]; NSMutableString *filterString = [NSMutableString string]; - NSMutableString *typesString = [NSMutableString string]; - [set addObjectsFromArray: types]; - en = [set objectEnumerator]; + en = [types objectEnumerator]; // build the string.. while((type = [en nextObject]) != nil) { - [filterString appendFormat:@"%@ (*.%@),", [dc displayNameForType: type], - type]; - [typesString appendFormat: @"*.%@;",type]; + + [filterString appendFormat:@"%@ (*.%@)address@hidden", [dc displayNameForType: type], + type, type]; } - [filterString replaceCharactersInRange:NSMakeRange([filterString length]-1,1) - withString:@"+"]; - [filterString appendString:typesString]; - [filterString replaceCharactersInRange:NSMakeRange([filterString length]-1,1) - withString:@"+"]; // Add the nulls... unichar *fs = (unichar *)[filterString cStringUsingEncoding: @@ -464,28 +456,38 @@ types: (NSArray *)fileTypes relativeToWindow: (NSWindow*)window { + NSUInteger i, j; BOOL flag = YES; int result = NSOKButton; NSDocumentController *dc = [NSDocumentController sharedDocumentController]; - NSArray *extensionsForDefaultType = [dc fileExtensionsFromType: [dc defaultType]]; - NSMutableSet *typeset = [NSMutableSet set]; - NSArray *types = nil; + Class doc = [dc documentClassForType: [fileTypes objectAtIndex: 0]]; + NSArray *types = nil, *names, *exts; + NSMutableArray *tps= [NSMutableArray array]; - [typeset addObjectsFromArray: fileTypes]; - types = [typeset allObjects]; + // Get all writable types, not only the current type. For the case when + // the user wants change the format of the file + names = [doc writableTypes]; + for (i = 0; i < [names count]; i++) + { + exts = [dc fileExtensionsFromType: [names objectAtIndex: i]]; + + for (j = 0; j < [exts count]; j++) + { + if (![tps containsObject: [exts objectAtIndex: j]]) + { + [tps addObject: [exts objectAtIndex: j]]; + } + } + } + types = [NSArray arrayWithArray: tps]; + ofn.hwndOwner = (HWND)[window windowNumber]; ofn.lpstrFilter = (unichar *)filter_string_from_types(types); - ofn.nFilterIndex = 0; - if ([extensionsForDefaultType count] > 0) - { - NSUInteger defaultIndex = [types indexOfObject: [extensionsForDefaultType objectAtIndex: 0]]; - if (defaultIndex != NSNotFound) - { - ofn.nFilterIndex = defaultIndex + 1; - } - } + // Select the current type + ofn.nFilterIndex = [types indexOfObject: [fileTypes objectAtIndex: 0]]; + ofn.lpstrTitle = (unichar *)[[self title] cStringUsingEncoding: NSUnicodeStringEncoding]; if ([name length]) { NSString *file = [name lastPathComponent];