[Libreoffice-commits] core.git: 2 commits - sw/source
Michael Stahl
mstahl at redhat.com
Wed Mar 27 15:49:22 PDT 2013
sw/source/core/crsr/crsrsh.cxx | 60 +++++++++--------------------------------
1 file changed, 14 insertions(+), 46 deletions(-)
New commits:
commit efc5995170f2ffe98374acb16a4f851bede6842d
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Mar 27 23:33:44 2013 +0100
SwCrsrShell: remove pointless resetting of Mark positions...
... before calling DeleteMark(), which actually resets the Mark
position to something guaranteed not to be an SwIndexReg since CWS
odfmetadata2; checking HasMark() before DeleteMark() is pointless too.
Change-Id: I145c3800a4a7e5d20de9567d8f3163431577e918
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 0c9a620..73c01be 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -808,15 +808,7 @@ void SwCrsrShell::ClearMark()
delete pCurCrsr->GetNext();
pTblCrsr->DeleteMark();
- if( pCurCrsr->HasMark() )
- {
- // move content part from mark to nodes array if not all indices
- // were moved correctly (e.g. when deleting header/footer)
- SwPosition& rPos = *pCurCrsr->GetMark();
- rPos.nNode.Assign( mpDoc->GetNodes(), 0 );
- rPos.nContent.Assign( 0, 0 );
- pCurCrsr->DeleteMark();
- }
+ pCurCrsr->DeleteMark();
*pCurCrsr->GetPoint() = *pTblCrsr->GetPoint();
pCurCrsr->GetPtPos() = pTblCrsr->GetPtPos();
@@ -827,11 +819,6 @@ void SwCrsrShell::ClearMark()
{
if( !pCurCrsr->HasMark() )
return;
- // move content part from mark to nodes array if not all indices
- // were moved correctly (e.g. when deleting header/footer)
- SwPosition& rPos = *pCurCrsr->GetMark();
- rPos.nNode.Assign( mpDoc->GetNodes(), 0 );
- rPos.nContent.Assign( 0, 0 );
pCurCrsr->DeleteMark();
if( !nCrsrMove )
pCurCrsr->SwSelPaintRects::Show();
@@ -1214,8 +1201,7 @@ void SwCrsrShell::UpdateCrsrPos()
aTmpState.bSetInReadOnly = IsReadOnlyAvailable();
GetLayout()->GetCrsrOfst( pShellCrsr->GetPoint(), pShellCrsr->GetPtPos(),
&aTmpState );
- if( pShellCrsr->HasMark())
- pShellCrsr->DeleteMark();
+ pShellCrsr->DeleteMark();
}
IGrammarContact *pGrammarContact = GetDoc() ? GetDoc()->getGrammarContact() : 0;
if( pGrammarContact )
@@ -2354,10 +2340,9 @@ sal_Bool SwCrsrShell::ParkTblCrsr()
while( pCurCrsr->GetNext() != pCurCrsr )
delete pCurCrsr->GetNext();
- // *always* move cursor's SPoint and Mark
- pCurCrsr->SetMark();
- *pCurCrsr->GetMark() = *pCurCrsr->GetPoint() = *pTblCrsr->GetPoint();
+ // *always* move cursor's Point and Mark
pCurCrsr->DeleteMark();
+ *pCurCrsr->GetPoint() = *pTblCrsr->GetPoint();
return sal_True;
}
@@ -2388,7 +2373,7 @@ void SwCrsrShell::_ParkPams( SwPaM* pDelRg, SwShellCrsr** ppDelRing )
pTmpDel = pTmp;
bGoNext = true;
- if( pTmpDel ) // is the pam in area -> delete
+ if (pTmpDel) // is the pam in the range -> delete
{
sal_Bool bDelete = sal_True;
if( *ppDelRing == pTmpDel )
@@ -2409,20 +2394,10 @@ void SwCrsrShell::_ParkPams( SwPaM* pDelRg, SwShellCrsr** ppDelRing )
delete pTmpDel; // invalidate old area
else
{
- pTmpDel->GetPoint()->nContent.Assign( 0, 0 );
- pTmpDel->GetPoint()->nNode = 0;
- pTmpDel->SetMark();
pTmpDel->DeleteMark();
}
pTmpDel = 0;
}
- else if( !pTmp->HasMark() )
- {
- // Take care that not used indices are considered.
- // SPoint is not in area but maybe GetMark is, thus set it.
- pTmp->SetMark();
- pTmp->DeleteMark();
- }
if( bGoNext )
pTmp = (SwPaM*)pTmp->GetNext();
} while( !bGoNext || *ppDelRing != pTmp );
@@ -2478,9 +2453,6 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx )
SwNode* pTblNd = pTCrsr->GetPoint()->nNode.GetNode().FindTableNode();
if ( pTblNd )
{
- pTCrsr->GetPoint()->nContent.Assign( 0, 0 );
- pTCrsr->GetPoint()->nNode = 0;
- pTCrsr->SetMark();
pTCrsr->DeleteMark();
pSh->pCurCrsr->GetPoint()->nNode = *pTblNd;
}
@@ -3065,14 +3037,6 @@ void SwCrsrShell::SetSelection( const SwPaM& rCrsr )
EndAction();
}
-static void lcl_RemoveMark( SwPaM* pPam )
-{
- OSL_ENSURE( pPam->HasMark(), "Don't remove pPoint!" );
- pPam->GetMark()->nContent.Assign( 0, 0 );
- pPam->GetMark()->nNode = 0;
- pPam->DeleteMark();
-}
-
static const SwStartNode* lcl_NodeContext( const SwNode& rNode )
{
const SwStartNode *pRet = rNode.StartOfSectionNode();
@@ -3135,7 +3099,7 @@ void SwCrsrShell::ClearUpCrsrs()
if( pStartCrsr->HasMark() && !sw_PosOk( *pStartCrsr->GetMark() ) )
{
- lcl_RemoveMark( pStartCrsr );
+ pStartCrsr->DeleteMark();
bChanged = true;
}
if( !sw_PosOk( *pStartCrsr->GetPoint() ) )
commit b227a8e4d65e4bbfe991aed9342fe3e30eca8639
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Mar 27 23:09:59 2013 +0100
fdo#60513: SwCrsrShell::Push(): take position from table cursor
If there is a table cursor, store its point/mark position on the cursor
stack instead of pCurCrsr, which in this case is just one cell in a ring
that contains a SwShellCrsr for every selected cell.
SwCrsrShell::Pop() is surprisingly able to restore the prior state,
because it calls UpdateCrsr(), which detects that the pCurCrsr spans
multiple table cells and re-creates pTblCrsr, and then later on the
first GetCrsr() call SwTableCursor::MakeBoxSels() will restore the ring
of SwShellCrsrs from the pTblCrsr selection.
Change-Id: Ibe9a7f379ece61c7dab1a6f69abaebf42a4c85ec
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 8f0c03c..0c9a620 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1859,13 +1859,17 @@ void SwCrsrShell::RefreshBlockCursor()
/// create a copy of the cursor and save it in the stack
void SwCrsrShell::Push()
{
- pCrsrStk = new SwShellCrsr( *this, *pCurCrsr->GetPoint(),
- pCurCrsr->GetPtPos(), pCrsrStk );
+ // fdo#60513: if we have a table cursor, copy that; else copy current.
+ // This seems to work because UpdateCrsr() will fix this up on Pop(),
+ // then MakeBoxSels() will re-create the current pCurCrsr cell ring.
+ SwShellCrsr *const pCurrent((pTblCrsr) ? pTblCrsr : pCurCrsr);
+ pCrsrStk = new SwShellCrsr( *this, *pCurrent->GetPoint(),
+ pCurrent->GetPtPos(), pCrsrStk );
- if( pCurCrsr->HasMark() )
+ if (pCurrent->HasMark())
{
pCrsrStk->SetMark();
- *pCrsrStk->GetMark() = *pCurCrsr->GetMark();
+ *pCrsrStk->GetMark() = *pCurrent->GetMark();
}
}
More information about the Libreoffice-commits
mailing list