1cdf0e10cSrcweir #ifndef _MyProtocolHandler_HXX
2cdf0e10cSrcweir #define _MyProtocolHandler_HXX
3cdf0e10cSrcweir 
4*cb2654afSPedro Giffuni #include <com/sun/star/awt/XToolkit.hpp>
5*cb2654afSPedro Giffuni #include <com/sun/star/beans/NamedValue.hpp>
6cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
7*cb2654afSPedro Giffuni #include <com/sun/star/lang/XServiceInfo.hpp>
8cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
9cdf0e10cSrcweir #include <com/sun/star/frame/XControlNotificationListener.hpp>
10cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
11*cb2654afSPedro Giffuni #include <cppuhelper/implbase3.hxx>
12cdf0e10cSrcweir 
13cdf0e10cSrcweir #define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME   "vnd.demo.Impl.ProtocolHandler"
14cdf0e10cSrcweir #define MYPROTOCOLHANDLER_SERVICENAME          "vnd.demo.ProtocolHandler"
15cdf0e10cSrcweir 
16cdf0e10cSrcweir namespace com
17cdf0e10cSrcweir {
18cdf0e10cSrcweir 	namespace sun
19cdf0e10cSrcweir 	{
20cdf0e10cSrcweir 		namespace star
21cdf0e10cSrcweir 		{
22cdf0e10cSrcweir 			namespace frame
23cdf0e10cSrcweir 			{
24cdf0e10cSrcweir 				class XModel;
25cdf0e10cSrcweir 				class XFrame;
26cdf0e10cSrcweir 			}
27cdf0e10cSrcweir 		}
28cdf0e10cSrcweir 	}
29cdf0e10cSrcweir }
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class MyProtocolHandler : public cppu::WeakImplHelper3
33cdf0e10cSrcweir <
34cdf0e10cSrcweir 	com::sun::star::frame::XDispatchProvider,
35cdf0e10cSrcweir 	com::sun::star::lang::XInitialization,
36cdf0e10cSrcweir 	com::sun::star::lang::XServiceInfo
37cdf0e10cSrcweir >
38cdf0e10cSrcweir {
39cdf0e10cSrcweir private:
40cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
41cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir public:
44cdf0e10cSrcweir 	MyProtocolHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
45cdf0e10cSrcweir         : mxMSF( rxMSF ) {}
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	// XDispatchProvider
48cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
49cdf0e10cSrcweir 			SAL_CALL queryDispatch(	const ::com::sun::star::util::URL& aURL,
50cdf0e10cSrcweir 				const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
51cdf0e10cSrcweir 				throw( ::com::sun::star::uno::RuntimeException );
52cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > >
53cdf0e10cSrcweir 		SAL_CALL queryDispatches(
54cdf0e10cSrcweir 			const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor )
55cdf0e10cSrcweir 			throw( ::com::sun::star::uno::RuntimeException );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	// XInitialization
58cdf0e10cSrcweir     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
59cdf0e10cSrcweir 		throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	// XServiceInfo
62cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  )
63cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
64cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
65cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
66cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
67cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
68cdf0e10cSrcweir };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir ::rtl::OUString MyProtocolHandler_getImplementationName()
71cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
74cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames(  )
77cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
80cdf0e10cSrcweir SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
81cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::Exception );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir class BaseDispatch : public cppu::WeakImplHelper2
84cdf0e10cSrcweir <
85cdf0e10cSrcweir 	::com::sun::star::frame::XDispatch,
86cdf0e10cSrcweir     ::com::sun::star::frame::XControlNotificationListener
87cdf0e10cSrcweir >
88cdf0e10cSrcweir {
89cdf0e10cSrcweir protected:
90cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
91cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
92cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit;
93cdf0e10cSrcweir     ::rtl::OUString msDocService;
94cdf0e10cSrcweir     ::rtl::OUString maComboBoxText;
95cdf0e10cSrcweir     sal_Bool        mbButtonEnabled;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir public:
98cdf0e10cSrcweir 	BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
99cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	virtual ~BaseDispatch();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	void ShowMessageBox( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText );
104cdf0e10cSrcweir     void SendCommand( const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rArgs, sal_Bool bEnabled );
105cdf0e10cSrcweir     void SendCommandTo( const com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener >& xControl, const com::sun::star::util::URL& aURL, const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rArgs, sal_Bool bEnabled );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	// XDispatch
108cdf0e10cSrcweir     virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL,
109cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs )
110cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir     virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
112cdf0e10cSrcweir 		const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
113cdf0e10cSrcweir     virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
114cdf0e10cSrcweir 		const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     // XControlNotificationListener
117cdf0e10cSrcweir     virtual void SAL_CALL controlEvent( const ::com::sun::star::frame::ControlEvent& Event )
118cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir };
120cdf0e10cSrcweir 
121cdf0e10cSrcweir class WriterDispatch : public BaseDispatch
122cdf0e10cSrcweir {
123cdf0e10cSrcweir public:
124cdf0e10cSrcweir 	WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
125cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
126cdf0e10cSrcweir         : BaseDispatch( rxMSF, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) )
127cdf0e10cSrcweir 	{}
128cdf0e10cSrcweir };
129cdf0e10cSrcweir 
130cdf0e10cSrcweir class CalcDispatch : public BaseDispatch
131cdf0e10cSrcweir {
132cdf0e10cSrcweir public:
133cdf0e10cSrcweir 	CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
134cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
135cdf0e10cSrcweir         : BaseDispatch( rxMSF, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadSheetDocument" ) ) )
136cdf0e10cSrcweir 	{}
137cdf0e10cSrcweir };
138cdf0e10cSrcweir 
139cdf0e10cSrcweir #endif
140