diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-21 17:04:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-22 16:23:14 +0200 |
commit | 0f6457b1e867c49bc82f2b18e2e462fb7100051f (patch) | |
tree | 500430f8d8bbfd7fa1a2d49430aa8c7c443ce337 /sw | |
parent | f30c3ff66a24d5031c077be0cb839f5f249c188e (diff) |
don't store vcl::Font with unique_ptr
it is already a COW object, so just use std::optional
Change-Id: I5ced54dbf3dc222316d9bcf3581b36e0f6e6e270
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120818
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/number.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/text/txtfld.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/writer/writer.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8num.cxx | 4 |
5 files changed, 9 insertions, 10 deletions
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 3d7544e8cd09..e1fe300dda37 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -1182,7 +1182,7 @@ namespace numfunc sal_Unicode mnLevelChars[MAXLEVEL]; // default bullet list font instance - std::unique_ptr<vcl::Font> mpFont; + std::optional<vcl::Font> mpFont; }; } @@ -1308,7 +1308,7 @@ namespace numfunc void SwDefBulletConfig::InitFont() { - mpFont.reset( new vcl::Font( msFontname, OUString(), Size( 0, 14 ) ) ); + mpFont.emplace( msFontname, OUString(), Size( 0, 14 ) ); mpFont->SetWeight( meFontWeight ); mpFont->SetItalic( meFontItalic ); mpFont->SetCharSet( RTL_TEXTENCODING_SYMBOL ); diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index fe292e368cb5..bfcb5ef57c05 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -656,7 +656,7 @@ SwNumberPortion *SwTextFormatter::NewNumberPortion( SwTextFormatInfo &rInf ) con if( SVX_NUM_CHAR_SPECIAL == rNumFormat.GetNumberingType() ) { - const vcl::Font *pFormatFnt = rNumFormat.GetBulletFont(); + const std::optional<vcl::Font> pFormatFnt = rNumFormat.GetBulletFont(); // Build a new bullet font basing on the current paragraph font: std::unique_ptr<SwFont> pNumFnt(new SwFont( &rInf.GetCharAttr(), pIDSA )); diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 76b7839415b0..afc309008ca2 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -1413,7 +1413,7 @@ uno::Sequence<beans::PropertyValue> SwXNumberingRules::GetPropertiesForNumFormat nINT16 = cBullet; aPropertyValues.push_back(comphelper::makePropertyValue("BulletId", nINT16)); - const vcl::Font* pFont = rFormat.GetBulletFont(); + std::optional<vcl::Font> pFont = rFormat.GetBulletFont(); //BulletChar aUString = OUString(&cBullet, 1); diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index f775293554d9..e3ba8cddc9f3 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -350,7 +350,6 @@ void Writer::PutNumFormatFontsInAttrPool() SfxItemPool& rPool = m_pDoc->GetAttrPool(); const SwNumRuleTable& rListTable = m_pDoc->GetNumRuleTable(); const SwNumFormat* pFormat; - const vcl::Font* pFont; const vcl::Font* pDefFont = &numfunc::GetDefBulletFont(); bool bCheck = false; @@ -364,9 +363,9 @@ void Writer::PutNumFormatFontsInAttrPool() if( SVX_NUM_CHAR_SPECIAL == (pFormat = &pRule->Get( nLvl ))->GetNumberingType() || SVX_NUM_BITMAP == pFormat->GetNumberingType() ) { - pFont = pFormat->GetBulletFont(); - if( nullptr == pFont ) - pFont = pDefFont; + std::optional<vcl::Font> pFont = pFormat->GetBulletFont(); + if( !pFont ) + pFont = *pDefFont; if( bCheck ) { diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx index a5a97854aa4f..aac2b0595f63 100644 --- a/sw/source/filter/ww8/wrtw8num.cxx +++ b/sw/source/filter/ww8/wrtw8num.cxx @@ -467,7 +467,7 @@ void MSWordExportBase::NumberingLevel( OUString sNumStr; OUString sFontName; bool bWriteBullet = false; - const vcl::Font* pBulletFont=nullptr; + std::optional<vcl::Font> pBulletFont; rtl_TextEncoding eChrSet=0; FontFamily eFamily=FAMILY_DECORATIVE; if (SVX_NUM_CHAR_SPECIAL == rFormat.GetNumberingType() || @@ -519,7 +519,7 @@ void MSWordExportBase::NumberingLevel( pBulletFont = rFormat.GetBulletFont(); if (!pBulletFont) { - pBulletFont = &numfunc::GetDefBulletFont(); + pBulletFont = numfunc::GetDefBulletFont(); } eChrSet = pBulletFont->GetCharSet(); |