1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> 24#include <com/sun/star/uno/Any.hxx> 25 26#ifndef _SALAQUAFILEPICKER_HXX_ 27#include "SalAquaFilePicker.hxx" 28#endif 29 30#ifndef _FILTERHELPER_HXX_ 31#include "FilterHelper.hxx" 32#endif 33 34#include "AquaFilePickerDelegate.hxx" 35 36@implementation AquaFilePickerDelegate 37 38- (id)initWithFilePicker:(SalAquaFilePicker*)fPicker 39{ 40 if ((self = [super init])) { 41 filePicker = fPicker; 42 filterHelper = NULL; 43 return self; 44 } 45 return nil; 46} 47 48- (void)setFilterHelper:(FilterHelper*)helper 49{ 50 filterHelper = helper; 51} 52 53#pragma mark NSSavePanel delegate methods 54 55- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename 56{ 57 if( filterHelper == NULL ) 58 return true; 59 if( filename == nil ) 60 return false; 61 return filterHelper->filenameMatchesFilter(filename); 62} 63 64- (void)panelSelectionDidChange:(id)sender 65{ 66 if (filePicker != NULL) { 67 ::com::sun::star::ui::dialogs::FilePickerEvent evt; 68 filePicker->fileSelectionChanged(evt); 69 } 70} 71 72- (void)panel:(id)sender directoryDidChange:(NSString *)path 73{ 74 if (filePicker != NULL) { 75 ::com::sun::star::ui::dialogs::FilePickerEvent evt; 76 filePicker->directoryChanged(evt); 77 } 78} 79 80 81#pragma mark UIActions 82- (void)filterSelectedAtIndex:(id)sender 83{ 84 if (sender == nil) { 85 return; 86 } 87 88 if ([sender class] != [NSPopUpButton class]) { 89 return; 90 } 91 92 if (filterHelper == NULL) { 93 return; 94 } 95 96 NSPopUpButton *popup = (NSPopUpButton*)sender; 97 unsigned int selectedIndex = [popup indexOfSelectedItem]; 98 99 filterHelper->SetFilterAtIndex(selectedIndex); 100 101 filePicker->filterControlChanged(); 102} 103 104- (void)autoextensionChanged:(id)sender 105{ 106 if (sender == nil) { 107 return; 108 } 109 110 if ([sender class] != [NSButton class]) { 111 return; 112 } 113 uno::Any aValue; 114 aValue <<= ([((NSButton*)sender) state] == NSOnState); 115 116 filePicker->setValue(::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue); 117} 118 119@end 120