[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Thu Feb 23 07:22:17 PST 2012


 sw/source/core/doc/doclay.cxx      |    3 +++
 sw/source/core/docnode/ndcopy.cxx  |    2 +-
 sw/source/core/unocore/unotext.cxx |   21 +++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

New commits:
commit 2d5231041203f2471c4d2f052dde6f4808fa8344
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Feb 22 23:58:04 2012 +0100

    fdo#46482: prevent duplication of frames:
    
    SwDoc::MakeFlySection: abuse the SwDoc::mbRedlineMove flag, which
    (with the fix for fdo#40599) does exactly what is necessary to prevent
    the spurious copies.
    Also, remove the ugly hack to work around this problem from
    SwXText::convertToTextFrame.
    (cherry picked from commit 91fab30f3b1617024ee2eadf3c7ad1ea84d7f6dd)

diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index a2ae209..59377f9 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -840,8 +840,10 @@ if( GetIDocumentUndoRedo().DoesUndo() )
                 SwPaM* pTmp = (SwPaM*)&rPam;
                 sal_Bool bOldFlag = mbCopyIsMove;
                 bool const bOldUndo = GetIDocumentUndoRedo().DoesUndo();
+                bool const bOldRedlineMove(IsRedlineMove());
                 mbCopyIsMove = sal_True;
                 GetIDocumentUndoRedo().DoUndo(false);
+                SetRedlineMove(true);
                 do {
                     if( pTmp->HasMark() &&
                         *pTmp->GetPoint() != *pTmp->GetMark() )
@@ -850,6 +852,7 @@ if( GetIDocumentUndoRedo().DoesUndo() )
                     }
                     pTmp = static_cast<SwPaM*>(pTmp->GetNext());
                 } while ( &rPam != pTmp );
+                SetRedlineMove(bOldRedlineMove);
                 mbCopyIsMove = bOldFlag;
                 GetIDocumentUndoRedo().DoUndo(bOldUndo);
 
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index a562a25..71939e4 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1720,12 +1720,6 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
                         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);
                     }
                 }
             }
commit ab55f25ecad89e05a440770cfc8c87320ae010ef
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Feb 22 23:48:57 2012 +0100

    fdo#40599 i#112763: fix frame duplication:
    
    SwDoc::CopyFlyInFlyImpl: When called from SwRedline::CopyToSection, do not
    copy frames that are anchored at the redline end node by checking
    IsRedlineMove(); these frames are not deleted by DelCopyOfSection and were
    thus duplicated on every Show/Hide redlines.
    (regression from 62ebbb006b4a11974e14dd61d3c453a98336f951 (CWS os131))
    (cherry picked from commit 23e52c207760c596cc2f841ef59f3100c110d591)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 3ac2c18..0a823c2 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -1432,7 +1432,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg,
             bool bAdd = false;
             if( pAPos->nNode < rRg.aEnd )
                 bAdd = true;
-            if( !bAdd )
+            if (!bAdd && !IsRedlineMove()) // fdo#40599: not for redline move
             {
                 bool bEmptyNode = false;
                 bool bLastNode = false;
commit 65a3888588c81991e811e1ff15ba05195443dac0
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Feb 20 10:12:01 2012 +0100

    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.
    (cherry picked from commit 9592f56323de27f9e1d890ee6259a5f4f328cbd3)
    
    Signed-off-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 820239f..a562a25 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);


More information about the Libreoffice-commits mailing list