1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <osl/diagnose.h>
22 #include "FolderPicker.hxx"
23 #include <com/sun/star/lang/DisposedException.hpp>
24 #include <cppuhelper/supportsservice.hxx>
25 #include "WinFOPImpl.hxx"
28 // namespace directives
31 using com::sun::star::uno::Reference
;
32 using com::sun::star::uno::RuntimeException
;
33 using com::sun::star::uno::Sequence
;
34 using com::sun::star::uno::XInterface
;
35 using com::sun::star::lang::XMultiServiceFactory
;
36 using com::sun::star::lang::XServiceInfo
;
37 using com::sun::star::lang::DisposedException
;
38 using com::sun::star::lang::IllegalArgumentException
;
39 using osl::MutexGuard
;
42 using namespace com::sun::star::ui::dialogs
;
44 #define FOLDERPICKER_IMPL_NAME "com.sun.star.ui.dialogs.Win32FolderPicker"
52 Sequence
< OUString
> SAL_CALL
FolderPicker_getSupportedServiceNames()
54 Sequence
< OUString
> aRet(1);
55 aRet
[0] = "com.sun.star.ui.dialogs.SystemFolderPicker";
64 CFolderPicker::CFolderPicker( const Reference
< XMultiServiceFactory
>& xServiceMgr
) :
65 m_xServiceMgr( xServiceMgr
)
67 m_pFolderPickerImpl
= std::unique_ptr
< CWinFolderPickerImpl
> ( new CWinFolderPickerImpl( this ) );
74 void SAL_CALL
CFolderPicker::setTitle( const OUString
& aTitle
) throw( RuntimeException
)
76 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
77 MutexGuard
aGuard( m_aMutex
);
78 m_pFolderPickerImpl
->setTitle( aTitle
);
85 void SAL_CALL
CFolderPicker::setDisplayDirectory( const OUString
& aDirectory
)
86 throw( IllegalArgumentException
, RuntimeException
)
88 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
89 MutexGuard
aGuard( m_aMutex
);
90 m_pFolderPickerImpl
->setDisplayDirectory( aDirectory
);
97 OUString SAL_CALL
CFolderPicker::getDisplayDirectory( )
98 throw( RuntimeException
)
100 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
101 MutexGuard
aGuard( m_aMutex
);
102 return m_pFolderPickerImpl
->getDisplayDirectory( );
109 OUString SAL_CALL
CFolderPicker::getDirectory( ) throw( RuntimeException
)
111 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
112 MutexGuard
aGuard( m_aMutex
);
113 return m_pFolderPickerImpl
->getDirectory( );
120 void SAL_CALL
CFolderPicker::setDescription( const OUString
& aDescription
) throw( RuntimeException
)
122 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
123 MutexGuard
aGuard( m_aMutex
);
124 m_pFolderPickerImpl
->setDescription( aDescription
);
131 sal_Int16 SAL_CALL
CFolderPicker::execute( )
132 throw( RuntimeException
)
134 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
136 // we should not block in this call else
137 // in the case of an event the client can'tgetPImplFromHandle( hWnd )
138 // call another function an we run into a
140 return m_pFolderPickerImpl
->execute( );
147 OUString SAL_CALL
CFolderPicker::getImplementationName( )
148 throw( RuntimeException
)
150 return OUString( FOLDERPICKER_IMPL_NAME
);
154 sal_Bool SAL_CALL
CFolderPicker::supportsService( const OUString
& ServiceName
)
155 throw( RuntimeException
)
157 return cppu::supportsService(this, ServiceName
);
164 Sequence
< OUString
> SAL_CALL
CFolderPicker::getSupportedServiceNames( )
165 throw( RuntimeException
)
167 return FolderPicker_getSupportedServiceNames();
174 void SAL_CALL
CFolderPicker::cancel( )
175 throw(RuntimeException
)
177 OSL_ASSERT( m_pFolderPickerImpl
.get( ) );
178 MutexGuard
aGuard( m_aMutex
);
179 m_pFolderPickerImpl
->cancel( );
183 // overwrite base class method, which is called
184 // by base class dispose function
187 void SAL_CALL
CFolderPicker::disposing()
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */