diff options
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/tblafmt.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 78 | ||||
-rw-r--r-- | sw/source/core/frmedt/fetab.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/table/rowht.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/shells/tabsh.cxx | 22 | ||||
-rw-r--r-- | sw/source/uibase/uiview/formatclipboard.cxx | 3 |
6 files changed, 48 insertions, 76 deletions
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index cacd3b268f71..b018a468a793 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -930,11 +930,9 @@ void SwTableAutoFormat::StoreTableProperties(const SwTable &table) return; SwEditShell *pShell = pDoc->GetEditShell(); - SwFormatRowSplit *pRowSplit = nullptr; - SwDoc::GetRowSplit(*pShell->getShellCursor(false), pRowSplit); + std::unique_ptr<SwFormatRowSplit> pRowSplit = SwDoc::GetRowSplit(*pShell->getShellCursor(false)); m_bRowSplit = pRowSplit && pRowSplit->GetValue(); - delete pRowSplit; - pRowSplit = nullptr; + pRowSplit.reset(); const SfxItemSet &rSet = pFormat->GetAttrSet(); diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index fcec43de7db4..fc9d328335f8 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -336,35 +336,28 @@ void SwDoc::SetRowSplit( const SwCursor& rCursor, const SwFormatRowSplit &rNew ) } } -void SwDoc::GetRowSplit( const SwCursor& rCursor, SwFormatRowSplit *& rpSz ) +std::unique_ptr<SwFormatRowSplit> SwDoc::GetRowSplit( const SwCursor& rCursor ) { - rpSz = nullptr; - SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode(); - if( pTableNd ) - { - std::vector<SwTableLine*> aRowArr; // For Lines collecting - ::lcl_CollectLines( aRowArr, rCursor, false ); + if( !pTableNd ) + return nullptr; - if( !aRowArr.empty() ) - { - rpSz = &const_cast<SwFormatRowSplit&>(aRowArr[0]->GetFrameFormat()->GetRowSplit()); + std::vector<SwTableLine*> aRowArr; // For Lines collecting + ::lcl_CollectLines( aRowArr, rCursor, false ); - if (rpSz) - { - for ( auto pLn : aRowArr ) - { - if ( (*rpSz).GetValue() != pLn->GetFrameFormat()->GetRowSplit().GetValue() ) - { - rpSz = nullptr; - break; - } - } - } - if ( rpSz ) - rpSz = new SwFormatRowSplit( *rpSz ); + if( aRowArr.empty() ) + return nullptr; + + SwFormatRowSplit* pSz = &const_cast<SwFormatRowSplit&>(aRowArr[0]->GetFrameFormat()->GetRowSplit()); + + for ( auto pLn : aRowArr ) + { + if ( pSz->GetValue() != pLn->GetFrameFormat()->GetRowSplit().GetValue() ) + { + return nullptr; } } + return o3tl::make_unique<SwFormatRowSplit>( *pSz ); } /* Class: SwDoc @@ -407,35 +400,26 @@ void SwDoc::SetRowHeight( const SwCursor& rCursor, const SwFormatFrameSize &rNew } } -void SwDoc::GetRowHeight( const SwCursor& rCursor, SwFormatFrameSize *& rpSz ) +std::unique_ptr<SwFormatFrameSize> SwDoc::GetRowHeight( const SwCursor& rCursor ) { - rpSz = nullptr; - SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode(); - if( pTableNd ) - { - std::vector<SwTableLine*> aRowArr; // For Lines collecting - ::lcl_CollectLines( aRowArr, rCursor, true ); + if( !pTableNd ) + return nullptr; - if( !aRowArr.empty() ) - { - rpSz = &const_cast<SwFormatFrameSize&>(aRowArr[0]->GetFrameFormat()->GetFrameSize()); + std::vector<SwTableLine*> aRowArr; // For Lines collecting + ::lcl_CollectLines( aRowArr, rCursor, true ); - if (rpSz) - { - for ( auto pLn : aRowArr ) - { - if ( *rpSz != pLn->GetFrameFormat()->GetFrameSize() ) - { - rpSz = nullptr; - break; - } - } - } - if ( rpSz ) - rpSz = new SwFormatFrameSize( *rpSz ); - } + if( aRowArr.empty() ) + return nullptr; + + SwFormatFrameSize* pSz = &const_cast<SwFormatFrameSize&>(aRowArr[0]->GetFrameFormat()->GetFrameSize()); + + for ( auto pLn : aRowArr ) + { + if ( *pSz != pLn->GetFrameFormat()->GetFrameSize() ) + return nullptr; } + return o3tl::make_unique<SwFormatFrameSize>( *pSz ); } bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly, const bool bOptimize ) diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 61001866b042..5aa912204eac 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -63,7 +63,7 @@ #include <swerror.h> #include <swundo.hxx> #include <frmtool.hxx> - +#include <fmtrowsplt.hxx> #include <node.hxx> #include <sortedobjs.hxx> @@ -718,9 +718,9 @@ void SwFEShell::SetRowSplit( const SwFormatRowSplit& rNew ) EndAllActionAndCall(); } -void SwFEShell::GetRowSplit( SwFormatRowSplit*& rpSz ) const +std::unique_ptr<SwFormatRowSplit> SwFEShell::GetRowSplit() const { - SwDoc::GetRowSplit( *getShellCursor( false ), rpSz ); + return SwDoc::GetRowSplit( *getShellCursor( false ) ); } void SwFEShell::SetRowHeight( const SwFormatFrameSize &rNew ) @@ -731,9 +731,9 @@ void SwFEShell::SetRowHeight( const SwFormatFrameSize &rNew ) EndAllActionAndCall(); } -void SwFEShell::GetRowHeight( SwFormatFrameSize *& rpSz ) const +std::unique_ptr<SwFormatFrameSize> SwFEShell::GetRowHeight() const { - SwDoc::GetRowHeight( *getShellCursor( false ), rpSz ); + return SwDoc::GetRowHeight( *getShellCursor( false ) ); } bool SwFEShell::BalanceRowHeight( bool bTstOnly, const bool bOptimize ) diff --git a/sw/source/ui/table/rowht.cxx b/sw/source/ui/table/rowht.cxx index 2a46f3e36629..066209e6389a 100644 --- a/sw/source/ui/table/rowht.cxx +++ b/sw/source/ui/table/rowht.cxx @@ -58,15 +58,12 @@ SwTableHeightDlg::SwTableHeightDlg(weld::Window *pParent, SwWrtShell &rS) ::SetFieldUnit(*m_xHeightEdit, eFieldUnit); m_xHeightEdit->set_min(MINLAY, FieldUnit::TWIP); - SwFormatFrameSize *pSz; - m_rSh.GetRowHeight(pSz); + std::unique_ptr<SwFormatFrameSize> pSz = m_rSh.GetRowHeight(); if (pSz) { auto nHeight = pSz->GetHeight(); m_xAutoHeightCB->set_active(pSz->GetHeightSizeType() != ATT_FIX_SIZE); m_xHeightEdit->set_value(m_xHeightEdit->normalize(nHeight), FieldUnit::TWIP); - - delete pSz; } } diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index b8da4958ede3..4b3c3dc78f41 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -203,12 +203,11 @@ static SwTableRep* lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh ) rSh.GetTabBorders( rSet ); //row split - SwFormatRowSplit* pSplit = nullptr; - rSh.GetRowSplit(pSplit); + std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit(); if(pSplit) { rSet.Put(*pSplit); - delete pSplit; + pSplit.reset(); } if(!bTableSel) @@ -1184,21 +1183,20 @@ void SwTableShell::Execute(SfxRequest &rReq) case FN_TABLE_ROW_SPLIT : { const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem); - SwFormatRowSplit* pSplit = nullptr; + std::unique_ptr<SwFormatRowSplit> pSplit; if(!pBool) { - rSh.GetRowSplit(pSplit); + pSplit = rSh.GetRowSplit(); if(pSplit) pSplit->SetValue(!pSplit->GetValue()); else - pSplit = new SwFormatRowSplit(true); + pSplit.reset(new SwFormatRowSplit(true)); } else { - pSplit = new SwFormatRowSplit(pBool->GetValue()); + pSplit.reset(new SwFormatRowSplit(pBool->GetValue())); } rSh.SetRowSplit( *pSplit ); - delete pSplit; break; } @@ -1268,13 +1266,11 @@ void SwTableShell::GetState(SfxItemSet &rSet) case SID_TABLE_MINIMAL_ROW_HEIGHT: { // Disable if auto height already is enabled. - SwFormatFrameSize *pSz; - rSh.GetRowHeight( pSz ); + std::unique_ptr<SwFormatFrameSize> pSz = rSh.GetRowHeight(); if ( pSz ) { if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() ) rSet.DisableItem( nSlot ); - delete pSz; } break; } @@ -1365,13 +1361,11 @@ void SwTableShell::GetState(SfxItemSet &rSet) } else { - SwFormatRowSplit* pSplit = nullptr; - rSh.GetRowSplit(pSplit); + std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit(); if(pSplit) rSet.Put(*pSplit); else rSet.InvalidateItem( nSlot ); - delete pSplit; } break; } diff --git a/sw/source/uibase/uiview/formatclipboard.cxx b/sw/source/uibase/uiview/formatclipboard.cxx index 7ea583af5305..8585795b3d4d 100644 --- a/sw/source/uibase/uiview/formatclipboard.cxx +++ b/sw/source/uibase/uiview/formatclipboard.cxx @@ -139,8 +139,7 @@ void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh ) rSet.Put( pFrameFormat->GetFrameDir() ); } - SwFormatRowSplit* pSplit = nullptr; - rSh.GetRowSplit(pSplit); + std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit(); if(pSplit) rSet.Put(*pSplit); } |