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