Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / appl / helpdispatch.cxx
blob8ae6135e24a706f8765af18388f2f427de985cae
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
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;
32 // class HelpInterceptor_Impl --------------------------------------------
34 HelpDispatch_Impl::HelpDispatch_Impl( HelpInterceptor_Impl& _rInterceptor,
35 const ::com::sun::star::uno::Reference<
36 ::com::sun::star::frame::XDispatch >& _xDisp ) :
38 m_rInterceptor ( _rInterceptor ),
39 m_xRealDispatch ( _xDisp )
46 HelpDispatch_Impl::~HelpDispatch_Impl()
51 // XDispatch
53 void SAL_CALL HelpDispatch_Impl::dispatch(
55 const URL& aURL, const Sequence< PropertyValue >& aArgs ) throw( RuntimeException, std::exception )
58 DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
60 // search for a keyword (dispatch from the basic ide)
61 bool bHasKeyword = false;
62 OUString sKeyword;
63 const PropertyValue* pBegin = aArgs.getConstArray();
64 const PropertyValue* pEnd = pBegin + aArgs.getLength();
65 for ( ; pBegin != pEnd; ++pBegin )
67 if ( pBegin->Name == "HelpKeyword" )
69 OUString sHelpKeyword;
70 if ( ( pBegin->Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() )
72 sKeyword = sHelpKeyword;
73 bHasKeyword = !sKeyword.isEmpty();
74 break;
79 // if a keyword was found, then open it
80 SfxHelpWindow_Impl* pHelpWin = m_rInterceptor.GetHelpWindow();
81 DBG_ASSERT( pHelpWin, "invalid HelpWindow" );
82 if ( bHasKeyword )
84 pHelpWin->OpenKeyword( sKeyword );
85 return;
88 pHelpWin->loadHelpContent(aURL.Complete);
93 void SAL_CALL HelpDispatch_Impl::addStatusListener(
95 const Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException, std::exception )
98 DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
99 m_xRealDispatch->addStatusListener( xControl, aURL );
104 void SAL_CALL HelpDispatch_Impl::removeStatusListener(
106 const Reference< XStatusListener >& xControl, const URL& aURL ) throw( RuntimeException, std::exception )
109 DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
110 m_xRealDispatch->removeStatusListener( xControl, aURL );
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */