2000-09-18 23:08:29 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-10 12:07:03 +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:07:03 +00:00
|
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:07:03 +00:00
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:07:03 +00:00
|
|
|
|
* $RCSfile: docbm.cxx,v $
|
2008-04-18 12:16:17 +00:00
|
|
|
|
*
|
|
|
|
|
* $Revision: 1.25 $
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:07:03 +00:00
|
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 12:07:03 +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:07:03 +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:07:03 +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:50:01 +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 <tools/pstm.hxx>
|
|
|
|
|
#include <svx/linkmgr.hxx>
|
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
|
#include <node.hxx>
|
|
|
|
|
#include <doc.hxx>
|
|
|
|
|
#include <errhdl.hxx>
|
|
|
|
|
#include <cntfrm.hxx>
|
|
|
|
|
#include <dcontact.hxx>
|
|
|
|
|
#include <bookmrk.hxx>
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-10-16 #i81002#
|
|
|
|
|
#include <crossrefbookmark.hxx>
|
|
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
|
#include <undobj.hxx>
|
2008-04-18 12:16:17 +00:00
|
|
|
|
#include <rolbck.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
#include <pam.hxx>
|
|
|
|
|
#include <mvsave.hxx>
|
|
|
|
|
#include <swserv.hxx>
|
|
|
|
|
#include <redline.hxx>
|
|
|
|
|
#include <docary.hxx>
|
|
|
|
|
#include <editsh.hxx>
|
|
|
|
|
#include <unocrsr.hxx>
|
|
|
|
|
#include <viscrs.hxx>
|
2004-08-02 13:01:07 +00:00
|
|
|
|
// OD 2004-05-24 #i28701#
|
|
|
|
|
#include <sortedobjs.hxx>
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-10-23 #i81002#
|
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
SV_IMPL_OP_PTRARR_SORT(SwBookmarks, SwBookmarkPtr)
|
|
|
|
|
|
|
|
|
|
#define PCURCRSR (_pCurrCrsr)
|
|
|
|
|
#define FOREACHPAM_START(pSttCrsr) \
|
|
|
|
|
{\
|
|
|
|
|
SwPaM *_pStartCrsr = pSttCrsr, *_pCurrCrsr = pSttCrsr; \
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
|
|
#define FOREACHPAM_END() \
|
|
|
|
|
} while( (_pCurrCrsr=(SwPaM *)_pCurrCrsr->GetNext()) != _pStartCrsr ); \
|
|
|
|
|
}
|
|
|
|
|
#define PCURSH ((SwCrsrShell*)_pStartShell)
|
|
|
|
|
#define FOREACHSHELL_START( pEShell ) \
|
|
|
|
|
{\
|
2007-09-27 07:33:02 +00:00
|
|
|
|
ViewShell *_pStartShell = pEShell; \
|
2000-09-18 23:08:29 +00:00
|
|
|
|
do { \
|
|
|
|
|
if( _pStartShell->IsA( TYPE( SwCrsrShell )) ) \
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#define FOREACHSHELL_END( pEShell ) \
|
|
|
|
|
} \
|
|
|
|
|
} while((_pStartShell=(ViewShell*)_pStartShell->GetNext())!= pEShell ); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
/** IDocumentBookmarkAccess ssc
|
|
|
|
|
*/
|
|
|
|
|
const SwBookmarks& SwDoc::getBookmarks() const
|
|
|
|
|
{
|
|
|
|
|
return *pBookmarkTbl;
|
|
|
|
|
}
|
2004-11-16 14:39:14 +00:00
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
SwBookmark* SwDoc::makeBookmark( /*[in]*/const SwPaM& rPaM, /*[in]*/const KeyCode& rCode,
|
|
|
|
|
/*[in]*/ const String& rName, /*[in]*/const String& rShortName,
|
|
|
|
|
/*[in]*/IDocumentBookmarkAccess::BookmarkType eMark )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
SwBookmark *pBM( 0 );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( MARK == eMark )
|
2008-02-26 09:35:35 +00:00
|
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pBM = new SwMark( *rPaM.GetPoint(), rCode, rName, rShortName );
|
2008-02-26 09:35:35 +00:00
|
|
|
|
}
|
|
|
|
|
// // --> OD 2007-10-16 #TESTING#
|
|
|
|
|
// else if ( BOOKMARK == eMark )
|
|
|
|
|
// {
|
|
|
|
|
// if ( ( !rPaM.HasMark() &&
|
|
|
|
|
// rPaM.GetPoint()->nNode.GetNode().GetTxtNode() &&
|
|
|
|
|
// rPaM.GetPoint()->nContent.GetIndex() == 0 ) ||
|
|
|
|
|
// ( rPaM.HasMark() &&
|
|
|
|
|
// rPaM.GetMark()->nNode == rPaM.GetPoint()->nNode &&
|
|
|
|
|
// rPaM.GetPoint()->nNode.GetNode().GetTxtNode() &&
|
|
|
|
|
// rPaM.Start()->nContent.GetIndex() == 0 &&
|
|
|
|
|
// rPaM.End()->nContent.GetIndex() ==
|
|
|
|
|
// rPaM.GetPoint()->nNode.GetNode().GetTxtNode()->Len() ) )
|
|
|
|
|
// {
|
|
|
|
|
// pBM = new SwCrossRefBookmark( *(rPaM.Start()), rCode, rName, rShortName);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// ASSERT( false,
|
|
|
|
|
// "<SwDoc::makeBookmark(..)> - creation of cross-reference bookmark with invalid PaM" );
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // <--
|
|
|
|
|
else if( BOOKMARK == eMark || DDE_BOOKMARK == eMark)
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-09-26 #i81002#
|
|
|
|
|
pBM = new SwBookmark( rPaM, rCode, rName, rShortName);
|
|
|
|
|
if ( eMark == DDE_BOOKMARK )
|
|
|
|
|
{
|
|
|
|
|
pBM->SetType( eMark );
|
|
|
|
|
}
|
|
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-10-17 #i81002#
|
|
|
|
|
else if ( eMark == CROSSREF_BOOKMARK )
|
|
|
|
|
{
|
|
|
|
|
if ( ( !rPaM.HasMark() &&
|
|
|
|
|
rPaM.GetPoint()->nNode.GetNode().GetTxtNode() &&
|
|
|
|
|
rPaM.GetPoint()->nContent.GetIndex() == 0 ) ||
|
|
|
|
|
( rPaM.HasMark() &&
|
|
|
|
|
rPaM.GetMark()->nNode == rPaM.GetPoint()->nNode &&
|
|
|
|
|
rPaM.GetPoint()->nNode.GetNode().GetTxtNode() &&
|
|
|
|
|
rPaM.Start()->nContent.GetIndex() == 0 &&
|
|
|
|
|
rPaM.End()->nContent.GetIndex() ==
|
|
|
|
|
rPaM.GetPoint()->nNode.GetNode().GetTxtNode()->Len() ) )
|
|
|
|
|
{
|
|
|
|
|
pBM = new SwCrossRefBookmark( *(rPaM.Start()), rCode, rName, rShortName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ASSERT( false,
|
|
|
|
|
"<SwDoc::makeBookmark(..)> - creation of cross-reference bookmark with invalid PaM" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-09-26 #i81002#
|
|
|
|
|
pBM = new SwUNOMark( rPaM, rCode, rName, rShortName);
|
|
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-10-18 #i81002#
|
|
|
|
|
if ( pBM )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if ( !pBookmarkTbl->Insert( pBM ) )
|
|
|
|
|
delete pBM, pBM = 0;
|
|
|
|
|
else
|
2005-10-24 14:29:40 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( BOOKMARK == eMark && DoesUndo() )
|
|
|
|
|
{
|
|
|
|
|
ClearRedo();
|
|
|
|
|
AppendUndo( new SwUndoInsBookmark( *pBM ));
|
|
|
|
|
}
|
|
|
|
|
switch( eMark )
|
|
|
|
|
{
|
|
|
|
|
case UNO_BOOKMARK:
|
|
|
|
|
case DDE_BOOKMARK:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
SetModified();
|
|
|
|
|
}
|
2005-10-24 14:29:40 +00:00
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
return pBM;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
void SwDoc::deleteBookmark( /*[in]*/sal_uInt16 nPos )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
SwBookmark *pBM = (*pBookmarkTbl)[nPos];
|
|
|
|
|
if( DoesUndo() && !pBM->IsUNOMark())
|
|
|
|
|
{
|
|
|
|
|
ClearRedo();
|
|
|
|
|
AppendUndo( new SwUndoDelBookmark( *pBM ));
|
|
|
|
|
}
|
2003-04-24 12:48:36 +00:00
|
|
|
|
|
|
|
|
|
// #108964# UNO bookmark don't contribute to the document state,
|
|
|
|
|
// and hence changing them shouldn't set the document modified
|
|
|
|
|
if( !pBM->IsUNOMark() )
|
|
|
|
|
SetModified();
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pBookmarkTbl->Remove(nPos);
|
|
|
|
|
|
|
|
|
|
SwServerObject* pServObj = pBM->GetObject();
|
|
|
|
|
if( pServObj ) // dann aus der Liste entfernen
|
|
|
|
|
GetLinkManager().RemoveServer( pServObj );
|
|
|
|
|
|
|
|
|
|
delete pBM;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
void SwDoc::deleteBookmark( /*[in]*/const String& rName )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2006-08-14 14:55:23 +00:00
|
|
|
|
USHORT nFnd = findBookmark( rName );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( USHRT_MAX != nFnd )
|
2006-08-14 14:55:23 +00:00
|
|
|
|
deleteBookmark( nFnd );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-10-24 #i81002#
|
|
|
|
|
bool SwDoc::isCrossRefBookmarkName( /*[in]*/const String& rName )
|
|
|
|
|
{
|
|
|
|
|
return bookmarkfunc::isHeadingCrossRefBookmarkName( rName ) ||
|
|
|
|
|
bookmarkfunc::isNumItemCrossRefBookmarkName( rName );
|
|
|
|
|
}
|
|
|
|
|
// <--
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
sal_uInt16 SwDoc::findBookmark( /*[in]*/const String& rName )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
ASSERT( rName.Len(), "wo ist der Name?" );
|
|
|
|
|
for( USHORT n = pBookmarkTbl->Count(); n ; )
|
|
|
|
|
if( rName.Equals( (*pBookmarkTbl)[ --n ]->GetName() ) )
|
|
|
|
|
return n;
|
|
|
|
|
return USHRT_MAX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Zur Vereinfachung gibt es auch den direkten Zugriff
|
|
|
|
|
// auf die "echten" Bookmarks
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
sal_uInt16 SwDoc::getBookmarkCount( /*[in]*/bool bBkmrk) const
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
USHORT nRet = pBookmarkTbl->Count();
|
|
|
|
|
if(bBkmrk)
|
|
|
|
|
{
|
|
|
|
|
for( USHORT i = nRet; i; --i )
|
|
|
|
|
{
|
|
|
|
|
if(!(*pBookmarkTbl)[i - 1]->IsBookMark())
|
|
|
|
|
nRet--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
SwBookmark& SwDoc::getBookmark( /*[in]*/sal_uInt16 nPos, /*[in]*/bool bBkmrk)
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( bBkmrk )
|
|
|
|
|
{
|
|
|
|
|
USHORT i = 0;
|
|
|
|
|
do {
|
|
|
|
|
if(!(*pBookmarkTbl)[i]->IsBookMark())
|
|
|
|
|
nPos++;
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
while( i < nPos || !(*pBookmarkTbl)[nPos]->IsBookMark() );
|
|
|
|
|
}
|
|
|
|
|
return *(*pBookmarkTbl)[nPos];
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
void SwDoc::makeUniqueBookmarkName( String& rNm )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
ASSERT( rNm.Len(), "es sollte ein Name vorgegeben werden!" );
|
|
|
|
|
|
|
|
|
|
// wir erzeugen uns eine temp. Bookmark
|
|
|
|
|
String sTmp;
|
|
|
|
|
USHORT nCnt = 0, n;
|
|
|
|
|
USHORT nBookCnt = pBookmarkTbl->Count();
|
|
|
|
|
do {
|
|
|
|
|
sTmp = rNm;
|
2006-03-29 07:04:29 +00:00
|
|
|
|
// #i35726# try without number extension first
|
|
|
|
|
if(nCnt)
|
|
|
|
|
sTmp += String::CreateFromInt32( nCnt );
|
|
|
|
|
nCnt++;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
for( n = 0; n < nBookCnt; ++n )
|
|
|
|
|
if( (*pBookmarkTbl)[ n ]->GetName().Equals( sTmp ))
|
|
|
|
|
break;
|
|
|
|
|
} while( n < nBookCnt );
|
2008-02-26 09:35:35 +00:00
|
|
|
|
|
|
|
|
|
// --> OD 2007-10-24 #i81002#
|
|
|
|
|
// a cross-reference bookmark name still have to be a cross-reference
|
|
|
|
|
// bookmark name after renaming due to duplicate names and vice versa.
|
|
|
|
|
// Thus, consider this, when changing the renaming algorithm
|
|
|
|
|
ASSERT( isCrossRefBookmarkName( rNm ) == isCrossRefBookmarkName( sTmp ),
|
|
|
|
|
"<SwDoc::makeUniqueBookmarkName(..)> - change of the bookmark name causes change of bookmark name type" );
|
|
|
|
|
// <--
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
rNm = sTmp;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-11-16 #i83479#
|
|
|
|
|
String SwDoc::getCrossRefBookmarkName(
|
|
|
|
|
/*[in]*/const SwTxtNode& rTxtNode,
|
|
|
|
|
/*[in]*/const CrossReferenceBookmarkSubType nCrossRefType ) const
|
|
|
|
|
{
|
|
|
|
|
for( USHORT n = pBookmarkTbl->Count(); n ; )
|
|
|
|
|
{
|
|
|
|
|
const SwCrossRefBookmark* pCrossRefBkmk(
|
|
|
|
|
dynamic_cast<SwCrossRefBookmark*>((*pBookmarkTbl)[ --n ]) );
|
|
|
|
|
if ( pCrossRefBkmk &&
|
|
|
|
|
pCrossRefBkmk->GetBookmarkPos().nNode.GetNode().GetTxtNode() ==
|
|
|
|
|
&rTxtNode &&
|
|
|
|
|
pCrossRefBkmk->GetSubType() == nCrossRefType )
|
|
|
|
|
{
|
|
|
|
|
return pCrossRefBkmk->GetName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return String();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String SwDoc::makeCrossRefBookmark(
|
|
|
|
|
/*[in]*/const SwTxtNode& rTxtNode,
|
|
|
|
|
/*[in]*/const CrossReferenceBookmarkSubType nCrossRefType )
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( rTxtNode );
|
|
|
|
|
aPos.nContent.Assign( &(const_cast<SwTxtNode&>(rTxtNode)), 0 );
|
|
|
|
|
SwPaM aPaM( aPos );
|
|
|
|
|
KeyCode rKeyCodeDummy;
|
|
|
|
|
String sBkmkName( bookmarkfunc::generateNewCrossRefBookmarkName( nCrossRefType ) );
|
|
|
|
|
makeUniqueBookmarkName( sBkmkName );
|
|
|
|
|
SwBookmark* pCrossRefBk =
|
|
|
|
|
makeBookmark( aPaM, rKeyCodeDummy, sBkmkName, sBkmkName, CROSSREF_BOOKMARK );
|
|
|
|
|
if ( pCrossRefBk )
|
|
|
|
|
{
|
|
|
|
|
return pCrossRefBk->GetName();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return String();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
SaveBookmark::SaveBookmark( int eType, const SwBookmark& rBkmk,
|
|
|
|
|
const SwNodeIndex & rMvPos,
|
|
|
|
|
const SwIndex* pIdx )
|
2008-02-26 09:35:35 +00:00
|
|
|
|
: aName( rBkmk.GetName() ),
|
|
|
|
|
aShortName( rBkmk.GetShortName() ),
|
|
|
|
|
aCode( rBkmk.GetKeyCode() ),
|
|
|
|
|
eBkmkType( (SaveBookmarkType)eType ),
|
|
|
|
|
eOrigBkmType(rBkmk.GetType())
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
nNode1 = rBkmk.GetBookmarkPos().nNode.GetIndex();
|
|
|
|
|
nCntnt1 = rBkmk.GetBookmarkPos().nContent.GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2007-09-27 07:33:02 +00:00
|
|
|
|
if( nsSaveBookmarkType::BKMK_POS & eBkmkType )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
nNode1 -= rMvPos.GetIndex();
|
|
|
|
|
if( pIdx && !nNode1 )
|
2007-09-27 07:33:02 +00:00
|
|
|
|
nCntnt1 = nCntnt1 - pIdx->GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( rBkmk.GetOtherBookmarkPos() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
nNode2 = rBkmk.GetOtherBookmarkPos()->nNode.GetIndex();
|
|
|
|
|
nCntnt2 = rBkmk.GetOtherBookmarkPos()->nContent.GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2007-09-27 07:33:02 +00:00
|
|
|
|
if( nsSaveBookmarkType::BKMK_POS_OTHER & eBkmkType )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
nNode2 -= rMvPos.GetIndex();
|
|
|
|
|
if( pIdx && !nNode2 )
|
2007-09-27 07:33:02 +00:00
|
|
|
|
nCntnt2 = nCntnt2 - pIdx->GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nNode2 = ULONG_MAX, nCntnt2 = STRING_NOTFOUND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SaveBookmark::SetInDoc( SwDoc* pDoc, const SwNodeIndex& rNewPos,
|
|
|
|
|
const SwIndex* pIdx )
|
|
|
|
|
{
|
|
|
|
|
SwPaM aPam( rNewPos.GetNode() );
|
|
|
|
|
if( pIdx )
|
|
|
|
|
aPam.GetPoint()->nContent = *pIdx;
|
|
|
|
|
|
|
|
|
|
if( ULONG_MAX != nNode2 )
|
|
|
|
|
{
|
|
|
|
|
aPam.SetMark();
|
|
|
|
|
|
2007-09-27 07:33:02 +00:00
|
|
|
|
if( nsSaveBookmarkType::BKMK_POS_OTHER & eBkmkType )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
aPam.GetMark()->nNode += nNode2;
|
|
|
|
|
if( pIdx && !nNode2 )
|
|
|
|
|
aPam.GetMark()->nContent += nCntnt2;
|
|
|
|
|
else
|
|
|
|
|
aPam.GetMark()->nContent.Assign( aPam.GetCntntNode( FALSE ),
|
|
|
|
|
nCntnt2 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aPam.GetMark()->nNode = nNode2;
|
|
|
|
|
aPam.GetMark()->nContent.Assign( aPam.GetCntntNode( FALSE ),
|
|
|
|
|
nCntnt2 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-27 07:33:02 +00:00
|
|
|
|
if( nsSaveBookmarkType::BKMK_POS & eBkmkType )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
aPam.GetPoint()->nNode += nNode1;
|
|
|
|
|
|
|
|
|
|
if( pIdx && !nNode1 )
|
|
|
|
|
aPam.GetPoint()->nContent += nCntnt1;
|
|
|
|
|
else
|
|
|
|
|
aPam.GetPoint()->nContent.Assign( aPam.GetCntntNode(), nCntnt1 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aPam.GetPoint()->nNode = nNode1;
|
|
|
|
|
aPam.GetPoint()->nContent.Assign( aPam.GetCntntNode(), nCntnt1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !aPam.HasMark() ||
|
|
|
|
|
CheckNodesRange( aPam.GetPoint()->nNode, aPam.GetMark()->nNode, TRUE ))
|
2006-08-14 14:55:23 +00:00
|
|
|
|
pDoc->makeBookmark( aPam, aCode, aName, aShortName, eOrigBkmType );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline int GreaterThan( const SwPosition& rPos, const SwNodeIndex& rNdIdx,
|
|
|
|
|
const SwIndex* pIdx )
|
|
|
|
|
{
|
|
|
|
|
return pIdx ? ( rPos.nNode > rNdIdx || ( rPos.nNode == rNdIdx &&
|
|
|
|
|
rPos.nContent >= pIdx->GetIndex() ))
|
|
|
|
|
: rPos.nNode >= rNdIdx;
|
|
|
|
|
}
|
|
|
|
|
inline int Lower( const SwPosition& rPos, const SwNodeIndex& rNdIdx,
|
|
|
|
|
const SwIndex* pIdx )
|
|
|
|
|
{
|
|
|
|
|
return rPos.nNode < rNdIdx || ( pIdx && rPos.nNode == rNdIdx &&
|
|
|
|
|
rPos.nContent < pIdx->GetIndex() );
|
|
|
|
|
}
|
|
|
|
|
inline int Greater( const SwPosition& rPos, const SwNodeIndex& rNdIdx,
|
|
|
|
|
const SwIndex* pIdx )
|
|
|
|
|
{
|
|
|
|
|
return rPos.nNode > rNdIdx || ( pIdx && rPos.nNode == rNdIdx &&
|
|
|
|
|
rPos.nContent > pIdx->GetIndex() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _DelBookmarks( const SwNodeIndex& rStt, const SwNodeIndex& rEnd,
|
|
|
|
|
SaveBookmarks* pSaveBkmk,
|
|
|
|
|
const SwIndex* pSttIdx, const SwIndex* pEndIdx )
|
|
|
|
|
{
|
|
|
|
|
// kein gueltiger Bereich ??
|
|
|
|
|
if( rStt.GetIndex() > rEnd.GetIndex() || ( rStt == rEnd &&
|
|
|
|
|
(!pSttIdx || pSttIdx->GetIndex() >= pEndIdx->GetIndex())) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// kopiere alle Bookmarks, die im Move Bereich stehen in ein
|
|
|
|
|
// Array, das alle Angaben auf die Position als Offset speichert.
|
|
|
|
|
// Die neue Zuordung erfolgt nach dem Moven.
|
|
|
|
|
SwDoc* pDoc = rStt.GetNode().GetDoc();
|
2006-08-14 14:55:23 +00:00
|
|
|
|
const SwBookmarks& rBkmks = pDoc->getBookmarks();
|
2003-12-01 15:33:46 +00:00
|
|
|
|
USHORT nCnt;
|
|
|
|
|
|
|
|
|
|
for( nCnt = 0; nCnt < rBkmks.Count(); ++nCnt )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
// liegt auf der Position ??
|
2007-09-27 07:33:02 +00:00
|
|
|
|
int eType = nsSaveBookmarkType::BKMK_POS_NONE;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwBookmark* pBkmk = rBkmks[ nCnt ];
|
2001-01-10 12:41:45 +00:00
|
|
|
|
//simple marks should not be moved
|
|
|
|
|
if(pBkmk->IsMark())
|
|
|
|
|
continue;
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( GreaterThan( pBkmk->GetBookmarkPos(), rStt, pSttIdx ) &&
|
|
|
|
|
Lower( pBkmk->GetBookmarkPos(), rEnd, pEndIdx ))
|
2007-09-27 07:33:02 +00:00
|
|
|
|
eType = nsSaveBookmarkType::BKMK_POS;
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( pBkmk->GetOtherBookmarkPos() &&
|
|
|
|
|
GreaterThan( *pBkmk->GetOtherBookmarkPos(), rStt, pSttIdx ) &&
|
|
|
|
|
Lower( *pBkmk->GetOtherBookmarkPos(), rEnd, pEndIdx ))
|
2007-09-27 07:33:02 +00:00
|
|
|
|
eType |= nsSaveBookmarkType::BKMK_POS_OTHER;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2007-09-27 07:33:02 +00:00
|
|
|
|
if( nsSaveBookmarkType::BKMK_POS_NONE == eType ) // auf zum naechsten
|
2000-09-18 23:08:29 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if( pSaveBkmk )
|
|
|
|
|
{
|
|
|
|
|
// Besonderheit: komplett eingeschlossen? dann mitnehmen
|
2007-09-27 07:33:02 +00:00
|
|
|
|
if( pEndIdx && (nsSaveBookmarkType::BKMK_POS_OTHER | nsSaveBookmarkType::BKMK_POS) != eType &&
|
|
|
|
|
( ( nsSaveBookmarkType::BKMK_POS_OTHER & eType &&
|
2008-02-26 09:35:35 +00:00
|
|
|
|
pBkmk->GetBookmarkPos().nNode == rEnd &&
|
|
|
|
|
pBkmk->GetBookmarkPos().nContent == *pEndIdx ) ||
|
|
|
|
|
( nsSaveBookmarkType::BKMK_POS & eType && pBkmk->GetOtherBookmarkPos() &&
|
|
|
|
|
pBkmk->GetOtherBookmarkPos()->nNode == rEnd &&
|
|
|
|
|
pBkmk->GetOtherBookmarkPos()->nContent == *pEndIdx ) ) )
|
2007-09-27 07:33:02 +00:00
|
|
|
|
eType = nsSaveBookmarkType::BKMK_POS_OTHER | nsSaveBookmarkType::BKMK_POS;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
SaveBookmark * pSBkmk = new SaveBookmark( eType, *pBkmk, rStt, pSttIdx );
|
|
|
|
|
pSaveBkmk->C40_INSERT( SaveBookmark, pSBkmk, pSaveBkmk->Count() );
|
2006-08-14 14:55:23 +00:00
|
|
|
|
pDoc->deleteBookmark( nCnt-- );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2007-09-27 07:33:02 +00:00
|
|
|
|
else if( (nsSaveBookmarkType::BKMK_POS_OTHER | nsSaveBookmarkType::BKMK_POS ) == eType ||
|
2008-02-26 09:35:35 +00:00
|
|
|
|
( nsSaveBookmarkType::BKMK_POS == eType && !pBkmk->GetOtherBookmarkPos() ) )
|
2006-08-14 14:55:23 +00:00
|
|
|
|
pDoc->deleteBookmark( nCnt-- );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-10-17 #i81002# - refactoring:
|
|
|
|
|
// no direct manipulation of <SwBookmark> member.
|
|
|
|
|
// SwPosition* pPos = (SwPosition*)(nsSaveBookmarkType::BKMK_POS & eType
|
|
|
|
|
// ? &pBkmk->GetBookmarkPos()
|
|
|
|
|
// : pBkmk->GetOtherBookmarkPos());
|
|
|
|
|
SwPosition aNewPos( nsSaveBookmarkType::BKMK_POS & eType
|
|
|
|
|
? pBkmk->GetBookmarkPos()
|
|
|
|
|
: *pBkmk->GetOtherBookmarkPos() );
|
|
|
|
|
aNewPos.nNode = rEnd;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( pEndIdx )
|
2008-02-26 09:35:35 +00:00
|
|
|
|
aNewPos.nContent = *pEndIdx;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
SwCntntNode* pCNd = aNewPos.nNode.GetNode().GetCntntNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
BOOL bStt = TRUE;
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( !pCNd && 0 == ( pCNd = pDoc->GetNodes().GoNext( &(aNewPos.nNode) )) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
bStt = FALSE;
|
2008-02-26 09:35:35 +00:00
|
|
|
|
aNewPos.nNode = rStt;
|
|
|
|
|
if( 0 == ( pCNd = pDoc->GetNodes().GoPrevious( &(aNewPos.nNode) )) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
aNewPos.nNode = nsSaveBookmarkType::BKMK_POS == eType
|
|
|
|
|
? pBkmk->GetOtherBookmarkPos()->nNode
|
|
|
|
|
: pBkmk->GetBookmarkPos().nNode;
|
|
|
|
|
pCNd = aNewPos.nNode.GetNode().GetCntntNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
xub_StrLen nTmp = bStt ? 0 : pCNd->Len();
|
2008-02-26 09:35:35 +00:00
|
|
|
|
aNewPos.nContent.Assign( pCNd, nTmp );
|
|
|
|
|
}
|
|
|
|
|
if ( nsSaveBookmarkType::BKMK_POS & eType )
|
|
|
|
|
{
|
|
|
|
|
pBkmk->SetBookmarkPos( &aNewPos );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pBkmk->SetOtherBookmarkPos( &aNewPos );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// keine ungueltigen Selektionen zulassen!
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( pBkmk->GetOtherBookmarkPos() &&
|
|
|
|
|
pBkmk->GetOtherBookmarkPos()->nNode.GetNode().FindTableBoxStartNode() !=
|
|
|
|
|
pBkmk->GetBookmarkPos().nNode.GetNode().FindTableBoxStartNode() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// SwPaM aPam( pPos == pBkmk->GetOtherBookmarkPos()
|
|
|
|
|
// ? pBkmk->GetBookmarkPos()
|
|
|
|
|
// : *pBkmk->GetOtherBookmarkPos() );
|
|
|
|
|
const SwPaM aPam( nsSaveBookmarkType::BKMK_POS & eType
|
|
|
|
|
? *pBkmk->GetOtherBookmarkPos()
|
|
|
|
|
: pBkmk->GetBookmarkPos() );
|
|
|
|
|
const String sNm( pBkmk->GetName() );
|
|
|
|
|
const String sShortNm( pBkmk->GetShortName() );
|
|
|
|
|
const KeyCode aKCode( pBkmk->GetKeyCode() );
|
|
|
|
|
const IDocumentBookmarkAccess::BookmarkType eBkmkType( pBkmk->GetType() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2008-01-15 12:48:42 +00:00
|
|
|
|
bool bMake = !pBkmk->IsUNOMark();
|
2006-08-14 14:55:23 +00:00
|
|
|
|
pDoc->deleteBookmark( nCnt-- );
|
2008-01-15 12:48:42 +00:00
|
|
|
|
if( bMake )
|
2008-02-26 09:35:35 +00:00
|
|
|
|
pDoc->makeBookmark( aPam, aKCode, sNm, sShortNm, eBkmkType );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// <--
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// kopiere alle Redlines, die im Move Bereich stehen in ein
|
|
|
|
|
// Array, das alle Angaben auf die Position als Offset speichert.
|
|
|
|
|
// Die neue Zuordung erfolgt nach dem Moven.
|
|
|
|
|
SwRedlineTbl& rTbl = (SwRedlineTbl&)pDoc->GetRedlineTbl();
|
|
|
|
|
for( nCnt = 0; nCnt < rTbl.Count(); ++nCnt )
|
|
|
|
|
{
|
|
|
|
|
// liegt auf der Position ??
|
|
|
|
|
SwRedline* pRedl = rTbl[ nCnt ];
|
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
|
SwPosition *pRStt = &pRedl->GetBound(TRUE),
|
|
|
|
|
*pREnd = &pRedl->GetBound(FALSE);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( *pRStt > *pREnd )
|
|
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
|
SwPosition *pTmp = pRStt; pRStt = pREnd, pREnd = pTmp;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( Greater( *pRStt, rStt, pSttIdx ) && Lower( *pRStt, rEnd, pEndIdx ))
|
|
|
|
|
{
|
|
|
|
|
pRStt->nNode = rEnd;
|
|
|
|
|
if( pEndIdx )
|
|
|
|
|
pRStt->nContent = *pEndIdx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BOOL bStt = TRUE;
|
|
|
|
|
SwCntntNode* pCNd = pRStt->nNode.GetNode().GetCntntNode();
|
|
|
|
|
if( !pCNd && 0 == ( pCNd = pDoc->GetNodes().GoNext( &pRStt->nNode )) )
|
|
|
|
|
{
|
|
|
|
|
bStt = FALSE;
|
|
|
|
|
pRStt->nNode = rStt;
|
|
|
|
|
if( 0 == ( pCNd = pDoc->GetNodes().GoPrevious( &pRStt->nNode )) )
|
|
|
|
|
{
|
|
|
|
|
pRStt->nNode = pREnd->nNode;
|
|
|
|
|
pCNd = pRStt->nNode.GetNode().GetCntntNode();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
xub_StrLen nTmp = bStt ? 0 : pCNd->Len();
|
|
|
|
|
pRStt->nContent.Assign( pCNd, nTmp );
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-27 14:45:43 +00:00
|
|
|
|
if( Greater( *pREnd, rStt, pSttIdx ) && Lower( *pREnd, rEnd, pEndIdx ))
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
pREnd->nNode = rStt;
|
|
|
|
|
if( pSttIdx )
|
|
|
|
|
pREnd->nContent = *pSttIdx;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BOOL bStt = FALSE;
|
|
|
|
|
SwCntntNode* pCNd = pREnd->nNode.GetNode().GetCntntNode();
|
|
|
|
|
if( !pCNd && 0 == ( pCNd = pDoc->GetNodes().GoPrevious( &pREnd->nNode )) )
|
|
|
|
|
{
|
|
|
|
|
bStt = TRUE;
|
|
|
|
|
pREnd->nNode = rEnd;
|
|
|
|
|
if( 0 == ( pCNd = pDoc->GetNodes().GoNext( &pREnd->nNode )) )
|
|
|
|
|
{
|
|
|
|
|
pREnd->nNode = pRStt->nNode;
|
|
|
|
|
pCNd = pREnd->nNode.GetNode().GetCntntNode();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
xub_StrLen nTmp = bStt ? 0 : pCNd->Len();
|
|
|
|
|
pREnd->nContent.Assign( pCNd, nTmp );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-18 12:16:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Aufbau vom Array: 2 longs,
|
|
|
|
|
// 1. Long enthaelt Type und Position im DocArray,
|
|
|
|
|
// 2. die ContentPosition
|
|
|
|
|
//
|
|
|
|
|
// CntntType --
|
|
|
|
|
// 0x8000 = Bookmark Pos1
|
|
|
|
|
// 0x8001 = Bookmark Pos2
|
|
|
|
|
// 0x2000 = Absatzgebundener Rahmen
|
|
|
|
|
// 0x2001 = Auto-Absatzgebundener Rahmen, der umgehaengt werden soll
|
|
|
|
|
// 0x1000 = Redline Mark
|
|
|
|
|
// 0x1001 = Redline Point
|
|
|
|
|
// 0x0800 = Crsr aus der CrsrShell Mark
|
|
|
|
|
// 0x0801 = Crsr aus der CrsrShell Point
|
|
|
|
|
// 0x0400 = UnoCrsr Mark
|
|
|
|
|
// 0x0401 = UnoCrsr Point
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
class _SwSaveTypeCountContent
|
|
|
|
|
{
|
|
|
|
|
union {
|
|
|
|
|
struct { USHORT nType, nCount; } TC;
|
|
|
|
|
ULONG nTypeCount;
|
|
|
|
|
} TYPECOUNT;
|
|
|
|
|
xub_StrLen nContent;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
_SwSaveTypeCountContent() { TYPECOUNT.nTypeCount = 0; nContent = 0; }
|
|
|
|
|
_SwSaveTypeCountContent( USHORT nType )
|
|
|
|
|
{
|
|
|
|
|
SetTypeAndCount( nType, 0 );
|
|
|
|
|
nContent = 0;
|
|
|
|
|
}
|
|
|
|
|
_SwSaveTypeCountContent( const SvULongs& rArr, USHORT& rPos )
|
|
|
|
|
{
|
|
|
|
|
TYPECOUNT.nTypeCount = rArr[ rPos++ ];
|
2007-09-27 07:33:02 +00:00
|
|
|
|
nContent = static_cast<xub_StrLen>(rArr[ rPos++ ]);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
void Add( SvULongs& rArr )
|
|
|
|
|
{
|
|
|
|
|
rArr.Insert( TYPECOUNT.nTypeCount, rArr.Count() );
|
|
|
|
|
rArr.Insert( nContent, rArr.Count() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetType( USHORT n ) { TYPECOUNT.TC.nType = n; }
|
|
|
|
|
USHORT GetType() const { return TYPECOUNT.TC.nType; }
|
|
|
|
|
void IncType() { ++TYPECOUNT.TC.nType; }
|
|
|
|
|
void DecType() { --TYPECOUNT.TC.nType; }
|
|
|
|
|
|
|
|
|
|
void SetCount( USHORT n ) { TYPECOUNT.TC.nCount = n; }
|
|
|
|
|
USHORT GetCount() const { return TYPECOUNT.TC.nCount; }
|
|
|
|
|
USHORT IncCount() { return ++TYPECOUNT.TC.nCount; }
|
|
|
|
|
USHORT DecCount() { return --TYPECOUNT.TC.nCount; }
|
|
|
|
|
|
|
|
|
|
void SetTypeAndCount( USHORT nT, USHORT nC )
|
|
|
|
|
{ TYPECOUNT.TC.nCount = nC; TYPECOUNT.TC.nType = nT; }
|
|
|
|
|
|
|
|
|
|
void SetContent( xub_StrLen n ) { nContent = n; }
|
|
|
|
|
xub_StrLen GetContent() const { return nContent; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _ChkPaM( SvULongs& rSaveArr, ULONG nNode, xub_StrLen nCntnt,
|
|
|
|
|
const SwPaM& rPam, _SwSaveTypeCountContent& rSave,
|
|
|
|
|
BOOL bChkSelDirection )
|
|
|
|
|
{
|
|
|
|
|
// SelektionsRichtung beachten
|
2007-09-27 07:33:02 +00:00
|
|
|
|
bool bBound1IsStart = !bChkSelDirection ? TRUE :
|
2000-09-18 23:08:29 +00:00
|
|
|
|
( *rPam.GetPoint() < *rPam.GetMark()
|
|
|
|
|
? rPam.GetPoint() == &rPam.GetBound()
|
|
|
|
|
: rPam.GetMark() == &rPam.GetBound());
|
|
|
|
|
|
|
|
|
|
const SwPosition* pPos = &rPam.GetBound( TRUE );
|
|
|
|
|
if( pPos->nNode.GetIndex() == nNode &&
|
|
|
|
|
( bBound1IsStart ? pPos->nContent.GetIndex() < nCntnt
|
|
|
|
|
: pPos->nContent.GetIndex() <= nCntnt ))
|
|
|
|
|
{
|
|
|
|
|
rSave.SetContent( pPos->nContent.GetIndex() );
|
|
|
|
|
rSave.Add( rSaveArr );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pPos = &rPam.GetBound( FALSE );
|
|
|
|
|
if( pPos->nNode.GetIndex() == nNode &&
|
|
|
|
|
( (bBound1IsStart && bChkSelDirection)
|
|
|
|
|
? pPos->nContent.GetIndex() <= nCntnt
|
|
|
|
|
: pPos->nContent.GetIndex() < nCntnt ))
|
|
|
|
|
{
|
|
|
|
|
rSave.SetContent( pPos->nContent.GetIndex() );
|
|
|
|
|
rSave.IncType();
|
|
|
|
|
rSave.Add( rSaveArr );
|
|
|
|
|
rSave.DecType();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-19 13:16:33 +00:00
|
|
|
|
// #i59534: If a paragraph will be splitted we have to restore some redline positions
|
|
|
|
|
// This help function checks a position compared with a node and an content index
|
|
|
|
|
|
|
|
|
|
const int BEFORE_NODE = 0; // Position before the given node index
|
|
|
|
|
const int BEFORE_SAME_NODE = 1; // Same node index but content index before given content index
|
|
|
|
|
const int SAME_POSITION = 2; // Same node index and samecontent index
|
|
|
|
|
const int BEHIND_SAME_NODE = 3; // Same node index but content index behind given content index
|
|
|
|
|
const int BEHIND_NODE = 4; // Position behind the given node index
|
|
|
|
|
|
|
|
|
|
int lcl_RelativePosition( const SwPosition& rPos, ULONG nNode, xub_StrLen nCntnt )
|
|
|
|
|
{
|
|
|
|
|
ULONG nIndex = rPos.nNode.GetIndex();
|
|
|
|
|
int nReturn = BEFORE_NODE;
|
|
|
|
|
if( nIndex == nNode )
|
|
|
|
|
{
|
|
|
|
|
xub_StrLen nCntIdx = rPos.nContent.GetIndex();
|
|
|
|
|
if( nCntIdx < nCntnt )
|
|
|
|
|
nReturn = BEFORE_SAME_NODE;
|
|
|
|
|
else if( nCntIdx == nCntnt )
|
|
|
|
|
nReturn = SAME_POSITION;
|
|
|
|
|
else
|
|
|
|
|
nReturn = BEHIND_SAME_NODE;
|
|
|
|
|
}
|
|
|
|
|
else if( nIndex > nNode )
|
|
|
|
|
nReturn = BEHIND_NODE;
|
|
|
|
|
return nReturn;
|
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
void _SaveCntntIdx( SwDoc* pDoc, ULONG nNode, xub_StrLen nCntnt,
|
|
|
|
|
SvULongs& rSaveArr, BYTE nSaveFly )
|
|
|
|
|
{
|
|
|
|
|
// 1. Bookmarks
|
|
|
|
|
_SwSaveTypeCountContent aSave;
|
|
|
|
|
aSave.SetTypeAndCount( 0x8000, 0 );
|
|
|
|
|
|
2006-08-14 14:55:23 +00:00
|
|
|
|
const SwBookmarks& rBkmks = pDoc->getBookmarks();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
for( ; aSave.GetCount() < rBkmks.Count(); aSave.IncCount() )
|
|
|
|
|
{
|
2008-04-18 12:16:17 +00:00
|
|
|
|
bool bEqual = false;
|
|
|
|
|
bool bLower = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
const SwBookmark* pBkmk = rBkmks[ aSave.GetCount() ];
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( pBkmk->GetBookmarkPos().nNode.GetIndex() == nNode &&
|
2008-04-18 12:16:17 +00:00
|
|
|
|
pBkmk->GetBookmarkPos().nContent.GetIndex() <= nCntnt )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-04-18 12:16:17 +00:00
|
|
|
|
if( pBkmk->GetBookmarkPos().nContent.GetIndex() < nCntnt )
|
|
|
|
|
{
|
|
|
|
|
bLower = true; // a hint for the other position...
|
|
|
|
|
aSave.SetContent( pBkmk->GetBookmarkPos().nContent.GetIndex() );
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
}
|
|
|
|
|
else // if a bookmark position is equal nCntnt, the other position
|
|
|
|
|
bEqual = true; // has to decide if it is added to the array
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
if( pBkmk->GetOtherBookmarkPos() && pBkmk->GetOtherBookmarkPos()->nNode.GetIndex() ==
|
2008-04-18 12:16:17 +00:00
|
|
|
|
nNode && pBkmk->GetOtherBookmarkPos()->nContent.GetIndex() <= nCntnt )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2008-04-18 12:16:17 +00:00
|
|
|
|
if( bLower || pBkmk->GetOtherBookmarkPos()->nContent.GetIndex() < nCntnt )
|
|
|
|
|
{
|
|
|
|
|
if( bEqual )
|
|
|
|
|
{ // the other position is before, the (main) position is equal
|
|
|
|
|
aSave.SetContent( pBkmk->GetBookmarkPos().nContent.GetIndex() );
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
}
|
|
|
|
|
aSave.SetContent( pBkmk->GetOtherBookmarkPos()->nContent.GetIndex() );
|
|
|
|
|
aSave.IncType();
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
aSave.DecType();
|
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. Redlines
|
|
|
|
|
aSave.SetTypeAndCount( 0x1000, 0 );
|
|
|
|
|
const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
|
|
|
|
|
for( ; aSave.GetCount() < rRedlTbl.Count(); aSave.IncCount() )
|
|
|
|
|
{
|
|
|
|
|
const SwRedline* pRdl = rRedlTbl[ aSave.GetCount() ];
|
2006-04-19 13:16:33 +00:00
|
|
|
|
int nPointPos = lcl_RelativePosition( *pRdl->GetPoint(), nNode, nCntnt );
|
|
|
|
|
int nMarkPos = pRdl->HasMark() ? lcl_RelativePosition( *pRdl->GetMark(), nNode, nCntnt ) :
|
|
|
|
|
nPointPos;
|
|
|
|
|
// #i59534: We have to store the positions inside the same node before the insert position
|
|
|
|
|
// and the one at the insert position if the corresponding Point/Mark position is before
|
|
|
|
|
// the insert position.
|
|
|
|
|
if( nPointPos == BEFORE_SAME_NODE ||
|
|
|
|
|
( nPointPos == SAME_POSITION && nMarkPos < SAME_POSITION ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
aSave.SetContent( pRdl->GetPoint()->nContent.GetIndex() );
|
|
|
|
|
aSave.IncType();
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
aSave.DecType();
|
|
|
|
|
}
|
2006-04-19 13:16:33 +00:00
|
|
|
|
if( pRdl->HasMark() && ( nMarkPos == BEFORE_SAME_NODE ||
|
|
|
|
|
( nMarkPos == SAME_POSITION && nPointPos < SAME_POSITION ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
aSave.SetContent( pRdl->GetMark()->nContent.GetIndex() );
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. Absatzgebundene Objekte
|
|
|
|
|
{
|
|
|
|
|
SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
|
|
|
|
|
if( pNode )
|
|
|
|
|
{
|
|
|
|
|
const SwPosition* pAPos;
|
|
|
|
|
|
|
|
|
|
SwFrm* pFrm = pNode->GetFrm();
|
2003-04-15 15:48:48 +00:00
|
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2000-09-18 23:08:29 +00:00
|
|
|
|
static BOOL bViaDoc = FALSE;
|
|
|
|
|
if( bViaDoc )
|
|
|
|
|
pFrm = NULL;
|
|
|
|
|
#endif
|
|
|
|
|
if( pFrm ) // gibt es ein Layout? Dann ist etwas billiger...
|
|
|
|
|
{
|
|
|
|
|
if( pFrm->GetDrawObjs() )
|
|
|
|
|
{
|
2004-08-02 13:01:07 +00:00
|
|
|
|
const SwSortedObjs& rDObj = *pFrm->GetDrawObjs();
|
|
|
|
|
for( sal_uInt32 n = rDObj.Count(); n; )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2004-08-02 13:01:07 +00:00
|
|
|
|
SwAnchoredObject* pObj = rDObj[ --n ];
|
|
|
|
|
const SwFrmFmt& rFmt = pObj->GetFrmFmt();
|
|
|
|
|
const SwFmtAnchor& rAnchor = rFmt.GetAnchor();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( ( ( nSaveFly && FLY_AT_CNTNT == rAnchor.GetAnchorId() ) ||
|
|
|
|
|
FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) &&
|
|
|
|
|
( 0 != ( pAPos = rAnchor.GetCntntAnchor() ) ) )
|
|
|
|
|
{
|
|
|
|
|
aSave.SetType( 0x2000 );
|
|
|
|
|
aSave.SetContent( pAPos->nContent.GetIndex() );
|
|
|
|
|
|
|
|
|
|
ASSERT( nNode == pAPos->nNode.GetIndex(),
|
|
|
|
|
"_SaveCntntIdx: Wrong Node-Index" );
|
|
|
|
|
if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
if( nCntnt <= aSave.GetContent() )
|
|
|
|
|
{
|
|
|
|
|
if( SAVEFLY_SPLIT == nSaveFly )
|
|
|
|
|
aSave.IncType(); // = 0x2001;
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
aSave.SetCount( pDoc->GetSpzFrmFmts()->Count() );
|
|
|
|
|
while( aSave.GetCount() &&
|
2004-08-02 13:01:07 +00:00
|
|
|
|
&rFmt != (*pDoc->GetSpzFrmFmts())[
|
2000-09-18 23:08:29 +00:00
|
|
|
|
aSave.DecCount() ] )
|
|
|
|
|
; // nothing
|
2004-08-02 13:01:07 +00:00
|
|
|
|
ASSERT( &rFmt == (*pDoc->GetSpzFrmFmts())[
|
2000-09-18 23:08:29 +00:00
|
|
|
|
aSave.GetCount() ],
|
|
|
|
|
"_SaveCntntIdx: Lost FrameFormat" );
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Schade, kein Layout, dann ist es eben etwas teurer...
|
|
|
|
|
{
|
|
|
|
|
for( aSave.SetCount( pDoc->GetSpzFrmFmts()->Count() );
|
|
|
|
|
aSave.GetCount() ; )
|
|
|
|
|
{
|
|
|
|
|
SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[
|
|
|
|
|
aSave.DecCount() ];
|
|
|
|
|
if ( RES_FLYFRMFMT != pFrmFmt->Which() &&
|
|
|
|
|
RES_DRAWFRMFMT != pFrmFmt->Which() )
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
|
|
|
|
|
if( ( FLY_AT_CNTNT == rAnchor.GetAnchorId() ||
|
|
|
|
|
FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) &&
|
|
|
|
|
0 != ( pAPos = rAnchor.GetCntntAnchor()) &&
|
|
|
|
|
nNode == pAPos->nNode.GetIndex() )
|
|
|
|
|
{
|
|
|
|
|
aSave.SetType( 0x2000 );
|
|
|
|
|
aSave.SetContent( pAPos->nContent.GetIndex() );
|
|
|
|
|
if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
if( nCntnt <= aSave.GetContent() )
|
|
|
|
|
{
|
|
|
|
|
if( SAVEFLY_SPLIT == nSaveFly )
|
|
|
|
|
aSave.IncType(); // = 0x2001;
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
aSave.Add( rSaveArr );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 5. CrsrShell
|
|
|
|
|
{
|
|
|
|
|
SwCrsrShell* pShell = pDoc->GetEditShell();
|
|
|
|
|
if( pShell )
|
|
|
|
|
{
|
|
|
|
|
aSave.SetTypeAndCount( 0x800, 0 );
|
|
|
|
|
FOREACHSHELL_START( pShell )
|
2007-09-27 07:33:02 +00:00
|
|
|
|
SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( _pStkCrsr )
|
|
|
|
|
do {
|
|
|
|
|
::_ChkPaM( rSaveArr, nNode, nCntnt, *_pStkCrsr,
|
|
|
|
|
aSave, FALSE );
|
|
|
|
|
aSave.IncCount();
|
|
|
|
|
} while ( (_pStkCrsr != 0 ) &&
|
|
|
|
|
((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
|
|
|
|
|
|
|
|
|
|
FOREACHPAM_START( PCURSH->_GetCrsr() )
|
|
|
|
|
::_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR,
|
|
|
|
|
aSave, FALSE );
|
|
|
|
|
aSave.IncCount();
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
|
|
|
|
|
FOREACHSHELL_END( pShell )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 6. UnoCrsr
|
|
|
|
|
{
|
|
|
|
|
aSave.SetTypeAndCount( 0x400, 0 );
|
2007-09-27 07:33:02 +00:00
|
|
|
|
const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
for( USHORT n = 0; n < rTbl.Count(); ++n )
|
|
|
|
|
{
|
|
|
|
|
FOREACHPAM_START( rTbl[ n ] )
|
|
|
|
|
::_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR, aSave, FALSE );
|
|
|
|
|
aSave.IncCount();
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
|
|
|
|
|
SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ n ];
|
|
|
|
|
if( pUnoTblCrsr )
|
|
|
|
|
{
|
|
|
|
|
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
|
|
|
|
|
::_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR, aSave, FALSE );
|
|
|
|
|
aSave.IncCount();
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _RestoreCntntIdx( SwDoc* pDoc, SvULongs& rSaveArr,
|
|
|
|
|
ULONG nNode, xub_StrLen nOffset, BOOL bAuto )
|
|
|
|
|
{
|
|
|
|
|
SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode();
|
2006-08-14 14:55:23 +00:00
|
|
|
|
const SwBookmarks& rBkmks = pDoc->getBookmarks();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
|
|
|
|
|
SwSpzFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
|
|
|
|
|
USHORT n = 0;
|
|
|
|
|
while( n < rSaveArr.Count() )
|
|
|
|
|
{
|
|
|
|
|
_SwSaveTypeCountContent aSave( rSaveArr, n );
|
|
|
|
|
SwPosition* pPos = 0;
|
|
|
|
|
switch( aSave.GetType() )
|
|
|
|
|
{
|
|
|
|
|
case 0x8000:
|
2008-02-26 09:35:35 +00:00
|
|
|
|
{
|
|
|
|
|
// --> OD 2007-09-27 #i81002# - refactoring
|
|
|
|
|
// Do not directly manipulate members of <SwBookmark>
|
|
|
|
|
// pPos = (SwPosition*)&rBkmks[ aSave.GetCount() ]->GetBookmarkPos();
|
|
|
|
|
SwPosition aNewPos( rBkmks[ aSave.GetCount() ]->GetBookmarkPos() );
|
|
|
|
|
aNewPos.nNode = *pCNd;
|
|
|
|
|
aNewPos.nContent.Assign( pCNd, aSave.GetContent() + nOffset );
|
|
|
|
|
rBkmks[ aSave.GetCount() ]->SetBookmarkPos( &aNewPos );
|
|
|
|
|
// <--
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
case 0x8001:
|
2008-02-26 09:35:35 +00:00
|
|
|
|
{
|
|
|
|
|
// --> OD 2007-09-27 #i81002# - refactoring
|
|
|
|
|
// Do not directly manipulate members of <SwBookmark>
|
|
|
|
|
// pPos = (SwPosition*)rBkmks[ aSave.GetCount() ]->GetOtherBookmarkPos();
|
|
|
|
|
SwPosition aNewPos( *(rBkmks[ aSave.GetCount() ]->GetOtherBookmarkPos()) );
|
|
|
|
|
aNewPos.nNode = *pCNd;
|
|
|
|
|
aNewPos.nContent.Assign( pCNd, aSave.GetContent() + nOffset );
|
|
|
|
|
rBkmks[ aSave.GetCount() ]->SetOtherBookmarkPos( &aNewPos );
|
|
|
|
|
// <--
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
case 0x1001:
|
|
|
|
|
pPos = (SwPosition*)rRedlTbl[ aSave.GetCount() ]->GetPoint();
|
|
|
|
|
break;
|
|
|
|
|
case 0x1000:
|
|
|
|
|
pPos = (SwPosition*)rRedlTbl[ aSave.GetCount() ]->GetMark();
|
|
|
|
|
break;
|
|
|
|
|
case 0x2000:
|
|
|
|
|
{
|
|
|
|
|
SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
|
|
|
|
|
const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
|
|
|
|
|
if( rFlyAnchor.GetCntntAnchor() )
|
|
|
|
|
{
|
|
|
|
|
SwFmtAnchor aNew( rFlyAnchor );
|
|
|
|
|
SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
|
|
|
|
|
aNewPos.nNode = *pCNd;
|
|
|
|
|
if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() )
|
|
|
|
|
aNewPos.nContent.Assign( pCNd,
|
|
|
|
|
aSave.GetContent() + nOffset );
|
|
|
|
|
else
|
|
|
|
|
aNewPos.nContent.Assign( 0, 0 );
|
|
|
|
|
aNew.SetAnchor( &aNewPos );
|
|
|
|
|
pFrmFmt->SetAttr( aNew );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 0x2001:
|
|
|
|
|
if( bAuto )
|
|
|
|
|
{
|
|
|
|
|
SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
|
|
|
|
|
SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
|
|
|
|
|
pFrmFmt->SwModify::Modify( pAnchor, pAnchor );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0800:
|
|
|
|
|
case 0x0801:
|
|
|
|
|
{
|
|
|
|
|
USHORT nCnt = 0;
|
|
|
|
|
SwCrsrShell* pShell = pDoc->GetEditShell();
|
|
|
|
|
if( pShell )
|
|
|
|
|
{
|
|
|
|
|
FOREACHSHELL_START( pShell )
|
2007-09-27 07:33:02 +00:00
|
|
|
|
SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( _pStkCrsr )
|
|
|
|
|
do {
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &_pStkCrsr->GetBound( 0x0800 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
} while ( (_pStkCrsr != 0 ) &&
|
|
|
|
|
((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
|
|
|
|
|
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
FOREACHPAM_START( PCURSH->_GetCrsr() )
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &PCURCRSR->GetBound( 0x0800 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
FOREACHSHELL_END( pShell )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0400:
|
|
|
|
|
case 0x0401:
|
|
|
|
|
{
|
|
|
|
|
USHORT nCnt = 0;
|
2007-09-27 07:33:02 +00:00
|
|
|
|
const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
for( USHORT i = 0; i < rTbl.Count(); ++i )
|
|
|
|
|
{
|
|
|
|
|
FOREACHPAM_START( rTbl[ i ] )
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &PCURCRSR->GetBound( 0x0400 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ i ];
|
|
|
|
|
if( pUnoTblCrsr )
|
|
|
|
|
{
|
|
|
|
|
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &PCURCRSR->GetBound( 0x0400 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
}
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( pPos )
|
|
|
|
|
{
|
|
|
|
|
pPos->nNode = *pCNd;
|
|
|
|
|
pPos->nContent.Assign( pCNd, aSave.GetContent() + nOffset );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _RestoreCntntIdx( SvULongs& rSaveArr, const SwNode& rNd,
|
|
|
|
|
xub_StrLen nLen, xub_StrLen nChkLen )
|
|
|
|
|
{
|
|
|
|
|
const SwDoc* pDoc = rNd.GetDoc();
|
2006-08-14 14:55:23 +00:00
|
|
|
|
const SwBookmarks& rBkmks = pDoc->getBookmarks();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
|
|
|
|
|
const SwSpzFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
|
|
|
|
|
SwCntntNode* pCNd = (SwCntntNode*)rNd.GetCntntNode();
|
|
|
|
|
|
2008-04-18 12:16:17 +00:00
|
|
|
|
USHORT n = 0;
|
|
|
|
|
while( n < rSaveArr.Count() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
_SwSaveTypeCountContent aSave( rSaveArr, n );
|
|
|
|
|
if( aSave.GetContent() >= nChkLen )
|
2008-04-18 12:16:17 +00:00
|
|
|
|
rSaveArr[ n-1 ] -= nChkLen;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SwPosition* pPos = 0;
|
|
|
|
|
switch( aSave.GetType() )
|
|
|
|
|
{
|
|
|
|
|
case 0x8000:
|
2008-02-26 09:35:35 +00:00
|
|
|
|
{
|
|
|
|
|
// --> OD 2007-09-27 #i81002# - refactoring
|
|
|
|
|
// Do not directly manipulate members of <SwBookmark>
|
|
|
|
|
// pPos = (SwPosition*)&rBkmks[ aSave.GetCount() ]->GetBookmarkPos();
|
|
|
|
|
SwPosition aNewPos( rBkmks[ aSave.GetCount() ]->GetBookmarkPos() );
|
|
|
|
|
aNewPos.nNode = rNd;
|
|
|
|
|
aNewPos.nContent.Assign( pCNd, Min( aSave.GetContent(), nLen ) );
|
|
|
|
|
rBkmks[ aSave.GetCount() ]->SetBookmarkPos( &aNewPos );
|
|
|
|
|
// <--
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
case 0x8001:
|
2008-02-26 09:35:35 +00:00
|
|
|
|
{
|
|
|
|
|
// --> OD 2007-09-27 #i81002# - refactoring
|
|
|
|
|
// Do not directly manipulate members of <SwBookmark>
|
|
|
|
|
// pPos = (SwPosition*)rBkmks[ aSave.GetCount() ]->GetOtherBookmarkPos();
|
|
|
|
|
SwPosition aNewPos( *(rBkmks[ aSave.GetCount() ]->GetOtherBookmarkPos()) );
|
|
|
|
|
aNewPos.nNode = rNd;
|
|
|
|
|
aNewPos.nContent.Assign( pCNd, Min( aSave.GetContent(), nLen ) );
|
|
|
|
|
rBkmks[ aSave.GetCount() ]->SetOtherBookmarkPos( &aNewPos );
|
|
|
|
|
// <--
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
case 0x1001:
|
|
|
|
|
pPos = (SwPosition*)rRedlTbl[ aSave.GetCount() ]->GetPoint();
|
|
|
|
|
break;
|
|
|
|
|
case 0x1000:
|
|
|
|
|
pPos = (SwPosition*)rRedlTbl[ aSave.GetCount() ]->GetMark();
|
|
|
|
|
break;
|
|
|
|
|
case 0x2000:
|
|
|
|
|
case 0x2001:
|
|
|
|
|
{
|
|
|
|
|
SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
|
|
|
|
|
const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
|
|
|
|
|
if( rFlyAnchor.GetCntntAnchor() )
|
|
|
|
|
{
|
|
|
|
|
SwFmtAnchor aNew( rFlyAnchor );
|
|
|
|
|
SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
|
|
|
|
|
aNewPos.nNode = rNd;
|
|
|
|
|
if( FLY_AUTO_CNTNT == rFlyAnchor.GetAnchorId() )
|
|
|
|
|
aNewPos.nContent.Assign( pCNd, Min(
|
|
|
|
|
aSave.GetContent(), nLen ) );
|
|
|
|
|
else
|
|
|
|
|
aNewPos.nContent.Assign( 0, 0 );
|
|
|
|
|
aNew.SetAnchor( &aNewPos );
|
|
|
|
|
pFrmFmt->SetAttr( aNew );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0800:
|
|
|
|
|
case 0x0801:
|
|
|
|
|
{
|
|
|
|
|
USHORT nCnt = 0;
|
|
|
|
|
SwCrsrShell* pShell = pDoc->GetEditShell();
|
|
|
|
|
if( pShell )
|
|
|
|
|
{
|
|
|
|
|
FOREACHSHELL_START( pShell )
|
2007-09-27 07:33:02 +00:00
|
|
|
|
SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( _pStkCrsr )
|
|
|
|
|
do {
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &_pStkCrsr->GetBound( 0x0800 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
} while ( (_pStkCrsr != 0 ) &&
|
|
|
|
|
((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
|
|
|
|
|
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
FOREACHPAM_START( PCURSH->_GetCrsr() )
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &PCURCRSR->GetBound( 0x0800 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
FOREACHSHELL_END( pShell )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 0x0400:
|
|
|
|
|
case 0x0401:
|
|
|
|
|
{
|
|
|
|
|
USHORT nCnt = 0;
|
2007-09-27 07:33:02 +00:00
|
|
|
|
const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
for( USHORT i = 0; i < rTbl.Count(); ++i )
|
|
|
|
|
{
|
|
|
|
|
FOREACHPAM_START( rTbl[ i ] )
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &PCURCRSR->GetBound( 0x0400 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
SwUnoTableCrsr* pUnoTblCrsr = (SwUnoTableCrsr*)*rTbl[ i ];
|
|
|
|
|
if( pUnoTblCrsr )
|
|
|
|
|
{
|
|
|
|
|
FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
|
|
|
|
|
if( aSave.GetCount() == nCnt )
|
|
|
|
|
{
|
|
|
|
|
pPos = &PCURCRSR->GetBound( 0x0400 ==
|
|
|
|
|
aSave.GetType() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
++nCnt;
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
}
|
|
|
|
|
if( pPos )
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( pPos )
|
|
|
|
|
{
|
|
|
|
|
pPos->nNode = rNd;
|
|
|
|
|
pPos->nContent.Assign( pCNd, Min( aSave.GetContent(), nLen ) );
|
|
|
|
|
}
|
2008-04-18 12:16:17 +00:00
|
|
|
|
n -= 2;
|
|
|
|
|
rSaveArr.Remove( n, 2 );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
// --> OD 2007-11-09 #i81002#
|
|
|
|
|
namespace bookmarkfunc
|
|
|
|
|
{
|
|
|
|
|
const String getHeadingCrossRefBookmarkNamePrefix()
|
|
|
|
|
{
|
|
|
|
|
static const String sPrefix( String::CreateFromAscii( "__RefHeading__" ) );
|
|
|
|
|
|
|
|
|
|
return sPrefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const String getNumItemCrossRefBookmarkNamePrefix()
|
|
|
|
|
{
|
|
|
|
|
static String sPrefix( String::CreateFromAscii( "__RefNumPara__" ) );
|
|
|
|
|
|
|
|
|
|
return sPrefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isHeadingCrossRefBookmarkName( /*[in]*/const String& rName )
|
|
|
|
|
{
|
|
|
|
|
bool bRet( false );
|
|
|
|
|
|
|
|
|
|
const xub_StrLen cLenOfFixedFirstPart =
|
|
|
|
|
getHeadingCrossRefBookmarkNamePrefix().Len();
|
|
|
|
|
if ( rName.Len() > cLenOfFixedFirstPart )
|
|
|
|
|
{
|
|
|
|
|
const String aFirstPartOfName = rName.Copy( 0, cLenOfFixedFirstPart );
|
|
|
|
|
const String aRestOfName = rName.Copy( cLenOfFixedFirstPart );
|
|
|
|
|
if ( aRestOfName.ToInt64() > 0 &&
|
|
|
|
|
aFirstPartOfName.Equals( getHeadingCrossRefBookmarkNamePrefix() ) )
|
|
|
|
|
{
|
|
|
|
|
bRet = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isNumItemCrossRefBookmarkName( /*[in]*/const String& rName )
|
|
|
|
|
{
|
|
|
|
|
bool bRet( false );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2008-02-26 09:35:35 +00:00
|
|
|
|
const xub_StrLen cLenOfFixedFirstPart =
|
|
|
|
|
getNumItemCrossRefBookmarkNamePrefix().Len();
|
|
|
|
|
if ( rName.Len() > cLenOfFixedFirstPart )
|
|
|
|
|
{
|
|
|
|
|
const String aFirstPartOfName = rName.Copy( 0, cLenOfFixedFirstPart );
|
|
|
|
|
const String aRestOfName = rName.Copy( cLenOfFixedFirstPart );
|
|
|
|
|
if ( aRestOfName.ToInt64() > 0 &&
|
|
|
|
|
aFirstPartOfName.Equals( getNumItemCrossRefBookmarkNamePrefix() ) )
|
|
|
|
|
{
|
|
|
|
|
bRet = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --> OD 2007-11-16 #i83479#
|
|
|
|
|
String generateNewCrossRefBookmarkName(
|
|
|
|
|
/*[in]*/const IDocumentBookmarkAccess::CrossReferenceBookmarkSubType nSubType )
|
|
|
|
|
{
|
|
|
|
|
String sNewName;
|
|
|
|
|
if ( nSubType == IDocumentBookmarkAccess::HEADING )
|
|
|
|
|
{
|
|
|
|
|
sNewName = getHeadingCrossRefBookmarkNamePrefix();
|
|
|
|
|
}
|
|
|
|
|
else if ( nSubType == IDocumentBookmarkAccess::NUMITEM )
|
|
|
|
|
{
|
|
|
|
|
sNewName = getNumItemCrossRefBookmarkNamePrefix();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long n = Time().GetTime();
|
|
|
|
|
n += Date().GetDate();
|
|
|
|
|
sNewName.Append( String::CreateFromInt32( n ) );
|
|
|
|
|
|
|
|
|
|
return sNewName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <--
|