1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _MyProtocolHandler_HXX
21 #define _MyProtocolHandler_HXX
23 #include <com/sun/star/awt/XToolkit2.hpp>
24 #include <com/sun/star/beans/NamedValue.hpp>
25 #include <com/sun/star/lang/XInitialization.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/frame/XDispatchProvider.hpp>
28 #include <com/sun/star/frame/XControlNotificationListener.hpp>
29 #include <cppuhelper/implbase2.hxx>
30 #include <cppuhelper/implbase3.hxx>
32 #define MYPROTOCOLHANDLER_IMPLEMENTATIONNAME "vnd.demo.Impl.ProtocolHandler"
33 #define MYPROTOCOLHANDLER_SERVICENAME "vnd.demo.ProtocolHandler"
51 class MyProtocolHandler
: public cppu::WeakImplHelper3
53 com::sun::star::frame::XDispatchProvider
,
54 com::sun::star::lang::XInitialization
,
55 com::sun::star::lang::XServiceInfo
59 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxContext
;
60 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> mxFrame
;
63 MyProtocolHandler( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
)
64 : mxContext( rxContext
) {}
67 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>
68 SAL_CALL
queryDispatch( const ::com::sun::star::util::URL
& aURL
,
69 const ::rtl::OUString
& sTargetFrameName
, sal_Int32 nSearchFlags
)
70 throw( ::com::sun::star::uno::RuntimeException
);
71 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> >
72 SAL_CALL
queryDispatches(
73 const ::com::sun::star::uno::Sequence
< ::com::sun::star::frame::DispatchDescriptor
>& seqDescriptor
)
74 throw( ::com::sun::star::uno::RuntimeException
);
77 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
78 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
81 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
82 throw (::com::sun::star::uno::RuntimeException
);
83 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
84 throw (::com::sun::star::uno::RuntimeException
);
85 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
86 throw (::com::sun::star::uno::RuntimeException
);
89 ::rtl::OUString
MyProtocolHandler_getImplementationName()
90 throw ( ::com::sun::star::uno::RuntimeException
);
92 sal_Bool SAL_CALL
MyProtocolHandler_supportsService( const ::rtl::OUString
& ServiceName
)
93 throw ( ::com::sun::star::uno::RuntimeException
);
95 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
MyProtocolHandler_getSupportedServiceNames( )
96 throw ( ::com::sun::star::uno::RuntimeException
);
98 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
99 SAL_CALL
MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> & rContext
)
100 throw ( ::com::sun::star::uno::Exception
);
102 class BaseDispatch
: public cppu::WeakImplHelper2
104 ::com::sun::star::frame::XDispatch
,
105 ::com::sun::star::frame::XControlNotificationListener
109 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> mxFrame
;
110 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxContext
;
111 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XToolkit2
> mxToolkit
;
112 ::rtl::OUString msDocService
;
113 ::rtl::OUString maComboBoxText
;
114 sal_Bool mbButtonEnabled
;
117 BaseDispatch( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
,
118 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
, const ::rtl::OUString
& rServiceName
);
120 virtual ~BaseDispatch();
122 void ShowMessageBox( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
, const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aMsgText
);
123 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
);
124 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
);
127 virtual void SAL_CALL
dispatch( const ::com::sun::star::util::URL
& aURL
,
128 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& lArgs
)
129 throw (::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
addStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& xControl
,
131 const ::com::sun::star::util::URL
& aURL
) throw (::com::sun::star::uno::RuntimeException
);
132 virtual void SAL_CALL
removeStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& xControl
,
133 const ::com::sun::star::util::URL
& aURL
) throw (::com::sun::star::uno::RuntimeException
);
135 // XControlNotificationListener
136 virtual void SAL_CALL
controlEvent( const ::com::sun::star::frame::ControlEvent
& Event
)
137 throw (::com::sun::star::uno::RuntimeException
);
140 class WriterDispatch
: public BaseDispatch
143 WriterDispatch( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
,
144 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
)
145 : BaseDispatch( rxContext
, xFrame
, rtl::OUString( "com.sun.star.text.TextDocument" ) )
149 class CalcDispatch
: public BaseDispatch
152 CalcDispatch( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
,
153 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
)
154 : BaseDispatch( rxContext
, xFrame
, rtl::OUString( "com.sun.star.sheet.SpreadSheetDocument" ) )
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */