summaryrefslogtreecommitdiff
path: root/desktop/source/so_comp
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/source/so_comp')
-rw-r--r--desktop/source/so_comp/evaluation.cxx205
-rw-r--r--desktop/source/so_comp/evaluation.hxx92
-rw-r--r--desktop/source/so_comp/makefile.mk84
-rw-r--r--desktop/source/so_comp/oemjob.cxx280
-rw-r--r--desktop/source/so_comp/oemjob.hxx92
-rw-r--r--desktop/source/so_comp/services.cxx134
-rw-r--r--desktop/source/so_comp/socomp.component37
7 files changed, 924 insertions, 0 deletions
diff --git a/desktop/source/so_comp/evaluation.cxx b/desktop/source/so_comp/evaluation.cxx
new file mode 100644
index 000000000000..4cbb38931d37
--- /dev/null
+++ b/desktop/source/so_comp/evaluation.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * 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_desktop.hxx"
+
+#include "evaluation.hxx"
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <uno/environment.h>
+#include <cppuhelper/factory.hxx>
+#include <unotools/configmgr.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/resid.hxx>
+#include "../app/desktop.hrc"
+
+
+using namespace rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::registry;
+
+namespace desktop {
+
+static SOEvaluation* pSOEval=0;
+
+const char* SOEvaluation::interfaces[] =
+{
+ "com.sun.star.beans.XExactName",
+ "com.sun.star.beans.XMaterialHolder",
+ "com.sun.star.lang.XComponent",
+ "com.sun.star.lang.XServiceInfo",
+ NULL,
+};
+
+const char* SOEvaluation::implementationName = "com.sun.star.comp.desktop.Evaluation";
+const char* SOEvaluation::serviceName = "com.sun.star.office.Evaluation";
+
+OUString SOEvaluation::GetImplementationName()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationName));
+}
+
+Sequence< OUString > SOEvaluation::GetSupportedServiceNames()
+{
+ sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *)) - 1;
+ Sequence< OUString > aResult( nSize );
+
+ for( sal_Int32 i = 0; i < nSize; i++ )
+ aResult[i] = OUString::createFromAscii( interfaces[i] );
+ return aResult;
+}
+
+Reference< XInterface > SAL_CALL SOEvaluation::CreateInstance(
+ const Reference< XMultiServiceFactory >& rSMgr )
+{
+ static osl::Mutex aMutex;
+ if ( pSOEval == 0 )
+ {
+ osl::MutexGuard guard( aMutex );
+ if ( pSOEval == 0 )
+ return (XComponent*) ( new SOEvaluation( rSMgr ) );
+ }
+ return (XComponent*)0;
+}
+
+SOEvaluation::SOEvaluation( const Reference< XMultiServiceFactory >& xFactory ) :
+ m_aListeners( m_aMutex ),
+ m_xServiceManager( xFactory )
+{
+}
+
+SOEvaluation::~SOEvaluation()
+{
+}
+
+// XComponent
+void SAL_CALL SOEvaluation::dispose() throw ( RuntimeException )
+{
+ EventObject aObject;
+ aObject.Source = (XComponent*)this;
+ m_aListeners.disposeAndClear( aObject );
+}
+
+void SAL_CALL SOEvaluation::addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException )
+{
+ m_aListeners.addInterface( aListener );
+}
+
+void SAL_CALL SOEvaluation::removeEventListener( const Reference< XEventListener > & aListener ) throw ( RuntimeException )
+{
+ m_aListeners.removeInterface( aListener );
+}
+
+// XExactName
+rtl::OUString SAL_CALL SOEvaluation::getExactName( const rtl::OUString& rApproximateName ) throw ( RuntimeException )
+{
+ // get the tabreg service for an evaluation version
+ // without this service office shouldn't run at all
+ OUString aTitle = rApproximateName;
+ OUString aEval;
+ sal_Bool bExpired = sal_True;
+ Reference < XMaterialHolder > xHolder( m_xServiceManager->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.tab.tabreg" ) ) ), UNO_QUERY );
+ if ( xHolder.is() )
+ {
+ // get a sequence of strings for the defined locales
+ // a registered version doesn't provide data
+ bExpired = sal_False;
+ Any aData = xHolder->getMaterial();
+ Sequence < NamedValue > aSeq;
+ if ( aData >>= aSeq )
+ {
+ // this is an evaluation version, because it provides "material"
+ bExpired = sal_True;
+ for (int i=0; i<aSeq.getLength(); i++ )
+ {
+ NamedValue& rValue = aSeq[i];
+ if ( rValue.Name.equalsAscii("expired") )
+ rValue.Value >>= bExpired;
+ else if (rValue.Name.equalsAscii("title") )
+ rValue.Value >>= aEval;
+ }
+ // append eval string to title
+ aTitle += OUString::createFromAscii(" ") + aEval;
+ if ( bExpired )
+ throw RuntimeException();
+ }
+ }
+
+ return aTitle;
+}
+
+// XMaterialHolder
+Any SAL_CALL SOEvaluation::getMaterial() throw( RuntimeException )
+{
+ // Time bomb implementation. Return empty Any to do nothing or
+ // provide a com::sun::star::util::Date with the time bomb date.
+ Any a;
+
+ // change here to force recompile 00002
+#ifdef TIMEBOMB
+ // Code for extracting/providing time bomb date!
+ int nDay = TIMEBOMB % 100;
+ int nMonth = ( TIMEBOMB % 10000 ) / 100;
+ int nYear = TIMEBOMB / 10000;
+ com::sun::star::util::Date aDate( nDay, nMonth, nYear );
+ a <<= aDate;
+#endif
+ return a;
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL SOEvaluation::getImplementationName()
+throw ( RuntimeException )
+{
+ return SOEvaluation::GetImplementationName();
+}
+
+sal_Bool SAL_CALL SOEvaluation::supportsService( const ::rtl::OUString& rServiceName )
+throw ( RuntimeException )
+{
+ sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *))-1;
+
+ for( sal_Int32 i = 0; i < nSize; i++ )
+ if ( rServiceName.equalsAscii( interfaces[i] ))
+ return sal_True;
+ return sal_False;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SOEvaluation::getSupportedServiceNames()
+throw ( RuntimeException )
+{
+ return SOEvaluation::GetSupportedServiceNames();
+}
+
+}
diff --git a/desktop/source/so_comp/evaluation.hxx b/desktop/source/so_comp/evaluation.hxx
new file mode 100644
index 000000000000..a1225029b297
--- /dev/null
+++ b/desktop/source/so_comp/evaluation.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+/* makefile.mk changed 20030409, LO */
+
+#ifndef _SOCOMP_EVALUATION_HXX_
+#define _SOCOMP_EVALUATION_HXX_
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/interfacecontainer.h>
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <osl/mutex.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+namespace desktop {
+
+class SOEvaluation : public ::cppu::WeakImplHelper4< XExactName, XMaterialHolder, XComponent, XServiceInfo >
+{
+ ::osl::Mutex m_aMutex;
+ ::cppu::OInterfaceContainerHelper m_aListeners;
+ Reference< XMultiServiceFactory > m_xServiceManager;
+
+public:
+ SOEvaluation( const Reference < XMultiServiceFactory >& xFactory );
+ virtual ~SOEvaluation();
+
+ static Reference< XSingleServiceFactory > GetSOEvaluationFactory( Reference< XMultiServiceFactory > & xSMgr );
+ static ::rtl::OUString GetImplementationName();
+ static Sequence< rtl::OUString > GetSupportedServiceNames();
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw ( RuntimeException );
+ virtual void SAL_CALL addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException );
+ virtual void SAL_CALL removeEventListener(const Reference< XEventListener > & aListener) throw ( RuntimeException );
+
+ // XExactName
+ virtual rtl::OUString SAL_CALL getExactName( const rtl::OUString& rApproximateName ) throw ( RuntimeException );
+
+ // XMaterialHolder
+ virtual Any SAL_CALL getMaterial() throw ( RuntimeException );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw ( RuntimeException );
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( RuntimeException );
+
+ static const char* interfaces[];
+ static const char* implementationName;
+ static const char* serviceName;
+ static Reference<XInterface> SAL_CALL CreateInstance(
+ const Reference< XMultiServiceFactory >&);
+
+
+
+};
+}
+#endif // _SOCOMP_EVALUATION_HXX_
diff --git a/desktop/source/so_comp/makefile.mk b/desktop/source/so_comp/makefile.mk
new file mode 100644
index 000000000000..7f9ceb4b646a
--- /dev/null
+++ b/desktop/source/so_comp/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# 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=desktop
+TARGET=socomp
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Define time bomb date. Not active for OOo --------------------
+# --- Change something in evaluation.cxx!!! (e.g. line 313)
+# --- You must use the yyyymmdd format!!! --------------------------
+#CDEFS+=-DTIMEBOMB=20050930
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = $(SLO)$/evaluation.obj \
+ $(SLO)$/oemjob.obj \
+ $(SLO)$/services.obj
+
+SHL1DEPN= makefile.mk
+SHL1OBJS= $(SLOFILES)
+
+
+SHL1TARGET= $(TARGET)
+SHL1IMPLIB= i$(TARGET)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS= \
+ $(FWELIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(SVTOOLLIB) \
+ $(COMPHELPERLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/socomp.component
+
+$(MISC)/socomp.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ socomp.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt socomp.component
diff --git a/desktop/source/so_comp/oemjob.cxx b/desktop/source/so_comp/oemjob.cxx
new file mode 100644
index 000000000000..1b78da694ff7
--- /dev/null
+++ b/desktop/source/so_comp/oemjob.cxx
@@ -0,0 +1,280 @@
+/*************************************************************************
+ *
+ * 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_desktop.hxx"
+
+#include "oemjob.hxx"
+#include <rtl/bootstrap.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <osl/file.hxx>
+#include <unotools/bootstrap.hxx>
+#include <tools/config.hxx>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+using namespace rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+
+namespace desktop{
+
+char const OEM_PRELOAD_SECTION[] = "Bootstrap";
+char const OEM_PRELOAD[] = "Preload";
+char const STR_TRUE[] = "1";
+char const STR_FALSE[] = "0";
+
+const char* OEMPreloadJob::interfaces[] =
+{
+ "com.sun.star.task.XJob",
+ NULL,
+};
+const char* OEMPreloadJob::implementationName = "com.sun.star.comp.desktop.OEMPreloadJob";
+const char* OEMPreloadJob::serviceName = "com.sun.star.office.OEMPreloadJob";
+
+OUString OEMPreloadJob::GetImplementationName()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationName));
+}
+
+Sequence< OUString > OEMPreloadJob::GetSupportedServiceNames()
+{
+ sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *)) - 1;
+ Sequence< OUString > aResult( nSize );
+
+ for( sal_Int32 i = 0; i < nSize; i++ )
+ aResult[i] = OUString::createFromAscii( interfaces[i] );
+ return aResult;
+}
+
+Reference< XInterface > SAL_CALL OEMPreloadJob::CreateInstance(
+ const Reference< XMultiServiceFactory >& rSMgr )
+{
+ static osl::Mutex aMutex;
+ osl::MutexGuard guard( aMutex );
+ return (XComponent*) ( new OEMPreloadJob( rSMgr ) );
+}
+
+OEMPreloadJob::OEMPreloadJob( const Reference< XMultiServiceFactory >& xFactory ) :
+ m_aListeners( m_aMutex ),
+ m_xServiceManager( xFactory )
+{
+}
+
+OEMPreloadJob::~OEMPreloadJob()
+{
+}
+
+// XComponent
+void SAL_CALL OEMPreloadJob::dispose() throw ( RuntimeException )
+{
+ EventObject aObject;
+ aObject.Source = (XComponent*)this;
+ m_aListeners.disposeAndClear( aObject );
+}
+
+void SAL_CALL OEMPreloadJob::addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException )
+{
+ m_aListeners.addInterface( aListener );
+}
+
+void SAL_CALL OEMPreloadJob::removeEventListener( const Reference< XEventListener > & aListener ) throw ( RuntimeException )
+{
+ m_aListeners.removeInterface( aListener );
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL OEMPreloadJob::getImplementationName()
+throw ( RuntimeException )
+{
+ return OEMPreloadJob::GetImplementationName();
+}
+
+sal_Bool SAL_CALL OEMPreloadJob::supportsService( const ::rtl::OUString& rServiceName )
+throw ( RuntimeException )
+{
+ sal_Int32 nSize = sizeof( interfaces ) / sizeof( const char *);
+
+ for( sal_Int32 i = 0; i < nSize; i++ )
+ if ( rServiceName.equalsAscii( interfaces[i] ))
+ return sal_True;
+ return sal_False;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL OEMPreloadJob::getSupportedServiceNames()
+throw ( RuntimeException )
+{
+ return OEMPreloadJob::GetSupportedServiceNames();
+}
+
+// XJob
+Any SAL_CALL OEMPreloadJob::execute(const Sequence<NamedValue>&)
+throw ( RuntimeException )
+{
+ sal_Bool bCont = sal_False;
+ // are we an OEM version at all?
+ if (checkOEMPreloadFlag())
+ {
+ // create OEM preload service dialog
+ Reference <XExecutableDialog> xDialog( m_xServiceManager->createInstance(
+ OUString::createFromAscii("org.openoffice.comp.preload.OEMPreloadWizard")),
+ UNO_QUERY );
+ if ( xDialog.is() ){
+ // execute OEM preload dialog and check return value
+ if ( xDialog->execute() == ExecutableDialogResults::OK ) {
+ // user accepted.
+ // make sure the job does not get called again.
+ bCont = sal_True;
+ disableOEMPreloadFlag();
+ } else {
+ // user declined...
+ // terminate.
+ /*
+ Reference< XDesktop > xDesktop( m_xServiceManager->createInstance(
+ OUString::createFromAscii("com.sun.star.frame.Desktop")),
+ UNO_QUERY );
+ xDesktop->terminate();
+ */
+ /*
+ OUString aName;
+ OUString aEnvType;
+ Reference<XFrame> rFrame;
+ Reference<XModel> rModel;
+ Reference<XCloseable> rClose;
+ for (int i=0; i<args.getLength(); i++)
+ {
+ if (args[i].Name.equalsAscii("EnvType"))
+ args[i].Value >>= aEnvType;
+ else if (args[i].Name.equalsAscii("Frame")) {
+ args[i].Value >>= rFrame;
+ rClose = Reference<XCloseable>(rFrame, UNO_QUERY);
+ }
+ else if (args[i].Name.equalsAscii("Model")) {
+ args[i].Value >>= rModel;
+ rClose = Reference<XCloseable>(rModel, UNO_QUERY);
+ }
+ }
+ if (rClose.is()) rClose->close(sal_True);
+ */
+ bCont = sal_False;
+ }
+ }
+ } else {
+ // don't try again
+ bCont = sal_True;
+ }
+ /*
+ NamedValue nv;
+ nv.Name = OUString::createFromAscii("Deactivate");
+ nv.Value <<= bDeactivate;
+ Sequence<NamedValue> s(1);
+ s[0] = nv;
+ */
+ Any r;
+ r <<= bCont;
+ return r;
+}
+
+
+static sal_Bool existsURL( OUString const& _sURL )
+{
+ using namespace osl;
+ DirectoryItem aDirItem;
+
+ if (_sURL.getLength() != 0)
+ return ( DirectoryItem::get( _sURL, aDirItem ) == DirectoryItem::E_None );
+
+ return sal_False;
+}
+
+
+// locate soffice.ini/.rc file
+static OUString locateIniFile()
+{
+ OUString aUserDataPath;
+ OUString aSofficeIniFileURL;
+
+ // Retrieve the default file URL for the soffice.ini/rc
+ Bootstrap().getIniName( aSofficeIniFileURL );
+
+ if ( utl::Bootstrap::locateUserData( aUserDataPath ) == utl::Bootstrap::PATH_EXISTS )
+ {
+ const char CONFIG_DIR[] = "/config";
+
+ sal_Int32 nIndex = aSofficeIniFileURL.lastIndexOf( '/');
+ if ( nIndex > 0 )
+ {
+ OUString aUserSofficeIniFileURL;
+ OUStringBuffer aBuffer( aUserDataPath );
+ aBuffer.appendAscii( CONFIG_DIR );
+ aBuffer.append( aSofficeIniFileURL.copy( nIndex ));
+ aUserSofficeIniFileURL = aBuffer.makeStringAndClear();
+
+ if ( existsURL( aUserSofficeIniFileURL ))
+ return aUserSofficeIniFileURL;
+ }
+ }
+ // Fallback try to use the soffice.ini/rc from program folder
+ return aSofficeIniFileURL;
+}
+
+// check whether the OEMPreload flag was set in soffice.ini/.rc
+sal_Bool OEMPreloadJob::checkOEMPreloadFlag()
+{
+ OUString aSofficeIniFileURL;
+ aSofficeIniFileURL = locateIniFile();
+ Config aConfig(aSofficeIniFileURL);
+ aConfig.SetGroup( OEM_PRELOAD_SECTION );
+ ByteString sResult = aConfig.ReadKey( OEM_PRELOAD );
+ if ( sResult == STR_TRUE )
+ return sal_True;
+ else
+ return sal_False;
+}
+
+void OEMPreloadJob::disableOEMPreloadFlag()
+{
+ OUString aSofficeIniFileURL = locateIniFile();
+ if ( aSofficeIniFileURL.getLength() > 0 )
+ {
+ Config aConfig(aSofficeIniFileURL);
+ aConfig.SetGroup( OEM_PRELOAD_SECTION );
+ aConfig.WriteKey( OEM_PRELOAD, STR_FALSE );
+ aConfig.Flush();
+ }
+}
+
+} // namespace desktop
diff --git a/desktop/source/so_comp/oemjob.hxx b/desktop/source/so_comp/oemjob.hxx
new file mode 100644
index 000000000000..16a111badab9
--- /dev/null
+++ b/desktop/source/so_comp/oemjob.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SOCOMP_OEMJOB_HXX_
+#define _SOCOMP_OEMJOB_HXX_
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/interfacecontainer.h>
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <osl/mutex.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::task;
+
+namespace desktop{
+
+class OEMPreloadJob : public ::cppu::WeakImplHelper3< XJob, XComponent, XServiceInfo >
+{
+
+private:
+ ::osl::Mutex m_aMutex;
+ ::cppu::OInterfaceContainerHelper m_aListeners;
+ Reference< XMultiServiceFactory > m_xServiceManager;
+
+ sal_Bool checkOEMPreloadFlag();
+ void disableOEMPreloadFlag();
+
+public:
+ OEMPreloadJob( const Reference < XMultiServiceFactory >& xFactory );
+ virtual ~OEMPreloadJob();
+
+ static ::rtl::OUString GetImplementationName();
+ static Sequence< rtl::OUString > GetSupportedServiceNames();
+
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw ( RuntimeException );
+ virtual void SAL_CALL addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException );
+ virtual void SAL_CALL removeEventListener(const Reference< XEventListener > & aListener) throw ( RuntimeException );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& rServiceName ) throw ( RuntimeException );
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( RuntimeException );
+
+ //XJob
+ virtual Any SAL_CALL execute(const Sequence<NamedValue>& args)throw ( RuntimeException );
+
+
+ static const char* interfaces[];
+ static const char* implementationName;
+ static const char* serviceName;
+ static Reference<XInterface> SAL_CALL CreateInstance(
+ const Reference< XMultiServiceFactory >&);
+
+
+};
+}
+
+#endif // _SOCOMP_OEMJOB_HXX_
diff --git a/desktop/source/so_comp/services.cxx b/desktop/source/so_comp/services.cxx
new file mode 100644
index 000000000000..e28d762fc69b
--- /dev/null
+++ b/desktop/source/so_comp/services.cxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * 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_desktop.hxx"
+
+#include "evaluation.hxx"
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <uno/environment.h>
+#include <cppuhelper/factory.hxx>
+#include <unotools/configmgr.hxx>
+
+#include "oemjob.hxx"
+#include "evaluation.hxx"
+
+#include <string.h>
+
+using namespace rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::registry;
+using namespace ::desktop;
+
+static const char* pServices[] =
+{
+ SOEvaluation::serviceName,
+ OEMPreloadJob::serviceName,
+ NULL
+};
+
+static const char* pImplementations[] =
+{
+ SOEvaluation::implementationName,
+ OEMPreloadJob::implementationName,
+ NULL
+};
+
+typedef Reference<XInterface>(* fProvider)(const Reference<XMultiServiceFactory>&);
+
+static const fProvider pInstanceProviders[] =
+{
+ SOEvaluation::CreateInstance,
+ OEMPreloadJob::CreateInstance,
+ NULL
+};
+
+
+static const char** pSupportedServices[] =
+{
+ SOEvaluation::interfaces,
+ OEMPreloadJob::interfaces,
+ NULL
+};
+
+static Sequence<OUString>
+getSupportedServiceNames(int p) {
+ const char **names = pSupportedServices[p];
+ Sequence<OUString> aSeq;
+ for(int i = 0; names[i] != NULL; i++) {
+ aSeq.realloc(i+1);
+ aSeq[i] = OUString::createFromAscii(names[i]);
+ }
+ return aSeq;
+}
+
+extern "C"
+{
+void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char** ppEnvironmentTypeName,
+ uno_Environment**)
+{
+ *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+void* SAL_CALL
+component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void*)
+{
+ // Set default return value for this operation - if it failed.
+ if ( pImplementationName && pServiceManager )
+ {
+ Reference< XSingleServiceFactory > xFactory;
+ Reference< XMultiServiceFactory > xServiceManager(
+ reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+
+ // search implementation
+ for (int i = 0; (pImplementations[i]!=NULL); i++) {
+ if ( strcmp(pImplementations[i], pImplementationName ) == 0 ) {
+ // found implementation
+ xFactory = Reference<XSingleServiceFactory>(cppu::createSingleFactory(
+ xServiceManager, OUString::createFromAscii(pImplementationName),
+ pInstanceProviders[i], getSupportedServiceNames(i)));
+ if ( xFactory.is() ) {
+ // Factory is valid - service was found.
+ xFactory->acquire();
+ return xFactory.get();
+ }
+ }
+ } // for()
+ }
+ // Return with result of this operation.
+ return NULL;
+}
+} // extern "C"
diff --git a/desktop/source/so_comp/socomp.component b/desktop/source/so_comp/socomp.component
new file mode 100644
index 000000000000..a53035223c39
--- /dev/null
+++ b/desktop/source/so_comp/socomp.component
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* 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.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.desktop.Evaluation">
+ <service name="com.sun.star.office.Evaluation"/>
+ </implementation>
+ <implementation name="com.sun.star.comp.desktop.OEMPreloadJob">
+ <service name="com.sun.star.office.OEMPreloadJob"/>
+ </implementation>
+</component>