MyProtocolHandler.cxx (61161268) MyProtocolHandler.cxx (b1c5b4ce)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 16 unchanged lines hidden (view full) ---

25#include "MyProtocolHandler.h"
26
27#include <com/sun/star/awt/MessageBoxButtons.hpp>
28#include <com/sun/star/awt/XMessageBoxFactory.hpp>
29#include <com/sun/star/frame/ControlCommand.hpp>
30#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
31#include <com/sun/star/sheet/XSpreadsheetView.hpp>
32#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 16 unchanged lines hidden (view full) ---

25#include "MyProtocolHandler.h"
26
27#include <com/sun/star/awt/MessageBoxButtons.hpp>
28#include <com/sun/star/awt/XMessageBoxFactory.hpp>
29#include <com/sun/star/frame/ControlCommand.hpp>
30#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
31#include <com/sun/star/sheet/XSpreadsheetView.hpp>
32#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
33#include <com/sun/star/system/XSystemShellExecute.hpp>
33#include <com/sun/star/system/SystemShellExecute.hpp>
34
35
36using namespace com::sun::star::awt;
37using namespace com::sun::star::frame;
38using namespace com::sun::star::system;
39using namespace com::sun::star::uno;
40
41using com::sun::star::beans::NamedValue;
42using com::sun::star::beans::PropertyValue;
34
35
36using namespace com::sun::star::awt;
37using namespace com::sun::star::frame;
38using namespace com::sun::star::system;
39using namespace com::sun::star::uno;
40
41using com::sun::star::beans::NamedValue;
42using com::sun::star::beans::PropertyValue;
43using com::sun::star::lang::XMultiServiceFactory;
43using com::sun::star::uno::XComponentContext;
44using com::sun::star::sheet::XSpreadsheetView;
45using com::sun::star::text::XTextViewCursorSupplier;
46using com::sun::star::util::URL;
47
48ListenerHelper aListenerHelper;
49
50void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
51{
52 if ( !mxToolkit.is() )
44using com::sun::star::sheet::XSpreadsheetView;
45using com::sun::star::text::XTextViewCursorSupplier;
46using com::sun::star::util::URL;
47
48ListenerHelper aListenerHelper;
49
50void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
51{
52 if ( !mxToolkit.is() )
53 mxToolkit = Reference< XToolkit > ( mxMSF->createInstance(
54 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
53 mxToolkit = Reference< XToolkit > (
54 mxContext->getServiceManager()->createInstanceWithContext(
55 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" )), mxContext), UNO_QUERY );
55
56 Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY );
57 if ( rFrame.is() && xMsgBoxFactory.is() )
58 {
59 Reference< XMessageBox > xMsgBox = xMsgBoxFactory->createMessageBox(
60 Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ),
61 com::sun::star::awt::MessageBoxType_INFOBOX,
62 MessageBoxButtons::BUTTONS_OK,

--- 77 unchanged lines hidden (view full) ---

140 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) ||
141 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) ||
142 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EditfieldCmd" ) ) ||
143 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) )
144 {
145 xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
146 if ( !xRet.is() )
147 {
56
57 Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY );
58 if ( rFrame.is() && xMsgBoxFactory.is() )
59 {
60 Reference< XMessageBox > xMsgBox = xMsgBoxFactory->createMessageBox(
61 Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY ),
62 com::sun::star::awt::MessageBoxType_INFOBOX,
63 MessageBoxButtons::BUTTONS_OK,

--- 77 unchanged lines hidden (view full) ---

141 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownButtonCmd" ) ) ||
142 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "SpinfieldCmd" ) ) ||
143 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "EditfieldCmd" ) ) ||
144 aURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "DropdownboxCmd" ) ) )
145 {
146 xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
147 if ( !xRet.is() )
148 {
148 xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxMSF, mxFrame ) :
149 (BaseDispatch*) new CalcDispatch( mxMSF, mxFrame );
149 xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxContext, mxFrame ) :
150 (BaseDispatch*) new CalcDispatch( mxContext, mxFrame );
150 aListenerHelper.AddDispatch( xRet, mxFrame, aURL.Path );
151 }
152 }
153 }
154
155 return xRet;
156}
157

--- 29 unchanged lines hidden (view full) ---

187{
188 Sequence < ::rtl::OUString > aRet(1);
189 aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) );
190 return aRet;
191}
192
193#undef SERVICE_NAME
194
151 aListenerHelper.AddDispatch( xRet, mxFrame, aURL.Path );
152 }
153 }
154 }
155
156 return xRet;
157}
158

--- 29 unchanged lines hidden (view full) ---

188{
189 Sequence < ::rtl::OUString > aRet(1);
190 aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) );
191 return aRet;
192}
193
194#undef SERVICE_NAME
195
195Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
196Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XComponentContext > & rContext)
196 throw( Exception )
197{
197 throw( Exception )
198{
198 return (cppu::OWeakObject*) new MyProtocolHandler( rSMgr );
199 return (cppu::OWeakObject*) new MyProtocolHandler( rContext );
199}
200
201// XServiceInfo
202::rtl::OUString SAL_CALL MyProtocolHandler::getImplementationName( )
203 throw (RuntimeException)
204{
205 return MyProtocolHandler_getImplementationName();
206}

--- 22 unchanged lines hidden (view full) ---

229 Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
230
231 if ( !aURL.Protocol.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) )
232 {
233 if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) )
234 {
235 // open the OpenOffice.org web page
236 ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "http://www.openoffice.org" ) );
200}
201
202// XServiceInfo
203::rtl::OUString SAL_CALL MyProtocolHandler::getImplementationName( )
204 throw (RuntimeException)
205{
206 return MyProtocolHandler_getImplementationName();
207}

--- 22 unchanged lines hidden (view full) ---

230 Reference< XInterface > xSelfHold(static_cast< XDispatch* >(this), UNO_QUERY);
231
232 if ( !aURL.Protocol.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "vnd.demo.complextoolbarcontrols.demoaddon:" ) ) )
233 {
234 if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ImageButtonCmd" ) ) )
235 {
236 // open the OpenOffice.org web page
237 ::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "http://www.openoffice.org" ) );
237 Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
238 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ), UNO_QUERY );
239 if ( xSystemShellExecute.is() )
238 Reference< XSystemShellExecute > xSystemShellExecute(
239 com::sun::star::system::SystemShellExecute::create( mxContext ) );
240 try
240 {
241 {
241 try
242 {
243 xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
244 }
245 catch( Exception& rEx )
246 {
247 (void)rEx;
248 }
242 xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
249 }
243 }
244 catch( Exception& rEx )
245 {
246 (void)rEx;
247 }
250 }
251 else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) )
252 {
253 // remove the text if it's in our list
254 Sequence< NamedValue > aRemoveArgs( 1 );
255 aRemoveArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
256 aRemoveArgs[0].Value <<= maComboBoxText;
257 SendCommand( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoveEntryText" ) ), aRemoveArgs, sal_True );

--- 238 unchanged lines hidden (view full) ---

496
497 if ( bHasText )
498 maComboBoxText = aNewText;
499 }
500 }
501 }
502}
503
248 }
249 else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) )
250 {
251 // remove the text if it's in our list
252 Sequence< NamedValue > aRemoveArgs( 1 );
253 aRemoveArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ));
254 aRemoveArgs[0].Value <<= maComboBoxText;
255 SendCommand( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoveEntryText" ) ), aRemoveArgs, sal_True );

--- 238 unchanged lines hidden (view full) ---

494
495 if ( bHasText )
496 maComboBoxText = aNewText;
497 }
498 }
499 }
500}
501
504BaseDispatch::BaseDispatch( const Reference< XMultiServiceFactory > &rxMSF,
502BaseDispatch::BaseDispatch( const Reference< XComponentContext > &rxContext,
505 const Reference< XFrame >& xFrame, const rtl::OUString& rServiceName )
503 const Reference< XFrame >& xFrame, const rtl::OUString& rServiceName )
506 : mxMSF( rxMSF )
504 : mxContext( rxContext )
507 , mxFrame( xFrame )
508 , msDocService( rServiceName )
509 , mbButtonEnabled( sal_True )
510{
511}
512
513
514BaseDispatch::~BaseDispatch()
515{
516 mxFrame.clear();
505 , mxFrame( xFrame )
506 , msDocService( rServiceName )
507 , mbButtonEnabled( sal_True )
508{
509}
510
511
512BaseDispatch::~BaseDispatch()
513{
514 mxFrame.clear();
517 mxMSF.clear();
515 mxContext.clear();
518}
516}