Related: tdf#144092 improve wording
Attempts to address concerns pointed out by Justin in:
https://gerrit.libreoffice.org/c/core/+/138652/#message-6dd69691fbaabf26424b4c3fb85f42e550b53ee2
Change-Id: I1af4d316fae73626ce734ca60c6539502eb80f14
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140067
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index bf07612..b837bc0 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -258,12 +258,7 @@ public:
/// Next time layouting would be done, skip it (to layout at the end of multiple actions).
void SetSkipChangeLayout(bool bSkipChangeLayout);
/** Tries to get table height if rows with sizes less than the minimum size were expanded
(i.e. Table height layouted without fitting to an area)
Helper for OOXML import
*/
sal_Int32 getHeightWithoutFitting();
void LayoutTableHeight(tools::Rectangle& rArea, bool bFit);
virtual void onEditOutlinerStatusEvent( EditStatus* pEditStatus ) override;
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index cfe1ea2..2a46f93 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -835,8 +835,7 @@ Reference< XShape > const & Shape::createAndInsert(
maSize.Height = 0;
for (auto const& elem : mpTablePropertiesPtr->getTableRows())
{
// WARN: When less than minimum sized rows exist, calculated height here
// is corrected before layouting takes place
// WARN: If some rows can't fit the content, this is not the final height
maSize.Height = o3tl::saturating_add(maSize.Height, elem.getHeight());
}
}
@@ -1263,7 +1262,7 @@ Reference< XShape > const & Shape::createAndInsert(
mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
if ( auto* pTableShape = dynamic_cast<sdr::table::SdrTableObj*>(SdrObject::getSdrObjectFromXShape(mxShape)) )
{
// Disable layouting until an attempt at correcting faulty table height is made
// Disable layouting until table height is expanded to fit the content
pTableShape->SetSkipChangeLayout(true);
}
}
@@ -1502,11 +1501,13 @@ Reference< XShape > const & Shape::createAndInsert(
if (mpTablePropertiesPtr && aServiceName == "com.sun.star.drawing.TableShape")
{
// Powerpoint sometimes export row heights less than the minimum size,
// which during import expanded to the minimum
// Powerpoint exports desired row heights (i.e. what user attempted to set it as, not how it appears visually)
// Expand table height if there are rows that can't fit the content
if (auto* pTableShape = dynamic_cast<sdr::table::SdrTableObj*>(SdrObject::getSdrObjectFromXShape(mxShape)))
{
sal_Int32 nCorrectedHeight = pTableShape->getHeightWithoutFitting();
tools::Rectangle aArea{};
pTableShape->LayoutTableHeight(aArea, /*bFit=*/false);
sal_Int32 nCorrectedHeight = aArea.GetHeight();
const auto& aShapeSize = mxShape->getSize();
if( nCorrectedHeight > aShapeSize.Height )
mxShape->setSize( {aShapeSize.Width, nCorrectedHeight} );
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 6d50267..94006af 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -2415,16 +2415,12 @@ void SdrTableObj::CropTableModelToSelection(const CellPos& rStart, const CellPos
mpImpl->CropTableModelToSelection(rStart, rEnd);
}
sal_Int32 SdrTableObj::getHeightWithoutFitting()
void SdrTableObj::LayoutTableHeight(tools::Rectangle& rArea, bool bFit)
{
tools::Rectangle aRect{};
if( mpImpl.is() && mpImpl->mpLayouter)
{
mpImpl->mpLayouter->LayoutTableHeight(aRect, /*bFit=*/false);
return aRect.GetHeight();
mpImpl->mpLayouter->LayoutTableHeight(rArea, bFit);
}
else
return 0;
}
void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize )