[Libreoffice-commits] .: 9 commits - cppuhelper/Library_cppuhelper.mk cppuhelper/source i18npool/source stoc/source stoc/test stoc/util

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jan 16 02:39:29 PST 2013


 cppuhelper/Library_cppuhelper.mk                |    3 
 cppuhelper/source/compat.cxx                    |   16 
 cppuhelper/source/component_context.cxx         |    9 
 cppuhelper/source/defaultbootstrap.cxx          | 2127 ------------------------
 cppuhelper/source/paths.cxx                     |   57 
 cppuhelper/source/paths.hxx                     |    7 
 cppuhelper/source/servicefactory.cxx            |  336 ---
 cppuhelper/source/servicefactory_detail.hxx     |   56 
 cppuhelper/source/servicemanager.cxx            | 1650 ++++++++++++++++++
 cppuhelper/source/servicemanager.hxx            |  338 +++
 cppuhelper/source/typedescriptionprovider.cxx   |  150 +
 cppuhelper/source/typedescriptionprovider.hxx   |   38 
 i18npool/source/localedata/saxparser.cxx        |   13 
 stoc/source/security/access_controller.cxx      |    4 
 stoc/source/security/file_policy.cxx            |    5 
 stoc/test/security/makefile.mk                  |   49 
 stoc/test/security/test_security.cxx            |  515 -----
 stoc/test/security/test_security.ini            |   24 
 stoc/test/security/test_security.policy         |   37 
 stoc/test/security/test_security_singleuser.ini |   24 
 stoc/util/bootstrap.component                   |    1 
 21 files changed, 2305 insertions(+), 3154 deletions(-)

New commits:
commit 41e2b320209997767497f49f83f9520fb76261ec
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 16 11:34:00 2013 +0100

    Register theTypeDescriptionManager normally in services.rdb
    
    ...no need to handle it specially during bootstrap.
    
    Change-Id: I666dc9c0040a30a7d81ec1815c338be1407281bb

diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 6032acf..e0ff2d8 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -88,12 +88,6 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
             false));
     context_values.push_back( //TODO: from services.rdb?
         cppu::ContextEntry_Init(
-            "/singletons/com.sun.star.reflection.theTypeDescriptionManager",
-            css::uno::makeAny(
-                rtl::OUString("com.sun.star.comp.stoc.TypeDescriptionManager")),
-            true /*TODO: false?*/));
-    context_values.push_back( //TODO: from services.rdb?
-        cppu::ContextEntry_Init(
             "/singletons/com.sun.star.util.theMacroExpander",
             css::uno::makeAny(
                 cppuhelper::detail::create_bootstrap_macro_expander_factory()),
diff --git a/stoc/util/bootstrap.component b/stoc/util/bootstrap.component
index 5ff3b07..d6e9b0c 100644
--- a/stoc/util/bootstrap.component
+++ b/stoc/util/bootstrap.component
@@ -43,6 +43,7 @@
   </implementation>
   <implementation name="com.sun.star.comp.stoc.TypeDescriptionManager">
     <service name="com.sun.star.reflection.TypeDescriptionManager"/>
+    <singleton name="com.sun.star.reflection.theTypeDescriptionManager"/>
   </implementation>
   <implementation name="com.sun.star.security.comp.stoc.AccessController">
     <service name="com.sun.star.security.AccessController"/>
commit dcdda1d61092aad74cd77023be58ef823b424126
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 16 09:31:07 2013 +0100

    Unfold remainder of add_access_control_entries at call site
    
    Change-Id: I6e1a5a0223c1ea3e1a8c8800fb4cb032719ecf4f

diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index acfa4c7..81baa34 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -68,7 +68,6 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
 	cppuhelper/source/paths \
 	cppuhelper/source/propertysetmixin \
 	cppuhelper/source/propshlp \
-	cppuhelper/source/servicefactory \
 	cppuhelper/source/servicemanager \
 	cppuhelper/source/shlib \
 	cppuhelper/source/supportsservice \
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 9b21484..6032acf 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -45,7 +45,6 @@
 
 #include "macro_expander.hxx"
 #include "paths.hxx"
-#include "servicefactory_detail.hxx"
 #include "servicemanager.hxx"
 #include "typedescriptionprovider.hxx"
 
@@ -115,7 +114,16 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
                 "/singletons/" + i->first,
                 css::uno::makeAny(i->second[0]->info->name), true));
     }
