sw/source/core/inc/UndoTable.hxx |    2 +-
 sw/source/core/undo/untbl.cxx    |   10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 912278671718d5d3d45fce25a3ca76228c81f7f3
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Aug 9 15:41:39 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Aug 13 14:29:58 2022 +0200

    unique_ptr->optional in SwUndoInsTable
    
    Change-Id: I30920fb2353b5d8616361c995f0947abc3d34370
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138160
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 0507f531ae12..749f4873d77b 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -58,7 +58,7 @@ class SwUndoInsTable final : public SwUndo
     OUString m_sTableName;
     SwInsertTableOptions m_aInsTableOptions;
     std::unique_ptr<SwDDEFieldType> m_pDDEFieldType;
-    std::unique_ptr<std::vector<sal_uInt16>> m_pColumnWidth;
+    std::optional<std::vector<sal_uInt16>> m_oColumnWidth;
     std::unique_ptr<SwRedlineData>  m_pRedlineData;
     std::unique_ptr<SwTableAutoFormat> m_pAutoFormat;
     SwNodeOffset m_nStartNode;
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index f17c8419741c..98a67a3b6996 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -242,7 +242,7 @@ SwUndoInsTable::SwUndoInsTable( const SwPosition& rPos, 
sal_uInt16 nCl, sal_uInt
 {
     if( pColArr )
     {
-        m_pColumnWidth.reset( new std::vector<sal_uInt16>(*pColArr) );
+        m_oColumnWidth.emplace( *pColArr );
     }
     if( pTAFormat )
         m_pAutoFormat.reset( new SwTableAutoFormat( *pTAFormat ) );
@@ -261,7 +261,7 @@ SwUndoInsTable::SwUndoInsTable( const SwPosition& rPos, 
sal_uInt16 nCl, sal_uInt
 SwUndoInsTable::~SwUndoInsTable()
 {
     m_pDDEFieldType.reset();
-    m_pColumnWidth.reset();
+    m_oColumnWidth.reset();
     m_pRedlineData.reset();
     m_pAutoFormat.reset();
 }
@@ -315,7 +315,8 @@ void SwUndoInsTable::RedoImpl(::sw::UndoRedoContext & 
rContext)
     SwPosition const aPos(rDoc.GetNodes(), m_nStartNode);
     const SwTable* pTable = rDoc.InsertTable( m_aInsTableOptions, aPos, 
m_nRows, m_nColumns,
                                             m_nAdjust,
-                                            m_pAutoFormat.get(), 
m_pColumnWidth.get() );
+                                            m_pAutoFormat.get(),
+                                            m_oColumnWidth ? &*m_oColumnWidth 
: nullptr );
     rDoc.GetEditShell()->MoveTable( GotoPrevTable, fnTableStart );
     static_cast<SwFrameFormat*>(pTable->GetFrameFormat())->SetFormatName( 
m_sTableName );
     SwTableNode* pTableNode = rDoc.GetNodes()[m_nStartNode]->GetTableNode();
@@ -355,7 +356,8 @@ void SwUndoInsTable::RepeatImpl(::sw::RepeatContext & 
rContext)
 {
     rContext.GetDoc().InsertTable(
             m_aInsTableOptions, *rContext.GetRepeatPaM().GetPoint(),
-            m_nRows, m_nColumns, m_nAdjust, m_pAutoFormat.get(), 
m_pColumnWidth.get() );
+            m_nRows, m_nColumns, m_nAdjust, m_pAutoFormat.get(),
+            m_oColumnWidth ? &*m_oColumnWidth : nullptr );
 }
 
 SwRewriter SwUndoInsTable::GetRewriter() const

Reply via email to