Kaydet (Commit) d4cafd20 authored tarafından Noel Grandin's avatar Noel Grandin

use boost::optional in EditFieldInfo

it is inefficient to allocate a tiny object like Color separately on the
heap

Change-Id: I2f03538f987ff032857f3316ed2d8c2c8d731549
Reviewed-on: https://gerrit.libreoffice.org/67968
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ddaaf6d1
......@@ -49,6 +49,7 @@
#include <editeng/paragraphdata.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <boost/optional.hpp>
#include <functional>
#include <memory>
#include <vector>
......@@ -497,8 +498,8 @@ private:
Outliner* pOutliner;
const SvxFieldItem& rFldItem;
std::unique_ptr<Color> pTxtColor;
std::unique_ptr<Color> pFldColor;
boost::optional<Color> mxTxtColor;
boost::optional<Color> mxFldColor;
OUString aRepresentation;
......@@ -522,15 +523,11 @@ public:
const SvxFieldItem& GetField() const { return rFldItem; }
Color* GetTextColor() const { return pTxtColor.get(); }
void SetTextColor( const Color& rColor )
{ pTxtColor.reset( new Color( rColor ) ); }
boost::optional<Color> const & GetTextColor() const { return mxTxtColor; }
void SetTextColor( boost::optional<Color> xCol ) { mxTxtColor = xCol; }
Color* GetFieldColor() const { return pFldColor.get(); }
void SetFieldColor( const Color& rColor )
{ pFldColor.reset( new Color( rColor ) ); }
void ClearFieldColor()
{ pFldColor.reset(); }
boost::optional<Color> const & GetFieldColor() const { return mxFldColor; }
void SetFieldColor( boost::optional<Color> xCol ) { mxFldColor = xCol; }
sal_Int32 GetPara() const { return nPara; }
sal_Int32 GetPos() const { return nPos; }
......
......@@ -343,7 +343,7 @@ IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
}
else if ( dynamic_cast< const SdrMeasureField* >(pField))
{
pInfo->ClearFieldColor();
pInfo->SetFieldColor(boost::optional<Color>()); // clear the field color
}
else if ((pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pField)) != nullptr)
{
......
......@@ -541,8 +541,8 @@ IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
}
else if (dynamic_cast<const SdrMeasureField*>( pField))
{
// Measure field
pInfo->ClearFieldColor();
// Clear measure field
pInfo->SetFieldColor(boost::optional<Color>());
}
else if ( auto pTimeField = dynamic_cast<const SvxExtTimeField*>( pField) )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment