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