handle properly anchor transition at page->at paragraph->as character

Otherwise setting text range afterwards crashes with pHnt being NULL.

Change-Id: Ib4ac2712c061605dcaaa262280c0307f7a9af2ce
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 329bed9..267f6f2 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1344,18 +1344,29 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
                            aSet.Put( aNewAnchor );
                            pFmt->SetFmtAttr(aSet);
                            bSetAttr = false;
                            if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
                                (FLY_AS_CHAR != eOldAnchorId))
                        }
                        if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
                            (FLY_AS_CHAR != eOldAnchorId))
                        {
                            SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
                            if( pDoc->GetCurrentLayout() )
                            {
                                //the RES_TXTATR_FLYCNT needs to be added now
                                SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
                                SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
                                SwFmtFlyCnt aFmt( pFlyFmt );
                                pNd->InsertItem(aFmt,
                                    aPam.GetPoint()->nContent.GetIndex(), 0 );
                                //aPam.GetPoint()->nContent--;

                                SwCrsrMoveState aState( MV_SETONLYTEXT );
                                Point aTmp( pObj->GetSnapRect().TopLeft() );
                                pDoc->GetCurrentLayout()->GetCrsrOfst( aPam.GetPoint(), aTmp, &aState );
                            }
                            else
                            {
                                //without access to the layout the last node of the body will be used as anchor position
                                aPam.Move( fnMoveBackward, fnGoDoc );
                            }
                            //the RES_TXTATR_FLYCNT needs to be added now
                            SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
                            SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a TxtNode." );
                            SwFmtFlyCnt aFmt( pFlyFmt );
                            pNd->InsertItem(aFmt,
                                aPam.GetPoint()->nContent.GetIndex(), 0 );
                            //aPam.GetPoint()->nContent--;
                        }
                        if( bSetAttr )
                            pFmt->SetFmtAttr(aSet);