tdf#137802 sw: fix crash of textbox anchored to page

This is a regression from commit
a7bd634371285dbdceaf775dc31b6b586c7ca02f
(tdf#137802 tdf#84691 sw: sync anchoring of
textbox with UNO), where synching didn't
remove the anchoring setting.

Steps for reproducing:

1. In an empty document add a new paragraph so that you have two.
2. Insert – Shape – Basic Shapes – Rectangle and place it to the
   center of page to have it anchored to the second empty paragraph.
3. Right click on the shape – Add Text Box
4. Right click on the shape – Position and Size
5. Set Anchor as To page
6. Delete the second paragraph that the shape was anchored
7. Click on the shape and press Delete

Change-Id: I67f076bb9fc26cf47185aa21a84371dd85c6e3ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106531
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 1e27699..0d66639 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -828,17 +828,14 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& 
    const SfxPoolItem* pItem = aIter.GetCurItem();

    const RndStdIds aAnchId = rShape.GetAnchor().GetAnchorId();
    if ((aAnchId == RndStdIds::FLY_AT_PAGE && rShape.GetAnchor().GetPageNum() != 0)
        || ((aAnchId == RndStdIds::FLY_AT_PARA || aAnchId == RndStdIds::FLY_AT_CHAR)
            && rShape.GetAnchor().GetContentAnchor()))
    if (aAnchId == RndStdIds::FLY_AT_PAGE && rShape.GetAnchor().GetPageNum() != 0)
    {
        SwFormatAnchor aNewAnch = pFormat->GetAnchor();
        if (rShape.GetAnchor().GetContentAnchor())
            aNewAnch.SetAnchor(rShape.GetAnchor().GetContentAnchor());
        if (rShape.GetAnchor().GetPageNum() > 0)
            aNewAnch.SetPageNum(rShape.GetAnchor().GetPageNum());
        aNewAnch.SetType(rShape.GetAnchor().GetAnchorId());
        aTextBoxSet.Put(aNewAnch);
        aTextBoxSet.Put(SwFormatAnchor(RndStdIds::FLY_AT_PAGE, rShape.GetAnchor().GetPageNum()));
    }
    if ((aAnchId == RndStdIds::FLY_AT_PARA || aAnchId == RndStdIds::FLY_AT_CHAR)
        && rShape.GetAnchor().GetContentAnchor())
    {
        aTextBoxSet.Put(rShape.GetAnchor());
    }
    do
    {