Kaydet (Commit) ace4202d authored tarafından Ariel Constenla-Haile's avatar Ariel Constenla-Haile

i121578 - Convert css.system.SystemShellExectue to new-style

While at it, remove unused code from the complex toolbar controls
example.
üst 96cd87ec
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#include "MyListener.h"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
void SAL_CALL CalcListener::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException)
{
}
void SAL_CALL CalcListener::disposing( const com::sun::star::lang::EventObject& aSource ) throw( com::sun::star::uno::RuntimeException )
{
}
......@@ -44,10 +44,6 @@ COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
CXXFILES = \
MyProtocolHandler.cxx \
MyJob.cxx \
MyListener.cxx \
WriterListener.cxx \
CalcListener.cxx \
ListenerHelper.cxx \
exports.cxx
......@@ -118,9 +114,6 @@ $(COMP_COMPONENTS) :
@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)vnd.My.impl.NewDocListener$(QM)"$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)service name="$(QM)vnd.My.NewDocListener$(QM)"/$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)vnd.demo.Impl.ProtocolHandler$(QM)"$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)service name="$(QM)vnd.demo.ProtocolHandler$(QM)"/$(CSEP) >> $@
@echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
......@@ -152,7 +145,7 @@ endif
Example : $(COMP_REGISTERFLAG)
@echo --------------------------------------------------------------------------------
@echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
@echo The "$(QM)Complext Toolbar Controlls$(QM)" component was installed if SDK_AUTO_DEPLOYMENT = YES.
@echo You can use this component inside your office installation, see the example
@echo description.
@echo --------------------------------------------------------------------------------
......
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#include "MyJob.h"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
using rtl::OUString;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Any;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::lang::IllegalArgumentException;
using com::sun::star::lang::XMultiServiceFactory;
using com::sun::star::beans::NamedValue;
using com::sun::star::document::XEventBroadcaster;
Any SAL_CALL MyJob::execute( const Sequence< NamedValue >& aArguments )
throw ( IllegalArgumentException, Exception, RuntimeException )
{
Reference < XEventBroadcaster > xBrd( mxMSF->createInstance(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.GlobalEventBroadcaster" ) ) ), UNO_QUERY );
Reference < com::sun::star::document::XEventListener > xLstner( mxMSF->createInstance(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Office.MyListener" ) ) ), UNO_QUERY );
if ( xBrd.is() )
xBrd->addEventListener( xLstner );
return Any();
}
OUString MyJob_getImplementationName ()
throw (RuntimeException)
{
return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Office.MyJob" ) );
}
#define SERVICE_NAME "com.sun.star.task.Job"
sal_Bool SAL_CALL MyJob_supportsService( const OUString& ServiceName )
throw (RuntimeException)
{
return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SERVICE_NAME ) );
}
Sequence< OUString > SAL_CALL MyJob_getSupportedServiceNames( )
throw (RuntimeException)
{
Sequence < OUString > aRet(1);
OUString* pArray = aRet.getArray();
pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
return aRet;
}
#undef SERVICE_NAME
Reference< XInterface > SAL_CALL MyJob_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
throw( Exception )
{
return (cppu::OWeakObject*) new MyJob( rSMgr );
}
// XServiceInfo
OUString SAL_CALL MyJob::getImplementationName( )
throw (RuntimeException)
{
return MyJob_getImplementationName();
}
sal_Bool SAL_CALL MyJob::supportsService( const OUString& rServiceName )
throw (RuntimeException)
{
return MyJob_supportsService( rServiceName );
}
Sequence< OUString > SAL_CALL MyJob::getSupportedServiceNames( )
throw (RuntimeException)
{
return MyJob_getSupportedServiceNames();
}
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef _MyJob_HXX
#define _MyJob_HXX
#include <com/sun/star/task/XJob.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/implbase2.hxx>
namespace com
{
namespace sun
{
namespace star
{
namespace frame
{
class XModel;
class XFrame;
}
namespace beans
{
struct NamedValue;
}
}
}
}
class MyJob : public cppu::WeakImplHelper2
<
com::sun::star::task::XJob,
com::sun::star::lang::XServiceInfo
>
{
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
public:
MyJob( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
: mxMSF( rxMSF ) {}
virtual ~MyJob() {}
// XJob
virtual ::com::sun::star::uno::Any SAL_CALL execute(
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& Arguments )
throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( )
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException);
};
::rtl::OUString MyJob_getImplementationName()
throw ( ::com::sun::star::uno::RuntimeException );
sal_Bool SAL_CALL MyJob_supportsService( const ::rtl::OUString& ServiceName )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MyJob_getSupportedServiceNames( )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL MyJob_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
throw ( ::com::sun::star::uno::Exception );
#endif
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#include "MyListener.h"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/document/XEventBroadcaster.hpp>
namespace css = ::com::sun::star;
MyListener::MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
: m_xSMGR(xSMGR)
{}
MyListener::~MyListener()
{}
css::uno::Any SAL_CALL MyListener::execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
throw (css::lang::IllegalArgumentException,
css::uno::Exception,
css::uno::RuntimeException)
{
css::uno::Sequence< css::beans::NamedValue > lEnv;
sal_Int32 i = 0;
sal_Int32 c = lArguments.getLength();
const css::beans::NamedValue* p = lArguments.getConstArray();
for (i=0; i<c; ++i)
{
if (p[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Environment" ) ) )
{
p[i].Value >>= lEnv;
break;
}
}
css::uno::Reference< css::frame::XModel > xModel;
c = lEnv.getLength();
p = lEnv.getConstArray();
for (i=0; i<c; ++i)
{
if (p[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Model" ) ) )
{
p[i].Value >>= xModel;
break;
}
if (p[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Frame" ) ) )
{
css::uno::Reference< css::frame::XController > xController;
css::uno::Reference< css::frame::XFrame > xFrame;
p[i].Value >>= xFrame;
if (xFrame.is())
xController = xFrame->getController();
if (xController.is())
xModel = xController->getModel();
break;
}
}
if (!xModel.is())
return css::uno::Any();
css::uno::Reference< css::lang::XServiceInfo > xInfo(xModel, css::uno::UNO_QUERY);
sal_Bool bCalc = xInfo->supportsService(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) );
sal_Bool bWriter = (
xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) ) &&
!xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) ) &&
!xInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.GlobalDocument" ) ) )
);
// Wir interessieren uns nur fr Writer und Calc. Werden hier aber fr
// alle neu geffneten Dokumente benachrichtigt ...
if (!bCalc && !bWriter)
return css::uno::Any();
void* pListener = 0;
if (bCalc)
pListener = (void*)(new CalcListener(m_xSMGR));
else
if (bWriter)
pListener = (void*)(new WriterListener(m_xSMGR));
css::uno::Reference< css::document::XEventListener > xDocListener (static_cast< css::document::XEventListener* >(pListener), css::uno::UNO_QUERY);
css::uno::Reference< css::document::XEventBroadcaster > xDocBroadcaster (xModel , css::uno::UNO_QUERY);
xDocBroadcaster->addEventListener(xDocListener);
return css::uno::Any();
}
::rtl::OUString SAL_CALL MyListener::getImplementationName()
throw (css::uno::RuntimeException)
{
return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) );
}
css::uno::Sequence< ::rtl::OUString > SAL_CALL MyListener::getSupportedServiceNames()
throw (css::uno::RuntimeException)
{
css::uno::Sequence< ::rtl::OUString > lNames(1);
lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_SERVICENAME ) );
return lNames;
}
sal_Bool SAL_CALL MyListener::supportsService(const ::rtl::OUString& sServiceName)
throw (css::uno::RuntimeException)
{
return (
sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYLISTENER_SERVICENAME )) ||
sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.task.Job" ) )
);
}
css::uno::Reference< css::uno::XInterface > MyListener::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
{
MyListener* pListener = new MyListener(xSMGR);
css::uno::Reference< css::uno::XInterface > xListener(static_cast< css::task::XJob* >(pListener), css::uno::UNO_QUERY);
return xListener;
}
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef _MyListener_HXX
#define _MyListener_HXX
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/task/XJob.hpp>
#include <com/sun/star/document/XEventListener.hpp>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#define MYLISTENER_IMPLEMENTATIONNAME "vnd.My.impl.NewDocListener"
#define MYLISTENER_SERVICENAME "vnd.My.NewDocListener"
namespace css = ::com::sun::star;
/*---------------------------------------------------
* Registriert sich in der Office Konfiguration als Job.
* Dieser wird dann fr alle neu geffneten Dokumente automatisch
* gerufen. Man bekommt eine Reference auf das geffnete Dokument
* berreicht und kann dann prfen, ob es ein untersttztes Format
* hat. (Wir interessieren uns ja schlielich nur fr Writer/Calc Dokumente.)
*
* @see CalcListener
* @see WriterListener
*/
class MyListener : public cppu::WeakImplHelper2< css::task::XJob ,
css::lang::XServiceInfo >
{
private:
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
public:
MyListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
virtual ~MyListener();
// XJob
virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments)
throw (css::lang::IllegalArgumentException,
css::uno::Exception,
css::uno::RuntimeException);
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
throw (css::uno::RuntimeException);
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
throw (css::uno::RuntimeException);
public:
static css::uno::Reference< css::uno::XInterface > st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
};
class CalcListener : public cppu::WeakImplHelper1< css::document::XEventListener >
{
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
public:
CalcListener(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxMSF)
: mxMSF( rxMSF )
{}
virtual ~CalcListener()
{}
// document.XEventListener
virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
throw (css::uno::RuntimeException);
virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
throw (css::uno::RuntimeException);
};
class WriterListener : public cppu::WeakImplHelper1< css::document::XEventListener >
{
private:
css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
public:
WriterListener(const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMSF);
virtual ~WriterListener()
{}
// document.XEventListener
virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
throw (css::uno::RuntimeException);
virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
throw (css::uno::RuntimeException);
};
#endif // _MyListener_HXX
......@@ -30,7 +30,7 @@
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/system/XSystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecute.hpp>
using namespace com::sun::star::awt;
......@@ -40,7 +40,7 @@ using namespace com::sun::star::uno;
using com::sun::star::beans::NamedValue;
using com::sun::star::beans::PropertyValue;
using com::sun::star::lang::XMultiServiceFactory;
using com::sun::star::uno::XComponentContext;
using com::sun::star::sheet::XSpreadsheetView;
using com::sun::star::text::XTextViewCursorSupplier;
using com::sun::star::util::URL;
......@@ -50,8 +50,9 @@ ListenerHelper aListenerHelper;
void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
{
if ( !mxToolkit.is() )
mxToolkit = Reference< XToolkit > ( mxMSF->createInstance(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
mxToolkit = Reference< XToolkit > (
mxContext->getServiceManager()->createInstanceWithContext(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" )), mxContext), UNO_QUERY );
Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY );
if ( rFrame.is() && xMsgBoxFactory.is() )
......@@ -145,8 +146,8 @@ Reference< XDispatch > SAL_CALL MyProtocolHandler::queryDispatch( const URL& a
xRet = aListenerHelper.GetDispatch( mxFrame, aURL.Path );
if ( !xRet.is() )
{
xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxMSF, mxFrame ) :
(BaseDispatch*) new CalcDispatch( mxMSF, mxFrame );
xRet = xCursor.is() ? (BaseDispatch*) new WriterDispatch( mxContext, mxFrame ) :
(BaseDispatch*) new CalcDispatch( mxContext, mxFrame );
aListenerHelper.AddDispatch( xRet, mxFrame, aURL.Path );
}
}
......@@ -192,10 +193,10 @@ Sequence< ::rtl::OUString > SAL_CALL MyProtocolHandler_getSupportedServiceNames(
#undef SERVICE_NAME
Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
Reference< XInterface > SAL_CALL MyProtocolHandler_createInstance( const Reference< XComponentContext > & rContext)
throw( Exception )
{
return (cppu::OWeakObject*) new MyProtocolHandler( rSMgr );
return (cppu::OWeakObject*) new MyProtocolHandler( rContext );
}
// XServiceInfo
......@@ -234,18 +235,15 @@ void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
{
// open the OpenOffice.org web page
::rtl::OUString sURL( RTL_CONSTASCII_USTRINGPARAM( "http://www.openoffice.org" ) );
Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ), UNO_QUERY );
if ( xSystemShellExecute.is() )
Reference< XSystemShellExecute > xSystemShellExecute(
com::sun::star::system::SystemShellExecute::create( mxContext ) );
try
{
try
{
xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
}
catch( Exception& rEx )
{
(void)rEx;
}
xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::DEFAULTS );
}
catch( Exception& rEx )
{
(void)rEx;
}
}
else if ( !aURL.Path.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ComboboxCmd" ) ) )
......@@ -501,9 +499,9 @@ void SAL_CALL BaseDispatch::controlEvent( const ControlEvent& Event ) throw (Run
}
}
BaseDispatch::BaseDispatch( const Reference< XMultiServiceFactory > &rxMSF,
BaseDispatch::BaseDispatch( const Reference< XComponentContext > &rxContext,
const Reference< XFrame >& xFrame, const rtl::OUString& rServiceName )
: mxMSF( rxMSF )
: mxContext( rxContext )
, mxFrame( xFrame )
, msDocService( rServiceName )
, mbButtonEnabled( sal_True )
......@@ -514,5 +512,5 @@ BaseDispatch::BaseDispatch( const Reference< XMultiServiceFactory > &rxMSF,
BaseDispatch::~BaseDispatch()
{
mxFrame.clear();
mxMSF.clear();
mxContext.clear();
}
......@@ -22,6 +22,7 @@
#ifndef _MyProtocolHandler_HXX
#define _MyProtocolHandler_HXX
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/awt/XToolkit.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
......@@ -58,12 +59,12 @@ class MyProtocolHandler : public cppu::WeakImplHelper3
>
{
private:
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
public:
MyProtocolHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
: mxMSF( rxMSF ) {}
MyProtocolHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
: mxContext( rxContext ) {}
// XDispatchProvider
virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
......@@ -98,7 +99,7 @@ sal_Bool SAL_CALL MyProtocolHandler_supportsService( const ::rtl::OUString& Serv
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
SAL_CALL MyProtocolHandler_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
throw ( ::com::sun::star::uno::Exception );
class BaseDispatch : public cppu::WeakImplHelper2
......@@ -109,14 +110,14 @@ class BaseDispatch : public cppu::WeakImplHelper2
{
protected:
::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit;
::rtl::OUString msDocService;
::rtl::OUString maComboBoxText;
sal_Bool mbButtonEnabled;
public:
BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
BaseDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const ::rtl::OUString& rServiceName );
virtual ~BaseDispatch();
......@@ -142,18 +143,18 @@ public:
class WriterDispatch : public BaseDispatch
{
public:
WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
WriterDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
: BaseDispatch( rxMSF, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) )
: BaseDispatch( rxContext, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument" ) ) )
{}
};
class CalcDispatch : public BaseDispatch
{
public:
CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF,
CalcDispatch( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame )
: BaseDispatch( rxMSF, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadSheetDocument" ) ) )
: BaseDispatch( rxContext, xFrame, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadSheetDocument" ) ) )
{}
};
......
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#include "MyListener.h"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
void SAL_CALL WriterListener::notifyEvent( const ::com::sun::star::document::EventObject& aEvent ) throw (com::sun::star::uno::RuntimeException)
{
}
void SAL_CALL WriterListener::disposing( const com::sun::star::lang::EventObject& aSource ) throw( com::sun::star::uno::RuntimeException )
{
}
WriterListener::WriterListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
: mxMSF( rxMSF )
{
}
......@@ -19,98 +19,44 @@
*
*************************************************************/
#include <cppuhelper/factory.hxx>
#include "MyProtocolHandler.h"
#include "MyListener.h"
namespace css = ::com::sun::star;
#if 0
static void writeInfo(const css::uno::Reference< css::registry::XRegistryKey >& xRegistryKey ,
const char* pImplementationName,
const char* pServiceName )
{
::rtl::OUStringBuffer sKey(256);
sKey.append (::rtl::OUString::createFromAscii(pImplementationName));
sKey.appendAscii("/UNO/SERVICES/");
sKey.append (::rtl::OUString::createFromAscii(pServiceName));
xRegistryKey->createKey(sKey.makeStringAndClear());
}
#endif
extern "C"
{
//==================================================================================================
SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char** ppEnvTypeName,
uno_Environment** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#if 0
/**
* This method not longer necessary since OOo 3.4 where the component registration was
* was changed to passive component registration. For more details see
* http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
*/
//==================================================================================================
SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void* pServiceManager,
void* pRegistryKey )
namespace framework
{
if (!pRegistryKey)
return sal_False;
try
namespace complex_toolbar_controls
{
css::uno::Reference< css::registry::XRegistryKey > xKey(reinterpret_cast< css::registry::XRegistryKey* >(pRegistryKey), css::uno::UNO_QUERY);
writeInfo( xKey, MYLISTENER_IMPLEMENTATIONNAME , MYLISTENER_SERVICENAME );
writeInfo( xKey, MYPROTOCOLHANDLER_IMPLEMENTATIONNAME, MYPROTOCOLHANDLER_SERVICENAME );
return sal_True;
static ::cppu::ImplementationEntry const s_impl_entries[] =
{
{
MyProtocolHandler_createInstance,
MyProtocolHandler_getImplementationName,
MyProtocolHandler_getSupportedServiceNames,
::cppu::createSingleComponentFactory,
0,
0
},
{ 0, 0, 0, 0, 0, 0 }
};
}
catch(const css::registry::InvalidRegistryException&)
{ OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); }
return sal_False;
}
#endif
//==================================================================================================
SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplName ,
void* pServiceManager,
void* pRegistryKey )
extern "C"
{
if ( !pServiceManager || !pImplName )
return 0;
css::uno::Reference< css::lang::XSingleServiceFactory > xFactory ;
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR (reinterpret_cast< css::lang::XMultiServiceFactory* >(pServiceManager), css::uno::UNO_QUERY);
::rtl::OUString sImplName = ::rtl::OUString::createFromAscii(pImplName);
if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) ) )
SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
const sal_Char **ppEnvTypeName, uno_Environment ** )
{
css::uno::Sequence< ::rtl::OUString > lNames(1);
lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYLISTENER_IMPLEMENTATIONNAME ) );
xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyListener::st_createInstance, lNames);
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
else
if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MYPROTOCOLHANDLER_IMPLEMENTATIONNAME ) ) )
SAL_DLLPUBLIC_EXPORT void *SAL_CALL component_getFactory(
const sal_Char *pImplName, void *pServiceManager, void *pRegistryKey )
{
css::uno::Sequence< ::rtl::OUString > lNames(1);
lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( MYPROTOCOLHANDLER_SERVICENAME ) );
xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyProtocolHandler_createInstance, lNames);
return ::cppu::component_getFactoryHelper( pImplName,
pServiceManager,
pRegistryKey ,
framework::complex_toolbar_controls::s_impl_entries );
}
if (!xFactory.is())
return 0;
xFactory->acquire();
return xFactory.get();
}
} // extern C
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment