summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-12-10 15:18:05 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-12-10 18:06:38 +0100
commit572b0c700c783d32becd758184417f43e2db0757 (patch)
tree4b73da8a19be01ca7ac3eaacc64159cac36a70dc /odk
parentb2cb6e5e6f30640a243ac9c8b824548e022b96ab (diff)
Fix SDK example
Change-Id: I3d31e0ad7e5015340a045230678760e3b20c59a1 (cherry picked from commit ad2e7f5be349627326ba92a565692f0ee955f44f)
Diffstat (limited to 'odk')
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx39
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h24
-rw-r--r--odk/examples/cpp/complextoolbarcontrols/exports.cxx4
3 files changed, 31 insertions, 36 deletions
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
index c149167d2ee4..efa527c89027 100644
--- a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
+++ b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx
@@ -22,15 +22,15 @@
#include "MyProtocolHandler.h"
#include <com/sun/star/awt/MessageBoxButtons.hpp>
+#include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/awt/XMessageBoxFactory.hpp>
#include <com/sun/star/frame/ControlCommand.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/system/XSystemShellExecute.hpp>
-#include <compphelper/componentcontext.hxx>
-
using namespace com::sun::star::awt;
using namespace com::sun::star::frame;
using namespace com::sun::star::system;
@@ -38,7 +38,6 @@ 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::sheet::XSpreadsheetView;
using com::sun::star::text::XTextViewCursorSupplier;
using com::sun::star::util::URL;
@@ -48,7 +47,7 @@ ListenerHelper aListenerHelper;
void BaseDispatch::ShowMessageBox( const Reference< XFrame >& rFrame, const ::rtl::OUString& aTitle, const ::rtl::OUString& aMsgText )
{
if ( !mxToolkit.is() )
- mxToolkit = Reference< XToolkit > ( Toolkit::create(comphelper::getComponentContext(mxMSF)), UNO_QUERY_THROW );
+ mxToolkit = Toolkit::create(mxContext);
Reference< XMessageBoxFactory > xMsgBoxFactory( mxToolkit, UNO_QUERY );
if ( rFrame.is() && xMsgBoxFactory.is() )
{
@@ -141,8 +140,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 );
}
}
@@ -186,7 +185,7 @@ 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 > & rSMgr)
throw( Exception )
{
return (cppu::OWeakObject*) new MyProtocolHandler( rSMgr );
@@ -228,19 +227,15 @@ void SAL_CALL BaseDispatch::dispatch( const URL& aURL, const Sequence < Property
{
// open the LibreOffice web page
::rtl::OUString sURL("http://www.libreoffice.org");
- Reference< XSystemShellExecute > xSystemShellExecute( mxMSF->createInstance(
- "com.sun.star.system.SystemShellExecute"), UNO_QUERY );
- if ( xSystemShellExecute.is() )
+ Reference< XSystemShellExecute > xSystemShellExecute(
+ SystemShellExecute::create(mxContext) );
+ try
{
- try
-
- {
- xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::URIS_ONLY );
- }
- catch( Exception& rEx )
- {
- (void)rEx;
- }
+ xSystemShellExecute->execute( sURL, ::rtl::OUString(), SystemShellExecuteFlags::URIS_ONLY );
+ }
+ catch( Exception& rEx )
+ {
+ (void)rEx;
}
}
else if ( aURL.Path == "ComboboxCmd" )
@@ -496,10 +491,10 @@ 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 )
@@ -510,7 +505,7 @@ BaseDispatch::BaseDispatch( const Reference< XMultiServiceFactory > &rxMSF,
BaseDispatch::~BaseDispatch()
{
mxFrame.clear();
- mxMSF.clear();
+ mxContext.clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
index 25817f6ef75c..54c5b8a7cdc9 100644
--- a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
+++ b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h
@@ -20,7 +20,7 @@
#ifndef _MyProtocolHandler_HXX
#define _MyProtocolHandler_HXX
-#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/awt/XToolkit2.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -56,12 +56,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 >
@@ -96,7 +96,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
@@ -107,14 +107,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::awt::XToolkit > mxToolkit;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit2 > 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();
@@ -140,18 +140,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" ) ) )
{}
};
diff --git a/odk/examples/cpp/complextoolbarcontrols/exports.cxx b/odk/examples/cpp/complextoolbarcontrols/exports.cxx
index f1dd0b8e37e6..09ab4ceb6cf4 100644
--- a/odk/examples/cpp/complextoolbarcontrols/exports.cxx
+++ b/odk/examples/cpp/complextoolbarcontrols/exports.cxx
@@ -32,7 +32,7 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplNa
if ( !pServiceManager || !pImplName )
return 0;
- css::uno::Reference< css::lang::XSingleServiceFactory > xFactory ;
+ css::uno::Reference< css::uno::XInterface > 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);
@@ -46,7 +46,7 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(const sal_Char* pImplNa
{
css::uno::Sequence< ::rtl::OUString > lNames(1);
lNames[0] = MYPROTOCOLHANDLER_SERVICENAME;
- xFactory = ::cppu::createSingleFactory(xSMGR, sImplName, MyProtocolHandler_createInstance, lNames);
+ xFactory = ::cppu::createSingleComponentFactory(MyProtocolHandler_createInstance, sImplName, lNames);
}
if (!xFactory.is())