diff options
Diffstat (limited to 'extensions/source/plugin/inc/plugin')
-rw-r--r-- | extensions/source/plugin/inc/plugin/aqua/sysplug.hxx | 167 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/impl.hxx | 430 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/model.hxx | 136 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/multiplx.hxx | 167 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/plcom.hxx | 85 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/plctrl.hxx | 181 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/unx/mediator.hxx | 183 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/unx/plugcon.hxx | 251 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/unx/sysplug.hxx | 83 | ||||
-rw-r--r-- | extensions/source/plugin/inc/plugin/win/sysplug.hxx | 125 |
10 files changed, 1808 insertions, 0 deletions
diff --git a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx new file mode 100644 index 000000000000..941725b1f53d --- /dev/null +++ b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __PLUGIN_INC_MACPLUG_HXX +#define __PLUGIN_INC_MACPLUG_HXX + +#include <unistd.h> + +#include <list> +#include <map> +#include <algorithm> +#include "premac.h" +#include <Carbon/Carbon.h> +#include <Security/cssmconfig.h> +#include "postmac.h" +#undef uint32 + +#define XP_MAC +#include "npsdk/npapi.h" +#include "npsdk/npupp.h" + +#include "plugin/plcom.hxx" +#include "premac.h" +#include <Cocoa/Cocoa.h> +#include "postmac.h" + +#include "vcl/sysdata.hxx" +#include "vcl/threadex.hxx" +#include "vcl/timer.hxx" +#include "osl/module.h" + +class XPlugin_Impl; + +namespace plugstringhelper +{ +rtl::OUString getString( CFStringRef i_xString ); +rtl::OUString getString( CFURLRef i_xURL ); +CFMutableStringRef createString( const rtl::OUString& i_rString ); +CFURLRef createURL( const rtl::OUString& i_rString ); +rtl::OUString getURLFromPath( const rtl::OUString& i_rPath ); +CFURLRef createURLFromPath( const rtl::OUString& i_rPath ); +rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL ); +} + +//================================================================================================== +class MacPluginComm : + public PluginComm, + public ::vcl::SolarThreadExecutor + +{ + enum CallType { + eNPP_Destroy, + eNPP_DestroyStream, + eNPP_GetJavaClass, + eNPP_Initialize, + eNPP_New, + eNPP_NewStream, + eNPP_Print, + eNPP_SetWindow, + eNPP_Shutdown, + eNPP_StreamAsFile, + eNPP_URLNotify, + eNPP_Write, + eNPP_WriteReady, + eNPP_GetValue, + eNPP_SetValue, + eNPP_HandleEvent, + eNP_Initialize + }; + + void* m_aArgs[ 8 ]; + CallType m_eCall; + + virtual long doIt(); +public: + MacPluginComm( const rtl::OUString& rMIME, const rtl::OUString& rName, NSView* pView ); + virtual ~MacPluginComm(); + + // FIXME: + // this actually should be from the NP headers + // but currently we have too old a version + // changes this when we have updated our headers + typedef struct NP_CGContext + { + CGContextRef context; + WindowRef window; + } NP_CGContext; + +public: + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); + virtual void * NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, + NPReason reason, void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *ret_value ); + virtual int16 NPP_HandleEvent( NPP instance, void* event ); + + virtual NPError NPP_SetWindow( XPlugin_Impl* ); + virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save ); + + void drawView( XPlugin_Impl* ); +private: + BOOL retrieveFunction( const char* i_pName, void** i_ppFunc ) const; + DECL_LINK( NullTimerHdl, void* ); + +private: + CFBundleRef m_xBundle; + oslModule m_hPlugLib; + NPPluginFuncs m_aNPPfuncs; + + // timer for sending nullEvents + AutoTimer* m_pNullTimer; + std::list< XPlugin_Impl* > m_aNullEventClients; +}; + +struct SysPlugData +{ + MacPluginComm::NP_CGContext m_aCGContext; + NP_Port m_aNPPort; + NSView* m_pParentView; + NSView* m_pPlugView; + int m_nDrawingModel; + NSPoint m_aLastPlugViewOrigin; + bool m_bSetWindowOnDraw; +}; + + + +#endif + + diff --git a/extensions/source/plugin/inc/plugin/impl.hxx b/extensions/source/plugin/inc/plugin/impl.hxx new file mode 100644 index 000000000000..6aa7ec7cca14 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/impl.hxx @@ -0,0 +1,430 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __PLUGIN_SOURCE_MGR_IMPL_HXX +#define __PLUGIN_SOURCE_MGR_IMPL_HXX + +#ifdef SOLARIS +#include <limits> +#endif + +#include "cppuhelper/weak.hxx" + +#include "com/sun/star/awt/Key.hpp" +#include "com/sun/star/awt/KeyFunction.hpp" +#include "com/sun/star/beans/PropertyAttribute.hpp" +#include "com/sun/star/plugin/PluginMode.hpp" +#include "com/sun/star/plugin/PluginDescription.hpp" +#include "com/sun/star/plugin/PluginException.hpp" +#include "com/sun/star/plugin/PluginVariable.hpp" +#include "com/sun/star/plugin/XPlugin.hpp" +#include "com/sun/star/plugin/XPluginManager.hpp" +#include "com/sun/star/plugin/XPluginContext.hpp" +#include "com/sun/star/io/XConnectable.hpp" +#include "com/sun/star/io/XOutputStream.hpp" +#include "com/sun/star/io/XDataOutputStream.hpp" +#include "com/sun/star/io/XActiveDataControl.hpp" +#include "com/sun/star/io/XDataInputStream.hpp" +#include "com/sun/star/io/XMarkableStream.hpp" +#include "com/sun/star/io/XInputStream.hpp" +#include "com/sun/star/io/XStreamListener.hpp" +#include "com/sun/star/io/XActiveDataSink.hpp" +#include "com/sun/star/io/XActiveDataSource.hpp" +#include "com/sun/star/lang/XServiceName.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/lang/XMultiServiceFactory.hpp" +#include "com/sun/star/lang/XSingleServiceFactory.hpp" +#include "com/sun/star/awt/GradientStyle.hpp" +#include "com/sun/star/awt/RasterOperation.hpp" +#include "com/sun/star/awt/Gradient.hpp" +#include "com/sun/star/awt/XGraphics.hpp" + +#include "cppuhelper/implbase3.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/implbase1.hxx" + +#include <list> + +#ifdef WNT +#include "plugin/win/sysplug.hxx" +#endif + +#ifdef WNT +#include <plugin/win/sysplug.hxx> +#elif defined(OS2) +#include "plugin/os2/sysplug.hxx" +#elif defined(QUARTZ) +#include "plugin/aqua/sysplug.hxx" +#elif defined(UNX) +#include "plugin/unx/sysplug.hxx" +#endif + +#if ! defined (QUARTZ) +// the QUARTZ implementation needs special instance data +typedef int SysPlugData; +#endif + +#include "plugin/plctrl.hxx" +#include "plugin/model.hxx" + +#include "vcl/sysdata.hxx" +#include "vcl/syschild.hxx" + +#include "tools/link.hxx" +#include "tools/stream.hxx" + + +using namespace com::sun::star::uno; + +#define PROVIDING_NONE 0 +#define PROVIDING_NOW 1 +#define PROVIDING_MODEL_UPDATE 2 + +// forwards +namespace ucbhelper { class Content; } +class PluginStream; +class PluginInputStream; +class PluginOutputStream; +class XPlugin_Impl; +class PluginDisposer; +class PluginEventListener; + +class XPlugin_Impl : public com::sun::star::plugin::XPlugin, + public PluginControl_Impl, + public com::sun::star::beans::XPropertyChangeListener +{ +private: + ::osl::Mutex m_aMutex; + Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + Reference< com::sun::star::plugin::XPluginContext > m_rBrowserContext; + + PluginComm* m_pPluginComm; + NPP_t m_aInstance; + NPWindow m_aNPWindow; + SysPlugData m_aSysPlugData; + rtl_TextEncoding m_aEncoding; + + const char** m_pArgv; + const char** m_pArgn; + int m_nArgs; + rtl::OString m_aLastGetUrl; + + Reference< com::sun::star::awt::XControlModel > m_xModel; + + ::com::sun::star::plugin::PluginDescription m_aDescription; + sal_Int16 m_aPluginMode; + + int m_nProvidingState; + int m_nCalledFromPlugin; + PluginDisposer* m_pDisposer; + + ::std::list<PluginInputStream*> m_aInputStreams; + ::std::list<PluginOutputStream*> m_aOutputStreams; + ::std::list<PluginEventListener*> m_aPEventListeners; + ::rtl::OUString m_aURL; + + sal_Bool m_bIsDisposed; + + void prependArg( const char* pName, const char* pValue ); // arguments will be strdup'ed + void initArgs( const Sequence< rtl::OUString >& argn, + const Sequence< rtl::OUString >& argv, + sal_Int16 mode ); + void freeArgs(); + void handleSpecialArgs(); + + void loadPlugin(); + void destroyInstance(); + void modelChanged(); + +public: + XPlugin_Impl( const Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr ); + virtual ~XPlugin_Impl(); + + ::osl::Mutex& getMutex() { return m_aMutex; } + + void destroyStreams(); + + void setLastGetUrl( const rtl::OString& rUrl ) { m_aLastGetUrl = rUrl; } + + com::sun::star::plugin::PluginDescription fitDescription( const rtl::OUString& rURL ); + + ::std::list<PluginInputStream*>& getInputStreams() { return m_aInputStreams; } + ::std::list<PluginOutputStream*>& getOutputStreams() { return m_aOutputStreams; } + PluginComm* getPluginComm() { return m_pPluginComm; } + void setPluginComm( PluginComm* comm ) + { + if( ! m_pPluginComm ) + { + m_pPluginComm = comm; + m_pPluginComm->addRef(); + } + } + Reference< com::sun::star::lang::XMultiServiceFactory > getServiceManager() { return m_xSMgr; } + const com::sun::star::plugin::PluginDescription& getDescription() const { return m_aDescription; } + rtl_TextEncoding getTextEncoding() { return m_aEncoding; } + NPP getNPPInstance() { return &m_aInstance; } + NPWindow* getNPWindow() { return &m_aNPWindow; } + SysPlugData& getSysPlugData() { return m_aSysPlugData; } + + void enterPluginCallback() { m_nCalledFromPlugin++; } + void leavePluginCallback() { m_nCalledFromPlugin--; } + sal_Bool isDisposable() { return m_nCalledFromPlugin < 1 ? sal_True : sal_False; } + DECL_LINK( secondLevelDispose, XPlugin_Impl* ); + + void addPluginEventListener( PluginEventListener* pListener ) + { m_aPEventListeners.push_back( pListener ); } + void checkListeners( const char* normalizedURL ); + + void initInstance( + const com::sun::star::plugin::PluginDescription& rDescription, + const Sequence< rtl::OUString >& argn, + const Sequence< rtl::OUString >& argv, + sal_Int16 mode ); + void initInstance( + const rtl::OUString& rURL, + const Sequence< rtl::OUString >& argn, + const Sequence< rtl::OUString >& argv, + sal_Int16 mode ); + + const rtl::OUString& getRefererURL() { return m_aURL; } + ::rtl::OUString getCreationURL(); + + PluginStream* getStreamFromNPStream( NPStream* ); + + const SystemEnvData* getSysChildSysData() + { return _pSysChild->GetSystemData(); } + + const Reference< com::sun::star::plugin::XPluginContext > & getPluginContext() const + { return m_rBrowserContext; } + void setPluginContext( const Reference< com::sun::star::plugin::XPluginContext > & ); + + void secondLevelDispose(); + +// static const Reference< com::sun::star::reflection::XIdlClass > & staticGetIdlClass(); + + // XInterface + virtual Any SAL_CALL queryInterface( const Type& ) throw( com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() throw() + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw() + { OWeakAggObject::release(); } + + // OWeakAggObject + virtual Any SAL_CALL queryAggregation( const Type& ) + throw( com::sun::star::uno::RuntimeException ); + + // PluginContol_Impl + virtual void SAL_CALL dispose() throw(); + virtual void SAL_CALL createPeer( const Reference< com::sun::star::awt::XToolkit > & xToolkit, const Reference< com::sun::star::awt::XWindowPeer > & Parent) throw( RuntimeException ); + + virtual sal_Bool SAL_CALL setModel( const Reference< com::sun::star::awt::XControlModel > & Model ) throw( RuntimeException ); + virtual Reference< com::sun::star::awt::XControlModel > SAL_CALL getModel()throw( RuntimeException ) + { return m_xModel; } + + virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( RuntimeException ); + + // com::sun::star::plugin::XPlugin + virtual sal_Bool SAL_CALL provideNewStream(const rtl::OUString& mimetype, const Reference< com::sun::star::io::XActiveDataSource > & stream, const rtl::OUString& url, sal_Int32 length, sal_Int32 lastmodified, sal_Bool isfile) throw(); + + // com::sun::star::beans::XPropertyChangeListener + virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& rSource ) throw(); + virtual void SAL_CALL propertyChange( const com::sun::star::beans::PropertyChangeEvent& rEvent ) throw(); +}; + +class PluginManager +{ +private: + Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + ::std::list<PluginComm*> m_aPluginComms; + ::std::list<XPlugin_Impl*> m_aAllPlugins; + ::osl::Mutex m_aPluginMutex; + + static PluginManager* pManager; + + PluginManager(); +public: + + static PluginManager& get(); + static void setServiceFactory( const Reference< com::sun::star::lang::XMultiServiceFactory >& xFactory ); + static const Sequence< rtl::OUString >& getAdditionalSearchPaths(); + + ::std::list<PluginComm*>& getPluginComms() { return m_aPluginComms; } + ::std::list<XPlugin_Impl*>& getPlugins() { return m_aAllPlugins; } + ::osl::Mutex& getPluginMutex() { return m_aPluginMutex; } +}; + +class XPluginManager_Impl : + public cppu::WeakAggImplHelper1< com::sun::star::plugin::XPluginManager > +{ + Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr; +public: + XPluginManager_Impl( const Reference< com::sun::star::lang::XMultiServiceFactory > & ); + virtual ~XPluginManager_Impl(); + + static XPlugin_Impl* getXPluginFromNPP( NPP ); + static XPlugin_Impl* getPluginImplementation( const Reference< com::sun::star::plugin::XPlugin >& plugin ); + + virtual Reference< com::sun::star::plugin::XPluginContext > SAL_CALL createPluginContext() throw(); + + // has to be implemented per system + virtual Sequence< com::sun::star::plugin::PluginDescription > SAL_CALL impl_getPluginDescriptions(void) throw(); + // calls system specific impl_getPluginDescriptions + // checks whether plugins are disabled + virtual Sequence< com::sun::star::plugin::PluginDescription > SAL_CALL getPluginDescriptions(void) throw(); + + virtual Reference< com::sun::star::plugin::XPlugin > SAL_CALL createPlugin( const Reference< com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< rtl::OUString >& argn, const Sequence< rtl::OUString >& argv, const com::sun::star::plugin::PluginDescription& plugintype) throw( RuntimeException,::com::sun::star::plugin::PluginException ); + + virtual Reference< com::sun::star::plugin::XPlugin > SAL_CALL createPluginFromURL( const Reference< com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< rtl::OUString >& argn, const Sequence< rtl::OUString >& argv, const Reference< com::sun::star::awt::XToolkit > & toolkit, const Reference< com::sun::star::awt::XWindowPeer > & parent, const rtl::OUString& url ) throw(); + + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw(); + virtual rtl::OUString SAL_CALL getImplementationName() throw(); + + Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ); + static Sequence< rtl::OUString > getSupportedServiceNames_Static(void) throw( ); + static rtl::OUString getImplementationName_Static() throw( ) + { + /** the soplayer uses this name in its source! maybe not after 5.2 */ + return rtl::OUString::createFromAscii( "com.sun.star.extensions.PluginManager" ); + } +}; +Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception ); + +enum PluginStreamType { InputStream, OutputStream }; + +class PluginStream +{ +protected: + XPlugin_Impl* m_pPlugin; + NPStream m_aNPStream; +public: + PluginStream( XPlugin_Impl* pPlugin, + const char* url, sal_uInt32 len, sal_uInt32 lastmod ); + virtual ~PluginStream(); + + NPStream* getStream() { return &m_aNPStream; } + XPlugin_Impl* getPlugin() { return m_pPlugin; } + + virtual PluginStreamType getStreamType() = 0; +}; + +class PluginInputStream : + public PluginStream, + public cppu::WeakAggImplHelper2< + ::com::sun::star::io::XOutputStream, + ::com::sun::star::io::XConnectable + > +{ +private: + ::ucbhelper::Content* m_pContent; + sal_Int32 m_nMode; + UINT32 m_nWritePos; + + Reference< com::sun::star::io::XActiveDataSource > m_xSource; + // hold a reference on input until closeOutput is called + + Reference< com::sun::star::io::XConnectable > m_xPredecessor; + Reference< com::sun::star::io::XConnectable > m_xSuccessor; + + // needed to hold a reference to self in NP_SEEK mode + Reference< com::sun::star::io::XOutputStream > m_xSelf; + + SvFileStream m_aFileStream; +public: + PluginInputStream( XPlugin_Impl* pPlugin, + const char* url, UINT32 len, UINT32 lastmod ); + + PluginInputStream() : PluginStream( NULL, NULL, 0, 0 ) {} + + virtual ~PluginInputStream(); + + virtual PluginStreamType getStreamType(); + + void setMode( sal_Int32 nMode ); + UINT32 read( UINT32 offset, sal_Int8* buffer, UINT32 size ); + void setSource( const Reference< com::sun::star::io::XActiveDataSource >& xSource ) { m_xSource = xSource; } + // get contents ot url via ucbhelper::Content + void load(); + + // clear reference + bool releaseSelf() + { bool bRet = m_xSelf.is(); m_xSelf.clear(); return bRet; } + + // XOutputStream + virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw(); + virtual void SAL_CALL flush() throw(); + virtual void SAL_CALL closeOutput() throw(); + + // XConnectable + virtual void SAL_CALL setPredecessor( const Reference< com::sun::star::io::XConnectable >& xPredecessor ) throw() + { m_xPredecessor = xPredecessor; } + virtual Reference< com::sun::star::io::XConnectable > SAL_CALL getPredecessor() throw() + { return m_xPredecessor; } + + virtual void SAL_CALL setSuccessor( const Reference< com::sun::star::io::XConnectable >& xSuccessor ) throw() + { m_xSuccessor = xSuccessor; } + virtual Reference< com::sun::star::io::XConnectable > SAL_CALL getSuccessor() throw() + { return m_xSuccessor; } +}; + +class PluginOutputStream : public PluginStream +{ +private: + Reference< com::sun::star::io::XOutputStream > m_xStream; +public: + PluginOutputStream( XPlugin_Impl* pPlugin, const char* url, + sal_uInt32 len, sal_uInt32 lastmod ); + virtual ~PluginOutputStream(); + + virtual PluginStreamType getStreamType(); + + Reference< com::sun::star::io::XOutputStream > & getOutputStream() { return m_xStream; } +}; + +class PluginEventListener : + public cppu::WeakAggImplHelper1< com::sun::star::lang::XEventListener > +{ +private: + XPlugin_Impl* m_pPlugin; + Reference< com::sun::star::plugin::XPlugin > m_xPlugin; // just to hold the plugin + char* m_pUrl; + char* m_pNormalizedUrl; + void* m_pNotifyData; +public: + PluginEventListener( XPlugin_Impl*, + const char* url, + const char* normurl, + void* notifyData ); + virtual ~PluginEventListener(); + + const char* getURL() { return m_pUrl; } + const char* getNormalizedURL() { return m_pNormalizedUrl; } + void* getNotifyData() { return m_pNotifyData; } + + // com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw(); +}; + +#endif diff --git a/extensions/source/plugin/inc/plugin/model.hxx b/extensions/source/plugin/inc/plugin/model.hxx new file mode 100644 index 000000000000..9f9ac01f0ac3 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/model.hxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __PLUGIN_MODEL_HXX +#define __PLUGIN_MODEL_HXX + +#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/io/XObjectOutputStream.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XControl.hpp> + +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/weakagg.hxx> +#include <rtl/alloc.h> + +#include <list> + +using namespace com::sun::star::uno; + +class BroadcasterHelperHolder +{ +protected: + ::cppu::OBroadcastHelper m_aHelper; +public: + BroadcasterHelperHolder( osl::Mutex& rMutex ) : + m_aHelper( rMutex ) {} + ~BroadcasterHelperHolder() {} + + ::cppu::OBroadcastHelper& getHelper() { return m_aHelper; } + +}; + +class PluginModel : public BroadcasterHelperHolder, + public cppu::OPropertySetHelper, + public cppu::OPropertyArrayHelper, + public cppu::OWeakAggObject, + public com::sun::star::lang::XComponent, + public com::sun::star::io::XPersistObject, + public com::sun::star::awt::XControlModel +{ + private: + rtl::OUString m_aCreationURL; + rtl::OUString m_aMimeType; + + std::list< Reference< com::sun::star::lang::XEventListener > > + m_aDisposeListeners; + public: + // these are here to force memory de/allocation to sal lib. + static void * SAL_CALL operator new( size_t nSize ) throw() + { return rtl_allocateMemory( nSize ); } + static void SAL_CALL operator delete( void * pMem ) throw() + { rtl_freeMemory( pMem ); } + + PluginModel(); + PluginModel( const rtl::OUString& rURL, const rtl::OUString& rMimeType ); + virtual ~PluginModel(); + + + const rtl::OUString& getCreationURL() { return m_aCreationURL; } + void setMimeType( const rtl::OUString& rMime ) { m_aMimeType = rMime; } + + // XInterface + virtual Any SAL_CALL queryInterface( const Type& rType ) throw( com::sun::star::uno::RuntimeException ) + { return OWeakAggObject::queryInterface( rType ); } + virtual void SAL_CALL acquire() throw() + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw() + { OWeakAggObject::release(); } + + virtual Any SAL_CALL queryAggregation( const Type& ) throw( com::sun::star::uno::RuntimeException ); + + + // com::sun::star::lang::XTypeProvider + + static Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames_Static(void) throw( ); + static rtl::OUString SAL_CALL getImplementationName_Static() throw( ) + { + /** the soplayer uses this name in its source! maybe not after 5.2 */ + return rtl::OUString::createFromAscii( "com.sun.star.extensions.PluginModel" ); + } + + // OPropertySetHelper + virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + virtual sal_Bool SAL_CALL convertFastPropertyValue( Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue ) throw(); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, + const Any& rValue ) + throw(::com::sun::star::uno::Exception); + virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw(); + virtual Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(); + + // com::sun::star::io::XPersistObject + virtual rtl::OUString SAL_CALL getServiceName() throw(); + virtual void SAL_CALL write(const Reference< com::sun::star::io::XObjectOutputStream > & OutStream) throw(); + virtual void SAL_CALL read(const Reference< com::sun::star::io::XObjectInputStream > & InStream) throw(); + + // com::sun::star::lang::XComponent + virtual void SAL_CALL addEventListener( const Reference< com::sun::star::lang::XEventListener > & l ) throw(); + virtual void SAL_CALL removeEventListener( const Reference< com::sun::star::lang::XEventListener > & l ) throw(); + virtual void SAL_CALL dispose() throw(); + private: + using cppu::OPropertySetHelper::getFastPropertyValue; +}; +Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception ); + +#endif // __PLUGIN_MODEL_HXX diff --git a/extensions/source/plugin/inc/plugin/multiplx.hxx b/extensions/source/plugin/inc/plugin/multiplx.hxx new file mode 100644 index 000000000000..45b60c12313d --- /dev/null +++ b/extensions/source/plugin/inc/plugin/multiplx.hxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _MRC_MULTIPLX_HXX +#define _MRC_MULTIPLX_HXX + +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XKeyListener.hpp> +#include <com/sun/star/awt/XPaintListener.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> +#include <com/sun/star/awt/KeyModifier.hpp> +#include <com/sun/star/awt/XMouseMotionListener.hpp> +#include <com/sun/star/awt/FocusEvent.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/awt/XActivateListener.hpp> +#include <com/sun/star/awt/MouseEvent.hpp> +#include <com/sun/star/awt/XTopWindowListener.hpp> +#include <com/sun/star/awt/PaintEvent.hpp> +#include <com/sun/star/awt/InputEvent.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/WindowEvent.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/KeyFunction.hpp> +#include <com/sun/star/awt/FocusChangeReason.hpp> +#include <com/sun/star/awt/MouseButton.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/PosSize.hpp> + +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/interfacecontainer.hxx> + +using namespace com::sun::star::uno; + +struct MRCListenerMultiplexerHelper_Mutex +{ + ::osl::Mutex aMutex; +}; + +class MRCListenerMultiplexerHelper : + public MRCListenerMultiplexerHelper_Mutex, + + public ::cppu::WeakAggImplHelper7< + ::com::sun::star::awt::XFocusListener, + ::com::sun::star::awt::XWindowListener, + ::com::sun::star::awt::XKeyListener, + ::com::sun::star::awt::XMouseListener, + ::com::sun::star::awt::XMouseMotionListener, + ::com::sun::star::awt::XPaintListener, + ::com::sun::star::awt::XTopWindowListener > +{ +public: + /** + * Create a Multiplexer of XWindowEvents. + * + * @param rControl The control. All listeners think that this is the original + * broadcaster. + * @param rPeer The peer from which the original events are dispatched. Null is + * allowed. + */ + MRCListenerMultiplexerHelper( const Reference< ::com::sun::star::awt::XWindow > & rControl, const Reference< ::com::sun::star::awt::XWindow > & rPeer ); + + /** + * Remove all listeners from the previous set peer and add the needed listeners to rPeer. + * @param rPeer The peer from which the original events are dispatched. Null is + * allowed. + */ + void setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer ); + + /** + * Remove all listeners and send a disposing message. + */ + void disposeAndClear(); + + /** + * Add the specified listener to the source. + */ + void advise( const Type& type, const Reference< XInterface > & listener); + /** + * Remove the specified listener from the source. + */ + void unadvise(const Type& type, const Reference< XInterface > & listener); + + // ::com::sun::star::lang::XEventListener + void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(); + // ::com::sun::star::awt::XFocusListener + void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw(); + void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw(); + // ::com::sun::star::awt::XWindowListener + void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& e) throw(); + void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& e) throw(); + void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& e) throw(); + void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& e) throw(); + // ::com::sun::star::awt::XKeyListener + void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw(); + void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw(); + // ::com::sun::star::awt::XMouseListener + void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw(); + void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw(); + void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw(); + void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw(); + // ::com::sun::star::awt::XMouseMotionListener + void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& e) throw(); + void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& e) throw(); + // ::com::sun::star::awt::XPaintListener + void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& e) throw(); + // ::com::sun::star::awt::XTopWindowListener + void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw(); + void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw(); + void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw(); + void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw(); + void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw(); + void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw(); + void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw(); +protected: + /** + * Remove the listener with the uik rUik from the peer rPeer. + * @param rPeer the peer from which the listener is removed. + * @param rUik the listener uik, which specify the type of the listener. + */ + void adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ); + /** + * Add the listener with the uik rUik to the peer rPeer. + * @param rPeer the peer to which the listener is added. + * @param rUik the listener uik, which specify the type of the listener. + */ + void unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ); +private: + /** The source of the events. Normally this is the peer object.*/ + Reference< ::com::sun::star::awt::XWindow > xPeer; + WeakReference< ::com::sun::star::awt::XControl > xControl; + ::cppu::OMultiTypeInterfaceContainerHelper aListenerHolder; + + + MRCListenerMultiplexerHelper( const MRCListenerMultiplexerHelper & ); + MRCListenerMultiplexerHelper & operator = ( const MRCListenerMultiplexerHelper & ); +}; + +#endif // _MRC_MULTIPLX_HXX + + + diff --git a/extensions/source/plugin/inc/plugin/plcom.hxx b/extensions/source/plugin/inc/plugin/plcom.hxx new file mode 100644 index 000000000000..f0c4d54c02c3 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/plcom.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __PLUGIN_INC_PLCOM_HXX +#define __PLUGIN_INC_PLCOM_HXX + +#include <tools/string.hxx> +#include <list> + +class XPlugin_Impl; + +class PluginComm +{ +protected: + int m_nRefCount; + ::rtl::OString m_aLibName; + std::list< String > m_aFilesToDelete; +public: + PluginComm( const ::rtl::OString& rLibName, bool bReusable = true ); + virtual ~PluginComm(); + + int getRefCount() { return m_nRefCount; } + void addRef() { m_nRefCount++; } + void decRef() { m_nRefCount--; if( ! m_nRefCount ) delete this; } + + const ::rtl::OString& getLibName() { return m_aLibName; } + void setLibName( const ::rtl::OString& rName ) { m_aLibName = rName; } + + void addFileToDelete( const String& filename ) + { m_aFilesToDelete.push_back( filename ); } + + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ) = 0; + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, + NPError reason ) = 0; + virtual void* NPP_GetJavaClass() = 0; + virtual NPError NPP_Initialize() = 0; + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, + uint16 mode, int16 argc, + char* argn[], char* argv[], + NPSavedData *saved ) = 0; + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, + NPStream* stream, + NPBool seekable, uint16* stype ) = 0; + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ) = 0; + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ) = 0; + virtual void NPP_Shutdown() = 0; + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, + const char* fname ) = 0; + virtual void NPP_URLNotify( NPP instance, const char* url, + NPReason reason, void* notifyData ) = 0; + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ) = 0; + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ) = 0; + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ) = 0; + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, + void *value) = 0; + + virtual NPError NPP_SetWindow( XPlugin_Impl* ); + virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save ); +}; + +#endif diff --git a/extensions/source/plugin/inc/plugin/plctrl.hxx b/extensions/source/plugin/inc/plugin/plctrl.hxx new file mode 100644 index 000000000000..1980fa7b6725 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/plctrl.hxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __PLCTRL_HXX +#define __PLCTRL_HXX + +#include <tools/debug.hxx> + +#include <cppuhelper/weak.hxx> +#include <plugin/multiplx.hxx> +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> +#include <com/sun/star/beans/XVetoableChangeListener.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XPropertyStateChangeListener.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertiesChangeListener.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/beans/PropertyStateChangeEvent.hpp> +#include <com/sun/star/beans/PropertyChangeEvent.hpp> +#include <com/sun/star/awt/XVclContainerPeer.hpp> +#include <com/sun/star/awt/XVclWindowPeer.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XUnoControlContainer.hpp> +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> +#include <com/sun/star/awt/XVclContainer.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/awt/PosSize.hpp> + +#include <cppuhelper/implbase4.hxx> + +#include <list> + +class SystemChildWindow; + +//================================================================================================== +class PluginControl_Impl : public ::cppu::WeakAggImplHelper4< + ::com::sun::star::awt::XControl, + ::com::sun::star::awt::XWindow, + ::com::sun::star::awt::XFocusListener, + ::com::sun::star::awt::XView > +{ +public: + // ::com::sun::star::awt::XControl + virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xContext ) throw( ::com::sun::star::uno::RuntimeException ) + { _xContext = xContext; } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getContext() throw( ::com::sun::star::uno::RuntimeException ) + { return _xContext; } + + virtual sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model ) throw( ::com::sun::star::uno::RuntimeException ) = 0; +// { DBG_ERROR( "### setModel() illegal on plugincontrol!" ); return sal_False; } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ) = 0; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > SAL_CALL getView() throw( ::com::sun::star::uno::RuntimeException ) + { return (::com::sun::star::awt::XView*)this; } + + virtual sal_Bool SAL_CALL isTransparent() throw( ::com::sun::star::uno::RuntimeException ) + { return sal_False; } + + virtual void SAL_CALL setDesignMode( sal_Bool bOn ) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL isDesignMode() throw( ::com::sun::star::uno::RuntimeException ) + { return _bInDesignMode; } + + virtual void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & xToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > & Parent) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer() throw( ::com::sun::star::uno::RuntimeException ) + { return _xPeer; } + + // ::com::sun::star::awt::XWindow + virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setEnable( sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setFocus(void) throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize(void) throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) throw( RuntimeException ); + virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject & rSource ) throw( ::com::sun::star::uno::RuntimeException ); + // ::com::sun::star::awt::XFocusListener + virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent & rEvt ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent & rEvt ) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::lang::XComponent + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & l ) throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::awt::XView + virtual sal_Bool SAL_CALL setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > & /*aDevice*/ ) throw( ::com::sun::star::uno::RuntimeException ) + { return sal_False; } + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics(void) throw( ::com::sun::star::uno::RuntimeException ) + { return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > (); } + + virtual ::com::sun::star::awt::Size SAL_CALL getSize(void) throw( ::com::sun::star::uno::RuntimeException ) + { return ::com::sun::star::awt::Size(_nWidth, _nHeight); } + + virtual void SAL_CALL draw( sal_Int32 x, sal_Int32 y ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setZoom( float ZoomX, float ZoomY ) throw( ::com::sun::star::uno::RuntimeException ); + +public: + PluginControl_Impl(); + virtual ~PluginControl_Impl(); + + MRCListenerMultiplexerHelper* getMultiplexer(); + +protected: + void releasePeer(); + +protected: + ::std::list< Reference< ::com::sun::star::lang::XEventListener > > _aDisposeListeners; + MRCListenerMultiplexerHelper* _pMultiplexer; + + Reference< XInterface > _xContext; + + sal_Int32 _nX; + sal_Int32 _nY; + sal_Int32 _nWidth; + sal_Int32 _nHeight; + sal_Int16 _nFlags; + + sal_Bool _bVisible; + sal_Bool _bInDesignMode; + sal_Bool _bEnable; + + SystemChildWindow* _pSysChild; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > _xPeer; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > _xPeerWindow; + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > _xParentWindow; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > _xParentPeer; +}; + +#endif + + diff --git a/extensions/source/plugin/inc/plugin/unx/mediator.hxx b/extensions/source/plugin/inc/plugin/unx/mediator.hxx new file mode 100644 index 000000000000..68619db54cad --- /dev/null +++ b/extensions/source/plugin/inc/plugin/unx/mediator.hxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _MEDIATOR_HXX +#define _MEDIATOR_HXX + +#include <string.h> +#include <stdarg.h> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <vos/pipe.hxx> +#include <vos/mutex.hxx> +#include <vos/conditn.hxx> +#include <vos/thread.hxx> +#if OSL_DEBUG_LEVEL > 1 +#include <stdio.h> +#endif + +#include <vector> + +struct MediatorMessage +{ + ULONG m_nID; + ULONG m_nBytes; + char* m_pBytes; + char* m_pRun; + + MediatorMessage() : m_nID( 0 ), m_nBytes( 0 ), + m_pBytes( NULL ), m_pRun( NULL ) {} + MediatorMessage( ULONG nID, ULONG nBytes, char* pBytes ) : + m_nID( nID ),m_nBytes( nBytes ), m_pRun( NULL ) + { + m_pBytes = new char[ m_nBytes ]; + memcpy( m_pBytes, pBytes, (size_t)m_nBytes ); + } + + ~MediatorMessage() + { + if( m_pBytes ) + delete [] m_pBytes; + } + + void Set( ULONG nBytes, char* pBytes ) + { + if( m_pBytes ) + delete [] m_pBytes; + m_nBytes = nBytes; + m_pBytes = new char[ m_nBytes ]; + memcpy( m_pBytes, pBytes, (size_t)m_nBytes ); + } + + ULONG ExtractULONG(); + char* GetString(); + UINT32 GetUINT32(); + void* GetBytes( ULONG& ); + void* GetBytes() { ULONG nBytes; return GetBytes( nBytes ); } + + void Rewind() { m_pRun = NULL; } +}; + +class MediatorListener; + +class Mediator +{ + friend class MediatorListener; +protected: + int m_nSocket; + + std::vector<MediatorMessage*> m_aMessageQueue; + NAMESPACE_VOS(OMutex) m_aQueueMutex; + NAMESPACE_VOS(OMutex) m_aSendMutex; + // only one thread can send a message at any given time + NAMESPACE_VOS(OCondition) m_aNewMessageCdtn; + MediatorListener* m_pListener; + // thread to fill the queue + + ULONG m_nCurrentID; + // will be constantly increased with each message sent + bool m_bValid; + + Link m_aConnectionLostHdl; + Link m_aNewMessageHdl; +public: + Mediator( int nSocket ); + ~Mediator(); + + // mark mediator as invalid. No more messages will be processed, + // SendMessage, WaitForMessage, TransactMessage will return immediatly + // with error + void invalidate() { m_bValid = false; } + + ULONG SendMessage( ULONG nBytes, const char* pBytes, ULONG nMessageID = 0 ); + ULONG SendMessage( const ByteString& rMessage, ULONG nMessageID = 0 ) + { + return SendMessage( rMessage.Len(), rMessage.GetBuffer(), nMessageID ); + } + + BOOL WaitForMessage( ULONG nTimeOut = 5000 ); + // timeout in ms + // TRUE: Message came in + // FALSE: timed out + // if timeout is set, WaitForMessage will wait even if there are messages + // in the queue + + virtual MediatorMessage* WaitForAnswer( ULONG nMessageID ); + // wait for an answer message ( ID >= 1 << 24 ) + // the message will be removed from the queue and returned + + MediatorMessage* TransactMessage( ULONG nBytes, char* pBytes ); + // sends a message and waits for an answer + + MediatorMessage* GetNextMessage( BOOL bWait = FALSE ); + + + Link SetConnectionLostHdl( const Link& rLink ) + { + Link aRet = m_aConnectionLostHdl; + m_aConnectionLostHdl = rLink; + return aRet; + } + + Link SetNewMessageHdl( const Link& rLink ) + { + Link aRet = m_aNewMessageHdl; + m_aNewMessageHdl = rLink; + return aRet; + } +}; + +class MediatorListener : public NAMESPACE_VOS( OThread ) +{ + friend class Mediator; + private: + Mediator* m_pMediator; + ::vos::OMutex m_aMutex; + + MediatorListener( Mediator* ); + ~MediatorListener(); + + virtual void run(); + virtual void onTerminated(); +}; + +inline void medDebug( int condition, const char* pFormat, ... ) +{ +#if OSL_DEBUG_LEVEL > 1 + if( condition ) + { + va_list ap; + va_start( ap, pFormat ); + vfprintf( stderr, pFormat, ap ); + va_end( ap ); + } +#else + (void)condition; + (void)pFormat; +#endif +} + +#endif // _MEDIATOR_HXX diff --git a/extensions/source/plugin/inc/plugin/unx/plugcon.hxx b/extensions/source/plugin/inc/plugin/unx/plugcon.hxx new file mode 100644 index 000000000000..9044a14a9cbc --- /dev/null +++ b/extensions/source/plugin/inc/plugin/unx/plugcon.hxx @@ -0,0 +1,251 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _PLUGCON_HXX +#define _PLUGCON_HXX + +#include <stdarg.h> +#include <string.h> + +#include <list> +#include <vector> +#include <plugin/unx/mediator.hxx> + +#if defined SOLARIS +#define USE_MOTIF +#endif + +#define Window XLIB_Window +#define Font XLIB_Font +#define KeyCode XLIB_KeyCode +#define Time XLIB_Time +#define Cursor XLIB_Cursor +#define Region XLIB_Region +#define String XLIB_String +#define Boolean XLIB_Boolean +#define XPointer XLIB_XPointer +#include <X11/Xlib.h> +extern "C" { +#include <X11/Intrinsic.h> +} +#include <X11/Shell.h> +#include <X11/IntrinsicP.h> /* Intrinsics Definitions*/ +#include <X11/StringDefs.h> /* Standard Name-String definitions*/ +#if defined USE_MOTIF +#include <Xm/DrawingA.h> +#else +# if defined DISABLE_XAW +# include <X11/Composite.h> +# else +# include <X11/Xaw/Label.h> +# endif +#endif +#include <X11/Xatom.h> +#ifndef XP_UNIX +# define XP_UNIX +#endif +#define MOZ_X11 +#include <stdio.h> +#ifdef SYSTEM_MOZILLA +#ifndef OJI +# define OJI +#endif +#define MOZ_X11 +#endif + +//http://qa.openoffice.org/issues/show_bug.cgi?id=82545 +//https://bugzilla.mozilla.org/show_bug.cgi?id=241262 +#ifdef UNIX +# ifndef _UINT32 +# if defined(__alpha) || defined(__LP64__) + typedef unsigned int uint32; +# else /* __alpha */ + typedef unsigned long uint32; +# endif +# define _UINT32 +# endif +# ifndef _INT32 +# if defined(__alpha) || defined(__LP64__) + typedef int int32; +# else /* __alpha */ + typedef long int32; +# endif +# define _INT32 +# endif +#endif + +#ifndef _NPAPI_H_ +extern "C" { +#include <npsdk/npupp.h> +} +#include <npsdk/npapi.h> + +#if NP_VERSION_MINOR < 17 +// compatibility hack: compile with older NPN api header, but define +// some later introduced constants +// for gcc 3 +#define NP_ABI_MASK 0x10000000 +#define NPNVSupportsXEmbedBool ((NPNVariable)14) +#define NPPVpluginNeedsXEmbed ((NPPVariable)14) +#define NPNVToolkit ((int)(13 | NP_ABI_MASK)) +#define NPNVGtk12 1 +#define NPNVGtk2 2 +#endif +#endif + +#ifdef ENABLE_GTK +#include <gtk/gtk.h> +#include <gdk/gdkx.h> +#else +#define GtkWidget void +#endif + +#undef Window +#undef Font +#undef KeyCode +#undef Time +#undef Cursor +#undef String +#undef Region +#undef Boolean +#undef XPointer + +class ConnectorInstance +{ +public: + NPP instance; + NPWindow window; + NPSetWindowCallbackStruct ws_info; + char* pMimeType; + void* pShell; + void* pWidget; + void* pForm; + + GtkWidget* pGtkWindow; + GtkWidget* pGtkWidget; + + bool bShouldUseXEmbed; + + int nArg; + char** argn; + char** argv; + char* pArgnBuf; + char* pArgvBuf; + NPSavedData aData; + + ConnectorInstance( NPP inst, char* type, + int args, char* pargnbuf, ULONG nargnbytes, + char* pargvbuf, ULONG nargvbytes, + char* savedata, ULONG savebytes ); + ~ConnectorInstance(); +}; + +class PluginConnector : public Mediator +{ +protected: + NAMESPACE_VOS(OMutex) m_aUserEventMutex; + + static std::vector<PluginConnector*> allConnectors; + + DECL_LINK( NewMessageHdl, Mediator* ); + DECL_LINK( WorkOnNewMessageHdl, Mediator* ); + + std::vector<NPStream*> m_aNPWrapStreams; + std::vector<ConnectorInstance*> m_aInstances; + + ULONG FillBuffer( char*&, const char*, ULONG, va_list ); +public: + PluginConnector( int nSocket ); + ~PluginConnector(); + + virtual MediatorMessage* WaitForAnswer( ULONG nMessageID ); + MediatorMessage* Transact( const char*, ULONG, ... ); + MediatorMessage* Transact( UINT32, ... ); + void Respond( ULONG nID, char*, ULONG, ... ); + ULONG Send( UINT32, ... ); + + static const UINT32 UnknownStreamID = 0xffffffff; + static const UINT32 UnknownNPPID = 0xffffffff; + + UINT32 GetStreamID( NPStream* pStream ); + UINT32 GetNPPID( NPP ); + + std::vector<NPStream*>& getStreamList() { return m_aNPWrapStreams; } + + NPError GetNPError( MediatorMessage* pMes ) + { + NPError* pErr = (NPError*)pMes->GetBytes(); + NPError aErr = *pErr; + delete [] pErr; + return aErr; + } + + void CallWorkHandler() + { + LINK( this, PluginConnector, WorkOnNewMessageHdl ). + Call( (Mediator*)this ); + } + + ConnectorInstance* getInstance( NPP ); + ConnectorInstance* getInstanceById( UINT32 ); +}; + +enum CommandAtoms +{ + eNPN_GetURL, + eNPN_GetURLNotify, + eNPN_DestroyStream, + eNPN_NewStream, + eNPN_PostURLNotify, + eNPN_PostURL, + eNPN_RequestRead, + eNPN_Status, + eNPN_Version, + eNPN_Write, + eNPN_UserAgent, + + eNPP_DestroyStream, + eNPP_Destroy, + eNPP_DestroyPhase2, + eNPP_NewStream, + eNPP_New, + eNPP_SetWindow, + eNPP_StreamAsFile, + eNPP_URLNotify, + eNPP_WriteReady, + eNPP_Write, + eNPP_GetMIMEDescription, + eNPP_Initialize, + eNPP_Shutdown, + + eMaxCommand +}; + +const char* GetCommandName( CommandAtoms ); + +#define POST_STRING( x ) x ? x : const_cast<char*>(""), x ? strlen(x) : 1 + +#endif // _PLUGCON_HXX diff --git a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx new file mode 100644 index 000000000000..70b01d3fc69c --- /dev/null +++ b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __PLUGIN_INC_UNXPLUG_HXX +#define __PLUGIN_INC_UNXPLUG_HXX + +#include <unistd.h> + +#include <plugin/unx/plugcon.hxx> +#include <plugin/plcom.hxx> +#include <vcl/sysdata.hxx> + +class UnxPluginComm : public PluginComm, public PluginConnector +{ +private: + static int nConnCounter; + + pid_t m_nCommPID; +public: + UnxPluginComm( const String& mimetype, + const String& library, + XLIB_Window aParent, + int nDescriptor1, + int nDescriptor2 + ); + virtual ~UnxPluginComm(); + + using PluginComm::NPP_Destroy; + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, + NPError reason ); + virtual void* NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, + uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, + NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + + using PluginComm::NPP_SetWindow; + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, + const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, NPReason reason, + void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual char* NPP_GetMIMEDescription(); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, + void *value); + + static bool getPluginappPath(rtl::OString * path); +}; + +#endif diff --git a/extensions/source/plugin/inc/plugin/win/sysplug.hxx b/extensions/source/plugin/inc/plugin/win/sysplug.hxx new file mode 100644 index 000000000000..9dd25d34dd06 --- /dev/null +++ b/extensions/source/plugin/inc/plugin/win/sysplug.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __PLUGIN_INC_WINPLUG_HXX +#define __PLUGIN_INC_WINPLUG_HXX + +#pragma warning (push,1) +#pragma warning (disable:4005) + +#include <tools/prewin.h> + +#include <windows.h> +#include <tchar.h> +#include <winbase.h> + +#include <tools/postwin.h> + +#pragma pack( push, 8 ) +#include <npsdk/npapi.h> +#include <npsdk/npupp.h> +#pragma pack( pop ) + +#pragma warning (pop) + +#include <list> +#include <map> +#include <algorithm> + +#include <plugin/plcom.hxx> +#include <vcl/threadex.hxx> + +//================================================================================================== +class PluginComm_Impl : + public PluginComm, + public ::vcl::SolarThreadExecutor + +{ + enum CallType { + eNPP_Destroy, + eNPP_DestroyStream, + eNPP_GetJavaClass, + eNPP_Initialize, + eNPP_New, + eNPP_NewStream, + eNPP_Print, + eNPP_SetWindow, + eNPP_Shutdown, + eNPP_StreamAsFile, + eNPP_URLNotify, + eNPP_Write, + eNPP_WriteReady, + eNPP_GetValue, + eNPP_SetValue, + eNP_Initialize + }; + + void* m_aArgs[ 8 ]; + CallType m_eCall; + + virtual long doIt(); +public: + PluginComm_Impl( const rtl::OUString& rMIME, const rtl::OUString& rName, HWND hWnd ); + virtual ~PluginComm_Impl(); + +public: + using PluginComm::NPP_Destroy; + virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); + virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); + virtual void * NPP_GetJavaClass(); + virtual NPError NPP_Initialize(); + virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, + char* argn[], char* argv[], NPSavedData *saved ); + virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, + NPBool seekable, uint16* stype ); + virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); + + using PluginComm::NPP_SetWindow; + virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); + virtual void NPP_Shutdown(); + virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); + virtual void NPP_URLNotify( NPP instance, const char* url, + NPReason reason, void* notifyData ); + virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer ); + virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ); + virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_alue ); + virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *ret_alue ); + +private: + BOOL retrieveFunction( TCHAR* pName, void** ppFunc ) const; + +private: + HINSTANCE _plDLL; + + NPPluginFuncs _NPPfuncs; +}; + + +#endif + + |