2000-09-18 23:08:29 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* $RCSfile: unocrsr.cxx,v $
|
2008-04-22 13:56:30 +00:00
|
|
|
|
* $Revision: 1.18 $
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:05:05 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2006-09-16 19:48:24 +00:00
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
#include <unocrsr.hxx>
|
|
|
|
|
#include <doc.hxx>
|
|
|
|
|
#include <swtable.hxx>
|
|
|
|
|
#include <docary.hxx>
|
|
|
|
|
#include <rootfrm.hxx>
|
|
|
|
|
|
|
|
|
|
SV_IMPL_PTRARR( SwUnoCrsrTbl, SwUnoCrsrPtr )
|
|
|
|
|
|
|
|
|
|
IMPL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr, 10, 10 )
|
|
|
|
|
|
|
|
|
|
SwUnoCrsr::SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing )
|
2007-11-22 14:31:42 +00:00
|
|
|
|
: SwCursor( rPos, pRing, false ), SwModify( 0 ),
|
2000-10-25 15:02:15 +00:00
|
|
|
|
bRemainInSection( TRUE ),
|
2000-10-26 10:09:45 +00:00
|
|
|
|
bSkipOverHiddenSections( FALSE ),
|
2000-10-25 15:02:15 +00:00
|
|
|
|
bSkipOverProtectSections( FALSE )
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{}
|
|
|
|
|
|
2004-08-23 07:44:16 +00:00
|
|
|
|
// @@@ semantic: no copy ctor.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwUnoCrsr::SwUnoCrsr( SwUnoCrsr& rICrsr )
|
|
|
|
|
: SwCursor( rICrsr ), SwModify( 0 ),
|
2000-10-25 15:02:15 +00:00
|
|
|
|
bRemainInSection( rICrsr.bRemainInSection ),
|
|
|
|
|
bSkipOverHiddenSections( rICrsr.bSkipOverHiddenSections ),
|
|
|
|
|
bSkipOverProtectSections( rICrsr.bSkipOverProtectSections )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
SwUnoCrsr::~SwUnoCrsr()
|
|
|
|
|
{
|
|
|
|
|
SwDoc* pDoc = GetDoc();
|
|
|
|
|
if( !pDoc->IsInDtor() )
|
|
|
|
|
{
|
|
|
|
|
// dann muss der Cursor aus dem Array ausgetragen werden
|
|
|
|
|
SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
|
|
|
|
|
USHORT nDelPos = rTbl.GetPos( this );
|
|
|
|
|
|
|
|
|
|
if( USHRT_MAX != nDelPos )
|
|
|
|
|
rTbl.Remove( nDelPos );
|
2008-04-22 13:56:30 +00:00
|
|
|
|
else {
|
2000-09-18 23:08:29 +00:00
|
|
|
|
ASSERT( !this, "UNO Cursor nicht mehr im Array" );
|
2008-04-22 13:56:30 +00:00
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// den gesamten Ring loeschen!
|
|
|
|
|
while( GetNext() != this )
|
|
|
|
|
{
|
|
|
|
|
Ring* pNxt = GetNext();
|
|
|
|
|
pNxt->MoveTo( 0 ); // ausketten
|
|
|
|
|
delete pNxt; // und loeschen
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-22 15:24:06 +00:00
|
|
|
|
SwUnoCrsr * SwUnoCrsr::Clone() const
|
|
|
|
|
{
|
|
|
|
|
SwUnoCrsr * pNewCrsr = 0;
|
|
|
|
|
|
|
|
|
|
// check if the cursor is a SwUnoTableCrsr, if so clone that type
|
|
|
|
|
const SwUnoTableCrsr * pUnoTableCrsr = *this;
|
|
|
|
|
if (pUnoTableCrsr)
|
|
|
|
|
pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint(), sal_True /* create SwUnoTableCrsr */ );
|
|
|
|
|
else
|
|
|
|
|
pNewCrsr = GetDoc()->CreateUnoCrsr( *GetPoint() );
|
|
|
|
|
if (HasMark())
|
|
|
|
|
{
|
|
|
|
|
pNewCrsr->SetMark();
|
|
|
|
|
*pNewCrsr->GetMark() = *GetMark();
|
|
|
|
|
}
|
|
|
|
|
return pNewCrsr;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwUnoCrsr::operator SwUnoCrsr* () { return this; }
|
|
|
|
|
|
2007-09-27 07:31:37 +00:00
|
|
|
|
|
|
|
|
|
BOOL SwUnoCrsr::IsSelOvr( int eFlags )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( bRemainInSection )
|
|
|
|
|
{
|
|
|
|
|
SwDoc* pDoc = GetDoc();
|
|
|
|
|
SwNodeIndex aOldIdx( *pDoc->GetNodes()[ GetSavePos()->nNode ] );
|
|
|
|
|
SwNodeIndex& rPtIdx = GetPoint()->nNode;
|
2006-08-14 14:54:01 +00:00
|
|
|
|
SwStartNode *pOldSttNd = aOldIdx.GetNode().StartOfSectionNode(),
|
|
|
|
|
*pNewSttNd = rPtIdx.GetNode().StartOfSectionNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( pOldSttNd != pNewSttNd )
|
|
|
|
|
{
|
|
|
|
|
BOOL bMoveDown = GetSavePos()->nNode < rPtIdx.GetIndex();
|
|
|
|
|
BOOL bValidPos = FALSE;
|
2000-10-24 16:21:47 +00:00
|
|
|
|
|
|
|
|
|
// search the correct surrounded start node - which the index
|
|
|
|
|
// can't leave.
|
|
|
|
|
while( pOldSttNd->IsSectionNode() )
|
|
|
|
|
pOldSttNd = pOldSttNd->StartOfSectionNode();
|
|
|
|
|
|
|
|
|
|
// is the new index inside this surrounded section?
|
|
|
|
|
if( rPtIdx > *pOldSttNd &&
|
|
|
|
|
rPtIdx < pOldSttNd->EndOfSectionIndex() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2000-10-24 16:21:47 +00:00
|
|
|
|
// check if it a valid move inside this section
|
|
|
|
|
// (only over SwSection's !)
|
|
|
|
|
const SwStartNode* pInvalidNode;
|
|
|
|
|
do {
|
|
|
|
|
pInvalidNode = 0;
|
2006-08-14 14:54:01 +00:00
|
|
|
|
pNewSttNd = rPtIdx.GetNode().StartOfSectionNode();
|
2000-10-24 16:21:47 +00:00
|
|
|
|
|
|
|
|
|
const SwStartNode *pSttNd = pNewSttNd, *pEndNd = pOldSttNd;
|
|
|
|
|
if( pSttNd->EndOfSectionIndex() >
|
|
|
|
|
pEndNd->EndOfSectionIndex() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2000-10-24 16:21:47 +00:00
|
|
|
|
pEndNd = pNewSttNd;
|
|
|
|
|
pSttNd = pOldSttNd;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2000-10-24 16:21:47 +00:00
|
|
|
|
|
|
|
|
|
while( pSttNd->GetIndex() > pEndNd->GetIndex() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2000-10-24 16:21:47 +00:00
|
|
|
|
if( !pSttNd->IsSectionNode() )
|
|
|
|
|
pInvalidNode = pSttNd;
|
|
|
|
|
pSttNd = pSttNd->StartOfSectionNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2000-10-24 16:21:47 +00:00
|
|
|
|
if( pInvalidNode )
|
|
|
|
|
{
|
|
|
|
|
if( bMoveDown )
|
|
|
|
|
{
|
|
|
|
|
rPtIdx.Assign( *pInvalidNode->EndOfSectionNode(), 1 );
|
|
|
|
|
|
|
|
|
|
if( !rPtIdx.GetNode().IsCntntNode() &&
|
2007-12-12 12:22:38 +00:00
|
|
|
|
( !pDoc->GetNodes().GoNextSection( &rPtIdx ) ||
|
|
|
|
|
rPtIdx > pOldSttNd->EndOfSectionIndex() ) )
|
2000-10-24 16:21:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rPtIdx.Assign( *pInvalidNode, -1 );
|
|
|
|
|
|
|
|
|
|
if( !rPtIdx.GetNode().IsCntntNode() &&
|
2007-12-12 12:22:38 +00:00
|
|
|
|
( !pDoc->GetNodes().GoPrevSection( &rPtIdx ) ||
|
|
|
|
|
rPtIdx < *pOldSttNd ) )
|
2000-10-24 16:21:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
bValidPos = TRUE;
|
|
|
|
|
} while ( pInvalidNode );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bValidPos )
|
|
|
|
|
{
|
|
|
|
|
SwCntntNode* pCNd = GetCntntNode();
|
|
|
|
|
USHORT nCnt = 0;
|
|
|
|
|
if( pCNd && !bMoveDown )
|
|
|
|
|
nCnt = pCNd->Len();
|
|
|
|
|
GetPoint()->nContent.Assign( pCNd, nCnt );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rPtIdx = GetSavePos()->nNode;
|
|
|
|
|
GetPoint()->nContent.Assign( GetCntntNode(), GetSavePos()->nCntnt );
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return SwCursor::IsSelOvr( eFlags );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
2004-06-16 08:34:52 +00:00
|
|
|
|
SwUnoTableCrsr::SwUnoTableCrsr(const SwPosition& rPos)
|
2007-11-22 14:31:42 +00:00
|
|
|
|
: SwCursor(rPos,0,false), SwUnoCrsr(rPos), SwTableCursor(rPos), aTblSel(rPos,0,false)
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2004-06-16 08:34:52 +00:00
|
|
|
|
SetRemainInSection(FALSE);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwUnoTableCrsr::~SwUnoTableCrsr()
|
|
|
|
|
{
|
|
|
|
|
while( aTblSel.GetNext() != &aTblSel )
|
|
|
|
|
delete aTblSel.GetNext(); // und loeschen
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwUnoTableCrsr::operator SwUnoCrsr* () { return this; }
|
|
|
|
|
SwUnoTableCrsr::operator SwTableCursor* () { return this; }
|
|
|
|
|
SwUnoTableCrsr::operator SwUnoTableCrsr* () { return this; }
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SwCursor* SwUnoTableCrsr::Create( SwPaM* pRing ) const
|
|
|
|
|
{
|
|
|
|
|
return SwUnoCrsr::Create( pRing );
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2007-09-27 07:31:37 +00:00
|
|
|
|
BOOL SwUnoTableCrsr::IsSelOvr( int eFlags )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2007-09-27 07:31:37 +00:00
|
|
|
|
BOOL bRet = SwUnoCrsr::IsSelOvr( eFlags );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( !bRet )
|
|
|
|
|
{
|
|
|
|
|
const SwTableNode* pTNd = GetPoint()->nNode.GetNode().FindTableNode();
|
|
|
|
|
bRet = !(pTNd == GetDoc()->GetNodes()[ GetSavePos()->nNode ]->
|
|
|
|
|
FindTableNode() && (!HasMark() ||
|
|
|
|
|
pTNd == GetMark()->nNode.GetNode().FindTableNode() ));
|
|
|
|
|
}
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUnoTableCrsr::MakeBoxSels()
|
|
|
|
|
{
|
|
|
|
|
const SwCntntNode* pCNd;
|
2003-07-09 08:16:31 +00:00
|
|
|
|
bool bMakeTblCrsrs = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( GetPoint()->nNode.GetIndex() && GetMark()->nNode.GetIndex() &&
|
|
|
|
|
0 != ( pCNd = GetCntntNode() ) && pCNd->GetFrm() &&
|
|
|
|
|
0 != ( pCNd = GetCntntNode(FALSE) ) && pCNd->GetFrm() )
|
2003-07-09 08:16:31 +00:00
|
|
|
|
bMakeTblCrsrs = GetDoc()->GetRootFrm()->MakeTblCrsrs( *this );
|
|
|
|
|
|
|
|
|
|
if ( !bMakeTblCrsrs )
|
|
|
|
|
{
|
|
|
|
|
SwSelBoxes& rTmpBoxes = (SwSelBoxes&)GetBoxes();
|
|
|
|
|
USHORT nCount = 0;
|
|
|
|
|
while( nCount < rTmpBoxes.Count() )
|
|
|
|
|
DeleteBox( nCount );
|
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
if( IsChgd() )
|
|
|
|
|
{
|
|
|
|
|
SwTableCursor::MakeBoxSels( &aTblSel );
|
|
|
|
|
if( !GetBoxesCount() )
|
|
|
|
|
{
|
|
|
|
|
const SwTableBox* pBox;
|
|
|
|
|
const SwNode* pBoxNd = GetPoint()->nNode.GetNode().FindTableBoxStartNode();
|
|
|
|
|
const SwTableNode* pTblNd = pBoxNd ? pBoxNd->FindTableNode() : 0;
|
|
|
|
|
if( pTblNd && 0 != ( pBox = pTblNd->GetTable().GetTblBox( pBoxNd->GetIndex() )) )
|
|
|
|
|
InsertBox( *pBox );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|