1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: loaddispatchlistener.cxx,v $
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 //_______________________________________________
53 // may there exist already a define .-(
55 namespace css
= ::com::sun::star
;
58 //_______________________________________________
61 //-----------------------------------------------
62 DEFINE_XINTERFACE_2(LoadDispatchListener
,
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.
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
);
91 // <- SAFE ----------------------------------
93 // inform user about this arrived event
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();
106 // <- SAFE ----------------------------------
108 // inform user about this arrived event
112 //-----------------------------------------------
113 void LoadDispatchListener::setURL(const ::rtl::OUString
& sURL
)
115 // SAFE -> ----------------------------------
116 WriteGuard
aWriteLock(m_aLock
);
119 // <- SAFE ----------------------------------
122 //-----------------------------------------------
123 sal_Bool
LoadDispatchListener::wait(sal_Int32
/*nWait_ms*/)
125 // Wait till an event occures
127 // reset the condition, so this method can be called again.
128 // Of course a new action has to be started outside too!
131 // TODO implement real timeout :-)
135 //-----------------------------------------------
136 css::frame::DispatchResultEvent
LoadDispatchListener::getResult() const
138 // SAFE -> ----------------------------------
139 ReadGuard
aReadLock(m_aLock
);
141 // <- SAFE ----------------------------------
144 } // namespace framework