Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vcl / unx / kde / UnxNotifyThread.cxx
blobad838405639b7e520ae3bf6147a30c08602ad189
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 //////////////////////////////////////////////////////////////////////////
26 // UnxFilePickerNotifyThread
27 //////////////////////////////////////////////////////////////////////////
29 UnxFilePickerNotifyThread::UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker )
30 : m_pUnxFilePicker( pUnxFilePicker ),
31 m_bExit( sal_False ),
32 m_eNotifyType( Nothing ),
33 m_nControlId( 0 )
37 void SAL_CALL UnxFilePickerNotifyThread::addFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& xListener )
38 throw( uno::RuntimeException )
40 ::osl::MutexGuard aGuard( m_aMutex );
42 m_xListener = xListener;
45 void SAL_CALL UnxFilePickerNotifyThread::removeFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& /*xListener*/ )
46 throw( uno::RuntimeException )
48 ::osl::MutexGuard aGuard( m_aMutex );
50 m_xListener.clear();
53 void SAL_CALL UnxFilePickerNotifyThread::exit()
55 ::osl::MutexGuard aGuard( m_aMutex );
57 m_bExit = sal_True;
59 m_aExitCondition.reset();
60 m_aNotifyCondition.set();
62 m_aExitCondition.wait();
65 void SAL_CALL UnxFilePickerNotifyThread::fileSelectionChanged()
67 ::osl::MutexGuard aGuard( m_aMutex );
69 m_eNotifyType = FileSelectionChanged;
70 m_nControlId = 0;
72 m_aNotifyCondition.set();
75 void SAL_CALL UnxFilePickerNotifyThread::run()
77 do {
78 m_aNotifyCondition.reset();
79 m_aNotifyCondition.wait();
81 if ( m_xListener.is() && m_pUnxFilePicker )
83 ::osl::MutexGuard aGuard( m_aMutex );
85 ui::dialogs::FilePickerEvent aEvent( *m_pUnxFilePicker, m_nControlId );
87 switch ( m_eNotifyType )
89 case FileSelectionChanged:
90 m_xListener->fileSelectionChanged( aEvent );
91 break;
93 // TODO More to come...
95 default:
96 // nothing
97 break;
100 } while ( !m_bExit );
102 m_aExitCondition.set();
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */