1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d119d52dSAndrew Rist * distributed with this work for additional information
6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at
10*d119d52dSAndrew Rist *
11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist *
13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the
17*d119d52dSAndrew Rist * specific language governing permissions and limitations
18*d119d52dSAndrew Rist * under the License.
19*d119d52dSAndrew Rist *
20*d119d52dSAndrew Rist *************************************************************/
21*d119d52dSAndrew Rist
22*d119d52dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "helpdispatch.hxx"
28cdf0e10cSrcweir #include <sfx2/sfxuno.hxx>
29cdf0e10cSrcweir #include "newhelp.hxx"
30cdf0e10cSrcweir #include <tools/debug.hxx>
31cdf0e10cSrcweir #include <tools/urlobj.hxx>
32cdf0e10cSrcweir #include <com/sun/star/frame/XNotifyingDispatch.hpp>
33cdf0e10cSrcweir
34cdf0e10cSrcweir using namespace ::com::sun::star::beans;
35cdf0e10cSrcweir using namespace ::com::sun::star::frame;
36cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37cdf0e10cSrcweir using namespace ::com::sun::star::util;
38cdf0e10cSrcweir
39cdf0e10cSrcweir // class HelpInterceptor_Impl --------------------------------------------
40cdf0e10cSrcweir
HelpDispatch_Impl(HelpInterceptor_Impl & _rInterceptor,const::com::sun::star::uno::Reference<::com::sun::star::frame::XDispatch> & _xDisp)41cdf0e10cSrcweir HelpDispatch_Impl::HelpDispatch_Impl( HelpInterceptor_Impl& _rInterceptor,
42cdf0e10cSrcweir const ::com::sun::star::uno::Reference<
43cdf0e10cSrcweir ::com::sun::star::frame::XDispatch >& _xDisp ) :
44cdf0e10cSrcweir
45cdf0e10cSrcweir m_rInterceptor ( _rInterceptor ),
46cdf0e10cSrcweir m_xRealDispatch ( _xDisp )
47cdf0e10cSrcweir
48cdf0e10cSrcweir {
49cdf0e10cSrcweir }
50cdf0e10cSrcweir
51cdf0e10cSrcweir // -----------------------------------------------------------------------
52cdf0e10cSrcweir
~HelpDispatch_Impl()53cdf0e10cSrcweir HelpDispatch_Impl::~HelpDispatch_Impl()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
57cdf0e10cSrcweir // -----------------------------------------------------------------------
58cdf0e10cSrcweir // XDispatch
59cdf0e10cSrcweir
dispatch(const URL & aURL,const Sequence<PropertyValue> & aArgs)60cdf0e10cSrcweir void SAL_CALL HelpDispatch_Impl::dispatch(
61cdf0e10cSrcweir
62cdf0e10cSrcweir const URL& aURL, const Sequence< PropertyValue >& aArgs ) throw( RuntimeException )
63cdf0e10cSrcweir
64cdf0e10cSrcweir {
65cdf0e10cSrcweir DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
66cdf0e10cSrcweir
67cdf0e10cSrcweir // search for a keyword (dispatch from the basic ide)
68cdf0e10cSrcweir sal_Bool bHasKeyword = sal_False;
69cdf0e10cSrcweir String sKeyword;
70cdf0e10cSrcweir const PropertyValue* pBegin = aArgs.getConstArray();
71cdf0e10cSrcweir const PropertyValue* pEnd = pBegin + aArgs.getLength();
72cdf0e10cSrcweir for ( ; pBegin != pEnd; ++pBegin )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir if ( 0 == ( *pBegin ).Name.compareToAscii( "HelpKeyword" ) )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir rtl::OUString sHelpKeyword;
77cdf0e10cSrcweir if ( ( ( *pBegin ).Value >>= sHelpKeyword ) && sHelpKeyword.getLength() > 0 )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir sKeyword = String( sHelpKeyword );
80cdf0e10cSrcweir bHasKeyword = ( sKeyword.Len() > 0 );
81cdf0e10cSrcweir break;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir }
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir // if a keyword was found, then open it
87cdf0e10cSrcweir SfxHelpWindow_Impl* pHelpWin = m_rInterceptor.GetHelpWindow();
88cdf0e10cSrcweir DBG_ASSERT( pHelpWin, "invalid HelpWindow" );
89cdf0e10cSrcweir if ( bHasKeyword )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir pHelpWin->OpenKeyword( sKeyword );
92cdf0e10cSrcweir return;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir pHelpWin->loadHelpContent(aURL.Complete);
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir // -----------------------------------------------------------------------
99cdf0e10cSrcweir
addStatusListener(const Reference<XStatusListener> & xControl,const URL & aURL)100cdf0e10cSrcweir void SAL_CALL HelpDispatch_Impl::addStatusListener(
101cdf0e10cSrcweir
102cdf0e10cSrcweir const Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException )
103cdf0e10cSrcweir
104cdf0e10cSrcweir {
105cdf0e10cSrcweir DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
106cdf0e10cSrcweir m_xRealDispatch->addStatusListener( xControl, aURL );
107cdf0e10cSrcweir }
108cdf0e10cSrcweir
109cdf0e10cSrcweir // -----------------------------------------------------------------------
110cdf0e10cSrcweir
removeStatusListener(const Reference<XStatusListener> & xControl,const URL & aURL)111cdf0e10cSrcweir void SAL_CALL HelpDispatch_Impl::removeStatusListener(
112cdf0e10cSrcweir
113cdf0e10cSrcweir const Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException )
114cdf0e10cSrcweir
115cdf0e10cSrcweir {
116cdf0e10cSrcweir DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
117cdf0e10cSrcweir m_xRealDispatch->removeStatusListener( xControl, aURL );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120