diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-12-11 18:05:45 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-12-11 18:07:15 +0100 |
commit | f4536fafffbf62b16c8c4115b0302223438e6476 (patch) | |
tree | f76df4ea25e1322d3f7c5daabf0914804dcf9971 | |
parent | b44bf22ae9c1602d8ff38d90068f6e553dfdc7c5 (diff) |
Fix SDK examples
Change-Id: I0a3153bc3fa8338a1a0865db2fbe65a56ae064a4
(cherry picked from commit 693332c0b4a8e340b8350f548dce07456975531a)
8 files changed, 72 insertions, 84 deletions
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx index fb35eeda7321..8fac61698cca 100644 --- a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx @@ -36,8 +36,6 @@ #include <addon.hxx> #include <osl/diagnose.h> #include <rtl/ustring.hxx> -#include <comphelper/componentcontext.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XController.hpp> @@ -45,12 +43,12 @@ #include <com/sun/star/awt/XWindowPeer.hpp> #include <com/sun/star/awt/WindowAttribute.hpp> #include <com/sun/star/awt/XMessageBox.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> using rtl::OUString; using namespace com::sun::star::uno; using namespace com::sun::star::frame; using namespace com::sun::star::awt; -using com::sun::star::lang::XMultiServiceFactory; using com::sun::star::beans::PropertyValue; using com::sun::star::util::URL; @@ -105,7 +103,7 @@ void SAL_CALL Addon::initialize( const Sequence< Any >& aArguments ) throw ( Exc } // Create the toolkit to have access to it later - mxToolkit = Reference< XToolkit >( Toolkit::create(comphelper::getComponentContext(mxMSF)), UNO_QUERY_THROW ); + mxToolkit = Reference< XToolkit >( Toolkit::create(mxContext), UNO_QUERY_THROW ); } /** @@ -220,10 +218,10 @@ throw (RuntimeException) return aRet; } -Reference< XInterface > SAL_CALL Addon_createInstance( const Reference< XMultiServiceFactory > & rSMgr) +Reference< XInterface > SAL_CALL Addon_createInstance( const Reference< XComponentContext > & rContext) throw( Exception ) { - return (cppu::OWeakObject*) new Addon( rSMgr ); + return (cppu::OWeakObject*) new Addon( rContext ); } //################################################################################################## diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx index f2e4a0f4a08e..9568aeae24db 100644 --- a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx @@ -57,6 +57,10 @@ namespace com { class XToolkit; } + namespace uno + { + class XComponentContext; + } } } } @@ -70,13 +74,13 @@ class Addon : public cppu::WeakImplHelper4 > { 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; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit; public: - Addon( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} + Addon( 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 > @@ -120,7 +124,7 @@ sal_Bool SAL_CALL Addon_supportsService( const ::rtl::OUString& ServiceName ) throw ( ::com::sun::star::uno::RuntimeException ); ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL Addon_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) +SAL_CALL Addon_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext) throw ( ::com::sun::star::uno::Exception ); #endif // _Addon_HXX diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx index 4efca05638c1..164cf6454d19 100644 --- a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx @@ -38,8 +38,7 @@ #include <cppuhelper/queryinterface.hxx> // helper for queryInterface() impl #include <cppuhelper/factory.hxx> // helper for component factory // generated c++ interfaces -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/registry/XRegistryKey.hpp> @@ -105,16 +104,15 @@ using namespace ::com::sun::star::registry; * @param pRegistryKey the registry key for this component, need for persistent data * @return a component factory */ -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey) +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * /*pServiceManager*/, void * pRegistryKey) { void * pRet = 0; if (rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0) { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ), + Reference< XSingleComponentFactory > xFactory( createSingleComponentFactory( Addon_createInstance, + OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ), Addon_getSupportedServiceNames() ) ); if (xFactory.is()) diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java index a5fd9694274d..758835579bb5 100644 --- a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java +++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java @@ -203,35 +203,31 @@ public class ProtocolHandlerAddon { } public void showMessageBox(String sTitle, String sMessage) { - try { - if ( null != m_xFrame && null != m_xToolkit ) { - - // describe window properties. - WindowDescriptor aDescriptor = new WindowDescriptor(); - aDescriptor.Type = WindowClass.MODALTOP; - aDescriptor.WindowServiceName = new String( "infobox" ); - aDescriptor.ParentIndex = -1; - aDescriptor.Parent = (XWindowPeer)UnoRuntime.queryInterface( - XWindowPeer.class, m_xFrame.getContainerWindow()); - aDescriptor.Bounds = new Rectangle(0,0,300,200); - aDescriptor.WindowAttributes = WindowAttribute.BORDER | - WindowAttribute.MOVEABLE | - WindowAttribute.CLOSEABLE; - - XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); - if ( null != xPeer ) { - XMessageBox xMsgBox = (XMessageBox)UnoRuntime.queryInterface( - XMessageBox.class, xPeer); - if ( null != xMsgBox ) - { - xMsgBox.setCaptionText( sTitle ); - xMsgBox.setMessageText( sMessage ); - xMsgBox.execute(); - } + if ( null != m_xFrame && null != m_xToolkit ) { + + // describe window properties. + WindowDescriptor aDescriptor = new WindowDescriptor(); + aDescriptor.Type = WindowClass.MODALTOP; + aDescriptor.WindowServiceName = new String( "infobox" ); + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = (XWindowPeer)UnoRuntime.queryInterface( + XWindowPeer.class, m_xFrame.getContainerWindow()); + aDescriptor.Bounds = new Rectangle(0,0,300,200); + aDescriptor.WindowAttributes = WindowAttribute.BORDER | + WindowAttribute.MOVEABLE | + WindowAttribute.CLOSEABLE; + + XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); + if ( null != xPeer ) { + XMessageBox xMsgBox = (XMessageBox)UnoRuntime.queryInterface( + XMessageBox.class, xPeer); + if ( null != xMsgBox ) + { + xMsgBox.setCaptionText( sTitle ); + xMsgBox.setMessageText( sMessage ); + xMsgBox.execute(); } } - } catch ( com.sun.star.uno.Exception e) { - // do your error handling } } } diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx index c3eabe23b8a9..606c8385f7c0 100644 --- a/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx +++ b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx @@ -36,7 +36,7 @@ #include <osl/interlck.h> #include <osl/mutex.hxx> #include <rtl/uuid.h> -#include <rtl/instance.hpp> +#include <rtl/instance.hxx> #include <cppuhelper/factory.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -181,15 +181,15 @@ namespace private: ::com::sun::star::uno::Sequence< sal_Int8 > m_aSeq; public: - UniqueIdInitIdInit() : m_aSeq(16) + UniqueIdInit() : m_aSeq(16) { rtl_createUuid( (sal_uInt8*)m_aSeq.getArray(), 0, sal_True ); } const ::com::sun::star::uno::Sequence< sal_Int8 >& getSeq() const { return m_aSeq; } }; - //A multi-thread safe UniqueIdInitIdInit singleton wrapper + //A multi-thread safe UniqueIdInit singleton wrapper class theService1ImplImplementationId - : public rtl::Static< UniqueIdInitIdInit, + : public rtl::Static< UniqueIdInit, theService1ImplImplementationId > { }; diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java index d654882b1eac..146aef4cf342 100644 --- a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java +++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java @@ -250,35 +250,31 @@ public class DialogComponent { } public void showMessageBox(String sTitle, String sMessage) { - try { - if ( null != m_xFrame && null != m_xToolkit ) { - - // describe window properties. - WindowDescriptor aDescriptor = new WindowDescriptor(); - aDescriptor.Type = WindowClass.MODALTOP; - aDescriptor.WindowServiceName = new String( "infobox" ); - aDescriptor.ParentIndex = -1; - aDescriptor.Parent = (XWindowPeer)UnoRuntime.queryInterface( - XWindowPeer.class, m_xFrame.getContainerWindow()); - aDescriptor.Bounds = new Rectangle(0,0,300,200); - aDescriptor.WindowAttributes = WindowAttribute.BORDER | - WindowAttribute.MOVEABLE | - WindowAttribute.CLOSEABLE; - - XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); - if ( null != xPeer ) { - XMessageBox xMsgBox = (XMessageBox)UnoRuntime.queryInterface( - XMessageBox.class, xPeer); - if ( null != xMsgBox ) - { - xMsgBox.setCaptionText( sTitle ); - xMsgBox.setMessageText( sMessage ); - xMsgBox.execute(); - } + if ( null != m_xFrame && null != m_xToolkit ) { + + // describe window properties. + WindowDescriptor aDescriptor = new WindowDescriptor(); + aDescriptor.Type = WindowClass.MODALTOP; + aDescriptor.WindowServiceName = new String( "infobox" ); + aDescriptor.ParentIndex = -1; + aDescriptor.Parent = (XWindowPeer)UnoRuntime.queryInterface( + XWindowPeer.class, m_xFrame.getContainerWindow()); + aDescriptor.Bounds = new Rectangle(0,0,300,200); + aDescriptor.WindowAttributes = WindowAttribute.BORDER | + WindowAttribute.MOVEABLE | + WindowAttribute.CLOSEABLE; + + XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor ); + if ( null != xPeer ) { + XMessageBox xMsgBox = (XMessageBox)UnoRuntime.queryInterface( + XMessageBox.class, xPeer); + if ( null != xMsgBox ) + { + xMsgBox.setCaptionText( sTitle ); + xMsgBox.setMessageText( sMessage ); + xMsgBox.execute(); } } - } catch ( com.sun.star.uno.Exception e) { - // do your error handling } } } diff --git a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java index f88d5b662115..113b7043e08c 100644 --- a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java +++ b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java @@ -167,16 +167,10 @@ public class ButtonOperator implements XActionListener, XFeatureInvalidation */ public void onFormsAlive() { - try - { - m_formOperations = FormOperations.createWithFormController( - m_componentContext, m_aDocument.getCurrentView().getFormController( m_form ) ); - m_formOperations.setFeatureInvalidation( this ); - invalidateAllFeatures(); - } - catch( final com.sun.star.uno.Exception e ) - { - } + m_formOperations = FormOperations.createWithFormController( + m_componentContext, m_aDocument.getCurrentView().getFormController( m_form ) ); + m_formOperations.setFeatureInvalidation( this ); + invalidateAllFeatures(); } /* ================================================================== diff --git a/odk/examples/java/ToDo/ToDo.java b/odk/examples/java/ToDo/ToDo.java index 98ece6192583..b85541ad6e09 100644 --- a/odk/examples/java/ToDo/ToDo.java +++ b/odk/examples/java/ToDo/ToDo.java @@ -40,6 +40,8 @@ import com.sun.star.lang.XServiceInfo; import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; +import org.openoffice.*; + // addintional interfaces used by the implementation import com.sun.star.sheet.XSpreadsheetDocument; import com.sun.star.sheet.XSpreadsheet; |