Kaydet (Commit) 382b0132 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Some ConfigurationProvider -> theDefaultProvider simplifications

Change-Id: I7c25cd94f8a1ca339f7423c26f21f13c7a68906d
üst b45e8153
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "comphelper/makesequence.hxx" #include "comphelper/makesequence.hxx"
#include "comphelper/processfactory.hxx" #include "comphelper/processfactory.hxx"
#include "boost/optional.hpp" #include "boost/optional.hpp"
#include "com/sun/star/configuration/theDefaultProvider.hpp"
#include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/container/XNameAccess.hpp"
#include "com/sun/star/beans/Optional.hpp" #include "com/sun/star/beans/Optional.hpp"
#include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/beans/PropertyValue.hpp"
...@@ -374,12 +375,6 @@ void DescriptionInfoset::checkBlacklist() const ...@@ -374,12 +375,6 @@ void DescriptionInfoset::checkBlacklist() const
if (currentversion.getLength() == 0) if (currentversion.getLength() == 0)
return; // nothing to check return; // nothing to check
css::uno::Reference< css::lang::XMultiComponentFactory > manager(
m_context->getServiceManager(), css::uno::UNO_QUERY_THROW);
css::uno::Reference< css::lang::XMultiServiceFactory> provider(
manager->createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", m_context),
css::uno::UNO_QUERY_THROW);
css::uno::Sequence< css::uno::Any > args = css::uno::Sequence< css::uno::Any >(1); css::uno::Sequence< css::uno::Any > args = css::uno::Sequence< css::uno::Any >(1);
css::beans::PropertyValue prop; css::beans::PropertyValue prop;
prop.Name = "nodepath"; prop.Name = "nodepath";
...@@ -387,8 +382,10 @@ void DescriptionInfoset::checkBlacklist() const ...@@ -387,8 +382,10 @@ void DescriptionInfoset::checkBlacklist() const
args[0] <<= prop; args[0] <<= prop;
css::uno::Reference< css::container::XNameAccess > blacklist( css::uno::Reference< css::container::XNameAccess > blacklist(
provider->createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args), (css::configuration::theDefaultProvider::get(m_context)
css::uno::UNO_QUERY_THROW); ->createInstanceWithArguments(
"com.sun.star.configuration.ConfigurationAccess", args)),
css::uno::UNO_QUERY_THROW);
// check first if a blacklist entry is available // check first if a blacklist entry is available
if (blacklist.is() && blacklist->hasByName(*id)) { if (blacklist.is() && blacklist->hasByName(*id)) {
...@@ -412,7 +409,7 @@ void DescriptionInfoset::checkBlacklist() const ...@@ -412,7 +409,7 @@ void DescriptionInfoset::checkBlacklist() const
OString xmlDependencies = OUStringToOString(udeps, RTL_TEXTENCODING_UNICODE); OString xmlDependencies = OUStringToOString(udeps, RTL_TEXTENCODING_UNICODE);
css::uno::Reference< css::xml::dom::XDocumentBuilder> docbuilder( css::uno::Reference< css::xml::dom::XDocumentBuilder> docbuilder(
manager->createInstanceWithContext("com.sun.star.xml.dom.DocumentBuilder", m_context), m_context->getServiceManager()->createInstanceWithContext("com.sun.star.xml.dom.DocumentBuilder", m_context),
css::uno::UNO_QUERY_THROW); css::uno::UNO_QUERY_THROW);
css::uno::Sequence< sal_Int8 > byteSeq((const sal_Int8*)xmlDependencies.getStr(), xmlDependencies.getLength()); css::uno::Sequence< sal_Int8 > byteSeq((const sal_Int8*)xmlDependencies.getStr(), xmlDependencies.getLength());
......
...@@ -21,6 +21,7 @@ package complex.accelerators; ...@@ -21,6 +21,7 @@ package complex.accelerators;
import com.sun.star.awt.KeyEvent; import com.sun.star.awt.KeyEvent;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.configuration.theDefaultProvider;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.embed.XStorage; import com.sun.star.embed.XStorage;
import com.sun.star.embed.XTransactedObject; import com.sun.star.embed.XTransactedObject;
...@@ -750,7 +751,8 @@ public class AcceleratorsConfigurationTest ...@@ -750,7 +751,8 @@ public class AcceleratorsConfigurationTest
boolean bReadOnly) boolean bReadOnly)
throws java.lang.Exception throws java.lang.Exception
{ {
XMultiServiceFactory xConfigRoot = UnoRuntime.queryInterface(XMultiServiceFactory.class, xSMGR.createInstance("com.sun.star.configuration.ConfigurationProvider")); XMultiServiceFactory xConfigRoot = theDefaultProvider.get(
connection.getComponentContext());
PropertyValue[] lParams = new PropertyValue[2]; PropertyValue[] lParams = new PropertyValue[2];
lParams[0] = new PropertyValue(); lParams[0] = new PropertyValue();
......
...@@ -208,7 +208,7 @@ public class AutoSave ...@@ -208,7 +208,7 @@ public class AutoSave
// prepare AutoSave // prepare AutoSave
// make sure it will be started every 1 min // make sure it will be started every 1 min
ConfigHelper aConfig = new ConfigHelper(m_xSMGR, "org.openoffice.Office.Recovery", false); ConfigHelper aConfig = new ConfigHelper(connection.getComponentContext(), "org.openoffice.Office.Recovery", false);
aConfig.writeRelativeKey("AutoSave", "Enabled" , Boolean.TRUE ); aConfig.writeRelativeKey("AutoSave", "Enabled" , Boolean.TRUE );
aConfig.writeRelativeKey("AutoSave", "TimeIntervall", new Integer(1)); // 1 min aConfig.writeRelativeKey("AutoSave", "TimeIntervall", new Integer(1)); // 1 min
aConfig.flush(); aConfig.flush();
......
...@@ -20,24 +20,22 @@ package complex.framework.autosave; ...@@ -20,24 +20,22 @@ package complex.framework.autosave;
import com.sun.star.uno.*; import com.sun.star.uno.*;
import com.sun.star.lang.*; import com.sun.star.lang.*;
import com.sun.star.configuration.theDefaultProvider;
import com.sun.star.container.*; import com.sun.star.container.*;
import com.sun.star.beans.*; import com.sun.star.beans.*;
import com.sun.star.util.*; import com.sun.star.util.*;
class ConfigHelper class ConfigHelper
{ {
private XMultiServiceFactory m_xSMGR = null;
private XHierarchicalNameAccess m_xConfig = null; private XHierarchicalNameAccess m_xConfig = null;
//----------------------------------------------- //-----------------------------------------------
public ConfigHelper(XMultiServiceFactory xSMGR , public ConfigHelper(XComponentContext context,
String sConfigPath , String sConfigPath ,
boolean bReadOnly ) boolean bReadOnly )
throws com.sun.star.uno.Exception throws com.sun.star.uno.Exception
{ {
m_xSMGR = xSMGR; XMultiServiceFactory xConfigRoot = theDefaultProvider.get(context);
XMultiServiceFactory xConfigRoot = UnoRuntime.queryInterface(XMultiServiceFactory.class, m_xSMGR.createInstance("com.sun.star.configuration.ConfigurationProvider"));
PropertyValue[] lParams = new PropertyValue[1]; PropertyValue[] lParams = new PropertyValue[1];
lParams[0] = new PropertyValue(); lParams[0] = new PropertyValue();
......
...@@ -141,7 +141,7 @@ def __getprop__(name, value): ...@@ -141,7 +141,7 @@ def __getprop__(name, value):
p, p.Name, p.Value = __property__(), name, value p, p.Name, p.Value = __property__(), name, value
return p return p
__uilocale__ = uno.getComponentContext().ServiceManager.createInstance("com.sun.star.configuration.ConfigurationProvider").\ __uilocale__ = uno.getComponentContext().getValueByName("/singletons/com.sun.star.configuration.theDefaultProvider").\
createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",\ createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess",\
(__getprop__("nodepath", "/org.openoffice.Setup/L10N"),)).getByName("ooLocale") + '-' # handle missing Country of locale 'eo' (__getprop__("nodepath", "/org.openoffice.Setup/L10N"),)).getByName("ooLocale") + '-' # handle missing Country of locale 'eo'
......
...@@ -30,6 +30,7 @@ package com.sun.star.comp.Calc.NLPSolver; ...@@ -30,6 +30,7 @@ package com.sun.star.comp.Calc.NLPSolver;
import com.sun.star.beans.PropertyState; import com.sun.star.beans.PropertyState;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.configuration.theDefaultProvider;
import com.sun.star.deployment.PackageInformationProvider; import com.sun.star.deployment.PackageInformationProvider;
import com.sun.star.deployment.XPackageInformationProvider; import com.sun.star.deployment.XPackageInformationProvider;
import com.sun.star.lang.Locale; import com.sun.star.lang.Locale;
...@@ -60,8 +61,7 @@ public class ResourceManager { ...@@ -60,8 +61,7 @@ public class ResourceManager {
m_resourceBaseUrl = m_oxtRoot + relativeResourceBaseUrl; m_resourceBaseUrl = m_oxtRoot + relativeResourceBaseUrl;
try { try {
XMultiServiceFactory xConfig = UnoRuntime.queryInterface(XMultiServiceFactory.class, XMultiServiceFactory xConfig = theDefaultProvider.get(m_context);
m_context.getServiceManager().createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", m_context));
Object[] args = new Object[1]; Object[] args = new Object[1];
args[0] = new PropertyValue("nodepath", 0, "/org.openoffice.Setup/L10N", PropertyState.DIRECT_VALUE); args[0] = new PropertyValue("nodepath", 0, "/org.openoffice.Setup/L10N", PropertyState.DIRECT_VALUE);
...@@ -95,4 +95,4 @@ public class ResourceManager { ...@@ -95,4 +95,4 @@ public class ResourceManager {
} }
} }
} }
\ No newline at end of file
...@@ -76,6 +76,7 @@ import com.sun.star.awt.XWindowPeer; ...@@ -76,6 +76,7 @@ import com.sun.star.awt.XWindowPeer;
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XMultiPropertySet; import com.sun.star.beans.XMultiPropertySet;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.configuration.theDefaultProvider;
import com.sun.star.container.XIndexContainer; import com.sun.star.container.XIndexContainer;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer; import com.sun.star.container.XNameContainer;
...@@ -193,13 +194,11 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis ...@@ -193,13 +194,11 @@ public class UnoDialogSample implements XTextListener, XSpinListener, XActionLis
*/ */
public XNameAccess getRegistryKeyContent(String _sKeyName){ public XNameAccess getRegistryKeyContent(String _sKeyName){
try { try {
Object oConfigProvider;
PropertyValue[] aNodePath = new PropertyValue[1]; PropertyValue[] aNodePath = new PropertyValue[1];
oConfigProvider = m_xMCF.createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", this.m_xContext); XMultiServiceFactory xMSFConfig = theDefaultProvider.get(m_xContext);
aNodePath[0] = new PropertyValue(); aNodePath[0] = new PropertyValue();
aNodePath[0].Name = "nodepath"; aNodePath[0].Name = "nodepath";
aNodePath[0].Value = _sKeyName; aNodePath[0].Value = _sKeyName;
XMultiServiceFactory xMSFConfig = UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider);
Object oNode = xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath); Object oNode = xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath);
XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, oNode); XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, oNode);
return xNameAccess; return xNameAccess;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
* *
*************************************************************************/ *************************************************************************/
import com.sun.star.configuration.theDefaultProvider;
import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XComponentContext;
import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiComponentFactory;
...@@ -79,11 +80,7 @@ public class DisableCommandsTest extends java.lang.Object { ...@@ -79,11 +80,7 @@ public class DisableCommandsTest extends java.lang.Object {
xTransformer = UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, xTransformer = UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class,
transformer ); transformer );
Object configProvider = xRemoteServiceManager.createInstanceWithContext( xConfigProvider = theDefaultProvider.get(xRemoteContext);
"com.sun.star.configuration.ConfigurationProvider",
xRemoteContext );
xConfigProvider = UnoRuntime.queryInterface(
com.sun.star.lang.XMultiServiceFactory.class, configProvider );
// create a new test document // create a new test document
Object oDesktop = xRemoteServiceManager.createInstanceWithContext( Object oDesktop = xRemoteServiceManager.createInstanceWithContext(
......
...@@ -20,6 +20,7 @@ import java.awt.Dimension; ...@@ -20,6 +20,7 @@ import java.awt.Dimension;
import java.util.ArrayList; import java.util.ArrayList;
import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySet;
import com.sun.star.configuration.theDefaultProvider;
import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameAccess;
import com.sun.star.embed.VisualRepresentation; import com.sun.star.embed.VisualRepresentation;
import com.sun.star.embed.XStorage; import com.sun.star.embed.XStorage;
...@@ -29,7 +30,6 @@ import com.sun.star.io.XOutputStream; ...@@ -29,7 +30,6 @@ import com.sun.star.io.XOutputStream;
import com.sun.star.io.XStream; import com.sun.star.io.XStream;
import com.sun.star.io.XTruncate; import com.sun.star.io.XTruncate;
import com.sun.star.lang.XComponent; import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
...@@ -987,9 +987,7 @@ public final class OwnEmbeddedObject extends WeakBase ...@@ -987,9 +987,7 @@ public final class OwnEmbeddedObject extends WeakBase
{ {
try try
{ {
XMultiComponentFactory xFactory = m_xContext.getServiceManager(); XMultiServiceFactory xConfProvider = theDefaultProvider.get(m_xContext);
Object obj = xFactory.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", m_xContext );
XMultiServiceFactory xConfProvider = UnoRuntime.queryInterface( XMultiServiceFactory.class, obj );
if ( xConfProvider == null ) if ( xConfProvider == null )
throw new com.sun.star.uno.RuntimeException(); throw new com.sun.star.uno.RuntimeException();
......
...@@ -1334,8 +1334,9 @@ void JavaVirtualMachine::registerConfigChangesListener() ...@@ -1334,8 +1334,9 @@ void JavaVirtualMachine::registerConfigChangesListener()
try try
{ {
css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
m_xContext->getServiceManager()->createInstanceWithContext( OUString( m_xContext->getValueByName(
"com.sun.star.configuration.ConfigurationProvider"), m_xContext), css::uno::UNO_QUERY); "/singletons/com.sun.star.configuration.theDefaultProvider"),
css::uno::UNO_QUERY);
if (xConfigProvider.is()) if (xConfigProvider.is())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment