Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "helpdispatch.hxx"
22 : #include <sfx2/sfxuno.hxx>
23 : #include "newhelp.hxx"
24 : #include <tools/debug.hxx>
25 : #include <com/sun/star/frame/XNotifyingDispatch.hpp>
26 :
27 : using namespace ::com::sun::star::beans;
28 : using namespace ::com::sun::star::frame;
29 : using namespace ::com::sun::star::uno;
30 : using namespace ::com::sun::star::util;
31 :
32 : // class HelpInterceptor_Impl --------------------------------------------
33 :
34 0 : HelpDispatch_Impl::HelpDispatch_Impl( HelpInterceptor_Impl& _rInterceptor,
35 : const ::com::sun::star::uno::Reference<
36 : ::com::sun::star::frame::XDispatch >& _xDisp ) :
37 :
38 : m_rInterceptor ( _rInterceptor ),
39 0 : m_xRealDispatch ( _xDisp )
40 :
41 : {
42 0 : }
43 :
44 :
45 :
46 0 : HelpDispatch_Impl::~HelpDispatch_Impl()
47 : {
48 0 : }
49 :
50 :
51 : // XDispatch
52 :
53 0 : void SAL_CALL HelpDispatch_Impl::dispatch(
54 :
55 : const URL& aURL, const Sequence< PropertyValue >& aArgs ) throw( RuntimeException, std::exception )
56 :
57 : {
58 : DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
59 :
60 : // search for a keyword (dispatch from the basic ide)
61 0 : bool bHasKeyword = false;
62 0 : OUString sKeyword;
63 0 : const PropertyValue* pBegin = aArgs.getConstArray();
64 0 : const PropertyValue* pEnd = pBegin + aArgs.getLength();
65 0 : for ( ; pBegin != pEnd; ++pBegin )
66 : {
67 0 : if ( pBegin->Name.equalsAscii( "HelpKeyword" ) )
68 : {
69 0 : OUString sHelpKeyword;
70 0 : if ( ( pBegin->Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() )
71 : {
72 0 : sKeyword = sHelpKeyword;
73 0 : bHasKeyword = !sKeyword.isEmpty();
74 0 : break;
75 0 : }
76 : }
77 : }
78 :
79 : // if a keyword was found, then open it
80 0 : SfxHelpWindow_Impl* pHelpWin = m_rInterceptor.GetHelpWindow();
81 : DBG_ASSERT( pHelpWin, "invalid HelpWindow" );
82 0 : if ( bHasKeyword )
83 : {
84 0 : pHelpWin->OpenKeyword( sKeyword );
85 0 : return;
86 : }
87 :
88 0 : pHelpWin->loadHelpContent(aURL.Complete);
89 : }
90 :
91 :
92 :
93 0 : void SAL_CALL HelpDispatch_Impl::addStatusListener(
94 :
95 : const Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException, std::exception )
96 :
97 : {
98 : DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
99 0 : m_xRealDispatch->addStatusListener( xControl, aURL );
100 0 : }
101 :
102 :
103 :
104 0 : void SAL_CALL HelpDispatch_Impl::removeStatusListener(
105 :
106 : const Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException, std::exception )
107 :
108 : {
109 : DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
110 0 : m_xRealDispatch->removeStatusListener( xControl, aURL );
111 0 : }
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|