1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AquaFilePickerDelegate.mm,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SALAQUAFILEPICKER_HXX_
32 #include "SalAquaFilePicker.hxx"
35 #ifndef _FILTERHELPER_HXX_
36 #include "FilterHelper.hxx"
39 #include "AquaFilePickerDelegate.hxx"
41 @implementation AquaFilePickerDelegate
43 - (id)initWithFilePicker:(SalAquaFilePicker*)fPicker
45 if ((self = [super init])) {
53 - (void)setFilterHelper:(FilterHelper*)helper
55 filterHelper = helper;
58 #pragma mark NSSavePanel delegate methods
60 - (MacOSBOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
62 if( filterHelper == NULL )
66 return filterHelper->filenameMatchesFilter(filename);
69 - (void)panelSelectionDidChange:(id)sender
71 if (filePicker != NULL) {
72 ::com::sun::star::ui::dialogs::FilePickerEvent evt;
73 filePicker->fileSelectionChanged(evt);
77 - (void)panel:(id)sender directoryDidChange:(NSString *)path
79 if (filePicker != NULL) {
80 ::com::sun::star::ui::dialogs::FilePickerEvent evt;
81 filePicker->directoryChanged(evt);
86 #pragma mark UIActions
87 - (void)filterSelectedAtIndex:(id)sender
93 if ([sender class] != [NSPopUpButton class]) {
97 if (filterHelper == NULL) {
101 NSPopUpButton *popup = (NSPopUpButton*)sender;
102 unsigned int selectedIndex = [popup indexOfSelectedItem];
104 filterHelper->SetFilterAtIndex(selectedIndex);
106 filePicker->filterControlChanged();