[Libreoffice-commits] core.git: include/sfx2 sc/inc sc/source sd/inc sd/source sfx2/source sw/inc sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri May 28 11:20:04 UTC 2021


 include/sfx2/module.hxx           |    3 ++-
 sc/inc/scmod.hxx                  |    2 +-
 sc/source/ui/app/scmod.cxx        |   10 +++++-----
 sd/inc/sdmod.hxx                  |    2 +-
 sd/source/ui/app/sdmod2.cxx       |   10 +++++-----
 sfx2/source/dialog/mgetempl.cxx   |    8 ++++----
 sfx2/source/dialog/mgetempl.hxx   |    2 +-
 sfx2/source/dialog/templdlg.cxx   |   26 +++++++++++++-------------
 sfx2/source/inc/templdgi.hxx      |    3 ++-
 sw/inc/swmodule.hxx               |    2 +-
 sw/source/ui/chrdlg/swuiccoll.cxx |    2 +-
 sw/source/uibase/app/swmodule.cxx |   18 +++++++++---------
 12 files changed, 45 insertions(+), 43 deletions(-)

New commits:
commit 6eb3d37fdc75537aa94144eef97493ec6192792f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri May 28 09:53:29 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri May 28 13:19:18 2021 +0200

    no need to allocate SfxStyleFamilies on the heap
    
    Change-Id: Ibedb36dec14c61927ef594ddf47fda94728530a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116319
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/sfx2/module.hxx b/include/sfx2/module.hxx
index fbffbc6ade78..13cf89769703 100644
--- a/include/sfx2/module.hxx
+++ b/include/sfx2/module.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_SFX2_MODULE_HXX
 
 #include <memory>
+#include <optional>
 #include <sal/config.h>
 #include <sfx2/dllapi.h>
 #include <sfx2/shell.hxx>
@@ -81,7 +82,7 @@ public:
                                                const SfxItemSet& rSet );
     virtual void                Invalidate(sal_uInt16 nId = 0) override;
 
-    virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() { return nullptr; }
+    virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() { return {}; }
 
     static SfxModule*           GetActiveModule( SfxViewFrame* pFrame=nullptr );
     static FieldUnit            GetCurrentFieldUnit();
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 8f2a1b34ea8f..1f6833371ca4 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -232,7 +232,7 @@ public:
     virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
     virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
     virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
-    virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() override;
+    virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
 
     void                SetInSharedDocLoading( bool bNew )  { m_bIsInSharedDocLoading = bNew; }
     bool                IsInSharedDocLoading() const        { return m_bIsInSharedDocLoading; }
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index bdd66a15db47..bccf25f7ec9b 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -2217,21 +2217,21 @@ bool ScModule::HasThesaurusLanguage( LanguageType nLang )
     return bHasLang;
 }
 
-std::unique_ptr<SfxStyleFamilies> ScModule::CreateStyleFamilies()
+std::optional<SfxStyleFamilies> ScModule::CreateStyleFamilies()
 {
-    std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
+    SfxStyleFamilies aStyleFamilies;
 
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
+    aStyleFamilies.emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Para,
                                                     ScResId(STR_STYLE_FAMILY_CELL),
                                                     BMP_STYLES_FAMILY_CELL,
                                                     RID_CELLSTYLEFAMILY, SC_MOD()->GetResLocale()));
 
-    pStyleFamilies->emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
+    aStyleFamilies.emplace_back(SfxStyleFamilyItem(SfxStyleFamily::Page,
                                                     ScResId(STR_STYLE_FAMILY_PAGE),
                                                     BMP_STYLES_FAMILY_PAGE,
                                                     RID_PAGESTYLEFAMILY, SC_MOD()->GetResLocale()));
 
-    return pStyleFamilies;
+    return aStyleFamilies;
 }
 
 void ScModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)
diff --git a/sd/inc/sdmod.hxx b/sd/inc/sdmod.hxx
index 218913a1b69a..5e21a32ca07a 100644
--- a/sd/inc/sdmod.hxx
+++ b/sd/inc/sdmod.hxx
@@ -114,7 +114,7 @@ public:
     virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
     virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
     virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
