diff options
-rw-r--r-- | sw/inc/doc.hxx | 6 | ||||
-rw-r--r-- | sw/inc/fesh.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl1.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/frmedt/fetab.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/shells/tabsh.cxx | 18 |
5 files changed, 24 insertions, 16 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index b06048cbadbc..bdff80442ebe 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1434,7 +1434,11 @@ public: static void GetRowHeight( const SwCursor& rCursor, SwFormatFrameSize *& rpSz ); void SetRowSplit( const SwCursor& rCursor, const SwFormatRowSplit &rNew ); static void GetRowSplit( const SwCursor& rCursor, SwFormatRowSplit *& rpSz ); - bool BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly ); + + /// Adjustment of Rowheights. Determine via bTstOnly if more than one row is selected. + /// bOptimize: distribute current table height, instead of using the largest row. + /// Call again without bOptimize to ensure equal height in case some row's content didn't fit. + bool BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly, const bool bOptimize ); void SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew ); static bool GetRowBackground( const SwCursor& rCursor, SvxBrushItem &rToFill ); void SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet ); diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 0fb81347dccd..f01fb6d9022a 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -655,8 +655,7 @@ public: void SetBoxAlign( sal_uInt16 nOrient ); sal_uInt16 GetBoxAlign() const; ///< USHRT_MAX if ambiguous. - /// Adjustment of Rowheights. Determine via bTstOnly if more than one row is selected. - bool BalanceRowHeight( bool bTstOnly ); + bool BalanceRowHeight( bool bTstOnly, const bool bOptimize = false ); void SetTabBorders( const SfxItemSet& rSet ); void GetTabBorders( SfxItemSet& rSet) const; diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index a5ee3f383cce..70ca0acd17b4 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -438,7 +438,7 @@ void SwDoc::GetRowHeight( const SwCursor& rCursor, SwFormatFrameSize *& rpSz ) } } -bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly ) +bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly, const bool bOptimize ) { bool bRet = false; SwTableNode* pTableNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode(); @@ -452,7 +452,7 @@ bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly ) if( !bTstOnly ) { long nHeight = 0; - + sal_Int32 nTotalHeight = 0; for ( auto pLn : aRowArr ) { SwIterator<SwFrame,SwFormat> aIter( *pLn->GetFrameFormat() ); @@ -462,7 +462,12 @@ bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, bool bTstOnly ) nHeight = std::max( nHeight, pFrame->getFrameArea().Height() ); pFrame = aIter.Next(); } + nTotalHeight += nHeight; } + + if ( bOptimize ) + nHeight = nTotalHeight / aRowArr.size(); + SwFormatFrameSize aNew( ATT_MIN_SIZE, 0, nHeight ); if (GetIDocumentUndoRedo().DoesUndo()) diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 3a21ae2ccdfe..e51f1e4e96e1 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -736,12 +736,12 @@ void SwFEShell::GetRowHeight( SwFormatFrameSize *& rpSz ) const SwDoc::GetRowHeight( *getShellCursor( false ), rpSz ); } -bool SwFEShell::BalanceRowHeight( bool bTstOnly ) +bool SwFEShell::BalanceRowHeight( bool bTstOnly, const bool bOptimize ) { SET_CURR_SHELL( this ); if( !bTstOnly ) StartAllAction(); - bool bRet = GetDoc()->BalanceRowHeight( *getShellCursor( false ), bTstOnly ); + bool bRet = GetDoc()->BalanceRowHeight( *getShellCursor( false ), bTstOnly, bOptimize ); if( !bTstOnly ) EndAllActionAndCall(); return bRet; diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 75ec7e57c888..a849013d9dbb 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -711,13 +711,6 @@ void SwTableShell::Execute(SfxRequest &rReq) rSh.UpdateTable(); bCallDone = true; break; - case FN_TABLE_OPTIMAL_HEIGHT: - { - const SwFormatFrameSize aSz; - rSh.SetRowHeight( aSz ); - bCallDone = true; - break; - } case FN_TABLE_DELETE_COL: if ( rSh.DeleteCol() && rSh.HasSelection() ) rSh.EnterStdMode(); @@ -795,6 +788,13 @@ void SwTableShell::Execute(SfxRequest &rReq) bCallDone = true; break; } + case FN_TABLE_OPTIMAL_HEIGHT: + { + rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true); + rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false); + bCallDone = true; + break; + } case FN_TABLE_BALANCE_ROWS: if ( rSh.BalanceRowHeight(true) ) rSh.BalanceRowHeight(false); @@ -1240,9 +1240,10 @@ void SwTableShell::GetState(SfxItemSet &rSet) rSet.DisableItem(FN_TABLE_BALANCE_CELLS); break; + case FN_TABLE_OPTIMAL_HEIGHT: case FN_TABLE_BALANCE_ROWS: if ( !rSh.BalanceRowHeight(true) ) - rSet.DisableItem(FN_TABLE_BALANCE_ROWS); + rSet.DisableItem(nSlot); break; case FN_OPTIMIZE_TABLE: if ( !rSh.IsTableMode() && @@ -1267,7 +1268,6 @@ void SwTableShell::GetState(SfxItemSet &rSet) break; case SID_TABLE_MINIMAL_ROW_HEIGHT: - case FN_TABLE_OPTIMAL_HEIGHT: { // Disable if auto height already is enabled. SwFormatFrameSize *pSz; |