summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-05-27 10:57:41 +0200
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-05-29 10:38:41 +0200
commitdb94d1079a83eae9ac0c8d92f4547698d016daf8 (patch)
tree83c3d21359ee0e74a8c8fb4a9b6bc1b799feb421
parent7175431a4b2154113c2c3c28f7ae8a8f14a84c7a (diff)
Revert "tdf#161261 sw: fix lost size of image resized in fixed-height cell"
This reverts commit 4da6f52f5fd164082fd42fc58fc7d31da567c924 plus follow-up 24f65bf5940adb0aa3590443752110119e2bea5e "Fix typo". It caused CppunitTest_sw_uiwriter6 to fail with > /sw/source/core/layout/flylay.cxx:1426:51: runtime error: downcast of address 0x606000c4b620 which does not point to an object of type 'const SwDrawContact' > 0x606000c4b620: note: object is of type 'SwFlyDrawContact' > 00 00 00 00 50 3d 2f b8 99 7f 00 00 c0 3d 2f b8 99 7f 00 00 00 00 00 00 00 00 00 00 d0 64 50 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'SwFlyDrawContact' > #0 0x7f99ae257936 in CalcClipRect(SdrObject const*, SwRect&, bool) /sw/source/core/layout/flylay.cxx:1426:51 > #1 0x7f99ad5b2607 in SwDrawView::TakeDragLimit(SdrDragMode, tools::Rectangle&) const /sw/source/core/draw/dview.cxx:694:13 > #2 0x7f99c317c1a0 in SdrDragView::BegDragObj(Point const&, OutputDevice*, SdrHdl*, short, SdrDragMethod*) /svx/source/svdraw/svddrgv.cxx:199:21 > #3 0x7f99c18eef25 in E3dView::BegDragObj(Point const&, OutputDevice*, SdrHdl*, short, SdrDragMethod*) /svx/source/engine3d/view3d.cxx:1243:21 > #4 0x7f99adcfa821 in SwFEShell::BeginDrag(Point const*, bool) /sw/source/core/frmedt/feshview.cxx:741:20 > #5 0x7f99b3ea5ffd in SwWrtShell::BeginFrameDrag(Point const*, bool) /sw/source/uibase/wrtsh/select.cxx:761:20 > #6 0x7f99b27a8238 in SwWrtShell::Drag(Point const*, bool) /sw/source/uibase/inc/wrtsh.hxx:124:56 > #7 0x7f99b2742135 in SwEditWin::MouseMove(MouseEvent const&) /sw/source/uibase/docvw/edtwin.cxx:4489:25 > #8 0x7f99dcdc6f64 in testTdf161261::TestBody() /sw/qa/extras/uiwriter/uiwriter6.cxx:1613:14 (<https://ci.libreoffice.org/job/lo_ubsan/3185/>) Change-Id: Idf0c0c75d39a28671c852fc526549439892d0902 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168177 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter6.cxx63
-rw-r--r--sw/source/core/layout/flylay.cxx38
2 files changed, 5 insertions, 96 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 6322120748da..fb3ecb357bcd 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -36,7 +36,6 @@
#include <sfx2/dispatch.hxx>
#include <cmdid.h>
#include <tools/json_writer.hxx>
-#include <tools/UnitConversion.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <com/sun/star/text/XTextTable.hpp>
@@ -1560,68 +1559,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf160836)
CPPUNIT_ASSERT_EQUAL(tools::Long(1980), pCellA1->getFrameArea().Height());
}
-CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf161261)
-{
- createSwDoc("tdf160842.fodt");
- SwDoc* pDoc = getSwDoc();
- CPPUNIT_ASSERT(pDoc);
- SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
- CPPUNIT_ASSERT(pWrtShell);
- // the cursor is not in the table
- CPPUNIT_ASSERT(!pWrtShell->IsCursorInTable());
-
- SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
- auto pPage = dynamic_cast<SwPageFrame*>(pLayout->Lower());
- CPPUNIT_ASSERT(pPage);
- const SwSortedObjs& rPageObjs = *pPage->GetSortedObjs();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPageObjs.size());
- auto pPageFly = dynamic_cast<SwFlyAtContentFrame*>(rPageObjs[0]);
- CPPUNIT_ASSERT(pPageFly);
- auto pTable = dynamic_cast<SwTabFrame*>(pPageFly->GetLower());
- CPPUNIT_ASSERT(pTable);
- auto pRow1 = pTable->GetLower();
- CPPUNIT_ASSERT(pRow1->IsRowFrame());
- auto pCellA1 = pRow1->GetLower();
- CPPUNIT_ASSERT(pCellA1);
- const SwRect& rCellA1Rect = pCellA1->getFrameArea();
- auto nRowHeight = rCellA1Rect.Height();
-
- // select image by clicking on it at the center of the upper cell
- Point ptFrom(rCellA1Rect.Left() + rCellA1Rect.Width() / 2, rCellA1Rect.Top() + nRowHeight / 2);
- vcl::Window& rEditWin = pDoc->GetDocShell()->GetView()->GetEditWin();
- Point aFrom = rEditWin.LogicToPixel(ptFrom);
- MouseEvent aClickEvent(aFrom, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
- rEditWin.MouseButtonDown(aClickEvent);
- rEditWin.MouseButtonUp(aClickEvent);
-
- // Then make sure that the image is selected:
- SelectionType eType = pWrtShell->GetSelectionType();
- CPPUNIT_ASSERT_EQUAL(SelectionType::Graphic, eType);
-
- uno::Reference<drawing::XShape> xShape = getShape(2);
- CPPUNIT_ASSERT(xShape.is());
-
- // zoom image by drag & drop using right bottom handle of the image
- const SwRect& rSelRect = pWrtShell->GetAnyCurRect(CurRectType::Frame);
- Point ptFromHandle(rSelRect.Right(), rSelRect.Bottom());
- Point aFromHandle = rEditWin.LogicToPixel(ptFromHandle);
- Point ptTo(rSelRect.Left() + rSelRect.Width() * 1.5, rSelRect.Top() + rSelRect.Height() * 1.5);
- Point aTo = rEditWin.LogicToPixel(ptTo);
- MouseEvent aClickEvent2(aFromHandle, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
- rEditWin.MouseButtonDown(aClickEvent2);
- MouseEvent aClickEvent3(aTo, 0, MouseEventModifiers::SIMPLEMOVE, MOUSE_LEFT);
- rEditWin.MouseMove(aClickEvent3);
- rEditWin.MouseMove(aClickEvent3);
- MouseEvent aClickEvent4(aTo, 1, MouseEventModifiers::SIMPLECLICK, MOUSE_LEFT);
- rEditWin.MouseButtonUp(aClickEvent4);
- Scheduler::ProcessEventsToIdle();
-
- // Make sure image is greater than before, instead of minimizing it to the cell size
- // This was 8707 and 6509
- CPPUNIT_ASSERT_GREATER(sal_Int32(10000), xShape->getSize().Width);
- CPPUNIT_ASSERT_GREATER(sal_Int32(8000), xShape->getSize().Height);
-}
-
CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf115132)
{
createSwDoc();
diff --git a/sw/source/core/layout/flylay.cxx b/sw/source/core/layout/flylay.cxx
index 35eb225782f9..1a39b735d2d8 100644
--- a/sw/source/core/layout/flylay.cxx
+++ b/sw/source/core/layout/flylay.cxx
@@ -1409,45 +1409,17 @@ 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() )
{
- 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() )
+ rRect += pUp->getFramePrintArea().Pos();
+ rRect.SSize( pUp->getFramePrintArea().SSize() );
+ if ( pUp->IsCellFrame() )
{
- // is image anchored as character?
- if (const SwDrawContact* pC = static_cast<const SwDrawContact*>(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()) ); // set bottom
- }
+ const SwFrame *pTab = pUp->FindTabFrame();
+ aRectFnSet.SetBottom( rRect, aRectFnSet.GetPrtBottom(*pTab->GetUpper()) );
}
}
else if ( pUp->GetUpper()->IsPageFrame() )