diff options
Diffstat (limited to 'sw/source/core/frmedt/fecopy.cxx')
-rw-r--r-- | sw/source/core/frmedt/fecopy.cxx | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 1d8b0ef680..01eee5072f 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -195,18 +195,20 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText ) } else { - SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall( pObj )); - SwFrameFormat *pFormat = pContact->GetFormat(); - SwFormatAnchor aAnchor( pFormat->GetAnchor() ); - if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) || - (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) || - (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) || - (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId())) + if (SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall( pObj ))) { - aAnchor.SetAnchor( &aPos ); - } + SwFrameFormat *pFormat = pContact->GetFormat(); + SwFormatAnchor aAnchor( pFormat->GetAnchor() ); + if ((RndStdIds::FLY_AT_PARA == aAnchor.GetAnchorId()) || + (RndStdIds::FLY_AT_CHAR == aAnchor.GetAnchorId()) || + (RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId()) || + (RndStdIds::FLY_AS_CHAR == aAnchor.GetAnchorId())) + { + aAnchor.SetAnchor( &aPos ); + } - rClpDoc.getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true ); + rClpDoc.getIDocumentLayoutAccess().CopyLayoutFormat( *pFormat, aAnchor, true, true ); + } } } } @@ -297,6 +299,9 @@ bool SwFEShell::CopyDrawSel( SwFEShell& rDestShell, const Point& rSttPt, SdrObject *pObj = aMrkList.GetMark( i )->GetMarkedSdrObj(); SwDrawContact *pContact = static_cast<SwDrawContact*>(GetUserCall( pObj )); + if (!pContact) + continue; + SwFrameFormat *pFormat = pContact->GetFormat(); const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); @@ -1088,9 +1093,24 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable) --aIndexBefore; + // copying to the clipboard, the section is inserted + // at the start of the nodes, followed by empty text node + bool const isSourceSection(aCpyPam.Start()->GetNode().IsSectionNode() + && aCpyPam.End()->GetNodeIndex() == aCpyPam.Start()->GetNode().EndOfSectionIndex() + 1 + && aCpyPam.End()->GetNode().IsTextNode() + && aCpyPam.End()->GetNode().GetTextNode()->Len() == 0); + rClpDoc.getIDocumentContentOperations().CopyRange(aCpyPam, rInsPos, SwCopyFlags::CheckPosInFly); // Note: aCpyPam is invalid now + if (isSourceSection + && aIndexBefore.GetNode().IsStartNode() + && rInsPos.GetNode().GetTextNode()->Len() == 0) + { // if there is an empty text node at the start, it + // should be *replaced* by the section, so delete it + GetDoc()->getIDocumentContentOperations().DelFullPara(rPaM); + } + ++aIndexBefore; SwPaM aPaM(aIndexBefore.GetNode(), rInsPos.GetNode()); |