134dd1e25SAndrew Rist /**************************************************************
234dd1e25SAndrew Rist  *
334dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
434dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
534dd1e25SAndrew Rist  * distributed with this work for additional information
634dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
734dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
834dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
934dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
1034dd1e25SAndrew Rist  *
1134dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1234dd1e25SAndrew Rist  *
1334dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1434dd1e25SAndrew Rist  * software distributed under the License is distributed on an
1534dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1634dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
1734dd1e25SAndrew Rist  * specific language governing permissions and limitations
1834dd1e25SAndrew Rist  * under the License.
1934dd1e25SAndrew Rist  *
2034dd1e25SAndrew Rist  *************************************************************/
2134dd1e25SAndrew Rist 
22cdf0e10cSrcweir #ifndef _MyProtocolHandler_HXX
23cdf0e10cSrcweir #define _MyProtocolHandler_HXX
24cdf0e10cSrcweir 
25*b1c5b4ceSAriel Constenla-Haile #include <com/sun/star/uno/XComponentContext.hpp>
26cb2654afSPedro Giffuni #include <com/sun/star/awt/XToolkit.hpp>
27cb2654afSPedro Giffuni #include <com/sun/star/beans/NamedValue.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
29cb2654afSPedro Giffuni #include <com/sun/star/lang/XServiceInfo.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XControlNotificationListener.hpp>
32cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
33cb2654afSPedro Giffuni #include <cppuhelper/implbase3.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME   "vnd.demo.Impl.ProtocolHandler"
36cdf0e10cSrcweir #define MYPROTOCOLHANDLER_SERVICENAME          "vnd.demo.ProtocolHandler"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace com
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 	namespace sun
41cdf0e10cSrcweir 	{
42cdf0e10cSrcweir 		namespace star
43cdf0e10cSrcweir 		{
44cdf0e10cSrcweir 			namespace frame
45cdf0e10cSrcweir 			{
46cdf0e10cSrcweir 				class XModel;
47cdf0e10cSrcweir 				class XFrame;
48cdf0e10cSrcweir 			}
49cdf0e10cSrcweir 		}
50cdf0e10cSrcweir 	}
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 
54cdf0e10cSrcweir class MyProtocolHandler : public cppu::WeakImplHelper3
55cdf0e10cSrcweir <
56cdf0e10cSrcweir 	com::sun::star::frame::XDispatchProvider,
57cdf0e10cSrcweir 	com::sun::star::lang::XInitialization,
58cdf0e10cSrcweir 	com::sun::star::lang::XServiceInfo
59cdf0e10cSrcweir >
60cdf0e10cSrcweir {
61cdf0e10cSrcweir private:
62*b1c5b4ceSAriel Constenla-Haile     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
63cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir public:
MyProtocolHandler(const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & rxContext)66*b1c5b4ceSAriel Constenla-Haile 	MyProtocolHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
67*b1c5b4ceSAriel Constenla-Haile         : mxContext( rxContext ) {}
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	// XDispatchProvider
70cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
71cdf0e10cSrcweir 			SAL_CALL queryDispatch(	const ::com::sun::star::util::URL& aURL,
72cdf0e10cSrcweir 				const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
73cdf0e10cSrcweir 				throw( ::com::sun::star::uno::RuntimeException );
74cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > >
75cdf0e10cSrcweir 		SAL_CALL queryDispatches(
76cdf0e10cSrcweir 			const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor )
77cdf0e10cSrcweir 			throw( ::com::sun::star::uno::RuntimeException );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	// XInitialization
80cdf0e10cSrcweir     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
81cdf0e10cSrcweir 		throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	// XServiceInfo
84cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  )
85cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
86cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
87cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
88cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
89cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir ::rtl::OUString MyProtocolHandler_getImplementationName()
93cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName )
96cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames(  )
99cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException );
100cdf0e10cSrcweir 
101cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
102*b1c5b4ceSAriel Constenla-Haile SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
103cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::Exception );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir class BaseDispatch : public cppu::WeakImplHelper2
106cdf0e10cSrcweir <
107cdf0e10cSrcweir 	::com::sun::star::frame::XDispatch,
108cdf0e10cSrcweir     ::com::sun::star::frame::XControlNotificationListener
109cdf0e10cSrcweir >
110cdf0e10cSrcweir {
111cdf0e10cSrcweir protected:
112cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
113*b1c5b4ceSAriel Constenla-Haile     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
114cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit;
115cdf0e10cSrcweir     ::rtl::OUString msDocService;
116cdf0e10cSrcweir     ::rtl::OUString maComboBoxText;
117cdf0e10cSrcweir     sal_Bool        mbButtonEnabled;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir public:
120*b1c5b4ceSAriel Constenla-Haile 	BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
121cdf0e10cSrcweir         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	virtual ~BaseDispatch();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	void ShowMessageBox( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText );
126cdf0e10cSrcweir     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 );
127cdf0e10cSrcweir     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 );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	// XDispatch
130cdf0e10cSrcweir     virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL,
131cdf0e10cSrcweir 		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs )
132cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
133cdf0e10cSrcweir     virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
134cdf0e10cSrcweir 		const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir     virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
136cdf0e10cSrcweir 		const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     // XControlNotificationListener
139cdf0e10cSrcweir     virtual void SAL_CALL controlEvent( const ::com::sun::star::frame::ControlEvent& Event )
140cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir };
142cdf0e10cSrcweir 
143cdf0e10cSrcweir class WriterDispatch : public BaseDispatch
144cdf0e10cSrcweir {
145cdf0e10cSrcweir public:
WriterDispatch(const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & rxContext,const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & xFrame)146*b1c5b4ceSAriel Constenla-Haile 	WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
147cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
148*b1c5b4ceSAriel Constenla-Haile         : BaseDispatch( rxContext, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) )
149cdf0e10cSrcweir 	{}
150cdf0e10cSrcweir };
151cdf0e10cSrcweir 
152cdf0e10cSrcweir class CalcDispatch : public BaseDispatch
153cdf0e10cSrcweir {
154cdf0e10cSrcweir public:
CalcDispatch(const::com::sun::star::uno::Reference<::com::sun::star::uno::XComponentContext> & rxContext,const::com::sun::star::uno::Reference<::com::sun::star::frame::XFrame> & xFrame)155*b1c5b4ceSAriel Constenla-Haile 	CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
156cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
157*b1c5b4ceSAriel Constenla-Haile         : BaseDispatch( rxContext, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadSheetDocument" ) ) )
158cdf0e10cSrcweir 	{}
159cdf0e10cSrcweir };
160cdf0e10cSrcweir 
161cdf0e10cSrcweir #endif
162