Update ooo320-m1
[ooovba.git] / framework / source / loadenv / loaddispatchlistener.cxx
blobeb1859b048a285de13dd1dea2001782a4d4840f4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: loaddispatchlistener.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 //_______________________________________________
35 // includes of own project
36 #include <loadenv/loaddispatchlistener.hxx>
37 #include <threadhelp/writeguard.hxx>
38 #include <threadhelp/readguard.hxx>
40 //_______________________________________________
41 // includes of uno interface
42 #include <com/sun/star/frame/DispatchResultState.hpp>
44 //_______________________________________________
45 // includes of an other project
46 #include <vcl/svapp.hxx>
48 //_______________________________________________
49 // namespace
51 namespace framework{
53 // may there exist already a define .-(
54 #ifndef css
55 namespace css = ::com::sun::star;
56 #endif
58 //_______________________________________________
59 // declarations
61 //-----------------------------------------------
62 DEFINE_XINTERFACE_2(LoadDispatchListener ,
63 OWeakObject ,
64 DIRECT_INTERFACE (css::frame::XDispatchResultListener ),
65 DERIVED_INTERFACE(css::lang::XEventListener, css::frame::XDispatchResultListener))
67 //-----------------------------------------------
68 LoadDispatchListener::LoadDispatchListener()
69 : ThreadHelpBase(&Application::GetSolarMutex())
71 // reset the condition object - so our user can wait there.
72 m_aUserWait.reset();
73 // set defined state for our result value
74 m_aResult.State = css::frame::DispatchResultState::DONTKNOW;
75 m_aResult.Result.clear();
78 //-----------------------------------------------
79 LoadDispatchListener::~LoadDispatchListener()
83 //-----------------------------------------------
84 void SAL_CALL LoadDispatchListener::dispatchFinished(const css::frame::DispatchResultEvent& aEvent)
85 throw(css::uno::RuntimeException)
87 // SAFE -> ----------------------------------
88 WriteGuard aWriteLock(m_aLock);
89 m_aResult = aEvent;
90 aWriteLock.unlock();
91 // <- SAFE ----------------------------------
93 // inform user about this arrived event
94 m_aUserWait.set();
97 //-----------------------------------------------
98 void SAL_CALL LoadDispatchListener::disposing(const css::lang::EventObject&)
99 throw(css::uno::RuntimeException)
101 // SAFE -> ----------------------------------
102 WriteGuard aWriteLock(m_aLock);
103 m_aResult.State = css::frame::DispatchResultState::DONTKNOW;
104 m_aResult.Result.clear();
105 aWriteLock.unlock();
106 // <- SAFE ----------------------------------
108 // inform user about this arrived event
109 m_aUserWait.set();
112 //-----------------------------------------------
113 void LoadDispatchListener::setURL(const ::rtl::OUString & sURL)
115 // SAFE -> ----------------------------------
116 WriteGuard aWriteLock(m_aLock);
117 m_sURL = sURL;
118 aWriteLock.unlock();
119 // <- SAFE ----------------------------------
122 //-----------------------------------------------
123 sal_Bool LoadDispatchListener::wait(sal_Int32 /*nWait_ms*/)
125 // Wait till an event occures
126 m_aUserWait.wait(0);
127 // reset the condition, so this method can be called again.
128 // Of course a new action has to be started outside too!
129 m_aUserWait.reset();
131 // TODO implement real timeout :-)
132 return sal_True;
135 //-----------------------------------------------
136 css::frame::DispatchResultEvent LoadDispatchListener::getResult() const
138 // SAFE -> ----------------------------------
139 ReadGuard aReadLock(m_aLock);
140 return m_aResult;
141 // <- SAFE ----------------------------------
144 } // namespace framework