odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx | 39 ++++------ odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.h | 24 +++--- odk/examples/cpp/complextoolbarcontrols/exports.cxx | 4 - sal/inc/osl/diagnose.h | 4 + 4 files changed, 35 insertions(+), 36 deletions(-)
New commits: commit 572b0c700c783d32becd758184417f43e2db0757 Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Dec 10 15:18:05 2012 +0100 Fix SDK example Change-Id: I3d31e0ad7e5015340a045230678760e3b20c59a1 (cherry picked from commit ad2e7f5be349627326ba92a565692f0ee955f44f) diff --git a/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx b/odk/examples/cpp/complextoolbarcontrols/MyProtocolHandler.cxx index c149167..efa527c 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 25817f6..54c5b8a 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 f1dd0b8..09ab4ce 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()) commit b2cb6e5e6f30640a243ac9c8b824548e022b96ab Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Dec 10 15:15:08 2012 +0100 Do not fail for unset OSL_DEBUG_LEVEL (as happens in SDK) Change-Id: I0e9b8a251ed790d1505566ef4fa991309986522d (cherry picked from commit f2609cc70fa4bb62a7ae876e97a3c7003bc1e99b) diff --git a/sal/inc/osl/diagnose.h b/sal/inc/osl/diagnose.h index eb52b20..b3bfee9 100644 --- a/sal/inc/osl/diagnose.h +++ b/sal/inc/osl/diagnose.h @@ -83,6 +83,10 @@ OSL_DEBUG_ONLY(expr) */ +#if !defined OSL_DEBUG_LEVEL +#define OSL_DEBUG_LEVEL 0 +#endif + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits