summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2025-02-02 23:46:11 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2025-02-04 00:33:07 +0100
commit700194c65544f130c92819425933d43528ba1598 (patch)
tree270c177289da7c352e33bbb62c6486df5d7c0ed1 /sfx2/source
parent527f81f2717812a10f88fb69edeaf062fd8589a1 (diff)
No longer use std::optional for SfxModule::CreateStyleFamilies
Just return an empty std::vector instead of a std::optional that contains no value in the default implementation, and adjust the type of the local variables and class members that contain the result and their use accordingly. Change-Id: I4e25b3cbd96c6eb9f06b0ae44b36675bb11ab38a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181024 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/dialog/StyleList.cxx24
-rw-r--r--sfx2/source/dialog/mgetempl.cxx7
-rw-r--r--sfx2/source/dialog/mgetempl.hxx3
-rw-r--r--sfx2/source/inc/StyleList.hxx2
4 files changed, 16 insertions, 20 deletions
diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index 1fd863181d02..846dee4089de 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -235,9 +235,7 @@ IMPL_LINK_NOARG(StyleList, ReadResource, void*, size_t)
m_pCurObjShell = pViewFrame->GetObjectShell();
m_Module = m_pCurObjShell ? m_pCurObjShell->GetModule() : nullptr;
if (m_Module)
- m_xStyleFamilies = m_Module->CreateStyleFamilies();
- if (!m_xStyleFamilies)
- m_xStyleFamilies.emplace();
+ m_aStyleFamilies = m_Module->CreateStyleFamilies();
m_nActFilter = 0xffff;
@@ -251,14 +249,14 @@ IMPL_LINK_NOARG(StyleList, ReadResource, void*, size_t)
if (m_bModuleHasStylesHighlighterFeature)
sDefaultCharStyleUIName = getDefaultStyleName(SfxStyleFamily::Char);
}
- size_t nCount = m_xStyleFamilies->size();
+ size_t nCount = m_aStyleFamilies.size();
m_pBindings->ENTERREGISTRATIONS();
size_t i;
for (i = 0; i < nCount; ++i)
{
sal_uInt16 nSlot = 0;
- switch (m_xStyleFamilies->at(i).GetFamily())
+ switch (m_aStyleFamilies.at(i).GetFamily())
{
case SfxStyleFamily::Char:
nSlot = SID_STYLE_FAMILY1;
@@ -860,17 +858,17 @@ static SfxStyleFamily NIdToSfxFamilyId(sal_uInt16 nId)
sal_uInt16 StyleList::StyleNrToInfoOffset(sal_uInt16 nId)
{
- const SfxStyleFamilyItem& rItem = m_xStyleFamilies->at(nId);
+ const SfxStyleFamilyItem& rItem = m_aStyleFamilies.at(nId);
return SfxTemplate::SfxFamilyIdToNId(rItem.GetFamily()) - 1;
}
// Helper function: Access to the current family item
const SfxStyleFamilyItem* StyleList::GetFamilyItem() const
{
- const size_t nCount = m_xStyleFamilies->size();
+ const size_t nCount = m_aStyleFamilies.size();
for (size_t i = 0; i < nCount; ++i)
{
- const SfxStyleFamilyItem& rItem = m_xStyleFamilies->at(i);
+ const SfxStyleFamilyItem& rItem = m_aStyleFamilies.at(i);
sal_uInt16 nId = SfxTemplate::SfxFamilyIdToNId(rItem.GetFamily());
if (nId == m_nActFamily)
return &rItem;
@@ -912,7 +910,7 @@ IMPL_LINK_NOARG(StyleList, IsSafeForWaterCan, void*, bool)
IMPL_LINK(StyleList, SetWaterCanState, const SfxBoolItem*, pItem, void)
{
- size_t nCount = m_xStyleFamilies->size();
+ size_t nCount = m_aStyleFamilies.size();
m_pBindings->EnterRegistrations();
for (size_t n = 0; n < nCount; n++)
{
@@ -1239,7 +1237,7 @@ void StyleList::UpdateStyles(StyleFlags nFlags)
if (!pItem)
{
// Is the case for the template catalog
- const size_t nFamilyCount = m_xStyleFamilies->size();
+ const size_t nFamilyCount = m_aStyleFamilies.size();
size_t n;
for (n = 0; n < nFamilyCount; n++)
if (m_pFamilyState[StyleNrToInfoOffset(n)])
@@ -1568,7 +1566,7 @@ IMPL_LINK_NOARG(StyleList, Clear, void*, void)
pViewShell->GetStylesHighlighterCharColorMap().clear();
}
}
- m_xStyleFamilies.reset();
+ m_aStyleFamilies.clear();
for (auto& i : m_pFamilyState)
i.reset();
m_pCurObjShell = nullptr;
@@ -1916,7 +1914,7 @@ void StyleList::Update()
if (m_nActFamily == 0xffff || nullptr == (pItem = m_pFamilyState[m_nActFamily - 1].get()))
{
m_pParentDialog->CheckItem(OUString::number(m_nActFamily), false);
- const size_t nFamilyCount = m_xStyleFamilies->size();
+ const size_t nFamilyCount = m_aStyleFamilies.size();
size_t n;
for (n = 0; n < nFamilyCount; n++)
if (m_pFamilyState[StyleNrToInfoOffset(n)])
@@ -1974,7 +1972,7 @@ void StyleList::Update()
const SfxStyleFamilyItem& StyleList::GetFamilyItemByIndex(size_t i) const
{
- return m_xStyleFamilies->at(i);
+ return m_aStyleFamilies.at(i);
}
IMPL_STATIC_LINK(StyleList, CustomGetSizeHdl, weld::TreeView::get_size_args, aPayload, Size)
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
index 9425b5e5b437..4bbed98ecb5a 100644
--- a/sfx2/source/dialog/mgetempl.cxx
+++ b/sfx2/source/dialog/mgetempl.cxx
@@ -91,7 +91,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
else
m_xEditLinkStyleBtn->set_sensitive(true);
- mxFamilies = SfxApplication::GetModule_Impl()->CreateStyleFamilies();
+ maFamilies = SfxApplication::GetModule_Impl()->CreateStyleFamilies();
SfxStyleSheetBasePool* pPool = nullptr;
SfxObjectShell* pDocShell = SfxObjectShell::Current();
@@ -184,11 +184,11 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
m_xBaseLb->set_sensitive(false);
}
- size_t nCount = mxFamilies->size();
+ size_t nCount = maFamilies.size();
size_t i;
for ( i = 0; i < nCount; ++i )
{
- pItem = &(mxFamilies->at(i));
+ pItem = &(maFamilies.at(i));
if ( pItem->GetFamily() == pStyle->GetFamily() )
break;
@@ -255,7 +255,6 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(weld::Container* pPage, weld::D
SfxManageStyleSheetPage::~SfxManageStyleSheetPage()
{
- mxFamilies.reset();
pItem = nullptr;
pStyle = nullptr;
}
diff --git a/sfx2/source/dialog/mgetempl.hxx b/sfx2/source/dialog/mgetempl.hxx
index 7bc67cec3c7e..0e59c6862ef8 100644
--- a/sfx2/source/dialog/mgetempl.hxx
+++ b/sfx2/source/dialog/mgetempl.hxx
@@ -22,7 +22,6 @@
#include <sfx2/styfitem.hxx>
#include <sfx2/tabdlg.hxx>
#include <memory>
-#include <optional>
namespace weld { class Button; }
namespace weld { class CheckButton; }
@@ -39,7 +38,7 @@ namespace weld { class Widget; }
class SfxManageStyleSheetPage final : public SfxTabPage
{
SfxStyleSheetBase *pStyle;
- std::optional<SfxStyleFamilies> mxFamilies;
+ SfxStyleFamilies maFamilies;
const SfxStyleFamilyItem *pItem;
OUString aBuf;
bool bModified;
diff --git a/sfx2/source/inc/StyleList.hxx b/sfx2/source/inc/StyleList.hxx
index bc8a90ada248..3d466409a67e 100644
--- a/sfx2/source/inc/StyleList.hxx
+++ b/sfx2/source/inc/StyleList.hxx
@@ -223,7 +223,7 @@ private:
std::unique_ptr<weld::Builder> mxMenuBuilder;
std::unique_ptr<weld::Menu> mxMenu;
- std::optional<SfxStyleFamilies> m_xStyleFamilies;
+ SfxStyleFamilies m_aStyleFamilies;
std::array<std::unique_ptr<SfxTemplateItem>, MAX_FAMILIES> m_pFamilyState;
SfxObjectShell* m_pCurObjShell;
sal_uInt16 m_nActFamily;