[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Caolán McNamara caolanm at redhat.com
Tue Oct 25 14:40:19 UTC 2016


 include/sfx2/module.hxx         |    3 +++
 sfx2/source/appl/module.cxx     |   15 +++++++++++++++
 sfx2/source/dialog/mgetempl.cxx |    4 +---
 sfx2/source/dialog/templdlg.cxx |   10 ++--------
 4 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit 45a646f2fa1c8161d9fbc4509a2f0b2e826dc63f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Oct 25 14:11:44 2016 +0100

    split the creation of SfxStyleFamilies into a method
    
    Change-Id: I2590180fc30d75c89e758c72246a8294b5c4b9a2

diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx
index 8de3e90..4a20b1c 100644
--- a/include/sfx2/module.hxx
+++ b/include/sfx2/module.hxx
@@ -37,6 +37,7 @@ class SfxObjectFactory;
 class SfxModule;
 class SfxModule_Impl;
 class SfxSlotPool;
+class SfxStyleFamilies;
 struct SfxChildWinContextFactory;
 struct SfxChildWinFactory;
 struct SfxStbCtrlFactory;
@@ -84,6 +85,8 @@ public:
                                                const SfxItemSet& rSet );
     virtual void                Invalidate(sal_uInt16 nId = 0) override;
 
+    SfxStyleFamilies*           CreateStyleFamilies();
+
     static SfxModule*           GetActiveModule( SfxViewFrame* pFrame=nullptr );
     static FieldUnit            GetCurrentFieldUnit();
     /** retrieves the field unit of the module belonging to the document displayed in the given frame
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index a6465c5..0b64e6f 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -23,6 +23,7 @@
 #include <sfx2/module.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/sfxresid.hxx>
+#include <sfx2/styfitem.hxx>
 #include <sfx2/msgpool.hxx>
 #include <sfx2/tbxctrl.hxx>
 #include <sfx2/stbitem.hxx>
@@ -291,4 +292,18 @@ FieldUnit SfxModule::GetFieldUnit() const
     return eUnit;
 }
 
+SfxStyleFamilies* SfxModule::CreateStyleFamilies()
+{
+    SfxStyleFamilies *pStyleFamilies = nullptr;
+    ResMgr* pMgr = GetResMgr();
+    if (pMgr)
+    {
+        ResId aFamId(DLG_STYLE_DESIGNER, *pMgr);
+        aFamId.SetRT(RSC_SFX_STYLE_FAMILIES);
+        if (pMgr->IsAvailable(aFamId))
+            pStyleFamilies = new SfxStyleFamilies(aFamId);
+    }
+    return pStyleFamilies;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index a0a41e7..8a5e89e 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -95,9 +95,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(vcl::Window* pParent, const Sfx
     else
         m_pEditLinkStyleBtn->Enable();
 
-    ResMgr* pResMgr = SfxApplication::GetModule_Impl()->GetResMgr();
-    OSL_ENSURE( pResMgr, "No ResMgr in Module" );
-    pFamilies = new SfxStyleFamilies( ResId( DLG_STYLE_DESIGNER, *pResMgr ) );
+    pFamilies = SfxApplication::GetModule_Impl()->CreateStyleFamilies();
 
     SfxStyleSheetBasePool* pPool = nullptr;
     SfxObjectShell* pDocShell = SfxObjectShell::Current();
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index e522d53..cb21669 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -736,14 +736,8 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
     SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
     pCurObjShell = pViewFrame->GetObjectShell();
     pModule = pCurObjShell ? pCurObjShell->GetModule() : nullptr;
-    ResMgr* pMgr = pModule ? pModule->GetResMgr() : nullptr;
-    if (pMgr)
-    {
-        ResId aFamId( DLG_STYLE_DESIGNER, *pMgr );
-        aFamId.SetRT(RSC_SFX_STYLE_FAMILIES);
-        if (pMgr->IsAvailable(aFamId))
-            pStyleFamilies = new SfxStyleFamilies( aFamId );
-    }
+    if (pModule)
+        pStyleFamilies = pModule->CreateStyleFamilies();
     if (!pStyleFamilies)
         pStyleFamilies = new SfxStyleFamilies;
 


More information about the Libreoffice-commits mailing list