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 <UnxNotifyThread.hxx>
21 #include <UnxFilePicker.hxx>
23 using namespace ::com::sun::star
;
25 // UnxFilePickerNotifyThread
27 UnxFilePickerNotifyThread::UnxFilePickerNotifyThread( UnxFilePicker
*pUnxFilePicker
)
28 : m_pUnxFilePicker( pUnxFilePicker
),
30 m_eNotifyType( Nothing
),
35 void SAL_CALL
UnxFilePickerNotifyThread::addFilePickerListener( const uno::Reference
< ui::dialogs::XFilePickerListener
>& xListener
)
36 throw( uno::RuntimeException
)
38 ::osl::MutexGuard
aGuard( m_aMutex
);
40 m_xListener
= xListener
;
43 void SAL_CALL
UnxFilePickerNotifyThread::removeFilePickerListener( const uno::Reference
< ui::dialogs::XFilePickerListener
>& /*xListener*/ )
44 throw( uno::RuntimeException
)
46 ::osl::MutexGuard
aGuard( m_aMutex
);
51 void SAL_CALL
UnxFilePickerNotifyThread::exit()
53 ::osl::MutexGuard
aGuard( m_aMutex
);
57 m_aExitCondition
.reset();
58 m_aNotifyCondition
.set();
60 m_aExitCondition
.wait();
63 void SAL_CALL
UnxFilePickerNotifyThread::fileSelectionChanged()
65 ::osl::MutexGuard
aGuard( m_aMutex
);
67 m_eNotifyType
= FileSelectionChanged
;
70 m_aNotifyCondition
.set();
73 void SAL_CALL
UnxFilePickerNotifyThread::run()
76 m_aNotifyCondition
.reset();
77 m_aNotifyCondition
.wait();
79 if ( m_xListener
.is() && m_pUnxFilePicker
)
81 ::osl::MutexGuard
aGuard( m_aMutex
);
83 ui::dialogs::FilePickerEvent
aEvent( *m_pUnxFilePicker
, m_nControlId
);
85 switch ( m_eNotifyType
)
87 case FileSelectionChanged
:
88 m_xListener
->fileSelectionChanged( aEvent
);
91 // TODO More to come...
100 m_aExitCondition
.set();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */