Kaydet (Commit) e84f0a9b authored tarafından Michael Stahl's avatar Michael Stahl

Revert "Fix single node CopyRange"

This reverts commit 9099e21b.

It causes the problem that frames anchored to the same node where
redlines start or end get duplicated during Hide.

Jan-Marek said that the original mail-merge related problem this change
was fixing is now most likely fixed differently, and the test in
testMultiPageAnchoredDraws() still passes.

Change-Id: Ie84fed3f64be7696782bc557004eb18fccc5b64b
üst ed031895
...@@ -79,6 +79,9 @@ public: ...@@ -79,6 +79,9 @@ public:
The position can be in the same or in an another document. It can also The position can be in the same or in an another document. It can also
be within the range! be within the range!
\warning The range has to include at least two nodes or has to be a
SwDoc::IsColumnSelection!
Normally this function should work only with content nodes. But there Normally this function should work only with content nodes. But there
is a special case used by SwDoc::Paste, which starts the SwPaM at the is a special case used by SwDoc::Paste, which starts the SwPaM at the
content start node. This position doesn't contain any content: content start node. This position doesn't contain any content:
......
...@@ -1584,7 +1584,7 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons ...@@ -1584,7 +1584,7 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
// Catch if there's no copy to do // Catch if there's no copy to do
if( !rPam.HasMark() || ( *pStt > *pEnd && !bColumnSel ) ) if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) )
return false; return false;
// Prevent copying in Flys that are anchored in the area // Prevent copying in Flys that are anchored in the area
...@@ -3132,8 +3132,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( ...@@ -3132,8 +3132,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
const SwPaM* pCopiedPaM, const SwPaM* pCopiedPaM,
const bool bMakeNewFrms, const bool bMakeNewFrms,
const bool bDelRedlines, const bool bDelRedlines,
const bool bCopyFlyAtFly, const bool bCopyFlyAtFly ) const
const bool bMergedFirstNode ) const
{ {
SwDoc* pDest = rInsPos.GetNode().GetDoc(); SwDoc* pDest = rInsPos.GetNode().GetDoc();
...@@ -3141,17 +3140,13 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( ...@@ -3141,17 +3140,13 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
SwNodeIndex aSavePos( rInsPos, -1 ); SwNodeIndex aSavePos( rInsPos, -1 );
bool bEndIsEqualEndPos = rInsPos == rRg.aEnd; bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
SwNodeRange aRg( rRg ); m_rDoc.GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, true );
if ( bMergedFirstNode ) ++aSavePos;
aRg.aStart++; if( bEndIsEqualEndPos )
if ( aRg.aStart <= aRg.aEnd )
m_rDoc.GetNodes()._CopyNodes( aRg, rInsPos, bMakeNewFrms, true );
if ( !bMergedFirstNode )
++aSavePos;
if ( bEndIsEqualEndPos )
const_cast<SwNodeIndex&>(rRg.aEnd) = aSavePos; const_cast<SwNodeIndex&>(rRg.aEnd) = aSavePos;
aRedlRest.Restore(); aRedlRest.Restore();
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
{ {
//JP 17.06.99: Bug 66973 - check count only if the selection is in //JP 17.06.99: Bug 66973 - check count only if the selection is in
...@@ -3165,9 +3160,9 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( ...@@ -3165,9 +3160,9 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
!aTmpI.GetNode().IsEndNode() ) !aTmpI.GetNode().IsEndNode() )
{ {
// If the range starts with a SwStartNode, it isn't copied // If the range starts with a SwStartNode, it isn't copied
sal_uInt16 offset = (aRg.aStart.GetNode().GetNodeType() != ND_STARTNODE) ? 1 : 0; sal_uInt16 offset = (rRg.aStart.GetNode().GetNodeType() != ND_STARTNODE) ? 1 : 0;
OSL_ENSURE( rInsPos.GetIndex() - aSavePos.GetIndex() == OSL_ENSURE( rInsPos.GetIndex() - aSavePos.GetIndex() ==
aRg.aEnd.GetIndex() - aRg.aStart.GetIndex() - 1 + offset, rRg.aEnd.GetIndex() - rRg.aStart.GetIndex() - 1 + offset,
"An insufficient number of nodes were copied!" ); "An insufficient number of nodes were copied!" );
} }
} }
...@@ -3175,7 +3170,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly( ...@@ -3175,7 +3170,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
{ {
::sw::UndoGuard const undoGuard(pDest->GetIDocumentUndoRedo()); ::sw::UndoGuard const undoGuard(pDest->GetIDocumentUndoRedo());
CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly, bMergedFirstNode ); CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly );
} }
SwNodeRange aCpyRange( aSavePos, rInsPos ); SwNodeRange aCpyRange( aSavePos, rInsPos );
...@@ -3201,8 +3196,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl( ...@@ -3201,8 +3196,7 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
const SwNodeRange& rRg, const SwNodeRange& rRg,
const sal_Int32 nEndContentIndex, const sal_Int32 nEndContentIndex,
const SwNodeIndex& rStartIdx, const SwNodeIndex& rStartIdx,
const bool bCopyFlyAtFly, const bool bCopyFlyAtFly ) const
const bool bMergedFirstNode ) const
{ {
// First collect all Flys, sort them according to their ordering number, // First collect all Flys, sort them according to their ordering number,
// and then only copy them. This maintains the ordering numbers (which are only // and then only copy them. This maintains the ordering numbers (which are only
...@@ -3335,8 +3329,6 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl( ...@@ -3335,8 +3329,6 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
++aIdx; ++aIdx;
} }
if ( bMergedFirstNode )
nAnchorTextNdNumInRange--;
if ( !bAnchorTextNdFound ) if ( !bAnchorTextNdFound )
{ {
...@@ -4105,7 +4097,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4105,7 +4097,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
SwPosition* pEnd = rPam.End(); SwPosition* pEnd = rPam.End();
// Catch when there's no copy to do. // Catch when there's no copy to do.
if( !rPam.HasMark() || ( *pStt > *pEnd && !bColumnSel ) || if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ||
//JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end //JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end
//JP 15.11.2001: don't test inclusive the end, ever exclusive //JP 15.11.2001: don't test inclusive the end, ever exclusive
( pDoc == &m_rDoc && *pStt <= rPos && rPos < *pEnd )) ( pDoc == &m_rDoc && *pStt <= rPos && rPos < *pEnd ))
...@@ -4193,8 +4185,6 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4193,8 +4185,6 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
pNumRuleToPropagate = 0; pNumRuleToPropagate = 0;
} }
bool bHandledStartNode = false;
// This do/while block is only there so that we can break out of it! // This do/while block is only there so that we can break out of it!
do { do {
if( pSttTextNd ) if( pSttTextNd )
...@@ -4202,8 +4192,6 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4202,8 +4192,6 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
// Don't copy the beginning completely? // Don't copy the beginning completely?
if( !bCopyCollFormat || bColumnSel || pStt->nContent.GetIndex() ) if( !bCopyCollFormat || bColumnSel || pStt->nContent.GetIndex() )
{ {
bHandledStartNode = true;
SwIndex aDestIdx( rPos.nContent ); SwIndex aDestIdx( rPos.nContent );
bool bCopyOk = false; bool bCopyOk = false;
if( !pDestTextNd ) if( !pDestTextNd )
...@@ -4279,11 +4267,18 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4279,11 +4267,18 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
pEnd->nContent -= nCpyLen; pEnd->nContent -= nCpyLen;
} }
if( bCopyCollFormat && bOneNode ) if( bOneNode )
{ {
pSttTextNd->CopyCollFormat( *pDestTextNd ); if (bCopyCollFormat)
POP_NUMRULE_STATE {
pSttTextNd->CopyCollFormat( *pDestTextNd );
POP_NUMRULE_STATE
}
break;
} }
aRg.aStart++;
} }
} }
else if( pDestTextNd ) else if( pDestTextNd )
...@@ -4340,7 +4335,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4340,7 +4335,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
} }
pDestTextNd = aInsPos.GetNode().GetTextNode(); pDestTextNd = aInsPos.GetNode().GetTextNode();
if( pEndTextNd && (!bOneNode || !bHandledStartNode) ) if (pEndTextNd)
{ {
SwIndex aDestIdx( rPos.nContent ); SwIndex aDestIdx( rPos.nContent );
if( !pDestTextNd ) if( !pDestTextNd )
...@@ -4384,7 +4379,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4384,7 +4379,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
if( bCopyAll || aRg.aStart != aRg.aEnd ) if( bCopyAll || aRg.aStart != aRg.aEnd )
{ {
SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange ); SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange );
if( !bOneNode && pSttTextNd && bCopyCollFormat && pDestTextNd->HasSwAttrSet() ) if (pSttTextNd && bCopyCollFormat && pDestTextNd->HasSwAttrSet())
{ {
aBrkSet.Put( *pDestTextNd->GetpSwAttrSet() ); aBrkSet.Put( *pDestTextNd->GetpSwAttrSet() );
if( SfxItemState::SET == aBrkSet.GetItemState( RES_BREAK, false ) ) if( SfxItemState::SET == aBrkSet.GetItemState( RES_BREAK, false ) )
...@@ -4396,15 +4391,13 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos, ...@@ -4396,15 +4391,13 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
if( aInsPos == pEnd->nNode ) if( aInsPos == pEnd->nNode )
{ {
SwNodeIndex aSaveIdx( aInsPos, -1 ); SwNodeIndex aSaveIdx( aInsPos, -1 );
CopyWithFlyInFly( aRg, 0, aInsPos, &rPam, bMakeNewFrms, CopyWithFlyInFly( aRg, 0,aInsPos, &rPam, bMakeNewFrms, false );
false, false, bHandledStartNode );
++aSaveIdx; ++aSaveIdx;
pEnd->nNode = aSaveIdx; pEnd->nNode = aSaveIdx;
pEnd->nContent.Assign( aSaveIdx.GetNode().GetTextNode(), 0 ); pEnd->nContent.Assign( aSaveIdx.GetNode().GetTextNode(), 0 );
} }
else else
CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, bMakeNewFrms, false );
bMakeNewFrms, false, false, bHandledStartNode );
bCopyBookmarks = false; bCopyBookmarks = false;
......
...@@ -912,6 +912,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu ...@@ -912,6 +912,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
SwPageDesc *const pTargetPageDesc, bool const bDeletePrevious, int pageOffset) SwPageDesc *const pTargetPageDesc, bool const bDeletePrevious, int pageOffset)
{ {
// GetEndOfExtras + 1 = StartOfContent == no content node! // GetEndOfExtras + 1 = StartOfContent == no content node!
// this ensures, that we have at least two nodes in the SwPaM.
// @see IDocumentContentOperations::CopyRange // @see IDocumentContentOperations::CopyRange
SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 ); SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
SwNodeIndex aSourceEndIdx( rSource.GetNodes().GetEndOfContent(), -1 ); SwNodeIndex aSourceEndIdx( rSource.GetNodes().GetEndOfContent(), -1 );
......
...@@ -106,13 +106,11 @@ public: ...@@ -106,13 +106,11 @@ public:
const SwPaM* pCopiedPaM = NULL, const SwPaM* pCopiedPaM = NULL,
bool bMakeNewFrms = true, bool bMakeNewFrms = true,
bool bDelRedlines = true, bool bDelRedlines = true,
bool bCopyFlyAtFly = false, bool bCopyFlyAtFly = false ) const;
const bool bMergedFirstNode = false ) const;
void CopyFlyInFlyImpl( const SwNodeRange& rRg, void CopyFlyInFlyImpl( const SwNodeRange& rRg,
const sal_Int32 nEndContentIndex, const sal_Int32 nEndContentIndex,
const SwNodeIndex& rStartIdx, const SwNodeIndex& rStartIdx,
const bool bCopyFlyAtFly = false, const bool bCopyFlyAtFly = false ) const;
const bool bMergedFirstNode = false ) const;
/// Parameters for _Rst and lcl_SetTextFormatColl /// Parameters for _Rst and lcl_SetTextFormatColl
//originallyfrom docfmt.cxx //originallyfrom docfmt.cxx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment