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 ************************************************************************/
62 #ifndef _UNXFILEPICKER_HXX_
63 #define _UNXFILEPICKER_HXX_
65 #ifndef _CPPUHELPER_COMPBASE8_HXX_
66 #include <cppuhelper/compbase8.hxx>
69 #ifndef _OSL_CONDITN_HXX_
70 #include <osl/conditn.hxx>
73 #ifndef _OSL_MUTEX_HXX_
74 #include <osl/mutex.hxx>
77 #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
78 #include <com/sun/star/lang/XInitialization.hpp>
81 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
82 #include <com/sun/star/lang/XServiceInfo.hpp>
85 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERNOTIFIER_HPP_
86 #include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp>
89 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILTERMANAGER_HPP_
90 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
93 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILTERGROUPMANAGER_HPP_
94 #include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp>
97 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPICKERCONTROLACCESS_HPP_
98 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
101 #ifndef _COM_SUN_STAR_UI_DIALOGS_XFILEPREVIEW_HPP_
102 #include <com/sun/star/ui/dialogs/XFilePreview.hpp>
105 #ifndef _COM_SUN_STAR_UTIL_XCANCELLABLE_HPP_
106 #include <com/sun/star/util/XCancellable.hpp>
109 #ifndef _RTL_USTRBUF_HXX_
110 #include <rtl/ustrbuf.hxx>
115 class UnxFilePickerCommandThread
;
116 class UnxFilePickerNotifyThread
;
119 class UnxFilePickerDummy
123 osl::Mutex m_rbHelperMtx
;
126 class UnxFilePicker
:
127 public UnxFilePickerDummy
,
128 public cppu::WeakComponentImplHelper8
<
129 ::com::sun::star::ui::dialogs::XFilterManager
,
130 ::com::sun::star::ui::dialogs::XFilterGroupManager
,
131 ::com::sun::star::ui::dialogs::XFilePickerControlAccess
,
132 ::com::sun::star::ui::dialogs::XFilePickerNotifier
,
133 // TODO ::com::sun::star::ui::dialogs::XFilePreview,
134 ::com::sun::star::lang::XInitialization
,
135 ::com::sun::star::util::XCancellable
,
136 ::com::sun::star::lang::XEventListener
,
137 ::com::sun::star::lang::XServiceInfo
>
140 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceMgr
; // to instanciate own services
142 pid_t m_nFilePickerPid
;
143 int m_nFilePickerWrite
; // (kde|...)filepicker gets it as stdin
144 int m_nFilePickerRead
; // (kde|...)filepicker gets it as stdout
146 UnxFilePickerNotifyThread
*m_pNotifyThread
;
147 UnxFilePickerCommandThread
*m_pCommandThread
;
152 UnxFilePicker( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& xServiceMgr
);
153 virtual ~UnxFilePicker();
155 // XFilePickerNotifier
157 virtual void SAL_CALL
addFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
) throw( ::com::sun::star::uno::RuntimeException
);
158 virtual void SAL_CALL
removeFilePickerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::ui::dialogs::XFilePickerListener
>& xListener
) throw( ::com::sun::star::uno::RuntimeException
);
160 // XExecutableDialog functions
162 virtual void SAL_CALL
setTitle( const ::rtl::OUString
&rTitle
) throw( ::com::sun::star::uno::RuntimeException
);
163 virtual sal_Int16 SAL_CALL
execute() throw( ::com::sun::star::uno::RuntimeException
);
165 // XFilePicker functions
167 virtual void SAL_CALL
setMultiSelectionMode( sal_Bool bMode
) throw( ::com::sun::star::uno::RuntimeException
);
168 virtual void SAL_CALL
setDefaultName( const ::rtl::OUString
&rName
) throw( ::com::sun::star::uno::RuntimeException
);
169 virtual void SAL_CALL
setDisplayDirectory( const ::rtl::OUString
&rDirectory
) throw( ::com::sun::star::uno::RuntimeException
);
170 virtual ::rtl::OUString SAL_CALL
getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException
);
171 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getFiles() throw( ::com::sun::star::uno::RuntimeException
);
173 // XFilterManager functions
175 virtual void SAL_CALL
appendFilter( const ::rtl::OUString
&rTitle
, const ::rtl::OUString
&rFilter
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
176 virtual void SAL_CALL
setCurrentFilter( const ::rtl::OUString
&rTitle
) throw( ::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
177 virtual ::rtl::OUString SAL_CALL
getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException
);
179 // XFilterGroupManager functions
181 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
);
183 // XFilePickerControlAccess functions
185 virtual void SAL_CALL
setValue( sal_Int16 nControlId
, sal_Int16 nControlAction
, const ::com::sun::star::uno::Any
&rValue
) throw (::com::sun::star::uno::RuntimeException
);
186 virtual ::com::sun::star::uno::Any SAL_CALL
getValue( sal_Int16 nControlId
, sal_Int16 nControlAction
) throw (::com::sun::star::uno::RuntimeException
);
187 virtual void SAL_CALL
enableControl( sal_Int16 nControlId
, sal_Bool bEnable
) throw( ::com::sun::star::uno::RuntimeException
);
188 virtual void SAL_CALL
setLabel( sal_Int16 nControlId
, const ::rtl::OUString
&rLabel
) throw (::com::sun::star::uno::RuntimeException
);
189 virtual ::rtl::OUString SAL_CALL
getLabel( sal_Int16 nControlId
) throw (::com::sun::star::uno::RuntimeException
);
193 virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException);
194 virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException);
195 virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException);
196 virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException);
197 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);
198 virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException);
199 virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException);
204 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
);
208 virtual void SAL_CALL
cancel( ) throw( ::com::sun::star::uno::RuntimeException
);
212 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
&rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
216 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw( ::com::sun::star::uno::RuntimeException
);
217 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
&rServiceName
) throw( ::com::sun::star::uno::RuntimeException
);
218 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException
);
221 // prevent copy and assignment
222 UnxFilePicker( const UnxFilePicker
& );
223 UnxFilePicker
& operator=( const UnxFilePicker
& );
226 void initFilePicker();
227 void checkFilePicker() throw( ::com::sun::star::uno::RuntimeException
);
230 void sendCommand( const ::rtl::OUString
&rCommand
);
231 // Synchronized sendCommand
232 void sendCommand( const ::rtl::OUString
&rCommand
, ::osl::Condition
&rCondition
);
233 void appendEscaped( ::rtl::OUStringBuffer
&rBuffer
, const ::rtl::OUString
&rString
);
236 sal_Bool
controlIdInfo( sal_Int16 nControlId
, ::rtl::OUString
&rType
, sal_Int32
&rTitleId
);
237 sal_Bool
controlActionInfo( sal_Int16 nControlId
, ::rtl::OUString
&rType
);
238 void sendAppendControlCommand( sal_Int16 nControlId
);
241 #endif // _UNXFILEPICKER_HXX_