-    virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() override;
+    virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
 
     SdExtPropertySetInfoCache gImplImpressPropertySetInfoCache;
     SdExtPropertySetInfoCache gImplDrawPropertySetInfoCache;
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 20ff418808df..0080a0db1c50 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -797,21 +797,21 @@ std::unique_ptr<SfxTabPage> SdModule::CreateTabPage( sal_uInt16 nId, weld::Conta
     return xRet;
 }
 
-std::unique_ptr<SfxStyleFamilies> SdModule::CreateStyleFamilies()
+std::optional<SfxStyleFamilies> SdModule::CreateStyleFamilies()
 {
-    std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
+    SfxStyleFamilies aStyleFamilies;
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Para,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Para,
                                  SdResId(STR_GRAPHICS_STYLE_FAMILY),
                                  BMP_STYLES_FAMILY_GRAPHICS,
                                  RID_GRAPHICSTYLEFAMILY, SD_MOD()->GetResLocale());
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Pseudo,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Pseudo,
                                  SdResId(STR_PRESENTATIONS_STYLE_FAMILY),
                                  BMP_STYLES_FAMILY_PRESENTATIONS,
                                  RID_PRESENTATIONSTYLEFAMILY, SD_MOD()->GetResLocale());
 
-    return pStyleFamilies;
+    return aStyleFamilies;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index eae174748abd..de570eb24228 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -92,7 +92,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
     else
         m_xEditLinkStyleBtn->set_sensitive(true);
 
-    pFamilies = SfxApplication::GetModule_Impl()->CreateStyleFamilies();
+    mxFamilies = SfxApplication::GetModule_Impl()->CreateStyleFamilies();
 
     SfxStyleSheetBasePool* pPool = nullptr;
     SfxObjectShell* pDocShell = SfxObjectShell::Current();
@@ -185,11 +185,11 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
         m_xBaseLb->set_sensitive(false);
     }
 
