summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2021-09-28 15:01:45 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-28 18:25:48 +0200
commit8156a8f87996e353f8d36935e0497624245f1ad1 (patch)
tree2e3b70d7bd097bdc489b13c05d74f08975f8b2b7 /sw
parent2d45cef3cd18c9d0198b9d302016a7598ce0484c (diff)
no need to allocate SwFont separately in SwAttrHandler
Change-Id: I08ef59f48b1f986854c6d194fb856b2da73c2ccd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122775 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/text/atrhndl.hxx10
-rw-r--r--sw/source/core/text/atrstck.cxx16
2 files changed, 11 insertions, 15 deletions
diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx
index 8a3c438fd91d..92d0153eefc3 100644
--- a/sw/source/core/text/atrhndl.hxx
+++ b/sw/source/core/text/atrhndl.hxx
@@ -45,7 +45,7 @@ private:
// This is the base font for the paragraph. It is stored in order to have
// a template, if we have to restart the attribute evaluation
- std::unique_ptr<SwFont> m_pFnt;
+ std::optional<SwFont> m_oFnt;
bool m_bVertLayout;
bool m_bVertLayoutLRBT;
@@ -104,14 +104,14 @@ public:
inline void SwAttrHandler::ResetFont( SwFont& rFnt ) const
{
- OSL_ENSURE(m_pFnt, "ResetFont without a font");
- if (m_pFnt)
- rFnt = *m_pFnt;
+ OSL_ENSURE(m_oFnt, "ResetFont without a font");
+ if (m_oFnt)
+ rFnt = *m_oFnt;
};
inline const SwFont* SwAttrHandler::GetFont() const
{
- return m_pFnt.get();
+ return m_oFnt ? &*m_oFnt : nullptr;
};
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index 794390a63ede..79dc822361c6 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -322,14 +322,10 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
// SwTextFrame::FormatOnceMore situation or (since sw_redlinehide)
// from SwAttrIter::Seek(); in the latter case SwTextSizeInfo::m_pFnt
// is an alias of m_pFnt so it must not be deleted!
- if (m_pFnt)
- {
- *m_pFnt = rFnt;
- }
+ if (m_oFnt)
+ *m_oFnt = rFnt;
else
- {
- m_pFnt.reset(new SwFont(rFnt));
- }
+ m_oFnt.emplace(rFnt);
}
void SwAttrHandler::Reset( )
@@ -826,11 +822,11 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, bool bPush )
void SwAttrHandler::GetDefaultAscentAndHeight( SwViewShell const * pShell, OutputDevice const & rOut,
sal_uInt16& nAscent, sal_uInt16& nHeight ) const
{
- OSL_ENSURE(m_pFnt, "No font available for GetDefaultAscentAndHeight");
+ OSL_ENSURE(m_oFnt, "No font available for GetDefaultAscentAndHeight");
- if (m_pFnt)
+ if (m_oFnt)
{
- SwFont aFont( *m_pFnt );
+ SwFont aFont( *m_oFnt );
nHeight = aFont.GetHeight( pShell, rOut );
nAscent = aFont.GetAscent( pShell, rOut );
}