Author: arielch
Date: Fri Jan 4 19:57:52 2013
New Revision: 1429071
URL: http://svn.apache.org/viewvc?rev=1429071&view=rev
Log:
i121578 - Convert css.system.SystemShellExectue to new-style
While at it, remove unused code from the complex toolbar controls
example.
Removed:
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/CalcListener.cxx
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyJob.cxx
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyJob.h
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyListener.cxx
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyListener.h
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/WriterListener.cxx
Modified:
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/Makefile
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/exports.cxx
Modified: openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/Makefile
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/Makefile?rev=1429071&r1=1429070&r2=1429071&view=diff
==============================================================================
--- openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/Makefile
(original)
+++ openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/Makefile Fri
Jan 4 19:57:52 2013
@@ -44,10 +44,6 @@ COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_N
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
--------------------------------------------------------------------------------
Modified:
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx?rev=1429071&r1=1429070&r2=1429071&view=diff
==============================================================================
---
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
(original)
+++
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
Fri Jan 4 19:57:52 2013
@@ -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 MyProtoc
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 MyP
#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( co
{
// 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
}
}
-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 Refere
BaseDispatch::~BaseDispatch()
{
mxFrame.clear();
- mxMSF.clear();
+ mxContext.clear();
}
Modified:
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h?rev=1429071&r1=1429070&r2=1429071&view=diff
==============================================================================
---
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
(original)
+++
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
Fri Jan 4 19:57:52 2013
@@ -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::W
>
{
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_supp
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::WeakIm
{
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" ) ) )
{}
};
Modified:
openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/exports.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/exports.cxx?rev=1429071&r1=1429070&r2=1429071&view=diff
==============================================================================
--- openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/exports.cxx
(original)
+++ openoffice/trunk/main/odk/examples/cpp/complextoolbarcontrols/exports.cxx
Fri Jan 4 19:57:52 2013
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* 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
@@ -7,110 +7,56 @@
* 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 <cppuhelper/factory.hxx>
-
#include "MyProtocolHandler.h"
-#include "MyListener.h"
-namespace css = ::com::sun::star;
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
-#if 0
-static void writeInfo(const css::uno::Reference< css::registry::XRegistryKey
>& xRegistryKey ,
- const char*
pImplementationName,
- const char*
pServiceName )
+namespace framework
{
- ::rtl::OUStringBuffer sKey(256);
- sKey.append (::rtl::OUString::createFromAscii(pImplementationName));
- sKey.appendAscii("/UNO/SERVICES/");
- sKey.append (::rtl::OUString::createFromAscii(pServiceName));
-
- xRegistryKey->createKey(sKey.makeStringAndClear());
+ namespace complex_toolbar_controls
+ {
+ static ::cppu::ImplementationEntry const s_impl_entries[] =
+ {
+ {
+ MyProtocolHandler_createInstance,
+ MyProtocolHandler_getImplementationName,
+ MyProtocolHandler_getSupportedServiceNames,
+ ::cppu::createSingleComponentFactory,
+ 0,
+ 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+ }
}
-#endif
extern "C"
{
-//==================================================================================================
-SAL_DLLPUBLIC_EXPORT void SAL_CALL
component_getImplementationEnvironment(const sal_Char** ppEnvTypeName,
-
uno_Environment** ppEnv )
-{
- *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
-}
-
-#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
)
-{
- if (!pRegistryKey)
- return sal_False;
-
- try
+ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName, uno_Environment ** )
{
- 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;
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
- 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 )
-{
- 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 ) ) )
- {
- 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);
- }
- else
- if (sImplName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
MYPROTOCOLHANDLER_IMPLEMENTATIONNAME ) ) )
- {
- css::uno::Sequence< ::rtl::OUString > lNames(1);
- lNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
MYPROTOCOLHANDLER_SERVICENAME ) );
- xFactory = ::cppu::createSingleFactory(xSMGR, sImplName,
MyProtocolHandler_createInstance, lNames);
- }
-
- if (!xFactory.is())
- return 0;
-
- xFactory->acquire();
- return xFactory.get();
+ SAL_DLLPUBLIC_EXPORT void *SAL_CALL component_getFactory(
+ const sal_Char *pImplName, void *pServiceManager, void *pRegistryKey )
+ {
+ return ::cppu::component_getFactoryHelper( pImplName,
+ pServiceManager,
+ pRegistryKey ,
+ framework::complex_toolbar_controls::s_impl_entries );
+ }
}
-
-} // extern C