[Libreoffice-commits] .: Branch 'feature/cmclayout' - 3 commits - Repository.mk vcl/Executable_ui-previewer.mk vcl/inc vcl/Library_vcl.mk vcl/Module_vcl.mk vcl/Package_inc.mk vcl/qa vcl/source vcl/unx

Caolán McNamara caolan at kemper.freedesktop.org
Mon Mar 26 04:30:27 PDT 2012


 Repository.mk                         |    1 
 vcl/Executable_ui-previewer.mk        |   58 +++++++++
 vcl/Library_vcl.mk                    |    2 
 vcl/Module_vcl.mk                     |    1 
 vcl/Package_inc.mk                    |    1 
 vcl/inc/vcl/builder.hxx               |   53 ++++++++
 vcl/qa/cppunit/builder/demo.ui        |   72 +++++++++++
 vcl/source/uipreviewer/previewer.cxx  |   93 +++++++++++++++
 vcl/source/window/builder.cxx         |  208 ++++++++++++++++++++++++++++++++++
 vcl/unx/generic/plugadapt/salplug.cxx |   15 +-
 10 files changed, 499 insertions(+), 5 deletions(-)

New commits:
commit ceda7a38206766aa20db3fca391a0835a2a8b9eb
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 26 12:16:40 2012 +0100

    add header

diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx
index 9b5fa91..9f3bdb2 100644
--- a/vcl/source/uipreviewer/previewer.cxx
+++ b/vcl/source/uipreviewer/previewer.cxx
@@ -1,4 +1,31 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Caolán McNamara <caolanm at redhat.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
commit f9ba39d2136f21fbdb45f40814592f303bdb8ace
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 26 12:15:22 2012 +0100

    bootstrap a ui-previewer for rendering GtkBuilder xml with vcl widgets

diff --git a/Repository.mk b/Repository.mk
index 8e9b6d9..1b0f0c1 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -55,6 +55,7 @@ $(eval $(call gb_Helper_register_executables,OOO, \
 	$(if $(filter $(GUIBASE)$(ENABLE_KDE),unxTRUE), \
 		kdefilepicker \
 	) \
+	ui-previewer \
 ))
 
 ifeq ($(OS),WNT)
diff --git a/vcl/Executable_ui-previewer.mk b/vcl/Executable_ui-previewer.mk
new file mode 100644
index 0000000..0bad665
--- /dev/null
+++ b/vcl/Executable_ui-previewer.mk
@@ -0,0 +1,58 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+# Version: MPL 1.1 / GPLv3+ / LGPLv3+
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License or as specified alternatively below. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# Major Contributor(s):
+# Copyright (C) 2012 Red Hat, Inc., Caolán McNamara <caolanm at redhat.com>
+#  (initial developer)
+#
+# All Rights Reserved.
+#
+# For minor contributions see the git repository.
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+# instead of those above.
+
+$(eval $(call gb_Executable_Executable,ui-previewer))
+
+$(eval $(call gb_Executable_set_include,ui-previewer,\
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_Executable_add_api,ui-previewer,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_Executable_add_linked_static_libs,ui-previewer,\
+    vclmain \
+))
+
+$(eval $(call gb_Executable_add_linked_libs,ui-previewer,\
+	comphelper \
+	cppu \
+	cppuhelper \
+	sal \
+    tl \
+    ucbhelper \
+    vcl \
+    $(gb_STDLIBS) \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,ui-previewer,\
+    vcl/source/uipreviewer/previewer \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a0037a9..17c3a50 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -76,6 +76,7 @@ $(eval $(call gb_Library_add_linked_libs,vcl,\
     i18nutil \
     cppu \
     sal \
+    xmlreader \
     $(gb_STDLIBS) \
 ))
 
@@ -229,6 +230,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/window/arrange \
     vcl/source/window/brdwin \
     vcl/source/window/btndlg \
+    vcl/source/window/builder \
     vcl/source/window/cmdevt \
     vcl/source/window/cursor \
     vcl/source/window/decoview \
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index dfd0e34..5912710 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
     Package_inc \
 	Package_afmhash \
     AllLangResTarget_vcl \
+	Executable_ui-previewer \
 ))
 
 ifeq ($(GUIBASE),unx)
