tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / odk / examples / cpp / complextoolbarcontrols / MyProtocolHandler.h
blob49a2a4ecebdbdbd6930bde8e552b3d24bc7e3ba7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
35 namespace com
37 namespace sun
39 namespace star
41 namespace frame
43 class XModel;
44 class XFrame;
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
59 private:
60 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
61 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
63 public:
64 MyProtocolHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
65 : mxContext( rxContext ) {}
67 // XDispatchProvider
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 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 );
75 // XInitialization
76 virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
78 // XServiceInfo
79 virtual ::rtl::OUString SAL_CALL getImplementationName( );
80 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
81 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( );
84 ::rtl::OUString MyProtocolHandler_getImplementationName();
86 sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& ServiceName );
88 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames( );
90 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
91 SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext);
93 class BaseDispatch : public cppu::WeakImplHelper2
95 ::com::sun::star::frame::XDispatch,
96 ::com::sun::star::frame::XControlNotificationListener
99 protected:
100 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
101 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
102 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit2 > mxToolkit;
103 ::rtl::OUString msDocService;
104 ::rtl::OUString maComboBoxText;
105 sal_Bool mbButtonEnabled;
107 public:
108 BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
109 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName );
111 virtual ~BaseDispatch();
113 void ShowMessageBox( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText );
114 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 );
115 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 );
117 // XDispatch
118 virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL,
119 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs );
120 virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
121 const ::com::sun::star::util::URL& aURL );
122 virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
123 const ::com::sun::star::util::URL& aURL );
125 // XControlNotificationListener
126 virtual void SAL_CALL controlEvent( const ::com::sun::star::frame::ControlEvent& Event );
129 class WriterDispatch : public BaseDispatch
131 public:
132 WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
133 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
134 : BaseDispatch( rxContext, xFrame, rtl::OUString( "com.sun.star.text.TextDocument" ) )
138 class CalcDispatch : public BaseDispatch
140 public:
141 CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
142 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
143 : BaseDispatch( rxContext, xFrame, rtl::OUString( "com.sun.star.sheet.SpreadSheetDocument" ) )
147 #endif
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */