diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-28 09:53:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-28 13:19:18 +0200 |
commit | 6eb3d37fdc75537aa94144eef97493ec6192792f (patch) | |
tree | 4f65352402590eee8dd6164644ee2140ad0e79da /sfx2 | |
parent | a4b66458a7b8da2f5580014813e5dabe3fa670b6 (diff) |
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@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/mgetempl.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/dialog/mgetempl.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 26 | ||||
-rw-r--r-- | sfx2/source/inc/templdgi.hxx | 3 |
4 files changed, 20 insertions, 19 deletions
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; |