[Libreoffice-commits] .: desktop/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Mon Mar 19 11:37:36 PDT 2012


 desktop/source/splash/services_spl.cxx |   92 ++++---------------------
 desktop/source/splash/splash.cxx       |  114 +++++++++++++++++++++++++------
 desktop/source/splash/splash.hxx       |  118 ++++++---------------------------
 3 files changed, 129 insertions(+), 195 deletions(-)

New commits:
commit 5bda84a2d7d135ed099fc87c10bf9d3a2758b44f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Mar 19 19:36:44 2012 +0100

    Fixed spl_component_getFactory
    
    The old code relied on the order of initializing global static variables across
    compilation units, which failed for MinGW cross compilation.  Cleaned up.

diff --git a/desktop/source/splash/services_spl.cxx b/desktop/source/splash/services_spl.cxx
index 0dc412c..5cc0bcf 100644
--- a/desktop/source/splash/services_spl.cxx
+++ b/desktop/source/splash/services_spl.cxx
@@ -26,92 +26,32 @@
  *
  ************************************************************************/
 
-#include <com/sun/star/beans/NamedValue.hpp>
-#include <com/sun/star/registry/XRegistryKey.hpp>
-#include <com/sun/star/util/Date.hpp>
-#include <uno/environment.h>
-#include <cppuhelper/factory.hxx>
-#include <unotools/configmgr.hxx>
+#include "sal/config.h"
 
-#include "splash.hxx"
-
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::registry;
-using namespace ::desktop;
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "sal/types.h"
 
-using ::rtl::OUString;
-
-static const char* pServices[] =
-{
-    SplashScreen::serviceName,
-    NULL
-};
-
-static const char* pImplementations[] =
-{
-    SplashScreen::implementationName,
-    NULL
-};
+#include "splash.hxx"
 
-typedef Reference<XInterface>(* fProvider)(const Reference<XMultiServiceFactory>&);
+namespace {
 
-static const fProvider pInstanceProviders[] =
-{
-    SplashScreen::getInstance,
-    NULL
-};
+namespace css = com::sun::star;
 
-static const char** pSupportedServices[] =
-{
-    SplashScreen::interfaces,
-    NULL
+static cppu::ImplementationEntry const services[] = {
+    { &desktop::splash::create, &desktop::splash::getImplementationName,
+      &desktop::splash::getSupportedServiceNames,
+      &cppu::createSingleComponentFactory, 0, 0 },
+    { 0, 0, 0, 0, 0, 0 }
 };
 
-static Sequence<OUString>
-getSupportedServiceNames(int p) {
-    const char **names = pSupportedServices[p];
-    Sequence<OUString> aSeq;
-    for(int i = 0; names[i] != NULL; i++) {
-        aSeq.realloc(i+1);
-        aSeq[i] = OUString::createFromAscii(names[i]);
-    }
-    return aSeq;
 }
 
-extern "C"
-{
-SAL_DLLPUBLIC_EXPORT void* SAL_CALL spl_component_getFactory(
-    const sal_Char* pImplementationName,
-    void* pServiceManager,
-    void*)
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL spl_component_getFactory(
+    char const * pImplName, void * pServiceManager, void * pRegistryKey)
 {
-    // Set default return value for this operation - if it failed.
-    if  ( pImplementationName && pServiceManager )
-    {
-        Reference< XSingleServiceFactory > xFactory;
-        Reference< XMultiServiceFactory > xServiceManager(
-            reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
-
-        // search implementation
-        for (int i = 0; (pImplementations[i]!=NULL); i++) {
-            if ( strcmp(pImplementations[i], pImplementationName ) == 0 ) {
-                // found implementation
-                xFactory = Reference<XSingleServiceFactory>(cppu::createSingleFactory(
-                    xServiceManager, OUString::createFromAscii(pImplementationName),
-                    pInstanceProviders[i], getSupportedServiceNames(i)));
-                if ( xFactory.is() ) {
-                    // Factory is valid - service was found.
-                    xFactory->acquire();
-                    return xFactory.get();
-                }
-            }
-        } // for()
-    }
-    // Return with result of this operation.
-    return NULL;
+    return cppu::component_getFactoryHelper(
+        pImplName, pServiceManager, pRegistryKey, services);
 }
-} // extern "C"
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx
index 8773f1a..eaa6d07 100644
--- a/desktop/source/splash/splash.cxx
+++ b/desktop/source/splash/splash.cxx
@@ -35,24 +35,99 @@
 #include <vcl/svapp.hxx>
 #include <vcl/salnativewidgets.hxx>
 
+#include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <cppuhelper/implbase2.hxx>
 #include <rtl/bootstrap.hxx>
 #include <rtl/logfile.hxx>
 #include <rtl/locale.hxx>
 #include <rtl/strbuf.hxx>
 #include <rtl/math.hxx>
 #include <vcl/graph.hxx>
+#include <vcl/introwin.hxx>
+#include <vcl/virdev.hxx>
 #include <svtools/filter.hxx>
 
 #define NOT_LOADED  ((long)-1)
 
 using namespace ::rtl;
+using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::uno;
 
-namespace desktop
+namespace {
+
+namespace css = com::sun::star;
+
+class  SplashScreen
+    : public ::cppu::WeakImplHelper2< XStatusIndicator, XInitialization >
+    , public IntroWindow
 {
+private:
+    struct FullScreenProgressRatioValue
+    {
+        double _fXRelPos;
+        double _fYRelPos;
+        double _fRelWidth;
+        double _fRelHeight;
+    };
+    enum BitmapMode { BM_FULLSCREEN, BM_DEFAULTMODE };
+
+    DECL_LINK( AppEventListenerHdl, VclWindowEvent * );
+    virtual ~SplashScreen();
+    void loadConfig();
+    void updateStatus();
+    void SetScreenBitmap(BitmapEx &rBitmap);
+    void determineProgressRatioValues( double& rXRelPos, double& rYRelPos, double& rRelWidth, double& rRelHeight );
+
+    static osl::Mutex _aMutex;
+
+    VirtualDevice   _vdev;
+    BitmapEx        _aIntroBmp;
+    Color           _cProgressFrameColor;
+    Color           _cProgressBarColor;
+    bool            _bNativeProgress;
+    OUString        _sAppName;
+    OUString        _sProgressText;
+    std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues;
+
+    sal_Int32   _iMax;
+    sal_Int32   _iProgress;
+    BitmapMode  _eBitmapMode;
+    sal_Bool    _bPaintBitmap;
+    sal_Bool    _bPaintProgress;
+    sal_Bool    _bVisible;
+    sal_Bool    _bShowLogo;
+    sal_Bool    _bFullScreenSplash;
+    sal_Bool    _bProgressEnd;
+    long _height, _width, _tlx, _tly, _barwidth;
+    long _barheight, _barspace;
+    double _fXPos, _fYPos;
+    double _fWidth, _fHeight;
+    const long _xoffset, _yoffset;
+
+public:
+    SplashScreen();
+
+    // XStatusIndicator
+    virtual void SAL_CALL end() throw ( RuntimeException );
+    virtual void SAL_CALL reset() throw ( RuntimeException );
+    virtual void SAL_CALL setText(const OUString& aText) throw ( RuntimeException );
+    virtual void SAL_CALL setValue(sal_Int32 nValue) throw ( RuntimeException );
+    virtual void SAL_CALL start(const OUString& aText, sal_Int32 nRange) throw ( RuntimeException );
+
+    // XInitialize
+    virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
+        throw ( RuntimeException );
+
+    // workwindow
+    virtual void Paint( const Rectangle& );
 
-SplashScreen::SplashScreen(const Reference< XMultiServiceFactory >& rSMgr)
+};
+
+SplashScreen::SplashScreen()
     : IntroWindow()
     , _vdev(*((IntroWindow*)this))
     , _cProgressFrameColor(sal::static_int_cast< ColorData >(NOT_LOADED))
@@ -78,8 +153,6 @@ SplashScreen::SplashScreen(const Reference< XMultiServiceFactory >& rSMgr)
     , _xoffset(12)
     , _yoffset(18)
 {
-    _rFactory = rSMgr;
-
     loadConfig();
 }
 
@@ -546,32 +619,25 @@ void SplashScreen::Paint( const Rectangle&)
 
 
 // get service instance...
-SplashScreen *SplashScreen::_pINSTANCE = NULL;
 osl::Mutex SplashScreen::_aMutex;
 
-Reference< XInterface > SplashScreen::getInstance(const Reference< XMultiServiceFactory >& rSMgr)
-{
-    if ( _pINSTANCE == 0 )
-    {
-        osl::MutexGuard guard(_aMutex);
-        if (_pINSTANCE == 0)
-            return (XComponent*)new SplashScreen(rSMgr);
-    }
-
-    return (XComponent*)0;
 }
 
-// static service info...
-const char* SplashScreen::interfaces[] =
+css::uno::Reference< css::uno::XInterface > desktop::splash::create(
+    css::uno::Reference< css::uno::XComponentContext > const &)
 {
-    "com.sun.star.task.XStartusIndicator",
-    "com.sun.star.lang.XInitialization",
-    NULL,
-};
-const sal_Char *SplashScreen::serviceName = "com.sun.star.office.SplashScreen";
-const sal_Char *SplashScreen::implementationName = "com.sun.star.office.comp.SplashScreen";
-const sal_Char *SplashScreen::supportedServiceNames[] = {"com.sun.star.office.SplashScreen", NULL};
+    return static_cast< cppu::OWeakObject * >(new SplashScreen);
+}
+
+rtl::OUString desktop::splash::getImplementationName() {
+    return rtl::OUString(
+        RTL_CONSTASCII_USTRINGPARAM("com.sun.star.office.comp.SplashScreen"));
+}
 
+css::uno::Sequence< rtl::OUString > desktop::splash::getSupportedServiceNames() {
+    rtl::OUString name(
+        RTL_CONSTASCII_USTRINGPARAM("com.sun.star.office.SplashScreen"));
+    return css::uno::Sequence< rtl::OUString >(&name, 1);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/splash/splash.hxx b/desktop/source/splash/splash.hxx
index 0d48584..b29f19e 100644
--- a/desktop/source/splash/splash.hxx
+++ b/desktop/source/splash/splash.hxx
@@ -26,109 +26,37 @@
  *
  ************************************************************************/
 
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/Exception.hpp>
-#include <com/sun/star/uno/Reference.h>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/task/XStatusIndicator.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/interfacecontainer.h>
-#include <vcl/introwin.hxx>
-#include <vcl/bitmapex.hxx>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <osl/mutex.hxx>
-#include <vcl/virdev.hxx>
+#ifndef INCLUDED_DESKTOP_SOURCE_SPLASH_SPLASH_HXX
+#define INCLUDED_DESKTOP_SOURCE_SPLASH_SPLASH_HXX
 
+#include "sal/config.h"
 
-using namespace ::rtl;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::task;
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "sal/types.h"
 
-namespace desktop {
+namespace com { namespace sun { namespace star {
+    namespace uno {
+        class XComponentContext;
+        class XInterface;
+    }
+} } }
+namespace rtl { class OUString; }
 
-class  SplashScreen
-    : public ::cppu::WeakImplHelper2< XStatusIndicator, XInitialization >
-    , public IntroWindow
-{
-private:
-    struct FullScreenProgressRatioValue
-    {
-        double _fXRelPos;
-        double _fYRelPos;
-        double _fRelWidth;
-        double _fRelHeight;
-    };
-    enum BitmapMode { BM_FULLSCREEN, BM_DEFAULTMODE };
+namespace desktop { namespace splash {
 
-    // don't allow anybody but ourselves to create instances of this class
-    SplashScreen(const SplashScreen&);
-    SplashScreen(void);
-    SplashScreen operator =(const SplashScreen&);
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
+create(
+    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+        const &);
 
-    SplashScreen(const Reference< XMultiServiceFactory >& xFactory);
+rtl::OUString SAL_CALL getImplementationName();
 
-    DECL_LINK( AppEventListenerHdl, VclWindowEvent * );
-    virtual ~SplashScreen();
-    void loadConfig();
-    void updateStatus();
-    void SetScreenBitmap(BitmapEx &rBitmap);
-    void determineProgressRatioValues( double& rXRelPos, double& rYRelPos, double& rRelWidth, double& rRelHeight );
+com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
+getSupportedServiceNames();
 
-    static  SplashScreen *_pINSTANCE;
+} }
 
-    static osl::Mutex _aMutex;
-    Reference< XMultiServiceFactory > _rFactory;
-
-    VirtualDevice   _vdev;
-    BitmapEx        _aIntroBmp;
-    Color           _cProgressFrameColor;
-    Color           _cProgressBarColor;
-    bool            _bNativeProgress;
-    OUString        _sAppName;
-    OUString        _sProgressText;
-    std::vector< FullScreenProgressRatioValue > _sFullScreenProgressRatioValues;
-
-    sal_Int32   _iMax;
-    sal_Int32   _iProgress;
-    BitmapMode  _eBitmapMode;
-    sal_Bool    _bPaintBitmap;
-    sal_Bool    _bPaintProgress;
-    sal_Bool    _bVisible;
-    sal_Bool    _bShowLogo;
-    sal_Bool    _bFullScreenSplash;
-    sal_Bool    _bProgressEnd;
-    long _height, _width, _tlx, _tly, _barwidth;
-    long _barheight, _barspace;
-    double _fXPos, _fYPos;
-    double _fWidth, _fHeight;
-    const long _xoffset, _yoffset;
-
-public:
-    static const char* interfaces[];
-    static const sal_Char *serviceName;
-    static const sal_Char *implementationName;
-    static const sal_Char *supportedServiceNames[];
-
-    static Reference< XInterface > getInstance(const Reference < XMultiServiceFactory >& xFactory);
-
-    // XStatusIndicator
-    virtual void SAL_CALL end() throw ( RuntimeException );
-    virtual void SAL_CALL reset() throw ( RuntimeException );
-    virtual void SAL_CALL setText(const OUString& aText) throw ( RuntimeException );
-    virtual void SAL_CALL setValue(sal_Int32 nValue) throw ( RuntimeException );
-    virtual void SAL_CALL start(const OUString& aText, sal_Int32 nRange) throw ( RuntimeException );
-
-    // XInitialize
-    virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
-        throw ( RuntimeException );
-
-    // workwindow
-    virtual void Paint( const Rectangle& );
-
-};
-
-}
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list