diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-02-20 10:12:01 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-02-20 10:33:33 +0100 |
commit | 9592f56323de27f9e1d890ee6259a5f4f328cbd3 (patch) | |
tree | c7d0e1489698d009ba3dc121cef98e003eab29ee /sw | |
parent | Shared libraries must in practice be called lib*.so on Android (diff) | |
download | core-9592f56323de27f9e1d890ee6259a5f4f328cbd3.tar.gz core-9592f56323de27f9e1d890ee6259a5f4f328cbd3.zip |
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.
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 27 |
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); |