summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-02-20 10:12:01 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-02-20 10:33:33 +0100
commit9592f56323de27f9e1d890ee6259a5f4f328cbd3 (patch)
treec7d0e1489698d009ba3dc121cef98e003eab29ee
parent31826318dfd2f4c38d6bf34f957fe51edc0a2b14 (diff)
n#695479 fix anchor handling in SwXText::convertToTextFrame()
When two (or more) text frames was imported without a non-frame paragraph in between, the first frame was anchored to the second one, instead of a non-frame paragraph. The fix is modelled after what the old RTF import already did in SwRTFParser::Continue() in swparrtf.cxx:493 and SwRTFParser::SetFlysInDoc() in rtffly.cxx:481.
-rw-r--r--sw/source/core/unocore/unotext.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 00c7e0992134..2c2570012df3 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1665,6 +1665,18 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
aStartPam.SetMark();
*aStartPam.End() = *pEndPam->End();
pEndPam.reset(0);
+
+ // see if there are frames already anchored to this node
+ std::vector<SwFrmFmt*> aAnchoredFrames;
+ for (int i = 0; i < m_pImpl->m_pDoc->GetSpzFrmFmts()->Count(); ++i)
+ {
+ SwFrmFmt* pFrmFmt = (*m_pImpl->m_pDoc->GetSpzFrmFmts())[i];
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ if (FLY_AT_PARA == rAnchor.GetAnchorId() &&
+ aStartPam.GetNode()->GetIndex() == rAnchor.GetCntntAnchor()->nNode.GetIndex())
+ aAnchoredFrames.push_back(pFrmFmt);
+ }
+
SwXTextFrame *const pNewFrame = new SwXTextFrame(m_pImpl->m_pDoc);
const uno::Reference< text::XTextFrame > xNewFrame = pNewFrame;
pNewFrame->SetSelection( aStartPam );
@@ -1700,6 +1712,21 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
aNewAnchor.SetAnchor( aMovePam.Start() );
m_pImpl->m_pDoc->SetAttr(
aNewAnchor, *pNewFrame->GetFrmFmt() );
+
+ // also move frames anchored to us
+ for (std::vector<SwFrmFmt*>::iterator i = aAnchoredFrames.begin(); i != aAnchoredFrames.end(); ++i)
+ {
+ // copy the anchor to the next paragraph
+ SwFmtAnchor aAnchor((*i)->GetAnchor());
+ aAnchor.SetAnchor(aMovePam.Start());
+ m_pImpl->m_pDoc->SetAttr(aAnchor, *(*i));
+
+ // delete the old anchor
+ SwSpzFrmFmts* pFrmFmts = m_pImpl->m_pDoc->GetSpzFrmFmts();
+ // here we rely on that fact that this is a sorted list, where the last element is the newly created frame
+ SwFrmFmt *pFrmFmt = (*pFrmFmts)[pFrmFmts->Count()-1];
+ m_pImpl->m_pDoc->DelLayoutFmt(pFrmFmt);
+ }
}
}
m_pImpl->m_pDoc->DelFullPara(aStartPam);