include/editeng/outliner.hxx | 17 +++++++---------- sd/source/ui/app/sdmod2.cxx | 2 +- sw/source/core/doc/docdraw.cxx | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-)
New commits: commit d4cafd20506a60a148b55e716c690a74c943def7 Author: Noel Grandin <[email protected]> AuthorDate: Mon Feb 18 15:05:28 2019 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Feb 19 09:40:22 2019 +0100 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: Noel Grandin <[email protected]> diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 1158f7195fea..67d2c47bb222 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -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; } diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx index 34584c4cd3e3..5fd4dc940116 100644 --- a/sd/source/ui/app/sdmod2.cxx +++ b/sd/source/ui/app/sdmod2.cxx @@ -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) { diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index 9eb49b95a44b..2087fbbe58d8 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -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) ) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
