LibreOffice Module sfx2 (master) 1
helpdispatch.cxx
Go to the documentation of this file.
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 "newhelp.hxx"
23#include <tools/debug.hxx>
24#include <utility>
25
26using namespace ::com::sun::star::beans;
27using namespace ::com::sun::star::frame;
28using namespace ::com::sun::star::uno;
29using namespace ::com::sun::star::util;
30
31// class HelpInterceptor_Impl --------------------------------------------
32
34 css::uno::Reference< css::frame::XDispatch > _xDisp ) :
35
36 m_rInterceptor ( _rInterceptor ),
37 m_xRealDispatch (std::move( _xDisp ))
38
39{
40}
41
42
44{
45}
46
47
48// XDispatch
49
51
52 const URL& aURL, const Sequence< PropertyValue >& aArgs )
53
54{
55 DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
56
57 // search for a keyword (dispatch from the basic ide)
58 bool bHasKeyword = false;
59 OUString sKeyword;
60 for ( const PropertyValue& rArg : aArgs )
61 {
62 if ( rArg.Name == "HelpKeyword" )
63 {
64 OUString sHelpKeyword;
65 if ( ( rArg.Value >>= sHelpKeyword ) && !sHelpKeyword.isEmpty() )
66 {
67 sKeyword = sHelpKeyword;
68 bHasKeyword = !sKeyword.isEmpty();
69 break;
70 }
71 }
72 }
73
74 // if a keyword was found, then open it
76 DBG_ASSERT( pHelpWin, "invalid HelpWindow" );
77 if ( bHasKeyword )
78 {
79 pHelpWin->OpenKeyword( sKeyword );
80 return;
81 }
82
83 pHelpWin->loadHelpContent(aURL.Complete);
84}
85
86
88
89 const Reference< XStatusListener >& xControl, const URL& aURL )
90
91{
92 DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
93 m_xRealDispatch->addStatusListener( xControl, aURL );
94}
95
96
98
99 const Reference< XStatusListener >& xControl, const URL& aURL )
100
101{
102 DBG_ASSERT( m_xRealDispatch.is(), "invalid dispatch" );
103 m_xRealDispatch->removeStatusListener( xControl, aURL );
104}
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
HelpDispatch_Impl(HelpInterceptor_Impl &_rInterceptor, css::uno::Reference< css::frame::XDispatch > _xDisp)
css::uno::Reference< css::frame::XDispatch > m_xRealDispatch
HelpInterceptor_Impl & m_rInterceptor
virtual ~HelpDispatch_Impl() override
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
SfxHelpWindow_Impl * GetHelpWindow() const
void OpenKeyword(const OUString &rKeyword)
Definition: newhelp.hxx:478
void loadHelpContent(const OUString &sHelpURL, bool bAddToHistory=true)
Definition: newhelp.cxx:1224
#define DBG_ASSERT(sCon, aError)
URL aURL