diff --git a/vcl/Package_inc.mk b/vcl/Package_inc.mk
index 63074fc..d309efd 100644
--- a/vcl/Package_inc.mk
+++ b/vcl/Package_inc.mk
@@ -37,6 +37,7 @@ $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/bitmapex.hxx,vcl/bitmapex.hxx)
 $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/bitmap.hxx,vcl/bitmap.hxx))
 $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/bmpacc.hxx,vcl/bmpacc.hxx))
 $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/btndlg.hxx,vcl/btndlg.hxx))
+$(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/builder.hxx,vcl/builder.hxx))
 $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/button.hxx,vcl/button.hxx))
 $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/canvastools.hxx,vcl/canvastools.hxx))
 $(eval $(call gb_Package_add_file,vcl_inc,inc/vcl/cmdevt.h,vcl/cmdevt.h))
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
new file mode 100644
index 0000000..4c2ce32
--- /dev/null
+++ b/vcl/inc/vcl/builder.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Caolán McNamara <caolanm at redhat.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef _VCLBUILDER_HXX
+#define _VCLBUILDER_HXX
+
+#include <vcl/dllapi.h>
+#include <vcl/window.hxx>
+#include <xmlreader/xmlreader.hxx>
+#include <vector>
+
+class VCL_DLLPUBLIC VclBuilder
+{
+private:
+    std::vector<Window*> m_aChildren;
+public:
+    VclBuilder(Window *pParent, rtl::OUString sUIFile);
+    ~VclBuilder();
+    Window *get_widget_root();
+private:
+    Window *makeObject(Window *pParent, xmlreader::Span &name);
+
+    void handleObject(Window *pParent, xmlreader::XmlReader &reader);
+    void handleProperty(Window *pWindow, xmlreader::XmlReader &reader);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/builder/demo.ui b/vcl/qa/cppunit/builder/demo.ui
new file mode 100644
index 0000000..d6bd41b
--- /dev/null
+++ b/vcl/qa/cppunit/builder/demo.ui
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkDialog" id="dialog1">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="type_hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can_focus">False</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button2">
+                <property name="label">Hello</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button1">
+                <property name="label">World</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Hello World</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">button2</action-widget>
+      <action-widget response="0">button1</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/vcl/source/uipreviewer/previewer.cxx b/vcl/source/uipreviewer/previewer.cxx
new file mode 100644
index 0000000..9b5fa91
--- /dev/null
+++ b/vcl/source/uipreviewer/previewer.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <ucbhelper/configurationkeys.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <vcl/builder.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/svapp.hxx>
+
+class UIPreviewApp : public Application
+{
+public:
+    virtual int Main();
+};
+
+using namespace com::sun::star;
+
+int UIPreviewApp::Main()
+{
+    std::vector<rtl::OUString> uifiles;
+    for (sal_uInt16 i = 0; i < GetCommandLineParamCount(); ++i)
+        uifiles.push_back(GetCommandLineParam(i));
+
+    if (uifiles.empty())
+    {
+        fprintf(stderr, "Usage: ui-previewer file.ui\n");
+        return EXIT_FAILURE;
+    }
+
+    uno::Reference<uno::XComponentContext> xContext =
+        cppu::defaultBootstrap_InitialComponentContext();
+    uno::Reference<lang::XMultiComponentFactory> xFactory =
+        xContext->getServiceManager();
+    uno::Reference<lang::XMultiServiceFactory> xSFactory =
+        uno::Reference<lang::XMultiServiceFactory> (xFactory, uno::UNO_QUERY_THROW);
+    comphelper::setProcessServiceFactory(xSFactory);
+
+    // Create UCB.
+    uno::Sequence< uno::Any > aArgs(2);
+    aArgs[ 0 ] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY1_LOCAL));
+    aArgs[ 1 ] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UCB_CONFIGURATION_KEY2_OFFICE));
+    ::ucbhelper::ContentBroker::initialize(xSFactory, aArgs);
+
+    VclBuilder aBuilder(NULL, uifiles[0]);
+    Window *pWindow = aBuilder.get_widget_root();
+    Dialog *pDialog = dynamic_cast<Dialog*>(pWindow);
+    if (pDialog)
+    {
+        pDialog->Execute();
+    }
+    else
+    {
+        fprintf(stderr, "to-do: no toplevel dialog, make one\n");
+    }
+
+    ::ucbhelper::ContentBroker::deinitialize();
+
+    return EXIT_SUCCESS;
+}
+
+UIPreviewApp aApp;
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
new file mode 100644
index 0000000..0378ea9
--- /dev/null
+++ b/vcl/source/window/builder.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *        Caolán McNamara <caolanm at redhat.com> (Red Hat, Inc.)
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Caolán McNamara <caolanm at redhat.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include <vcl/builder.hxx>
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/layout.hxx>
+
+VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri)
+{
+    xmlreader::XmlReader reader(sUri);
+
+    while(1)
+    {
+        xmlreader::Span name;
+        int nsId;
+        xmlreader::XmlReader::Result res = reader.nextItem(
+            xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+
+        if (res == xmlreader::XmlReader::RESULT_BEGIN &&
+            name.equals(RTL_CONSTASCII_STRINGPARAM("object")))
+        {
+            handleObject(pParent, reader);
+        }
+
+        rtl::OString sFoo(name.begin, name.length);
+        fprintf(stderr, "interface level is %s\n", sFoo.getStr());
+        if (res == xmlreader::XmlReader::RESULT_DONE)
+            break;
+    }
+
+    for (std::vector<Window*>::iterator aI = m_aChildren.begin(),
+         aEnd = m_aChildren.end(); aI != aEnd; ++aI)
+    {
+        Window *pWindow = *aI;
+        if (pWindow)
+        {
+            pWindow->Show();
+        }
+    }
+}
+
+VclBuilder::~VclBuilder()
+{
+    for (std::vector<Window*>::reverse_iterator aI = m_aChildren.rbegin(),
+         aEnd = m_aChildren.rend(); aI != aEnd; ++aI)
+    {
+        Window *pWindow = *aI;
+        delete pWindow;
+    }
+}
+
+Window *VclBuilder::makeObject(Window *pParent, xmlreader::Span &name)
+{
+    Window *pWindow = NULL;
+    if (name.equals(RTL_CONSTASCII_STRINGPARAM("GtkDialog")))
+    {
+        pWindow = new Dialog(pParent, WB_SIZEMOVE);
+    }
+    else if (name.equals(RTL_CONSTASCII_STRINGPARAM("GtkBox")))
+    {
+        pWindow = new VclHBox(pParent);
+    }
+    else if (name.equals(RTL_CONSTASCII_STRINGPARAM("GtkButton")))
+    {
+        pWindow = new PushButton(pParent);
+    }
+    else if (name.equals(RTL_CONSTASCII_STRINGPARAM("GtkLabel")))
+    {
+        pWindow = new FixedText(pParent);
+    }
+    else
+    {
+        fprintf(stderr, "TO-DO, implement %s\n",
+            rtl::OString(name.begin, name.length).getStr());
+    }
+    fprintf(stderr, "created %p child of %p\n", pWindow, pParent);
+    return pWindow;
+}
+
+void VclBuilder::handleObject(Window *pParent, xmlreader::XmlReader &reader)
+{
+    Window *pCurrentChild = NULL;
+
+    xmlreader::Span name;
+    int nsId;
+
+    while (reader.nextAttribute(&nsId, &name)) {
+        rtl::OString sFoo(name.begin, name.length);
+        fprintf(stderr, "objectlevel attribute: is %s\n", sFoo.getStr());
+
+        if (name.equals(RTL_CONSTASCII_STRINGPARAM("class")))
+        {
+            name = reader.getAttributeValue(false);
+            pCurrentChild = makeObject(pParent, name);
+            if (!pCurrentChild)
+            {
+                fprintf(stderr, "missing object!\n");
+            }
+
+            if (pCurrentChild)
+                m_aChildren.push_back(pCurrentChild);
+        }
+    }
+
+    if (!pCurrentChild)
+    {
+        fprintf(stderr, "missing object!\n");
+        pCurrentChild = m_aChildren.empty() ? pParent : m_aChildren.back();
+    }
+
+    int nLevel = 1;
+
+    while(1)
+    {
+        xmlreader::XmlReader::Result res = reader.nextItem(
+            xmlreader::XmlReader::TEXT_NONE, &name, &nsId);
+
+        if (res == xmlreader::XmlReader::RESULT_DONE)
+            break;
+
+        rtl::OString sFoo(name.begin, name.length);
+        fprintf(stderr, "objectlevel: is %s %d\n", sFoo.getStr(),
+            res);
+
+        if (res == xmlreader::XmlReader::RESULT_BEGIN)
+            ++nLevel;
+
+        if (res == xmlreader::XmlReader::RESULT_BEGIN &&
+            name.equals(RTL_CONSTASCII_STRINGPARAM("object")))
+        {
+            handleObject(pCurrentChild, reader);
+        }
+
+        if (res == xmlreader::XmlReader::RESULT_BEGIN &&
+            name.equals(RTL_CONSTASCII_STRINGPARAM("property")))
+        {
+            handleProperty(pCurrentChild, reader);
+        }
+
+        if (res == xmlreader::XmlReader::RESULT_END)
+        {
+            --nLevel;
+        }
+
+        if (!nLevel)
+            break;
+    }
+}
+
+void VclBuilder::handleProperty(Window *pWindow, xmlreader::XmlReader &reader)
+{
+    if (!pWindow)
+        return;
+
+    xmlreader::Span name;
+    int nsId;
+
+    while (reader.nextAttribute(&nsId, &name)) {
+        rtl::OString sFoo(name.begin, name.length);
+        fprintf(stderr, "property attribute: is %s\n", sFoo.getStr());
+
+        if (name.equals(RTL_CONSTASCII_STRINGPARAM("name")))
+        {
+            name = reader.getAttributeValue(false);
+            if (name.equals(RTL_CONSTASCII_STRINGPARAM("label")))
+            {
+                reader.nextItem(
+                    xmlreader::XmlReader::TEXT_NORMALIZED, &name, &nsId);
+                pWindow->SetText(rtl::OUString(name.begin, name.length, RTL_TEXTENCODING_UTF8));
+            }
+        }
+    }
+}
+
+
+Window *VclBuilder::get_widget_root()
+{
+    return m_aChildren.empty() ? NULL : m_aChildren[0];
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4b2917ca6d2c0b791ae0d8b9d049431b5f9358c3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Mar 26 09:55:29 2012 +0100

    configuration checked before component context exists
    
    in simple applications, e.g. spadmin, which don't have a custom main, then this
    configuration check happens too early before Application::Main gets run to have
    a chance to set the ProcessComponentContext.

diff --git a/vcl/unx/generic/plugadapt/salplug.cxx b/vcl/unx/generic/plugadapt/salplug.cxx
index 6bc7d89..b92c8c7 100644
--- a/vcl/unx/generic/plugadapt/salplug.cxx
+++ b/vcl/unx/generic/plugadapt/salplug.cxx
@@ -28,6 +28,8 @@
 
 #include "officecfg/Office/Common.hxx"
 
+#include "comphelper/processfactory.hxx"
+
 #include "osl/module.h"
 #include "osl/process.h"
 
@@ -54,11 +56,14 @@ static SalInstance* tryInstance( const OUString& rModuleBase, bool bForce = fals
 {
     SalInstance* pInst = NULL;
 #if !defined(ANDROID)
-    // Disable gtk3 plugin load except in experimental mode for now.
-    if( !bForce &&
-        rModuleBase.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "gtk3" ) ) &&
-        !officecfg::Office::Common::Misc::ExperimentalMode::get() )
-        return NULL;
+    if (!bForce && rModuleBase.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("gtk3")))
+    {
+        // Disable gtk3 plugin load except in experimental mode for now.
+        using namespace com::sun::star;
+        uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
+        if (!xContext.is() || !officecfg::Office::Common::Misc::ExperimentalMode::get(xContext))
+            return NULL;
+    }
 #endif
     OUStringBuffer aModName( 128 );
     aModName.appendAscii( SAL_DLLPREFIX"vclplug_" );


More information about the Libreoffice-commits mailing list