summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/svdotable.cxx4
-rw-r--r--svx/source/table/tablecontroller.cxx13
-rw-r--r--svx/source/table/tablelayouter.cxx14
-rw-r--r--svx/source/table/tablelayouter.hxx2
4 files changed, 24 insertions, 9 deletions
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 5bfcb7de6c90..a77655f40166 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -2428,12 +2428,12 @@ void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColu
}
-void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow )
+void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize )
{
if( mpImpl.is() && mpImpl->mpLayouter )
{
TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
- mpImpl->mpLayouter->DistributeRows( maRect, nFirstRow, nLastRow );
+ mpImpl->mpLayouter->DistributeRows( maRect, nFirstRow, nLastRow, bOptimize );
}
}
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index be901f99d8c2..f44b24daed84 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -492,7 +492,10 @@ void SvxTableController::GetState( SfxItemSet& rSet )
if( !bDistributeColumns )
rSet.DisableItem(SID_TABLE_DISTRIBUTE_COLUMNS);
if( !bDistributeRows )
+ {
+ rSet.DisableItem(SID_TABLE_OPTIMAL_ROW_HEIGHT);
rSet.DisableItem(SID_TABLE_DISTRIBUTE_ROWS);
+ }
break;
}
@@ -1007,8 +1010,12 @@ void SvxTableController::Execute( SfxRequest& rReq )
DistributeColumns(/*bOptimize=*/false);
break;
+ case SID_TABLE_OPTIMAL_ROW_HEIGHT:
+ DistributeRows(/*bOptimize=*/true);
+ break;
+
case SID_TABLE_DISTRIBUTE_ROWS:
- DistributeRows();
+ DistributeRows(/*bOptimize=*/false);
break;
case SID_TABLE_VERT_BOTTOM:
@@ -1316,7 +1323,7 @@ void SvxTableController::DistributeColumns(const bool bOptimize)
rModel.EndUndo();
}
-void SvxTableController::DistributeRows()
+void SvxTableController::DistributeRows(const bool bOptimize)
{
if(!checkTableObject())
return;
@@ -1333,7 +1340,7 @@ void SvxTableController::DistributeRows()
CellPos aStart, aEnd;
getSelectedCells( aStart, aEnd );
- rTableObj.DistributeRows( aStart.mnRow, aEnd.mnRow );
+ rTableObj.DistributeRows( aStart.mnRow, aEnd.mnRow, bOptimize );
if( bUndo )
rModel.EndUndo();
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index e74374a9e1f4..c1189e2ebdb4 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -1152,7 +1152,10 @@ void TableLayouter::DistributeColumns( ::tools::Rectangle& rArea,
}
-void TableLayouter::DistributeRows( ::tools::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow )
+void TableLayouter::DistributeRows( ::tools::Rectangle& rArea,
+ sal_Int32 nFirstRow,
+ sal_Int32 nLastRow,
+ const bool bOptimize )
{
if( mxTable.is() ) try
{
@@ -1173,7 +1176,7 @@ void TableLayouter::DistributeRows( ::tools::Rectangle& rArea, sal_Int32 nFirstR
const sal_Int32 nRows = (nLastRow-nFirstRow+1);
sal_Int32 nHeight = nAllHeight / nRows;
- if( nHeight < nMinHeight )
+ if( nHeight < nMinHeight && !bOptimize )
{
sal_Int32 nNeededHeight = nRows * nMinHeight;
rArea.AdjustBottom(nNeededHeight - nAllHeight );
@@ -1184,7 +1187,9 @@ void TableLayouter::DistributeRows( ::tools::Rectangle& rArea, sal_Int32 nFirstR
Reference< XTableRows > xRows( mxTable->getRows(), UNO_QUERY_THROW );
for( sal_Int32 nRow = nFirstRow; nRow <= nLastRow; ++nRow )
{
- if( nRow == nLastRow )
+ if ( bOptimize )
+ nHeight = maRows[nRow].mnMinSize;
+ else if ( nRow == nLastRow )
nHeight = nAllHeight; // last row get round errors
Reference< XPropertySet > xRowSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
@@ -1193,6 +1198,9 @@ void TableLayouter::DistributeRows( ::tools::Rectangle& rArea, sal_Int32 nFirstR
nAllHeight -= nHeight;
}
+ if ( bOptimize )
+ rArea.AdjustBottom( -nAllHeight );
+
LayoutTable( rArea, false, true );
}
catch( Exception& )
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index 960541219f9a..701a1eaf66ee 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -96,7 +96,7 @@ public:
sal_Int32 getVerticalEdge( int nEdgeX , sal_Int32* pnMin, sal_Int32* pnMax);
void DistributeColumns( ::tools::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol, const bool bOptimize );
- void DistributeRows( ::tools::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow );
+ void DistributeRows( ::tools::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow, const bool bOptimize );
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private: