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 INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYPROTOCOLHANDLER_H
21 #define INCLUDED_EXAMPLES_COMPLEXTOOLBARCONTROLS_MYPROTOCOLHANDLER_H
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"
46 namespace uno
{ class XComponentContext
; }
52 class MyProtocolHandler
: public cppu::WeakImplHelper3
54 com::sun::star::frame::XDispatchProvider
,
55 com::sun::star::lang::XInitialization
,
56 com::sun::star::lang::XServiceInfo
60 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxContext
;
61 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> mxFrame
;
64 MyProtocolHandler( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
)
65 : mxContext( rxContext
) {}
68 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>
69 SAL_CALL
queryDispatch( const ::com::sun::star::util::URL
& aURL
,
70 const ::rtl::OUString
& sTargetFrameName
, sal_Int32 nSearchFlags
)
71 throw( ::com::sun::star::uno::RuntimeException
);
72 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> >
73 SAL_CALL
queryDispatches(
74 const ::com::sun::star::uno::Sequence
< ::com::sun::star::frame::DispatchDescriptor
>& seqDescriptor
)
75 throw( ::com::sun::star::uno::RuntimeException
);
78 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
79 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
82 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
83 throw (::com::sun::star::uno::RuntimeException
);
84 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
85 throw (::com::sun::star::uno::RuntimeException
);
86 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
87 throw (::com::sun::star::uno::RuntimeException
);
90 ::rtl::OUString
MyProtocolHandler_getImplementationName()
91 throw ( ::com::sun::star::uno::RuntimeException
);
93 sal_Bool SAL_CALL
MyProtocolHandler_supportsService( const ::rtl::OUString
& ServiceName
)
94 throw ( ::com::sun::star::uno::RuntimeException
);
96 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
MyProtocolHandler_getSupportedServiceNames( )
97 throw ( ::com::sun::star::uno::RuntimeException
);
99 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
100 SAL_CALL
MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> & rContext
)
101 throw ( ::com::sun::star::uno::Exception
);
103 class BaseDispatch
: public cppu::WeakImplHelper2
105 ::com::sun::star::frame::XDispatch
,
106 ::com::sun::star::frame::XControlNotificationListener
110 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> mxFrame
;
111 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxContext
;
112 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XToolkit2
> mxToolkit
;
113 ::rtl::OUString msDocService
;
114 ::rtl::OUString maComboBoxText
;
115 sal_Bool mbButtonEnabled
;
118 BaseDispatch( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
,
119 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
, const ::rtl::OUString
& rServiceName
);
121 virtual ~BaseDispatch();
123 void ShowMessageBox( const com::sun::star::uno::Reference
< com::sun::star::frame::XFrame
>& rFrame
, const ::rtl::OUString
& aTitle
, const ::rtl::OUString
& aMsgText
);
124 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
);
125 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
);
128 virtual void SAL_CALL
dispatch( const ::com::sun::star::util::URL
& aURL
,
129 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& lArgs
)
130 throw (::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
addStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& xControl
,
132 const ::com::sun::star::util::URL
& aURL
) throw (::com::sun::star::uno::RuntimeException
);
133 virtual void SAL_CALL
removeStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
>& xControl
,
134 const ::com::sun::star::util::URL
& aURL
) throw (::com::sun::star::uno::RuntimeException
);
136 // XControlNotificationListener
137 virtual void SAL_CALL
controlEvent( const ::com::sun::star::frame::ControlEvent
& Event
)
138 throw (::com::sun::star::uno::RuntimeException
);
141 class WriterDispatch
: public BaseDispatch
144 WriterDispatch( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
,
145 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
)
146 : BaseDispatch( rxContext
, xFrame
, rtl::OUString( "com.sun.star.text.TextDocument" ) )
150 class CalcDispatch
: public BaseDispatch
153 CalcDispatch( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> &rxContext
,
154 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
)
155 : BaseDispatch( rxContext
, xFrame
, rtl::OUString( "com.sun.star.sheet.SpreadSheetDocument" ) )
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */