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