[Libreoffice-commits] core.git: 3 commits - comphelper/source comphelper/util framework/source
Matúš Kukan
matus.kukan at gmail.com
Sun Dec 27 04:55:17 PST 2015
comphelper/source/inc/comphelper_services.hxx | 2
comphelper/source/misc/comphelper_services.cxx | 2
comphelper/source/misc/officerestartmanager.cxx | 59 +++----
comphelper/source/misc/officerestartmanager.hxx | 10 -
comphelper/source/officeinstdir/officeinstallationdirectories.cxx | 83 +++-------
comphelper/source/officeinstdir/officeinstallationdirectories.hxx | 8
comphelper/util/comphelp.component | 6
framework/source/helper/persistentwindowstate.cxx | 51 +-----
8 files changed, 77 insertions(+), 144 deletions(-)
New commits:
commit 4db23a9d17cccc2103b72506e3837a3b6576c181
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Dec 26 22:39:08 2015 +0100
tdf#74608: Constructor function for OfficeInstallationDirectories singleton
Change-Id: Ia0de503c50b6b1d568df27f6a8139fdcc8d0cfbf
diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx
index 08ed94d..d62a16a 100644
--- a/comphelper/source/inc/comphelper_services.hxx
+++ b/comphelper/source/inc/comphelper_services.hxx
@@ -29,7 +29,6 @@ void createRegistryInfo_NamedPropertyValuesContainer();
void createRegistryInfo_OInstanceLocker();
void createRegistryInfo_OPropertyBag();
void createRegistryInfo_OSimpleLogRing();
-void createRegistryInfo_OfficeInstallationDirectories();
void createRegistryInfo_SequenceInputStream();
void createRegistryInfo_SequenceOutputStream();
void createRegistryInfo_UNOMemoryStream();
diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx
index 122f192..979cd36 100644
--- a/comphelper/source/misc/comphelper_services.cxx
+++ b/comphelper/source/misc/comphelper_services.cxx
@@ -41,7 +41,6 @@ namespace comphelper { namespace module
createRegistryInfo_IndexedPropertyValuesContainer();
createRegistryInfo_NamedPropertyValuesContainer();
createRegistryInfo_AnyCompareFactory();
- createRegistryInfo_OfficeInstallationDirectories();
createRegistryInfo_OInstanceLocker();
createRegistryInfo_Map();
createRegistryInfo_OSimpleLogRing();
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
index ca2aa0d..6342182 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
@@ -19,8 +19,6 @@
#include <config_folders.h>
-#include "comphelper_module.hxx"
-#include "comphelper_services.hxx"
#include <cppuhelper/supportsservice.hxx>
/**************************************************************************
@@ -30,7 +28,7 @@
*************************************************************************/
#include <osl/file.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
+#include <rtl/ref.hxx>
#include <com/sun/star/util/theMacroExpander.hpp>
#include <comphelper/fileurl.hxx>
@@ -38,13 +36,6 @@
using namespace com::sun::star;
-using namespace comphelper;
-
-
-// helpers
-
-
-
static bool makeCanonicalFileURL( OUString & rURL )
{
OSL_ENSURE(comphelper::isFileUrl(rURL), "File URL expected!");
@@ -82,13 +73,7 @@ static bool makeCanonicalFileURL( OUString & rURL )
return false;
}
-
-
-
-// OfficeInstallationDirectories Implementation.
-
-
-
+namespace comphelper {
OfficeInstallationDirectories::OfficeInstallationDirectories(
const uno::Reference< uno::XComponentContext > & xCtx )
@@ -212,7 +197,7 @@ OUString SAL_CALL
OfficeInstallationDirectories::getImplementationName()
throw ( uno::RuntimeException, std::exception )
{
- return getImplementationName_static();
+ return OUString("com.sun.star.comp.util.OfficeInstallationDirectories");
}
// virtual
@@ -228,40 +213,9 @@ uno::Sequence< OUString > SAL_CALL
OfficeInstallationDirectories::getSupportedServiceNames()
throw ( uno::RuntimeException, std::exception )
{
- return getSupportedServiceNames_static();
-}
-
-
-// static
-OUString SAL_CALL
-OfficeInstallationDirectories::getImplementationName_static()
-{
- return OUString("com.sun.star.comp.util.OfficeInstallationDirectories");
-}
-
-
-// static
-uno::Sequence< OUString > SAL_CALL
-OfficeInstallationDirectories::getSupportedServiceNames_static()
-{
- const OUString aServiceName("com.sun.star.util.OfficeInstallationDirectories");
- return uno::Sequence< OUString >( &aServiceName, 1 );
-}
-
-
-// static
-uno::Reference< uno::XInterface > SAL_CALL
-OfficeInstallationDirectories::Create(
- const uno::Reference< uno::XComponentContext > & rxContext )
-{
- return static_cast< cppu::OWeakObject * >(
- new OfficeInstallationDirectories( rxContext ) );
+ return { "com.sun.star.util.OfficeInstallationDirectories" };
}
-
-// non-UNO
-
-
void OfficeInstallationDirectories::initDirs()
{
if ( m_pOfficeBrandDir == nullptr )
@@ -293,9 +247,34 @@ void OfficeInstallationDirectories::initDirs()
}
}
-void createRegistryInfo_OfficeInstallationDirectories()
+}
+
+namespace {
+
+struct Instance {
+ explicit Instance(
+ css::uno::Reference<css::uno::XComponentContext> const & context):
+ instance(static_cast<cppu::OWeakObject *>(
+ new comphelper::OfficeInstallationDirectories(context)))
+ {}
+
+ rtl::Reference<css::uno::XInterface> instance;
+};
+
+struct Singleton:
+ public rtl::StaticWithArg<
+ Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_util_OfficeInstallationDirectories(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
{
- static ::comphelper::module::OSingletonRegistration< OfficeInstallationDirectories > aAutoRegistration;
+ return cppu::acquire(static_cast<cppu::OWeakObject *>(
+ Singleton::get(context).instance.get()));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
index 40c3fd0..88e8341 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
@@ -72,14 +72,6 @@ public:
getSupportedServiceNames()
throw (css::uno::RuntimeException, std::exception) override;
- // XServiceInfo - static versions (used for component registration)
- static OUString SAL_CALL
- getImplementationName_static();
- static css::uno::Sequence< OUString > SAL_CALL
- getSupportedServiceNames_static();
- static css::uno::Reference< css::uno::XInterface > SAL_CALL
- Create( const css::uno::Reference< css::uno::XComponentContext >& );
-
private:
void initDirs();
diff --git a/comphelper/util/comphelp.component b/comphelper/util/comphelp.component
index 95432c6..3a6803f 100644
--- a/comphelper/util/comphelp.component
+++ b/comphelper/util/comphelp.component
@@ -52,7 +52,8 @@
<service name="com.sun.star.comp.task.OfficeRestartManager"/>
<singleton name="com.sun.star.task.OfficeRestartManager"/>
</implementation>
- <implementation name="com.sun.star.comp.util.OfficeInstallationDirectories">
+ <implementation name="com.sun.star.comp.util.OfficeInstallationDirectories"
+ constructor="com_sun_star_comp_util_OfficeInstallationDirectories">
<service name="com.sun.star.util.OfficeInstallationDirectories"/>
<singleton name="com.sun.star.util.theOfficeInstallationDirectories"/>
</implementation>
commit 9e3c7725909ebce86e30f1e774d5f9e1d761c16a
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Dec 26 22:18:38 2015 +0100
tdf#74608: Constructor function for OfficeRestartManager singleton
Change-Id: I6c1383c292418b6744dacee95d4f289a6ca1c781
diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx
index 77d4dd9..08ed94d 100644
--- a/comphelper/source/inc/comphelper_services.hxx
+++ b/comphelper/source/inc/comphelper_services.hxx
@@ -27,7 +27,6 @@ void createRegistryInfo_IndexedPropertyValuesContainer();
void createRegistryInfo_Map();
void createRegistryInfo_NamedPropertyValuesContainer();
void createRegistryInfo_OInstanceLocker();
-void createRegistryInfo_OOfficeRestartManager();
void createRegistryInfo_OPropertyBag();
void createRegistryInfo_OSimpleLogRing();
void createRegistryInfo_OfficeInstallationDirectories();
diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx
index e86055c..122f192 100644
--- a/comphelper/source/misc/comphelper_services.cxx
+++ b/comphelper/source/misc/comphelper_services.cxx
@@ -45,7 +45,6 @@ namespace comphelper { namespace module
createRegistryInfo_OInstanceLocker();
createRegistryInfo_Map();
createRegistryInfo_OSimpleLogRing();
- createRegistryInfo_OOfficeRestartManager();
}
};
diff --git a/comphelper/source/misc/officerestartmanager.cxx b/comphelper/source/misc/officerestartmanager.cxx
index 54bdac9..a889528 100644
--- a/comphelper/source/misc/officerestartmanager.cxx
+++ b/comphelper/source/misc/officerestartmanager.cxx
@@ -23,9 +23,8 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <comphelper_module.hxx>
-#include <comphelper_services.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
#include "officerestartmanager.hxx"
using namespace ::com::sun::star;
@@ -33,31 +32,6 @@ using namespace ::com::sun::star;
namespace comphelper
{
-
-uno::Sequence< OUString > SAL_CALL OOfficeRestartManager::getSupportedServiceNames_static()
-{
- uno::Sequence<OUString> aResult { getServiceName_static() };
- return aResult;
-}
-
-
-OUString SAL_CALL OOfficeRestartManager::getImplementationName_static()
-{
- return OUString( "com.sun.star.comp.task.OfficeRestartManager" );
-}
-
-
-OUString SAL_CALL OOfficeRestartManager::getServiceName_static()
-{
- return OUString( "com.sun.star.comp.task.OfficeRestartManager" );
-}
-
-
-uno::Reference< uno::XInterface > SAL_CALL OOfficeRestartManager::Create( const uno::Reference< uno::XComponentContext >& rxContext )
-{
- return static_cast< cppu::OWeakObject* >( new OOfficeRestartManager( rxContext ) );
-}
-
// XRestartManager
void SAL_CALL OOfficeRestartManager::requestRestart( const uno::Reference< task::XInteractionHandler >& /* xInteractionHandler */ )
@@ -160,7 +134,7 @@ void SAL_CALL OOfficeRestartManager::notify( const uno::Any& /* aData */ )
OUString SAL_CALL OOfficeRestartManager::getImplementationName() throw (uno::RuntimeException, std::exception)
{
- return getImplementationName_static();
+ return OUString("com.sun.star.comp.task.OfficeRestartManager");
}
sal_Bool SAL_CALL OOfficeRestartManager::supportsService( const OUString& aServiceName ) throw (uno::RuntimeException, std::exception)
@@ -170,15 +144,36 @@ sal_Bool SAL_CALL OOfficeRestartManager::supportsService( const OUString& aServi
uno::Sequence< OUString > SAL_CALL OOfficeRestartManager::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
{
- return getSupportedServiceNames_static();
+ return { "com.sun.star.comp.task.OfficeRestartManager" };
}
} // namespace comphelper
-void createRegistryInfo_OOfficeRestartManager()
+namespace {
+
+struct Instance {
+ explicit Instance(
+ css::uno::Reference<css::uno::XComponentContext> const & context):
+ instance(static_cast<cppu::OWeakObject *>(new comphelper::OOfficeRestartManager(context)))
+ {}
+
+ rtl::Reference<css::uno::XInterface> instance;
+};
+
+struct Singleton:
+ public rtl::StaticWithArg<
+ Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_task_OfficeRestartManager(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
{
- static ::comphelper::module::OAutoRegistration< ::comphelper::OOfficeRestartManager > aAutoRegistration;
- static ::comphelper::module::OSingletonRegistration< ::comphelper::OOfficeRestartManager > aSingletonRegistration;
+ return cppu::acquire(static_cast<cppu::OWeakObject *>(
+ Singleton::get(context).instance.get()));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/officerestartmanager.hxx b/comphelper/source/misc/officerestartmanager.hxx
index 15a050f..43d707c 100644
--- a/comphelper/source/misc/officerestartmanager.hxx
+++ b/comphelper/source/misc/officerestartmanager.hxx
@@ -51,16 +51,6 @@ public:
virtual ~OOfficeRestartManager()
{}
- static css::uno::Sequence< OUString > SAL_CALL
- getSupportedServiceNames_static();
-
- static OUString SAL_CALL getImplementationName_static();
-
- static OUString SAL_CALL getServiceName_static();
-
- static css::uno::Reference< css::uno::XInterface > SAL_CALL
- Create( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
-
// XRestartManager
virtual void SAL_CALL requestRestart( const css::uno::Reference< css::task::XInteractionHandler >& xInteractionHandler ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL isRestartRequested( sal_Bool bInitialized ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
diff --git a/comphelper/util/comphelp.component b/comphelper/util/comphelp.component
index 4def104..95432c6 100644
--- a/comphelper/util/comphelp.component
+++ b/comphelper/util/comphelp.component
@@ -47,7 +47,8 @@
<service name="com.sun.star.logging.SimpleLogRing"/>
<singleton name="com.sun.star.logging.DocumentIOLogRing"/>
</implementation>
- <implementation name="com.sun.star.comp.task.OfficeRestartManager">
+ <implementation name="com.sun.star.comp.task.OfficeRestartManager"
+ constructor="com_sun_star_comp_task_OfficeRestartManager">
<service name="com.sun.star.comp.task.OfficeRestartManager"/>
<singleton name="com.sun.star.task.OfficeRestartManager"/>
</implementation>
commit 6b723132daacae5e007589ffdbe78d7569b06fa0
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Dec 26 12:27:56 2015 +0100
Small OUStringBuffer cleanup
Change-Id: I7b608400eea39eef4c620a1d4d67b11637c54436
diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx
index 4eb6f8c..12bf95d 100644
--- a/framework/source/helper/persistentwindowstate.cxx
+++ b/framework/source/helper/persistentwindowstate.cxx
@@ -19,11 +19,8 @@
#include <pattern/window.hxx>
#include <helper/persistentwindowstate.hxx>
-#include <services.h>
#include <com/sun/star/awt/XWindow.hpp>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
@@ -162,27 +159,18 @@ OUString PersistentWindowState::implst_identifyModule(const css::uno::Reference<
return sModuleName;
}
-OUString PersistentWindowState::implst_getWindowStateFromConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
- const OUString& sModuleName)
+OUString PersistentWindowState::implst_getWindowStateFromConfig(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sModuleName)
{
OUString sWindowState;
-
- OUStringBuffer sRelPathBuf(256);
- sRelPathBuf.append("Office/Factories/*[\"");
- sRelPathBuf.append (sModuleName );
- sRelPathBuf.append("\"]" );
-
- OUString sPackage("org.openoffice.Setup/");
- OUString sRelPath = sRelPathBuf.makeStringAndClear();
- OUString sKey("ooSetupFactoryWindowAttributes");
-
try
{
::comphelper::ConfigurationHelper::readDirectKey(rxContext,
- sPackage,
- sRelPath,
- sKey,
- ::comphelper::ConfigurationHelper::E_READONLY) >>= sWindowState;
+ "org.openoffice.Setup/",
+ "Office/Factories/*[\"" + sModuleName + "\"]",
+ "ooSetupFactoryWindowAttributes",
+ ::comphelper::ConfigurationHelper::E_READONLY) >>= sWindowState;
}
catch(const css::uno::RuntimeException&)
{ throw; }
@@ -192,27 +180,18 @@ OUString PersistentWindowState::implst_getWindowStateFromConfig(const css::uno::
return sWindowState;
}
-void PersistentWindowState::implst_setWindowStateOnConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
- const OUString& sModuleName ,
- const OUString& sWindowState)
+void PersistentWindowState::implst_setWindowStateOnConfig(
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sModuleName, const OUString& sWindowState)
{
- OUStringBuffer sRelPathBuf(256);
- sRelPathBuf.append("Office/Factories/*[\"");
- sRelPathBuf.append (sModuleName );
- sRelPathBuf.append("\"]" );
-
- OUString sPackage("org.openoffice.Setup/");
- OUString sRelPath = sRelPathBuf.makeStringAndClear();
- OUString sKey("ooSetupFactoryWindowAttributes");
-
try
{
::comphelper::ConfigurationHelper::writeDirectKey(rxContext,
- sPackage,
- sRelPath,
- sKey,
- css::uno::makeAny(sWindowState),
- ::comphelper::ConfigurationHelper::E_STANDARD);
+ "org.openoffice.Setup/",
+ "Office/Factories/*[\"" + sModuleName + "\"]",
+ "ooSetupFactoryWindowAttributes",
+ css::uno::makeAny(sWindowState),
+ ::comphelper::ConfigurationHelper::E_STANDARD);
}
catch(const css::uno::RuntimeException&)
{ throw; }
More information about the Libreoffice-commits
mailing list