[Libreoffice-commits] .: 3 commits - starmath/inc starmath/qa starmath/source sw/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon May 23 04:36:03 PDT 2011
starmath/inc/smdll.hxx | 20 ----
starmath/qa/cppunit/test_nodetotextvisitors.cxx | 2
starmath/qa/cppunit/test_starmath.cxx | 2
starmath/source/smdll.cxx | 104 ++++++++++++------------
starmath/source/unodoc.cxx | 9 --
sw/source/ui/app/swdll.cxx | 2
6 files changed, 63 insertions(+), 76 deletions(-)
New commits:
commit 6d192be41c725fb83cdd8c093873ff574696b995
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun May 22 16:41:01 2011 +0100
make this a non-leaky singleton
diff --git a/starmath/inc/smdll.hxx b/starmath/inc/smdll.hxx
index aba28e3..b1097da 100644
--- a/starmath/inc/smdll.hxx
+++ b/starmath/inc/smdll.hxx
@@ -28,21 +28,10 @@
#ifndef SMDLL_HXX
#define SMDLL_HXX
-#include <tools/resid.hxx>
-#include <sfx2/sfxdefs.hxx>
-#include "smmod.hxx"
-
-class SmData;
-class SfxMedium;
-class SfxFilter;
-
-class SmDLL
+namespace SmGlobals
{
- static bool bInitialized;
-public:
- static void Init();
- static void Exit();
-};
+ void ensure();
+}
#endif
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index aec9be0..f7b282c 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -150,7 +150,7 @@ Test::Test()
InitVCL(xSM);
- SmDLL::Init();
+ SmGlobals::ensure();
}
void Test::setUp()
diff --git a/starmath/qa/cppunit/test_starmath.cxx b/starmath/qa/cppunit/test_starmath.cxx
index cc013bf..b19ead0 100644
--- a/starmath/qa/cppunit/test_starmath.cxx
+++ b/starmath/qa/cppunit/test_starmath.cxx
@@ -115,7 +115,7 @@ Test::Test()
InitVCL(xSM);
- SmDLL::Init();
+ SmGlobals::ensure();
}
void Test::setUp()
diff --git a/starmath/source/smdll.cxx b/starmath/source/smdll.cxx
index f9f07c4..b519b48 100644
--- a/starmath/source/smdll.cxx
+++ b/starmath/source/smdll.cxx
@@ -50,59 +50,65 @@
#include <svx/xmlsecctrl.hxx>
-
-
-bool SmDLL::bInitialized = false;
-
-
-// Initialization
-
-void SmDLL::Init()
+namespace
{
- if ( bInitialized )
- return;
-
- bInitialized = true;
-
- SfxObjectFactory& rFactory = SmDocShell::Factory();
-
- SmModule** ppShlPtr = (SmModule**) GetAppData(SHL_SM);
- *ppShlPtr = new SmModule( &rFactory );
-
- SfxModule *p = SM_MOD();
- SmModule *pp = (SmModule *) p;
-
- rFactory.SetDocumentServiceName( String::CreateFromAscii("com.sun.star.formula.FormulaProperties") );
-
- SmModule::RegisterInterface(pp);
- SmDocShell::RegisterInterface(pp);
- SmViewShell::RegisterInterface(pp);
-
- SmViewShell::RegisterFactory(1);
-
- SvxZoomStatusBarControl::RegisterControl( SID_ATTR_ZOOM, pp );
- SvxModifyControl::RegisterControl( SID_TEXTSTATUS, pp );
- SvxUndoRedoControl::RegisterControl( SID_UNDO, pp );
- SvxUndoRedoControl::RegisterControl( SID_REDO, pp );
- XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pp );
-
- SmToolBoxWrapper::RegisterChildWindow(true);
- SmCmdBoxWrapper::RegisterChildWindow(true);
-
- ::sfx2::TaskPaneWrapper::RegisterChildWindow( false, pp );
+ class SmDLL
+ {
+ public:
+ SmDLL();
+ ~SmDLL();
+ };
+
+ SmDLL::SmDLL()
+ {
+ SmModule** ppShlPtr = (SmModule**) GetAppData(SHL_SM);
+ if ( *ppShlPtr )
+ return;
+
+ SfxObjectFactory& rFactory = SmDocShell::Factory();
+ SmModule *pModule = new SmModule( &rFactory );
+ *ppShlPtr = pModule;
+
+ rFactory.SetDocumentServiceName( String::CreateFromAscii("com.sun.star.formula.FormulaProperties") );
+
+ SmModule::RegisterInterface(pModule);
+ SmDocShell::RegisterInterface(pModule);
+ SmViewShell::RegisterInterface(pModule);
+
+ SmViewShell::RegisterFactory(1);
+
+ SvxZoomStatusBarControl::RegisterControl(SID_ATTR_ZOOM, pModule);
+ SvxModifyControl::RegisterControl(SID_TEXTSTATUS, pModule);
+ SvxUndoRedoControl::RegisterControl(SID_UNDO, pModule);
+ SvxUndoRedoControl::RegisterControl(SID_REDO, pModule);
+ XmlSecStatusBarControl::RegisterControl(SID_SIGNATURE, pModule);
+
+ SmToolBoxWrapper::RegisterChildWindow(true);
+ SmCmdBoxWrapper::RegisterChildWindow(true);
+
+ ::sfx2::TaskPaneWrapper::RegisterChildWindow(false, pModule);
+ }
+
+ SmDLL::~SmDLL()
+ {
+#if 0
+ // the SdModule must be destroyed
+ SmModule** ppShlPtr = (SmModule**) GetAppData(SHL_SM);
+ delete (*ppShlPtr);
+ (*ppShlPtr) = NULL;
+ *GetAppData(SHL_SM) = 0;
+#endif
+ }
+
+ struct theSmDLLInstance : public rtl::Static<SmDLL, theSmDLLInstance> {};
}
-
-// Deinitialization
-
-void SmDLL::Exit()
+namespace SmGlobals
{
- // the SdModule must be destroyed
- SmModule** ppShlPtr = (SmModule**) GetAppData(SHL_SM);
- delete (*ppShlPtr);
- (*ppShlPtr) = NULL;
-
- *GetAppData(SHL_SM) = 0;
+ void ensure()
+ {
+ theSmDLLInstance::get();
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/unodoc.cxx b/starmath/source/unodoc.cxx
index 9fae49f..2e4eae8 100644
--- a/starmath/source/unodoc.cxx
+++ b/starmath/source/unodoc.cxx
@@ -59,14 +59,9 @@ uno::Reference< uno::XInterface > SAL_CALL SmDocument_createInstance(
const uno::Reference< lang::XMultiServiceFactory > & /*rSMgr*/, const sal_uInt64 _nCreationFlags ) throw( uno::Exception )
{
SolarMutexGuard aGuard;
- if ( !SM_MOD() )
- SmDLL::Init();
-
+ SmGlobals::ensure();
SfxObjectShell* pShell = new SmDocShell( _nCreationFlags );
- if( pShell )
- return uno::Reference< uno::XInterface >( pShell->GetModel() );
-
- return uno::Reference< uno::XInterface >();
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
}
commit 7c20143b0935f73b2e1146e896f5502f5354aee4
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun May 22 16:40:23 2011 +0100
keep this simple
diff --git a/sw/source/ui/app/swdll.cxx b/sw/source/ui/app/swdll.cxx
index f99ea47..6124324 100644
--- a/sw/source/ui/app/swdll.cxx
+++ b/sw/source/ui/app/swdll.cxx
@@ -101,7 +101,7 @@ SwDLL::SwDLL()
SfxObjectFactory* pWDocFact = &SwWebDocShell::Factory();
SwModule* pModule = new SwModule( pWDocFact, pDocFact, pGlobDocFact );
- (*ppShlPtr) = pModule;
+ *ppShlPtr = pModule;
pWDocFact->SetDocumentServiceName(C2S("com.sun.star.text.WebDocument"));
commit 94149e3960db8794fcf9003207ac2c1bd8ff2220
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 21:17:31 2011 +0100
DetectFilter declared but not defined
diff --git a/starmath/inc/smdll.hxx b/starmath/inc/smdll.hxx
index 9c5e08d..aba28e3 100644
--- a/starmath/inc/smdll.hxx
+++ b/starmath/inc/smdll.hxx
@@ -42,9 +42,6 @@ class SmDLL
public:
static void Init();
static void Exit();
-
- static sal_uLong DetectFilter( SfxMedium& rMedium, const SfxFilter **ppFilter,
- SfxFilterFlags nMust, SfxFilterFlags nDont );
};
#endif
More information about the Libreoffice-commits
mailing list