diff options
Diffstat (limited to 'extensions/source/plugin/base')
-rw-r--r-- | extensions/source/plugin/base/context.cxx | 354 | ||||
-rw-r--r-- | extensions/source/plugin/base/evtlstnr.cxx | 77 | ||||
-rw-r--r-- | extensions/source/plugin/base/makefile.mk | 66 | ||||
-rw-r--r-- | extensions/source/plugin/base/manager.cxx | 237 | ||||
-rw-r--r-- | extensions/source/plugin/base/multiplx.cxx | 335 | ||||
-rw-r--r-- | extensions/source/plugin/base/nfuncs.cxx | 675 | ||||
-rw-r--r-- | extensions/source/plugin/base/plcom.cxx | 83 | ||||
-rw-r--r-- | extensions/source/plugin/base/plctrl.cxx | 325 | ||||
-rw-r--r-- | extensions/source/plugin/base/plmodel.cxx | 206 | ||||
-rw-r--r-- | extensions/source/plugin/base/service.cxx | 99 | ||||
-rw-r--r-- | extensions/source/plugin/base/xplugin.cxx | 1157 |
11 files changed, 0 insertions, 3614 deletions
diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx deleted file mode 100644 index bf5f95400..000000000 --- a/extensions/source/plugin/base/context.cxx +++ /dev/null @@ -1,354 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#include <cstdarg> -#include <cstdio> - -#include <plugin/impl.hxx> - -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/frame/XComponentLoader.hpp> -#include <tools/fsys.hxx> -#include <tools/urlobj.hxx> - -#include <cppuhelper/implbase1.hxx> - -using namespace com::sun::star::io; - -namespace ext_plug { - -class FileSink : public ::cppu::WeakAggImplHelper1< ::com::sun::star::io::XOutputStream > -{ -private: - Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; - FILE* fp; - Reference< ::com::sun::star::plugin::XPlugin > m_xPlugin; - ::rtl::OUString m_aMIMEType; - ::rtl::OUString m_aTarget; - ::rtl::OUString m_aFileName; - -public: - FileSink( const Reference< ::com::sun::star::lang::XMultiServiceFactory > &, - const Reference< ::com::sun::star::plugin::XPlugin > & plugin, - const ::rtl::OUString& mimetype, - const ::rtl::OUString& target, - const Reference< ::com::sun::star::io::XActiveDataSource > & source ); - virtual ~FileSink(); - - // ::com::sun::star::io::XOutputStream - virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw(); - virtual void SAL_CALL flush() throw(); - virtual void SAL_CALL closeOutput() throw(); -}; - -} -using namespace ext_plug; - -class XPluginContext_Impl : public ::cppu::WeakAggImplHelper1< ::com::sun::star::plugin::XPluginContext > -{ - Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr; - rtl_TextEncoding m_aEncoding; -public: - - XPluginContext_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ); - virtual ~XPluginContext_Impl(); - - - virtual ::rtl::OUString SAL_CALL getValue(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, ::com::sun::star::plugin::PluginVariable variable) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual void SAL_CALL getURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Reference< ::com::sun::star::lang::XEventListener > & listener) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual void SAL_CALL getURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual void SAL_CALL postURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< ::com::sun::star::lang::XEventListener > & listener) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual void SAL_CALL postURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual void SAL_CALL newStream(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& mimetype, const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual void SAL_CALL displayStatusText(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& message) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); - virtual ::rtl::OUString SAL_CALL getUserAgent(const Reference< ::com::sun::star::plugin::XPlugin > & plugin) throw( ::com::sun::star::plugin::PluginException, RuntimeException ); -}; - -Reference< ::com::sun::star::plugin::XPluginContext > XPluginManager_Impl::createPluginContext() throw() -{ - return new XPluginContext_Impl( m_xSMgr ); -} - -XPluginContext_Impl::XPluginContext_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) - : m_xSMgr( rSMgr ), - m_aEncoding( gsl_getSystemTextEncoding() ) -{ -} - -XPluginContext_Impl::~XPluginContext_Impl() -{ -} - -::rtl::OUString XPluginContext_Impl::getValue( const Reference< ::com::sun::star::plugin::XPlugin > & /*plugin*/, ::com::sun::star::plugin::PluginVariable /*variable*/ ) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - return ::rtl::OUString(); -} - - -void XPluginContext_Impl::getURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target) throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ); - if( ! xInst.is() ) - return; - - if( ! target.getLength() ) - { - INetURLObject aURL; - aURL.SetSmartProtocol( INET_PROT_FILE ); - aURL.SetSmartURL( ::rtl::OUStringToOString( url, m_aEncoding ) ); - - rtl::OUString aUrl = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI); - // the mimetype cannot be specified - plugin->provideNewStream( ::rtl::OUString(), - Reference< XActiveDataSource >(), - aUrl, - 0, 0, (sal_Bool)(aUrl.compareToAscii( "file:", 5 ) == 0) ); - return; - } - - Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY ); - XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin ); - - if( xLoader.is() && pPlugin ) - { - try - { - ::com::sun::star::beans::PropertyValue aValue; - aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")); - aValue.Value <<= pPlugin->getRefererURL(); - - Sequence< ::com::sun::star::beans::PropertyValue > aArgs( &aValue, 1 ); - Reference< ::com::sun::star::lang::XComponent > xComp = - xLoader->loadComponentFromURL( - url, - target, - ::com::sun::star::frame::FrameSearchFlag::PARENT | - ::com::sun::star::frame::FrameSearchFlag::SELF | - ::com::sun::star::frame::FrameSearchFlag::CHILDREN | - ::com::sun::star::frame::FrameSearchFlag::SIBLINGS | - ::com::sun::star::frame::FrameSearchFlag::TASKS | - ::com::sun::star::frame::FrameSearchFlag::CREATE, - aArgs - ); - } - catch(...) - { - throw ::com::sun::star::plugin::PluginException(); - } - } -} - -void XPluginContext_Impl::getURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Reference< ::com::sun::star::lang::XEventListener > & listener ) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - getURL( plugin, url, target ); - if( listener.is() ) - listener->disposing( ::com::sun::star::lang::EventObject() ); -} - -::rtl::OUString XPluginContext_Impl::getUserAgent(const Reference< ::com::sun::star::plugin::XPlugin > & /*plugin*/) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Mozilla 3.0")); -} - -void XPluginContext_Impl::displayStatusText(const Reference< ::com::sun::star::plugin::XPlugin > & /*plugin*/, const ::rtl::OUString& /*message*/) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ -} - -void XPluginContext_Impl::postURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - Sequence< sal_Int8 > aBuf; - - if( file ) - { - String aFileName( (char*)buf.getConstArray(), m_aEncoding ); - INetURLObject aFilePath( aFileName ); - aFileName = aFilePath.PathToFileName(); - SvFileStream aStream( aFileName, STREAM_READ ); - if( aStream.IsOpen() ) - { - int nBytes = 0; - aStream.Seek( STREAM_SEEK_TO_END ); - aBuf = Sequence<sal_Int8>( nBytes = aStream.Tell() ); - aStream.Seek( STREAM_SEEK_TO_BEGIN ); - aStream.Read( aBuf.getArray(), nBytes ); - aStream.Close(); - DirEntry( aFileName ).Kill(); - } - } - - Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ); - if( ! xInst.is() ) - return ; - - Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY ); - XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin ); - if( xLoader.is() && pPlugin ) - { - try - { - ::com::sun::star::beans::PropertyValue aValues[2]; - aValues[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")); - aValues[0].Value <<= pPlugin->getRefererURL(); - - aValues[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PostString")); - aValues[1].Value <<= ::rtl::OStringToOUString( (char*)( file ? aBuf : buf ).getConstArray(), m_aEncoding ); - Sequence< ::com::sun::star::beans::PropertyValue > aArgs( aValues, 2 ); - Reference< ::com::sun::star::lang::XComponent > xComp = - xLoader->loadComponentFromURL( - url, - target, - ::com::sun::star::frame::FrameSearchFlag::PARENT | - ::com::sun::star::frame::FrameSearchFlag::SELF | - ::com::sun::star::frame::FrameSearchFlag::CHILDREN | - ::com::sun::star::frame::FrameSearchFlag::SIBLINGS | - ::com::sun::star::frame::FrameSearchFlag::TASKS | - ::com::sun::star::frame::FrameSearchFlag::CREATE, - aArgs - ); - } - catch( ... ) - { - throw ::com::sun::star::plugin::PluginException(); - } - } -} - -void XPluginContext_Impl::postURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< ::com::sun::star::lang::XEventListener > & listener ) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - postURL( plugin, url, target, buf, file ); - if( listener.is() ) - listener->disposing( ::com::sun::star::lang::EventObject() ); -} - -void XPluginContext_Impl::newStream( const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& mimetype, const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source ) - throw( ::com::sun::star::plugin::PluginException, RuntimeException ) -{ - FileSink* pNewSink = new FileSink( m_xSMgr, plugin, mimetype, target, source ); - pNewSink->acquire(); -} - - - -FileSink::FileSink( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr, const Reference< ::com::sun::star::plugin::XPlugin > & plugin, - const ::rtl::OUString& mimetype, - const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source ) : - m_xSMgr( rSMgr ), - m_xPlugin( plugin ), - m_aMIMEType( mimetype ), - m_aTarget( target ) -{ - DirEntry aEntry; - m_aFileName = aEntry.TempName().GetFull(); - ::rtl::OString aFile = ::rtl::OUStringToOString( m_aFileName, gsl_getSystemTextEncoding() ); - fp = fopen( aFile.getStr() , "wb" ); - - Reference< ::com::sun::star::io::XActiveDataControl > xControl( source, UNO_QUERY ); - - source->setOutputStream( Reference< ::com::sun::star::io::XOutputStream > ( this ) ); - if( xControl.is() ) - xControl->start(); -} - -FileSink::~FileSink() -{ - DirEntry aEntry( m_aFileName ); - aEntry.Kill(); -} - -void FileSink::closeOutput() throw() -{ - if( fp ) - fclose( fp ); - - Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ); - Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY ); - XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( m_xPlugin ); - - if( xLoader.is() && pPlugin ) - { - try - { - ::com::sun::star::beans::PropertyValue aValue; - aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Referer")); - aValue.Value <<= pPlugin->getRefererURL(); - - Sequence< ::com::sun::star::beans::PropertyValue > aArgs( &aValue, 1 ); - Reference< ::com::sun::star::lang::XComponent > xComp = - xLoader->loadComponentFromURL( - m_aFileName, - m_aTarget, - ::com::sun::star::frame::FrameSearchFlag::PARENT | - ::com::sun::star::frame::FrameSearchFlag::SELF | - ::com::sun::star::frame::FrameSearchFlag::CHILDREN | - ::com::sun::star::frame::FrameSearchFlag::SIBLINGS | - ::com::sun::star::frame::FrameSearchFlag::TASKS | - ::com::sun::star::frame::FrameSearchFlag::CREATE, - aArgs - ); - } - catch( ... ) - { - } - } - release(); -} - -void FileSink::writeBytes( const Sequence<sal_Int8>& Buffer ) throw() -{ - if( fp ) - fwrite( Buffer.getConstArray(), 1, Buffer.getLength(), fp ); -} - -void FileSink::flush() throw() -{ - if( fp ) - fflush( fp ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/evtlstnr.cxx b/extensions/source/plugin/base/evtlstnr.cxx deleted file mode 100644 index b566f9117..000000000 --- a/extensions/source/plugin/base/evtlstnr.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#include <cstdarg> - -#include <plugin/impl.hxx> - -PluginEventListener::PluginEventListener( XPlugin_Impl* pPlugin, - const char* url, - const char* normurl, - void* notifyData ) : - m_pPlugin( pPlugin ), - m_xPlugin( pPlugin ), - m_pUrl( strdup( url ) ), - m_pNormalizedUrl( strdup( normurl ) ), - m_pNotifyData( notifyData ) -{ -} - -PluginEventListener::~PluginEventListener() -{ - if( m_pUrl ) - free( m_pUrl ); - if( m_pNormalizedUrl ) - free( m_pNormalizedUrl ); -} - -void PluginEventListener::disposing( const ::com::sun::star::lang::EventObject& /*rEvt*/ ) throw() -{ - m_pPlugin->getPluginComm()-> - NPP_URLNotify( m_pPlugin->getNPPInstance(), - m_pUrl, - NPRES_DONE, - m_pNotifyData ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/makefile.mk b/extensions/source/plugin/base/makefile.mk deleted file mode 100644 index 3049d9e9c..000000000 --- a/extensions/source/plugin/base/makefile.mk +++ /dev/null @@ -1,66 +0,0 @@ -#************************************************************************* -# -# 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. -# -#************************************************************************* -PRJ=..$/..$/.. - -PRJNAME=extensions -TARGET=plbase -TARGETTYPE=GUI -ENABLE_EXCEPTIONS=TRUE - -.INCLUDE : ..$/util$/makefile.pmk - -INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin -.IF "$(SOLAR_JAVA)" != "" -INCPRE+=-I$(SOLARINCDIR)$/mozilla$/java -INCPRE+=-I$(SOLARINCDIR)$/mozilla$/nspr -CDEFS+=-DOJI -.ENDIF - -.IF "$(WITH_MOZILLA)" != "NO" - -.IF "$(GUIBASE)"=="aqua" -CFLAGSCXX+=$(OBJCXXFLAGS) -.ENDIF # "$(GUIBASE)"=="aqua" - -SLOFILES= \ - $(SLO)$/plctrl.obj \ - $(SLO)$/service.obj \ - $(SLO)$/xplugin.obj \ - $(SLO)$/nfuncs.obj \ - $(SLO)$/manager.obj \ - $(SLO)$/context.obj \ - $(SLO)$/evtlstnr.obj \ - $(SLO)$/plcom.obj \ - $(SLO)$/multiplx.obj \ - $(SLO)$/plmodel.obj - -.ENDIF # $(WITH_MOZILLA) != "NO" - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - diff --git a/extensions/source/plugin/base/manager.cxx b/extensions/source/plugin/base/manager.cxx deleted file mode 100644 index 2806ee4cf..000000000 --- a/extensions/source/plugin/base/manager.cxx +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#include <cstdarg> - -#include "plugin/impl.hxx" - -#include "osl/mutex.hxx" -#include "unotools/pathoptions.hxx" -#include "vcl/configsettings.hxx" - -#include "com/sun/star/container/XEnumerationAccess.hpp" -#include "com/sun/star/container/XNameAccess.hpp" -#include "com/sun/star/container/XEnumeration.hpp" -#include "com/sun/star/container/XElementAccess.hpp" -#include "com/sun/star/container/XIndexAccess.hpp" -#include "com/sun/star/loader/XImplementationLoader.hpp" -#include "com/sun/star/loader/CannotActivateFactoryException.hpp" - -PluginManager* PluginManager::pManager = NULL; - -PluginManager& PluginManager::get() -{ - if( ! pManager ) - pManager = new PluginManager(); - return *pManager; -} - -void PluginManager::setServiceFactory( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ) -{ - PluginManager& rManager = get(); - if( ! rManager.m_xSMgr.is() ) - rManager.m_xSMgr = xFactory; -} - -PluginManager::PluginManager() -{ -} - -const Sequence< ::rtl::OUString >& PluginManager::getAdditionalSearchPaths() -{ - static Sequence< ::rtl::OUString > aPaths; - - if( ! aPaths.getLength() ) - { - SvtPathOptions aOptions; - String aPluginPath( aOptions.GetPluginPath() ); - if( aPluginPath.Len() ) - { - sal_uInt16 nPaths = aPluginPath.GetTokenCount( ';' ); - aPaths.realloc( nPaths ); - for( sal_uInt16 i = 0; i < nPaths; i++ ) - aPaths.getArray()[i] = aPluginPath.GetToken( i, ';' ); - } - } - - return aPaths; -} - -//================================================================================================== -Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) throw( Exception ) -{ - Reference< XInterface > xService = *new XPluginManager_Impl( rSMgr ); - return xService; -} - -// ::com::sun::star::lang::XServiceInfo -::rtl::OUString XPluginManager_Impl::getImplementationName() throw( ) - -{ - return getImplementationName_Static(); - -} - -// ::com::sun::star::lang::XServiceInfo -sal_Bool XPluginManager_Impl::supportsService(const ::rtl::OUString& ServiceName) throw( ) -{ - Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames(); - const ::rtl::OUString * pArray = aSNL.getConstArray(); - for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return sal_True; - return sal_False; -} - -// ::com::sun::star::lang::XServiceInfo -Sequence< ::rtl::OUString > XPluginManager_Impl::getSupportedServiceNames(void) throw( ) -{ - return getSupportedServiceNames_Static(); -} - -// XPluginManager_Impl -Sequence< ::rtl::OUString > XPluginManager_Impl::getSupportedServiceNames_Static(void) throw( ) -{ - Sequence< ::rtl::OUString > aSNS( 1 ); - aSNS.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.plugin.PluginManager")); - return aSNS; -} - -XPluginManager_Impl::XPluginManager_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) -: m_xSMgr( rSMgr ) -{ - PluginManager::setServiceFactory( rSMgr ); -} - -XPluginManager_Impl::~XPluginManager_Impl() -{ -} - -XPlugin_Impl* XPluginManager_Impl::getXPluginFromNPP( NPP instance ) -{ - ::std::list<XPlugin_Impl*>::iterator iter; - for( iter = PluginManager::get().getPlugins().begin(); - iter != PluginManager::get().getPlugins().end(); ++iter ) - { - if( (*iter)->getNPPInstance() == instance ) - return *iter; - } - - return NULL; -} - -XPlugin_Impl* XPluginManager_Impl::getPluginImplementation( const Reference< ::com::sun::star::plugin::XPlugin >& plugin ) -{ - ::std::list<XPlugin_Impl*>::iterator iter; - for( iter = PluginManager::get().getPlugins().begin(); - iter != PluginManager::get().getPlugins().end(); ++iter ) - { - if( plugin == Reference< ::com::sun::star::plugin::XPlugin >((*iter)) ) - return *iter; - } - - return NULL; -} - -Sequence<com::sun::star::plugin::PluginDescription> XPluginManager_Impl::getPluginDescriptions() throw() -{ - Sequence<com::sun::star::plugin::PluginDescription> aRet; - - vcl::SettingsConfigItem* pCfg = vcl::SettingsConfigItem::get(); - rtl::OUString aVal( pCfg->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowserPlugins" ) ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Disabled" ) ) ) ); - if( ! aVal.toBoolean() ) - { - aRet = impl_getPluginDescriptions(); - } - return aRet; -} - -Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::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 ) -{ - XPlugin_Impl* pImpl = new XPlugin_Impl( m_xSMgr ); - pImpl->setPluginContext( acontext ); - - PluginManager::get().getPlugins().push_back( pImpl ); - - pImpl->initInstance( plugintype, - argn, - argv, - mode ); - - return pImpl; -} - -Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::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() -{ - XPlugin_Impl* pImpl = new XPlugin_Impl( m_xSMgr ); - Reference< ::com::sun::star::plugin::XPlugin > xRef = pImpl; - - pImpl->setPluginContext( acontext ); - - PluginManager::get().getPlugins().push_back( pImpl ); - - - pImpl->initInstance( url, - argn, - argv, - mode ); - - pImpl->createPeer( toolkit, parent ); - - pImpl->provideNewStream( pImpl->getDescription().Mimetype, - Reference< com::sun::star::io::XActiveDataSource >(), - url, - 0, 0, (sal_Bool)(url.compareToAscii( "file:", 5 ) == 0) ); - - if( ! pImpl->getPluginComm() ) - { - pImpl->dispose(); - xRef = NULL; - } - - return xRef; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/multiplx.cxx b/extensions/source/plugin/base/multiplx.cxx deleted file mode 100644 index a9890e57b..000000000 --- a/extensions/source/plugin/base/multiplx.cxx +++ /dev/null @@ -1,335 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" -#include <osl/diagnose.h> -#include <plugin/multiplx.hxx> - -// --------------------------------------------------------------------- -// class MRCListenerMultiplexerHelper -// --------------------------------------------------------------------- -MRCListenerMultiplexerHelper::MRCListenerMultiplexerHelper -( - const Reference< ::com::sun::star::awt::XWindow > & rControl - , const Reference< ::com::sun::star::awt::XWindow > & rPeer -) - : xPeer( rPeer ) - , xControl( Reference< ::com::sun::star::awt::XControl >( rControl, UNO_QUERY ) ) - , aListenerHolder( aMutex ) -{ -} - - -void MRCListenerMultiplexerHelper::setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer ) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - if( xPeer != rPeer ) - { - if( xPeer.is() ) - { - // get all uiks from the listener added to the peer - Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes(); - const Type* pArray = aContainedTypes.getConstArray(); - sal_Int32 nCount = aContainedTypes.getLength(); - // loop over all listener types and remove the listeners from the peer - for( sal_Int32 i = 0; i < nCount; i++ ) - unadviseFromPeer( xPeer, pArray[i] ); - } - xPeer = rPeer; - if( xPeer.is() ) - { - // get all uiks from the listener added to the peer - Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes(); - const Type * pArray = aContainedTypes.getConstArray(); - sal_Int32 nCount = aContainedTypes.getLength(); - // loop over all listener types and add the listeners to the peer - for( sal_Int32 i = 0; i < nCount; i++ ) - adviseToPeer( xPeer, pArray[i] ); - } - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::disposeAndClear() -{ - ::com::sun::star::lang::EventObject aEvt; - aEvt.Source = xControl; - aListenerHolder.disposeAndClear( aEvt ); -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ) -{ - // add a listener to the source (peer) - if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0) ) - rPeer->addWindowListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0) ) - rPeer->addKeyListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) ) - rPeer->addFocusListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0) ) - rPeer->addMouseListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0) ) - rPeer->addMouseMotionListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0) ) - rPeer->addPaintListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XTopWindowListener >*)0) ) - { - Reference< ::com::sun::star::awt::XTopWindow > xTop( rPeer, UNO_QUERY ); - if( xTop.is() ) - xTop->addTopWindowListener( this ); - } - else - { - OSL_FAIL( "unknown listener" ); - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type ) -{ - // the last listener is removed, remove the listener from the source (peer) - if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0) ) - rPeer->removeWindowListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0) ) - rPeer->removeKeyListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) ) - rPeer->removeFocusListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0) ) - rPeer->removeMouseListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0) ) - rPeer->removeMouseMotionListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0) ) - rPeer->removePaintListener( this ); - else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XTopWindowListener >*)0) ) - { - Reference< ::com::sun::star::awt::XTopWindow > xTop( rPeer, UNO_QUERY ); - if( xTop.is() ) - xTop->removeTopWindowListener( this ); - } - else - { - OSL_FAIL( "unknown listener" ); - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::advise( const Type & type, const Reference< XInterface > & listener) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - if( 1 == aListenerHolder.addInterface( type, listener ) ) - { - // the first listener is added - if( xPeer.is() ) - adviseToPeer( xPeer, type ); - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::unadvise(const Type & type, const Reference< XInterface > & listener) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - ::cppu::OInterfaceContainerHelper * pCont = aListenerHolder.getContainer( type ); - if( pCont ) - { - if( 0 == pCont->removeInterface( listener ) && xPeer.is() ) - // the last listener is removed - unadviseFromPeer( xPeer, type ); - } -} - -// ::com::sun::star::lang::XEventListener -void MRCListenerMultiplexerHelper::disposing(const ::com::sun::star::lang::EventObject& ) throw() -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - // peer is disposed, clear the reference - xPeer = Reference< ::com::sun::star::awt::XWindow > (); -} - -#define MULTIPLEX( InterfaceName, MethodName, EventName ) \ -::cppu::OInterfaceContainerHelper * pCont; \ -pCont = aListenerHolder.getContainer( ::getCppuType((const Reference< InterfaceName >*)0) ); \ -if( pCont ) \ -{ \ - ::cppu::OInterfaceIteratorHelper aIt( *pCont ); \ - EventName aEvt = e; \ - /* Remark: The control is the event source not the peer. We must change */ \ - /* the source of the event */ \ - aEvt.Source = xControl;\ - /*.is the control not destroyed */ \ - if( aEvt.Source.is() ) \ - { \ - if( aIt.hasMoreElements() ) \ - { \ - InterfaceName * pListener = (InterfaceName *)aIt.next(); \ - try \ - { \ - pListener->MethodName( aEvt ); \ - } \ - catch( RuntimeException& ) \ - { \ - /* ignore all usr system exceptions from the listener */ \ - } \ - } \ - } \ -} - -// ::com::sun::star::awt::XFocusListener -void MRCListenerMultiplexerHelper::focusGained(const ::com::sun::star::awt::FocusEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XFocusListener, focusGained, ::com::sun::star::awt::FocusEvent ) -} - -// ::com::sun::star::awt::XFocusListener -void MRCListenerMultiplexerHelper::focusLost(const ::com::sun::star::awt::FocusEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XFocusListener, focusLost, ::com::sun::star::awt::FocusEvent ) -} - -// ::com::sun::star::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowResized(const ::com::sun::star::awt::WindowEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowResized, ::com::sun::star::awt::WindowEvent ) -} - -// ::com::sun::star::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowMoved(const ::com::sun::star::awt::WindowEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowMoved, ::com::sun::star::awt::WindowEvent ) -} - -// ::com::sun::star::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowShown(const ::com::sun::star::lang::EventObject& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowShown, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowHidden(const ::com::sun::star::lang::EventObject& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowHidden, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XKeyListener -void MRCListenerMultiplexerHelper::keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XKeyListener, keyPressed, ::com::sun::star::awt::KeyEvent ) -} - -// ::com::sun::star::awt::XKeyListener -void MRCListenerMultiplexerHelper::keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XKeyListener, keyReleased, ::com::sun::star::awt::KeyEvent ) -} - -// ::com::sun::star::awt::XMouseListener -void MRCListenerMultiplexerHelper::mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XMouseListener, mousePressed, ::com::sun::star::awt::MouseEvent ) -} - -// ::com::sun::star::awt::XMouseListener -void MRCListenerMultiplexerHelper::mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseReleased, ::com::sun::star::awt::MouseEvent ) -} - -// ::com::sun::star::awt::XMouseListener -void MRCListenerMultiplexerHelper::mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseEntered, ::com::sun::star::awt::MouseEvent ) -} - -// ::com::sun::star::awt::XMouseListener -void MRCListenerMultiplexerHelper::mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseExited, ::com::sun::star::awt::MouseEvent ) -} - -// ::com::sun::star::awt::XMouseMotionListener -void MRCListenerMultiplexerHelper::mouseDragged(const ::com::sun::star::awt::MouseEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XMouseMotionListener, mouseDragged, ::com::sun::star::awt::MouseEvent ) -} - -// ::com::sun::star::awt::XMouseMotionListener -void MRCListenerMultiplexerHelper::mouseMoved(const ::com::sun::star::awt::MouseEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XMouseMotionListener, mouseMoved, ::com::sun::star::awt::MouseEvent ) -} - -// ::com::sun::star::awt::XPaintListener -void MRCListenerMultiplexerHelper::windowPaint(const ::com::sun::star::awt::PaintEvent& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XPaintListener, windowPaint, ::com::sun::star::awt::PaintEvent ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowOpened(const ::com::sun::star::lang::EventObject& e) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowOpened, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowClosing( const ::com::sun::star::lang::EventObject& e ) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowClosing, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowClosed( const ::com::sun::star::lang::EventObject& e ) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowClosed, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowMinimized, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowNormalized, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowActivated( const ::com::sun::star::lang::EventObject& e ) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowActivated, ::com::sun::star::lang::EventObject ) -} - -// ::com::sun::star::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw() -{ - MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowDeactivated, ::com::sun::star::lang::EventObject ) -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx deleted file mode 100644 index 0d50bcf1c..000000000 --- a/extensions/source/plugin/base/nfuncs.cxx +++ /dev/null @@ -1,675 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#include <cstdarg> -#include <list> - -#include <plugin/impl.hxx> -#include <vcl/svapp.hxx> - -#if OSL_DEBUG_LEVEL > 1 -#include <osl/thread.h> -#include <stdio.h> -static FILE * s_file = 0; -void TRACE( char const * s ) -{ - if (! s_file) - s_file = stderr; - if (s_file) - { - oslThreadIdentifier t = osl_getThreadIdentifier(0); - fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s\n", t, s ); - fflush( s_file ); - } -} -void TRACEN( char const * s, long n ) -{ - if (! s_file) - s_file = stderr; - if (s_file) - { - oslThreadIdentifier t = osl_getThreadIdentifier(0); - fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s%ld\n", t, s, n ); - fflush( s_file ); - } -} -void TRACES( char const* s, char const* s2 ) -{ - if (! s_file) - s_file = stderr; - if (s_file) - { - oslThreadIdentifier t = osl_getThreadIdentifier(0); - fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s %s\n", t, s, s2 ); - fflush( s_file ); - } -} -#else -#define TRACE(x) -#define TRACEN(x,n) -#define TRACES(x,s) -#endif - -using namespace com::sun::star::lang; - -using ::rtl::OUString; -using ::rtl::OString; -using ::rtl::OStringToOUString; - -NPNetscapeFuncs aNPNFuncs = -{ - sizeof( NPNetscapeFuncs ), - (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR, - NPN_GetURL, - NPN_PostURL, - NPN_RequestRead, - NPN_NewStream, - NPN_Write, - NPN_DestroyStream, - NPN_Status, - NPN_UserAgent, - NPN_MemAlloc, - NPN_MemFree, - NPN_MemFlush, - NPN_ReloadPlugins, -#ifdef OJI - NPN_GetJavaEnv, - NPN_GetJavaPeer, -#else - 0, - 0, -#endif - NPN_GetURLNotify, - NPN_PostURLNotify, - NPN_GetValue, - NPN_SetValue, - NPN_InvalidateRect, - NPN_InvalidateRegion, - NPN_ForceRedraw -}; - -static ::rtl::OString normalizeURL( XPlugin_Impl* plugin, const ::rtl::OString& url ) -{ - ::rtl::OString aLoadURL; - if( url.indexOf( ":" ) == -1 ) - { - aLoadURL = ::rtl::OUStringToOString( plugin->getCreationURL(), plugin->getTextEncoding() ); - int nPos; - if( ( nPos = aLoadURL.indexOf( "://" ) ) != -1 ) - { - if( url.getLength() && (url.getStr()[ 0 ] == '/' || url.indexOf( '/' ) != -1) ) - { - // this means same server but new path - nPos = aLoadURL.indexOf( '/', nPos+3 ); - - if( nPos != -1 ) - aLoadURL = aLoadURL.copy( 0, url.getStr()[0] == '/' ? nPos : nPos+1 ); - } - else - { - // same server but new file - nPos = aLoadURL.lastIndexOf( '/' ); - aLoadURL = aLoadURL.copy( 0, nPos+1 ); - } - aLoadURL += url; - } - else - aLoadURL = url; - } - else if( url.indexOf( ":/" ) != -1 ) - aLoadURL = url; - - return aLoadURL; -} - -struct AsynchronousGetURL -{ - OUString aUrl; - OUString aTarget; - Reference< XEventListener > xListener; - - DECL_LINK( getURL, XPlugin_Impl* ); -}; - -IMPL_LINK( AsynchronousGetURL, getURL, XPlugin_Impl*, pImpl ) -{ - try - { - pImpl->enterPluginCallback(); - if( xListener.is() ) - pImpl->getPluginContext()-> - getURLNotify( pImpl, - aUrl, - aTarget, - xListener ); - else - pImpl->getPluginContext()-> - getURL( pImpl, - aUrl, - aTarget ); - } - catch( ::com::sun::star::plugin::PluginException& e ) - { - (void)e; - } - pImpl->leavePluginCallback(); - delete this; - return 0; -} - - -extern "C" { - - void* SAL_CALL NP_LOADDS NPN_MemAlloc( uint32 nBytes ) - { - TRACE( "NPN_MemAlloc" ); - void* pMem = malloc( nBytes ); - return pMem; - } - - void SAL_CALL NP_LOADDS NPN_MemFree( void* pMem ) - { - TRACE( "NPN_MemFree" ); - free( pMem ); - } - - uint32 SAL_CALL NP_LOADDS NPN_MemFlush( uint32 /*nSize*/ ) - { - TRACE( "NPN_MemFlush" ); - return 0; - } - - NPError SAL_CALL NP_LOADDS NPN_DestroyStream( NPP instance, NPStream* stream, NPError /*reason*/ ) - { - TRACE( "NPN_DestroyStream" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - PluginStream* pStream = pImpl->getStreamFromNPStream( stream ); - if( pStream ) - { - if( pStream->getStreamType() == InputStream ) - static_cast<PluginInputStream*>(pStream)->releaseSelf(); - else - delete pStream; - } - - return NPERR_NO_ERROR; - } - - #ifdef OJI - const JRIEnvInterface** SAL_CALL NP_LOADDS NPN_GetJavaEnv() - { - TRACE( "NPN_GetJavaEnv" ); - // no java in this program - return NULL; - } - - jref SAL_CALL NP_LOADDS NPN_GetJavaPeer( NPP /*instance*/ ) - { - TRACE( "NPN_GetJavaPeer" ); - return NULL; - } - #endif - - NPError SAL_CALL NP_LOADDS NPN_GetURL( NPP instance, const char* url, const char* window ) - { - TRACES( "NPN_GetURL", url ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - AsynchronousGetURL* pAsync = new AsynchronousGetURL(); - - OString aLoadURL = normalizeURL( pImpl, url ); - TRACES( "NPN_GetURL", aLoadURL.getStr() ); - pAsync->aUrl = OStringToOUString( aLoadURL, pImpl->getTextEncoding() ); - pAsync->aTarget = OStringToOUString( window, pImpl->getTextEncoding() ); - pImpl->setLastGetUrl( aLoadURL ); - Application::PostUserEvent( LINK( pAsync, AsynchronousGetURL, getURL ), pImpl ); - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_GetURLNotify( NPP instance, const char* url, const char* target, - void* notifyData ) - { - TRACES( "NPN_GetURLNotify", url ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - OString aLoadURL = normalizeURL( pImpl, url ); - if( !aLoadURL.getLength() ) - return NPERR_INVALID_URL; - - AsynchronousGetURL* pAsync = new AsynchronousGetURL(); - PluginEventListener* pListener = - new PluginEventListener( pImpl, url, aLoadURL.getStr(), notifyData ); - if( ! target || ! *target ) - { - // stream will be fed back to plugin, - // notify immediately after destruction of stream - pImpl->addPluginEventListener( pListener ); - pListener = NULL; - } - pAsync->aUrl = OStringToOUString( aLoadURL, pImpl->getTextEncoding() ); - pAsync->aTarget = OStringToOUString( target, pImpl->getTextEncoding() ); - pAsync->xListener = pListener; - pImpl->setLastGetUrl( aLoadURL ); - Application::PostUserEvent( LINK( pAsync, AsynchronousGetURL, getURL ), pImpl ); - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_NewStream( NPP instance, NPMIMEType type, const char* target, - NPStream** stream ) - // stream is a return value - { - TRACE( "NPN_NewStream" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - PluginOutputStream* pStream = new PluginOutputStream( pImpl, - "", 0, 0 ); - *stream = pStream->getStream(); - - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - newStream( - pImpl, - ::rtl::OStringToOUString( type, pImpl->getTextEncoding () ), - ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ), - ::com::sun::star::uno::Reference< ::com::sun::star::io::XActiveDataSource > ( pStream->getOutputStream(), UNO_QUERY ) - ); - pImpl->leavePluginCallback(); - } - catch( ::com::sun::star::plugin::PluginException& e ) - { - pImpl->leavePluginCallback(); - return e.ErrorCode; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_PostURLNotify( NPP instance, const char* url, const char* target, uint32 len, const char* buf, NPBool file, void* notifyData ) - { - TRACE( "NPN_PostURLNotify" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buf, len ); - - ::rtl::OString aPostURL = normalizeURL( pImpl, url ); - PluginEventListener* pListener = - new PluginEventListener( pImpl, url, aPostURL.getStr(), notifyData ); - - if( ! target || ! *target ) - { - // stream will be fed back to plugin, - // notify immediately after destruction of stream - pImpl->addPluginEventListener( pListener ); - pListener = NULL; - } - - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - postURLNotify( pImpl, - ::rtl::OStringToOUString( aPostURL, pImpl->getTextEncoding() ), - ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ), - Bytes, - file, - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > ( pListener ) ); - pImpl->leavePluginCallback(); - } - catch( ::com::sun::star::plugin::PluginException& e ) - { - pImpl->leavePluginCallback(); - return e.ErrorCode; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_PostURL( NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file ) - { - TRACE( "NPN_PostURL" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buf, len ); - ::rtl::OString aPostURL = normalizeURL( pImpl, url ); - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - postURL( pImpl, - ::rtl::OStringToOUString( aPostURL, pImpl->getTextEncoding() ), - ::rtl::OStringToOUString( window, pImpl->getTextEncoding () ), - Bytes, - file ); - pImpl->leavePluginCallback(); - } - catch( ::com::sun::star::plugin::PluginException& e ) - { - pImpl->leavePluginCallback(); - return e.ErrorCode; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_RequestRead( NPStream* stream, NPByteRange* rangeList ) - { - TRACE( "NPN_RequestRead" ); - if( ! rangeList ) - return NPERR_NO_ERROR; - - ::std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins(); - ::std::list<XPlugin_Impl*>::iterator iter; - XPlugin_Impl* pPlugin = NULL; - PluginStream* pStream = NULL; - for( iter = rList.begin(); iter!= rList.end(); ++iter ) - { - pStream = (*iter)->getStreamFromNPStream( stream ); - if( pStream ) - { - pPlugin = *iter; - break; - } - } - if( ! pPlugin ) - return NPERR_INVALID_INSTANCE_ERROR; - if( ! pStream || pStream->getStreamType() != InputStream ) - return NPERR_FILE_NOT_FOUND; - - PluginInputStream* pInputStream = (PluginInputStream*)pStream; - sal_Int8* pBytes = NULL; - int nBytes = 0; - pPlugin->enterPluginCallback(); - while( rangeList ) - { - if( pBytes && nBytes < (int)rangeList->length ) - { - delete [] pBytes; - pBytes = NULL; - } - if( ! pBytes ) - pBytes = new sal_Int8[ nBytes = rangeList->length ]; - int nRead = - pInputStream->read( rangeList->offset, pBytes, rangeList->length ); - int nPos = 0; - int nNow; - do - { - nNow = pPlugin->getPluginComm()-> - NPP_WriteReady( pPlugin->getNPPInstance(), - stream ); - nNow = pPlugin->getPluginComm()-> - NPP_Write( pPlugin->getNPPInstance(), - stream, - rangeList->offset + nPos, - nNow, - pBytes+nPos ); - nPos += nNow; - nRead -= nNow; - } while( nRead > 0 && nNow ); - rangeList = rangeList->next; - } - pPlugin->leavePluginCallback(); - - return NPERR_NO_ERROR; - } - - void SAL_CALL NP_LOADDS NPN_Status( NPP instance, const char* message ) - { - TRACE( "NPN_Status" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return; - - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - displayStatusText( pImpl, ::rtl::OStringToOUString( message, pImpl->getTextEncoding() ) ); - pImpl->leavePluginCallback(); - } - catch( ::com::sun::star::plugin::PluginException& ) - { - pImpl->leavePluginCallback(); - return; - } - } - - const char* SAL_CALL NP_LOADDS NPN_UserAgent( NPP instance ) - { - static char* pAgent = strdup( "Mozilla 3.0" ); - - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( pImpl ) - { - rtl::OUString UserAgent; - try - { - pImpl->enterPluginCallback(); - UserAgent = pImpl->getPluginContext()-> - getUserAgent( pImpl ); - pImpl->leavePluginCallback(); - if( pAgent ) - free( pAgent ); - pAgent = strdup( ::rtl::OUStringToOString( UserAgent, pImpl->getTextEncoding() ).getStr() ); - } - catch( ::com::sun::star::plugin::PluginException& ) - { - pImpl->leavePluginCallback(); - } - } - - TRACES( "NPN_UserAgent: returning", pAgent ); - - return pAgent; - } - -void SAL_CALL NP_LOADDS NPN_Version( int* major, int* minor, int* net_major, int* net_minor ) -{ - TRACE( "NPN_Version" ); - *major = 4; - *minor = 0; - *net_major = 4; - *net_minor = 5; -} - -int32 SAL_CALL NP_LOADDS NPN_Write( NPP instance, NPStream* stream, int32 len, - void* buffer ) -{ - TRACE( "NPN_Write" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return 0; - - PluginStream* pStream = pImpl->getStreamFromNPStream( stream ); - if( ! pStream || pStream->getStreamType() != OutputStream ) - return 0; - - pImpl->enterPluginCallback(); - ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buffer, len ); - ((PluginOutputStream*)pStream)->getOutputStream()->writeBytes( Bytes ); - pImpl->leavePluginCallback(); - - return len; -} - - -NPError SAL_CALL NP_LOADDS NPN_GetValue( NPP instance, NPNVariable variable, void* value ) -{ - TRACEN( "NPN_GetValue: ", variable ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - - if( ! pImpl ) - return 0; - - NPError aResult( NPERR_NO_ERROR ); - - switch( variable ) - { - case NPNVxDisplay: - // Unix only, handled in sysdep part - case NPNVxtAppContext: - // Unix only, handled in sysdep part - default: - aResult = NPERR_INVALID_PARAM; - break; - #ifdef QUARTZ - case 2000: // NPNVsupportsQuickDrawBool - *(NPBool*)value = false; - break; - case 2001: // NPNVsupportsCoreGraphicsBool - *(NPBool*)value = true; - break; - #endif - case NPNVjavascriptEnabledBool: - // no javascript - *(NPBool*)value = false; - break; - case NPNVasdEnabledBool: - // no SmartUpdate - *(NPBool*)value = false; - break; - case NPNVisOfflineBool: - // no offline browsing - *(NPBool*)value = false; - break; - } - - return aResult; -} - -void SAL_CALL NP_LOADDS NPN_ReloadPlugins(NPBool /*reloadPages*/) -{ - TRACE( "NPN_ReloadPlugins" ); -} - - -NPError SAL_CALL NP_LOADDS NPN_SetValue( NPP instance, - NPPVariable variable, - void* value ) -{ - NPError nError = NPERR_NO_ERROR; - TRACEN( "NPN_SetValue ", variable ); - switch( variable ) - { - #ifdef QUARTZ - case (NPPVariable)1000: // NPNVpluginDrawingModel - { - int nDrawingModel = (int)value; // ugly, but that's the way we need to do it - - TRACEN( "drawing model: ", nDrawingModel ); - - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( pImpl ) - pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel; - } - break; - #endif - case NPPVpluginNameString: // make the windows compiler happy, it needs at least one case statement - break; - default: - break; - } - #ifndef QUARTZ - (void)instance; - (void)value; - #endif - return nError; -} - -void SAL_CALL NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect* /*invalidRect*/) -{ - TRACE( "NPN_InvalidateRect" ); - - #ifdef QUARTZ - NPN_ForceRedraw( instance ); - #else - (void)instance; - #endif -} - -void SAL_CALL NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion /*invalidRegion*/) -{ - TRACE( "NPN_InvalidateRegion" ); - - #ifdef QUARTZ - NPN_ForceRedraw( instance ); - #else - (void)instance; - #endif -} - -void SAL_CALL NP_LOADDS NPN_ForceRedraw(NPP instance) -{ - TRACE( "NPN_ForceRedraw" ); - #ifdef QUARTZ - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( pImpl ) - { - SysPlugData& rPlugData( pImpl->getSysPlugData() ); - if( rPlugData.m_pPlugView ) - [rPlugData.m_pPlugView setNeedsDisplay: YES]; - } - #else - (void)instance; - #endif -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx deleted file mode 100644 index ac3401935..000000000 --- a/extensions/source/plugin/base/plcom.cxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#ifdef SOLARIS -#include <limits> -#endif - -#include <cstdarg> - -#include <tools/fsys.hxx> -#include <plugin/impl.hxx> - -PluginComm::PluginComm( const ::rtl::OString& rLibName, bool bReusable ) : - m_nRefCount( 0 ), - m_aLibName( rLibName ) -{ - if( bReusable ) - PluginManager::get().getPluginComms().push_back( this ); -} - -PluginComm::~PluginComm() -{ - PluginManager::get().getPluginComms().remove( this ); - while( m_aFilesToDelete.size() ) - { - String aFile = m_aFilesToDelete.front(); - m_aFilesToDelete.pop_front(); - DirEntry aEntry( aFile ); - aEntry.Kill(); - } -} - -NPError PluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl ) -{ - return NPP_SetWindow( i_pImpl->getNPPInstance(), i_pImpl->getNPWindow() ); -} - -NPError PluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save ) -{ - return NPP_Destroy( i_pImpl->getNPPInstance(), save ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/plctrl.cxx b/extensions/source/plugin/base/plctrl.cxx deleted file mode 100644 index 44a473ab0..000000000 --- a/extensions/source/plugin/base/plctrl.cxx +++ /dev/null @@ -1,325 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" -#include <com/sun/star/awt/XAdjustmentListener.hpp> -#include <com/sun/star/awt/XActionListener.hpp> -#include <com/sun/star/awt/XTextListener.hpp> -#include <com/sun/star/awt/XSpinListener.hpp> -#include <com/sun/star/awt/XItemListener.hpp> -#include <com/sun/star/awt/XVclContainerListener.hpp> - -#include <plugin/plctrl.hxx> -#include <vcl/syschild.hxx> -#include <toolkit/helper/vclunohelper.hxx> - - -//-------------------------------------------------------------------------------------------------- -PluginControl_Impl::PluginControl_Impl() : - _pMultiplexer( NULL ) - , _nX( 0 ) - , _nY( 0 ) - , _nWidth( 100 ) - , _nHeight( 100 ) - , _nFlags( WINDOW_POSSIZE_ALL ) - , _bVisible( sal_False ) - , _bInDesignMode( sal_False ) - , _bEnable( sal_True ) -{ -} - -//-------------------------------------------------------------------------------------------------- -PluginControl_Impl::~PluginControl_Impl() -{ -} - -MRCListenerMultiplexerHelper* PluginControl_Impl::getMultiplexer() -{ - if( ! _pMultiplexer ) - _pMultiplexer = new MRCListenerMultiplexerHelper( this, _xPeerWindow ); - return _pMultiplexer; -} -//================================================================================================== - -void PluginControl_Impl::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) - throw( RuntimeException ) -{ - _aDisposeListeners.push_back( l ); -} - -//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- -void PluginControl_Impl::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) - throw( RuntimeException ) -{ - _aDisposeListeners.remove( l ); -} - -//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- -void PluginControl_Impl::dispose(void) - throw( RuntimeException ) -{ - // send disposing events - ::com::sun::star::lang::EventObject aEvt; - if( getMultiplexer() ) - getMultiplexer()->disposeAndClear(); - - // release context - _xContext = Reference< XInterface > (); - releasePeer(); -} - - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) - throw( RuntimeException ) -{ - _nX = nX_ >=0 ? nX_ : 0; - _nY = nY_ >=0 ? nY_ : 0; - _nWidth = nWidth_ >=0 ? nWidth_ : 0; - _nHeight = nHeight_ >=0 ? nHeight_ : 0; - _nFlags = nFlags; - - if (_xPeerWindow.is()) - _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, nFlags ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -::com::sun::star::awt::Rectangle PluginControl_Impl::getPosSize(void) - throw( RuntimeException ) -{ - return _xPeerWindow->getPosSize(); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setVisible( sal_Bool bVisible ) - throw( RuntimeException ) -{ - _bVisible = bVisible; - if (_xPeerWindow.is()) - _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setEnable( sal_Bool bEnable ) - throw( RuntimeException ) -{ - _bEnable = bEnable; - if (_xPeerWindow.is()) - _xPeerWindow->setEnable( _bEnable ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setFocus(void) throw( RuntimeException ) -{ - if (_xPeerWindow.is()) - _xPeerWindow->setFocus(); -} - - -//-------------------------------------------------------------------------------------------------- -void PluginControl_Impl::releasePeer() -{ - if (_xPeer.is()) - { - _xParentWindow->removeFocusListener( this ); - _xPeerWindow->dispose(); - _pSysChild = NULL; - _xPeerWindow = Reference< ::com::sun::star::awt::XWindow > (); - _xPeer = Reference< ::com::sun::star::awt::XWindowPeer > (); - getMultiplexer()->setPeer( Reference< ::com::sun::star::awt::XWindow > () ); - } -} - -//---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------ -void PluginControl_Impl::createPeer( const Reference< ::com::sun::star::awt::XToolkit > & /*xToolkit*/, const Reference< ::com::sun::star::awt::XWindowPeer > & xParentPeer ) - throw( RuntimeException ) -{ - if (_xPeer.is()) - { - OSL_FAIL( "### Peer is already set!" ); - return; - } - - _xParentPeer = xParentPeer; - _xParentWindow = Reference< ::com::sun::star::awt::XWindow > ( xParentPeer, UNO_QUERY ); - DBG_ASSERT( _xParentWindow.is(), "### no parent peer window!" ); - - Window* pImpl = VCLUnoHelper::GetWindow( xParentPeer ); - if (pImpl) - { - _pSysChild = new SystemChildWindow( pImpl, WB_CLIPCHILDREN ); - if (pImpl->HasFocus()) - _pSysChild->GrabFocus(); - - // get peer - _xPeer = Reference< ::com::sun::star::awt::XWindowPeer > ( _pSysChild->GetComponentInterface() ); - _xPeerWindow = Reference< ::com::sun::star::awt::XWindow > ( _xPeer, UNO_QUERY ); - // !_BOTH_ MUST BE VALID! - DBG_ASSERT( (_xPeer.is() && _xPeerWindow.is()), "### no peer!" ); - - _xParentWindow->addFocusListener( this ); - _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, _nFlags ); - _xPeerWindow->setEnable( _bEnable ); - _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); - } - else - { - OSL_FAIL( "### cannot get implementation of parent peer!" ); - } - - getMultiplexer()->setPeer( _xPeerWindow ); -} - -//---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------ -void PluginControl_Impl::setDesignMode( sal_Bool bOn ) - throw( RuntimeException ) -{ - _bInDesignMode = bOn; - if (_xPeerWindow.is()) - _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addPaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removePaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l ); -} - -//---- ::com::sun::star::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) - throw( RuntimeException ) -{ - getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l ); -} - - -//---- ::com::sun::star::awt::XView --------------------------------------------------------------------------------------- -void PluginControl_Impl::draw( sal_Int32 /*x*/, sal_Int32 /*y*/ ) - throw( RuntimeException ) -{ - // has to be done by further implementation of control -} - -//---- ::com::sun::star::awt::XView --------------------------------------------------------------------------------------- -void PluginControl_Impl::setZoom( float /*ZoomX*/, float /*ZoomY*/ ) - throw( RuntimeException ) -{ - // has to be done by further implementation of control -} - -//---- ::com::sun::star::lang::XEventListener ------------------------------------------------------------------------------ -void PluginControl_Impl::disposing( const ::com::sun::star::lang::EventObject & /*rSource*/ ) - throw( RuntimeException ) -{ -} -//---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------ -void PluginControl_Impl::focusGained( const ::com::sun::star::awt::FocusEvent & /*rEvt*/ ) - throw( RuntimeException ) -{ - if (_xPeerWindow.is()) - _xPeerWindow->setFocus(); -} -//---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------ -void PluginControl_Impl::focusLost( const ::com::sun::star::awt::FocusEvent & /*rEvt*/ ) - throw( RuntimeException ) -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/plmodel.cxx b/extensions/source/plugin/base/plmodel.cxx deleted file mode 100644 index d09bd7c14..000000000 --- a/extensions/source/plugin/base/plmodel.cxx +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" -#include <plugin/model.hxx> -#include <com/sun/star/beans/PropertyAttribute.hpp> - -using namespace com::sun::star::uno; - -//================================================================================================== -Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception ) -{ - Reference< XInterface > xService = *new PluginModel(); - return xService; -} - -Any PluginModel::queryAggregation( const Type& type ) throw( RuntimeException ) -{ - Any aRet( ::cppu::queryInterface( type, - static_cast< ::com::sun::star::lang::XComponent* >(this), - static_cast< ::com::sun::star::io::XPersistObject* >(this ), - static_cast< ::com::sun::star::awt::XControlModel* >(this), - static_cast< ::com::sun::star::beans::XPropertySet* >(this), - static_cast< ::com::sun::star::beans::XMultiPropertySet* >(this), - static_cast< ::com::sun::star::beans::XFastPropertySet* >(this) - ) ); - return aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( type ); -} - - -// XPluginManager_Impl -Sequence< ::rtl::OUString > PluginModel::getSupportedServiceNames_Static(void) throw() -{ - Sequence< ::rtl::OUString > aSNS( 1 ); - aSNS.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.plugin.PluginModel")); - return aSNS; -} - - -static const char* aCreationURL = "URL"; -static const char* aMime = "TYPE"; - -static ::osl::Mutex aPropertyMutex; - -static ::com::sun::star::beans::Property aProps[] = -{ - ::com::sun::star::beans::Property( - ::rtl::OUString::createFromAscii( aMime ), - 1, - ::getCppuType((const ::rtl::OUString*)0), - ::com::sun::star::beans::PropertyAttribute::BOUND ), - ::com::sun::star::beans::Property( - ::rtl::OUString::createFromAscii( aCreationURL ), - 2, - ::getCppuType((const ::rtl::OUString*)0), - ::com::sun::star::beans::PropertyAttribute::BOUND ) -}; - -PluginModel::PluginModel() : - BroadcasterHelperHolder( aPropertyMutex ), - OPropertySetHelper( m_aHelper ), - OPropertyArrayHelper( aProps, 2 ) -{ -} - -PluginModel::PluginModel(const ::rtl::OUString& rURL, const rtl::OUString& rMimeType ) : - BroadcasterHelperHolder( aPropertyMutex ), - OPropertySetHelper( m_aHelper ), - OPropertyArrayHelper( aProps, 2 ), - m_aCreationURL( rURL ), - m_aMimeType( rMimeType ) -{ -} - -PluginModel::~PluginModel() -{ -} - -Reference< ::com::sun::star::beans::XPropertySetInfo > PluginModel::getPropertySetInfo() throw() -{ - static Reference< ::com::sun::star::beans::XPropertySetInfo > aInfo = - createPropertySetInfo( *this ); - return aInfo; -} - -::cppu::IPropertyArrayHelper& PluginModel::getInfoHelper() -{ - return *this; -} - -sal_Bool PluginModel::convertFastPropertyValue( Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) throw() -{ - if( nHandle == 1 || nHandle == 2 ) - { - if( rValue.getValueTypeClass() == TypeClass_STRING ) - { - rConvertedValue = rValue; - if( nHandle == 2 ) - rOldValue <<= m_aCreationURL; - else if( nHandle == 1 ) - rOldValue <<= m_aMimeType; - return sal_True; - } - } - return sal_False; -} - -void PluginModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, - const Any& rValue ) - throw(::com::sun::star::uno::Exception) -{ - if( rValue.getValueTypeClass() == TypeClass_STRING ) // FIXME wrong type! - - { - if( nHandle == 2 ) - rValue >>= m_aCreationURL; - else if( nHandle == 1 ) - rValue >>= m_aMimeType; - } - else - throw ::com::sun::star::lang::IllegalArgumentException(); -} - -void PluginModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw() -{ - if( nHandle == 2 ) - rValue <<= m_aCreationURL; - else if( nHandle == 1 ) - rValue <<= m_aMimeType; -} - -//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- -void PluginModel::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw() -{ - m_aDisposeListeners.push_back( l ); -} - -//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- -void PluginModel::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw() -{ - m_aDisposeListeners.remove( l ); -} - -//---- ::com::sun::star::lang::XComponent ---------------------------------------------------------------------------------- -void PluginModel::dispose(void) throw() -{ - // send disposing events - ::com::sun::star::lang::EventObject aEvt; - aEvt.Source = (::cppu::OWeakObject*)this; - ::std::list< Reference< ::com::sun::star::lang::XEventListener > > aLocalListeners = m_aDisposeListeners; - for( ::std::list< Reference< ::com::sun::star::lang::XEventListener > >::iterator it = aLocalListeners.begin(); - it != aLocalListeners.end(); ++it ) - (*it)->disposing( aEvt ); - - m_aDisposeListeners.clear(); - - disposing(); -} - - -// ::com::sun::star::io::XPersistObject -::rtl::OUString PluginModel::getServiceName() throw() -{ - return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.plugin.PluginModel")); -} - -void PluginModel::write(const Reference< ::com::sun::star::io::XObjectOutputStream > & OutStream) throw() -{ - OutStream->writeUTF( m_aCreationURL ); -} - -void PluginModel::read(const Reference< ::com::sun::star::io::XObjectInputStream > & InStream) throw() -{ - m_aCreationURL = InStream->readUTF(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/service.cxx b/extensions/source/plugin/base/service.cxx deleted file mode 100644 index 5ecb800d4..000000000 --- a/extensions/source/plugin/base/service.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#include <cstdarg> - -#include <plugin/impl.hxx> -#include <tools/debug.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/container/XSet.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> - -#include <uno/dispatcher.h> // declaration of generic uno interface -#include <uno/mapping.hxx> // mapping stuff - -#include <cppuhelper/factory.hxx> - -using namespace cppu; - -extern "C" { - SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( - const sal_Char* pImplementationName, - void* pXUnoSMgr, - void* /*pXUnoKey*/ - ) - { - void* pRet = 0; - - ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) ); - - if( pXUnoSMgr ) - { - Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( - reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr ) - ); - Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory; - if( aImplName.equals( XPluginManager_Impl::getImplementationName_Static() ) ) - { - xFactory = ::cppu::createSingleFactory( - xMgr, aImplName, PluginManager_CreateInstance, - XPluginManager_Impl::getSupportedServiceNames_Static() ); - } - else if( aImplName.equals( PluginModel::getImplementationName_Static() ) ) - { - xFactory = ::cppu::createSingleFactory( - xMgr, aImplName, PluginModel_CreateInstance, - PluginModel::getSupportedServiceNames_Static() ); - } - if( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - return pRet; - } -} /* extern "C" */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx deleted file mode 100644 index 19d1d6cb0..000000000 --- a/extensions/source/plugin/base/xplugin.cxx +++ /dev/null @@ -1,1157 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#undef OPTIONAL -#endif - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/loader/XImplementationLoader.hpp> -#include <com/sun/star/loader/CannotActivateFactoryException.hpp> - -#include <plugin/impl.hxx> -#include <tools/fsys.hxx> -#include <ucbhelper/content.hxx> -#include <tools/urlobj.hxx> -#include <tools/string.hxx> -#include <vcl/svapp.hxx> -#include <salhelper/timer.hxx> -#include <osl/file.hxx> - -#ifdef UNX -#include <sys/types.h> -#include <sys/socket.h> -#endif - -#if OSL_DEBUG_LEVEL > 1 -#include <stdio.h> -#endif - -using namespace com::sun::star; -using namespace com::sun::star::io; -using namespace com::sun::star::beans; -using namespace com::sun::star::plugin; -using namespace osl; - -using ::rtl::OUString; -using ::rtl::OString; - -class PluginDisposer : public salhelper::Timer -{ -private: - XPlugin_Impl* m_pPlugin; - - virtual void SAL_CALL onShot(); -public: - PluginDisposer( XPlugin_Impl* pPlugin ) : - salhelper::Timer( salhelper::TTimeValue( 2, 0 ), - salhelper::TTimeValue( 2, 0 ) ), - m_pPlugin( pPlugin ) - { start(); } - ~PluginDisposer() {} -}; - -void PluginDisposer::onShot() -{ - if( m_pPlugin ) - { - if( m_pPlugin->isDisposable() ) - { - sal_uLong nEvent; - Application::PostUserEvent( nEvent, LINK( m_pPlugin, XPlugin_Impl, secondLevelDispose ), (void*)m_pPlugin ); - } - } - else - release(); -} - -//================================================================================================== - -Any XPlugin_Impl::queryInterface( const Type& type ) throw( RuntimeException ) -{ - return OWeakAggObject::queryInterface( type ); -} - -Any XPlugin_Impl::queryAggregation( const Type& type ) throw( RuntimeException ) -{ - Any aRet( cppu::queryInterface( type, static_cast< XPlugin* >(this) ) ); - if( ! aRet.hasValue() ) - aRet = PluginControl_Impl::queryAggregation( type ); - return aRet; -} - - -XPlugin_Impl::XPlugin_Impl( const uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) : - PluginControl_Impl(), - m_xSMgr( rSMgr ), - m_pPluginComm( NULL ), - m_aEncoding( gsl_getSystemTextEncoding() ), - m_pArgv( NULL ), - m_pArgn( NULL ), - m_nArgs( 0 ), - m_aPluginMode( NP_FULL ), - m_nProvidingState( PROVIDING_NONE ), - m_nCalledFromPlugin( 0 ), - m_pDisposer( NULL ), - m_bIsDisposed( sal_False ) -{ - memset( &m_aInstance, 0, sizeof( m_aInstance ) ); - memset( &m_aNPWindow, 0, sizeof( m_aNPWindow ) ); - memset( &m_aSysPlugData, 0, sizeof( m_aSysPlugData ) ); - - m_xModel = new PluginModel(); - uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - xPS->addPropertyChangeListener( OUString(), this ); - - Guard< Mutex > aGuard( PluginManager::get().getPluginMutex() ); - PluginManager::get().getPlugins().push_back( this ); -} - -void XPlugin_Impl::destroyInstance() -{ - Guard< Mutex > aGuard( m_aMutex ); - - NPSavedData* pSavedData = NULL; - - destroyStreams(); - if( getPluginComm() ) - { - getPluginComm()->NPP_Destroy( this, &pSavedData ); - getPluginComm()->decRef(); - m_pPluginComm = NULL; - } - - freeArgs(); - - while( m_aPEventListeners.size() ) - { - delete *m_aPEventListeners.begin(); - m_aPEventListeners.pop_front(); - } -} - -XPlugin_Impl::~XPlugin_Impl() -{ - destroyInstance(); -} - -void XPlugin_Impl::checkListeners( const char* normalizedURL ) -{ - if( ! normalizedURL ) - return; - - Guard< Mutex > aGuard( m_aMutex ); - - std::list<PluginEventListener*>::iterator iter; - for( iter = m_aPEventListeners.begin(); - iter != m_aPEventListeners.end(); - ++iter ) - { - if( ! strcmp( normalizedURL, (*iter)->getURL() ) || - ! strcmp( normalizedURL, (*iter)->getNormalizedURL() ) ) - { - (*iter)->disposing( com::sun::star::lang::EventObject() ); - delete *iter; - m_aPEventListeners.remove( *iter ); - return; - } - } -} - -IMPL_LINK( XPlugin_Impl, secondLevelDispose, XPlugin_Impl*, /*pThis*/ ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - // may have become undisposable between PostUserEvent and here - // or may have disposed and receive a second UserEvent - std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins(); - std::list<XPlugin_Impl*>::iterator iter; - - { - Guard< Mutex > aPluginGuard( PluginManager::get().getPluginMutex() ); - for( iter = rList.begin(); iter != rList.end(); ++iter ) - { - if( *iter == this ) - break; - } - if( iter == rList.end() || ! isDisposable() ) - return 0; - } - - if (m_pDisposer) - { - m_pDisposer->release(); - m_pDisposer = NULL; - } - - uno::Reference< XPlugin > xProtection( this ); - uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - xPS->removePropertyChangeListener( OUString(), this ); - { - Guard< Mutex > aPluginGuard( PluginManager::get().getPluginMutex() ); - rList.remove( this ); - } - m_aNPWindow.window = NULL; -#ifndef UNX - // acrobat does an unconditional XtParent on the windows widget - getPluginComm()->NPP_SetWindow( this ); -#endif - destroyInstance(); - PluginControl_Impl::dispose(); - return 0; -} - -void XPlugin_Impl::dispose() throw() -{ - Guard< Mutex > aGuard( m_aMutex ); - - if (m_bIsDisposed || !getPluginComm()) - return; - m_bIsDisposed = sal_True; - - if( isDisposable() ) - secondLevelDispose( this ); - else - { - m_pDisposer = new PluginDisposer( this ); - m_pDisposer->acquire(); - } -} - -void XPlugin_Impl::initArgs( const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ) -{ - m_aPluginMode = mode; - - m_nArgs = argn.getLength(); - m_pArgn = new const char*[m_nArgs]; - m_pArgv = new const char*[m_nArgs]; - const OUString* pUArgn = argn.getConstArray(); - const OUString* pUArgv = argv.getConstArray(); - for( int i = 0; i < m_nArgs; i++ ) - { - m_pArgn[i] = strdup( - OUStringToOString( pUArgn[i], m_aEncoding ).getStr() - ); - m_pArgv[i] = strdup( - OUStringToOString( pUArgv[i], m_aEncoding ).getStr() - ); - } -} - -void XPlugin_Impl::freeArgs() -{ - if( m_nArgs > 0 ) - { - for( ; m_nArgs--; ) - { - free( (void*)m_pArgn[m_nArgs] ); - free( (void*)m_pArgv[m_nArgs] ); - } - delete [] m_pArgn; - delete [] m_pArgv; - } -} - -void XPlugin_Impl::prependArg( const char* pName, const char* pValue ) -{ - const char** pNewNames = new const char*[m_nArgs+1]; - const char** pNewValues = new const char*[m_nArgs+1]; - - pNewNames[0] = strdup( pName ); - pNewValues[0] = strdup( pValue ); - for( int nIndex = 0; nIndex < m_nArgs; ++nIndex ) - { - pNewNames[nIndex+1] = m_pArgn[nIndex]; - pNewValues[nIndex+1]= m_pArgv[nIndex]; - } - // free old arrays - delete [] m_pArgn; - delete [] m_pArgv; - // set new arrays - m_pArgn = pNewNames; - m_pArgv = pNewValues; - // set new number of arguments - m_nArgs++; -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "inserted %s=%s\n", pNewNames[0], pNewValues[0] ); -#endif -} - -void XPlugin_Impl::handleSpecialArgs() -{ - // special handling for real audio which needs a lot of parameters - // or won't function at all - if( ! m_aDescription.Mimetype.compareToAscii( "audio/x-pn-realaudio-plugin" ) && m_nArgs < 1 ) - { - OUString aURL; - if( m_xModel.is() ) - { - try - { - uno::Reference< XPropertySet > xProp( m_xModel, UNO_QUERY ); - Any aProp = xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) ); - aProp >>= aURL; - } - catch( UnknownPropertyException ) - { - } - } - - if( aURL.getLength() ) - { - // set new args, old args need not be freed as there were none set - m_nArgs = 6; - m_pArgn = new const char*[m_nArgs]; - m_pArgv = new const char*[m_nArgs]; - - // SRC - m_pArgn[0] = strdup( "SRC" ); - m_pArgv[0] = strdup( OUStringToOString( aURL, m_aEncoding ).getStr() ); - // WIDTH - m_pArgn[1] = strdup( "WIDTH" ); - m_pArgv[1] = strdup( "200" ); - // HEIGHT - m_pArgn[2] = strdup( "HEIGHT" ); - m_pArgv[2] = strdup( "200" ); - // CONTROLS - m_pArgn[3] = strdup( "CONTROLS" ); - m_pArgv[3] = strdup( "PlayButton,StopButton,ImageWindow" ); - // AUTOSTART - m_pArgn[4] = strdup( "AUTOSTART" ); - m_pArgv[4] = strdup( "TRUE" ); - // NOJAVA - m_pArgn[5] = strdup( "NOJAVA" ); - m_pArgv[5] = strdup( "TRUE" ); - } - } - // #69333# special for pdf - else if( ! m_aDescription.Mimetype.compareToAscii( "application/pdf" ) ) - m_aPluginMode = PluginMode::FULL; - - // see if we have a TYPE tag - int nIndex; - for( nIndex = 0; nIndex < m_nArgs; ++nIndex ) - if( m_pArgn[nIndex][0] == 'T' && - m_pArgn[nIndex][1] == 'Y' && - m_pArgn[nIndex][2] == 'P' && - m_pArgn[nIndex][3] == 'E' && - m_pArgn[nIndex][4] == 0 ) - break; - if( nIndex >= m_nArgs ) - { - // TYPE - prependArg( "TYPE", OUStringToOString( m_aDescription.Mimetype, m_aEncoding ).getStr() ); - } - - // see if we have a SRC tag - for( nIndex = 0; nIndex < m_nArgs; ++nIndex ) - if( m_pArgn[nIndex][0] == 'S' && - m_pArgn[nIndex][1] == 'R' && - m_pArgn[nIndex][2] == 'C' && - m_pArgn[nIndex][3] == 0 ) - break; - if( nIndex >= m_nArgs ) - { - // need a SRC parameter (as all browser set one on the plugin - OUString aURL; - if( m_xModel.is() ) - { - try - { - uno::Reference< XPropertySet > xProp( m_xModel, UNO_QUERY ); - Any aProp = xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) ); - aProp >>= aURL; - } - catch( UnknownPropertyException ) - { - } - } - - if( aURL.getLength() ) - { - // SRC - prependArg( "SRC", OUStringToOString( aURL, m_aEncoding ).getStr() ); - } - } -} - -void XPlugin_Impl::initInstance( const PluginDescription& rDescription, - const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - m_aDescription = rDescription; - initArgs( argn, argv, mode ); - handleSpecialArgs(); -} - -void XPlugin_Impl::initInstance( const OUString& rURL, - const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - initArgs( argn, argv, mode ); - m_aDescription = fitDescription( rURL ); - - m_xModel = new PluginModel( rURL, m_aDescription.Mimetype ); - handleSpecialArgs(); -} - -void XPlugin_Impl::modelChanged() -{ - Guard< Mutex > aGuard( m_aMutex ); - - m_nProvidingState = PROVIDING_MODEL_UPDATE; - - destroyInstance(); - - m_aDescription = fitDescription( getCreationURL() ); - if( !m_aDescription.Mimetype.getLength() ) - { - m_nProvidingState = PROVIDING_NONE; - return; - } - - OUString aURL = getCreationURL(); - provideNewStream( m_aDescription.Mimetype, - uno::Reference< XActiveDataSource >(), - aURL, - 0, 0, (sal_Bool)(aURL.compareToAscii( "file:", 5 ) == 0) ); - m_nProvidingState = PROVIDING_NONE; -} - -OUString XPlugin_Impl::getCreationURL() -{ - Guard< Mutex > aGuard( m_aMutex ); - - OUString aRet; - uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - if( xPS.is() ) - { - Any aValue = xPS->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) ); - aValue >>= aRet; - } - return aRet; -} - - -sal_Bool XPlugin_Impl::setModel( const uno::Reference< com::sun::star::awt::XControlModel > & Model ) - throw( RuntimeException ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - uno::Reference< com::sun::star::beans::XPropertySet > xPS( Model, UNO_QUERY ); - if( ! xPS.is() ) - return sal_False; - - if( getCreationURL().getLength() ) - { - m_xModel = Model; - modelChanged(); - xPS->addPropertyChangeListener( OUString(), this ); - return sal_True; - } - return sal_False; -} - -void XPlugin_Impl::createPeer( const uno::Reference< com::sun::star::awt::XToolkit > & xToolkit, const uno::Reference< com::sun::star::awt::XWindowPeer > & Parent ) - throw( RuntimeException ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - if( ! _xPeer.is() ) - { - if( ! Parent.is() ) - throw RuntimeException(); - PluginControl_Impl::createPeer( xToolkit, Parent ); - } -} - -void XPlugin_Impl::loadPlugin() -{ - Guard< Mutex > aGuard( m_aMutex ); - - std::list<PluginComm*>::iterator iter; - for( iter = PluginManager::get().getPluginComms().begin(); - iter != PluginManager::get().getPluginComms().end(); ++iter ) - { - if( OStringToOUString( (*iter)->getLibName(), m_aEncoding ) == m_aDescription.PluginName ) - { - setPluginComm( *iter ); - break; - } - } - const SystemEnvData* pEnvData = getSysChildSysData(); -#if defined( UNX ) && !(defined(QUARTZ)) - XSync( (Display*)pEnvData->pDisplay, False ); -#endif - if( ! getPluginComm() ) - { - if( m_aDescription.PluginName.getLength() ) - { -#if defined QUARTZ - PluginComm* pComm = new MacPluginComm( m_aDescription.Mimetype, - m_aDescription.PluginName, - pEnvData->pView ); -#elif defined UNX - // need a new PluginComm - PluginComm* pComm = NULL; - int sv[2]; - if( !socketpair( AF_UNIX, SOCK_STREAM, 0, sv ) ) - pComm = new UnxPluginComm( m_aDescription.Mimetype, - m_aDescription.PluginName, - (XLIB_Window)pEnvData->aWindow, - sv[0], - sv[1] - ); -#elif defined WNT - PluginComm* pComm = new PluginComm_Impl( m_aDescription.Mimetype, - m_aDescription.PluginName, - (HWND)pEnvData->hWnd ); -#endif - setPluginComm( pComm ); - } - else - return; - } - - getPluginComm()-> - NPP_New( (char*)OUStringToOString( m_aDescription.Mimetype, - m_aEncoding).getStr(), - getNPPInstance(), - m_aPluginMode == PluginMode::FULL ? NP_FULL : NP_EMBED, - ::sal::static_int_cast< int16, int >( m_nArgs ), - (char**)(m_nArgs ? m_pArgn : NULL), - (char**)(m_nArgs ? m_pArgv : NULL), - NULL ); -#ifdef QUARTZ - // m_aNPWindow is set up in the MacPluginComm from the view - m_aSysPlugData.m_pParentView = pEnvData->pView; -#elif defined( UNX ) - XSync( (Display*)pEnvData->pDisplay, False ); - m_aNPWindow.window = (void*)pEnvData->aWindow; - m_aNPWindow.ws_info = NULL; -#else - m_aNPWindow.window = (void*)pEnvData->hWnd; -#endif - com::sun::star::awt::Rectangle aPosSize = getPosSize(); - - for( int i = 0; i < m_nArgs; i++ ) - { - OString aName( m_pArgn[i] ); - if( aName.equalsIgnoreAsciiCase( "width" ) ) - { - OString aValue( m_pArgv[i] ); - aPosSize.Width = aValue.toInt32(); - } - else if( aName.equalsIgnoreAsciiCase( "height" ) ) - { - OString aValue( m_pArgv[i] ); - aPosSize.Height = aValue.toInt32(); - } - } - - m_aNPWindow.clipRect.top = 0; - m_aNPWindow.clipRect.left = 0; - m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16, sal_Int32 >( aPosSize.Height ); - m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16, sal_Int32 >( aPosSize.Width ); - m_aNPWindow.type = NPWindowTypeWindow; - - m_aNPWindow.x = 0; - m_aNPWindow.y = 0; - m_aNPWindow.width = aPosSize.Width ? aPosSize.Width : 600; - m_aNPWindow.height = aPosSize.Height ? aPosSize.Height : 600; - - getPluginComm()->NPP_SetWindow( this ); -} - -void XPlugin_Impl::destroyStreams() -{ - Guard< Mutex > aGuard( m_aMutex ); - - // streams remove themselves from this list when deleted - while( m_aOutputStreams.size() ) - delete *m_aOutputStreams.begin(); - - // input streams are XOutputStreams, they cannot be simply deleted - std::list<PluginInputStream*> aLocalList( m_aInputStreams ); - for( std::list<PluginInputStream*>::iterator it = aLocalList.begin(); - it != aLocalList.end(); ++it ) - (*it)->setMode( -1 ); -} - -PluginStream* XPlugin_Impl::getStreamFromNPStream( NPStream* stream ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - std::list<PluginInputStream*>::iterator iter; - for( iter = m_aInputStreams.begin(); iter != m_aInputStreams.end(); ++iter ) - if( (*iter)->getStream() == stream ) - return *iter; - - std::list<PluginOutputStream*>::iterator iter2; - for( iter2 = m_aOutputStreams.begin(); iter2 != m_aOutputStreams.end(); ++iter2 ) - if( (*iter2)->getStream() == stream ) - return *iter2; - - return NULL; -} - -sal_Bool XPlugin_Impl::provideNewStream(const OUString& mimetype, - const uno::Reference< com::sun::star::io::XActiveDataSource > & stream, - const OUString& url, sal_Int32 length, - sal_Int32 lastmodified, sal_Bool isfile) throw() - -{ - Guard< Mutex > aGuard( m_aMutex ); - sal_Bool bRet = sal_False; - - if( m_nProvidingState != PROVIDING_NONE ) - { - m_nProvidingState = PROVIDING_NOW; - Any aAny; - aAny <<= url; - uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - if( xPS.is() ) - { - try - { - xPS->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("URL")), aAny ); - aAny <<= mimetype; - xPS->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TYPE")), aAny ); - } - catch(...) - { - } - } - } - m_nProvidingState = PROVIDING_NOW; - - OString aMIME; - if( mimetype.getLength() ) - aMIME = OUStringToOString( mimetype, m_aEncoding ); - else - aMIME = OUStringToOString( m_aDescription.Mimetype, m_aEncoding ); - - OString aURL = OUStringToOString( url, m_aEncoding ); - - // check wether there is a notifylistener for this stream - // this means that the strema is created from the plugin - // via NPN_GetURLNotify or NPN_PostURLNotify - std::list<PluginEventListener*>::iterator iter; - for( iter = m_aPEventListeners.begin(); - iter != m_aPEventListeners.end(); - ++iter ) - { - if( (*iter)->getNormalizedURL() == aURL ) - { - aURL = (*iter)->getURL(); - break; - } - } - - if( ! m_pPluginComm ) - { - loadPlugin(); - if( m_aLastGetUrl.getLength() && m_aLastGetUrl == aURL ) - { - // plugin is pulling data, don't push the same stream; - // this complicated method could have been avoided if - // all plugins respected the SRC parameter; but e.g. - // acrobat reader plugin does not - m_nProvidingState = PROVIDING_NONE; - return sal_True; - } - } - if( ! m_pPluginComm ) - return sal_False; - - if( ! url.getLength() ) - // this is valid if the plugin is supposed to - // pull data (via e.g. NPN_GetURL) - return sal_True; - - // set mimetype on model - { - uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - if( xPS.is() ) - { - try - { - Any aAny; - aAny <<= m_aDescription.Mimetype; - xPS->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TYPE")), aAny ); - } - catch(...) - { - } - } - } - - // there may be plugins that can use the file length information, - // but currently none are known. Since this file opening/seeking/closing - // is rather costly, it is not implemented. If there are plugins known to - // make use of the file length, simply put it in - - PluginInputStream* pStream = new PluginInputStream( this, aURL.getStr(), - length, lastmodified ); - uno::Reference< com::sun::star::io::XOutputStream > xNewStream( pStream ); - - if( iter != m_aPEventListeners.end() ) - pStream->getStream()->notifyData = (*iter)->getNotifyData(); - - uint16 stype = 0; - - // special handling acrobat reader - // presenting a seekable stream to it does not seem to work correctly - if( aMIME.equals( "application/pdf" ) ) - isfile = sal_False; - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "new stream \"%s\" of MIMEType \"%s\"\n" - "for plugin \"%s\"\n" - "seekable = %s, length = %"SAL_PRIdINT32"\n", - aURL.getStr(), aMIME.getStr(), getPluginComm()->getLibName().getStr(), - isfile ? "true" : "false", length ); - -#endif - if( ! m_pPluginComm->NPP_NewStream( &m_aInstance, - (char*)aMIME.getStr(), - pStream->getStream(), isfile, - &stype ) ) - { -#if OSL_DEBUG_LEVEL > 1 - const char* pType; - switch( stype ) - { - case NP_NORMAL: pType = "NP_NORMAL";break; - case NP_SEEK: pType = "NP_SEEK";break; - case NP_ASFILE: pType = "NP_ASFILE";break; - case NP_ASFILEONLY: pType = "NP_ASFILEONLY";break; - default: pType = "unknown!!!"; - } - fprintf( stderr, "Plugin wants it in Mode %s\n", pType ); -#endif - if( isfile && stype == NP_ASFILEONLY ) - { - OString aFileName; - if( url.compareToAscii( "file:", 5 ) == 0 ) - { - OUString aSysName; - osl_getSystemPathFromFileURL( url.pData, &aSysName.pData ); - aFileName = OUStringToOString( aSysName, m_aEncoding ); - } - else - aFileName = OUStringToOString( url, m_aEncoding ); - m_pPluginComm-> - NPP_StreamAsFile( &m_aInstance, - pStream->getStream(), - aFileName.getStr() ); - } - else - { - pStream->setMode( stype ); - - if( ! stream.is() ) - { - // stream has to be loaded by PluginStream itself via UCB - pStream->load(); - } - else - { - uno::Reference< com::sun::star::io::XConnectable > xConnectable( stream, UNO_QUERY ); - pStream->setPredecessor( xConnectable ); - if( xConnectable.is() ) - { - xConnectable->setSuccessor( static_cast< com::sun::star::io::XConnectable* >(pStream) ); - while( xConnectable->getPredecessor().is() ) - xConnectable = xConnectable->getPredecessor(); - } - stream->setOutputStream( xNewStream ); - pStream->setSource( stream ); - uno::Reference< com::sun::star::io::XActiveDataControl > xController; - if( xConnectable.is() ) - xController = uno::Reference< com::sun::star::io::XActiveDataControl >( xConnectable, UNO_QUERY ); - else - xController = uno::Reference< com::sun::star::io::XActiveDataControl >( stream, UNO_QUERY ); - - if( xController.is() ) - xController->start(); - } - } - bRet = sal_True; - } - - m_nProvidingState = PROVIDING_NONE; - - return bRet; -} - -void XPlugin_Impl::disposing( const com::sun::star::lang::EventObject& /*rSource*/ ) throw() -{ -} - -void XPlugin_Impl::propertyChange( const com::sun::star::beans::PropertyChangeEvent& rEvent ) throw() -{ - Guard< Mutex > aGuard( m_aMutex ); - - if( ! rEvent.PropertyName.compareToAscii( "URL" ) ) - { - OUString aStr; - rEvent.NewValue >>= aStr; - if( m_nProvidingState == PROVIDING_NONE ) - { - if( aStr != m_aURL ) - { - m_aURL = aStr; - modelChanged(); - } - } - } -} - -void XPlugin_Impl::setPluginContext( const uno::Reference< XPluginContext > & rContext ) -{ - m_rBrowserContext = rContext; -} - -void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) - throw( RuntimeException ) -{ - Guard< Mutex > aGuard( m_aMutex ); - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "XPlugin_Impl::setPosSize( %"SAL_PRIdINT32", %"SAL_PRIdINT32", %"SAL_PRIdINT32", %"SAL_PRIdINT32", %d )\n", - nX_, nY_, nWidth_, nHeight_, nFlags ); -#endif - - PluginControl_Impl::setPosSize(nX_, nY_, nWidth_, nHeight_, nFlags); - - m_aNPWindow.x = 0; - m_aNPWindow.y = 0; - m_aNPWindow.width = nWidth_; - m_aNPWindow.height = nHeight_; - m_aNPWindow.clipRect.top = 0; - m_aNPWindow.clipRect.left = 0; - m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16, sal_Int32 >( nWidth_ ); - m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16, sal_Int32 >( nHeight_ ); - - if( getPluginComm() ) - getPluginComm()->NPP_SetWindow( this ); -} - -PluginDescription XPlugin_Impl::fitDescription( const OUString& rURL ) -{ - uno::Reference< XPluginManager > xPMgr( m_xSMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.plugin.PluginManager")) ), UNO_QUERY ); - if( !xPMgr.is() ) - { - m_nProvidingState = PROVIDING_NONE; - return PluginDescription(); - } - - Sequence< PluginDescription > aDescrs = xPMgr->getPluginDescriptions(); - const PluginDescription* pDescrs = aDescrs.getConstArray(); - - for( int nArg = 0; nArg < m_nArgs; nArg++ ) - { - if( strncmp( m_pArgn[nArg], "TYPE", 4 ) == 0 && - m_pArgn[nArg][4] == 0 ) - { - for( int i = 0; i < aDescrs.getLength(); i++ ) - { - if( pDescrs[i].Mimetype.compareToAscii( m_pArgv[nArg] ) == 0 ) - return pDescrs[i]; - } - } - } - - int nPos = rURL.lastIndexOf( (sal_Unicode)'.' ); - OUString aExt = rURL.copy( nPos ).toAsciiLowerCase(); - if( nPos != -1 ) - { - for( int i = 0; i < aDescrs.getLength(); i++ ) - { - OUString aThisExt = pDescrs[ i ].Extension.toAsciiLowerCase(); - if( aThisExt.indexOf( aExt ) != -1 ) - { - return pDescrs[i]; - } - } - } - return PluginDescription(); -} - - -PluginStream::PluginStream( XPlugin_Impl* pPlugin, - const char* url, sal_uInt32 len, sal_uInt32 lastmod ) : - m_pPlugin( pPlugin ) -{ - memset( &m_aNPStream, 0, sizeof( m_aNPStream ) ); - m_aNPStream.url = strdup( url ); - m_aNPStream.end = len; - m_aNPStream.lastmodified = lastmod; -} - -PluginStream::~PluginStream() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - if( m_pPlugin && m_pPlugin->getPluginComm() ) - { - m_pPlugin->getPluginComm()->NPP_DestroyStream( m_pPlugin->getNPPInstance(), - &m_aNPStream, NPRES_DONE ); - m_pPlugin->checkListeners( m_aNPStream.url ); - m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin ); - } - ::free( (void*)m_aNPStream.url ); -} - -PluginInputStream::PluginInputStream( XPlugin_Impl* pPlugin, - const char* url, - sal_uInt32 len, - sal_uInt32 lastmod ) : - PluginStream( pPlugin, url, len, lastmod ), - m_pContent( NULL ), - m_nMode( NP_NORMAL ), - m_nWritePos( 0 ) -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getInputStreams().push_back( this ); - DirEntry aEntry; - aEntry = aEntry.TempName(); - - // set correct extension, some plugins need that - DirEntry aName( String( m_aNPStream.url, m_pPlugin->getTextEncoding() ) ); - String aExtension = aName.GetExtension(); - if( aExtension.Len() ) - aEntry.SetExtension( aExtension ); - m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE ); - if( ! m_aFileStream.IsOpen() ) - { - // #74808# might be that the extension scrambled the whole filename - aEntry = aEntry.TempName(); - m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE ); - } -} - -PluginInputStream::~PluginInputStream() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getInputStreams().remove( this ); - - String aFile( m_aFileStream.GetFileName() ); - - m_aFileStream.Close(); - if( m_pPlugin ) - { - ByteString aFileName( aFile, m_pPlugin->getTextEncoding() ); - if( m_pPlugin->getPluginComm() && m_nMode != -1 ) - // mode -1 means either an error occurred, - // or the plugin is already disposing - { - m_pPlugin->getPluginComm()->addFileToDelete( aFile ); - if( m_nMode == NP_ASFILE ) - { - m_pPlugin->getPluginComm()-> - NPP_StreamAsFile( m_pPlugin->getNPPInstance(), - &m_aNPStream, - aFileName.GetBuffer() ); - } - m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin ); - m_pPlugin->getInputStreams().remove( this ); - } - else - DirEntry( m_aFileStream.GetFileName() ).Kill(); - } - else - DirEntry( m_aFileStream.GetFileName() ).Kill(); - if( m_pContent ) - delete m_pContent; -} - -PluginStreamType PluginInputStream::getStreamType() -{ - return InputStream; -} - -void PluginInputStream::load() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - INetURLObject aUrl; - aUrl.SetSmartProtocol( INET_PROT_FILE ); - aUrl.SetSmartURL( - String( getStream()->url, - ::sal::static_int_cast< sal_uInt16, size_t >( strlen( getStream()->url ) ), - RTL_TEXTENCODING_MS_1252 - ) ); - try - { - m_pContent = - new ::ucbhelper::Content( - aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI), - uno::Reference< com::sun::star::ucb::XCommandEnvironment >() - ); - m_pContent->openStream( static_cast< XOutputStream* >( this ) ); - } - catch( com::sun::star::uno::Exception ) - { - } -} - -void PluginInputStream::setMode( sal_Int32 nMode ) -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_nMode = nMode; - - // invalidation by plugin - if( m_nMode == -1 && m_pPlugin ) - { - m_pPlugin->getInputStreams().remove( this ); - m_pPlugin = NULL; - } -} - -void PluginInputStream::writeBytes( const Sequence<sal_Int8>& Buffer ) throw() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_aFileStream.Seek( STREAM_SEEK_TO_END ); - m_aFileStream.Write( Buffer.getConstArray(), Buffer.getLength() ); - - if( m_nMode == NP_SEEK ) - // hold reference, streem gets destroyed in NPN_DestroyStream - m_xSelf = this; - - if( m_nMode == -1 || !m_pPlugin->getPluginComm() ) - return; - - sal_uInt32 nPos = m_aFileStream.Tell(); - sal_uInt32 nBytes = 0; - while( m_nMode != NP_ASFILEONLY && - m_nWritePos < nPos && - (nBytes = m_pPlugin->getPluginComm()-> NPP_WriteReady( - m_pPlugin->getNPPInstance(), &m_aNPStream )) > 0 ) - { - nBytes = (nBytes > nPos - m_nWritePos) ? nPos - m_nWritePos : nBytes; - - char* pBuffer = new char[ nBytes ]; - m_aFileStream.Seek( m_nWritePos ); - nBytes = m_aFileStream.Read( pBuffer, nBytes ); - - int32 nBytesRead = 0; - try - { - nBytesRead = m_pPlugin->getPluginComm()->NPP_Write( - m_pPlugin->getNPPInstance(), &m_aNPStream, m_nWritePos, nBytes, pBuffer ); - } - catch( ... ) - { - nBytesRead = 0; - } - delete [] pBuffer; - - if( nBytesRead < 0 ) - { - m_nMode = -1; - return; - } - - m_nWritePos += nBytesRead; - } -} - -void PluginInputStream::closeOutput() throw() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - flush(); - m_xSource = uno::Reference< com::sun::star::io::XActiveDataSource >(); -} - -sal_uInt32 PluginInputStream::read( sal_uInt32 offset, sal_Int8* buffer, sal_uInt32 size ) -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - if( m_nMode != NP_SEEK ) - return 0; - - m_aFileStream.Seek( offset ); - return m_aFileStream.Read( buffer, size ); -} - -void PluginInputStream::flush(void) throw() -{ -} - -PluginOutputStream::PluginOutputStream( XPlugin_Impl* pPlugin, - const char* url, - sal_uInt32 len, - sal_uInt32 lastmod ) : - PluginStream( pPlugin, url, len, lastmod ), - m_xStream( pPlugin->getServiceManager()->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.io.DataOutputStream")) ), UNO_QUERY ) -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getOutputStreams().push_back( this ); -} - -PluginOutputStream::~PluginOutputStream() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getOutputStreams().remove( this ); -} - -PluginStreamType PluginOutputStream::getStreamType() -{ - return OutputStream; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |