[Libreoffice-commits] core.git: Branch 'feature/liblibo' - desktop/source

Michael Meeks michael.meeks at suse.com
Tue Mar 5 05:31:48 PST 2013


 desktop/source/lib/init.cxx |   90 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 82 insertions(+), 8 deletions(-)

New commits:
commit 7f141a511f5e25be12a8df416980ef0ad8d5641a
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Tue Mar 5 13:30:51 2013 +0000

    liblibo: start of initial bootstrapping.
    
    Change-Id: I929888b1f4ebacff348a55afa3c992a9c9e9e9a2

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d3c2e98..cd8ce9f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /*
  * This file is part of the LibreOffice project.
  *
@@ -8,8 +8,31 @@
  */
 
 #include <stdio.h>
+
 #include <liblibreoffice.h>
+#include <tools/errinf.hxx>
+#include <rtl/strbuf.hxx>
+#include <rtl/bootstrap.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
+
+#include <vcl/svapp.hxx>
+#include <tools/resmgr.hxx>
+#include <vcl/graphicfilter.hxx>
+#include <unotools/syslocaleoptions.hxx>
 
+using namespace ::com::sun::star;
+
+// Wonder global state ...
+static uno::Reference<css::uno::XComponentContext> xContext;
+static uno::Reference<css::lang::XMultiServiceFactory> xSFactory;
+static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
 
 void lo_error_free( LOError * )
 {
@@ -17,24 +40,75 @@ void lo_error_free( LOError * )
 
 LOError *lo_error_new( int, const char * )
 {
-  return NULL;
+    return NULL;
 }
 
 LODocument *
-lo_document_load (const char *, LOError ** )
+lo_document_load( const char *, LOError ** )
 {
-  return NULL;
+    return NULL;
 }
 
 loboolean
-lo_document_save (const char *, LOError ** )
+lo_document_save( const char *, LOError ** )
 {
-  return 1;
+    return 1;
 }
 
-void lo_initialize(const char *)
+static void
+force_c_locale( void )
 {
-  fprintf (stderr, "do nothing yet");
+    // force locale (and resource files loaded) to en-US
+    css::lang::Locale aLocale( "en", "US", "");
+    ResMgr::SetDefaultLocale( aLocale );
+    SvtSysLocaleOptions aLocalOptions;
+    OUString aLangISO( "en-US" );
+    aLocalOptions.SetLocaleConfigString( aLangISO );
+    aLocalOptions.SetUILocaleConfigString( aLangISO );
+}
+
+static void
+aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
+{
+    OStringBuffer aErr( "Unexpected dialog: " );
+    aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) );
+    aErr.append( " Error: " );
+    aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) );
+    fprintf( stderr, "Unexpected basic error dialog '%s'\n", aErr.getStr() );
+}
+
+static void
+initialize_uno( void )
+{
+    // set UserInstallation to user profile dir in test/user-template
+    rtl::Bootstrap aDefaultVars;
+    // madness ...
+    fprintf(stderr, "trying to bootstrap with no user install !\n");
+/*    rtl::OUString sUserInstallURL = m_aSolverRootURL + rtl::OUString("/unittest");
+      aDefaultVars.set(rtl::OUString("UserInstallation"), sUserInstallURL); */
+
+    xContext = comphelper::getProcessComponentContext();
+    xFactory = xContext->getServiceManager();
+    xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
+}
+
+void lo_initialize( const char * )
+{
+    try {
+        initialize_uno();
+        force_c_locale();
+        InitVCL();
+        if (Application::IsHeadlessModeRequested())
+            Application::EnableHeadlessMode(true);
+
+        ErrorHandler::RegisterDisplay( aBasicErrorFunc );
+
+        fprintf (stderr, "do nothing yet");
+    } catch (css::uno::Exception & e) {
+        fprintf( stderr, "bootstrapping exception '%s'\n",
+                 OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+


More information about the Libreoffice-commits mailing list