[Libreoffice-commits] core.git: sd/qa svx/source
GülÅah Köse (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 4 21:49:13 UTC 2020
sd/qa/unit/data/pptx/tablescale.pptx |binary
sd/qa/unit/import-tests.cxx | 20 +++++++++++++++++++-
svx/source/table/tablelayouter.cxx | 17 +++++++++++++----
3 files changed, 32 insertions(+), 5 deletions(-)
New commits:
commit 7dc234fa57ca409d0db131c93abea738014b5e1f
Author: Gülşah Köse <gulsah.kose at collabora.com>
AuthorDate: Mon Nov 2 23:32:06 2020 +0300
Commit: Gülşah Köse <gulsah.kose at collabora.com>
CommitDate: Wed Nov 4 22:48:32 2020 +0100
tdf#137949 Fix table row heigths.
Consider "Height" property of the the table while calculating
the minimum row height.
Change-Id: I4a57b69c4c0fc4dd004c895bd105ebc70f0c4bb3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105228
Tested-by: Xisco Fauli <xiscofauli at libreoffice.org>
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>
diff --git a/sd/qa/unit/data/pptx/tablescale.pptx b/sd/qa/unit/data/pptx/tablescale.pptx
new file mode 100644
index 000000000000..c4d946e5c619
Binary files /dev/null and b/sd/qa/unit/data/pptx/tablescale.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 11cbbb4f98b7..6e6b08d2bad2 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1482,9 +1482,27 @@ void SdImportTest::testRowHeight()
uno::Reference< css::table::XTableRows > xRows( xTable->getRows(), uno::UNO_SET_THROW);
uno::Reference< beans::XPropertySet > xRefRow( xRows->getByIndex(0), uno::UNO_QUERY_THROW );
xRefRow->getPropertyValue( "Height" ) >>= nHeight;
- CPPUNIT_ASSERT_EQUAL( sal_Int32(507), nHeight);
+ CPPUNIT_ASSERT_EQUAL( sal_Int32(508), nHeight);
xDocShRef->DoClose();
+
+ sd::DrawDocShellRef xDocShRef2 = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tablescale.pptx"), PPTX );
+ const SdrPage *pPage2 = GetPage( 1, xDocShRef2 );
+
+ sdr::table::SdrTableObj *pTableObj2 = dynamic_cast<sdr::table::SdrTableObj*>(pPage2->GetObj(0));
+ CPPUNIT_ASSERT( pTableObj2 );
+
+ uno::Reference< css::table::XTable > xTable2(pTableObj2->getTable(), uno::UNO_SET_THROW);
+ uno::Reference< css::table::XTableRows > xRows2( xTable2->getRows(), uno::UNO_SET_THROW);
+
+ for(sal_Int32 nRow = 0; nRow < 7; ++nRow)
+ {
+ uno::Reference< beans::XPropertySet > xRefRow2( xRows2->getByIndex(nRow), uno::UNO_QUERY_THROW );
+ xRefRow2->getPropertyValue( "Height" ) >>= nHeight;
+ CPPUNIT_ASSERT_EQUAL( sal_Int32(800), nHeight);
+ }
+
+ xDocShRef2->DoClose();
}
void SdImportTest::testTdf93830()
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 1c369e6d08b4..09611ab50979 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -725,6 +725,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
{
const sal_Int32 nColCount = getColumnCount();
const sal_Int32 nRowCount = getRowCount();
+
if( nRowCount == 0 )
return;
@@ -741,6 +742,9 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
sal_Int32 nCol, nRow;
for( nRow = 0; nRow < nRowCount; ++nRow )
{
+ Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
+ sal_Int32 nRowPropHeight = 0;
+ xRowSet->getPropertyValue( gsSize ) >>= nRowPropHeight;
sal_Int32 nMinHeight = 0;
bool bIsEmpty = true; // check if all cells in this row are merged
@@ -764,7 +768,13 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
bool bCellHasText = xCell->hasText();
if (bRowHasText == bCellHasText)
{
- nMinHeight = std::max( nMinHeight, xCell->getMinimumHeight() );
+ if(nRowPropHeight > 0)
+ {
+ nMinHeight = std::max( nMinHeight, xCell->getMinimumHeight() );
+ nMinHeight = std::min( nMinHeight, nRowPropHeight);
+ }
+ else
+ nMinHeight = xCell->getMinimumHeight();
}
else if ( !bRowHasText && bCellHasText )
{
@@ -784,7 +794,6 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
else
{
sal_Int32 nRowHeight = 0;
- Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
bool bOptimal = false;
xRowSet->getPropertyValue( sOptimalSize ) >>= bOptimal;
@@ -854,7 +863,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
}
// now scale if wanted and needed
- if( bFit && nCurrentHeight != rArea.getHeight() )
+ if( bFit && nCurrentHeight != rArea.getHeight())
distribute(maRows, o3tl::saturating_sub<sal_Int32>(rArea.getHeight(), nCurrentHeight));
// last step, update left edges
@@ -864,7 +873,7 @@ void TableLayouter::LayoutTableHeight( tools::Rectangle& rArea, bool bFit )
maRows[nRow].mnPos = nNewHeight;
nNewHeight = o3tl::saturating_add(nNewHeight, maRows[nRow].mnSize);
- if( bFit )
+ if( bFit)
{
Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
xRowSet->setPropertyValue( gsSize, Any( maRows[nRow].mnSize ) );
More information about the Libreoffice-commits
mailing list