summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx16
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx18
2 files changed, 28 insertions, 6 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 6f56022e92ae..0f1cb7f2ad9d 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -844,6 +844,22 @@ void SwUiWriterTest2::testTdf122942()
// paragraph mark, not above it.
const SwFormatVertOrient& rVert = rFormats[1]->GetVertOrient();
CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), rVert.GetPos());
+
+ reload("writer8", "tdf122942.odt");
+ pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+ pDoc = pWrtShell->GetDoc();
+ const SwFrameFormats& rFormats2 = *pDoc->GetSpzFrameFormats();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats2.size());
+
+ SdrObject* pObject = rFormats2[1]->FindSdrObject();
+ CPPUNIT_ASSERT(pObject);
+
+ const tools::Rectangle& rOutRect = pObject->GetLastBoundRect();
+ // Without the accompanying fix in place, this test would have failed with
+ // 'Expected greater than: 5000; Actual : 2817', i.e. the shape moved up
+ // after a reload(), while it's expected to not change its position (5773).
+ CPPUNIT_ASSERT_GREATER(static_cast<SwTwips>(5000), rOutRect.Top());
}
void SwUiWriterTest2::testTdf52391()
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 88f9969a422f..de969773d8b9 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -374,12 +374,18 @@ void SwAnchoredDrawObject::MakeObjPosAnchoredAtPara()
// --> #i50356# - format anchor frame containing the anchor
// position. E.g., for at-character anchored object this can be the follow
// frame of the anchor frame, which contains the anchor character.
- const bool bFormatAnchor =
- !static_cast<const SwTextFrame*>( GetAnchorFrameContainingAnchPos() )->IsAnyJoinLocked() &&
- !ConsiderObjWrapInfluenceOnObjPos() &&
- !ConsiderObjWrapInfluenceOfOtherObjs();
-
- if ( bFormatAnchor )
+ bool bJoinLocked
+ = static_cast<const SwTextFrame*>(GetAnchorFrameContainingAnchPos())->IsAnyJoinLocked();
+ const bool bFormatAnchor = !bJoinLocked && !ConsiderObjWrapInfluenceOnObjPos()
+ && !ConsiderObjWrapInfluenceOfOtherObjs();
+
+ // Format of anchor is needed for (vertical) fly offsets, otherwise the
+ // lack of fly portions will result in an incorrect 0 offset.
+ bool bAddVerticalFlyOffsets = GetFrameFormat().getIDocumentSettingAccess().get(
+ DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS);
+ bool bFormatAnchorOnce = !bJoinLocked && bAddVerticalFlyOffsets;
+
+ if (bFormatAnchor || bFormatAnchorOnce)
{
// --> #i50356#
GetAnchorFrameContainingAnchPos()->Calc(GetAnchorFrameContainingAnchPos()->getRootFrame()->GetCurrShell()->GetOut());