1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: helpdispatch.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
34 #include "helpdispatch.hxx"
35 #include <sfx2/sfxuno.hxx>
36 #include "newhelp.hxx"
37 #include <tools/debug.hxx>
38 #include <tools/urlobj.hxx>
39 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
41 using namespace ::com::sun::star::beans
;
42 using namespace ::com::sun::star::frame
;
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::util
;
46 // class HelpInterceptor_Impl --------------------------------------------
48 HelpDispatch_Impl::HelpDispatch_Impl( HelpInterceptor_Impl
& _rInterceptor
,
49 const ::com::sun::star::uno::Reference
<
50 ::com::sun::star::frame::XDispatch
>& _xDisp
) :
52 m_rInterceptor ( _rInterceptor
),
53 m_xRealDispatch ( _xDisp
)
58 // -----------------------------------------------------------------------
60 HelpDispatch_Impl::~HelpDispatch_Impl()
64 // -----------------------------------------------------------------------
67 void SAL_CALL
HelpDispatch_Impl::dispatch(
69 const URL
& aURL
, const Sequence
< PropertyValue
>& aArgs
) throw( RuntimeException
)
72 DBG_ASSERT( m_xRealDispatch
.is(), "invalid dispatch" );
74 // search for a keyword (dispatch from the basic ide)
75 sal_Bool bHasKeyword
= sal_False
;
77 const PropertyValue
* pBegin
= aArgs
.getConstArray();
78 const PropertyValue
* pEnd
= pBegin
+ aArgs
.getLength();
79 for ( ; pBegin
!= pEnd
; ++pBegin
)
81 if ( 0 == ( *pBegin
).Name
.compareToAscii( "HelpKeyword" ) )
83 rtl::OUString sHelpKeyword
;
84 if ( ( ( *pBegin
).Value
>>= sHelpKeyword
) && sHelpKeyword
.getLength() > 0 )
86 sKeyword
= String( sHelpKeyword
);
87 bHasKeyword
= ( sKeyword
.Len() > 0 );
93 // if a keyword was found, then open it
94 SfxHelpWindow_Impl
* pHelpWin
= m_rInterceptor
.GetHelpWindow();
95 DBG_ASSERT( pHelpWin
, "invalid HelpWindow" );
98 pHelpWin
->OpenKeyword( sKeyword
);
102 pHelpWin
->loadHelpContent(aURL
.Complete
);
105 // -----------------------------------------------------------------------
107 void SAL_CALL
HelpDispatch_Impl::addStatusListener(
109 const Reference
< XStatusListener
>& xControl
, const URL
& aURL
) throw( RuntimeException
)
112 DBG_ASSERT( m_xRealDispatch
.is(), "invalid dispatch" );
113 m_xRealDispatch
->addStatusListener( xControl
, aURL
);
116 // -----------------------------------------------------------------------
118 void SAL_CALL
HelpDispatch_Impl::removeStatusListener(
120 const Reference
< XStatusListener
>& xControl
, const URL
& aURL
) throw( RuntimeException
)
123 DBG_ASSERT( m_xRealDispatch
.is(), "invalid dispatch" );
124 m_xRealDispatch
->removeStatusListener( xControl
, aURL
);