diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2022-08-17 16:23:29 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-08-31 08:05:21 +0200 |
commit | a5126a21351c87138ff86a6636326eb6cd6a0f8c (patch) | |
tree | eb211306f04e98f041aab3d26ef790b56596211a /svx | |
parent | 4f738840d804a03c44fc9f468f3470688a43f926 (diff) |
tdf#144092 pptx import: correct table height during import
It appears PowerPoint can export rows of a table with row heights that
is less than the minimum height (for that row). And also export the
total table height wrong with it.
If PowerPoint imports such a table, those rows are individually
expanded to the minimum height. (Also increasing the table's total
height)
In Impress import we calculate table height by adding up individual
row heights. Table layouting code depends on the table height being
correct. This is why rows with less than minimum height lead to
layouting problems.
To compensate for this, while importing tables, layouting is skipped
until the table height is updated with the corrected height.
The correct height is calculated by layouting the table without
fitting to an area (i.e with bFit = false).
Change-Id: I79187882470a4e285b45bca1eabb469a084067f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138652
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/svdotable.cxx | 12 | ||||
-rw-r--r-- | svx/source/table/tablelayouter.hxx | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index f7d80e433612..6d50267a1b4d 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -2415,6 +2415,18 @@ void SdrTableObj::CropTableModelToSelection(const CellPos& rStart, const CellPos mpImpl->CropTableModelToSelection(rStart, rEnd); } +sal_Int32 SdrTableObj::getHeightWithoutFitting() +{ + tools::Rectangle aRect{}; + if( mpImpl.is() && mpImpl->mpLayouter) + { + mpImpl->mpLayouter->LayoutTableHeight(aRect, /*bFit=*/false); + return aRect.GetHeight(); + } + else + return 0; +} + void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn, const bool bOptimize, const bool bMinimize ) { if( mpImpl.is() && mpImpl->mpLayouter ) diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx index 519c1bda0a47..ef6837b2c6b0 100644 --- a/svx/source/table/tablelayouter.hxx +++ b/svx/source/table/tablelayouter.hxx @@ -123,13 +123,13 @@ public: const bool bMinimize ); void dumpAsXml(xmlTextWriterPtr pWriter) const; + void LayoutTableWidth(::tools::Rectangle& rArea, bool bFit); + void LayoutTableHeight(::tools::Rectangle& rArea, bool bFit); + private: CellRef getCell( const CellPos& rPos ) const; basegfx::B2ITuple getCellSize( const CellRef& xCell, const CellPos& rPos ) const; - void LayoutTableWidth( ::tools::Rectangle& rArea, bool bFit ); - void LayoutTableHeight( ::tools::Rectangle& rArea, bool bFit ); - bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (o3tl::make_unsigned(nColumn) < maColumns.size()); } bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (o3tl::make_unsigned(nRow) < maRows.size()); } bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); } |