summaryrefslogtreecommitdiff
path: root/starmath/source/smdll.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'starmath/source/smdll.cxx')
-rw-r--r--starmath/source/smdll.cxx104
1 files changed, 55 insertions, 49 deletions
diff --git a/starmath/source/smdll.cxx b/starmath/source/smdll.cxx
index 00ea0f5d49b2..7c4a19b49439 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: */