[Libreoffice-commits] core.git: config_host.mk.in configure.ac extensions/Executable_pluginapp.bin.mk extensions/Library_pl.mk extensions/Module_extensions.mk extensions/source extensions/StaticLibrary_plugcon.mk external/np_sdk offapi/com offapi/type_reference offapi/UnoApi_offapi.mk Repository.mk
Rene Engelhard
rene at debian.org
Thu Dec 17 07:32:53 PST 2015
Repository.mk | 2
config_host.mk.in | 3
configure.ac | 78
extensions/Executable_pluginapp.bin.mk | 69
extensions/Library_pl.mk | 120 -
extensions/Module_extensions.mk | 17
extensions/StaticLibrary_plugcon.mk | 61
extensions/source/plugin/aqua/macmgr.mm | 654 -------
extensions/source/plugin/aqua/sysplug.mm | 882 ---------
extensions/source/plugin/base/context.cxx | 345 ---
extensions/source/plugin/base/evtlstnr.cxx | 74
extensions/source/plugin/base/manager.cxx | 234 --
extensions/source/plugin/base/multiplx.cxx | 333 ---
extensions/source/plugin/base/nfuncs.cxx | 644 -------
extensions/source/plugin/base/plcom.cxx | 80
extensions/source/plugin/base/plctrl.cxx | 322 ---
extensions/source/plugin/base/plmodel.cxx | 204 --
extensions/source/plugin/base/service.cxx | 95 -
extensions/source/plugin/base/xplugin.cxx | 1206 -------------
extensions/source/plugin/inc/plugin/aqua/sysplug.hxx | 156 -
extensions/source/plugin/inc/plugin/impl.hxx | 437 ----
extensions/source/plugin/inc/plugin/model.hxx | 132 -
extensions/source/plugin/inc/plugin/multiplx.hxx | 169 -
extensions/source/plugin/inc/plugin/plcom.hxx | 80
extensions/source/plugin/inc/plugin/plctrl.hxx | 181 --
extensions/source/plugin/inc/plugin/unx/mediator.hxx | 147 -
extensions/source/plugin/inc/plugin/unx/plugcon.hxx | 206 --
extensions/source/plugin/inc/plugin/unx/sysplug.hxx | 78
extensions/source/plugin/inc/plugin/win/sysplug.hxx | 130 -
extensions/source/plugin/pl.component | 37
extensions/source/plugin/unx/mediator.cxx | 337 ---
extensions/source/plugin/unx/npnapi.cxx | 949 ----------
extensions/source/plugin/unx/nppapi.cxx | 593 ------
extensions/source/plugin/unx/npwrap.cxx | 495 -----
extensions/source/plugin/unx/npwrap.hxx | 31
extensions/source/plugin/unx/plugcon.cxx | 281 ---
extensions/source/plugin/unx/sysplug.cxx | 152 -
extensions/source/plugin/unx/unxmgr.cxx | 313 ---
extensions/source/plugin/win/sysplug.cxx | 441 ----
extensions/source/plugin/win/winmgr.cxx | 445 ----
external/np_sdk/README | 1
external/np_sdk/inc/LEGAL | 43
external/np_sdk/inc/LICENSE | 567 ------
external/np_sdk/inc/npapi.h | 879 ---------
external/np_sdk/inc/npfunctions.h | 321 ---
external/np_sdk/inc/npruntime.h | 393 ----
external/np_sdk/inc/nptypes.h | 111 -
external/np_sdk/npsdk/LEGAL | 43
external/np_sdk/npsdk/LICENSE | 567 ------
external/np_sdk/npsdk/README | 2
external/np_sdk/npsdk/jri.h | 689 -------
external/np_sdk/npsdk/jri_md.h | 545 ------
external/np_sdk/npsdk/jritypes.h | 232 --
external/np_sdk/npsdk/npupp.h | 1267 --------------
offapi/UnoApi_offapi.mk | 17
offapi/com/sun/star/mozilla/XPluginInstance.idl | 109 -
offapi/com/sun/star/mozilla/XPluginInstanceNotifySink.idl | 49
offapi/com/sun/star/mozilla/XPluginInstancePeer.idl | 132 -
offapi/com/sun/star/mozilla/XPluginInstanceSyncPeer.idl | 54
offapi/com/sun/star/mozilla/XPluginWindowPeer.idl | 46
offapi/com/sun/star/plugin/PluginDescription.idl | 47
offapi/com/sun/star/plugin/PluginException.idl | 46
offapi/com/sun/star/plugin/PluginManager.idl | 38
offapi/com/sun/star/plugin/PluginMode.idl | 40
offapi/com/sun/star/plugin/PluginVariable.idl | 48
offapi/com/sun/star/plugin/XPlugin.idl | 67
offapi/com/sun/star/plugin/XPluginContext.idl | 177 -
offapi/com/sun/star/plugin/XPluginManager.idl | 114 -
offapi/type_reference/offapi.idl | 79
69 files changed, 17936 deletions(-)
New commits:
commit 4c18af27bf95b332ee2006cfc0bbf469fb1a84d4
Author: Rene Engelhard <rene at debian.org>
Date: Sat Dec 12 11:36:25 2015 +0100
tdf#96398 kill remaining NPAPI support for plugins _inside_ LO
- probably out of date
- links against Gtk2 and thus causes a GTk2 dependency in core packages
- the only serious usecase (Flash) is doomed anyway
Change-Id: I7264ab5eb04c2f4b6c31a815e45b9818209e5ae2
Reviewed-on: https://gerrit.libreoffice.org/20658
Reviewed-by: David Ostrovsky <david at ostrovsky.org>
Reviewed-by: Bryan Quigley <gquigs at gmail.com>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/Repository.mk b/Repository.mk
index 5e9bb48..5c468b2 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -145,7 +145,6 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,writer_brand, \
$(eval $(call gb_Helper_register_executables_for_install,OOO,ooo, \
gengal \
- $(if $(filter TRUE-TRUE,$(USING_X11)-$(ENABLE_NPAPI_FROM_BROWSER)),pluginapp.bin) \
$(if $(filter WNT,$(OS)),,uri-encode) \
ui-previewer \
$(if $(filter WNT,$(OS)), \
@@ -360,7 +359,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
$(call gb_Helper_optional,OPENCL,opencl) \
passwordcontainer \
pcr \
- $(if $(ENABLE_NPAPI_FROM_BROWSER),pl) \
pdffilter \
$(call gb_Helper_optional,SCRIPTING,protocolhandler) \
res \
diff --git a/config_host.mk.in b/config_host.mk.in
index 33c26b7..9b59af3 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -151,7 +151,6 @@ export ENABLE_LWP=@ENABLE_LWP@
export ENABLE_MACOSX_SANDBOX=@ENABLE_MACOSX_SANDBOX@
export ENABLE_MEDIAWIKI=@ENABLE_MEDIAWIKI@
export ENABLE_MARIADBC=@ENABLE_MARIADBC@
-export ENABLE_NPAPI_FROM_BROWSER=@ENABLE_NPAPI_FROM_BROWSER@
export ENABLE_ONLINE_UPDATE=@ENABLE_ONLINE_UPDATE@
export ENABLE_ONLINE_UPDATE_MAR=@ENABLE_ONLINE_UPDATE_MAR@
export ENABLE_EXTENSION_UPDATE=@ENABLE_EXTENSION_UPDATE@
@@ -416,7 +415,6 @@ export NEON_CFLAGS=$(gb_SPACE)@NEON_CFLAGS@
export NEON_LIBS=$(gb_SPACE)@NEON_LIBS@
export NEON_VERSION=@NEON_VERSION@
export NM=@NM@
-export NPAPI_HEADERS_CFLAGS=$(gb_SPACE)@NPAPI_HEADERS_CFLAGS@
export NSS_CFLAGS=$(gb_SPACE)@NSS_CFLAGS@
export NSS_LIBS=$(gb_SPACE)@NSS_LIBS@
export NUMBERTEXT_EXTENSION_PACK=@NUMBERTEXT_EXTENSION_PACK@
@@ -561,7 +559,6 @@ export SYSTEM_MWAW=@SYSTEM_MWAW@
export SYSTEM_MYSQL_CPPCONN=@SYSTEM_MYSQL_CPPCONN@
export SYSTEM_MYTHES=@SYSTEM_MYTHES@
export SYSTEM_NEON=@SYSTEM_NEON@
-export SYSTEM_NPAPI_HEADERS=@SYSTEM_NPAPI_HEADERS@
export SYSTEM_NSS=@SYSTEM_NSS@
export SYSTEM_ODBC_HEADERS=@SYSTEM_ODBC_HEADERS@
export SYSTEM_ODFGEN=@SYSTEM_ODFGEN@
diff --git a/configure.ac b/configure.ac
index 49198a8..ecff371 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1951,13 +1951,6 @@ AC_ARG_WITH(system-liblangtag,
[Use liblangtag library already on system.]),,
[with_system_liblangtag="$with_system_libs"])
-AC_ARG_WITH(system-npapi-headers,
- AS_HELP_STRING([--with-system-npapi-headers],
- [Use NPAPI headers provided by system instead of bundled ones. Used in
- extensions/source/plugin (ENABLE_NPAPI_FROM_BROWSER=TRUE)]),,
- [with_system_npapi_headers="$with_system_headers"]
-)
-
AC_ARG_WITH(jpeg-turbo,
AS_HELP_STRING([--with-jpeg-turbo],
[Use internal libjpeg-turbo library.]),,
@@ -8953,56 +8946,6 @@ if test $_os = WINNT -a -z "$ENABLE_RELEASE_BUILD" -a "$with_prebuilt_openssl" =
fi
dnl ===================================================================
-dnl Check for system mozilla headers
-dnl ===================================================================
-HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION=
-AC_MSG_CHECKING([which NPAPI headers to use])
-
-if test "$with_system_npapi_headers" = "yes"; then
- AC_MSG_RESULT([external])
- SYSTEM_NPAPI_HEADERS=TRUE
- # First try npapi-sdk:
- PKG_CHECK_MODULES(NPAPI_HEADERS, npapi-sdk, [LOCATED=yes], [LOCATED=no])
- # Then go with libxul:
- if test "x$LOCATED" != "xyes"; then
- PKG_CHECK_MODULES(NPAPI_HEADERS, libxul, [LOCATED=yes], [LOCATED=no])
- fi
- if test "x$LOCATED" != "xyes"; then
- PKG_CHECK_MODULES(NPAPI_HEADERS, mozilla-plugin, [LOCATED=yes], [LOCATED=no])
- fi
- # if still not found bail out
- if test "x$LOCATED" != "xyes"; then
- AC_MSG_ERROR([npapi.h header file not found])
- fi
-
- AC_LANG_PUSH([C])
- save_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS $NPAPI_HEADERS_CFLAGS"
- AC_MSG_CHECKING([for NPP_GetMIMEDescription return type])
- AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([[
- #define XP_UNIX
- #include <npapi.h>
- const char* NPP_GetMIMEDescription(void) { return "foo"; }
- ]])],
- [AC_MSG_RESULT([const char*])],
- [
- AC_MSG_RESULT([char*])
- HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION=TRUE
- ])
- CFLAGS=$save_CFLAGS
- AC_LANG_POP([C])
- NPAPI_HEADERS_CFLAGS=$(printf '%s' "$NPAPI_HEADERS_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
-else
- AC_MSG_RESULT([internal])
- dnl ...but will not be built/used unless ENABLE_NPAPI_FROM_BROWSER
- SYSTEM_NPAPI_HEADERS=
-fi
-AC_SUBST(NPAPI_HEADERS_CFLAGS)
-AC_SUBST(SYSTEM_NPAPI_HEADERS)
-AC_SUBST(HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION)
-
-dnl ===================================================================
dnl Check for system sane
dnl ===================================================================
AC_MSG_CHECKING([which sane header to use])
@@ -9211,23 +9154,6 @@ else
fi
AC_SUBST(ENABLE_HARFBUZZ)
-dnl ===================================================================
-dnl Check for NPAPI interface to plug browser plugins into LibreOffice documents
-dnl ===================================================================
-AC_MSG_CHECKING([whether to plug browser plugins into LibreOffice documents])
-# Obviously no such thing on iOS or Android. Also not possible when building
-# 64-bit OS X code as the plugin code uses QuickTime and Carbon.
-if test "$_os" != Android -a "$_os" != iOS -a $_os != Darwin -a \
- "$with_x" != "no" -a "$enable_mpl_subset" != yes
-then
- AC_MSG_RESULT([yes])
- ENABLE_NPAPI_FROM_BROWSER=TRUE
-else
- AC_MSG_RESULT([no])
- ENABLE_NPAPI_FROM_BROWSER=
-fi
-AC_SUBST(ENABLE_NPAPI_FROM_BROWSER)
-
AC_MSG_CHECKING([whether to use X11])
dnl ***************************************
dnl testing for X libraries and includes...
@@ -9263,10 +9189,6 @@ if test "$USING_X11" = TRUE; then
AC_CHECK_HEADERS(X11/Composite.h,[],[AC_MSG_ERROR([Xt headers not found])],
[#include <X11/Intrinsic.h>])
- # ENABLE_NPAPI_FROM_BROWSER requires Xt library
- AC_CHECK_LIB([Xt], [XtToolkitInitialize], [:],
- [AC_MSG_ERROR(Xt library not found)])
-
dnl ===================================================================
dnl Check for extension headers
dnl ===================================================================
diff --git a/extensions/Executable_pluginapp.bin.mk b/extensions/Executable_pluginapp.bin.mk
deleted file mode 100644
index 96a25cc..0000000
--- a/extensions/Executable_pluginapp.bin.mk
+++ /dev/null
@@ -1,69 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#
-
-$(eval $(call gb_Executable_Executable,pluginapp.bin))
-
-$(eval $(call gb_Executable_use_external,pluginapp.bin,npapi_headers))
-
-$(eval $(call gb_Executable_set_include,pluginapp.bin,\
- $$(INCLUDE) \
- -I$(SRCDIR)/extensions/source/plugin/inc \
-))
-
-$(eval $(call gb_Executable_use_sdk_api,pluginapp.bin))
-
-$(eval $(call gb_Executable_add_exception_objects,pluginapp.bin,\
- extensions/source/plugin/unx/npwrap \
- extensions/source/plugin/unx/npnapi \
-))
-
-$(eval $(call gb_Executable_use_static_libraries,pluginapp.bin,\
- plugcon \
-))
-
-$(eval $(call gb_Executable_use_libraries,pluginapp.bin,\
- sal \
-))
-
-ifeq ($(filter-out FREEBSD NETBSD OPENBSD DRAGONFLY,$(OS)),)
-$(eval $(call gb_Executable_add_libs,pluginapp.bin,\
- -lXt \
- -lXext \
- -lX11 \
-))
-else ifeq ($(OS),AIX)
-$(eval $(call gb_Executable_add_libs,pluginapp.bin,\
- -lXpm \
- -lXmu \
- -lXt \
- -lXext \
- -lX11 \
- -ldl \
-))
-else
-$(eval $(call gb_Executable_add_libs,pluginapp.bin,\
- -lXt \
- -lXext \
- -lX11 \
- -ldl \
-))
-endif
-
-
-ifeq ($(ENABLE_GTK),TRUE)
-$(eval $(call gb_Executable_use_externals,pluginapp.bin,\
- gthread \
- gtk \
-))
-
-endif
-
-# vim:set noet sw=4 ts=4:
diff --git a/extensions/Library_pl.mk b/extensions/Library_pl.mk
deleted file mode 100644
index 82a71d6..0000000
--- a/extensions/Library_pl.mk
+++ /dev/null
@@ -1,120 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#
-
-$(eval $(call gb_Library_Library,pl))
-
-$(eval $(call gb_Library_set_componentfile,pl,extensions/source/plugin/pl))
-
-$(eval $(call gb_Library_use_externals,pl,\
- boost_headers \
- npapi_headers \
-))
-
-$(eval $(call gb_Library_set_include,pl,\
- $$(INCLUDE) \
- -I$(SRCDIR)/extensions/source/plugin/inc \
-))
-
-$(eval $(call gb_Library_use_sdk_api,pl))
-
-ifeq ($(ENABLE_JAVA),TRUE)
-$(eval $(call gb_Library_add_defs,pl,\
- -DOJI \
-))
-
-endif # ENABLE_JAVA=YES
-
-ifeq ($(OS),SOLARIS)
-$(eval $(call gb_Library_add_libs,pl,\
- -lsocket \
-))
-endif # OS=SOLARIS
-
-ifeq ($(OS),WNT)
-$(eval $(call gb_Library_use_system_win32_libs,pl,\
- advapi32 \
- ole32 \
- version \
-))
-
-$(eval $(call gb_Library_add_exception_objects,pl,\
- extensions/source/plugin/win/winmgr \
- extensions/source/plugin/win/sysplug \
-))
-
-else ifeq ($(OS),MACOSX)
-
-$(eval $(call gb_Library_add_objcxxobjects,pl,\
- extensions/source/plugin/aqua/macmgr \
- extensions/source/plugin/aqua/sysplug \
-))
-
-$(eval $(call gb_Library_use_system_darwin_frameworks,pl,\
- Cocoa \
- Carbon \
- CoreFoundation \
-))
-
-else
-
-ifeq ($(ENABLE_GTK),TRUE)
-$(eval $(call gb_Library_add_defs,pl,\
- -DENABLE_GTK \
-))
-
-$(eval $(call gb_Library_use_external,pl,gtk))
-endif # ENABLE_GTK=TRUE
-
-$(eval $(call gb_Library_add_exception_objects,pl,\
- extensions/source/plugin/unx/nppapi \
- extensions/source/plugin/unx/sysplug \
- extensions/source/plugin/unx/unxmgr \
-))
-
-$(eval $(call gb_Library_use_static_libraries,pl,\
- plugcon \
-))
-
-$(eval $(call gb_Library_add_libs,pl,\
- -lX11 \
-))
-
-endif
-
-$(eval $(call gb_Library_use_libraries,pl,\
- tk \
- vcl \
- svl \
- utl \
- tl \
- comphelper \
- ucbhelper \
- cppuhelper \
- cppu \
- sal \
- salhelper \
- $(gb_UWINAPI) \
-))
-
-$(eval $(call gb_Library_add_exception_objects,pl,\
- extensions/source/plugin/base/context \
- extensions/source/plugin/base/evtlstnr \
- extensions/source/plugin/base/manager \
- extensions/source/plugin/base/multiplx \
- extensions/source/plugin/base/nfuncs \
- extensions/source/plugin/base/plcom \
- extensions/source/plugin/base/plctrl \
- extensions/source/plugin/base/plmodel \
- extensions/source/plugin/base/service \
- extensions/source/plugin/base/xplugin \
-))
-
-# vim:set noet sw=4 ts=4:
diff --git a/extensions/Module_extensions.mk b/extensions/Module_extensions.mk
index fa527f5..f5a27bf 100644
--- a/extensions/Module_extensions.mk
+++ b/extensions/Module_extensions.mk
@@ -94,23 +94,6 @@ endif # DISABLE_ATL
endif # WNT
-ifeq ($(ENABLE_NPAPI_FROM_BROWSER),TRUE)
-
-$(eval $(call gb_Module_add_targets,extensions,\
- Library_pl \
-))
-
-ifneq ($(OS),WNT)
-ifneq ($(OS),MACOSX)
-$(eval $(call gb_Module_add_targets,extensions,\
- StaticLibrary_plugcon \
- Executable_pluginapp.bin \
-))
-endif
-endif
-
-endif # ENABLE_NPAPI_FROM_BROWSER=TRUE
-
ifeq ($(OS),MACOSX)
$(eval $(call gb_Module_add_targets,extensions,\
Library_OOoSpotlightImporter \
diff --git a/extensions/StaticLibrary_plugcon.mk b/extensions/StaticLibrary_plugcon.mk
deleted file mode 100644
index 149e86b..0000000
--- a/extensions/StaticLibrary_plugcon.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-ifeq ($(OS),WNT)
-$(error only for UNX)
-endif
-
-$(eval $(call gb_StaticLibrary_StaticLibrary,plugcon))
-
-$(eval $(call gb_StaticLibrary_use_externals,plugcon,\
- boost_headers \
- npapi_headers \
-))
-
-$(eval $(call gb_StaticLibrary_set_include,plugcon,\
- $$(INCLUDE) \
- -I$(SRCDIR)/extensions/source/plugin/inc \
-))
-
-$(eval $(call gb_StaticLibrary_use_api,plugcon,\
- offapi \
- udkapi \
-))
-
-ifeq ($(ENABLE_JAVA),TRUE)
-$(eval $(call gb_StaticLibrary_add_defs,plugcon,\
- -DOJI \
-))
-
-endif # ENABLE_JAVA=YES
-
-ifeq ($(ENABLE_GTK),TRUE)
-$(eval $(call gb_StaticLibrary_add_defs,plugcon,\
- -DENABLE_GTK \
-))
-
-$(eval $(call gb_StaticLibrary_use_external,plugcon,gtk))
-
-# Gtk uses cairo, and if we build internal cairo, the linker could
-# pick up our cairo libs before they're fully ready, causing problems
-# (e.g. using our libpixman and system libcairo). Depend on cairo
-# to delay build until cairo is done.
-ifeq ($(SYSTEM_CAIRO),)
-$(eval $(call gb_StaticLibrary_use_external,plugcon,cairo))
-endif
-endif # ENABLE_GTK=TRUE
-
-$(eval $(call gb_StaticLibrary_add_exception_objects,plugcon,\
- extensions/source/plugin/unx/mediator \
- extensions/source/plugin/unx/plugcon \
-))
-
-# vim:set noet sw=4 ts=4:
-
diff --git a/extensions/source/plugin/aqua/macmgr.mm b/extensions/source/plugin/aqua/macmgr.mm
deleted file mode 100644
index 878571a..0000000
--- a/extensions/source/plugin/aqua/macmgr.mm
+++ /dev/null
@@ -1,654 +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.
- *
- ************************************************************************/
-
-#include "rtl/ustrbuf.hxx"
-#include "rtl/strbuf.hxx"
-
-#include "plugin/impl.hxx"
-#include "osl/file.h"
-#include "osl/module.hxx"
-
-using namespace std;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::plugin;
-
-using ::rtl::OUString;
-using ::rtl::OString;
-using ::rtl::OUStringBuffer;
-using ::rtl::OStringBuffer;
-using ::rtl::OUStringToOString;
-using ::rtl::OStringToOUString;
-
-namespace plugstringhelper
-{
-
-rtl::OUString getString( CFStringRef i_xString )
-{
- rtl::OUStringBuffer aBuf;
- if( i_xString )
- {
- CFIndex nChars = CFStringGetLength( i_xString );
- CFRange aRange = { 0, nChars };
- aBuf.setLength( nChars );
- CFStringGetCharacters( i_xString, aRange, static_cast< UniChar* >(const_cast<sal_Unicode*>(aBuf.getStr())) );
- }
- return aBuf.makeStringAndClear();
-}
-
-rtl::OUString getString( CFURLRef i_xURL )
-{
- CFStringRef xString = CFURLGetString( i_xURL );
- return getString( xString );
-}
-
-CFMutableStringRef createString( const rtl::OUString& i_rString )
-{
- CFMutableStringRef xString = CFStringCreateMutable( NULL, 0 );
- if( xString )
- CFStringAppendCharacters( xString, i_rString.getStr(), i_rString.getLength() );
- return xString;
-}
-
-CFURLRef createURL( const rtl::OUString& i_rString )
-{
-
- CFMutableStringRef xMutableString = createString( i_rString );
- CFURLRef xURL = CFURLCreateWithString( NULL, xMutableString, NULL );
- CFRelease( xMutableString );
- return xURL;
-}
-
-rtl::OUString getURLFromPath( const rtl::OUString& i_rPath )
-{
- CFMutableStringRef xMutableString = createString( i_rPath );
- CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true );
- CFRelease( xMutableString );
- CFStringRef xString = CFURLGetString( xURL );
- rtl::OUString aRet = getString( xString );
- CFRelease( xURL );
- return aRet;
-}
-
-CFURLRef createURLFromPath( const rtl::OUString& i_rPath )
-{
- CFMutableStringRef xMutableString = createString( i_rPath );
- CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true );
- return xURL;
-}
-
-rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL )
-{
- // make URL absolute
- CFURLRef xAbsURL = CFURLCopyAbsoluteURL( i_xURL );
- // copy system path
- CFStringRef xSysPath = CFURLCopyFileSystemPath( xAbsURL ? xAbsURL : i_xURL, kCFURLPOSIXPathStyle );
- if( xAbsURL )
- CFRelease( xAbsURL );
- rtl::OUString aSysPath( getString( xSysPath ) );
- CFRelease( xSysPath );
- rtl::OUString aFileURL;
- osl_getFileURLFromSystemPath( aSysPath.pData, &aFileURL.pData );
- return aFileURL;
-}
-
-}
-
-using namespace plugstringhelper;
-
-static int parsePlist( CFBundleRef i_xBundle, const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions )
-{
- CFTypeRef xMimeDict = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginMIMETypes"));
- int nMimetypes = 0;
- if( xMimeDict == 0 ||
- CFGetTypeID(xMimeDict) != CFDictionaryGetTypeID() ||
- (nMimetypes = CFDictionaryGetCount( static_cast<CFDictionaryRef>(xMimeDict))) <= 0 )
- {
- return 0;
- }
-
- // prepare an array of key and value refs
- std::vector< CFTypeRef > aKeys( nMimetypes, CFTypeRef(NULL) );
- std::vector< CFTypeRef > aValues( nMimetypes, CFTypeRef(NULL) );
- CFDictionaryGetKeysAndValues(static_cast<CFDictionaryRef>(xMimeDict), &aKeys[0], &aValues[0] );
-
- int nAdded = 0;
- for( int i = 0; i < nMimetypes; i++ )
- {
- // get the mimetype
- CFTypeRef xKey = aKeys[i];
- if( ! xKey || CFGetTypeID(xKey) != CFStringGetTypeID() )
- continue;
- rtl::OUString aMimetype = getString( (CFStringRef)xKey );
-
- // the correspoding value should be a dictionary
- CFTypeRef xDict = aValues[i];
- if( ! xDict || CFGetTypeID( xDict ) != CFDictionaryGetTypeID() )
- continue;
-
- // get the extension list
- CFTypeRef xExtArray = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginExtensions" ) );
- if( !xExtArray || CFGetTypeID( xExtArray ) != CFArrayGetTypeID() )
- continue;
-
- OUStringBuffer aExtBuf;
- int nExtensions = CFArrayGetCount( (CFArrayRef)xExtArray );
- for( int n = 0; n < nExtensions; n++ )
- {
- CFTypeRef xExt = CFArrayGetValueAtIndex( (CFArrayRef)xExtArray, n );
- if( xExt && CFGetTypeID( xExt ) == CFStringGetTypeID() )
- {
- if( aExtBuf.getLength() > 0 )
- aExtBuf.append( sal_Unicode(';') );
- OUString aExt( getString( (CFStringRef)xExt ) );
- if( aExt.indexOfAsciiL( "*.", 2 ) != 0 )
- aExtBuf.appendAscii( "*." );
- aExtBuf.append( aExt );
- }
- }
-
- // get the description string
- CFTypeRef xDescString = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginTypeDescription" ) );
- if( !xDescString || CFGetTypeID( xDescString ) != CFStringGetTypeID() )
- continue;
- rtl::OUString aDescription = getString( (CFStringRef)xDescString );
-
- PluginDescription* pNew = new PluginDescription;
- // set plugin name (path to library)
- pNew->PluginName = i_rBundleURL;
- // set mimetype
- pNew->Mimetype = aMimetype;
- // set extension line
- pNew->Extension = aExtBuf.makeStringAndClear();
- // set description
- pNew->Description= aDescription;
-
- io_rDescriptions.push_back( pNew );
- nAdded++;
-
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr,
- "Inserting from PList:\n"
- " Mimetype: %s\n"
- " Extension: %s\n"
- " Description: %s\n",
- OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(),
- OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(),
- OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr()
- );
-#endif
-
- }
-
- return nAdded;
-}
-
-static int parseMimeString( const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions, const char* i_pMime )
-{
- if( ! i_pMime )
- return 0;
-
- rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
-
- OStringBuffer aMIME;
- aMIME.append( i_pMime );
-
- if( aMIME.getLength() < 1 )
- return 0;
-
- OString aLine = aMIME.makeStringAndClear();
-
- int nAdded = 0;
- sal_Int32 nIndex = 0;
- while( nIndex != -1 )
- {
- OString aType = aLine.getToken( 0, ';', nIndex );
-
- sal_Int32 nTypeIndex = 0;
- OString aMimetype = aType.getToken( 0, ':', nTypeIndex );
- OString aExtLine = aType.getToken( 0, ':', nTypeIndex );
- if( nTypeIndex < 0 ) // ensure at least three tokens
- continue;
- OString aDesc = aType.getToken( 0, ':', nTypeIndex );
-
- // create extension list string
- sal_Int32 nExtIndex = 0;
- OStringBuffer aExtension;
- while( nExtIndex != -1 )
- {
- OString aExt = aExtLine.getToken( 0, ',', nExtIndex);
- if( aExt.indexOf( "*." ) != 0 )
- aExtension.append( "*." );
- aExtension.append( aExt );
- if( nExtIndex != -1 )
- aExtension.append( ';' );
- }
-
- PluginDescription* pNew = new PluginDescription;
- // set plugin name (path to library)
- pNew->PluginName = i_rBundleURL;
- // set mimetype
- pNew->Mimetype = OStringToOUString( aMimetype, aEncoding );
- // set extension line
- pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding );
- // set description
- pNew->Description= OStringToOUString( aDesc, aEncoding );
- io_rDescriptions.push_back( pNew );
- nAdded++;
-
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr,
- "Inserting from mime string:\n"
- " Mimetype: %s\n"
- " Extension: %s\n"
- " Description: %s\n",
- OUStringToOString( pNew->Mimetype, aEncoding ).getStr(),
- OUStringToOString( pNew->Extension, aEncoding ).getStr(),
- OUStringToOString( pNew->Description, aEncoding ).getStr()
- );
-#endif
- }
- return nAdded;
-}
-
-// this is so ugly it you want to tear your eyes out
-static rtl::OUString GetNextPluginStringFromHandle(Handle h, short *index)
-{
- char* pPascalBytes = (*h + *index);
- sal_uInt32 nLen = (unsigned char)pPascalBytes[0];
- rtl::OStringBuffer aBuf( nLen );
- aBuf.append( pPascalBytes+1, nLen );
- *index += nLen + 1;
- return rtl::OStringToOUString( aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
-}
-
-static int parseMimeResource( CFBundleRef i_xBundle,
- oslModule& i_rMod,
- const rtl::OUString& i_rBundleURL,
- list< PluginDescription* >& io_rDescriptions )
-{
- int nAdded = 0;
- // just to hurt our eyes more there is an alternative mimetype function plus the possibility
- // of a resource fork. Must be a case of think different.
- #if defined __LP64__
- int
- #else
- SInt16
- #endif
- xRes = 0;
- BPSupportedMIMETypes aMIMETypesStrangeStruct = {kBPSupportedMIMETypesStructVers_1, NULL, NULL};
-
- BP_GetSupportedMIMETypesUPP pBPGetSupp = (BP_GetSupportedMIMETypesUPP)osl_getAsciiFunctionSymbol( i_rMod, "BP_GetSupportedMIMETypes" );
- if( pBPGetSupp &&
- noErr == pBPGetSupp( &aMIMETypesStrangeStruct, 0 ) &&
- aMIMETypesStrangeStruct.typeStrings )
- {
- HLock( aMIMETypesStrangeStruct.typeStrings );
- if( aMIMETypesStrangeStruct.infoStrings ) // it's possible some plugins have infoStrings missing
- HLock( aMIMETypesStrangeStruct.infoStrings );
- }
- else // Try to get data from the resource fork
- {
- xRes = CFBundleOpenBundleResourceMap( i_xBundle );
- if( xRes > 0 )
- {
- aMIMETypesStrangeStruct.typeStrings = Get1Resource('STR#', 128);
- if( aMIMETypesStrangeStruct.typeStrings )
- {
- DetachResource( aMIMETypesStrangeStruct.typeStrings );
- HLock( aMIMETypesStrangeStruct.typeStrings );
- aMIMETypesStrangeStruct.infoStrings = Get1Resource('STR#', 127);
- if( aMIMETypesStrangeStruct.infoStrings )
- {
- DetachResource( aMIMETypesStrangeStruct.infoStrings );
- HLock( aMIMETypesStrangeStruct.infoStrings );
- }
- }
- }
- }
-
- if( aMIMETypesStrangeStruct.typeStrings && aMIMETypesStrangeStruct.infoStrings )
- {
- short nVariantCount = (**(short**)aMIMETypesStrangeStruct.typeStrings) / 2;
- // Fill in the info struct based on the data in the BPSupportedMIMETypes struct
- // this is an array of pascal string of unknown (!) encoding
- // whoever thought of this deserves a fair beating
- short mimeIndex = 2;
- short descriptionIndex = 2;
- for( int i = 0; i < nVariantCount; i++ )
- {
- rtl::OUString aMimetype = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex );
- rtl::OUString aExtLine = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex );
- rtl::OUString aDescription;
- if( aMIMETypesStrangeStruct.infoStrings )
- aDescription = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.infoStrings, &descriptionIndex );
-
- // create extension list string
- sal_Int32 nExtIndex = 0;
- OUStringBuffer aExtension;
- while( nExtIndex != -1 )
- {
- OUString aExt = aExtLine.getToken( 0, ',', nExtIndex);
- if( aExt.indexOfAsciiL( "*.", 2 ) != 0 )
- aExtension.appendAscii( "*." );
- aExtension.append( aExt );
- if( nExtIndex != -1 )
- aExtension.append( sal_Unicode(';') );
- }
-
- PluginDescription* pNew = new PluginDescription;
- // set plugin name (path to library)
- pNew->PluginName = i_rBundleURL;
- // set mimetype
- pNew->Mimetype = aMimetype;
- // set extension line
- pNew->Extension = aExtension.makeStringAndClear();
- // set description
- pNew->Description= aDescription;
- io_rDescriptions.push_back( pNew );
- nAdded++;
-
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr,
- "Inserting from resource:\n"
- " Mimetype: %s\n"
- " Extension: %s\n"
- " Description: %s\n",
- OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(),
- OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(),
- OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr()
- );
- #endif
- }
- }
-
-
- // clean up
- if( aMIMETypesStrangeStruct.typeStrings )
- {
- HUnlock( aMIMETypesStrangeStruct.typeStrings );
- DisposeHandle( aMIMETypesStrangeStruct.typeStrings );
- }
- if( aMIMETypesStrangeStruct.infoStrings )
- {
- HUnlock( aMIMETypesStrangeStruct.infoStrings );
- DisposeHandle( aMIMETypesStrangeStruct.infoStrings );
- }
- if( xRes )
- CFBundleCloseBundleResourceMap( i_xBundle, xRes );
-
- return nAdded;
-}
-
-// check some known bad plugins to avoid crashes
-static bool checkBlackList( CFBundleRef i_xBundle )
-{
- rtl::OUString aBundleName;
- CFTypeRef bundlename = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("CFBundleName"));
- if( bundlename && CFGetTypeID(bundlename) == CFStringGetTypeID() )
- aBundleName = getString( static_cast<CFStringRef>(bundlename) );
-
- rtl::OUString aBundleVersion;
- CFTypeRef bundleversion = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("CFBundleVersion"));
- if( bundleversion && CFGetTypeID(bundleversion) == CFStringGetTypeID() )
- aBundleVersion = getString( static_cast<CFStringRef>(bundleversion) );
-
- bool bReject = false;
- // #i102735# VLC plugin prior to 1.0 tends to crash
- if( aBundleName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VLC Plug-in" ) ) )
- {
- sal_Int32 nIndex = 0;
- rtl::OUString aMajor( aBundleVersion.getToken( 0, '.', nIndex ) );
- if( aMajor.toInt32() < 1 )
- {
- bReject = true;
- }
- }
- // #i103674# Garmin Communicator Plugin crashes
- else if( aBundleName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Garmin Communicator Plugin" ) ) )
- {
- bReject = true;
- }
-
- #if OSL_DEBUG_LEVEL > 1
- if( bReject )
- fprintf( stderr, "rejecting plugin \"%s\" version %s\n",
- rtl::OUStringToOString( aBundleName, RTL_TEXTENCODING_UTF8 ).getStr(),
- rtl::OUStringToOString( aBundleVersion, RTL_TEXTENCODING_UTF8 ).getStr()
- );
- #endif
-
- return bReject;
-}
-
-static int getPluginDescriptions( CFBundleRef i_xBundle , list< PluginDescription* >& io_rDescriptions )
-{
- int nDescriptions = 0;
- if( ! i_xBundle )
- return nDescriptions;
-
- if( checkBlackList( i_xBundle ) )
- return 0;
-
- rtl::OUString aPlugURL;
- CFURLRef xURL = CFBundleCopyBundleURL( i_xBundle );
- aPlugURL = getString( xURL );
- CFRelease( xURL );
-
- #if OSL_DEBUG_LEVEL > 1
- rtl::OUString aPlugName, aPlugDescription;
- CFTypeRef name = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginName"));
- if( name && CFGetTypeID(name) == CFStringGetTypeID() )
- aPlugName = getString( static_cast<CFStringRef>(name) );
-
- CFTypeRef description = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginDescription"));
- if( description && CFGetTypeID(description) == CFStringGetTypeID() )
- aPlugDescription = getString( static_cast<CFStringRef>(description) );
-
- fprintf( stderr, "URL: %s\nname: %s\ndescription: %s\n",
- rtl::OUStringToOString( aPlugURL, RTL_TEXTENCODING_UTF8 ).getStr(),
- rtl::OUStringToOString( aPlugName, RTL_TEXTENCODING_UTF8 ).getStr(),
- rtl::OUStringToOString( aPlugDescription, RTL_TEXTENCODING_UTF8 ).getStr()
- );
- #endif
-
-
- // get location of plugin library
- CFURLRef xLibURL = CFBundleCopyExecutableURL( i_xBundle );
- if( ! xLibURL )
- return 0;
- // get the file system path
- rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) );
- CFRelease( xLibURL );
-
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "exec URL = %s\n", rtl::OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() );
- #endif
-
- /* TODO: originally the C++ wrapper for oslModule was used here, but that led to
- mysterious crashes in the event loop (pointing to heap corruption). Why using
- the C style oslModule should fix this is completely unknown. It may be that
- we have just hidden the heap corruption a little more.
- */
- oslModule aMod = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT );
- if( ! aMod )
- return 0;
-
- // check for at least the init function of a plugin
- if( ! osl_getAsciiFunctionSymbol( aMod, "NP_Initialize") &&
- ! osl_getAsciiFunctionSymbol( aMod, "NP_GetEntryPoints" ) )
- {
- return 0;
- }
-
- // ask the plist of the bundle for mimetypes
- nDescriptions = parsePlist( i_xBundle, aPlugURL, io_rDescriptions );
- if( nDescriptions )
- {
- osl_unloadModule( aMod );
- return nDescriptions;
- }
-
- // resolve the symbol that might get us the mimetypes
- const char* (*pGetMimeDescription)() = (const char*(*)())osl_getAsciiFunctionSymbol( aMod, "_NP_GetMIMEDescription" );
- if( pGetMimeDescription )
- {
- const char* pMime = pGetMimeDescription();
- if( pMime )
- {
- nDescriptions = parseMimeString( aPlugURL, io_rDescriptions, pMime );
- if( nDescriptions )
- {
- osl_unloadModule( aMod );
- return nDescriptions;
- }
- }
- }
-
- // and as last resort check the resource of the bundle
- nDescriptions = parseMimeResource( i_xBundle, aMod, aPlugURL, io_rDescriptions );
- osl_unloadModule( aMod );
-
- return nDescriptions;
-}
-
-// Unix specific implementation
-static bool CheckPlugin( const rtl::OUString& rPath, list< PluginDescription* >& rDescriptions )
-{
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "Trying path %s ... ", rtl::OUStringToOString( rPath, RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
- CFURLRef xURL = createURL( rPath );
-
- CFArrayRef xBundles = CFBundleCreateBundlesFromDirectory( NULL, xURL, CFSTR("plugin") );
- if( ! xBundles )
- return false;
-
- CFIndex nBundles = CFArrayGetCount( xBundles );
-
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "got %d bundles\n", (int)nBundles );
-#endif
-
- int nDescriptions = 0;
- for( CFIndex i = 0; i < nBundles; i++ )
- {
- CFBundleRef xBundle = (CFBundleRef)CFArrayGetValueAtIndex( xBundles, i );
- nDescriptions += getPluginDescriptions( xBundle, rDescriptions );
-
- CFRelease( xBundle );
- }
- CFRelease( xBundles );
-
-
- return nDescriptions > 0;
-}
-
-static rtl::OUString FindFolderURL( FSVolumeRefNum vRefNum, OSType folderType )
-{
- rtl::OUString aRet;
-
- FSRef aFSRef;
- OSErr err = FSFindFolder( vRefNum, folderType, kDontCreateFolder, &aFSRef );
- if( err == noErr )
- {
- CFURLRef xURL = CFURLCreateFromFSRef( NULL, &aFSRef );
- aRet = getString( xURL );
- CFRelease( xURL );
- }
-
- return aRet;
-}
-
-Sequence<PluginDescription> XPluginManager_Impl::impl_getPluginDescriptions() throw(css::uno::RuntimeException, std::exception)
-{
- static Sequence<PluginDescription> aDescriptions;
- static sal_Bool bHavePlugins = sal_False;
- if( ! bHavePlugins )
- {
- std::list<PluginDescription*> aPlugins;
-
- static const char* pNPXPluginPath = getenv( "MOZ_PLUGIN_PATH" );
-
- // get directories
- std::list< rtl::OUString > aPaths;
- if( pNPXPluginPath )
- {
- CFMutableStringRef xMutableString = CFStringCreateMutable( NULL, 0 );
- CFStringAppendCString( xMutableString, pNPXPluginPath, kCFStringEncodingUTF8 );
- CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true );
- CFRelease( xMutableString );
- aPaths.push_back( getString( xURL ) );
- CFRelease( xURL );
- }
-
- rtl::OUString aPath = FindFolderURL( kUserDomain, kInternetPlugInFolderType );
- if( aPath.getLength() )
- aPaths.push_back( aPath );
- aPath = FindFolderURL( kLocalDomain, kInternetPlugInFolderType );
- if( aPath.getLength() )
- aPaths.push_back( aPath );
- aPath = FindFolderURL( kOnAppropriateDisk, kInternetPlugInFolderType );
- if( aPath.getLength() )
- aPaths.push_back( aPath );
-
-
- const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() );
- for( sal_Int32 i = 0; i < rPaths.getLength(); i++ )
- {
- aPaths.push_back( getURLFromPath( rPaths.getConstArray()[i] ) );
- }
-
- for( std::list< rtl::OUString >::const_iterator it = aPaths.begin(); it != aPaths.end(); ++it )
- {
- rtl::OUString aPath( *it );
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "check path %s\n", rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
- CheckPlugin( aPath, aPlugins );
- }
-
-
- // create return value
- aDescriptions = Sequence<PluginDescription>( aPlugins.size() );
-#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "found %d plugins\n", (int)aPlugins.size() );
-#endif
- list<PluginDescription*>::iterator iter;
- sal_Int32 nPlug = 0;
- for( iter = aPlugins.begin(); iter != aPlugins.end(); ++iter )
- {
- aDescriptions.getArray()[ nPlug++ ] = **iter;
- delete *iter;
- }
- aPlugins.clear();
- bHavePlugins = sal_True;
- }
- return aDescriptions;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/aqua/sysplug.mm b/extensions/source/plugin/aqua/sysplug.mm
deleted file mode 100644
index a9b54a8..0000000
--- a/extensions/source/plugin/aqua/sysplug.mm
+++ /dev/null
@@ -1,882 +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.
- *
- ************************************************************************/
-
-#include <config_lgpl.h>
-
-#include <cstdarg>
-
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/wait.h>
-
-#include "premac.h"
-#include <Cocoa/Cocoa.h>
-#include "postmac.h"
-
-#include <osl/thread.h>
-
-#include <plugin/impl.hxx>
-
-extern NPNetscapeFuncs aNPNFuncs;
-
-#include <tools/debug.hxx>
-
-using namespace plugstringhelper;
-
-using ::rtl::OUString;
-using ::rtl::OUStringToOString;
-
-#if OSL_DEBUG_LEVEL > 1
-void TRACE( char const * s );
-void TRACEN( char const * s, long n );
-#else
-#define TRACE(x)
-#define TRACEN(x,n)
-#endif
-
-
-struct SysPlugData
-{
- MacPluginComm::NP_CGContext m_aCGContext;
- NP_Port m_aNPPort;
- NSView* m_pParentView;
- NSView* m_pPlugView;
- int m_nDrawingModel;
- NSPoint m_aLastPlugViewOrigin;
- bool m_bSetWindowOnDraw;
- SysPlugData()
- {
- memset( this, 0, sizeof(*this) );
- }
-};
-
-std::shared_ptr<SysPlugData> CreateSysPlugData()
-{
- return std::shared_ptr<SysPlugData>(new SysPlugData);
-}
-
-void XPlugin_Impl::SetSysPlugDataParentView(SystemEnvData const& rEnvData)
-{
- m_pSysPlugData->m_pParentView = rEnvData.mpNSView;
-}
-
-extern "C" {
-
-void /*SAL_CALL NP_LOADDS*/ NPN_ForceRedraw_Impl(NPP instance)
-{
- TRACE( "NPN_ForceRedraw_Impl" );
- XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
- if( pImpl )
- {
- SysPlugData& rPlugData( pImpl->getSysPlugData() );
- if( rPlugData.m_pPlugView )
- [rPlugData.m_pPlugView setNeedsDisplay: YES];
- }
-}
-
-NPError /*SAL_CALL NP_LOADDS*/ NPN_SetValue_Impl( NPP instance,
- NPPVariable variable,
- void* value )
-{
- TRACE( "NPN_SetValue_Impl" );
- switch( variable )
- {
- case (NPPVariable)1000: // NPNVpluginDrawingModel
- {
- // ugly, but that's the way we need to do it
- int nDrawingModel = (int)value;
-
- TRACEN( "drawing model: ", nDrawingModel );
- XPlugin_Impl* pImpl =
- XPluginManager_Impl::getXPluginFromNPP( instance );
- if (pImpl)
- pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel;
- }
- break;
- default:
- break;
- }
- return NPERR_NO_ERROR;
-}
-
-} // extern "C"
-
-struct FakeEventRecord : public EventRecord
-{
- FakeEventRecord()
- {
- memset( this, 0, sizeof(EventRecord) );
- ::GetGlobalMouse( &where );
- when = ::TickCount();
- modifiers = ::GetCurrentEventKeyModifiers();
- }
-};
-
-
- at interface OOoPluginView : NSView
-{
- XPlugin_Impl* m_pImpl;
- MacPluginComm* m_pCom;
-}
--(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect)i_aRect;
--(void)drawRect: (NSRect)i_aRect;
--(BOOL)isOpaque;
--(BOOL)isFlipped;
-
-// NSResponder
--(void)mouseMoved: (NSEvent*)i_pEvent;
--(void)mouseDown: (NSEvent*)i_pEvent;
--(void)mouseDragged: (NSEvent*)i_pEvent;
--(void)mouseUp: (NSEvent*)i_pEvent;
--(void)rightMouseDown: (NSEvent*)i_pEvent;
--(void)rightMouseDragged: (NSEvent*)i_pEvent;
--(void)rightMouseUp: (NSEvent*)i_pEvent;
--(void)otherMouseDown: (NSEvent*)i_pEvent;
--(void)otherMouseDragged: (NSEvent*)i_pEvent;
--(void)otherMouseUp: (NSEvent*)i_pEvent;
--(void)mouseEntered: (NSEvent*)i_pEvent;
--(void)mouseExited: (NSEvent*)i_pEvent;
- at end
-
- at implementation OOoPluginView
--(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect) i_aRect
-{
- if( (self = [super initWithFrame: i_aRect]) )
- {
- m_pImpl = i_pImpl;
- m_pCom = i_pCom;
- }
- return self;
-}
-
--(void)drawRect: (NSRect) i_aRect
-{
- (void) i_aRect; // unused
- m_pCom->drawView( m_pImpl );
-}
-
--(BOOL)isOpaque
-{
- return NO;
-}
-
--(BOOL)isFlipped
-{
- return YES;
-}
-
-// NSResponder
--(void)mouseMoved: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)mouseDown: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = mouseDown;
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)mouseDragged: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)mouseUp: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = mouseUp;
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)rightMouseDown: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = mouseDown;
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)rightMouseDragged: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)rightMouseUp: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = mouseUp;
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)otherMouseDown: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = mouseDown;
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)otherMouseDragged: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)otherMouseUp: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = mouseUp;
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)mouseEntered: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
--(void)mouseExited: (NSEvent*)i_pEvent
-{
- (void) i_pEvent; // unused
- FakeEventRecord aRec;
- aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
- m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec );
-}
-
- at end
-
-
-MacPluginComm::MacPluginComm( const rtl::OUString& i_rMimetype, const rtl::OUString& i_rBundle, NSView* i_pParent )
- : PluginComm( OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ) ),
- m_xBundle( NULL ),
- m_hPlugLib( NULL ),
- m_pNullTimer( NULL )
-{
- (void) i_rMimetype; // unused
- (void) i_pParent; // unused
- // initialize plugin function table
- memset( &m_aNPPfuncs, 0, sizeof( m_aNPPfuncs ) );
-
- // load the bundle
- CFURLRef xURL = createURL( i_rBundle );
- m_xBundle = CFBundleCreate( NULL, xURL );
- CFRelease( xURL );
- if( m_xBundle )
- {
- // ask the plugin library
- // first get its location
- CFURLRef xLibURL = CFBundleCopyExecutableURL( m_xBundle );
- if( xLibURL )
- {
- // get the file system path
- rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) );
- CFRelease( xLibURL );
- m_hPlugLib = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT );
- #if OSL_DEBUG_LEVEL > 1
- if( ! m_hPlugLib )
- fprintf( stderr, "module %s could not be loaded\n", OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() );
- #endif
- }
- #if OSL_DEBUG_LEVEL > 1
- else
- fprintf( stderr, "bundle %s has no exectutable URL\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() );
- #endif
- }
- else
- {
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "bundle %s could not be loaded\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() );
- #endif
- }
-
- DBG_ASSERT( m_xBundle && m_hPlugLib, "loading plugin bundle failed!" );
-
-
- m_aNPPfuncs.size = sizeof( m_aNPPfuncs );
- m_aNPPfuncs.version = 0;
-
-
- m_eCall = eNP_Initialize;
- execute();
-}
-
-
-MacPluginComm::~MacPluginComm()
-{
- if( m_hPlugLib )
- {
- // NPP_Shutdown();
- NPError (*pShutdown)();
- if( retrieveFunction( "NP_Shutdown", (void**)&pShutdown ) )
- {
- NPError nErr = (*pShutdown)(); (void)nErr;
- DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_Shutdown() failed!" );
- }
- osl_unloadModule( m_hPlugLib );
- }
- if( m_xBundle )
- CFRelease( m_xBundle );
-}
-
-
-sal_Bool MacPluginComm::retrieveFunction( const char* i_pName, void** o_ppFunc ) const
-{
- if( ! m_hPlugLib || ! o_ppFunc )
- return sal_False;
-
- *o_ppFunc = (void*)osl_getAsciiFunctionSymbol( m_hPlugLib, i_pName );
-
- if( ! *o_ppFunc && m_xBundle )
- {
- rtl::OUString aName( OUString::createFromAscii( *i_pName == '_' ? i_pName+1 : i_pName ) );
- CFStringRef xName = createString( aName );
- if( xName )
- {
- *o_ppFunc = CFBundleGetFunctionPointerForName( m_xBundle, xName );
- CFRelease( xName );
- }
- }
-
- return (*o_ppFunc != NULL);
-}
-
-IMPL_LINK_NOARG_TYPED(MacPluginComm, NullTimerHdl, Timer*, void)
-{
- // note: this is a Timer handler, we are already protected by the SolarMutex
-
- FakeEventRecord aRec;
- aRec.what = nullEvent;
- aRec.where.h = aRec.where.v = 20000;
-
- for( std::list< XPlugin_Impl* >::iterator it = m_aNullEventClients.begin();
- it != m_aNullEventClients.end(); ++it )
- {
- SysPlugData& rPlugData( (*it)->getSysPlugData() );
- if( rPlugData.m_pPlugView ) // for safety do not dispatch null events before first NPP_SetWindow
- (*m_aNPPfuncs.event)( &(*it)->getNPPInstance(), &aRec );
- }
-}
-
-
-
-long MacPluginComm::doIt()
-{
- long nRet = 0;
- switch( m_eCall )
- {
- case eNP_Initialize:
- {
- TRACE( "eNP_Initialize" );
- NPError (*pInit)( NPNetscapeFuncs* );
- if( retrieveFunction( "NP_Initialize", (void**)&pInit ) )
- {
- nRet = (*pInit)( &aNPNFuncs );
-
- NPError nErr = NPERR_NO_ERROR;
- NPError (*pEntry)( NPPluginFuncs* );
- retrieveFunction( "NP_GetEntryPoints", (void**)&pEntry );
- nErr = (*pEntry)( &m_aNPPfuncs );
-
- DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_GetEntryPoints() failed!" );
- }
- else
- {
- nRet = NPERR_GENERIC_ERROR;
- }
- DBG_ASSERT( nRet == NPERR_NO_ERROR, "### NP_Initialize() failed!" );
- }
- break;
- case eNPP_Destroy:
- if( m_aNullEventClients.empty() )
- delete m_pNullTimer, m_pNullTimer = NULL;
-
- TRACE( "eNPP_Destroy" );
- nRet = (m_aNPPfuncs.destroy
- ? (*m_aNPPfuncs.destroy)(
- (NPP)m_aArgs[0],
- (NPSavedData**)m_aArgs[1] )
- : NPERR_GENERIC_ERROR);
- break;
- case eNPP_DestroyStream:
- TRACE( "eNPP_DestroyStream" );
- nRet = (m_aNPPfuncs.destroystream
- ? (*m_aNPPfuncs.destroystream)(
- (NPP)m_aArgs[0],
- (NPStream*)m_aArgs[1],
- (NPError)(sal_IntPtr)m_aArgs[2] )
- : NPERR_GENERIC_ERROR);
- break;
- case eNPP_New:
- TRACE( "eNPP_New" );
- nRet = (m_aNPPfuncs.newp
- ? (*m_aNPPfuncs.newp)(
- (NPMIMEType)m_aArgs[0],
- (NPP)m_aArgs[1],
- (uint16_t)(sal_IntPtr)m_aArgs[2],
- (int16_t)(sal_IntPtr)m_aArgs[3],
- (char**)m_aArgs[4],
- (char**)m_aArgs[5],
- (NPSavedData*)m_aArgs[6] )
- : NPERR_GENERIC_ERROR);
-
- if( ! m_pNullTimer && m_aNPPfuncs.event )
- {
- m_pNullTimer = new AutoTimer();
- m_pNullTimer->SetTimeout( 50 );
- m_pNullTimer->SetTimeoutHdl( LINK( this, MacPluginComm, NullTimerHdl ) );
- m_pNullTimer->Start();
- }
-
- break;
- case eNPP_NewStream:
- TRACE( "eNPP_NewStream" );
- nRet = (m_aNPPfuncs.newstream
- ? (*m_aNPPfuncs.newstream)(
- (NPP)m_aArgs[0],
- (NPMIMEType)m_aArgs[1],
- (NPStream*)m_aArgs[2],
- (NPBool)(sal_IntPtr)m_aArgs[3],
- (uint16_t*)m_aArgs[4] )
- : NPERR_GENERIC_ERROR);
- break;
- case eNPP_Print:
- TRACE( "eNPP_Print" );
- if (m_aNPPfuncs.print)
- (*m_aNPPfuncs.print)(
- (NPP)m_aArgs[0],
- (NPPrint*)m_aArgs[1] );
- break;
- case eNPP_SetWindow:
- {
- TRACE( "eNPP_SetWindow" );
- nRet = (m_aNPPfuncs.setwindow
- ? (*m_aNPPfuncs.setwindow)(
- (NPP)m_aArgs[0],
- (NPWindow*)m_aArgs[1] )
- : NPERR_GENERIC_ERROR);
-
- break;
- }
- case eNPP_HandleEvent:
- {
- TRACE( "eNPP_HandleEvent" );
- nRet = (m_aNPPfuncs.event
- ? (*m_aNPPfuncs.event)(
- (NPP)m_aArgs[0],
- m_aArgs[1] )
- : NPERR_GENERIC_ERROR);
-
- break;
- }
- case eNPP_StreamAsFile:
- TRACE( "eNPP_StreamAsFile" );
- if (m_aNPPfuncs.asfile)
- (*m_aNPPfuncs.asfile)(
- (NPP)m_aArgs[0],
- (NPStream*)m_aArgs[1],
- (char*)m_aArgs[2] );
- break;
- case eNPP_URLNotify:
- TRACE( "eNPP_URLNotify" );
- if (m_aNPPfuncs.urlnotify)
- (*m_aNPPfuncs.urlnotify)(
- (NPP)m_aArgs[0],
- (char*)m_aArgs[1],
- (NPReason)(sal_IntPtr)m_aArgs[2],
- m_aArgs[3] );
- break;
- case eNPP_Write:
- TRACEN( "eNPP_Write n=", (int32_t)m_aArgs[3] );
- nRet = (m_aNPPfuncs.write
- ? (*m_aNPPfuncs.write)(
- (NPP)m_aArgs[0],
- (NPStream*)m_aArgs[1],
- (int32_t)m_aArgs[2],
- (int32_t)m_aArgs[3],
- m_aArgs[4] )
- : 0);
- break;
- case eNPP_WriteReady:
- TRACE( "eNPP_WriteReady" );
- nRet = (m_aNPPfuncs.writeready
- ? (*m_aNPPfuncs.writeready)(
- (NPP)m_aArgs[0],
- (NPStream*)m_aArgs[1] )
- : 0);
- break;
- case eNPP_GetValue:
- TRACE( "eNPP_GetValue" );
- nRet = (m_aNPPfuncs.getvalue
- ? (*m_aNPPfuncs.getvalue)(
- (NPP)m_aArgs[0],
- (NPPVariable)(int)m_aArgs[1],
- m_aArgs[2] )
- : NPERR_GENERIC_ERROR);
- break;
- case eNPP_SetValue:
- TRACE( "eNPP_SetValue" );
- nRet = (m_aNPPfuncs.setvalue
- ? (*m_aNPPfuncs.setvalue)(
- (NPP)m_aArgs[0],
- (NPNVariable)(int)m_aArgs[1],
- m_aArgs[2] )
- : NPERR_GENERIC_ERROR);
- break;
- case eNPP_Shutdown:
- {
- TRACE( "eNPP_Shutdown" );
- NPP_ShutdownUPP pFunc;
- if (retrieveFunction( "NPP_Shutdown", (void**)&pFunc ))
- (*pFunc)();
- }
- break;
- case eNPP_Initialize:
- TRACE( "eNPP_Initialize" );
- OSL_FAIL( "NPP_Initialize: not implemented!" );
- break;
- case eNPP_GetJavaClass:
- TRACE( "eNPP_GetJavaClass" );
- OSL_FAIL( "NPP_GetJavaClass: not implemented!" );
- break;
- }
- return nRet;
-}
-
-
-NPError MacPluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save )
-{
- // remove from NullEvent timer
- m_aNullEventClients.remove( i_pImpl );
-
- NPError nErr = NPP_Destroy( &i_pImpl->getNPPInstance(), save );
-
- // release plugin view
- SysPlugData& rPlugData( i_pImpl->getSysPlugData() );
- if( rPlugData.m_pPlugView )
- {
- [rPlugData.m_pPlugView removeFromSuperview];
- [rPlugData.m_pPlugView release];
- rPlugData.m_pPlugView = nil;
- }
-
- return nErr;
-}
-
-
-NPError MacPluginComm::NPP_Destroy( NPP instance, NPSavedData** save )
-{
- DBG_ASSERT( m_aNPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" );
- m_eCall = eNPP_Destroy;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)save;
- return (NPError)execute();
-}
-
-
-NPError MacPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason )
-{
- DBG_ASSERT( m_aNPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" );
- m_eCall = eNPP_DestroyStream;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)stream;
- m_aArgs[2] = (void*)(intptr_t)reason;
- return (NPError)execute();
-}
-
-
-NPError MacPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
- char* argn[], char* argv[], NPSavedData *saved )
-{
- XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
- DBG_ASSERT( pImpl, "no instance found" );
-
- if( pImpl ) // sanity check
- m_aNullEventClients.push_back( pImpl );
-
- DBG_ASSERT( m_aNPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" );
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "NPP_New( %s. %p, %d, %d",
- pluginType, instance, (int)mode, (int)argc );
- for( int16_t i = 0; i < argc; i++ )
- fprintf( stderr, "\n%s = %s", argn[i], argv[i] );
- fprintf( stderr, ", %p )\n", saved );
- #endif
- m_eCall = eNPP_New;
- m_aArgs[0] = (void*)pluginType;
- m_aArgs[1] = (void*)instance;
- m_aArgs[2] = (void*)(intptr_t)mode;
- m_aArgs[3] = (void*)(intptr_t)argc;
- m_aArgs[4] = (void*)argn;
- m_aArgs[5] = (void*)argv;
- m_aArgs[6] = (void*)saved;
-
- return (NPError)execute();
-}
-
-
-NPError MacPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16_t* stype )
-{
- DBG_ASSERT( m_aNPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" );
- m_eCall = eNPP_NewStream;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)type;
- m_aArgs[2] = (void*)stream;
- m_aArgs[3] = (void*)(intptr_t)seekable;
- m_aArgs[4] = (void*)stype;
- return (NPError)execute();
-}
-
-
-void MacPluginComm::NPP_Print( NPP instance, NPPrint* platformPrint )
-{
- DBG_ASSERT( m_aNPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" );
- m_eCall = eNPP_Print;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)platformPrint;
- execute();
-}
-
-
-NPError MacPluginComm::NPP_SetWindow( NPP instance, NPWindow* window )
-{
- DBG_ASSERT( m_aNPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" );
- m_eCall = eNPP_SetWindow;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)window;
- return (NPError)execute();
-}
-
-
-NPError MacPluginComm::NPP_HandleEvent( NPP instance, void* event )
-{
- DBG_ASSERT( m_aNPPfuncs.event, "### NPP_HandleEvent(): null pointer in NPP functions table!" );
- m_eCall = eNPP_HandleEvent;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = event;
- return (NPError)execute();
-}
-
-
-void MacPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname )
-{
- DBG_ASSERT( m_aNPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" );
- m_eCall = eNPP_StreamAsFile;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)stream;
- m_aArgs[2] = (void*)fname;
- execute();
-}
-
-
-void MacPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData )
-{
- DBG_ASSERT( m_aNPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" );
- m_eCall = eNPP_URLNotify;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)url;
- m_aArgs[2] = (void*)(intptr_t)reason;
- m_aArgs[3] = notifyData;
- execute();
-}
-
-
-int32_t MacPluginComm::NPP_Write( NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer )
-{
- DBG_ASSERT( m_aNPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" );
- m_eCall = eNPP_Write;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)stream;
- m_aArgs[2] = (void*)offset;
- m_aArgs[3] = (void*)len;
- m_aArgs[4] = buffer;
- return (NPError)execute();
-}
-
-
-int32_t MacPluginComm::NPP_WriteReady( NPP instance, NPStream* stream )
-{
- DBG_ASSERT( m_aNPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" );
- m_eCall = eNPP_WriteReady;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)stream;
- return execute();
-}
-
-
-NPError MacPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value )
-{
- DBG_ASSERT( m_aNPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" );
- m_eCall = eNPP_GetValue;
- m_aArgs[0] = (void*)instance;
- m_aArgs[1] = (void*)variable;
- m_aArgs[2] = ret_value;
- return (NPError)execute();
-}
-
-
-NPError MacPluginComm::NPP_Initialize()
-{
- return NPERR_NO_ERROR;
-}
-
-
-void MacPluginComm::NPP_Shutdown()
-{
- m_eCall = eNPP_Shutdown;
- execute();
-}
-
-
-NPError MacPluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl )
-{
- // update window NPWindow from view
- SysPlugData& rPlugData( i_pImpl->getSysPlugData() );
-
- // update plug view
- NSRect aPlugRect = [rPlugData.m_pParentView frame];
- aPlugRect.origin.x = aPlugRect.origin.y = 0;
- if( ! rPlugData.m_pPlugView )
- {
- rPlugData.m_pPlugView = [[OOoPluginView alloc] initWithInstance: i_pImpl pluginComm: this frame: aPlugRect];
- [rPlugData.m_pParentView addSubview: rPlugData.m_pPlugView];
- }
- else
- [rPlugData.m_pPlugView setFrame: aPlugRect];
-
- NPWindow* pNPWin = &i_pImpl->getNPWindow();
- NSWindow* pWin = [rPlugData.m_pPlugView window];
- NSRect aWinRect = [pWin frame];
- NSRect aBounds = [rPlugData.m_pPlugView frame];
- NSRect aVisibleBounds = [rPlugData.m_pPlugView visibleRect];
-
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "visible bounds = %d+%d+%dx%d\n",
- (int)aVisibleBounds.origin.x, (int)aVisibleBounds.origin.y,
- (int)aVisibleBounds.size.width, (int)aVisibleBounds.size.height );
- #endif
-
- NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil];
- // save view origin so we can notice movement of the view in drawView
- // in case of a moved view we need to reset the port/context
- rPlugData.m_aLastPlugViewOrigin = aViewOrigin;
-
- // convert view origin to topdown coordinates
- aViewOrigin.y = aWinRect.size.height - aViewOrigin.y;
-
- // same for clipping
- NSPoint aClipOrigin = [rPlugData.m_pPlugView convertPoint: aVisibleBounds.origin toView: nil];
- aClipOrigin.y = aWinRect.size.height - aClipOrigin.y;
-
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "view origin: %d+%d, clip origin = %d+%d\n",
- (int)aViewOrigin.x, (int)aViewOrigin.y,
- (int)aClipOrigin.x, (int)aClipOrigin.y );
- #endif
-
- pNPWin->x = aViewOrigin.x;
- pNPWin->y = aViewOrigin.y;
- pNPWin->width = aBounds.size.width;
- pNPWin->height = aBounds.size.height;
- pNPWin->clipRect.left = aClipOrigin.x;
- pNPWin->clipRect.top = aClipOrigin.y;
- pNPWin->clipRect.right = aClipOrigin.x + aVisibleBounds.size.width;
- pNPWin->clipRect.bottom = aClipOrigin.y + aVisibleBounds.size.height;
-
- if( rPlugData.m_nDrawingModel == 1 )
- {
- rPlugData.m_aCGContext.window = reinterpret_cast<WindowRef>([pWin windowRef]);
- pNPWin->window = &rPlugData.m_aCGContext;
- rPlugData.m_aCGContext.context = reinterpret_cast<CGContextRef>([[pWin graphicsContext] graphicsPort]);
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "window is %p, context is %p\n",
- rPlugData.m_aCGContext.window, rPlugData.m_aCGContext.context );
- #endif
- }
- else
- {
- rPlugData.m_aNPPort.port = GetWindowPort( reinterpret_cast<WindowRef>([pWin windowRef]) );
- rPlugData.m_aNPPort.portx = aClipOrigin.x;
- rPlugData.m_aNPPort.porty = aClipOrigin.y;
- pNPWin->window = &rPlugData.m_aNPPort;
- #if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, "port is %p at (%d,%d)\n",
- rPlugData.m_aNPPort.port, (int)rPlugData.m_aNPPort.portx, (int)rPlugData.m_aNPPort.porty );
- #endif
- }
-
- if( pNPWin->width == 0 || pNPWin->height == 0 || [rPlugData.m_pPlugView isHiddenOrHasHiddenAncestor] )
- rPlugData.m_bSetWindowOnDraw = true;
-
- NPError nErr = NPP_SetWindow( &i_pImpl->getNPPInstance(), &i_pImpl->getNPWindow() );
-
- return nErr;
-}
-
-void MacPluginComm::drawView( XPlugin_Impl* i_pImpl )
-{
- SysPlugData& rPlugData( i_pImpl->getSysPlugData() );
-
- // check if the view was moved since the last SetWindow
- NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil];
- if( rPlugData.m_bSetWindowOnDraw ||
- aViewOrigin.x != rPlugData.m_aLastPlugViewOrigin.x ||
- aViewOrigin.y != rPlugData.m_aLastPlugViewOrigin.y )
- {
- NPP_SetWindow( i_pImpl );
- rPlugData.m_bSetWindowOnDraw = false;
- }
-
- // send a paint event
- NSWindow* pWin = [rPlugData.m_pPlugView window];
- FakeEventRecord aRec;
- aRec.what = updateEvt;
- aRec.message = (uint32_t)[pWin windowRef];
- this->NPP_HandleEvent( &i_pImpl->getNPPInstance(), &aRec );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx
deleted file mode 100644
index 478562aa..0000000
--- a/extensions/source/plugin/base/context.cxx
+++ /dev/null
@@ -1,345 +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.
- *
- ************************************************************************/
-
-#ifdef AIX
-#define _LINUX_SOURCE_COMPAT
-#include <sys/timer.h>
-#undef _LINUX_SOURCE_COMPAT
-#endif
-
-#ifdef WNT
-#include <prewin.h>
-#include <postwin.h>
-#endif
-
-#include <cstdarg>
-#include <cstdio>
-
-#include <plugin/impl.hxx>
-
-#include <sal/log.hxx>
-#include <com/sun/star/frame/FrameSearchFlag.hpp>
-#include <com/sun/star/frame/XComponentLoader.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/frame/Desktop.hpp>
-#include <comphelper/fileurl.hxx>
-#include <tools/urlobj.hxx>
-#include <osl/file.hxx>
-
-#include <cppuhelper/implbase1.hxx>
-
-using namespace com::sun::star::io;
-using namespace com::sun::star::frame;
-
-namespace ext_plug {
-
-class FileSink : public ::cppu::WeakAggImplHelper1< css::io::XOutputStream >
-{
-private:
- Reference< css::uno::XComponentContext > m_xContext;
- FILE* fp;
- Reference< css::plugin::XPlugin > m_xPlugin;
- OUString m_aTarget;
- OUString m_aFileName;
-
-public:
- FileSink( const Reference< css::uno::XComponentContext > &,
- const Reference< css::plugin::XPlugin > & plugin,
- const OUString& target,
- const Reference< css::io::XActiveDataSource > & source );
- virtual ~FileSink();
-
- // css::io::XOutputStream
- virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw(std::exception) override;
- virtual void SAL_CALL flush() throw(std::exception) override;
- virtual void SAL_CALL closeOutput() throw (RuntimeException, std::exception) override;
-};
-
-}
-using namespace ext_plug;
-
-class XPluginContext_Impl : public ::cppu::WeakAggImplHelper1< css::plugin::XPluginContext >
-{
- Reference< css::uno::XComponentContext > m_xContext;
- rtl_TextEncoding m_aEncoding;
-public:
-
- XPluginContext_Impl( const Reference< css::uno::XComponentContext > & );
- virtual ~XPluginContext_Impl();
-
-
- virtual OUString SAL_CALL getValue(const Reference< css::plugin::XPlugin > & plugin, css::plugin::PluginVariable variable) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual void SAL_CALL getURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Reference< css::lang::XEventListener > & listener) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual void SAL_CALL getURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual void SAL_CALL postURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< css::lang::XEventListener > & listener) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual void SAL_CALL postURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual void SAL_CALL newStream(const Reference< css::plugin::XPlugin > & plugin, const OUString& mimetype, const OUString& target, const Reference< css::io::XActiveDataSource > & source) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual void SAL_CALL displayStatusText(const Reference< css::plugin::XPlugin > & plugin, const OUString& message) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
- virtual OUString SAL_CALL getUserAgent(const Reference< css::plugin::XPlugin > & plugin) throw( css::plugin::PluginException, RuntimeException, std::exception ) override;
-};
-
-Reference< css::plugin::XPluginContext > XPluginManager_Impl::createPluginContext() throw(std::exception)
-{
- return new XPluginContext_Impl( m_xContext );
-}
-
-XPluginContext_Impl::XPluginContext_Impl( const Reference< css::uno::XComponentContext > & rxContext )
- : m_xContext( rxContext ),
- m_aEncoding( osl_getThreadTextEncoding() )
-{
-}
-
-XPluginContext_Impl::~XPluginContext_Impl()
-{
-}
-
-OUString XPluginContext_Impl::getValue( const Reference< css::plugin::XPlugin > & /*plugin*/, css::plugin::PluginVariable /*variable*/ )
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- return OUString();
-}
-
-
-void XPluginContext_Impl::getURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target) throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- Reference< XDesktop2 > xDesktop = Desktop::create(m_xContext);
-
- if( target.isEmpty() )
- {
- INetURLObject aURL;
- aURL.SetSmartProtocol( INetProtocol::File );
- aURL.SetSmartURL( url );
-
- OUString aUrl = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
- // the mimetype cannot be specified
- plugin->provideNewStream( OUString(),
- Reference< XActiveDataSource >(),
- aUrl,
- 0, 0, comphelper::isFileUrl(aUrl) );
- return;
- }
-
- XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin );
-
- if( pPlugin )
- {
- try
- {
- css::beans::PropertyValue aValue;
- aValue.Name = "Referer";
- aValue.Value <<= pPlugin->getRefererURL();
-
- Sequence< css::beans::PropertyValue > aArgs( &aValue, 1 );
- Reference< css::lang::XComponent > xComp =
- xDesktop->loadComponentFromURL(
- url,
- target,
- css::frame::FrameSearchFlag::PARENT |
- css::frame::FrameSearchFlag::SELF |
- css::frame::FrameSearchFlag::CHILDREN |
- css::frame::FrameSearchFlag::SIBLINGS |
- css::frame::FrameSearchFlag::TASKS |
- css::frame::FrameSearchFlag::CREATE,
- aArgs
- );
- }
- catch(...)
- {
- throw css::plugin::PluginException();
- }
- }
-}
-
-void XPluginContext_Impl::getURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Reference< css::lang::XEventListener > & listener )
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- getURL( plugin, url, target );
- if( listener.is() )
- listener->disposing( css::lang::EventObject() );
-}
-
-OUString XPluginContext_Impl::getUserAgent(const Reference< css::plugin::XPlugin > & /*plugin*/)
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- return OUString("Mozilla 3.0");
-}
-
-void XPluginContext_Impl::displayStatusText(const Reference< css::plugin::XPlugin > & /*plugin*/, const OUString& /*message*/)
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
-}
-
-void XPluginContext_Impl::postURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file)
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- Sequence< sal_Int8 > aBuf;
-
- if( file )
- {
- OUString aFileName( reinterpret_cast<char const *>(buf.getConstArray()), strlen(reinterpret_cast<char const *>(buf.getConstArray())), m_aEncoding );
- INetURLObject aFilePath( aFileName );
- aFileName = aFilePath.PathToFileName();
- SvFileStream aStream( aFileName, StreamMode::READ );
- if( aStream.IsOpen() )
- {
- sal_Int64 const nBytes = aStream.remainingSize();
- aBuf = Sequence<sal_Int8>( nBytes );
- aStream.Read( aBuf.getArray(), nBytes );
- aStream.Close();
- osl::FileBase::getFileURLFromSystemPath( aFileName, aFileName );
- osl::File::remove( aFileName );
- }
- }
-
- Reference< XDesktop2 > xDesktop = Desktop::create(m_xContext);
-
- XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin );
- if( pPlugin )
- {
- try
- {
- css::beans::PropertyValue aValues[2];
- aValues[0].Name = "Referer";
- aValues[0].Value <<= pPlugin->getRefererURL();
-
- aValues[1].Name = "PostString";
- aValues[1].Value <<= OStringToOUString( reinterpret_cast<char const *>(( file ? aBuf : buf ).getConstArray()), m_aEncoding );
- Sequence< css::beans::PropertyValue > aArgs( aValues, 2 );
- Reference< css::lang::XComponent > xComp =
- xDesktop->loadComponentFromURL(
- url,
- target,
- css::frame::FrameSearchFlag::PARENT |
- css::frame::FrameSearchFlag::SELF |
- css::frame::FrameSearchFlag::CHILDREN |
- css::frame::FrameSearchFlag::SIBLINGS |
- css::frame::FrameSearchFlag::TASKS |
- css::frame::FrameSearchFlag::CREATE,
- aArgs
- );
- }
- catch( ... )
- {
- throw css::plugin::PluginException();
- }
- }
-}
-
-void XPluginContext_Impl::postURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< css::lang::XEventListener > & listener )
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- postURL( plugin, url, target, buf, file );
- if( listener.is() )
- listener->disposing( css::lang::EventObject() );
-}
-
-void XPluginContext_Impl::newStream( const Reference< css::plugin::XPlugin > & plugin, const OUString&, const OUString& target, const Reference< css::io::XActiveDataSource > & source )
- throw( css::plugin::PluginException, RuntimeException, std::exception )
-{
- FileSink* pNewSink = new FileSink( m_xContext, plugin, target, source );
- pNewSink->acquire();
-}
-
-
-
-FileSink::FileSink( const Reference< css::uno::XComponentContext > & rxContext, const Reference< css::plugin::XPlugin > & plugin,
- const OUString& target, const Reference< css::io::XActiveDataSource > & source ) :
- m_xContext( rxContext ),
- m_xPlugin( plugin ),
- m_aTarget( target )
-{
- osl::FileBase::createTempFile( nullptr, nullptr, &m_aFileName );
- OString aFile = OUStringToOString( m_aFileName, osl_getThreadTextEncoding() );
- fp = fopen( aFile.getStr() , "wb" );
-
- Reference< css::io::XActiveDataControl > xControl( source, UNO_QUERY );
-
- source->setOutputStream( Reference< css::io::XOutputStream > ( this ) );
- if( xControl.is() )
- xControl->start();
-}
-
-FileSink::~FileSink()
-{
- osl::File::remove( m_aFileName );
-}
-
-void FileSink::closeOutput() throw (RuntimeException, std::exception)
-{
- if( fp )
- fclose( fp );
-
- Reference< XDesktop2 > xDesktop = Desktop::create(m_xContext);
- XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( m_xPlugin );
-
- if( pPlugin )
- {
- try
- {
- css::beans::PropertyValue aValue;
- aValue.Name = "Referer";
- aValue.Value <<= pPlugin->getRefererURL();
-
- Sequence< css::beans::PropertyValue > aArgs( &aValue, 1 );
- Reference< css::lang::XComponent > xComp =
- xDesktop->loadComponentFromURL(
- m_aFileName,
- m_aTarget,
- css::frame::FrameSearchFlag::PARENT |
- css::frame::FrameSearchFlag::SELF |
- css::frame::FrameSearchFlag::CHILDREN |
- css::frame::FrameSearchFlag::SIBLINGS |
- css::frame::FrameSearchFlag::TASKS |
- css::frame::FrameSearchFlag::CREATE,
- aArgs
- );
- }
- catch( ... )
- {
- }
- }
- release();
-}
-
-void FileSink::writeBytes( const Sequence<sal_Int8>& Buffer ) throw(std::exception)
-{
- if( fp )
- {
- size_t nItems = Buffer.getLength();
- bool bSuccess = (fwrite(Buffer.getConstArray(), 1, nItems, fp) == nItems);
- SAL_WARN_IF( !bSuccess, "extensions.plugin", "short write");
- }
-}
-
-void FileSink::flush() throw(std::exception)
-{
- 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 ef865fd..0000000
--- a/extensions/source/plugin/base/evtlstnr.cxx
+++ /dev/null
@@ -1,74 +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.
- *
- ************************************************************************/
-
-
-#ifdef AIX
-#define _LINUX_SOURCE_COMPAT
-#include <sys/timer.h>
-#undef _LINUX_SOURCE_COMPAT
-#endif
-
-#ifdef WNT
-#include <prewin.h>
-#include <postwin.h>
-#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 css::lang::EventObject& /*rEvt*/ ) throw(std::exception)
-{
- 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/manager.cxx b/extensions/source/plugin/base/manager.cxx
deleted file mode 100644
index 21e3542..0000000
--- a/extensions/source/plugin/base/manager.cxx
+++ /dev/null
@@ -1,234 +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.
- *
- ************************************************************************/
-
-
-#ifdef AIX
-#define _LINUX_SOURCE_COMPAT
-#include <sys/timer.h>
-#undef _LINUX_SOURCE_COMPAT
-#endif
-
-#ifdef WNT
-#include <prewin.h>
-#include <postwin.h>
-#endif
-
-#include <cstdarg>
-
-#include <comphelper/fileurl.hxx>
-#include <comphelper/string.hxx>
-#include <comphelper/processfactory.hxx>
-
-#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 <cppuhelper/supportsservice.hxx>
-
-PluginManager* PluginManager::pManager = nullptr;
-
-PluginManager& PluginManager::get()
-{
- if( ! pManager )
- pManager = new PluginManager();
- return *pManager;
-}
-
-void PluginManager::setServiceFactory( const Reference< css::lang::XMultiServiceFactory >& xFactory )
-{
- PluginManager& rManager = get();
- if( ! rManager.m_xSMgr.is() )
- rManager.m_xSMgr = xFactory;
-}
-
-PluginManager::PluginManager()
-{
-}
-
-const Sequence< OUString >& PluginManager::getAdditionalSearchPaths()
-{
- static Sequence< OUString > aPaths;
-
- if( ! aPaths.getLength() )
- {
- SvtPathOptions aOptions;
- OUString aPluginPath( aOptions.GetPluginPath() );
- if( !aPluginPath.isEmpty() )
- {
- sal_Int32 nPaths = comphelper::string::getTokenCount(aPluginPath, ';');
- aPaths.realloc( nPaths );
- for( sal_Int32 i = 0; i < nPaths; i++ )
- aPaths.getArray()[i] = aPluginPath.getToken(i, ';');
- }
- }
-
- return aPaths;
-}
-
-
-Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< css::lang::XMultiServiceFactory > & rSMgr ) throw( Exception )
-{
- Reference< XInterface > xService = *new XPluginManager_Impl( comphelper::getComponentContext(rSMgr) );
- return xService;
-}
-
-// css::lang::XServiceInfo
-OUString XPluginManager_Impl::getImplementationName() throw( )
-
-{
- return getImplementationName_Static();
-
-}
-
-// css::lang::XServiceInfo
-sal_Bool XPluginManager_Impl::supportsService(const OUString& ServiceName) throw( )
-{
- return cppu::supportsService(this, ServiceName);
-}
-
-// css::lang::XServiceInfo
-Sequence< OUString > XPluginManager_Impl::getSupportedServiceNames() throw( )
-{
- return getSupportedServiceNames_Static();
-}
-
-// XPluginManager_Impl
-Sequence< OUString > XPluginManager_Impl::getSupportedServiceNames_Static() throw( )
-{
- Sequence<OUString> aSNS { "com.sun.star.plugin.PluginManager" };
- return aSNS;
-}
-
-XPluginManager_Impl::XPluginManager_Impl( const Reference< css::uno::XComponentContext > & rxContext )
-: m_xContext( rxContext )
-{
- PluginManager::setServiceFactory( Reference< css::lang::XMultiServiceFactory>(rxContext->getServiceManager(), UNO_QUERY_THROW) );
-}
-
-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 nullptr;
-}
-
-XPlugin_Impl* XPluginManager_Impl::getPluginImplementation( const Reference< css::plugin::XPlugin >& plugin )
-{
- ::std::list<XPlugin_Impl*>::iterator iter;
- for( iter = PluginManager::get().getPlugins().begin();
- iter != PluginManager::get().getPlugins().end(); ++iter )
- {
- if( plugin == Reference< css::plugin::XPlugin >((*iter)) )
- return *iter;
- }
-
- return nullptr;
-}
-
-Sequence<css::plugin::PluginDescription> XPluginManager_Impl::getPluginDescriptions()
- throw (RuntimeException, std::exception)
-{
- Sequence<css::plugin::PluginDescription> aRet;
-
- vcl::SettingsConfigItem* pCfg = vcl::SettingsConfigItem::get();
- OUString aVal( pCfg->getValue( "BrowserPlugins",
- "Disabled" ) );
- if( ! aVal.toBoolean() )
- {
- aRet = impl_getPluginDescriptions();
- }
- return aRet;
-}
-
-Reference< css::plugin::XPlugin > XPluginManager_Impl::createPlugin( const Reference< css::plugin::XPluginContext >& acontext, sal_Int16 mode, const Sequence< OUString >& argn, const Sequence< OUString >& argv, const css::plugin::PluginDescription& plugintype)
- throw( RuntimeException,css::plugin::PluginException, std::exception )
-{
- XPlugin_Impl* pImpl = new XPlugin_Impl( Reference< css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW) );
- pImpl->setPluginContext( acontext );
-
- PluginManager::get().getPlugins().push_back( pImpl );
-
- pImpl->initInstance( plugintype,
- argn,
- argv,
- mode );
-
- return pImpl;
-}
-
-Reference< css::plugin::XPlugin > XPluginManager_Impl::createPluginFromURL( const Reference< css::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< OUString >& argn, const Sequence< OUString >& argv, const Reference< css::awt::XToolkit > & toolkit, const Reference< css::awt::XWindowPeer > & parent, const OUString& url ) throw (RuntimeException, std::exception)
-{
- XPlugin_Impl* pImpl = new XPlugin_Impl( Reference< css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW) );
- Reference< css::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< css::io::XActiveDataSource >(),
- url,
- 0, 0, comphelper::isFileUrl(url) );
-
- if( ! pImpl->getPluginComm() )
- {
- pImpl->dispose();
- xRef = nullptr;
- }
-
- 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 faf4100..0000000
--- a/extensions/source/plugin/base/multiplx.cxx
+++ /dev/null
@@ -1,333 +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.
- *
- ************************************************************************/
-
-#include <osl/diagnose.h>
-#include <plugin/multiplx.hxx>
-
-
-// class MRCListenerMultiplexerHelper
-
-MRCListenerMultiplexerHelper::MRCListenerMultiplexerHelper
-(
- const Reference< css::awt::XWindow > & rControl
- , const Reference< css::awt::XWindow > & rPeer
-)
- : xPeer( rPeer )
- , xControl( Reference< css::awt::XControl >( rControl, UNO_QUERY ) )
- , aListenerHolder( aMutex )
-{
-}
-
-
-void MRCListenerMultiplexerHelper::setPeer( const Reference< css::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()
-{
- css::lang::EventObject aEvt;
- aEvt.Source = xControl;
- aListenerHolder.disposeAndClear( aEvt );
-}
-
-// MRCListenerMultiplexerHelper
-void MRCListenerMultiplexerHelper::adviseToPeer( const Reference< css::awt::XWindow > & rPeer, const Type & type )
-{
- // add a listener to the source (peer)
- if( type == cppu::UnoType<css::awt::XWindowListener>::get())
- rPeer->addWindowListener( this );
- else if( type == cppu::UnoType<css::awt::XKeyListener>::get())
- rPeer->addKeyListener( this );
- else if( type == cppu::UnoType<css::awt::XFocusListener>::get())
- rPeer->addFocusListener( this );
- else if( type == cppu::UnoType<css::awt::XMouseListener>::get())
- rPeer->addMouseListener( this );
- else if( type == cppu::UnoType<css::awt::XMouseMotionListener>::get())
- rPeer->addMouseMotionListener( this );
- else if( type == cppu::UnoType<css::awt::XPaintListener>::get())
- rPeer->addPaintListener( this );
- else if( type == cppu::UnoType<css::awt::XTopWindowListener>::get())
- {
- Reference< css::awt::XTopWindow > xTop( rPeer, UNO_QUERY );
- if( xTop.is() )
- xTop->addTopWindowListener( this );
- }
- else
- {
- OSL_FAIL( "unknown listener" );
- }
-}
-
-// MRCListenerMultiplexerHelper
-void MRCListenerMultiplexerHelper::unadviseFromPeer( const Reference< css::awt::XWindow > & rPeer, const Type & type )
-{
- // the last listener is removed, remove the listener from the source (peer)
- if( type == cppu::UnoType<css::awt::XWindowListener>::get())
- rPeer->removeWindowListener( this );
- else if( type == cppu::UnoType<css::awt::XKeyListener>::get())
- rPeer->removeKeyListener( this );
- else if( type == cppu::UnoType<css::awt::XFocusListener>::get())
- rPeer->removeFocusListener( this );
- else if( type == cppu::UnoType<css::awt::XMouseListener>::get())
- rPeer->removeMouseListener( this );
- else if( type == cppu::UnoType<css::awt::XMouseMotionListener>::get())
- rPeer->removeMouseMotionListener( this );
- else if( type == cppu::UnoType<css::awt::XPaintListener>::get())
- rPeer->removePaintListener( this );
- else if( type == cppu::UnoType<css::awt::XTopWindowListener>::get())
- {
- Reference< css::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 );
- }
-}
-
-// css::lang::XEventListener
-void MRCListenerMultiplexerHelper::disposing(const css::lang::EventObject& ) throw(std::exception)
-{
- ::osl::Guard< ::osl::Mutex > aGuard( aMutex );
- // peer is disposed, clear the reference
- xPeer.clear();
-}
-
-#define MULTIPLEX( InterfaceName, MethodName, EventName ) \
-::cppu::OInterfaceContainerHelper * pCont; \
-pCont = aListenerHolder.getContainer( cppu::UnoType< InterfaceName >::get()); \
-if( pCont ) \
-{ \
- ::cppu::OInterfaceIteratorHelper aIt( *pCont ); \
- EventName aEvt = e; \
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list