[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Wed Sep 10 12:55:24 PDT 2014
sw/inc/IDocumentContentOperations.hxx | 3
sw/source/core/doc/DocumentContentOperationsManager.cxx | 58 +++++++++-------
sw/source/core/doc/docnew.cxx | 1
sw/source/core/inc/DocumentContentOperationsManager.hxx | 6 +
sw/source/core/view/vdraw.cxx | 11 +++
5 files changed, 48 insertions(+), 31 deletions(-)
New commits:
commit 508d2d2b1a6a23043c8c0f0d3fea4ec033ac2684
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Sun Jul 13 20:15:55 2014 +0200
fdo#80926 Don't move anchors of invalid pages
If the anchor is valid, check if its page is valid too,
before moving anchors on view change.
Change-Id: Idffdfdb786cb29a105c06d652e6ad7315abfb4c5
Reviewed-on: https://gerrit.libreoffice.org/10976
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
diff --git a/sw/source/core/view/vdraw.cxx b/sw/source/core/view/vdraw.cxx
index cfadd9e..4ac2908 100644
--- a/sw/source/core/view/vdraw.cxx
+++ b/sw/source/core/view/vdraw.cxx
@@ -227,6 +227,17 @@ void SwViewImp::NotifySizeChg( const Size &rNewSz )
{
continue;
}
+ else
+ {
+ // Actually this should never happen but currently layouting
+ // is broken. So don't move anchors, if the page is invalid.
+ // This should be turned into an DBG_ASSERT, once layouting is fixed!
+ const SwPageFrm *pPageFrm = pAnchor->FindPageFrm();
+ if (!pPageFrm || pPageFrm->IsInvalid() ) {
+ SAL_WARN( "sw.resizeview", "Trying to move anchor from invalid page - fix layouting!" );
+ continue;
+ }
+ }
// no move for drawing objects in header/footer
if ( pAnchor->FindFooterOrHeader() )
commit 9099e21b89184bd4e39def497e483cac4a77ec5a
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Tue Jul 1 15:45:47 2014 +0200
Fix single node CopyRange
Previously there was a restriction for the range to contain at
least two nodes.
Change-Id: Iadf21d3928303c2ab8df0d93dabd969ed1ff7e09
Reviewed-on: https://gerrit.libreoffice.org/10972
Reviewed-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen at canonical.com>
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index f30b774..2676a2f 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -70,9 +70,6 @@ public:
The position can be in the same or in an another document. It can also
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
is a special case used by SwDoc::Paste, which starts the SwPaM at the
content start node. This position doesn't contain any content:
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index e9aeddb..c6cabe8 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1586,7 +1586,7 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
// Catch if there's no copy to do
- if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) )
+ if( !rPam.HasMark() || ( *pStt > *pEnd && !bColumnSel ) )
return false;
// Prevent copying in Flys that are anchored in the area
@@ -3111,7 +3111,8 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
const SwPaM* pCopiedPaM,
const bool bMakeNewFrms,
const bool bDelRedlines,
- const bool bCopyFlyAtFly ) const
+ const bool bCopyFlyAtFly,
+ const bool bMergedFirstNode ) const
{
SwDoc* pDest = rInsPos.GetNode().GetDoc();
@@ -3119,13 +3120,17 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
SwNodeIndex aSavePos( rInsPos, -1 );
bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
- m_rSwdoc.GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, true );
- ++aSavePos;
- if( bEndIsEqualEndPos )
+ SwNodeRange aRg( rRg );
+ if ( bMergedFirstNode )
+ aRg.aStart++;
+ if ( aRg.aStart <= aRg.aEnd )
+ m_rSwdoc.GetNodes()._CopyNodes( aRg, rInsPos, bMakeNewFrms, true );
+ if ( !bMergedFirstNode )
+ ++aSavePos;
+ if ( bEndIsEqualEndPos )
((SwNodeIndex&)rRg.aEnd) = aSavePos;
aRedlRest.Restore();
-
#if OSL_DEBUG_LEVEL > 0
{
//JP 17.06.99: Bug 66973 - check count only if the selection is in
@@ -3139,9 +3144,9 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
!aTmpI.GetNode().IsEndNode() )
{
// If the range starts with a SwStartNode, it isn't copied
- sal_uInt16 offset = (rRg.aStart.GetNode().GetNodeType() != ND_STARTNODE) ? 1 : 0;
+ sal_uInt16 offset = (aRg.aStart.GetNode().GetNodeType() != ND_STARTNODE) ? 1 : 0;
OSL_ENSURE( rInsPos.GetIndex() - aSavePos.GetIndex() ==
- rRg.aEnd.GetIndex() - rRg.aStart.GetIndex() - 1 + offset,
+ aRg.aEnd.GetIndex() - aRg.aStart.GetIndex() - 1 + offset,
"An insufficient number of nodes were copied!" );
}
}
@@ -3149,7 +3154,7 @@ void DocumentContentOperationsManager::CopyWithFlyInFly(
{
::sw::UndoGuard const undoGuard(pDest->GetIDocumentUndoRedo());
- CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly );
+ CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly, bMergedFirstNode );
}
SwNodeRange aCpyRange( aSavePos, rInsPos );
@@ -3175,7 +3180,8 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
const SwNodeRange& rRg,
const sal_Int32 nEndContentIndex,
const SwNodeIndex& rStartIdx,
- const bool bCopyFlyAtFly ) const
+ const bool bCopyFlyAtFly,
+ const bool bMergedFirstNode ) const
{
// First collect all Flys, sort them according to their ordering number,
// and then only copy them. This maintains the ordering numbers (which are only
@@ -3295,6 +3301,9 @@ void DocumentContentOperationsManager::CopyFlyInFlyImpl(
++aIdx;
}
+ if ( bMergedFirstNode )
+ nAnchorTxtNdNumInRange--;
+
if ( !bAnchorTxtNdFound )
{
// This case can *not* happen, but to be robust take the first
@@ -4063,7 +4072,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
SwPosition* pEnd = rPam.End();
// 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 15.11.2001: don't test inclusive the end, ever exclusive
( pDoc == &m_rSwdoc && *pStt <= rPos && rPos < *pEnd ))
@@ -4151,6 +4160,8 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
pNumRuleToPropagate = 0;
}
+ bool bHandledStartNode = false;
+
// This do/while block is only there so that we can break out of it!
do {
if( pSttTxtNd )
@@ -4158,6 +4169,8 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
// Don't copy the beginning completely?
if( !bCopyCollFmt || bColumnSel || pStt->nContent.GetIndex() )
{
+ bHandledStartNode = true;
+
SwIndex aDestIdx( rPos.nContent );
bool bCopyOk = false;
if( !pDestTxtNd )
@@ -4233,18 +4246,11 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
pEnd->nContent -= nCpyLen;
}
- if( bOneNode )
+ if( bCopyCollFmt && bOneNode )
{
- if( bCopyCollFmt )
- {
- pSttTxtNd->CopyCollFmt( *pDestTxtNd );
- POP_NUMRULE_STATE
- }
-
- break;
+ pSttTxtNd->CopyCollFmt( *pDestTxtNd );
+ POP_NUMRULE_STATE
}
-
- aRg.aStart++;
}
}
else if( pDestTxtNd )
@@ -4301,7 +4307,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
}
pDestTxtNd = aInsPos.GetNode().GetTxtNode();
- if( pEndTxtNd )
+ if( pEndTxtNd && (!bOneNode || !bHandledStartNode) )
{
SwIndex aDestIdx( rPos.nContent );
if( !pDestTxtNd )
@@ -4345,7 +4351,7 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
if( bCopyAll || aRg.aStart != aRg.aEnd )
{
SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange );
- if( pSttTxtNd && bCopyCollFmt && pDestTxtNd->HasSwAttrSet() )
+ if( !bOneNode && pSttTxtNd && bCopyCollFmt && pDestTxtNd->HasSwAttrSet() )
{
aBrkSet.Put( *pDestTxtNd->GetpSwAttrSet() );
if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_BREAK, false ) )
@@ -4357,13 +4363,15 @@ bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
if( aInsPos == pEnd->nNode )
{
SwNodeIndex aSaveIdx( aInsPos, -1 );
- CopyWithFlyInFly( aRg, 0,aInsPos, &rPam, bMakeNewFrms, false );
+ CopyWithFlyInFly( aRg, 0, aInsPos, &rPam, bMakeNewFrms,
+ false, false, bHandledStartNode );
++aSaveIdx;
pEnd->nNode = aSaveIdx;
pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 );
}
else
- CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, bMakeNewFrms, false );
+ CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam,
+ bMakeNewFrms, false, false, bHandledStartNode );
bCopyBookmarks = false;
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 60330c8..a05b426 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -943,7 +943,6 @@ void SwDoc::Append( const SwDoc& rSource, sal_uInt16 nStartPageNumber,
SwPageDesc* pTargetPageDesc, bool bDeletePrevious )
{
// GetEndOfExtras + 1 = StartOfContent == no content node!
- // this ensures, that we have at least two nodes in the SwPaM.
// @see IDocumentContentOperations::CopyRange
SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
SwNodeIndex aSourceEndIdx( rSource.GetNodes().GetEndOfContent(), -1 );
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx
index a61f8e0..f5745b6 100644
--- a/sw/source/core/inc/DocumentContentOperationsManager.hxx
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -106,11 +106,13 @@ public:
const SwPaM* pCopiedPaM = NULL,
bool bMakeNewFrms = true,
bool bDelRedlines = true,
- bool bCopyFlyAtFly = false ) const;
+ bool bCopyFlyAtFly = false,
+ const bool bMergedFirstNode = false ) const;
void CopyFlyInFlyImpl( const SwNodeRange& rRg,
const sal_Int32 nEndContentIndex,
const SwNodeIndex& rStartIdx,
- const bool bCopyFlyAtFly = false ) const;
+ const bool bCopyFlyAtFly = false,
+ const bool bMergedFirstNode = false ) const;
/// Parameters for _Rst and lcl_SetTxtFmtColl
//originallyfrom docfmt.cxx
More information about the Libreoffice-commits
mailing list