[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/inc sw/qa sw/source
Michael Stahl (via logerrit)
logerrit at kemper.freedesktop.org
Thu Mar 11 12:26:08 UTC 2021
sw/inc/dcontact.hxx | 4 ++--
sw/qa/extras/mailmerge/mailmerge.cxx | 2 +-
sw/source/core/draw/dcontact.cxx | 27 ++++++++++++++++++++++++---
sw/source/core/inc/flyfrm.hxx | 2 +-
sw/source/core/layout/fly.cxx | 6 +++---
5 files changed, 31 insertions(+), 10 deletions(-)
New commits:
commit 18397b2ede1e6c3feb54bd2bf59da57fd8c4d13a
Author: Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Fri Mar 5 21:06:28 2021 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Mar 11 13:25:31 2021 +0100
tdf#140292: (related: tdf#133487) sw: fix ordering of virtual SdrObjects for textboxes
Calling XShapes3::sort() on export of the testTdf130314 fails because of
2 consecutive textboxes; the function requires a textbox to immediately
follow its shape in the list (i.e. textbox has OrdNum of shape + 1).
This is because for shapes in header/footer, one virtual SdrVirtObj is
created per page where the header/footer is shown, and the
SwFlyDrawContact::GetOrdNumForNewRef() does not take textbox ordering
into account.
It's not clear if the assumption that the shape's SdrVirtObj is created
before the textbox's always holds, but let's try this for now.
Change-Id: I860896471211bf6c142ab825f298f4d4c0eec148
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112029
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112272
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 1082ebc70d94..082c0fe8d77f 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -179,13 +179,13 @@ private:
SwFlyDrawObjPtr mpMasterObj;
void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
- sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly);
+ sal_uInt32 GetOrdNumForNewRef(const SwFlyFrame* pFly, SwFrame const& rAnchorFrame);
public:
/// Creates DrawObject and registers it with the Model.
SwFlyDrawContact(SwFlyFrameFormat* pToRegisterIn, SdrModel& rTargetModel);
- static SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat);
+ static SwVirtFlyDrawObj* CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat, SwFrame const& rAnchorFrame);
virtual ~SwFlyDrawContact() override;
virtual const SwAnchoredObject* GetAnchoredObj( const SdrObject* _pSdrObj ) const override;
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 17d92d3789ac..58173b1e56cb 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -397,7 +397,7 @@ DECLARE_FILE_MAILMERGE_TEST(testMissingDefaultLineColor, "missing-default-line-c
executeMailMerge();
// The document was created by LO version which didn't write out the default value for line color
// (see XMLGraphicsDefaultStyle::SetDefaults()).
- uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(getShape(5), uno::UNO_QUERY);
// Lines do not have a line color.
CPPUNIT_ASSERT( !xPropertySet->getPropertySetInfo()->hasPropertyByName( "LineColor" ));
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index bece3f460079..2c4ab5e5b288 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -480,8 +480,28 @@ SwFlyDrawContact::~SwFlyDrawContact()
}
}
-sal_uInt32 SwFlyDrawContact::GetOrdNumForNewRef(const SwFlyFrame* pFly)
+sal_uInt32 SwFlyDrawContact::GetOrdNumForNewRef(const SwFlyFrame* pFly,
+ SwFrame const& rAnchorFrame)
{
+ // maintain invariant that a shape's textbox immediately follows the shape
+ // also for the multiple SdrVirtObj created for shapes in header/footer
+ if (SwFrameFormat const*const pDrawFormat =
+ SwTextBoxHelper::getOtherTextBoxFormat(GetFormat(), RES_FLYFRMFMT))
+ {
+ // assume that the draw SdrVirtObj is always created before the flyframe one
+ if (SwSortedObjs const*const pObjs = rAnchorFrame.GetDrawObjs())
+ {
+ for (SwAnchoredObject const*const pAnchoredObj : *pObjs)
+ {
+ if (&pAnchoredObj->GetFrameFormat() == pDrawFormat)
+ {
+ return pAnchoredObj->GetDrawObj()->GetOrdNum() + 1;
+ }
+ }
+ }
+ // if called from AppendObjs(), this is a problem; if called from lcl_SetFlyFrameAttr() it's not
+ SAL_INFO("sw", "GetOrdNumForNewRef: cannot find SdrObject for text box's shape");
+ }
// search for another Writer fly frame registered at same frame format
SwIterator<SwFlyFrame,SwFormat> aIter(*GetFormat());
const SwFlyFrame* pFlyFrame(nullptr);
@@ -503,7 +523,8 @@ sal_uInt32 SwFlyDrawContact::GetOrdNumForNewRef(const SwFlyFrame* pFly)
return GetMaster()->GetOrdNumDirect();
}
-SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFormat* pFormat)
+SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly,
+ SwFlyFrameFormat* pFormat, SwFrame const& rAnchorFrame)
{
// Find ContactObject from the Format. If there's already one, we just
// need to create a new Ref, else we create the Contact now.
@@ -530,7 +551,7 @@ SwVirtFlyDrawObj* SwFlyDrawContact::CreateNewRef(SwFlyFrame* pFly, SwFlyFrameFor
// #i27030# - insert new <SwVirtFlyDrawObj> instance
// into drawing page with correct order number
else
- rIDDMA.GetDrawModel()->GetPage(0)->InsertObject(pDrawObj, pContact->GetOrdNumForNewRef(pFly));
+ rIDDMA.GetDrawModel()->GetPage(0)->InsertObject(pDrawObj, pContact->GetOrdNumForNewRef(pFly, rAnchorFrame));
// #i38889# - assure, that new <SwVirtFlyDrawObj> instance
// is in a visible layer.
pContact->MoveObjToVisibleLayer(pDrawObj);
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index fec9a4936e5b..df39df57e176 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -64,7 +64,7 @@ class SW_DLLPUBLIC SwFlyFrame : public SwLayoutFrame, public SwAnchoredObject
friend void Notify( SwFlyFrame *, SwPageFrame *pOld, const SwRect &rOld,
const SwRect* pOldPrt );
- void InitDrawObj(); // these to methods are called in the
+ void InitDrawObj(SwFrame const&); // these to methods are called in the
void FinitDrawObj(); // constructors
void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 9987d682dbfc..6e7fad1fcb82 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -162,7 +162,7 @@ SwFlyFrame::SwFlyFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch
// First the Init, then the Content:
// This is due to the fact that the Content may have Objects/Frames,
// which are then registered
- InitDrawObj();
+ InitDrawObj(*pAnch);
Chain( pAnch );
@@ -353,9 +353,9 @@ void SwFlyFrame::DeleteCnt()
InvalidatePage();
}
-void SwFlyFrame::InitDrawObj()
+void SwFlyFrame::InitDrawObj(SwFrame const& rAnchorFrame)
{
- SetDrawObj(*SwFlyDrawContact::CreateNewRef(this, GetFormat()));
+ SetDrawObj(*SwFlyDrawContact::CreateNewRef(this, GetFormat(), rAnchorFrame));
// Set the right Layer
IDocumentDrawModelAccess& rIDDMA = GetFormat()->getIDocumentDrawModelAccess();
More information about the Libreoffice-commits
mailing list