[Libreoffice-commits] core.git: editeng/source sw/inc sw/source
Noel (via logerrit)
logerrit at kemper.freedesktop.org
Mon Oct 26 10:51:45 UTC 2020
editeng/source/editeng/impedit.cxx | 2 -
editeng/source/editeng/impedit.hxx | 8 +++---
sw/inc/swtable.hxx | 13 +++++-----
sw/source/core/table/swtable.cxx | 46 +++++++++----------------------------
4 files changed, 24 insertions(+), 45 deletions(-)
New commits:
commit f49a6361ce4d7dc4efaca0b1701a3ca0e0702eb2
Author: Noel <noelgrandin at gmail.com>
AuthorDate: Mon Oct 26 10:03:47 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Oct 26 11:51:07 2020 +0100
std::unique_ptr -> std::optional
Change-Id: Icf8168423af437fda88a6bd26679fecb699606e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104795
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 2c18762e1f9d..9e82cedf32f4 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -214,7 +214,7 @@ ImpEditView::~ImpEditView()
void ImpEditView::SetBackgroundColor( const Color& rColor )
{
- pBackgroundColor.reset( new Color( rColor ) );
+ mxBackgroundColor = rColor;
}
void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 921c0dfe5498..dc28f3db2a65 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -257,7 +257,7 @@ class ImpEditView : public vcl::unohelper::DragAndDropClient
private:
EditView* pEditView;
std::unique_ptr<vcl::Cursor, o3tl::default_delete<vcl::Cursor>> pCursor;
- std::unique_ptr<Color> pBackgroundColor;
+ std::optional<Color> mxBackgroundColor;
/// Containing view shell, if any.
OutlinerViewShell* mpViewShell;
/// Another shell, just listening to our state, if any.
@@ -436,9 +436,9 @@ public:
bool DoAutoHeight() const { return bool( nControl & EVControlBits::AUTOSIZEY); }
bool DoInvalidateMore() const { return bool( nControl & EVControlBits::INVONEMORE ); }
- void SetBackgroundColor( const Color& rColor );
- const Color& GetBackgroundColor() const {
- return ( pBackgroundColor ? *pBackgroundColor : pOutWin->GetBackground().GetColor() ); }
+ void SetBackgroundColor( const Color& rColor );
+ const Color & GetBackgroundColor() const {
+ return ( mxBackgroundColor ? *mxBackgroundColor : pOutWin->GetBackground().GetColor() ); }
/// Informs this edit view about which view shell contains it.
void RegisterViewShell(OutlinerViewShell* pViewShell);
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index a101cfeeb85e..d878478f8978 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -31,6 +31,7 @@
#include <vector>
#include <algorithm>
#include <o3tl/sorted_vector.hxx>
+#include <optional>
class SwStartNode;
class SwFormat;
@@ -402,8 +403,8 @@ class SW_DLLPUBLIC SwTableBox: public SwClient //Client of FrameFormat.
const SwStartNode * m_pStartNode;
SwTableLine *m_pUpper;
- std::unique_ptr<Color> mpUserColor;
- std::unique_ptr<Color> mpNumFormatColor;
+ std::optional<Color> mxUserColor;
+ std::optional<Color> mxNumFormatColor;
tools::Long mnRowSpan;
bool mbDummyFlag;
@@ -478,10 +479,10 @@ public:
void ActualiseValueBox();
// Access on internal data - currently used for the NumFormatter.
- inline const Color* GetSaveUserColor() const;
- inline const Color* GetSaveNumFormatColor() const;
- inline void SetSaveUserColor(const Color* p );
- inline void SetSaveNumFormatColor( const Color* p );
+ const std::optional<Color>& GetSaveUserColor() const { return mxUserColor; }
+ const std::optional<Color>& GetSaveNumFormatColor() const { return mxNumFormatColor; }
+ void SetSaveUserColor(std::optional<Color> p ) { mxUserColor = p; }
+ void SetSaveNumFormatColor( std::optional<Color> p ) { mxNumFormatColor = p; }
tools::Long getRowSpan() const;
void setRowSpan( tools::Long nNewRowSpan );
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 003dd062aaaf..c78c9ffdea89 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -71,32 +71,6 @@ using namespace com::sun::star;
static void ChgTextToNum( SwTableBox& rBox, const OUString& rText, const Color* pCol,
bool bChgAlign, sal_uLong nNdPos );
-inline const Color* SwTableBox::GetSaveUserColor() const
-{
- return mpUserColor.get();
-}
-
-inline const Color* SwTableBox::GetSaveNumFormatColor() const
-{
- return mpNumFormatColor.get();
-}
-
-inline void SwTableBox::SetSaveUserColor(const Color* p )
-{
- if (p)
- mpUserColor.reset(new Color(*p));
- else
- mpUserColor.reset();
-}
-
-inline void SwTableBox::SetSaveNumFormatColor( const Color* p )
-{
- if (p)
- mpNumFormatColor.reset(new Color(*p));
- else
- mpNumFormatColor.reset();
-}
-
tools::Long SwTableBox::getRowSpan() const
{
return mnRowSpan;
@@ -1990,8 +1964,10 @@ void ChgTextToNum( SwTableBox& rBox, const OUString& rText, const Color* pCol,
GetItemState( RES_CHRATR_COLOR, false, &pItem ))
pItem = nullptr;
- const Color* pOldNumFormatColor = rBox.GetSaveNumFormatColor();
- const Color* pNewUserColor = pItem ? &static_cast<const SvxColorItem*>(pItem)->GetValue() : nullptr;
+ const std::optional<Color>& pOldNumFormatColor = rBox.GetSaveNumFormatColor();
+ std::optional<Color> pNewUserColor;
+ if (pItem)
+ pNewUserColor = static_cast<const SvxColorItem*>(pItem)->GetValue();
if( ( pNewUserColor && pOldNumFormatColor &&
*pNewUserColor == *pOldNumFormatColor ) ||
@@ -2013,14 +1989,14 @@ void ChgTextToNum( SwTableBox& rBox, const OUString& rText, const Color* pCol,
else
{
// Save user color, set NumFormat color if needed, but never reset the color
- rBox.SetSaveUserColor( pNewUserColor );
+ rBox.SetSaveUserColor( pNewUserColor ? *pNewUserColor : std::optional<Color>() );
if( pCol )
// if needed, set the color
pTNd->SetAttr( SvxColorItem( *pCol, RES_CHRATR_COLOR ));
}
- rBox.SetSaveNumFormatColor( pCol );
+ rBox.SetSaveNumFormatColor( pCol ? *pCol : std::optional<Color>() );
if( pTNd->GetText() != rText )
{
@@ -2098,7 +2074,7 @@ static void ChgNumToText( SwTableBox& rBox, sal_uLong nFormat )
bool bChgAlign = pDoc->IsInsTableAlignNum();
const SfxPoolItem* pItem;
- const Color* pCol = nullptr;
+ const Color * pCol = nullptr;
if( getSwDefaultTextFormat() != nFormat )
{
// special text format:
@@ -2132,8 +2108,10 @@ static void ChgNumToText( SwTableBox& rBox, sal_uLong nFormat )
GetItemState( RES_CHRATR_COLOR, false, &pItem ))
pItem = nullptr;
- const Color* pOldNumFormatColor = rBox.GetSaveNumFormatColor();
- const Color* pNewUserColor = pItem ? &static_cast<const SvxColorItem*>(pItem)->GetValue() : nullptr;
+ const std::optional<Color>& pOldNumFormatColor = rBox.GetSaveNumFormatColor();
+ std::optional<Color> pNewUserColor;
+ if (pItem)
+ pNewUserColor = static_cast<const SvxColorItem*>(pItem)->GetValue();
if( ( pNewUserColor && pOldNumFormatColor &&
*pNewUserColor == *pOldNumFormatColor ) ||
@@ -2162,7 +2140,7 @@ static void ChgNumToText( SwTableBox& rBox, sal_uLong nFormat )
pTNd->SetAttr( SvxColorItem( *pCol, RES_CHRATR_COLOR ));
}
- rBox.SetSaveNumFormatColor( pCol );
+ rBox.SetSaveNumFormatColor( pCol ? *pCol : std::optional<Color>() );
// assign vertical orientation
if( bChgAlign &&
More information about the Libreoffice-commits
mailing list