-    size_t nCount = pFamilies->size();
+    size_t nCount = mxFamilies->size();
     size_t i;
     for ( i = 0; i < nCount; ++i )
     {
-        pItem = &(pFamilies->at(i));
+        pItem = &(mxFamilies->at(i));
 
         if ( pItem->GetFamily() == pStyle->GetFamily() )
             break;
@@ -256,7 +256,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
 
 SfxManageStyleSheetPage::~SfxManageStyleSheetPage()
 {
-    pFamilies.reset();
+    mxFamilies.reset();
     pItem = nullptr;
     pStyle = nullptr;
 }
diff --git a/sfx2/source/dialog/mgetempl.hxx b/sfx2/source/dialog/mgetempl.hxx
index 97e1c843eb22..371bc86c57d5 100644
--- a/sfx2/source/dialog/mgetempl.hxx
+++ b/sfx2/source/dialog/mgetempl.hxx
@@ -38,7 +38,7 @@ namespace weld { class Widget; }
 class SfxManageStyleSheetPage final : public SfxTabPage
 {
     SfxStyleSheetBase *pStyle;
-    std::unique_ptr<SfxStyleFamilies> pFamilies;
+    std::optional<SfxStyleFamilies> mxFamilies;
     const SfxStyleFamilyItem *pItem;
     OUString aBuf;
     bool bModified;
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 5ed2e844c38c..8951cfb71cbf 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -566,7 +566,7 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl(SfxBindings* pB, weld
 
 sal_uInt16 SfxCommonTemplateDialog_Impl::StyleNrToInfoOffset(sal_uInt16 nId)
 {
-    const SfxStyleFamilyItem& rItem = pStyleFamilies->at( nId );
+    const SfxStyleFamilyItem& rItem = mxStyleFamilies->at( nId );
     return SfxTemplate::SfxFamilyIdToNId(rItem.GetFamily())-1;
 }
 
@@ -587,9 +587,9 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
     pCurObjShell = pViewFrame->GetObjectShell();
     pModule = pCurObjShell ? pCurObjShell->GetModule() : nullptr;
     if (pModule)
-        pStyleFamilies = pModule->CreateStyleFamilies();
-    if (!pStyleFamilies)
-        pStyleFamilies.reset(new SfxStyleFamilies);
+        mxStyleFamilies = pModule->CreateStyleFamilies();
+    if (!mxStyleFamilies)
+        mxStyleFamilies.emplace();
 
     nActFilter = 0xffff;
     if (pCurObjShell)
@@ -601,7 +601,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
 
     // Paste in the toolbox
     // reverse order, since always inserted at the head
-    size_t nCount = pStyleFamilies->size();
+    size_t nCount = mxStyleFamilies->size();
 
     pBindings->ENTERREGISTRATIONS();
 
@@ -609,7 +609,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
     for (i = 0; i < nCount; ++i)
     {
         sal_uInt16 nSlot = 0;
-        switch (pStyleFamilies->at(i).GetFamily())
+        switch (mxStyleFamilies->at(i).GetFamily())
         {
             case SfxStyleFamily::Char:
                 nSlot = SID_STYLE_FAMILY1; break;
@@ -666,7 +666,7 @@ void SfxCommonTemplateDialog_Impl::ReadResource()
 
     for( ; nCount--; )
     {
-        const SfxStyleFamilyItem &rItem = pStyleFamilies->at( nCount );
+        const SfxStyleFamilyItem &rItem = mxStyleFamilies->at( nCount );
         sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId( rItem.GetFamily() );
         InsertFamilyItem(nId, rItem);
     }
@@ -683,7 +683,7 @@ void SfxCommonTemplateDialog_Impl::ClearResource()
 
 void SfxCommonTemplateDialog_Impl::impl_clear()
 {
-    pStyleFamilies.reset();
+    mxStyleFamilies.reset();
     for (auto & i : pFamilyState)
         i.reset();
     for (auto & i : pBoundItems)
@@ -789,10 +789,10 @@ SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
 // Helper function: Access to the current family item
 const SfxStyleFamilyItem *SfxCommonTemplateDialog_Impl::GetFamilyItem_Impl() const
 {
-    const size_t nCount = pStyleFamilies->size();
+    const size_t nCount = mxStyleFamilies->size();
     for(size_t i = 0; i < nCount; ++i)
     {
-        const SfxStyleFamilyItem &rItem = pStyleFamilies->at( i );
+        const SfxStyleFamilyItem &rItem = mxStyleFamilies->at( i );
         sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId(rItem.GetFamily());
         if(nId == nActFamily)
             return &rItem;
@@ -1054,7 +1054,7 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(StyleFlags nFlags)
     if (!pItem)
     {
         // Is the case for the template catalog
-        const size_t nFamilyCount = pStyleFamilies->size();
+        const size_t nFamilyCount = mxStyleFamilies->size();
         size_t n;
         for( n = 0; n < nFamilyCount; n++ )
             if( pFamilyState[ StyleNrToInfoOffset(n) ] ) break;
@@ -1207,7 +1207,7 @@ void SfxCommonTemplateDialog_Impl::SetWaterCanState(const SfxBoolItem *pItem)
 
 // Ignore while in watercan mode statusupdates
 
-    size_t nCount = pStyleFamilies->size();
+    size_t nCount = mxStyleFamilies->size();
     pBindings->EnterRegistrations();
     for(size_t n = 0; n < nCount; n++)
     {
@@ -1288,7 +1288,7 @@ void SfxCommonTemplateDialog_Impl::Update_Impl()
     if(nActFamily == 0xffff || nullptr == (pItem = pFamilyState[nActFamily-1].get() ) )
     {
          CheckItem(OString::number(nActFamily), false);
-         const size_t nFamilyCount = pStyleFamilies->size();
+         const size_t nFamilyCount = mxStyleFamilies->size();
          size_t n;
          for( n = 0; n < nFamilyCount; n++ )
              if( pFamilyState[ StyleNrToInfoOffset(n) ] ) break;
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 357db1b24b32..21e2f8bda032 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -25,6 +25,7 @@ class SfxTemplateControllerItem;
 
 #include <array>
 #include <memory>
+#include <optional>
 
 #include <vcl/transfer.hxx>
 #include <vcl/weld.hxx>
@@ -90,7 +91,7 @@ protected:
     SfxModule* pModule;
     std::unique_ptr<Idle> pIdle;
 
-    std::unique_ptr<SfxStyleFamilies> pStyleFamilies;
+    std::optional<SfxStyleFamilies> mxStyleFamilies;
     std::array<std::unique_ptr<SfxTemplateItem>, MAX_FAMILIES> pFamilyState;
     SfxStyleSheetBasePool* pStyleSheetPool;
     SfxObjectShell* pCurObjShell;
diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx
index 987e75e61559..3b59b529bfa0 100644
--- a/sw/inc/swmodule.hxx
+++ b/sw/inc/swmodule.hxx
@@ -230,7 +230,7 @@ public:
     virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
     virtual void         ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
     virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
-    virtual std::unique_ptr<SfxStyleFamilies> CreateStyleFamilies() override;
+    virtual std::optional<SfxStyleFamilies> CreateStyleFamilies() override;
 
     // Pool is created here and set at SfxShell.
     void    InitAttrPool();
diff --git a/sw/source/ui/chrdlg/swuiccoll.cxx b/sw/source/ui/chrdlg/swuiccoll.cxx
index 642651283428..6b35b6a309e5 100644
--- a/sw/source/ui/chrdlg/swuiccoll.cxx
+++ b/sw/source/ui/chrdlg/swuiccoll.cxx
@@ -72,7 +72,7 @@ SwCondCollPage::SwCondCollPage(weld::Container* pPage, weld::DialogController* p
     m_xStyleLB->connect_changed(LINK(this, SwCondCollPage, SelectTreeListBoxHdl));
     m_xFilterLB->connect_changed(LINK(this, SwCondCollPage, SelectListBoxHdl));
 
-    std::unique_ptr<SfxStyleFamilies> xFamilies(SW_MOD()->CreateStyleFamilies());
+    std::optional<SfxStyleFamilies> xFamilies(SW_MOD()->CreateStyleFamilies());
     size_t nCount = xFamilies->size();
     for (size_t j = 0; j < nCount; ++j)
     {
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 485bb7a52d41..1a9622ebbd5f 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -341,41 +341,41 @@ void    SwModule::RemoveAttrPool()
     m_pAttrPool.clear();
 }
 
-std::unique_ptr<SfxStyleFamilies> SwModule::CreateStyleFamilies()
+std::optional<SfxStyleFamilies> SwModule::CreateStyleFamilies()
 {
-    std::unique_ptr<SfxStyleFamilies> pStyleFamilies(new SfxStyleFamilies);
+    SfxStyleFamilies aStyleFamilies;
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Para,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Para,
                                  SwResId(STR_PARAGRAPHSTYLEFAMILY),
                                  BMP_STYLES_FAMILY_PARA,
                                  RID_PARAGRAPHSTYLEFAMILY, GetResLocale());
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Char,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Char,
                                  SwResId(STR_CHARACTERSTYLEFAMILY),
                                  BMP_STYLES_FAMILY_CHAR,
                                  RID_CHARACTERSTYLEFAMILY, GetResLocale());
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Frame,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Frame,
                                  SwResId(STR_FRAMESTYLEFAMILY),
                                  BMP_STYLES_FAMILY_FRAME,
                                  RID_FRAMESTYLEFAMILY, GetResLocale());
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Page,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Page,
                                  SwResId(STR_PAGESTYLEFAMILY),
                                  BMP_STYLES_FAMILY_PAGE,
                                  RID_PAGESTYLEFAMILY, GetResLocale());
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Pseudo,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Pseudo,
                                  SwResId(STR_LISTSTYLEFAMILY),
                                  BMP_STYLES_FAMILY_LIST,
                                  RID_LISTSTYLEFAMILY, GetResLocale());
 
-    pStyleFamilies->emplace_back(SfxStyleFamily::Table,
+    aStyleFamilies.emplace_back(SfxStyleFamily::Table,
                                  SwResId(STR_TABLESTYLEFAMILY),
                                  BMP_STYLES_FAMILY_TABLE,
                                  RID_TABLESTYLEFAMILY, GetResLocale());
 
-    return pStyleFamilies;
+    return aStyleFamilies;
 }
 
 void SwModule::RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller)


More information about the Libreoffice-commits mailing list