1 /*************************************************************************
9 * The Contents of this file are made available subject to the terms of
10 * either of the following licenses
12 * - GNU Lesser General Public License Version 2.1
13 * - Sun Industry Standards Source License Version 1.1
15 * Sun Microsystems Inc., October, 2000
17 * GNU Lesser General Public License Version 2.1
18 * =============================================
19 * Copyright 2000 by Sun Microsystems, Inc.
20 * 901 San Antonio Road, Palo Alto, CA 94303, USA
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License version 2.1, as published by the Free Software Foundation.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 * Sun Industry Standards Source License Version 1.1
38 * =================================================
39 * The contents of this file are subject to the Sun Industry Standards
40 * Source License Version 1.1 (the "License"); You may not use this file
41 * except in compliance with the License. You may obtain a copy of the
42 * License at http://www.openoffice.org/license.html.
44 * Software provided under this License is provided on an "AS IS" basis,
45 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
46 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
47 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
48 * See the License for the specific provisions governing your rights and
49 * obligations concerning the Software.
51 * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
53 * Copyright: 2000 by Sun Microsystems, Inc.
55 * All Rights Reserved.
57 * Contributor(s): Jan Holesovsky <kendy@openoffice.org>
60 ************************************************************************/
64 #include <cppuhelper/compbase8.hxx>
66 #include <com/sun/star/lang/XInitialization.hpp>
67 #include <com/sun/star/lang/XServiceInfo.hpp>
68 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
69 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
70 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
71 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
72 //#include <com/sun/star/ui/dialogs/XFilePreview.hpp>
73 #include <com/sun/star/util/XCancellable.hpp>
75 #include <osl/conditn.hxx>
76 #include <osl/mutex.hxx>
78 #include <rtl/ustrbuf.hxx>
89 class KDE4FilePicker
:
90 public cppu::WeakComponentImplHelper8
<
91 ::com::sun::star::ui::dialogs::XFilterManager
,
92 ::com::sun::star::ui::dialogs::XFilterGroupManager
,
93 ::com::sun::star::ui::dialogs::XFilePickerControlAccess
,
94 ::com::sun::star::ui::dialogs::XFilePickerNotifier
,
95 // TODO ::com::sun::star::ui::dialogs::XFilePreview,
96 ::com::sun::star::lang::XInitialization
,
97 ::com::sun::star::util::XCancellable
,
98 ::com::sun::star::lang::XEventListener
,
99 ::com::sun::star::lang::XServiceInfo
>
102 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceMgr
; // to instanciate own services
104 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
> m_xListener
;
108 //the dialog to display
109 KFileDialog
* _dialog
;
111 osl::Mutex _helperMutex
;
113 //running filter string to add to dialog
116 //filter for reverse lookup of filter text
117 QHash
<QString
, QString
> _filters
;
119 //mapping of SAL control ID's to created custom controls
120 QHash
<sal_Int16
, QWidget
*> _customWidgets
;
122 //widget to contain extra custom controls
123 QWidget
* _extraControls
;
125 //layout for extra custom controls
129 KDE4FilePicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceMgr
);
130 virtual ~KDE4FilePicker();
132 // XFilePickerNotifier
134 virtual void SAL_CALL
addFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
) throw( ::com::sun::star::uno::RuntimeException
);
135 virtual void SAL_CALL
removeFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
) throw( ::com::sun::star::uno::RuntimeException
);
137 // XExecutableDialog functions
139 virtual void SAL_CALL
setTitle( const ::rtl::OUString
&rTitle
) throw( ::com::sun::star::uno::RuntimeException
);
140 virtual sal_Int16 SAL_CALL
execute() throw( ::com::sun::star::uno::RuntimeException
);
142 // XFilePicker functions
144 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
) throw( ::com::sun::star::uno::RuntimeException
);
145 virtual void SAL_CALL
setDefaultName( const ::rtl::OUString
&rName
) throw( ::com::sun::star::uno::RuntimeException
);
146 virtual void SAL_CALL
setDisplayDirectory( const ::rtl::OUString
&rDirectory
) throw( ::com::sun::star::uno::RuntimeException
);
147 virtual ::rtl::OUString SAL_CALL
getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException
);
148 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getFiles() throw( ::com::sun::star::uno::RuntimeException
);
150 // XFilterManager functions
152 virtual void SAL_CALL
appendFilter( const ::rtl::OUString
&rTitle
, const ::rtl::OUString
&rFilter
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
153 virtual void SAL_CALL
setCurrentFilter( const ::rtl::OUString
&rTitle
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
154 virtual ::rtl::OUString SAL_CALL
getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException
);
156 // XFilterGroupManager functions
158 virtual void SAL_CALL
appendFilterGroup( const ::rtl::OUString
&rGroupTitle
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::StringPair
> &rFilters
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
160 // XFilePickerControlAccess functions
162 virtual void SAL_CALL
setValue( sal_Int16 nControlId
, sal_Int16 nControlAction
, const ::com::sun::star::uno::Any
&rValue
) throw (::com::sun::star::uno::RuntimeException
);
163 virtual ::com::sun::star::uno::Any SAL_CALL
getValue( sal_Int16 nControlId
, sal_Int16 nControlAction
) throw (::com::sun::star::uno::RuntimeException
);
164 virtual void SAL_CALL
enableControl( sal_Int16 nControlId
, sal_Bool bEnable
) throw( ::com::sun::star::uno::RuntimeException
);
165 virtual void SAL_CALL
setLabel( sal_Int16 nControlId
, const ::rtl::OUString
&rLabel
) throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::rtl::OUString SAL_CALL
getLabel( sal_Int16 nControlId
) throw (::com::sun::star::uno::RuntimeException
);
170 virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException);
171 virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException);
172 virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException);
173 virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException);
174 virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any &rImage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
175 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException);
176 virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException);
181 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> &rArguments
) throw( ::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
185 virtual void SAL_CALL
cancel( ) throw( ::com::sun::star::uno::RuntimeException
);
189 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
&rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
193 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
);
194 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
&rServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
195 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException
);
198 // prevent copy and assignment
199 KDE4FilePicker( const KDE4FilePicker
& );
200 KDE4FilePicker
& operator=( const KDE4FilePicker
& );
202 //add a custom control widget to the file dialog
203 void addCustomControl(sal_Int16 controlId
);