-    cppu::add_access_control_entries(&context_values);
+    context_values.push_back(
+        cppu::ContextEntry_Init(
+            "/services/com.sun.star.security.AccessController/mode",
+            css::uno::makeAny(rtl::OUString("off")), false));
+    context_values.push_back(
+        cppu::ContextEntry_Init(
+            "/singletons/com.sun.star.security.theAccessController",
+            css::uno::makeAny(
+                rtl::OUString("com.sun.star.security.AccessController")),
+            true));
     assert(!context_values.empty());
     css::uno::Reference< css::uno::XComponentContext > context(
         createComponentContext(
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
deleted file mode 100644
index b521487..0000000
--- a/cppuhelper/source/servicefactory.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <vector>
-
-#include "rtl/bootstrap.hxx"
-#include "osl/diagnose.h"
-#include "osl/process.h"
-#include "cppuhelper/component_context.hxx"
-
-#include "com/sun/star/uno/SecurityException.hpp"
-
-#include "servicefactory_detail.hxx"
-
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-
-
-using namespace ::rtl;
-using namespace ::osl;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-
-namespace cppu
-{
-
-void add_access_control_entries( ::std::vector< ContextEntry_Init > * values )
-    SAL_THROW( (Exception) )
-{
-    ContextEntry_Init entry;
-    ::std::vector< ContextEntry_Init > & context_values = *values;
-
-    // - ac prop: mode
-    // { "off", "on", "dynamic-only", "single-user", "single-default-user" }
-    entry.bLateInitService = false;
-    entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode");
-    entry.value <<= OUSTR("off");
-    context_values.push_back( entry );
-    // - ac singleton
-    entry.bLateInitService = true;
-    entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController");
-    entry.value <<= OUSTR("com.sun.star.security.AccessController");
-    context_values.push_back( entry );
-}
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/servicefactory_detail.hxx b/cppuhelper/source/servicefactory_detail.hxx
deleted file mode 100644
index d1e8a37..0000000
--- a/cppuhelper/source/servicefactory_detail.hxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_CPPUHELPER_SOURCE_SERVICEFACTORY_DETAIL_HXX
-#define INCLUDED_CPPUHELPER_SOURCE_SERVICEFACTORY_DETAIL_HXX
-
-#include "sal/config.h"
-
-#include <vector>
-
-#include "com/sun/star/uno/Exception.hpp"
-#include "sal/types.h"
-
-namespace cppu { struct ContextEntry_Init; }
-
-namespace cppu {
-
-void add_access_control_entries(std::vector< cppu::ContextEntry_Init > * values)
-    SAL_THROW((com::sun::star::uno::Exception));
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e1e308bc4564f596bde5cd4c96b75d3b8c672e95
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 16 09:04:58 2013 +0100

    Remove support for UNO_AC* bootstrap variables
    
    ...they had effectively never been used.
    
    Change-Id: I514f2b844661e144cef758eb3ce7c4607ffad635

diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index c168aa2..18e150c 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -59,7 +59,6 @@
 #define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager"
 #define TDMGR_SINGLETON "/singletons/com.sun.star.reflection.theTypeDescriptionManager"
 #define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController"
-#define AC_POLICY "/singletons/com.sun.star.security.thePolicy"
 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
 
 
@@ -694,7 +693,7 @@ void ComponentContext::disposing()
     ::fprintf( stderr, "> disposing context %p\n", this );
 #endif
 
-    Reference< lang::XComponent > xTDMgr, xAC, xPolicy; // to be disposed separately
+    Reference< lang::XComponent > xTDMgr, xAC; // to be disposed separately
 
     // dispose all context objects
     t_map::const_iterator iPos( m_map.begin() );
@@ -731,10 +730,6 @@ void ComponentContext::disposing()
                 {
                     xAC = xComp;
                 }
-                else if ( iPos->first == AC_POLICY )
-                {
-                    xPolicy = xComp;
-                }
                 else // dispose immediately
                 {
                     xComp->dispose();
@@ -748,8 +743,6 @@ void ComponentContext::disposing()
     m_xSMgr.clear();
     // dispose ac
     try_dispose( xAC );
-    // dispose policy
-    try_dispose( xPolicy );
     // dispose tdmgr; revokes callback from cppu runtime
     try_dispose( xTDMgr );
 
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index d4863b3..9b21484 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -115,7 +115,7 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
                 "/singletons/" + i->first,
                 css::uno::makeAny(i->second[0]->info->name), true));
     }
-    cppu::add_access_control_entries(&context_values, bs);
+    cppu::add_access_control_entries(&context_values);
     assert(!context_values.empty());
     css::uno::Reference< css::uno::XComponentContext > context(
         createComponentContext(
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
index 268ddaa..b521487 100644
--- a/cppuhelper/source/servicefactory.cxx
+++ b/cppuhelper/source/servicefactory.cxx
@@ -40,151 +40,22 @@ using namespace ::com::sun::star::uno;
 namespace cppu
 {
 
-/** bootstrap variables:
-
-    UNO_AC=<mode> [mandatory]
-      -- mode := { on, off, dynamic-only, single-user, single-default-user }
-    UNO_AC_SERVICE=<service_name> [optional]
-      -- override ac singleton service name
-    UNO_AC_SINGLEUSER=<user-id|nothing> [optional]
-      -- run with this user id or with default user policy (<nothing>)
-         set UNO_AC=single-[default-]user
-    UNO_AC_USERCACHE_SIZE=<cache_size>
-      -- number of user permission sets to be cached
-
-    UNO_AC_POLICYSERVICE=<service_name> [optional]
-      -- override policy singleton service name
-    UNO_AC_POLICYFILE=<file_url> [optional]
-      -- read policy out of simple text file
-*/
-void add_access_control_entries(
-    ::std::vector< ContextEntry_Init > * values,
-    Bootstrap const & bootstrap )
+void add_access_control_entries( ::std::vector< ContextEntry_Init > * values )
     SAL_THROW( (Exception) )
 {
     ContextEntry_Init entry;
     ::std::vector< ContextEntry_Init > & context_values = *values;
 
-    OUString ac_policy;
-    if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYSERVICE"), ac_policy ))
-    {
-        // overridden service name
-        // - policy singleton
-        entry.bLateInitService = true;
-        entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy");
-        entry.value <<= ac_policy;
-        context_values.push_back( entry );
-    }
-    else if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYFILE"), ac_policy ))
-    {
-        // check for file policy
-        // - file policy prop: file-name
-        if (0 != ac_policy.compareToAscii(
-                RTL_CONSTASCII_STRINGPARAM("file:///") ))
-        {
-            // no file url
-            OUString baseDir;
-            if ( ::osl_getProcessWorkingDir( &baseDir.pData )
-                 != osl_Process_E_None )
-            {
-                OSL_ASSERT( false );
-            }
-            OUString fileURL;
-            if ( ::osl_getAbsoluteFileURL(
-                     baseDir.pData, ac_policy.pData, &fileURL.pData )
-                 != osl_File_E_None )
-            {
-                OSL_ASSERT( false );
-            }
-            ac_policy = fileURL;
-        }
-
-        entry.bLateInitService = false;
-        entry.name =
-            OUSTR("/implementations/com.sun.star.security.comp.stoc.FilePolicy/"
-                  "file-name");
-        entry.value <<= ac_policy;
-        context_values.push_back( entry );
-        // - policy singleton
-        entry.bLateInitService = true;
-        entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy");
-        entry.value <<= OUSTR("com.sun.star.security.comp.stoc.FilePolicy");
-        context_values.push_back( entry );
-    } // else policy singleton comes from storage
-
-    OUString ac_mode;
-    if (! bootstrap.getFrom( OUSTR("UNO_AC"), ac_mode ))
-    {
-        ac_mode = OUSTR("off"); // default
-    }
-    OUString ac_user;
-    if (bootstrap.getFrom( OUSTR("UNO_AC_SINGLEUSER"), ac_user ))
-    {
-        // ac in single-user mode
-        if (!ac_user.isEmpty())
-        {
-            // - ac prop: single-user-id
-            entry.bLateInitService = false;
-            entry.name =
-                OUSTR("/services/com.sun.star.security.AccessController/"
-                      "single-user-id");
-            entry.value <<= ac_user;
-            context_values.push_back( entry );
-            if ( ac_mode != "single-user" )
-            {
-                throw SecurityException(
-                    OUSTR("set UNO_AC=single-user "
-                          "if you set UNO_AC_SINGLEUSER=<user-id>!"),
-                    Reference< XInterface >() );
-            }
-        }
-        else
-        {
-            if ( ac_mode != "single-default-user" )
-            {
-                throw SecurityException(
-                    OUSTR("set UNO_AC=single-default-user "
-                          "if you set UNO_AC_SINGLEUSER=<nothing>!"),
-                    Reference< XInterface >() );
-            }
-        }
-    }
-
-    OUString ac_service;
-    if (! bootstrap.getFrom( OUSTR("UNO_AC_SERVICE"), ac_service ))
-    {
-        // override service name
-        ac_service = OUSTR("com.sun.star.security.AccessController"); // default
-//          ac = OUSTR("com.sun.star.security.comp.stoc.AccessController");
-    }
-
-    // - ac prop: user-cache-size
-    OUString ac_cache;
-    if (bootstrap.getFrom( OUSTR("UNO_AC_USERCACHE_SIZE"), ac_cache ))
-    {
-        // ac cache size
-        sal_Int32 n = ac_cache.toInt32();
-        if (0 < n)
-        {
-            entry.bLateInitService = false;
-            entry.name =
-                OUSTR("/services/com.sun.star.security.AccessController/"
-                      "user-cache-size");
-            entry.value <<= n;
-            context_values.push_back( entry );
-        }
-    }
-
     // - ac prop: mode
     // { "off", "on", "dynamic-only", "single-user", "single-default-user" }
     entry.bLateInitService = false;
     entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode");
-    entry.value <<= ac_mode;
+    entry.value <<= OUSTR("off");
     context_values.push_back( entry );
     // - ac singleton
     entry.bLateInitService = true;
     entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController");
-    entry.value <<= ac_service;
+    entry.value <<= OUSTR("com.sun.star.security.AccessController");
     context_values.push_back( entry );
 }
 
diff --git a/cppuhelper/source/servicefactory_detail.hxx b/cppuhelper/source/servicefactory_detail.hxx
index 09c3997..d1e8a37 100644
--- a/cppuhelper/source/servicefactory_detail.hxx
+++ b/cppuhelper/source/servicefactory_detail.hxx
@@ -28,13 +28,10 @@
 #include "sal/types.h"
 
 namespace cppu { struct ContextEntry_Init; }
-namespace rtl { class Bootstrap; }
 
 namespace cppu {
 
-void add_access_control_entries(
-    std::vector< cppu::ContextEntry_Init > * values,
-    rtl::Bootstrap const & bootstrap)
+void add_access_control_entries(std::vector< cppu::ContextEntry_Init > * values)
     SAL_THROW((com::sun::star::uno::Exception));
 
 }
diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx
index ae72ae8..09ffc70 100644
--- a/stoc/source/security/access_controller.cxx
+++ b/stoc/source/security/access_controller.cxx
@@ -472,6 +472,10 @@ AccessController::AccessController( Reference< XComponentContext > const & xComp
 {
     g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
 
+    // The .../mode value had originally been set in
+    // cppu::add_access_control_entries (cppuhelper/source/servicefactory.cxx)
+    // to something other than "off" depending on various UNO_AC* bootstrap
+    // variables that are no longer supported, so this is mostly dead code now:
     OUString mode;
     if (m_xComponentContext->getValueByName( OUSTR("/services/" SERVICE_NAME "/mode") ) >>= mode)
     {
diff --git a/stoc/source/security/file_policy.cxx b/stoc/source/security/file_policy.cxx
index 7864776..d7fa8c4 100644
--- a/stoc/source/security/file_policy.cxx
+++ b/stoc/source/security/file_policy.cxx
@@ -438,7 +438,10 @@ PolicyReader::~PolicyReader()
 void FilePolicy::refresh()
     throw (RuntimeException)
 {
-    // read out file
+    // read out file (the .../file-name value had originally been set in
+    // cppu::add_access_control_entries (cppuhelper/source/servicefactory.cxx)
+    // depending on various UNO_AC* bootstrap variables that are no longer
+    // supported, so this is effectively dead code):
     OUString fileName;
     m_xComponentContext->getValueByName(
         OUSTR("/implementations/" IMPL_NAME "/file-name") ) >>= fileName;
diff --git a/stoc/test/security/makefile.mk b/stoc/test/security/makefile.mk
deleted file mode 100644
index c71f91b..0000000
--- a/stoc/test/security/makefile.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# 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/.
-#
-# This file incorporates work covered by the following license notice:
-#
-#   Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements. See the NOTICE file distributed
-#   with this work for additional information regarding copyright
-#   ownership. The ASF licenses this file to you under the Apache
-#   License, Version 2.0 (the "License"); you may not use this file
-#   except in compliance with the License. You may obtain a copy of
-#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-PRJ=..$/..
-
-PRJNAME=stoc
-TARGET=test_security
-TARGETTYPE=CUI
-LIBTARGET=NO
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE :  settings.mk
-
-# --- Application 1 ------------------------------------------------
-APP1TARGET= $(TARGET)
-APP1OBJS=   $(OBJ)$/test_security.obj 
-
-APP1STDLIBS= \
-        $(CPPULIB) 		\
-        $(CPPUHELPERLIB) 	\
-        $(SALHELPERLIB) 	\
-        $(SALLIB)
-
-.IF "$(OS)"=="WNT"
-APP1STDLIBS+= 
-#		$(LIBCIMT) $(LIBCMT)
-.ENDIF
-
-
-# --- Target ------------------------------------------------
-
-.INCLUDE :	target.mk
-
diff --git a/stoc/test/security/test_security.cxx b/stoc/test/security/test_security.cxx
deleted file mode 100644
index a094b21..0000000
--- a/stoc/test/security/test_security.cxx
+++ /dev/null
@@ -1,515 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <stdio.h>
-
-#include <sal/main.h>
-#include <osl/diagnose.h>
-#include <osl/socket.hxx>
-#include <rtl/string.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <uno/current_context.hxx>
-
-#include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/bootstrap.hxx>
-#include <cppuhelper/access_control.hxx>
-
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/uno/XCurrentContext.hpp>
-
-#include <com/sun/star/io/FilePermission.hpp>
-
-#define USER_CREDS "access-control.user-credentials"
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-
-
-using namespace ::osl;
-using namespace ::rtl;
-using namespace ::cppu;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-
-//--------------------------------------------------------------------------------------------------
-static OUString localhost( OUString const & addition ) SAL_THROW(())
-{
-    static OUString ip;
-    if (! ip.getLength())
-    {
-        // dns lookup
-        SocketAddr addr;
-        SocketAddr::resolveHostname( OUSTR("localhost"), addr );
-        ::oslSocketResult rc = ::osl_getDottedInetAddrOfSocketAddr( addr.getHandle(), &ip.pData );
-        if (::osl_Socket_Ok != rc)
-            fprintf(stdout, "### cannot resolve localhost!" );
-    }
-    OUStringBuffer buf( 48 );
-    buf.append( ip );
-    buf.append( addition );
-    return buf.makeStringAndClear();
-}
-
-//--------------------------------------------------------------------------------------------------
-static inline void dispose( Reference< XInterface > const & x )
-    SAL_THROW( (RuntimeException) )
-{
-    Reference< lang::XComponent > xComp( x, UNO_QUERY );
-    if (xComp.is())
-    {
-        xComp->dispose();
-    }
-}
-//==================================================================================================
-class user_CurrentContext
-    : public ImplHelper1< XCurrentContext >
-{
-    oslInterlockedCount m_refcount;
-
-    Reference< XCurrentContext > m_xDelegate;
-    Any m_userId;
-
-public:
-    inline user_CurrentContext(
-        Reference< XCurrentContext > const & xDelegate,
-        OUString const & userId )
-        SAL_THROW(())
-        : m_refcount( 0 )
-        , m_xDelegate( xDelegate )
-        , m_userId( makeAny( userId ) )
-        {}
-
-    // XInterface impl
-    virtual void SAL_CALL acquire()
-        throw ();
-    virtual void SAL_CALL release()
-        throw ();
-
-    // XCurrentContext impl
-    virtual Any SAL_CALL getValueByName( OUString const & name )
-        throw (RuntimeException);
-};
-//__________________________________________________________________________________________________
-void user_CurrentContext::acquire()
-    throw ()
-{
-    ::osl_atomic_increment( &m_refcount );
-}
-//__________________________________________________________________________________________________
-void user_CurrentContext::release()
-    throw ()
-{
-    if (! ::osl_atomic_decrement( &m_refcount ))
-    {
-        delete this;
-    }
-}
-//__________________________________________________________________________________________________
-Any user_CurrentContext::getValueByName( OUString const & name )
-    throw (RuntimeException)
-{
-    if ( name == USER_CREDS ".id" )
-    {
-        return m_userId;
-    }
-    else if (m_xDelegate.is())
-    {
-        return m_xDelegate->getValueByName( name );
-    }
-    else
-    {
-        return Any();
-    }
-}
-
-// prepends line number
-#define CHECK( check, negative_test ) \
-{ \
-    try \
-    { \
-        if (negative_test) \
-        { \
-            bool thrown = true; \
-            try \
-            { \
-                check; \
-                thrown = false; \
-            } \
-            catch (RuntimeException &) \
-            { \
-            } \
-            if (! thrown) \
-            { \
-                throw RuntimeException( \
-                    OUSTR("expected RuntimeException upon check!"), Reference< XInterface >() ); \
-            } \
-        } \
-        else \
-        { \
-            check; \
-        } \
-    } \
-    catch (const RuntimeException & exc) \
-    { \
-        OUStringBuffer buf( 64 ); \
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("[line ") ); \
-        buf.append( (sal_Int32)__LINE__ ); \
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ") ); \
-        buf.append( exc.Message ); \
-        throw RuntimeException( buf.makeStringAndClear(), Reference< XInterface >() ); \
-    } \
-}
-
-/*
-grant
-{
-permission com.sun.star.io.FilePermission "file:///usr/bin/ *", "read";
-permission com.sun.star.io.FilePermission "file:///tmp/-", "read,write";
-permission com.sun.star.io.FilePermission "file:///etc/profile", "read";
-
-permission com.sun.star.security.RuntimePermission "DEF";
-
-permission com.sun.star.connection.SocketPermission "127.0.0.1:-1023", "resolve, connect, listen";
-permission com.sun.star.connection.SocketPermission "localhost:1024-", "accept, connect, listen, resolve,";
-permission com.sun.star.connection.SocketPermission "*.sun.com:1024-", "resolve";
-};
-*/
-static void check_defaults_pos( AccessControl & ac, bool invert = false )
-{
-    // positive tests
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/bla"), OUSTR("read") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///tmp/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///tmp/path/path/bla"), OUSTR("write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///etc/profile"), OUSTR("read") ), invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("DEF") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("localhost:1024"), OUSTR("connect") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("localhost:65535"), OUSTR("resolve") ), invert );
-    CHECK( ac.checkSocketPermission( localhost(OUSTR(":2048")), OUSTR("accept,listen") ), invert );
-    CHECK( ac.checkSocketPermission( localhost(OUSTR(":1024-")), OUSTR("accept,connect,listen,resolve") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("localhost:-1023"), OUSTR("resolve,listen,connect") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("jl-1036.germany.sun.com:1024-"), OUSTR("resolve") ), invert );
-}
-static void check_defaults_neg( AccessControl & ac, bool invert = false )
-{
-    // negative tests
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/tmp"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/bla"), OUSTR("write") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/bla"), OUSTR("execute") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/bin/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///tmp"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///tmp/"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///tm"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///etc/profile"), OUSTR("write") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///etc/profile/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///etc/blabla"), OUSTR("read,write,execute") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/root"), OUSTR("read,write,execute") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUSTR("read,write,execute") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUSTR("delete") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUString() ), !invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("ROOT") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("localhost:1023"), OUSTR("accept") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("localhost:123-"), OUSTR("accept") ), !invert );
-    CHECK( ac.checkSocketPermission( localhost(OUSTR(":-1023")), OUSTR("accept") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("localhost:-1023"), OUSTR("accept,resolve") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("sun.com:1024-"), OUSTR("resolve") ), !invert );
-}
-
-/*
-grant user "dbo"
-{
-permission com.sun.star.io.FilePermission "file:///home/dbo/-", "read,write";
-permission com.sun.star.io.FilePermission "-", "read,write";
-permission com.sun.star.io.FilePermission "file:///usr/local/dbo/ *", "read";
-
-permission com.sun.star.security.RuntimePermission "DBO";
-
-permission com.sun.star.connection.SocketPermission "dbo-1:1024-", "listen";
-permission com.sun.star.connection.SocketPermission "dbo-11081:-1023", "resolve";
-permission com.sun.star.connection.SocketPermission "dbo-11081:18", "listen";
-permission com.sun.star.connection.SocketPermission "dbo-11081:20-24", "listen";
-permission com.sun.star.connection.SocketPermission "dbo-11081", "connect";
-};
-*/
-static void check_dbo_pos( AccessControl & ac, bool invert = false )
-{
-    check_defaults_pos( ac, invert );
-    // positive tests
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/path/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/*"), OUSTR("read") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/bla"), OUSTR("read") ), invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("DBO") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-1:1024-"), OUSTR("listen") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-1:2048-3122"), OUSTR("listen") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-1:2048-"), OUSTR("listen") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:-1023"), OUSTR("resolve") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:20-1023"), OUSTR("resolve") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:18"), OUSTR("listen") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:20-24"), OUSTR("listen") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:22"), OUSTR("listen") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081"), OUSTR("connect") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:22"), OUSTR("connect") ), invert );
-}
-static void check_dbo_neg( AccessControl & ac, bool invert = false )
-{
-    check_defaults_neg( ac, invert );
-    // negative tests
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/-"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("write") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read,write") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/path/bla"), OUSTR("read,execute") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/-"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/path/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("JBU") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081"), OUSTR("listen") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081:22"), OUSTR("accept") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("jbu-11096:22"), OUSTR("resolve") ), !invert );
-}
-
-/*
-grant user "jbu"
-{
-permission com.sun.star.io.FilePermission  "file:///home/jbu/-", "read,write";
-permission com.sun.star.io.FilePermission "*", "read,write";
-
-permission com.sun.star.security.RuntimePermission "JBU";
-
-permission com.sun.star.connection.SocketPermission "jbu-11096","resolve";
-};
-*/
-static void check_jbu_pos( AccessControl & ac, bool invert = false )
-{
-    check_defaults_pos( ac, invert );
-    // positive tests
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/path/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/jbu/path/path/bla"), OUSTR("read,write") ), invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("JBU") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("jbu-11096"), OUSTR("resolve") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("jbu-11096:20-24"), OUSTR("resolve") ), invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081.germany.sun.com:2048"), OUSTR("resolve") ), invert );
-}
-static void check_jbu_neg( AccessControl & ac, bool invert = false )
-{
-    check_defaults_neg( ac, invert );
-    // negative tests
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/-"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/path/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("write") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/-"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///usr/local/dbo/path/path/bla"), OUSTR("read") ), !invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("DBO") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("jbu-11096:20-24"), OUSTR("accept") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081"), OUSTR("connect") ), !invert );
-    CHECK( ac.checkSocketPermission( OUSTR("dbo-11081.germany.sun.com"), OUSTR("connect") ), !invert );
-}
-
-/*
-grant principal "root"
-{
-permission com.sun.star.security.AllPermission;
-};
-*/
-//==================================================================================================
-static void check_root_pos( AccessControl & ac, bool invert = false )
-{
-    check_defaults_pos( ac, invert );
-    check_defaults_neg( ac, !invert );
-    check_dbo_pos( ac, invert );
-    check_dbo_neg( ac, !invert );
-    check_jbu_pos( ac, invert );
-    check_jbu_neg( ac, !invert );
-    // some more root positive
-    CHECK( ac.checkFilePermission( OUSTR("file:///etc/blabla"), OUSTR("read,write,execute") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///home/root"), OUSTR("read,write,execute") ), invert );
-    CHECK( ac.checkFilePermission( OUSTR("file:///root"), OUSTR("read,write,execute") ), invert );
-    CHECK( ac.checkRuntimePermission( OUSTR("ROOT") ), invert );
-}
-
-//==================================================================================================
-class acc_Restr
-    : public WeakImplHelper1< security::XAccessControlContext >
-{
-    Any m_perm;
-
-public:
-    inline acc_Restr( Any const & perm = Any() ) SAL_THROW(())
-        : m_perm( perm )
-        {}
-
-    // XAccessControlContext impl
-    virtual void SAL_CALL checkPermission( Any const & perm )
-        throw (RuntimeException);
-};
-//__________________________________________________________________________________________________
-void acc_Restr::checkPermission( Any const & perm )
-    throw (RuntimeException)
-{
-    if (perm != m_perm)
-    {
-        throw security::AccessControlException(
-            OUSTR("dyn violation!"), Reference< XInterface >(), perm );
-    }
-}
-
-typedef void (* t_action)( AccessControl &, Any const & arg );
-
-//==================================================================================================
-class Action
-    : public WeakImplHelper1< security::XAction >
-{
-    t_action m_action;
-    AccessControl & m_ac;
-    Any m_arg;
-
-public:
-    inline Action( t_action action, AccessControl & ac, Any const & arg = Any() ) SAL_THROW(())
-        : m_action( action )
-        , m_ac( ac )
-        , m_arg( arg )
-        {}
-
-    // XAction impl
-    virtual Any SAL_CALL run()
-        throw (Exception);
-};
-//__________________________________________________________________________________________________
-Any Action::run()
-    throw (Exception)
-{
-    (*m_action)( m_ac, m_arg );
-    return Any();
-}
-
-//==================================================================================================
-// static void restr_file_permissions( AccessControl & ac )
-// {
-//     // running in dbo's domain
-//     /* permission com.sun.star.io.FilePermission "file:///home/dbo/-", ",,read , write "; */
-//     CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write,execute") ), true );
-//     CHECK( ac.checkFilePermission( OUSTR("file:///home/dbo/bla"), OUSTR("read,write") ), false );
-// }
-//==================================================================================================
-static void all_dbo_permissions( AccessControl & ac, Any const & )
-{
-    check_dbo_pos( ac );
-    check_dbo_neg( ac );
-}
-//==================================================================================================
-static void no_permissions( AccessControl & ac, Any const & arg )
-{
-    check_dbo_pos( ac, true );
-    check_dbo_neg( ac );
-    // set privs to old dbo restr
-    Reference< security::XAccessControlContext > xContext;
-    OSL_VERIFY( arg >>= xContext );
-    ac->doPrivileged(
-        new Action( all_dbo_permissions, ac ),
-        xContext );
-}
-//==================================================================================================
-static void check_dbo_dynamic( AccessControl & ac )
-{
-    Any arg( makeAny( ac->getContext() ) );
-    ac->doRestricted(
-        new Action( no_permissions, ac, arg ),
-        new acc_Restr() );
-}
-
-SAL_IMPLEMENT_MAIN()
-{
-    try
-    {
-        // single-user test
-        Reference< XComponentContext > xContext( defaultBootstrap_InitialComponentContext(
-            OUSTR("../../test/security/test_security_singleuser.ini") ) );
-        {
-        ::fprintf( stderr, "[security test] single-user checking dbo..." );
-        AccessControl ac( xContext );
-        check_dbo_pos( ac );
-        check_dbo_neg( ac );
-        check_dbo_dynamic( ac );
-        ::fprintf( stderr, "dbo checked.\n" );
-        }
-
-        // multi-user test
-        dispose( xContext );
-        xContext = defaultBootstrap_InitialComponentContext(
-            OUSTR("../../test/security/test_security.ini") ); // UNO_AC=on
-        AccessControl ac( xContext );
-
-        {
-        // set up dbo current context
-        ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("dbo") ) );
-        ::fprintf( stderr, "[security test] multi-user checking dbo..." );
-        check_dbo_pos( ac );
-        check_dbo_neg( ac );
-        check_dbo_dynamic( ac );
-        ::fprintf( stderr, "dbo checked.\n" );
-        }
-        {
-        // set up jbu current context
-        ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("jbu") ) );
-        ::fprintf( stderr, "[security test] multi-user checking jbu..." );
-        check_jbu_pos( ac );
-        check_jbu_neg( ac );
-        ::fprintf( stderr, "jbu checked.\n" );
-        }
-        {
-        // set up root current context
-        ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("root") ) );
-        ::fprintf( stderr, "[security test] multi-user checking root..." );
-        check_root_pos( ac );
-        ::fprintf( stderr, "root checked.\n" );
-        }
-        {
-        // set up unknown guest user current context => default permissions
-        ContextLayer layer( new user_CurrentContext( getCurrentContext(), OUSTR("guest") ) );
-        ::fprintf( stderr, "[security test] multi-user checking guest..." );
-        check_defaults_pos( ac );
-        check_defaults_neg( ac );
-        ::fprintf( stderr, "guest checked.\n" );
-        }
-
-        dispose( xContext );
-        ::fprintf( stderr, "security test succeeded.\n" );
-        return 0;
-    }
-    catch (const Exception & exc)
-    {
-        OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
-        ::fprintf( stderr, "[security test] error: %s!\n", str.getStr() );
-        return 1;
-    }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/stoc/test/security/test_security.ini b/stoc/test/security/test_security.ini
deleted file mode 100644
index 037ff00..0000000
--- a/stoc/test/security/test_security.ini
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# 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/.
-#
-# This file incorporates work covered by the following license notice:
-#
-#   Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements. See the NOTICE file distributed
-#   with this work for additional information regarding copyright
-#   ownership. The ASF licenses this file to you under the Apache
-#   License, Version 2.0 (the "License"); you may not use this file
-#   except in compliance with the License. You may obtain a copy of
-#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-UNO_TYPES=stoctest.rdb
-UNO_SERVICES=stoctest.rdb
-UNO_WRITERDB=stoctest.rdb
-UNO_AC=on
-UNO_AC_POLICYFILE=../../test/security/test_security.policy
-UNO_AC_USERCACHE_SIZE=2
diff --git a/stoc/test/security/test_security.policy b/stoc/test/security/test_security.policy
deleted file mode 100644
index 93c2571..0000000
--- a/stoc/test/security/test_security.policy
+++ /dev/null
@@ -1,37 +0,0 @@
-/** dbo
-    permissions
-*/
-grant user "dbo"{
-      permission com.sun.star.io.FilePermission "file:///home/dbo/-", ",,read , write ";
-      permission com.sun.star.io.FilePermission "-", "read ,write";
-      permission com.sun.star.connection.SocketPermission "dbo-1:1024-", "listen";
-	permission com.sun.star.security.RuntimePermission "DBO";
-      permission com.sun.star.connection.SocketPermission "dbo-11081:-1023", "resolve";
-      permission com.sun.star.connection.SocketPermission "dbo-11081:18", "listen";
-      permission com.sun.star.connection.SocketPermission "dbo-11081:20-24", "listen";
-      permission com.sun.star.connection.SocketPermission "dbo-11081", "connect";
-      permission com.sun.star.io.FilePermission "file:///usr/local/dbo/*" , "read ";};
-grant user "jbu" {
-permission com.sun.star.security.RuntimePermission "JBU";
-permission com.sun.star.io.FilePermission  "file:///home/jbu/-" ,"read,write,";
-/*jbu resolve*/permission com.sun.star.connection.SocketPermission "jbu-11096","resolve";
- permission com.sun.star.io.FilePermission "*",",read,write";};	grant user "root"{permission com.sun.star.security.AllPermission;};
-
-// granted to anyone
- grant
-{
-	// read out this file
-	permission com.sun.star.io.FilePermission "../../test/security/test_security.policy",
-						  "read";
-
-	permission com.sun.star.security.RuntimePermission "DEF";
-	permission com.sun.star.io.FilePermission "file:///usr/bin/*", "read";
-	permission com.sun.star.io.FilePermission "file:///usr/bin/*", "read";
-	permission com.sun.star.io.FilePermission "file:///tmp/-", "read, write";
-	permission com.sun.star.io.FilePermission "file:///etc/profile", "read,,";
-	permission com.sun.star.connection.SocketPermission "127.0.0.1:-1023", "resolve, connect, listen";
-	permission com.sun.star.connection.SocketPermission "localhost:1024-", "accept, connect, listen, resolve,";
-	permission com.sun.star.connection.SocketPermission "*.sun.com:1024-", "resolve";
- } ;
-
-# eof
\ No newline at end of file
diff --git a/stoc/test/security/test_security_singleuser.ini b/stoc/test/security/test_security_singleuser.ini
deleted file mode 100644
index 018b598..0000000
--- a/stoc/test/security/test_security_singleuser.ini
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# 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/.
-#
-# This file incorporates work covered by the following license notice:
-#
-#   Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements. See the NOTICE file distributed
-#   with this work for additional information regarding copyright
-#   ownership. The ASF licenses this file to you under the Apache
-#   License, Version 2.0 (the "License"); you may not use this file
-#   except in compliance with the License. You may obtain a copy of
-#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-UNO_TYPES=stoctest.rdb
-UNO_SERVICES=stoctest.rdb
-UNO_WRITERDB=stoctest.rdb
-UNO_AC=single-user
-UNO_AC_SINGLEUSER=dbo
-UNO_AC_POLICYFILE=../../test/security/test_security.policy
commit fb8f3fac70ecfcc2b8612dbf71308cbea39ca789
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 15 18:18:43 2013 +0100

    get_this_libpath only used in paths.cxx
    
    Change-Id: I60bbb6fce36d20d476adc963ad2182f71e9c19c7

diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx
index c5ce22b..5f60ab8 100644
--- a/cppuhelper/source/paths.cxx
+++ b/cppuhelper/source/paths.cxx
@@ -32,7 +32,9 @@
 
 #include "paths.hxx"
 
-rtl::OUString cppu::get_this_libpath() {
+namespace {
+
+rtl::OUString get_this_libpath() {
     static rtl::OUString s_uri;
     if (s_uri.isEmpty()) {
         rtl::OUString uri;
@@ -53,6 +55,8 @@ rtl::OUString cppu::get_this_libpath() {
     return s_uri;
 }
 
+}
+
 rtl::OUString cppu::getUnoIniUri() {
 #if defined ANDROID
     // Wouldn't it be lovely to avoid this fugly hard-coding.
diff --git a/cppuhelper/source/paths.hxx b/cppuhelper/source/paths.hxx
index bba0833..37772d5 100644
--- a/cppuhelper/source/paths.hxx
+++ b/cppuhelper/source/paths.hxx
@@ -27,8 +27,6 @@ namespace rtl { class OUString; }
 
 namespace cppu {
 
-rtl::OUString get_this_libpath();
-
 rtl::OUString getUnoIniUri();
 
 bool nextDirectoryItem(osl::Directory & directory, rtl::OUString * url);
commit 9e2972dbf1a9526f30ffd3e001a6eaf473d76ae9
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 15 18:16:01 2013 +0100

    API CHANGE: Remove obsolete cppu::bootstrapInitialSF
    
    An aborting stub is left in cppuhelper/source/compat.cxx to avoid having to
    incompatibly change cppuhelper/source/gcc3.map.
    
    Change-Id: I28359397fa9c06ac955ee646b5ad3486e9200a10

diff --git a/cppuhelper/source/compat.cxx b/cppuhelper/source/compat.cxx
index a90d7e5..ab57a2a 100644
--- a/cppuhelper/source/compat.cxx
+++ b/cppuhelper/source/compat.cxx
@@ -27,7 +27,10 @@
 #include "sal/types.h"
 
 namespace com { namespace sun { namespace star {
-    namespace lang { class XMultiServiceFactory; }
+    namespace lang {
+        class XMultiComponentFactory;
+        class XMultiServiceFactory;
+    }
     namespace reflection { class XIdlClass; }
     namespace registry { class XSimpleRegistry; }
     namespace uno { class XComponentContext; }
@@ -36,6 +39,17 @@ namespace rtl { class OUString; }
 
 // Stubs for removed functionality, to be killed when we bump cppuhelper SONAME
 
+namespace cppu {
+
+SAL_DLLPUBLIC_EXPORT
+css::uno::Reference< css::lang::XMultiComponentFactory > bootstrapInitialSF(
+    rtl::OUString const &) SAL_THROW((com::sun::star::uno::Exception))
+{
+    for (;;) { std::abort(); } // avoid "must return a value" warnings
+}
+
+}
+
 SAL_DLLPUBLIC_EXPORT css::uno::Reference< css::uno::XComponentContext > SAL_CALL
 bootstrap_InitialComponentContext(
     css::uno::Reference< css::registry::XSimpleRegistry > const &,
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
index ac7e93f..268ddaa 100644
--- a/cppuhelper/source/servicefactory.cxx
+++ b/cppuhelper/source/servicefactory.cxx
@@ -20,35 +20,13 @@
 
 #include <vector>
 
-#include "rtl/string.hxx"
 #include "rtl/bootstrap.hxx"
-#include "rtl/strbuf.hxx"
 #include "osl/diagnose.h"
-#include "osl/file.h"
-#include "osl/module.h"
 #include "osl/process.h"
-#include "cppuhelper/shlib.hxx"
-#include "cppuhelper/factory.hxx"
 #include "cppuhelper/component_context.hxx"
-#include "cppuhelper/bootstrap.hxx"
 
-#include "com/sun/star/uno/DeploymentException.hpp"
-#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/lang/XInitialization.hpp"
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include "com/sun/star/lang/XSingleServiceFactory.hpp"
-#include "com/sun/star/lang/XSingleComponentFactory.hpp"
-#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/container/XSet.hpp"
-#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
-#include "com/sun/star/registry/XSimpleRegistry.hpp"
 #include "com/sun/star/uno/SecurityException.hpp"
-#if OSL_DEBUG_LEVEL > 1
-#include <stdio.h>
-#endif
 
-#include "macro_expander.hxx"
-#include "paths.hxx"
 #include "servicefactory_detail.hxx"
 
 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
@@ -62,30 +40,6 @@ using namespace ::com::sun::star::uno;
 namespace cppu
 {
 
-static Reference< XInterface > SAL_CALL createInstance(
-    Reference< XInterface > const & xFactory,
-    Reference< XComponentContext > const & xContext =
-    Reference< XComponentContext >() )
-{
-    Reference< lang::XSingleComponentFactory > xFac( xFactory, UNO_QUERY );
-    if (xFac.is())
-    {
-        return xFac->createInstanceWithContext( xContext );
-    }
-    else
-    {
-        Reference< lang::XSingleServiceFactory > xFac2( xFactory, UNO_QUERY );
-        if (xFac2.is())
-        {
-            OSL_ENSURE( !xContext.is(), "### ignoring context!" );
-            return xFac2->createInstance();
-        }
-    }
-    throw RuntimeException(
-        OUSTR("no factory object given!"),
-        Reference< XInterface >() );
-}
-
 /** bootstrap variables:
 
     UNO_AC=<mode> [mandatory]
@@ -234,103 +188,6 @@ void add_access_control_entries(
     context_values.push_back( entry );
 }
 
-namespace {
-void addFactories(
-    char const * const * ppNames /* implname, ..., 0 */,
-    OUString const & bootstrapPath,
-    Reference< lang::XMultiComponentFactory > const & xMgr,
-    Reference< registry::XRegistryKey > const & xKey )
-    SAL_THROW( (Exception) )
-{
-    Reference< container::XSet > xSet( xMgr, UNO_QUERY );
-    OSL_ASSERT( xSet.is() );
-    Reference< lang::XMultiServiceFactory > xSF( xMgr, UNO_QUERY );
-
-    while (*ppNames)
-    {
-        OUString implName( OUString::createFromAscii( *ppNames++ ) );
-
-        Any aFac( makeAny( loadSharedLibComponentFactory(
-                               OUSTR("bootstrap.uno" SAL_DLLEXTENSION),
-                               bootstrapPath, implName, xSF, xKey ) ) );
-        xSet->insert( aFac );
-#if OSL_DEBUG_LEVEL > 1
-        if (xSet->has( aFac ))
-        {
-            Reference< lang::XServiceInfo > xInfo;
-            if (aFac >>= xInfo)
-            {
-                ::fprintf(
-                    stderr, "> implementation %s supports: ", ppNames[ -1 ] );
-                Sequence< OUString > supported(
-                    xInfo->getSupportedServiceNames() );
-                for ( sal_Int32 nPos = supported.getLength(); nPos--; )
-                {
-                    OString str( OUStringToOString(
-                        supported[ nPos ], RTL_TEXTENCODING_ASCII_US ) );
-                    ::fprintf( stderr, nPos ? "%s, " : "%s\n", str.getStr() );
-                }
-            }
-            else
-            {
-                ::fprintf(
-                    stderr,
-                    "> implementation %s provides NO lang::XServiceInfo!!!\n",
-                    ppNames[ -1 ] );
-            }
-        }
-#endif
-#if OSL_DEBUG_LEVEL > 0
-        if (! xSet->has( aFac ))
-        {
-            OStringBuffer buf( 64 );
-            buf.append( "### failed inserting shared lib \"" );
-            buf.append( "bootstrap.uno" SAL_DLLEXTENSION );
-            buf.append( "\"!!!" );
-            OString str( buf.makeStringAndClear() );
-            OSL_FAIL( str.getStr() );
-        }
-#endif
-    }
-}
-
-} // namespace
-
-Reference< lang::XMultiComponentFactory > bootstrapInitialSF(
-    OUString const & rBootstrapPath )
-    SAL_THROW( (Exception) )
-{
-    OUString const & bootstrap_path =
-        rBootstrapPath.isEmpty() ? get_this_libpath() : rBootstrapPath;
-
-    Reference< lang::XMultiComponentFactory > xMgr(
-        createInstance(
-            loadSharedLibComponentFactory(
-                OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrap_path,
-                OUSTR("com.sun.star.comp.stoc.ORegistryServiceManager"),
-                Reference< lang::XMultiServiceFactory >(),
-                Reference< registry::XRegistryKey >() ) ),
-        UNO_QUERY );
-
-    // add initial bootstrap services
-    static char const * ar[] = {
-        "com.sun.star.comp.stoc.OServiceManagerWrapper",
-        "com.sun.star.comp.stoc.DLLComponentLoader",
-        "com.sun.star.comp.stoc.SimpleRegistry",
-        "com.sun.star.comp.stoc.NestedRegistry",
-        "com.sun.star.comp.stoc.TypeDescriptionManager",
-        "com.sun.star.comp.stoc.ImplementationRegistration",
-        "com.sun.star.security.comp.stoc.AccessController",
-        "com.sun.star.security.comp.stoc.FilePolicy",
-        0
-    };
-    addFactories(
-        ar, bootstrap_path,
-        xMgr, Reference< registry::XRegistryKey >() );
-
-    return xMgr;
-}
-
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/servicefactory_detail.hxx b/cppuhelper/source/servicefactory_detail.hxx
index 40fe77f..09c3997 100644
--- a/cppuhelper/source/servicefactory_detail.hxx
+++ b/cppuhelper/source/servicefactory_detail.hxx
@@ -25,17 +25,10 @@
 #include <vector>
 
 #include "com/sun/star/uno/Exception.hpp"
-#include "com/sun/star/uno/Reference.hxx"
 #include "sal/types.h"
 
-namespace com { namespace sun { namespace star { namespace lang {
-    class XMultiComponentFactory;
-} } } }
 namespace cppu { struct ContextEntry_Init; }
-namespace rtl {
-    class Bootstrap;
-    class OUString;
-}
+namespace rtl { class Bootstrap; }
 
 namespace cppu {
 
@@ -44,11 +37,6 @@ void add_access_control_entries(
     rtl::Bootstrap const & bootstrap)
     SAL_THROW((com::sun::star::uno::Exception));
 
-SAL_DLLPUBLIC_EXPORT
-com::sun::star::uno::Reference< com::sun::star::lang::XMultiComponentFactory >
-bootstrapInitialSF(rtl::OUString const & rBootstrapPath)
-    SAL_THROW((com::sun::star::uno::Exception));
-
 }
 
 #endif
commit fc9d23ff550194ba50fc6506ec901c22681d1b1c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 15 18:05:07 2013 +0100

    Reorganize defaultbootstrap so that typedescriptionprovider can use servicemgr
    
    ...instead of having to rely on the odd bootstrapInitialSF and explicit
    loadSharedLibComponentFactory.
    
    Change-Id: I2fb212024c483254da015db3af43d9002051dddc

diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index e4b3cd5..d4863b3 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -34,7 +34,6 @@
 
 #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
 #include "com/sun/star/container/XSet.hpp"
-#include "com/sun/star/registry/XSimpleRegistry.hpp"
 #include "com/sun/star/uno/DeploymentException.hpp"
 #include "com/sun/star/uno/Reference.hxx"
 #include "com/sun/star/uno/XComponentContext.hpp"
@@ -127,22 +126,13 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
         context->getValueByName(
             "/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
         css::uno::UNO_QUERY_THROW);
-    css::uno::Reference< css::registry::XSimpleRegistry > typereg(
-        cppuhelper::createTypeRegistry(
-            getBootstrapVariable(bs, "UNO_TYPES"),
-            getBootstrapVariable(bs, "URE_INTERNAL_LIB_DIR")));
-    if (typereg.is()) {
-        css::uno::Sequence< css::uno::Any > arg(1);
-        arg[0] <<= typereg;
-        css::uno::Reference< css::container::XSet >(
-            tdmgr, css::uno::UNO_QUERY_THROW)->
-            insert(
-                css::uno::makeAny(
-                    smgr->createInstanceWithArgumentsAndContext(
-                        ("com.sun.star.comp.stoc"
-                         ".RegistryTypeDescriptionProvider"),
-                        arg, context)));
-    }
+    css::uno::Reference< css::container::XSet >(
+        tdmgr, css::uno::UNO_QUERY_THROW)->
+        insert(
+            css::uno::makeAny(
+                cppuhelper::createTypeDescriptionProvider(
+                    getBootstrapVariable(bs, "UNO_TYPES"), smgr.get(),
+                    context)));
     cppu::installTypeDescriptionManager(tdmgr);
     return context;
 }
diff --git a/cppuhelper/source/typedescriptionprovider.cxx b/cppuhelper/source/typedescriptionprovider.cxx
index 62ff40e..d99650b 100644
--- a/cppuhelper/source/typedescriptionprovider.cxx
+++ b/cppuhelper/source/typedescriptionprovider.cxx
@@ -12,17 +12,17 @@
 #include <cassert>
 
 #include "com/sun/star/lang/XInitialization.hpp"
-#include "com/sun/star/lang/XSingleServiceFactory.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
 #include "com/sun/star/registry/InvalidRegistryException.hpp"
 #include "com/sun/star/registry/XSimpleRegistry.hpp"
 #include "com/sun/star/uno/DeploymentException.hpp"
 #include "com/sun/star/uno/Reference.hxx"
-#include "cppuhelper/shlib.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
 #include "osl/file.hxx"
 #include "rtl/ustring.hxx"
 
 #include "paths.hxx"
-#include "servicefactory_detail.hxx"
 #include "typedescriptionprovider.hxx"
 
 namespace {
@@ -30,19 +30,21 @@ namespace {
 css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbFile(
     rtl::OUString const & uri, bool optional,
     css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry,
-    css::uno::Reference< css::lang::XSingleServiceFactory > const &
-        simpleRegistryFactory,
-    css::uno::Reference< css::lang::XSingleServiceFactory > const &
-        nestedRegistryFactory)
+    css::uno::Reference< css::lang::XMultiComponentFactory > const &
+        serviceManager,
+    css::uno::Reference< css::uno::XComponentContext > const & context)
 {
-    assert(simpleRegistryFactory.is() && nestedRegistryFactory.is());
+    assert(serviceManager.is());
     try {
         css::uno::Reference< css::registry::XSimpleRegistry > simple(
-            simpleRegistryFactory->createInstance(), css::uno::UNO_QUERY_THROW);
+            serviceManager->createInstanceWithContext(
+                "com.sun.star.comp.stoc.SimpleRegistry", context),
+            css::uno::UNO_QUERY_THROW);
         simple->open(uri, true, false);
         if (lastRegistry.is()) {
             css::uno::Reference< css::registry::XSimpleRegistry > nested(
-                nestedRegistryFactory->createInstance(),
+                serviceManager->createInstanceWithContext(
+                    "com.sun.star.comp.stoc.NestedRegistry", context),
                 css::uno::UNO_QUERY_THROW);
             css::uno::Sequence< css::uno::Any > args(2);
             args[0] <<= lastRegistry;
@@ -68,12 +70,10 @@ css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbFile(
 css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbDirectory(
     rtl::OUString const & uri, bool optional,
     css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry,
-    css::uno::Reference< css::lang::XSingleServiceFactory > const &
-        simpleRegistryFactory,
-    css::uno::Reference< css::lang::XSingleServiceFactory > const &
-        nestedRegistryFactory)
+    css::uno::Reference< css::lang::XMultiComponentFactory > const &
+        serviceManager,
+    css::uno::Reference< css::uno::XComponentContext > const & context)
 {
-    assert(simpleRegistryFactory.is() && nestedRegistryFactory.is());
     osl::Directory dir(uri);
     switch (dir.open()) {
     case osl::FileBase::E_None:
@@ -96,36 +96,17 @@ css::uno::Reference< css::registry::XSimpleRegistry > readTypeRdbDirectory(
             break;
         }
         last = readTypeRdbFile(
-            fileUri, optional, last, simpleRegistryFactory,
-            nestedRegistryFactory);
+            fileUri, optional, last, serviceManager, context);
     }
     return last;
 }
 
-}
-
-css::uno::Reference< css::registry::XSimpleRegistry >
-cppuhelper::createTypeRegistry(
-    rtl::OUString const & uris, rtl::OUString const & libraryDirectoryUri)
+css::uno::Reference< css::registry::XSimpleRegistry > createTypeRegistry(
+    rtl::OUString const & uris,
+    css::uno::Reference< css::lang::XMultiComponentFactory > const &
+        serviceManager,
+    css::uno::Reference< css::uno::XComponentContext > const & context)
 {
-    css::uno::Reference< css::lang::XMultiComponentFactory > factory(
-        cppu::bootstrapInitialSF(libraryDirectoryUri));
-    css::uno::Reference< css::lang::XSingleServiceFactory > simpleRegs(
-        cppu::loadSharedLibComponentFactory(
-            "bootstrap.uno" SAL_DLLEXTENSION, libraryDirectoryUri,
-            "com.sun.star.comp.stoc.SimpleRegistry",
-            css::uno::Reference< css::lang::XMultiServiceFactory >(
-                factory, css::uno::UNO_QUERY_THROW),
-            css::uno::Reference< css::registry::XRegistryKey >()),
-        css::uno::UNO_QUERY_THROW);
-    css::uno::Reference< css::lang::XSingleServiceFactory > nestedRegs(
-        cppu::loadSharedLibComponentFactory(
-            "bootstrap.uno" SAL_DLLEXTENSION, libraryDirectoryUri,
-            "com.sun.star.comp.stoc.NestedRegistry",
-            css::uno::Reference< css::lang::XMultiServiceFactory >(
-                factory, css::uno::UNO_QUERY_THROW),
-            css::uno::Reference< css::registry::XRegistryKey >()),
-        css::uno::UNO_QUERY_THROW);
     css::uno::Reference< css::registry::XSimpleRegistry > reg;
     for (sal_Int32 i = 0; i != -1;) {
         rtl::OUString uri(uris.getToken(0, ' ', i));
@@ -136,10 +117,34 @@ cppuhelper::createTypeRegistry(
         bool directory;
         cppu::decodeRdbUri(&uri, &optional, &directory);
         reg = directory
-            ? readTypeRdbDirectory(uri, optional, reg, simpleRegs, nestedRegs)
-            : readTypeRdbFile(uri, optional, reg, simpleRegs, nestedRegs);
+            ? readTypeRdbDirectory(uri, optional, reg, serviceManager, context)
+            : readTypeRdbFile(uri, optional, reg, serviceManager, context);
     }
     return reg;
 }
 
+}
+
+css::uno::Reference< css::uno::XInterface >
+cppuhelper::createTypeDescriptionProvider(
+    rtl::OUString const & uris,
+    css::uno::Reference< css::lang::XMultiComponentFactory > const &
+        serviceManager,
+    css::uno::Reference< css::uno::XComponentContext > const & context)
+{
+    assert(serviceManager.is());
+    css::uno::Sequence< css::uno::Any > args;
+    css::uno::Reference< css::registry::XSimpleRegistry > typereg(
+        createTypeRegistry(uris, serviceManager, context));
+    if (typereg.is()) {
+        args.realloc(1);
+        args[0] <<= typereg;
+    }
+    return css::uno::Reference< css::uno::XInterface >(
+        serviceManager->createInstanceWithArgumentsAndContext(
+            "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider",
+            args, context),
+        css::uno::UNO_SET_THROW);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/typedescriptionprovider.hxx b/cppuhelper/source/typedescriptionprovider.hxx
index 716f2ad..f3715e6 100644
--- a/cppuhelper/source/typedescriptionprovider.hxx
+++ b/cppuhelper/source/typedescriptionprovider.hxx
@@ -14,15 +14,22 @@
 
 #include "com/sun/star/uno/Reference.hxx"
 
-namespace com { namespace sun { namespace star { namespace uno {
-    class XSimpleRegistry;
-} } } }
+namespace com { namespace sun { namespace star {
+     namespace lang { class XMultiComponentFactory; }
+     namespace uno {
+         class XComponentContext;
+         class XInterface;
+     }
+} } }
 namespace rtl { class OUString; }
 
 namespace cppuhelper {
 
-css::uno::Reference< css::registry::XSimpleRegistry > createTypeRegistry(
-    rtl::OUString const & uris, rtl::OUString const & libraryDirectoryUri);
+css::uno::Reference< css::uno::XInterface > createTypeDescriptionProvider(
+    rtl::OUString const & uris,
+    css::uno::Reference< css::lang::XMultiComponentFactory > const &
+        serviceManager,
+    css::uno::Reference< css::uno::XComponentContext > const & context);
 
 }
 
commit 556f94881225cdf1ae34dc9955bd5c04ffee9f14
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 15 18:04:07 2013 +0100

    Do not hide information about UNO bootstrap failures
    
    Change-Id: I42ce84a00c4de60d30093f58214f76647ff03097

diff --git a/i18npool/source/localedata/saxparser.cxx b/i18npool/source/localedata/saxparser.cxx
index c7cf61e..2715867 100644
--- a/i18npool/source/localedata/saxparser.cxx
+++ b/i18npool/source/localedata/saxparser.cxx
@@ -303,17 +303,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         exit( 1 );
     }
 
-    Reference< XComponentContext > xContext;
-    try
-    {
-        xContext = defaultBootstrap_InitialComponentContext();
-    }
-    catch ( const Exception &e )
-    {
-        printf( "Exception bootstrapping UNO: %s\n",
-            OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() );
-        exit(1);
-    }
+    Reference< XComponentContext > xContext(
+        defaultBootstrap_InitialComponentContext());
 
     //--------------------------------
     // parser demo
commit aed1f0d5d543c534b4b9c3517802a24e700f0b5a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 15 17:22:16 2013 +0100

    Simplify defaultbootstrap.cxx
    
    Change-Id: Ice206b1dabf8dbcad613f886574e737c039d2119

diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 23411b1..e4b3cd5 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -52,12 +52,33 @@
 
 namespace {
 
-css::uno::Reference< css::uno::XComponentContext > bootstrapComponentContext(
-    css::uno::Reference< css::registry::XSimpleRegistry > const & typeRegistry,
-    rtl::OUString const & serviceUris, rtl::Bootstrap const & bootstrap)
+rtl::OUString getBootstrapVariable(
+    rtl::Bootstrap const & bootstrap, rtl::OUString const & name)
 {
+    rtl::OUString v;
+    if (!bootstrap.getFrom(name, v)) {
+        throw css::uno::DeploymentException(
+            "Cannot obtain " + name + " from uno ini",
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    return v;
+}
+
+}
+
+css::uno::Reference< css::uno::XComponentContext >
+cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
+    SAL_THROW((css::uno::Exception))
+{
+    rtl::Bootstrap bs(iniUri);
+    if (bs.getHandle() == 0) {
+        throw css::uno::DeploymentException(
+            "Cannot open uno ini " + iniUri,
+            css::uno::Reference< css::uno::XInterface >());
+    }
     rtl::Reference< cppuhelper::ServiceManager > smgr(
-        new cppuhelper::ServiceManager(serviceUris));
+        new cppuhelper::ServiceManager(
+            getBootstrapVariable(bs, "UNO_SERVICES")));
     cppu::ContextEntry_Init entry;
     std::vector< cppu::ContextEntry_Init > context_values;
     context_values.push_back(
@@ -95,7 +116,7 @@ css::uno::Reference< css::uno::XComponentContext > bootstrapComponentContext(
                 "/singletons/" + i->first,
                 css::uno::makeAny(i->second[0]->info->name), true));
     }
-    cppu::add_access_control_entries(&context_values, bootstrap);
+    cppu::add_access_control_entries(&context_values, bs);
     assert(!context_values.empty());
     css::uno::Reference< css::uno::XComponentContext > context(
         createComponentContext(
@@ -106,9 +127,13 @@ css::uno::Reference< css::uno::XComponentContext > bootstrapComponentContext(
         context->getValueByName(
             "/singletons/com.sun.star.reflection.theTypeDescriptionManager"),
         css::uno::UNO_QUERY_THROW);
-    if (typeRegistry.is()) {
+    css::uno::Reference< css::registry::XSimpleRegistry > typereg(
+        cppuhelper::createTypeRegistry(
+            getBootstrapVariable(bs, "UNO_TYPES"),
+            getBootstrapVariable(bs, "URE_INTERNAL_LIB_DIR")));
+    if (typereg.is()) {
         css::uno::Sequence< css::uno::Any > arg(1);
-        arg[0] <<= typeRegistry;
+        arg[0] <<= typereg;
         css::uno::Reference< css::container::XSet >(
             tdmgr, css::uno::UNO_QUERY_THROW)->
             insert(
@@ -122,37 +147,6 @@ css::uno::Reference< css::uno::XComponentContext > bootstrapComponentContext(
     return context;
 }
 
-rtl::OUString getBootstrapVariable(
-    rtl::Bootstrap const & bootstrap, rtl::OUString const & name)
-{
-    rtl::OUString v;
-    if (!bootstrap.getFrom(name, v)) {
-        throw css::uno::DeploymentException(
-            "Cannot obtain " + name + " from uno ini",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return v;
-}
-
-}
-
-css::uno::Reference< css::uno::XComponentContext >
-cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
-    SAL_THROW((css::uno::Exception))
-{
-    rtl::Bootstrap bs(iniUri);
-    if (bs.getHandle() == 0) {
-        throw css::uno::DeploymentException(
-            "Cannot open uno ini " + iniUri,
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return bootstrapComponentContext(
-        cppuhelper::createTypeRegistry(
-            getBootstrapVariable(bs, "UNO_TYPES"),
-            getBootstrapVariable(bs, "URE_INTERNAL_LIB_DIR")),
-        getBootstrapVariable(bs, "UNO_SERVICES"), bs);
-}
-
 css::uno::Reference< css::uno::XComponentContext >
 cppu::defaultBootstrap_InitialComponentContext()
     SAL_THROW((css::uno::Exception))
commit 3250fad6374ef276e198faabbb1d655adeeb28f0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 15 16:28:30 2013 +0100

    Extract servicemanager and typedescriptionprovider from defaultbootstrap
    
    Change-Id: I94fe7e68c5a49e591a625e9bf62108acac69428d

diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index 07b8a41..acfa4c7 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -69,9 +69,11 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
 	cppuhelper/source/propertysetmixin \
 	cppuhelper/source/propshlp \
 	cppuhelper/source/servicefactory \
+	cppuhelper/source/servicemanager \
 	cppuhelper/source/shlib \
 	cppuhelper/source/supportsservice \
 	cppuhelper/source/tdmgr \
+	cppuhelper/source/typedescriptionprovider \
 	cppuhelper/source/typeprovider \
 	cppuhelper/source/unourl \
 	cppuhelper/source/weak \
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index 128ee64..23411b1 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -29,1959 +29,35 @@
 
 #include "sal/config.h"
 
-#include <algorithm>
 #include <cassert>
-#include <cstring>
-#include <map>
 #include <vector>
 
-#include "boost/noncopyable.hpp"
-#include "boost/shared_ptr.hpp"
-#include "com/sun/star/beans/NamedValue.hpp"
-#include "com/sun/star/beans/PropertyAttribute.hpp"
-#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/container/ElementExistException.hpp"
-#include "com/sun/star/container/XContentEnumerationAccess.hpp"
-#include "com/sun/star/container/XEnumeration.hpp"
 #include "com/sun/star/container/XHierarchicalNameAccess.hpp"
-#include "com/sun/star/container/XNameContainer.hpp"
 #include "com/sun/star/container/XSet.hpp"
-#include "com/sun/star/lang/XInitialization.hpp"
-#include "com/sun/star/lang/XServiceInfo.hpp"
-#include "com/sun/star/lang/XSingleComponentFactory.hpp"
-#include "com/sun/star/lang/XSingleServiceFactory.hpp"
-#include "com/sun/star/loader/XImplementationLoader.hpp"
-#include "com/sun/star/registry/InvalidRegistryException.hpp"
 #include "com/sun/star/registry/XSimpleRegistry.hpp"
 #include "com/sun/star/uno/DeploymentException.hpp"
 #include "com/sun/star/uno/Reference.hxx"
 #include "com/sun/star/uno/XComponentContext.hpp"
 #include "cppuhelper/bootstrap.hxx"
-#include "cppuhelper/compbase8.hxx"
 #include "cppuhelper/component_context.hxx"
-#include "cppuhelper/implbase1.hxx"
-#include "cppuhelper/implbase3.hxx"
-#include "cppuhelper/shlib.hxx"
-#include "cppuhelper/supportsservice.hxx"
-#include "osl/file.hxx"
-#include "registry/registry.hxx"
 #include "rtl/bootstrap.hxx"
 #include "rtl/ref.hxx"
-#include "rtl/uri.hxx"
 #include "rtl/ustring.hxx"
-#include "xmlreader/xmlreader.hxx"
 
 #include "macro_expander.hxx"
 #include "paths.hxx"
 #include "servicefactory_detail.hxx"
+#include "servicemanager.hxx"
+#include "typedescriptionprovider.hxx"
 
 namespace {
 
-bool nextDirectoryItem(osl::Directory & directory, rtl::OUString * url) {
-    assert(url != 0);
-    for (;;) {
-        osl::DirectoryItem i;
-        switch (directory.getNextItem(i, SAL_MAX_UINT32)) {
-        case osl::FileBase::E_None:
-            break;
-        case osl::FileBase::E_NOENT:
-            return false;
-        default:
-            throw css::uno::DeploymentException(
-                "Cannot iterate directory",
-                css::uno::Reference< css::uno::XInterface >());
-        }
-        osl::FileStatus stat(
-            osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
-            osl_FileStatus_Mask_FileURL);
-        if (i.getFileStatus(stat) != osl::FileBase::E_None) {
-            throw css::uno::DeploymentException(
-                "Cannot stat in directory",
-                css::uno::Reference< css::uno::XInterface >());
-        }
-        if (stat.getFileType() != osl::FileStatus::Directory) { //TODO: symlinks
-            // Ignore backup files:
-            rtl::OUString name(stat.getFileName());
-            if (!(name.match(".") || name.endsWith("~"))) {
-                *url = stat.getFileURL();
-                return true;
-            }
-        }
-    }
-}
-
-void decodeRdbUri(rtl::OUString * uri, bool * optional, bool * directory) {
-    assert(uri != 0 && optional != 0 && directory != 0);
-    *optional = (*uri)[0] == '?';
-    if (*optional) {
-        *uri = uri->copy(1);
-    }
-    *directory = uri->getLength() >= 3 && (*uri)[0] == '<'
-        && (*uri)[uri->getLength() - 2] == '>'
-        && (*uri)[uri->getLength() - 1] == '*';
-    if (*directory) {
-        *uri = uri->copy(1, uri->getLength() - 3);
-    }
-}
-
-struct ImplementationInfo: private boost::noncopyable {
-    ImplementationInfo(
-        rtl::OUString const & theName, rtl::OUString const & theLoader,
-        rtl::OUString const & theUri, rtl::OUString const & thePrefix,
-        css::uno::Reference< css::uno::XComponentContext > const &
-            theAlienContext,
-        rtl::OUString const & theRdbFile):
-        name(theName), loader(theLoader), uri(theUri), prefix(thePrefix),
-        alienContext(theAlienContext), rdbFile(theRdbFile)
-    {}
-
-    explicit ImplementationInfo(rtl::OUString const & theName): name(theName) {}
-
-    rtl::OUString const name;
-    rtl::OUString const loader;
-    rtl::OUString const uri;
-    rtl::OUString const prefix;
-    css::uno::Reference< css::uno::XComponentContext > const alienContext;
-    rtl::OUString const rdbFile;
-    std::vector< rtl::OUString > services;
-    std::vector< rtl::OUString > singletons;
-};
-
-struct Implementation: private boost::noncopyable {
-    Implementation(
-        rtl::OUString const & name, rtl::OUString const & loader,
-        rtl::OUString const & uri, rtl::OUString const & prefix,
-        css::uno::Reference< css::uno::XComponentContext > const & alienContext,
-        rtl::OUString const & rdbFile):
-        info(
-            new ImplementationInfo(
-                name, loader, uri, prefix, alienContext, rdbFile)),
-        loaded(false)
-    {}
-
-    Implementation(
-        rtl::OUString const & name,
-        css::uno::Reference< css::lang::XSingleComponentFactory > const &
-            theFactory1,
-        css::uno::Reference< css::lang::XSingleServiceFactory > const &
-            theFactory2,
-        css::uno::Reference< css::lang::XComponent > const & theComponent):
-        info(new ImplementationInfo(name)), factory1(theFactory1),
-        factory2(theFactory2), component(theComponent), loaded(true)
-    {}
-
-    boost::shared_ptr< ImplementationInfo > info;
-    css::uno::Reference< css::lang::XSingleComponentFactory > factory1;
-    css::uno::Reference< css::lang::XSingleServiceFactory > factory2;
-    css::uno::Reference< css::lang::XComponent > component;
-    bool loaded;
-};
-
-typedef std::map< rtl::OUString, boost::shared_ptr< Implementation > >
-NamedImplementations;
-
-typedef
-    std::map<
-        css::uno::Reference< css::lang::XServiceInfo >,
-        boost::shared_ptr< Implementation > >
-    DynamicImplementations;
-
-typedef
-    std::map<
-        rtl::OUString, std::vector< boost::shared_ptr< Implementation > > >
-    ImplementationMap;
-
-void insertImplementationMap(
-    ImplementationMap * destination, ImplementationMap const & source)
-{
-    assert(destination != 0);
-    for (ImplementationMap::const_iterator i(source.begin()); i != source.end();
-         ++i)
-    {
-        std::vector< boost::shared_ptr< Implementation > > & impls
-            = (*destination)[i->first];
-        impls.insert(impls.end(), i->second.begin(), i->second.end());
-    }
-}
-
-void removeFromImplementationMap(
-    ImplementationMap * map, std::vector< rtl::OUString > const & elements,
-    boost::shared_ptr< Implementation > const & implementation)
-{
-    // The underlying data structures make this function somewhat inefficient,
-    // but the assumption is that it is rarely called:
-    assert(map != 0);
-    for (std::vector< rtl::OUString >::const_iterator i(elements.begin());
-         i != elements.end(); ++i)
-    {
-        ImplementationMap::iterator j(map->find(*i));
-        assert(j != map->end());
-        std::vector< boost::shared_ptr< Implementation > >::iterator k(
-            std::find(j->second.begin(), j->second.end(), implementation));
-        assert(k != j->second.end());
-        j->second.erase(k);
-        if (j->second.empty()) {
-            map->erase(j);
-        }
-    }
-}
-
-struct Data: private boost::noncopyable {
-    NamedImplementations namedImplementations;
-    DynamicImplementations dynamicImplementations;
-    ImplementationMap services;
-    ImplementationMap singletons;
-};
-
-// For simplicity, this code keeps throwing
-// css::registry::InvalidRegistryException for invalid XML rdbs (even though
-// that does not fit the exception's name):
-class Parser: private boost::noncopyable {
-public:
-    Parser(
-        rtl::OUString const & uri,
-        css::uno::Reference< css::uno::XComponentContext > const & alienContext,
-        Data * data);
-
-private:
-    void handleComponent();
-
-    void handleImplementation();
-
-    void handleService();
-
-    void handleSingleton();
-
-    rtl::OUString getNameAttribute();
-
-    xmlreader::XmlReader reader_;
-    css::uno::Reference< css::uno::XComponentContext > alienContext_;
-    Data * data_;
-    rtl::OUString attrLoader_;
-    rtl::OUString attrUri_;
-    rtl::OUString attrPrefix_;
-    rtl::OUString attrImplementation_;
-    boost::shared_ptr< Implementation > implementation_;
-};
-
-Parser::Parser(
-    rtl::OUString const & uri,
-    css::uno::Reference< css::uno::XComponentContext > const & alienContext,
-    Data * data):
-    reader_(uri), alienContext_(alienContext), data_(data)
-{
-    assert(data != 0);
-    int ucNsId = reader_.registerNamespaceIri(
-        xmlreader::Span(
-            RTL_CONSTASCII_STRINGPARAM(
-                "http://openoffice.org/2010/uno-components")));
-    enum State {
-        STATE_BEGIN, STATE_END, STATE_COMPONENTS, STATE_COMPONENT_INITIAL,
-        STATE_COMPONENT, STATE_IMPLEMENTATION, STATE_SERVICE, STATE_SINGLETON };
-    for (State state = STATE_BEGIN;;) {
-        xmlreader::Span name;
-        int nsId;
-        xmlreader::XmlReader::Result res = reader_.nextItem(
-            xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
-        switch (state) {
-        case STATE_BEGIN:
-            if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId
-                && name.equals(RTL_CONSTASCII_STRINGPARAM("components")))
-            {
-                state = STATE_COMPONENTS;
-                break;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in outer level",
-                css::uno::Reference< css::uno::XInterface >());
-        case STATE_END:
-            if (res == xmlreader::XmlReader::RESULT_DONE) {
-                return;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in outer level",
-                css::uno::Reference< css::uno::XInterface >());
-        case STATE_COMPONENTS:
-            if (res == xmlreader::XmlReader::RESULT_END) {
-                state = STATE_END;
-                break;
-            }
-            if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId
-                && name.equals(RTL_CONSTASCII_STRINGPARAM("component")))
-            {
-                handleComponent();
-                state = STATE_COMPONENT_INITIAL;
-                break;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in <components>",
-                css::uno::Reference< css::uno::XInterface >());
-        case STATE_COMPONENT:
-            if (res == xmlreader::XmlReader::RESULT_END) {
-                state = STATE_COMPONENTS;
-                break;
-            }
-            // fall through
-        case STATE_COMPONENT_INITIAL:
-            if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId
-                && name.equals(RTL_CONSTASCII_STRINGPARAM("implementation")))
-            {
-                handleImplementation();
-                state = STATE_IMPLEMENTATION;
-                break;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in <component>",
-                css::uno::Reference< css::uno::XInterface >());
-        case STATE_IMPLEMENTATION:
-            if (res == xmlreader::XmlReader::RESULT_END) {
-                state = STATE_COMPONENT;
-                break;
-            }
-            if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId
-                && name.equals(RTL_CONSTASCII_STRINGPARAM("service")))
-            {
-                handleService();
-                state = STATE_SERVICE;
-                break;
-            }
-            if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId
-                && name.equals(RTL_CONSTASCII_STRINGPARAM("singleton")))
-            {
-                handleSingleton();
-                state = STATE_SINGLETON;
-                break;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in <implementation>",
-                css::uno::Reference< css::uno::XInterface >());
-        case STATE_SERVICE:
-            if (res == xmlreader::XmlReader::RESULT_END) {
-                state = STATE_IMPLEMENTATION;
-                break;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in <service>",
-                css::uno::Reference< css::uno::XInterface >());
-        case STATE_SINGLETON:
-            if (res == xmlreader::XmlReader::RESULT_END) {
-                state = STATE_IMPLEMENTATION;
-                break;
-            }
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": unexpected item in <service>",
-                css::uno::Reference< css::uno::XInterface >());
-        }
-    }
-}
-
-void Parser::handleComponent() {
-    attrLoader_ = rtl::OUString();
-    attrUri_ = rtl::OUString();
-    attrPrefix_ = rtl::OUString();
-    xmlreader::Span name;
-    int nsId;
-    while (reader_.nextAttribute(&nsId, &name)) {
-        if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
-            && name.equals(RTL_CONSTASCII_STRINGPARAM("loader")))
-        {
-            if (!attrLoader_.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl()
-                     + ": <component> has multiple \"loader\" attributes"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-            attrLoader_ = reader_.getAttributeValue(false).convertFromUtf8();
-            if (attrLoader_.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl()
-                     + ": <component> has empty \"loader\" attribute"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-        } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
-                   && name.equals(RTL_CONSTASCII_STRINGPARAM("uri")))
-        {
-            if (!attrUri_.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl()
-                     + ": <component> has multiple \"uri\" attributes"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-            attrUri_ = reader_.getAttributeValue(false).convertFromUtf8();
-            if (attrUri_.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl()
-                     + ": <component> has empty \"uri\" attribute"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-        } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
-                   && name.equals(RTL_CONSTASCII_STRINGPARAM("prefix")))
-        {
-            if (!attrPrefix_.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl() +
-                     ": <component> has multiple \"prefix\" attributes"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-            attrPrefix_ = reader_.getAttributeValue(false).convertFromUtf8();
-            if (attrPrefix_.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl() +
-                     ": <component> has empty \"prefix\" attribute"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-        } else {
-            throw css::registry::InvalidRegistryException(
-                (reader_.getUrl() + ": unexpected attribute \""
-                 + name.convertFromUtf8() + "\" in <component>"),
-                css::uno::Reference< css::uno::XInterface >());
-        }
-    }
-    if (attrLoader_.isEmpty()) {
-        throw css::registry::InvalidRegistryException(
-            reader_.getUrl() + ": <component> is missing \"loader\" attribute",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    if (attrUri_.isEmpty()) {
-        throw css::registry::InvalidRegistryException(
-            reader_.getUrl() + ": <component> is missing \"uri\" attribute",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-#ifndef DISABLE_DYNLOADING
-    try {
-        attrUri_ = rtl::Uri::convertRelToAbs(reader_.getUrl(), attrUri_);
-    } catch (const rtl::MalformedUriException & e) {
-        throw css::registry::InvalidRegistryException(
-            reader_.getUrl() + ": bad \"uri\" attribute: " + e.getMessage(),
-            css::uno::Reference< css::uno::XInterface >());
-    }
-#endif
-}
-
-void Parser::handleImplementation() {
-    attrImplementation_ = getNameAttribute();
-    implementation_.reset(
-        new Implementation(
-            attrImplementation_, attrLoader_, attrUri_, attrPrefix_,
-            alienContext_, reader_.getUrl()));
-    if (!data_->namedImplementations.insert(
-            NamedImplementations::value_type(
-                attrImplementation_, implementation_)).
-        second)
-    {
-        throw css::registry::InvalidRegistryException(
-            (reader_.getUrl() + ": duplicate <implementation name=\""
-             + attrImplementation_ + "\">"),
-            css::uno::Reference< css::uno::XInterface >());
-    }
-}
-
-void Parser::handleService() {
-    rtl::OUString name(getNameAttribute());
-    implementation_->info->services.push_back(name);
-    data_->services[name].push_back(implementation_);
-}
-
-void Parser::handleSingleton() {
-    rtl::OUString name(getNameAttribute());
-    implementation_->info->singletons.push_back(name);
-    data_->singletons[name].push_back(implementation_);
-}
-
-rtl::OUString Parser::getNameAttribute() {
-    rtl::OUString attrName;
-    xmlreader::Span name;
-    int nsId;
-    while (reader_.nextAttribute(&nsId, &name)) {
-        if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
-            && name.equals(RTL_CONSTASCII_STRINGPARAM("name")))
-        {
-            if (!attrName.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    (reader_.getUrl()
-                     + ": element has multiple \"name\" attributes"),
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-            attrName = reader_.getAttributeValue(false).convertFromUtf8();
-            if (attrName.isEmpty()) {
-                throw css::registry::InvalidRegistryException(
-                    reader_.getUrl() + ": element has empty \"name\" attribute",
-                    css::uno::Reference< css::uno::XInterface >());
-            }
-        } else {
-            throw css::registry::InvalidRegistryException(
-                reader_.getUrl() + ": expected element attribute \"name\"",
-                css::uno::Reference< css::uno::XInterface >());
-        }
-    }
-    if (attrName.isEmpty()) {
-        throw css::registry::InvalidRegistryException(
-            reader_.getUrl() + ": element is missing \"name\" attribute",
-            css::uno::Reference< css::uno::XInterface >());
-    }
-    return attrName;
-}
-
-class ContentEnumeration:
-    public cppu::WeakImplHelper1< css::container::XEnumeration >,
-    private boost::noncopyable
-{
-public:
-    explicit ContentEnumeration(std::vector< css::uno::Any > const & factories):
-        factories_(factories), iterator_(factories_.begin()) {}
-
-private:
-    virtual ~ContentEnumeration() {}
-
-    virtual sal_Bool SAL_CALL hasMoreElements()
-        throw (css::uno::RuntimeException);
-
-    virtual css::uno::Any SAL_CALL nextElement()
-        throw (
-            css::container::NoSuchElementException,
-            css::lang::WrappedTargetException, css::uno::RuntimeException);
-
-    osl::Mutex mutex_;
-    std::vector< css::uno::Any > factories_;
-    std::vector< css::uno::Any >::const_iterator iterator_;
-};
-
-sal_Bool ContentEnumeration::hasMoreElements()
-    throw (css::uno::RuntimeException)
-{
-    osl::MutexGuard g(mutex_);
-    return iterator_ != factories_.end();
-}
-
-css::uno::Any ContentEnumeration::nextElement()
-    throw (
-        css::container::NoSuchElementException,
-        css::lang::WrappedTargetException, css::uno::RuntimeException)
-{
-    osl::MutexGuard g(mutex_);
-    if (iterator_ == factories_.end()) {
-        throw css::container::NoSuchElementException(
-            "Bootstrap service manager service enumerator has no more elements",
-            static_cast< cppu::OWeakObject * >(this));
-    }
-    return *iterator_++;
-}
-
-css::beans::Property getDefaultContextProperty() {
-    return css::beans::Property(
-        "DefaultContext", -1,
-        cppu::UnoType< css::uno::XComponentContext >::get(),
-        css::beans::PropertyAttribute::READONLY);
-}
-
-typedef cppu::WeakComponentImplHelper8<
-    css::lang::XServiceInfo, css::lang::XMultiServiceFactory,
-    css::lang::XMultiComponentFactory, css::container::XSet,
-    css::container::XContentEnumerationAccess, css::beans::XPropertySet,
-    css::beans::XPropertySetInfo, css::lang::XEventListener >
-ServiceManagerBase;
-
-class ServiceManager:
-    private osl::Mutex, public ServiceManagerBase, private boost::noncopyable
-{
-public:
-    explicit ServiceManager(rtl::OUString const & rdbUris):
-        ServiceManagerBase(*static_cast< osl::Mutex * >(this))
-    { readRdbs(rdbUris); }
-
-    using ServiceManagerBase::acquire;
-    using ServiceManagerBase::release;
-
-    void setContext(
-        css::uno::Reference< css::uno::XComponentContext > const & context)
-    {
-        assert(context.is());
-        assert(!context_.is());
-        context_ = context;
-    }
-
-    css::uno::Reference< css::uno::XComponentContext > getContext() const {
-        assert(context_.is());
-        return context_;
-    }
-
-    Data const & getData() const { return data_; }
-
-    void loadImplementation(
-        css::uno::Reference< css::uno::XComponentContext > const & context,
-        boost::shared_ptr< ImplementationInfo > const & info,
-        css::uno::Reference< css::lang::XSingleComponentFactory > * factory1,
-        css::uno::Reference< css::lang::XSingleServiceFactory > * factory2);
-
-    virtual rtl::OUString SAL_CALL getImplementationName()
-        throw (css::uno::RuntimeException);
-
-    virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
-        throw (css::uno::RuntimeException);
-
-    virtual css::uno::Sequence< rtl::OUString > SAL_CALL
-    getSupportedServiceNames() throw (css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
-        rtl::OUString const & aServiceSpecifier)
-        throw (css::uno::Exception, css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
-    createInstanceWithArguments(
-        rtl::OUString const & ServiceSpecifier,
-        css::uno::Sequence< css::uno::Any > const & Arguments)
-        throw (css::uno::Exception, css::uno::RuntimeException);
-
-    virtual css::uno::Sequence< rtl::OUString > SAL_CALL
-    getAvailableServiceNames() throw (css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
-    createInstanceWithContext(
-        rtl::OUString const & aServiceSpecifier,
-        css::uno::Reference< css::uno::XComponentContext > const & Context)
-        throw (css::uno::Exception, css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
-    createInstanceWithArgumentsAndContext(
-        rtl::OUString const & ServiceSpecifier,
-        css::uno::Sequence< css::uno::Any > const & Arguments,
-        css::uno::Reference< css::uno::XComponentContext > const & Context)
-        throw (css::uno::Exception, css::uno::RuntimeException);
-
-    virtual css::uno::Type SAL_CALL getElementType()
-        throw (css::uno::RuntimeException);
-
-    virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
-    createEnumeration() throw (css::uno::RuntimeException);
-
-    virtual sal_Bool SAL_CALL has(css::uno::Any const & aElement)
-        throw (css::uno::RuntimeException);
-
-    virtual void SAL_CALL insert(css::uno::Any const & aElement)
-        throw (
-            css::lang::IllegalArgumentException,
-            css::container::ElementExistException, css::uno::RuntimeException);
-
-    virtual void SAL_CALL remove(css::uno::Any const & aElement)
-        throw (
-            css::lang::IllegalArgumentException,
-            css::container::NoSuchElementException, css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
-    createContentEnumeration(rtl::OUString const & aServiceName)
-        throw (css::uno::RuntimeException);
-
-    virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
-    getPropertySetInfo() throw (css::uno::RuntimeException);
-
-    virtual void SAL_CALL setPropertyValue(
-        rtl::OUString const & aPropertyName, css::uno::Any const & aValue)
-        throw (
-            css::beans::UnknownPropertyException,
-            css::beans::PropertyVetoException,
-            css::lang::IllegalArgumentException,
-            css::lang::WrappedTargetException, css::uno::RuntimeException);
-

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list