diff options
author | László Németh <nemeth@numbertext.org> | 2024-05-21 13:20:24 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2024-05-29 23:43:47 +0200 |
commit | dece7d80c31c3c489859200bc93d9c948a535cbf (patch) | |
tree | 46ccb708ac578b70a0ee8cf25fa3ee3aeed03695 /sw/source | |
parent | 566c7017a84e3d573de85a6d986b81d3f59de0fa (diff) |
tdf#161261 sw: fix lost size of image resized in fixed-height cell
A fixed-height cell can contain a bigger image, which is cropped by
cell boundaries. It was not possible to resize this image with a simple drag & drop, because its size changed to the cell size immediately.
Now it's possible, like MSO does.
Follow-up to commit 30de13743f144aced83bc43d310592f82788c910
"tdf#160836 sw: resize rows at images cropped by row height".
Change-Id: I6b4e911432e784a96d393ee225ce69a1f2986d56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168186
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/layout/flylay.cxx | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx index 1a39b735d2d8..42ea0332f6eb 100644 --- a/sw/source/core/layout/flylay.cxx +++ b/sw/source/core/layout/flylay.cxx @@ -1409,17 +1409,45 @@ bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, bool bMove ) { const SwFrame *pUp = pFly->GetAnchorFrame()->GetUpper(); SwRectFnSet aRectFnSet(pFly->GetAnchorFrame()); + bool bOnlyCellFrame = pUp->IsCellFrame(); while( pUp->IsColumnFrame() || pUp->IsSctFrame() || pUp->IsColBodyFrame()) pUp = pUp->GetUpper(); rRect = pUp->getFrameArea(); if( !pUp->IsBodyFrame() ) { - rRect += pUp->getFramePrintArea().Pos(); - rRect.SSize( pUp->getFramePrintArea().SSize() ); - if ( pUp->IsCellFrame() ) + bool bCropByFixedHeightCell = false; + // allow zoom image cropped by fixed height table cell + if ( bOnlyCellFrame && pUp->IsCellFrame() && pUp->GetUpper() && + // is a fixed height table row? + pUp->GetUpper()->IsRowFrame() && SwFrameSize::Fixed == + pUp->GetUpper()->GetAttrSet()->GetFrameSize().GetHeightSizeType() ) { - const SwFrame *pTab = pUp->FindTabFrame(); - aRectFnSet.SetBottom( rRect, aRectFnSet.GetPrtBottom(*pTab->GetUpper()) ); + // is image anchored as character? + if ( const SwContact* pC = GetUserCall(pSdrObj) ) + { + const SwFrameFormat* pFormat = pC->GetFormat(); + const SwFormatAnchor& rAnch = pFormat->GetAnchor(); + if ( RndStdIds::FLY_AS_CHAR == rAnch.GetAnchorId() ) + { + const SwPageFrame *pPageFrame = pFly->FindPageFrame(); + Size aSize( pPageFrame->getFramePrintArea().SSize() ); + // TODO doubled print area is still cropped by full page size, yet + rRect.SSize(Size(aSize.getWidth() * 2, aSize.getHeight() * 2)); + bCropByFixedHeightCell = true; + } + } + } + + if ( !bCropByFixedHeightCell ) + { + rRect += pUp->getFramePrintArea().Pos(); + rRect.SSize( pUp->getFramePrintArea().SSize() ); + + if ( pUp->IsCellFrame() ) + { + const SwFrame *pTab = pUp->FindTabFrame(); + aRectFnSet.SetBottom( rRect, aRectFnSet.GetPrtBottom(*pTab->GetUpper()) ); + } } } else if ( pUp->GetUpper()->IsPageFrame() ) |