update ooo310-m15
[ooovba.git] / fpicker / source / aqua / AquaFilePickerDelegate.mm
blob7a557495191b9c281451a9ebb0ea1d5b41f499f6
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  * 
5  * Copyright 2008 by Sun Microsystems, Inc.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * $RCSfile: AquaFilePickerDelegate.mm,v $
10  * $Revision: 1.3 $
11  *
12  * This file is part of OpenOffice.org.
13  *
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.
17  *
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).
23  *
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.
28  *
29  ************************************************************************/
31 #ifndef _SALAQUAFILEPICKER_HXX_
32 #include "SalAquaFilePicker.hxx"
33 #endif
35 #ifndef _FILTERHELPER_HXX_
36 #include "FilterHelper.hxx"
37 #endif
39 #include "AquaFilePickerDelegate.hxx"
41 @implementation AquaFilePickerDelegate
43 - (id)initWithFilePicker:(SalAquaFilePicker*)fPicker
45     if ((self = [super init])) {
46         filePicker = fPicker;
47         filterHelper = NULL;
48         return self;
49     }
50     return nil;
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 )
63         return true;
64     if( filename == nil )
65         return false;
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);
74     }
77 - (void)panel:(id)sender directoryDidChange:(NSString *)path
79     if (filePicker != NULL) {
80         ::com::sun::star::ui::dialogs::FilePickerEvent evt;
81         filePicker->directoryChanged(evt);
82     }
86 #pragma mark UIActions
87 - (void)filterSelectedAtIndex:(id)sender
89     if (sender == nil) {
90         return;
91     }
92     
93     if ([sender class] != [NSPopUpButton class]) {
94         return;
95     }
96     
97     if (filterHelper == NULL) {
98         return;
99     }
100     
101     NSPopUpButton *popup = (NSPopUpButton*)sender;
102     unsigned int selectedIndex = [popup indexOfSelectedItem];
103     
104     filterHelper->SetFilterAtIndex(selectedIndex);
105     
106     filePicker->filterControlChanged();
110 @end