1b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b557fc96SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b557fc96SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b557fc96SAndrew Rist  * distributed with this work for additional information
6b557fc96SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b557fc96SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b557fc96SAndrew Rist  * "License"); you may not use this file except in compliance
9b557fc96SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b557fc96SAndrew Rist  *
11b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b557fc96SAndrew Rist  *
13b557fc96SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b557fc96SAndrew Rist  * software distributed under the License is distributed on an
15b557fc96SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b557fc96SAndrew Rist  * KIND, either express or implied.  See the License for the
17b557fc96SAndrew Rist  * specific language governing permissions and limitations
18b557fc96SAndrew Rist  * under the License.
19b557fc96SAndrew Rist  *
20b557fc96SAndrew Rist  *************************************************************/
21b557fc96SAndrew Rist 
22b557fc96SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_fpicker.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //------------------------------------------------------------------------
28cdf0e10cSrcweir // includes
29cdf0e10cSrcweir //------------------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <tchar.h>
32cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
33cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
34cdf0e10cSrcweir #include <osl/diagnose.h>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #ifndef _FILEPICKER_HXX_
37cdf0e10cSrcweir #include "filepicker.hxx"
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include "WinFileOpenImpl.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "FPServiceInfo.hxx"
42cdf0e10cSrcweir #include "..\misc\WinImplHelper.hxx"
43cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
44cdf0e10cSrcweir #include "filepickereventnotification.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <comphelper/sequenceasvector.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //------------------------------------------------------------------------
49cdf0e10cSrcweir // namespace directives
50cdf0e10cSrcweir //------------------------------------------------------------------------
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace com::sun::star;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs;
55cdf0e10cSrcweir using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //------------------------------------------------------------------------
58cdf0e10cSrcweir // defines
59cdf0e10cSrcweir //------------------------------------------------------------------------
60cdf0e10cSrcweir 
61cdf0e10cSrcweir #define FILE_PICKER_DLL_NAME  TEXT("fps.dll")
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //------------------------------------------------------------------------
64cdf0e10cSrcweir // helper functions
65cdf0e10cSrcweir //------------------------------------------------------------------------
66cdf0e10cSrcweir 
67cdf0e10cSrcweir namespace
68cdf0e10cSrcweir {
69*07a3d7f1SPedro Giffuni     // controlling event notifications
70cdf0e10cSrcweir     const bool STARTUP_SUSPENDED = true;
71cdf0e10cSrcweir     const bool STARTUP_ALIVE     = false;
72cdf0e10cSrcweir 
FilePicker_getSupportedServiceNames()73cdf0e10cSrcweir 	uno::Sequence<rtl::OUString> SAL_CALL FilePicker_getSupportedServiceNames()
74cdf0e10cSrcweir 	{
75cdf0e10cSrcweir 		uno::Sequence<rtl::OUString> aRet(2);
76cdf0e10cSrcweir         aRet[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker");
77cdf0e10cSrcweir 		aRet[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker");
78cdf0e10cSrcweir 		return aRet;
79cdf0e10cSrcweir 	}
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
83cdf0e10cSrcweir //
84cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
85cdf0e10cSrcweir 
CFilePicker(const uno::Reference<lang::XMultiServiceFactory> & xServiceMgr)86cdf0e10cSrcweir CFilePicker::CFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) :
87cdf0e10cSrcweir 	cppu::WeakComponentImplHelper10<
88cdf0e10cSrcweir 		XFilterManager,
89cdf0e10cSrcweir         XFilterGroupManager,
90cdf0e10cSrcweir         XFilePickerControlAccess,
91cdf0e10cSrcweir 		XFilePickerNotifier,
92cdf0e10cSrcweir         XFilePreview,
93cdf0e10cSrcweir         XFilePicker2,
94cdf0e10cSrcweir 		lang::XInitialization,
95cdf0e10cSrcweir 		util::XCancellable,
96cdf0e10cSrcweir 		lang::XEventListener,
97cdf0e10cSrcweir 		lang::XServiceInfo>(m_rbHelperMtx),
98cdf0e10cSrcweir 		m_xServiceMgr(xServiceMgr),
99cdf0e10cSrcweir 		m_aAsyncEventNotifier(rBHelper)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     HINSTANCE hInstance = GetModuleHandle(FILE_PICKER_DLL_NAME);
102cdf0e10cSrcweir 	OSL_POSTCOND( hInstance, "The name of the service dll must have changed" );
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	// create a default FileOpen dialog without any additional ui elements
105cdf0e10cSrcweir 	m_pImpl = std::auto_ptr< CWinFileOpenImpl >(
106cdf0e10cSrcweir         new CWinFileOpenImpl(
107cdf0e10cSrcweir             this,
108cdf0e10cSrcweir             true,
109cdf0e10cSrcweir 			0,
110cdf0e10cSrcweir 			0,
111cdf0e10cSrcweir 			hInstance ) );
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //------------------------------------------------------------------------------------
115cdf0e10cSrcweir // XFPEventListenerManager
116cdf0e10cSrcweir //------------------------------------------------------------------------------------
117cdf0e10cSrcweir 
addFilePickerListener(const uno::Reference<XFilePickerListener> & xListener)118cdf0e10cSrcweir void SAL_CALL CFilePicker::addFilePickerListener(const uno::Reference<XFilePickerListener>& xListener)
119cdf0e10cSrcweir 	throw(uno::RuntimeException)
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	if ( rBHelper.bDisposed )
122cdf0e10cSrcweir 		throw lang::DisposedException(
123cdf0e10cSrcweir 			rtl::OUString::createFromAscii( "object is already disposed" ),
124cdf0e10cSrcweir 			static_cast< XFilePicker2* >( this ) );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	if ( !rBHelper.bInDispose && !rBHelper.bDisposed )
127cdf0e10cSrcweir 		rBHelper.aLC.addInterface( getCppuType( &xListener ), xListener );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
131cdf0e10cSrcweir //
132cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
133cdf0e10cSrcweir 
removeFilePickerListener(const uno::Reference<XFilePickerListener> & xListener)134cdf0e10cSrcweir void SAL_CALL CFilePicker::removeFilePickerListener(const uno::Reference<XFilePickerListener>& xListener )
135cdf0e10cSrcweir 	throw(uno::RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	if ( rBHelper.bDisposed )
138cdf0e10cSrcweir 		throw lang::DisposedException(
139cdf0e10cSrcweir 			rtl::OUString::createFromAscii( "object is already disposed" ),
140cdf0e10cSrcweir 			static_cast< XFilePicker2* >( this ) );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	rBHelper.aLC.removeInterface( getCppuType( &xListener ), xListener );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // -------------------------------------------------
146cdf0e10cSrcweir // XEventListener
147cdf0e10cSrcweir // -------------------------------------------------
148cdf0e10cSrcweir 
disposing(const lang::EventObject & aEvent)149cdf0e10cSrcweir void SAL_CALL CFilePicker::disposing(const lang::EventObject& aEvent) throw(uno::RuntimeException)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir 	uno::Reference<XFilePickerListener> xFilePickerListener(aEvent.Source, ::com::sun::star::uno::UNO_QUERY);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	if (xFilePickerListener.is())
154cdf0e10cSrcweir 		removeFilePickerListener(xFilePickerListener);
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
158cdf0e10cSrcweir //
159cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
160cdf0e10cSrcweir 
fileSelectionChanged(FilePickerEvent aEvent)161cdf0e10cSrcweir void SAL_CALL CFilePicker::fileSelectionChanged(FilePickerEvent aEvent)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir 	aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this));
164cdf0e10cSrcweir 	m_aAsyncEventNotifier.notifyEvent(
165cdf0e10cSrcweir 		new CFilePickerParamEventNotification(&XFilePickerListener::fileSelectionChanged,aEvent));
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
169cdf0e10cSrcweir //
170cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
171cdf0e10cSrcweir 
directoryChanged(FilePickerEvent aEvent)172cdf0e10cSrcweir void SAL_CALL CFilePicker::directoryChanged(FilePickerEvent aEvent)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this));
175cdf0e10cSrcweir 	m_aAsyncEventNotifier.notifyEvent(
176cdf0e10cSrcweir 		new CFilePickerParamEventNotification(&XFilePickerListener::directoryChanged,aEvent));
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
180cdf0e10cSrcweir //
181cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
182cdf0e10cSrcweir 
controlStateChanged(FilePickerEvent aEvent)183cdf0e10cSrcweir void SAL_CALL CFilePicker::controlStateChanged(FilePickerEvent aEvent)
184cdf0e10cSrcweir {
185cdf0e10cSrcweir 	aEvent.Source = uno::Reference<uno::XInterface>(static_cast<XFilePickerNotifier*>(this));
186cdf0e10cSrcweir 	m_aAsyncEventNotifier.notifyEvent(
187cdf0e10cSrcweir 		new CFilePickerParamEventNotification(&XFilePickerListener::controlStateChanged,aEvent));
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
191cdf0e10cSrcweir //
192cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
193cdf0e10cSrcweir 
dialogSizeChanged()194cdf0e10cSrcweir void SAL_CALL CFilePicker::dialogSizeChanged()
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	m_aAsyncEventNotifier.notifyEvent(
197cdf0e10cSrcweir 		new CFilePickerEventNotification(&XFilePickerListener::dialogSizeChanged));
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
201cdf0e10cSrcweir // If there are more then one listener the return value of the last one wins
202cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
203cdf0e10cSrcweir 
helpRequested(FilePickerEvent aEvent) const204cdf0e10cSrcweir rtl::OUString SAL_CALL CFilePicker::helpRequested(FilePickerEvent aEvent) const
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     rtl::OUString aHelpText;
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	::cppu::OInterfaceContainerHelper* pICHelper =
209cdf0e10cSrcweir 		rBHelper.getContainer( getCppuType((uno::Reference<XFilePickerListener>*)0));
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	if (pICHelper)
212cdf0e10cSrcweir 	{
213cdf0e10cSrcweir 		::cppu::OInterfaceIteratorHelper iter(*pICHelper);
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 		while(iter.hasMoreElements())
216cdf0e10cSrcweir 		{
217cdf0e10cSrcweir 			try
218cdf0e10cSrcweir 			{
219cdf0e10cSrcweir 				/*
220cdf0e10cSrcweir                   if there are multiple listeners responding
221cdf0e10cSrcweir                   to this notification the next response
222cdf0e10cSrcweir                   overwrittes  the one before if it is not empty
223cdf0e10cSrcweir                 */
224cdf0e10cSrcweir 
225cdf0e10cSrcweir                 rtl::OUString temp;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 				uno::Reference<XFilePickerListener> xFPListener(iter.next(), uno::UNO_QUERY);
228cdf0e10cSrcweir 				if (xFPListener.is())
229cdf0e10cSrcweir                 {
230cdf0e10cSrcweir 					temp = xFPListener->helpRequested(aEvent);
231cdf0e10cSrcweir                     if (temp.getLength())
232cdf0e10cSrcweir 						aHelpText = temp;
233cdf0e10cSrcweir                 }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 			}
236cdf0e10cSrcweir 			catch(uno::RuntimeException&)
237cdf0e10cSrcweir 			{
238cdf0e10cSrcweir 				OSL_ENSURE( false, "RuntimeException during event dispatching" );
239cdf0e10cSrcweir 			}
240cdf0e10cSrcweir 		}
241cdf0e10cSrcweir 	}
242cdf0e10cSrcweir 
243cdf0e10cSrcweir     return aHelpText;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir //-------------------------------------
247cdf0e10cSrcweir //
248cdf0e10cSrcweir //-------------------------------------
249cdf0e10cSrcweir 
startupEventNotification(bool bStartupSuspended)250cdf0e10cSrcweir bool CFilePicker::startupEventNotification(bool bStartupSuspended)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir     return m_aAsyncEventNotifier.startup(bStartupSuspended);
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //-------------------------------------
256cdf0e10cSrcweir //
257cdf0e10cSrcweir //-------------------------------------
258cdf0e10cSrcweir 
shutdownEventNotification()259cdf0e10cSrcweir void CFilePicker::shutdownEventNotification()
260cdf0e10cSrcweir {
261cdf0e10cSrcweir     m_aAsyncEventNotifier.shutdown();
262cdf0e10cSrcweir }
263cdf0e10cSrcweir 
264cdf0e10cSrcweir //-------------------------------------
265cdf0e10cSrcweir //
266cdf0e10cSrcweir //-------------------------------------
267cdf0e10cSrcweir 
suspendEventNotification()268cdf0e10cSrcweir void CFilePicker::suspendEventNotification()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     m_aAsyncEventNotifier.suspend();
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir //-------------------------------------
274cdf0e10cSrcweir //
275cdf0e10cSrcweir //-------------------------------------
276cdf0e10cSrcweir 
resumeEventNotification()277cdf0e10cSrcweir void CFilePicker::resumeEventNotification()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir     m_aAsyncEventNotifier.resume();
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir //------------------------------------------------------------------------------------
283cdf0e10cSrcweir // XFilePicker functions
284cdf0e10cSrcweir //------------------------------------------------------------------------------------
285cdf0e10cSrcweir 
setMultiSelectionMode(sal_Bool bMode)286cdf0e10cSrcweir void SAL_CALL CFilePicker::setMultiSelectionMode(sal_Bool bMode) throw(uno::RuntimeException)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
289cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
290cdf0e10cSrcweir 	m_pImpl->setMultiSelectionMode(bMode);
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
293cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
294cdf0e10cSrcweir //
295cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
296cdf0e10cSrcweir 
setTitle(const rtl::OUString & aTitle)297cdf0e10cSrcweir void SAL_CALL CFilePicker::setTitle(const rtl::OUString& aTitle) throw(uno::RuntimeException)
298cdf0e10cSrcweir {
299cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
300cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
301cdf0e10cSrcweir 	m_pImpl->setTitle(aTitle);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
305cdf0e10cSrcweir //
306cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
307cdf0e10cSrcweir 
appendFilter(const rtl::OUString & aTitle,const rtl::OUString & aFilter)308cdf0e10cSrcweir void SAL_CALL CFilePicker::appendFilter(const rtl::OUString& aTitle, const rtl::OUString& aFilter)
309cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, uno::RuntimeException)
310cdf0e10cSrcweir {
311cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
312cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
313cdf0e10cSrcweir 	m_pImpl->appendFilter(aTitle, aFilter);
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
317cdf0e10cSrcweir //
318cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
319cdf0e10cSrcweir 
setCurrentFilter(const rtl::OUString & aTitle)320cdf0e10cSrcweir void SAL_CALL CFilePicker::setCurrentFilter(const rtl::OUString& aTitle)
321cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, uno::RuntimeException)
322cdf0e10cSrcweir {
323cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
324cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
325cdf0e10cSrcweir 	m_pImpl->setCurrentFilter(aTitle);
326cdf0e10cSrcweir }
327cdf0e10cSrcweir 
328cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
329cdf0e10cSrcweir //
330cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
331cdf0e10cSrcweir 
getCurrentFilter()332cdf0e10cSrcweir rtl::OUString SAL_CALL CFilePicker::getCurrentFilter() throw(uno::RuntimeException)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
335cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
336cdf0e10cSrcweir 	return m_pImpl->getCurrentFilter();
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
340cdf0e10cSrcweir //
341cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
342cdf0e10cSrcweir 
appendFilterGroup(const rtl::OUString & sGroupTitle,const uno::Sequence<beans::StringPair> & aFilters)343cdf0e10cSrcweir void SAL_CALL CFilePicker::appendFilterGroup(const rtl::OUString& sGroupTitle, const uno::Sequence<beans::StringPair>& aFilters)
344cdf0e10cSrcweir 	throw (lang::IllegalArgumentException, uno::RuntimeException)
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
347cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
348cdf0e10cSrcweir 	m_pImpl->appendFilterGroup(sGroupTitle, aFilters);
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
352cdf0e10cSrcweir //
353cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
354cdf0e10cSrcweir 
setDefaultName(const rtl::OUString & aName)355cdf0e10cSrcweir void SAL_CALL CFilePicker::setDefaultName(const rtl::OUString& aName)
356cdf0e10cSrcweir 	throw(uno::RuntimeException)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
359cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
360cdf0e10cSrcweir 	m_pImpl->setDefaultName(aName);
361cdf0e10cSrcweir }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
364cdf0e10cSrcweir //
365cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
366cdf0e10cSrcweir 
setDisplayDirectory(const rtl::OUString & aDirectory)367cdf0e10cSrcweir void SAL_CALL CFilePicker::setDisplayDirectory(const rtl::OUString& aDirectory)
368cdf0e10cSrcweir 	throw(lang::IllegalArgumentException, uno::RuntimeException)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
371cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
372cdf0e10cSrcweir 	m_pImpl->setDisplayDirectory(aDirectory);
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
376cdf0e10cSrcweir //
377cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
378cdf0e10cSrcweir 
getDisplayDirectory()379cdf0e10cSrcweir rtl::OUString SAL_CALL CFilePicker::getDisplayDirectory() throw(uno::RuntimeException)
380cdf0e10cSrcweir {
381cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
382cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
383cdf0e10cSrcweir 	return m_pImpl->getDisplayDirectory();
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
387cdf0e10cSrcweir //
388cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
389cdf0e10cSrcweir 
getFiles()390cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL CFilePicker::getFiles() throw(uno::RuntimeException)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
393cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
394cdf0e10cSrcweir 	return m_pImpl->getFiles();
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
398cdf0e10cSrcweir //
399cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
getSelectedFiles()400cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL CFilePicker::getSelectedFiles() throw (uno::RuntimeException)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
403cdf0e10cSrcweir 	osl::MutexGuard aGuard(m_aMutex);
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	const uno::Sequence< ::rtl::OUString > lSource = m_pImpl->getFiles();
406cdf0e10cSrcweir     const ::sal_Int32                      c       = lSource.getLength();
407cdf0e10cSrcweir     if (c < 2)
408cdf0e10cSrcweir         return lSource;
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	const ::rtl::OUString                                   sPath  = lSource[0];
411cdf0e10cSrcweir           ::comphelper::SequenceAsVector< ::rtl::OUString > lTarget;
412cdf0e10cSrcweir           ::sal_Int32                                       i      = 1;
413cdf0e10cSrcweir     for (i=1; i<c; ++i)
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir         const ::rtl::OUString sFile = lSource[i];
416cdf0e10cSrcweir         if (sFile.indexOf ('/') > 0)
417cdf0e10cSrcweir         {
418cdf0e10cSrcweir             // a) file contains own path !
419cdf0e10cSrcweir             lTarget.push_back(sFile);
420cdf0e10cSrcweir         }
421cdf0e10cSrcweir         else
422cdf0e10cSrcweir         {
423cdf0e10cSrcweir             // b) file is relative to given path
424cdf0e10cSrcweir             ::rtl::OUStringBuffer sFull(256);
425cdf0e10cSrcweir 
426cdf0e10cSrcweir             sFull.append     (sPath);
427cdf0e10cSrcweir             sFull.appendAscii("/"  );
428cdf0e10cSrcweir             sFull.append     (sFile);
429cdf0e10cSrcweir 
430cdf0e10cSrcweir             lTarget.push_back(sFull.makeStringAndClear());
431cdf0e10cSrcweir         }
432cdf0e10cSrcweir 	}
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     return lTarget.getAsConstList();
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
438cdf0e10cSrcweir //
439cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
440cdf0e10cSrcweir 
execute()441cdf0e10cSrcweir sal_Int16 SAL_CALL CFilePicker::execute() throw(uno::RuntimeException)
442cdf0e10cSrcweir {
443cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	sal_Int16 ret;
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 	if (startupEventNotification(STARTUP_SUSPENDED))
448cdf0e10cSrcweir 	{
449cdf0e10cSrcweir 		// we should not block in this call else
450cdf0e10cSrcweir 		// in the case of an event the client can't
451cdf0e10cSrcweir 		// call another function an we run into a
452cdf0e10cSrcweir 		// deadlock !!!!!
453cdf0e10cSrcweir 		ret = m_pImpl->execute( );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 		shutdownEventNotification();
456cdf0e10cSrcweir 	}
457cdf0e10cSrcweir 	else
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		OSL_ENSURE(sal_False, "Could not start event notifier thread!");
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 		throw uno::RuntimeException(
462cdf0e10cSrcweir 			rtl::OUString::createFromAscii("Error executing dialog"),
463cdf0e10cSrcweir 			static_cast<XFilePicker2*>(this));
464cdf0e10cSrcweir 	}
465cdf0e10cSrcweir 
466cdf0e10cSrcweir 	return ret;
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir //------------------------------------------------------------------------------------
470cdf0e10cSrcweir // XFilePicker functions
471cdf0e10cSrcweir //------------------------------------------------------------------------------------
472cdf0e10cSrcweir 
setValue(sal_Int16 aControlId,sal_Int16 aControlAction,const uno::Any & aValue)473cdf0e10cSrcweir void SAL_CALL CFilePicker::setValue(sal_Int16 aControlId, sal_Int16 aControlAction, const uno::Any& aValue)
474cdf0e10cSrcweir 	throw(uno::RuntimeException)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
477cdf0e10cSrcweir 
478cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
479cdf0e10cSrcweir 	m_pImpl->setValue(aControlId, aControlAction, aValue);
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
482cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
483cdf0e10cSrcweir //
484cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
485cdf0e10cSrcweir 
getValue(sal_Int16 aControlId,sal_Int16 aControlAction)486cdf0e10cSrcweir uno::Any SAL_CALL CFilePicker::getValue(sal_Int16 aControlId, sal_Int16 aControlAction)
487cdf0e10cSrcweir 	throw(uno::RuntimeException)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir 	OSL_ASSERT(0 != m_pImpl.get());
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
492cdf0e10cSrcweir 	return m_pImpl->getValue(aControlId, aControlAction);
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
495cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
496cdf0e10cSrcweir //
497cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
498cdf0e10cSrcweir 
enableControl(sal_Int16 aControlId,sal_Bool bEnable)499cdf0e10cSrcweir void SAL_CALL CFilePicker::enableControl(sal_Int16 aControlId, sal_Bool bEnable)
500cdf0e10cSrcweir throw(uno::RuntimeException)
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	OSL_ASSERT( 0 != m_pImpl.get( ) );
503cdf0e10cSrcweir 
504cdf0e10cSrcweir     osl::MutexGuard aGuard( m_aMutex );
505cdf0e10cSrcweir 	m_pImpl->enableControl( aControlId, bEnable );
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
509cdf0e10cSrcweir //
510cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
511cdf0e10cSrcweir 
setLabel(sal_Int16 aControlId,const::rtl::OUString & aLabel)512cdf0e10cSrcweir void SAL_CALL CFilePicker::setLabel(sal_Int16 aControlId, const ::rtl::OUString& aLabel)
513cdf0e10cSrcweir 	throw (uno::RuntimeException)
514cdf0e10cSrcweir {
515cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
516cdf0e10cSrcweir 
517cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
518cdf0e10cSrcweir     m_pImpl->setLabel(aControlId, aLabel);
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
521cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
522cdf0e10cSrcweir //
523cdf0e10cSrcweir //-----------------------------------------------------------------------------------------
524cdf0e10cSrcweir 
getLabel(sal_Int16 aControlId)525cdf0e10cSrcweir rtl::OUString SAL_CALL CFilePicker::getLabel(sal_Int16 aControlId)
526cdf0e10cSrcweir 	throw (uno::RuntimeException)
527cdf0e10cSrcweir {
528cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
531cdf0e10cSrcweir 	return m_pImpl->getLabel(aControlId);
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
534cdf0e10cSrcweir //------------------------------------------------------------------------------------
535cdf0e10cSrcweir //
536cdf0e10cSrcweir //------------------------------------------------------------------------------------
537cdf0e10cSrcweir 
getSupportedImageFormats()538cdf0e10cSrcweir uno::Sequence<sal_Int16> SAL_CALL CFilePicker::getSupportedImageFormats() throw (uno::RuntimeException)
539cdf0e10cSrcweir {
540cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
541cdf0e10cSrcweir 
542cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
543cdf0e10cSrcweir     return m_pImpl->getSupportedImageFormats();
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir //------------------------------------------------------------------------------------
547cdf0e10cSrcweir //
548cdf0e10cSrcweir //------------------------------------------------------------------------------------
549cdf0e10cSrcweir 
getTargetColorDepth()550cdf0e10cSrcweir sal_Int32 SAL_CALL CFilePicker::getTargetColorDepth() throw (uno::RuntimeException)
551cdf0e10cSrcweir {
552cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
553cdf0e10cSrcweir 
554cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
555cdf0e10cSrcweir     return m_pImpl->getTargetColorDepth();
556cdf0e10cSrcweir }
557cdf0e10cSrcweir 
558cdf0e10cSrcweir //------------------------------------------------------------------------------------
559cdf0e10cSrcweir //
560cdf0e10cSrcweir //------------------------------------------------------------------------------------
561cdf0e10cSrcweir 
getAvailableWidth()562cdf0e10cSrcweir sal_Int32 SAL_CALL CFilePicker::getAvailableWidth() throw (uno::RuntimeException)
563cdf0e10cSrcweir {
564cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
565cdf0e10cSrcweir 
566cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
567cdf0e10cSrcweir     return m_pImpl->getAvailableWidth();
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir //------------------------------------------------------------------------------------
571cdf0e10cSrcweir //
572cdf0e10cSrcweir //------------------------------------------------------------------------------------
573cdf0e10cSrcweir 
getAvailableHeight()574cdf0e10cSrcweir sal_Int32 SAL_CALL CFilePicker::getAvailableHeight() throw (uno::RuntimeException)
575cdf0e10cSrcweir {
576cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
577cdf0e10cSrcweir 
578cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
579cdf0e10cSrcweir     return m_pImpl->getAvailableHeight();
580cdf0e10cSrcweir }
581cdf0e10cSrcweir 
582cdf0e10cSrcweir //------------------------------------------------------------------------------------
583cdf0e10cSrcweir //
584cdf0e10cSrcweir //------------------------------------------------------------------------------------
585cdf0e10cSrcweir 
setImage(sal_Int16 aImageFormat,const uno::Any & aImage)586cdf0e10cSrcweir void SAL_CALL CFilePicker::setImage(sal_Int16 aImageFormat, const uno::Any& aImage)
587cdf0e10cSrcweir 	throw (lang::IllegalArgumentException, uno::RuntimeException)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
590cdf0e10cSrcweir 
591cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
592cdf0e10cSrcweir     m_pImpl->setImage(aImageFormat, aImage);
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir //------------------------------------------------------------------------------------
596cdf0e10cSrcweir //
597cdf0e10cSrcweir //------------------------------------------------------------------------------------
598cdf0e10cSrcweir 
setShowState(sal_Bool bShowState)599cdf0e10cSrcweir sal_Bool SAL_CALL CFilePicker::setShowState(sal_Bool bShowState) throw (uno::RuntimeException)
600cdf0e10cSrcweir {
601cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
602cdf0e10cSrcweir 
603cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
604cdf0e10cSrcweir     return m_pImpl->setShowState(bShowState);
605cdf0e10cSrcweir }
606cdf0e10cSrcweir 
607cdf0e10cSrcweir //------------------------------------------------------------------------------------
608cdf0e10cSrcweir //
609cdf0e10cSrcweir //------------------------------------------------------------------------------------
610cdf0e10cSrcweir 
getShowState()611cdf0e10cSrcweir sal_Bool SAL_CALL CFilePicker::getShowState() throw (uno::RuntimeException)
612cdf0e10cSrcweir {
613cdf0e10cSrcweir     OSL_ASSERT(0 != m_pImpl.get());
614cdf0e10cSrcweir 
615cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
616cdf0e10cSrcweir     return m_pImpl->getShowState();
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir //------------------------------------------------------------------------------------
620cdf0e10cSrcweir //
621cdf0e10cSrcweir //------------------------------------------------------------------------------------
622cdf0e10cSrcweir 
initialize(const uno::Sequence<uno::Any> & aArguments)623cdf0e10cSrcweir void SAL_CALL CFilePicker::initialize(const uno::Sequence<uno::Any>& aArguments)
624cdf0e10cSrcweir 	throw( uno::Exception, uno::RuntimeException)
625cdf0e10cSrcweir {
626cdf0e10cSrcweir 	// parameter checking
627cdf0e10cSrcweir 	uno::Any aAny;
628cdf0e10cSrcweir 	if ( 0 == aArguments.getLength( ) )
629cdf0e10cSrcweir 		throw lang::IllegalArgumentException(
630cdf0e10cSrcweir 			rtl::OUString::createFromAscii( "no arguments" ),
631cdf0e10cSrcweir 			static_cast<XFilePicker2*>(this), 1);
632cdf0e10cSrcweir 
633cdf0e10cSrcweir     aAny = aArguments[0];
634cdf0e10cSrcweir 
635cdf0e10cSrcweir     if ( (aAny.getValueType() != ::getCppuType((sal_Int16*)0)) &&
636cdf0e10cSrcweir          (aAny.getValueType() != ::getCppuType((sal_Int8*)0)) )
637cdf0e10cSrcweir 		 throw lang::IllegalArgumentException(
638cdf0e10cSrcweir             rtl::OUString::createFromAscii("invalid argument type"),
639cdf0e10cSrcweir             static_cast<XFilePicker2*>(this), 1);
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	sal_Int16 templateId = -1;
642cdf0e10cSrcweir 	aAny >>= templateId;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	sal_Bool   bFileOpenDialog  = sal_True;
645cdf0e10cSrcweir 	sal_uInt32 winResTemplateId = 0;
646cdf0e10cSrcweir 	sal_Bool   bIsWin2000       = IsWindows2000Platform();
647cdf0e10cSrcweir 
648cdf0e10cSrcweir     switch ( templateId )
649cdf0e10cSrcweir     {
650cdf0e10cSrcweir     case FILEOPEN_SIMPLE:
651cdf0e10cSrcweir         bFileOpenDialog = sal_True;
652cdf0e10cSrcweir         break;
653cdf0e10cSrcweir 
654cdf0e10cSrcweir     case FILESAVE_SIMPLE:
655cdf0e10cSrcweir         bFileOpenDialog = sal_False;
656cdf0e10cSrcweir         break;
657cdf0e10cSrcweir 
658cdf0e10cSrcweir     case FILESAVE_AUTOEXTENSION_PASSWORD:
659cdf0e10cSrcweir         bFileOpenDialog = sal_False;
660cdf0e10cSrcweir         if ( bIsWin2000 )
661cdf0e10cSrcweir             winResTemplateId = TMPL2000_FILESAVE_AUTOEXT_PASSWORD_BOX_ID;
662cdf0e10cSrcweir         else
663cdf0e10cSrcweir             winResTemplateId = TMPL95_FILESAVE_AUTOEXT_PASSWORD_BOX_ID;
664cdf0e10cSrcweir         break;
665cdf0e10cSrcweir 
666cdf0e10cSrcweir     case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
667cdf0e10cSrcweir         bFileOpenDialog = sal_False;
668cdf0e10cSrcweir         if ( bIsWin2000 )
669cdf0e10cSrcweir             winResTemplateId = TMPL2000_AUTOEXT_PASSWORD_FILTEROPTION_BOX;
670cdf0e10cSrcweir         else
671cdf0e10cSrcweir             winResTemplateId = TMPL95_AUTOEXT_PASSWORD_FILTEROPTION_BOX;
672cdf0e10cSrcweir         break;
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     case FILESAVE_AUTOEXTENSION_SELECTION:
675cdf0e10cSrcweir         bFileOpenDialog = sal_False;
676cdf0e10cSrcweir         if ( bIsWin2000 )
677cdf0e10cSrcweir             winResTemplateId = TMPL2000_AUTOEXT_SELECTION_BOX;
678cdf0e10cSrcweir         else
679cdf0e10cSrcweir             winResTemplateId = TMPL95_AUTOEXT_SELECTION_BOX;
680cdf0e10cSrcweir         break;
681cdf0e10cSrcweir 
682cdf0e10cSrcweir     case FILESAVE_AUTOEXTENSION_TEMPLATE:
683cdf0e10cSrcweir         bFileOpenDialog = sal_False;
684cdf0e10cSrcweir         if ( bIsWin2000 )
685cdf0e10cSrcweir             winResTemplateId = TMPL2000_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID;
686cdf0e10cSrcweir         else
687cdf0e10cSrcweir             winResTemplateId = TMPL95_FILEOPEN_AUTOEXT_TEMPLATE_BOX_ID;
688cdf0e10cSrcweir         break;
689cdf0e10cSrcweir 
690cdf0e10cSrcweir     case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
691cdf0e10cSrcweir         if ( bIsWin2000 )
692cdf0e10cSrcweir             winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_ID;
693cdf0e10cSrcweir         else
694cdf0e10cSrcweir             winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_ID;
695cdf0e10cSrcweir         break;
696cdf0e10cSrcweir 
697cdf0e10cSrcweir     case FILEOPEN_PLAY:
698cdf0e10cSrcweir         if ( bIsWin2000 )
699cdf0e10cSrcweir             winResTemplateId = TMPL2000_PLAY_PUSHBUTTON;
700cdf0e10cSrcweir         else
701cdf0e10cSrcweir             winResTemplateId = TMPL95_PLAY_PUSHBUTTON;
702cdf0e10cSrcweir         break;
703cdf0e10cSrcweir 
704cdf0e10cSrcweir     case FILEOPEN_READONLY_VERSION:
705cdf0e10cSrcweir         if ( bIsWin2000 )
706cdf0e10cSrcweir             winResTemplateId = TMPL2000_FILEOPEN_READONLY_VERSION_BOX_ID;
707cdf0e10cSrcweir         else
708cdf0e10cSrcweir             winResTemplateId = TMPL95_FILEOPEN_READONLY_VERSION_BOX_ID;
709cdf0e10cSrcweir         break;
710cdf0e10cSrcweir 
711cdf0e10cSrcweir     case FILEOPEN_LINK_PREVIEW:
712cdf0e10cSrcweir         if ( bIsWin2000 )
713cdf0e10cSrcweir             winResTemplateId = TMPL2000_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID;
714cdf0e10cSrcweir         else
715cdf0e10cSrcweir             winResTemplateId = TMPL95_FILEOPEN_LINK_PREVIEW_BOX_SIMPLE_ID;
716cdf0e10cSrcweir         break;
717cdf0e10cSrcweir 
718cdf0e10cSrcweir     case FILESAVE_AUTOEXTENSION:
719cdf0e10cSrcweir         bFileOpenDialog = sal_False;
720cdf0e10cSrcweir         if ( bIsWin2000 )
721cdf0e10cSrcweir             winResTemplateId = TMPL2000_FILESAVE_AUTOEXT;
722cdf0e10cSrcweir         else
723cdf0e10cSrcweir             winResTemplateId = TMPL95_FILESAVE_AUTOEXT;
724cdf0e10cSrcweir         break;
725cdf0e10cSrcweir 
726cdf0e10cSrcweir     default:
727cdf0e10cSrcweir         throw lang::IllegalArgumentException(
728cdf0e10cSrcweir 			rtl::OUString::createFromAscii( "Unknown template" ),
729cdf0e10cSrcweir 			static_cast< XFilePicker2* >( this ),
730cdf0e10cSrcweir 			1 );
731cdf0e10cSrcweir     }
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 	HINSTANCE hInstance = GetModuleHandle( FILE_PICKER_DLL_NAME );
734cdf0e10cSrcweir 	OSL_POSTCOND( hInstance, "The name of the service dll must have changed" );
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 	// create a new impl-class here based on the
737cdf0e10cSrcweir 	// given string, if the given string is empty
738cdf0e10cSrcweir 	// we do nothing
739cdf0e10cSrcweir 	m_pImpl = std::auto_ptr< CWinFileOpenImpl >(
740cdf0e10cSrcweir 		new CWinFileOpenImpl(
741cdf0e10cSrcweir 			this,
742cdf0e10cSrcweir 			bFileOpenDialog,
743cdf0e10cSrcweir 			0,
744cdf0e10cSrcweir 			winResTemplateId,
745cdf0e10cSrcweir 			hInstance ) );
746cdf0e10cSrcweir }
747cdf0e10cSrcweir 
748cdf0e10cSrcweir //------------------------------------------------------------------------------------
749cdf0e10cSrcweir //
750cdf0e10cSrcweir //------------------------------------------------------------------------------------
751cdf0e10cSrcweir 
cancel()752cdf0e10cSrcweir void SAL_CALL CFilePicker::cancel()
753cdf0e10cSrcweir 	throw(uno::RuntimeException)
754cdf0e10cSrcweir {
755cdf0e10cSrcweir     OSL_ASSERT(m_pImpl.get());
756cdf0e10cSrcweir 
757cdf0e10cSrcweir     osl::MutexGuard aGuard(m_aMutex);
758cdf0e10cSrcweir     m_pImpl->cancel();
759cdf0e10cSrcweir }
760cdf0e10cSrcweir 
761cdf0e10cSrcweir // -------------------------------------------------
762cdf0e10cSrcweir // XServiceInfo
763cdf0e10cSrcweir // -------------------------------------------------
764cdf0e10cSrcweir 
getImplementationName()765cdf0e10cSrcweir rtl::OUString SAL_CALL CFilePicker::getImplementationName()
766cdf0e10cSrcweir 	throw(uno::RuntimeException)
767cdf0e10cSrcweir {
768cdf0e10cSrcweir 	return rtl::OUString::createFromAscii(FILE_PICKER_IMPL_NAME);
769cdf0e10cSrcweir }
770cdf0e10cSrcweir 
771cdf0e10cSrcweir // -------------------------------------------------
772cdf0e10cSrcweir //	XServiceInfo
773cdf0e10cSrcweir // -------------------------------------------------
774cdf0e10cSrcweir 
supportsService(const rtl::OUString & ServiceName)775cdf0e10cSrcweir sal_Bool SAL_CALL CFilePicker::supportsService(const rtl::OUString& ServiceName)
776cdf0e10cSrcweir 	throw(uno::RuntimeException )
777cdf0e10cSrcweir {
778cdf0e10cSrcweir 	uno::Sequence <rtl::OUString> SupportedServicesNames = FilePicker_getSupportedServiceNames();
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 	for (sal_Int32 n = SupportedServicesNames.getLength(); n--;)
781cdf0e10cSrcweir 		if (SupportedServicesNames[n].compareTo(ServiceName) == 0)
782cdf0e10cSrcweir 			return sal_True;
783cdf0e10cSrcweir 
784cdf0e10cSrcweir 	return sal_False;
785cdf0e10cSrcweir }
786cdf0e10cSrcweir 
787cdf0e10cSrcweir // -------------------------------------------------
788cdf0e10cSrcweir //	XServiceInfo
789cdf0e10cSrcweir // -------------------------------------------------
790cdf0e10cSrcweir 
getSupportedServiceNames()791cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL CFilePicker::getSupportedServiceNames()
792cdf0e10cSrcweir 	throw(uno::RuntimeException)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir 	return FilePicker_getSupportedServiceNames();
795cdf0e10cSrcweir }
796