[Libreoffice-commits] core.git: 2 commits - svx/source sw/inc sw/qa sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 8 11:22:23 UTC 2021


 svx/source/unodraw/unopage.cxx       |    5 +++++
 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 +++---
 6 files changed, 36 insertions(+), 10 deletions(-)

New commits:
commit 3bc8f90e9693f710f12632f69b9348c1c833c906
Author:     Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Fri Mar 5 21:06:28 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Mar 8 12:21:42 2021 +0100

    (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>

diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 3346b3a00443..52893220dde9 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 83cbee5580ac..67fb47fe6996 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -396,7 +396,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(4), 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 d1250d5305de..11687c41d0d5 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -478,8 +478,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);
@@ -501,7 +521,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.
@@ -528,7 +549,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 13629ecfed14..ff124ca7e2d7 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 761125b32222..ceb9a65a38a9 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -161,7 +161,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 );
 
@@ -352,9 +352,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();
commit 9463fec243e7507c826ea21a093b5475dc29fd41
Author:     Michael Stahl <michael.stahl at allotropia.de>
AuthorDate: Thu Mar 4 12:09:39 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Mar 8 12:21:24 2021 +0100

    SvxDrawPage::sort() is missing a mutex guard
    
    Change-Id: Ief291c7a7b866c0cf2533bddd8d1b69a55cd3a99
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112028
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index e282234e10e3..00be46da451d 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -325,6 +325,11 @@ void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape )
 
 void SvxDrawPage::sort( const css::uno::Sequence< sal_Int32 >& sortOrder )
 {
+    SolarMutexGuard aGuard;
+
+    if ((mpModel == nullptr) || (mpPage == nullptr))
+        throw lang::DisposedException();
+
     auto newOrder = comphelper::sequenceToContainer<std::vector<sal_Int32>>(sortOrder);
     mpPage->sort(newOrder);
 }


More information about the Libreoffice-commits mailing list