use boost::optional in SvTreeListEntry
it is inefficient to allocate a tiny object like Color separately on the heap Change-Id: Iac2cfc7c00c16240e7cf72e7d8814e97e9f65ac6 Reviewed-on: https://gerrit.libreoffice.org/67967 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -22,10 +22,12 @@
|
||||
|
||||
#include <vcl/dllapi.h>
|
||||
#include <tools/solar.h>
|
||||
#include <tools/color.hxx>
|
||||
#include <vcl/treelistbox.hxx>
|
||||
#include <vcl/treelistentries.hxx>
|
||||
#include <o3tl/typed_flags_set.hxx>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
@@ -62,7 +64,7 @@ class VCL_DLLPUBLIC SvTreeListEntry
|
||||
void* pUserData;
|
||||
SvTLEntryFlags nEntryFlags;
|
||||
Color maBackColor;
|
||||
std::unique_ptr<Color> mxTextColor;
|
||||
boost::optional<Color> mxTextColor;
|
||||
|
||||
private:
|
||||
void ClearChildren();
|
||||
@@ -110,8 +112,8 @@ public:
|
||||
void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
|
||||
const Color& GetBackColor() const { return maBackColor; }
|
||||
|
||||
void SetTextColor( const Color* pColor ) { mxTextColor.reset(pColor ? new Color(*pColor) : nullptr); }
|
||||
const Color* GetTextColor() const { return mxTextColor.get(); }
|
||||
void SetTextColor( boost::optional<Color> xColor ) { mxTextColor = xColor; }
|
||||
boost::optional<Color> const & GetTextColor() const { return mxTextColor; }
|
||||
|
||||
SvTreeListEntry* GetParent() const { return pParent; }
|
||||
|
||||
|
@@ -2233,7 +2233,7 @@ public:
|
||||
virtual void set_font_color(int pos, const Color& rColor) const override
|
||||
{
|
||||
SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos);
|
||||
pEntry->SetTextColor(&rColor);
|
||||
pEntry->SetTextColor(rColor);
|
||||
}
|
||||
|
||||
virtual void remove(int pos) override
|
||||
|
@@ -2701,8 +2701,8 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render
|
||||
if (bCurFontIsSel || rEntry.GetTextColor())
|
||||
{
|
||||
bCurFontIsSel = false;
|
||||
if (const auto* pCustomTextColor = rEntry.GetTextColor())
|
||||
rRenderContext.SetTextColor(*pCustomTextColor);
|
||||
if (const auto & xCustomTextColor = rEntry.GetTextColor())
|
||||
rRenderContext.SetTextColor(*xCustomTextColor);
|
||||
else
|
||||
rRenderContext.SetTextColor(aBackupTextColor);
|
||||
rRenderContext.SetFont(aBackupFont);
|
||||
|
Reference in New Issue
Block a user