1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "helpdispatch.hxx"
31 #include <sfx2/sfxuno.hxx>
32 #include "newhelp.hxx"
33 #include <tools/debug.hxx>
34 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
36 using namespace ::com::sun::star::beans
;
37 using namespace ::com::sun::star::frame
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::util
;
41 // class HelpInterceptor_Impl --------------------------------------------
43 HelpDispatch_Impl::HelpDispatch_Impl( HelpInterceptor_Impl
& _rInterceptor
,
44 const ::com::sun::star::uno::Reference
<
45 ::com::sun::star::frame::XDispatch
>& _xDisp
) :
47 m_rInterceptor ( _rInterceptor
),
48 m_xRealDispatch ( _xDisp
)
53 // -----------------------------------------------------------------------
55 HelpDispatch_Impl::~HelpDispatch_Impl()
59 // -----------------------------------------------------------------------
62 void SAL_CALL
HelpDispatch_Impl::dispatch(
64 const URL
& aURL
, const Sequence
< PropertyValue
>& aArgs
) throw( RuntimeException
)
67 DBG_ASSERT( m_xRealDispatch
.is(), "invalid dispatch" );
69 // search for a keyword (dispatch from the basic ide)
70 sal_Bool bHasKeyword
= sal_False
;
72 const PropertyValue
* pBegin
= aArgs
.getConstArray();
73 const PropertyValue
* pEnd
= pBegin
+ aArgs
.getLength();
74 for ( ; pBegin
!= pEnd
; ++pBegin
)
76 if ( 0 == ( *pBegin
).Name
.compareToAscii( "HelpKeyword" ) )
78 rtl::OUString sHelpKeyword
;
79 if ( ( ( *pBegin
).Value
>>= sHelpKeyword
) && !sHelpKeyword
.isEmpty() )
81 sKeyword
= String( sHelpKeyword
);
82 bHasKeyword
= ( sKeyword
.Len() > 0 );
88 // if a keyword was found, then open it
89 SfxHelpWindow_Impl
* pHelpWin
= m_rInterceptor
.GetHelpWindow();
90 DBG_ASSERT( pHelpWin
, "invalid HelpWindow" );
93 pHelpWin
->OpenKeyword( sKeyword
);
97 pHelpWin
->loadHelpContent(aURL
.Complete
);
100 // -----------------------------------------------------------------------
102 void SAL_CALL
HelpDispatch_Impl::addStatusListener(
104 const Reference
< XStatusListener
>& xControl
, const URL
& aURL
) throw( RuntimeException
)
107 DBG_ASSERT( m_xRealDispatch
.is(), "invalid dispatch" );
108 m_xRealDispatch
->addStatusListener( xControl
, aURL
);
111 // -----------------------------------------------------------------------
113 void SAL_CALL
HelpDispatch_Impl::removeStatusListener(
115 const Reference
< XStatusListener
>& xControl
, const URL
& aURL
) throw( RuntimeException
)
118 DBG_ASSERT( m_xRealDispatch
.is(), "invalid dispatch" );
119 m_xRealDispatch
->removeStatusListener( xControl
, aURL
);
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */