2000-09-18 23:08:29 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-10 15:07:42 +00:00
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:07:42 +00:00
|
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:07:42 +00:00
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:07:42 +00:00
|
|
|
|
* $RCSfile: unins.cxx,v $
|
|
|
|
|
* $Revision: 1.32 $
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:07:42 +00:00
|
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:07:42 +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 15:07:42 +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 15:07:42 +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 20:52:04 +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 <hintids.hxx>
|
2000-10-25 14:13:25 +00:00
|
|
|
|
#include <unotools/charclass.hxx>
|
2004-10-04 18:13:13 +00:00
|
|
|
|
#include <sot/storage.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
#include <svx/keepitem.hxx>
|
|
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
|
|
2004-10-04 18:13:13 +00:00
|
|
|
|
#include <docsh.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
#include <fmtcntnt.hxx>
|
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
|
#include <doc.hxx>
|
|
|
|
|
#include <swundo.hxx> // fuer die UndoIds
|
|
|
|
|
#include <pam.hxx>
|
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
|
#include <undobj.hxx>
|
|
|
|
|
#include <rolbck.hxx>
|
|
|
|
|
#include <ndgrf.hxx>
|
|
|
|
|
#include <ndole.hxx>
|
|
|
|
|
#include <grfatr.hxx>
|
|
|
|
|
#include <cntfrm.hxx>
|
|
|
|
|
#include <flyfrm.hxx>
|
|
|
|
|
#include <fesh.hxx>
|
|
|
|
|
#include <swtable.hxx>
|
|
|
|
|
#include <redline.hxx>
|
|
|
|
|
#include <docary.hxx>
|
|
|
|
|
#include <acorrect.hxx>
|
|
|
|
|
#include <dcontact.hxx>
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
#include <comcore.hrc> // #111827#
|
|
|
|
|
#include <undo.hrc>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2007-09-27 08:31:41 +00:00
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
class _UnReplaceData : private SwUndoSaveCntnt
|
|
|
|
|
{
|
|
|
|
|
String sOld, sIns;
|
|
|
|
|
ULONG nSttNd, nEndNd, nOffset;
|
|
|
|
|
xub_StrLen nSttCnt, nEndCnt, nSetPos, nSelEnd;
|
|
|
|
|
BOOL bSplitNext : 1;
|
|
|
|
|
BOOL bRegExp : 1;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
_UnReplaceData( const SwPaM& rPam, const String& rIns, BOOL bRegExp );
|
|
|
|
|
~_UnReplaceData();
|
|
|
|
|
|
|
|
|
|
void Undo( SwUndoIter& rIter );
|
|
|
|
|
void Redo( SwUndoIter& rIter );
|
|
|
|
|
void SetEnd( const SwPaM& rPam );
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
const String & GetOld() const { return sOld; }
|
|
|
|
|
const String & GetIns() const { return sIns; }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SV_IMPL_PTRARR( _UnReplaceDatas, _UnReplaceData* )
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
|
|
|
|
|
|
|
|
|
|
// zwei Zugriffs-Funktionen
|
|
|
|
|
inline SwPosition* IterPt( SwUndoIter& rUIter )
|
|
|
|
|
{ return rUIter.pAktPam->GetPoint(); }
|
|
|
|
|
inline SwPosition* IterMk( SwUndoIter& rUIter )
|
|
|
|
|
{ return rUIter.pAktPam->GetMark(); }
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// INSERT
|
|
|
|
|
|
2004-05-18 13:08:42 +00:00
|
|
|
|
String * SwUndoInsert::GetTxtFromDoc() const
|
|
|
|
|
{
|
|
|
|
|
String * pResult = NULL;
|
|
|
|
|
|
|
|
|
|
SwNodeIndex aNd( pDoc->GetNodes(), nNode);
|
|
|
|
|
SwCntntNode* pCNd = aNd.GetNode().GetCntntNode();
|
|
|
|
|
SwPaM aPaM( *pCNd, nCntnt );
|
|
|
|
|
|
|
|
|
|
aPaM.SetMark();
|
|
|
|
|
|
|
|
|
|
if( pCNd->IsTxtNode() )
|
|
|
|
|
{
|
|
|
|
|
pResult = new String( ((SwTxtNode*)pCNd)->GetTxt().Copy(nCntnt-nLen,
|
|
|
|
|
nLen ) );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoInsert::Init(const SwNodeIndex & rNd)
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
// Redline beachten
|
2004-05-18 13:08:42 +00:00
|
|
|
|
pDoc = rNd.GetNode().GetDoc();
|
|
|
|
|
if( pDoc->IsRedlineOn() )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pRedlData = new SwRedlineData( nsRedlineType_t::REDLINE_INSERT,
|
2004-05-18 13:08:42 +00:00
|
|
|
|
pDoc->GetRedlineAuthor() );
|
|
|
|
|
SetRedlineMode( pDoc->GetRedlineMode() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
pUndoTxt = GetTxtFromDoc();
|
2004-09-08 14:00:19 +00:00
|
|
|
|
|
|
|
|
|
bCacheComment = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-18 13:08:42 +00:00
|
|
|
|
// #111827#
|
|
|
|
|
SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, xub_StrLen nCnt,
|
|
|
|
|
xub_StrLen nL, BOOL bWDelim )
|
2007-09-27 08:31:41 +00:00
|
|
|
|
: SwUndo(UNDO_TYPING), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ),
|
|
|
|
|
nNode( rNd.GetIndex() ), nCntnt(nCnt), nLen(nL),
|
|
|
|
|
bIsWordDelim( bWDelim ), bIsAppend( FALSE )
|
2004-05-18 13:08:42 +00:00
|
|
|
|
{
|
|
|
|
|
Init(rNd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// #111827#
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd )
|
2007-09-27 08:31:41 +00:00
|
|
|
|
: SwUndo(UNDO_SPLITNODE), pPos( 0 ), pTxt( 0 ),
|
|
|
|
|
pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(0), nLen(1),
|
|
|
|
|
bIsWordDelim( FALSE ), bIsAppend( TRUE )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2004-05-18 13:08:42 +00:00
|
|
|
|
Init(rNd);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// stelle fest, ob das naechste Insert mit dem aktuellen zusammengefasst
|
|
|
|
|
// werden kann. Wenn ja, dann aender die Laenge und die InsPos.
|
|
|
|
|
// Dann wird von SwDoc::Insert kein neues Object in die Undoliste gestellt.
|
|
|
|
|
|
|
|
|
|
BOOL SwUndoInsert::CanGrouping( const SwPosition& rInsPos, sal_Unicode cIns )
|
|
|
|
|
{
|
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
|
if( !bIsAppend )
|
|
|
|
|
{
|
|
|
|
|
++nCntnt;
|
|
|
|
|
bRet = CanGrouping( rInsPos );
|
|
|
|
|
--nCntnt;
|
|
|
|
|
if( bRet )
|
|
|
|
|
bRet = CanGrouping( cIns );
|
|
|
|
|
}
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SwUndoInsert::CanGrouping( sal_Unicode cIns )
|
|
|
|
|
{
|
2000-10-25 14:13:25 +00:00
|
|
|
|
if( !bIsAppend && bIsWordDelim ==
|
|
|
|
|
!GetAppCharClass().isLetterNumeric( String( cIns )) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
nLen++;
|
|
|
|
|
nCntnt++;
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
if (pUndoTxt)
|
|
|
|
|
pUndoTxt->Insert(cIns);
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL SwUndoInsert::CanGrouping( const SwPosition& rPos )
|
|
|
|
|
{
|
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
|
if( nNode == rPos.nNode.GetIndex() &&
|
|
|
|
|
nCntnt == rPos.nContent.GetIndex() )
|
|
|
|
|
{
|
|
|
|
|
// Redline beachten
|
|
|
|
|
SwDoc& rDoc = *rPos.nNode.GetNode().GetDoc();
|
2007-09-27 08:31:41 +00:00
|
|
|
|
if( ( ~nsRedlineMode_t::REDLINE_SHOW_MASK & rDoc.GetRedlineMode() ) ==
|
|
|
|
|
( ~nsRedlineMode_t::REDLINE_SHOW_MASK & GetRedlineMode() ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
bRet = TRUE;
|
|
|
|
|
|
|
|
|
|
// dann war oder ist noch Redline an:
|
|
|
|
|
// pruefe, ob an der InsPosition ein anderer Redline
|
|
|
|
|
// rumsteht. Wenn der gleiche nur einmalig vorhanden ist,
|
|
|
|
|
// kann zusammen gefasst werden.
|
|
|
|
|
const SwRedlineTbl& rTbl = rDoc.GetRedlineTbl();
|
|
|
|
|
if( rTbl.Count() )
|
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SwRedlineData aRData( nsRedlineType_t::REDLINE_INSERT, rDoc.GetRedlineAuthor() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
const SwIndexReg* pIReg = rPos.nContent.GetIdxReg();
|
|
|
|
|
SwIndex* pIdx;
|
|
|
|
|
for( USHORT i = 0; i < rTbl.Count(); ++i )
|
|
|
|
|
{
|
|
|
|
|
SwRedline* pRedl = rTbl[ i ];
|
|
|
|
|
if( pIReg == (pIdx = &pRedl->End()->nContent)->GetIdxReg() &&
|
|
|
|
|
nCntnt == pIdx->GetIndex() )
|
|
|
|
|
{
|
2001-03-02 16:53:14 +00:00
|
|
|
|
if( !pRedl->HasMark() || !pRedlData ||
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*pRedl != *pRedlData || *pRedl != aRData )
|
|
|
|
|
{
|
|
|
|
|
bRet = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwUndoInsert::~SwUndoInsert()
|
|
|
|
|
{
|
|
|
|
|
if( pPos ) // loesche noch den Bereich aus dem UndoNodes Array
|
|
|
|
|
{
|
|
|
|
|
// Insert speichert den Inhalt in der IconSection
|
|
|
|
|
SwNodes& rUNds = pPos->nNode.GetNode().GetNodes();
|
|
|
|
|
if( pPos->nContent.GetIndex() ) // nicht den gesamten Node loeschen
|
|
|
|
|
{
|
|
|
|
|
SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
|
|
|
|
|
ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" );
|
|
|
|
|
pTxtNd->Erase( pPos->nContent );
|
|
|
|
|
pPos->nNode++;
|
|
|
|
|
}
|
|
|
|
|
pPos->nContent.Assign( 0, 0 );
|
|
|
|
|
rUNds.Delete( pPos->nNode, rUNds.GetEndOfExtras().GetIndex() -
|
|
|
|
|
pPos->nNode.GetIndex() );
|
|
|
|
|
delete pPos;
|
|
|
|
|
}
|
|
|
|
|
else if( pTxt ) // der eingefuegte Text
|
|
|
|
|
delete pTxt;
|
|
|
|
|
delete pRedlData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoInsert::Undo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SwDoc* pTmpDoc = &rUndoIter.GetDoc();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
if( bIsAppend )
|
|
|
|
|
{
|
|
|
|
|
SwPaM* pPam = rUndoIter.pAktPam;
|
|
|
|
|
pPam->GetPoint()->nNode = nNode;
|
|
|
|
|
|
2006-08-14 15:50:19 +00:00
|
|
|
|
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
pPam->GetPoint()->nContent.Assign( pPam->GetCntntNode(), 0 );
|
|
|
|
|
pPam->SetMark();
|
|
|
|
|
pPam->Move( fnMoveBackward );
|
|
|
|
|
pPam->Exchange();
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pTmpDoc->DeleteRedline( *pPam, true, USHRT_MAX );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
pPam->DeleteMark();
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pTmpDoc->DelFullPara( *pPam );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pPam->GetPoint()->nContent.Assign( pPam->GetCntntNode(), 0 );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ULONG nNd = nNode;
|
|
|
|
|
xub_StrLen nCnt = nCntnt;
|
|
|
|
|
if( nLen )
|
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SwNodeIndex aNd( pTmpDoc->GetNodes(), nNode);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwCntntNode* pCNd = aNd.GetNode().GetCntntNode();
|
|
|
|
|
SwPaM aPaM( *pCNd, nCntnt );
|
|
|
|
|
|
|
|
|
|
aPaM.SetMark();
|
|
|
|
|
|
|
|
|
|
if( pCNd->IsTxtNode() ) // Text !!
|
|
|
|
|
{
|
|
|
|
|
aPaM.GetPoint()->nContent -= nLen;
|
2006-08-14 15:50:19 +00:00
|
|
|
|
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pTmpDoc->DeleteRedline( aPaM, true, USHRT_MAX );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
RemoveIdxFromRange( aPaM, FALSE );
|
|
|
|
|
pTxt = new String( ((SwTxtNode*)pCNd)->GetTxt().Copy(
|
|
|
|
|
nCntnt-nLen, nLen ) );
|
|
|
|
|
((SwTxtNode*)pCNd)->Erase( aPaM.GetPoint()->nContent, nLen );
|
|
|
|
|
}
|
|
|
|
|
else // ansonsten Grafik/OLE/Text/...
|
|
|
|
|
{
|
|
|
|
|
aPaM.Move(fnMoveBackward);
|
2006-08-14 15:50:19 +00:00
|
|
|
|
if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pTmpDoc->DeleteRedline( aPaM, true, USHRT_MAX );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
RemoveIdxFromRange( aPaM, FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nNd = aPaM.GetPoint()->nNode.GetIndex();
|
|
|
|
|
nCnt = aPaM.GetPoint()->nContent.GetIndex();
|
|
|
|
|
|
|
|
|
|
if( !pTxt )
|
|
|
|
|
{
|
|
|
|
|
pPos = new SwPosition( *aPaM.GetPoint() );
|
|
|
|
|
MoveToUndoNds( aPaM, &pPos->nNode, &pPos->nContent );
|
|
|
|
|
}
|
|
|
|
|
nNode = aPaM.GetPoint()->nNode.GetIndex();
|
|
|
|
|
nCntnt = aPaM.GetPoint()->nContent.GetIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// setze noch den Cursor auf den Undo-Bereich
|
|
|
|
|
rUndoIter.pAktPam->DeleteMark();
|
|
|
|
|
|
|
|
|
|
IterPt(rUndoIter)->nNode = nNd;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
IterPt(rUndoIter)->nContent.Assign( pTmpDoc->GetNodes()[
|
2000-09-18 23:08:29 +00:00
|
|
|
|
IterPt(rUndoIter)->nNode ]->GetCntntNode(), nCnt );
|
|
|
|
|
// SPoint und GetMark auf der gleichen Position
|
|
|
|
|
}
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
DELETEZ(pUndoTxt);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoInsert::Redo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
// setze noch den Cursor auf den Redo-Bereich
|
|
|
|
|
SwPaM* pPam = rUndoIter.pAktPam;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SwDoc* pTmpDoc = pPam->GetDoc();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pPam->DeleteMark();
|
|
|
|
|
|
|
|
|
|
if( bIsAppend )
|
|
|
|
|
{
|
|
|
|
|
pPam->GetPoint()->nNode = nNode - 1;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pTmpDoc->AppendTxtNode( *pPam->GetPoint() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
pPam->SetMark();
|
|
|
|
|
pPam->Move( fnMoveBackward );
|
|
|
|
|
pPam->Exchange();
|
|
|
|
|
|
2006-08-14 15:50:19 +00:00
|
|
|
|
if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
RedlineMode_t eOld = pTmpDoc->GetRedlineMode();
|
|
|
|
|
pTmpDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
|
|
|
|
|
pTmpDoc->AppendRedline( new SwRedline( *pRedlData, *pPam ), true);
|
|
|
|
|
pTmpDoc->SetRedlineMode_intern( eOld );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2007-09-27 08:31:41 +00:00
|
|
|
|
else if( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) &&
|
|
|
|
|
pTmpDoc->GetRedlineTbl().Count() )
|
|
|
|
|
pTmpDoc->SplitRedline( *pPam );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
pPam->DeleteMark();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pPam->GetPoint()->nNode = nNode;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SwCntntNode* pCNd = pTmpDoc->GetNodes()[ pPam->GetPoint()->nNode ]->GetCntntNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pPam->GetPoint()->nContent.Assign( pCNd, nCntnt );
|
|
|
|
|
|
|
|
|
|
if( nLen )
|
|
|
|
|
{
|
|
|
|
|
BOOL bMvBkwrd = MovePtBackward( *pPam );
|
|
|
|
|
|
|
|
|
|
if( pTxt )
|
|
|
|
|
{
|
|
|
|
|
ASSERT( pCNd->IsTxtNode(), "wo ist mein Textnode ??" );
|
|
|
|
|
((SwTxtNode*)pCNd)->Insert( *pTxt, pPam->GetMark()->nContent,
|
|
|
|
|
INS_EMPTYEXPAND );
|
|
|
|
|
DELETEZ( pTxt );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Inhalt wieder einfuegen. (erst pPos abmelden !!)
|
|
|
|
|
ULONG nMvNd = pPos->nNode.GetIndex();
|
|
|
|
|
xub_StrLen nMvCnt = pPos->nContent.GetIndex();
|
|
|
|
|
DELETEZ( pPos );
|
2007-09-27 08:31:41 +00:00
|
|
|
|
MoveFromUndoNds( *pTmpDoc, nMvNd, nMvCnt, *pPam->GetMark() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
nNode = pPam->GetMark()->nNode.GetIndex();
|
|
|
|
|
nCntnt = pPam->GetMark()->nContent.GetIndex();
|
|
|
|
|
|
|
|
|
|
MovePtForward( *pPam, bMvBkwrd );
|
|
|
|
|
rUndoIter.pAktPam->Exchange();
|
2006-08-14 15:50:19 +00:00
|
|
|
|
if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ))
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
RedlineMode_t eOld = pTmpDoc->GetRedlineMode();
|
|
|
|
|
pTmpDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
|
|
|
|
|
pTmpDoc->AppendRedline( new SwRedline( *pRedlData,
|
2006-08-14 15:50:19 +00:00
|
|
|
|
*rUndoIter.pAktPam ), true);
|
2007-09-27 08:31:41 +00:00
|
|
|
|
pTmpDoc->SetRedlineMode_intern( eOld );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2007-09-27 08:31:41 +00:00
|
|
|
|
else if( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) &&
|
|
|
|
|
pTmpDoc->GetRedlineTbl().Count() )
|
|
|
|
|
pTmpDoc->SplitRedline( *rUndoIter.pAktPam );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
pUndoTxt = GetTxtFromDoc();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoInsert::Repeat( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
rUndoIter.pLastUndoObj = this;
|
|
|
|
|
if( !nLen )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
SwDoc& rDoc = rUndoIter.GetDoc();
|
|
|
|
|
SwNodeIndex aNd( rDoc.GetNodes(), nNode );
|
|
|
|
|
SwCntntNode* pCNd = aNd.GetNode().GetCntntNode();;
|
|
|
|
|
|
|
|
|
|
if( !bIsAppend && 1 == nLen ) // >1 dann immer nur Text, ansonsten Grafik/OLE/Text/...
|
|
|
|
|
{
|
|
|
|
|
SwPaM aPaM( *pCNd, nCntnt );
|
|
|
|
|
aPaM.SetMark();
|
|
|
|
|
aPaM.Move(fnMoveBackward);
|
|
|
|
|
pCNd = aPaM.GetCntntNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Was passiert mit dem evt. selektierten Bereich ???
|
|
|
|
|
|
|
|
|
|
switch( pCNd->GetNodeType() )
|
|
|
|
|
{
|
|
|
|
|
case ND_TEXTNODE:
|
|
|
|
|
if( bIsAppend )
|
|
|
|
|
rDoc.AppendTxtNode( *rUndoIter.pAktPam->GetPoint() );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
String aTxt( ((SwTxtNode*)pCNd)->GetTxt() );
|
|
|
|
|
BOOL bGroupUndo = rDoc.DoesGroupUndo();
|
|
|
|
|
rDoc.DoGroupUndo( FALSE );
|
2006-08-14 15:50:19 +00:00
|
|
|
|
rDoc.Insert( *rUndoIter.pAktPam, aTxt.Copy( nCntnt - nLen, nLen ), true);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
rDoc.DoGroupUndo( bGroupUndo );
|
|
|
|
|
}
|
2007-07-18 13:28:52 +00:00
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
case ND_GRFNODE:
|
|
|
|
|
{
|
|
|
|
|
SwGrfNode* pGrfNd = (SwGrfNode*)pCNd;
|
|
|
|
|
String sFile, sFilter;
|
|
|
|
|
if( pGrfNd->IsGrfLink() )
|
|
|
|
|
pGrfNd->GetFileFilterNms( &sFile, &sFilter );
|
|
|
|
|
|
|
|
|
|
rDoc.Insert( *rUndoIter.pAktPam, sFile, sFilter,
|
|
|
|
|
&pGrfNd->GetGrf(),
|
2006-08-14 15:50:19 +00:00
|
|
|
|
0/* Grafik-Collection*/, NULL, NULL );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ND_OLENODE:
|
|
|
|
|
{
|
|
|
|
|
// StarView bietet noch nicht die Moeglichkeit ein StarOBJ zu kopieren
|
|
|
|
|
SvStorageRef aRef = new SvStorage( aEmptyStr );
|
|
|
|
|
SwOLEObj& rSwOLE = (SwOLEObj&)((SwOLENode*)pCNd)->GetOLEObj();
|
2004-10-04 18:13:13 +00:00
|
|
|
|
|
|
|
|
|
// temporary storage until object is inserted
|
|
|
|
|
// TODO/MBA: seems that here a physical copy is done - not as in drawing layer! Testing!
|
2005-03-23 13:00:31 +00:00
|
|
|
|
// TODO/LATER: Copying through the container would copy the replacement image as well
|
2004-10-04 18:13:13 +00:00
|
|
|
|
comphelper::EmbeddedObjectContainer aCnt;
|
2005-03-23 13:00:31 +00:00
|
|
|
|
::rtl::OUString aName = aCnt.CreateUniqueObjectName();
|
|
|
|
|
if ( aCnt.StoreEmbeddedObject( rSwOLE.GetOleRef(), aName, sal_True ) )
|
2004-11-26 15:27:10 +00:00
|
|
|
|
{
|
2007-09-27 08:31:41 +00:00
|
|
|
|
uno::Reference < embed::XEmbeddedObject > aNew = aCnt.GetEmbeddedObject( aName );
|
2006-10-13 10:09:38 +00:00
|
|
|
|
rDoc.Insert( *rUndoIter.pAktPam, svt::EmbeddedObjectRef( aNew, ((SwOLENode*)pCNd)->GetAspect() ), NULL, NULL, NULL );
|
2004-11-26 15:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-18 13:08:42 +00:00
|
|
|
|
// #111827#
|
|
|
|
|
SwRewriter SwUndoInsert::GetRewriter() const
|
|
|
|
|
{
|
|
|
|
|
SwRewriter aResult;
|
|
|
|
|
String * pStr = NULL;
|
|
|
|
|
bool bDone = false;
|
|
|
|
|
|
|
|
|
|
if (pTxt)
|
|
|
|
|
pStr = pTxt;
|
|
|
|
|
else if (pUndoTxt)
|
|
|
|
|
pStr = pUndoTxt;
|
|
|
|
|
|
|
|
|
|
if (pStr)
|
|
|
|
|
{
|
2004-09-08 14:00:19 +00:00
|
|
|
|
String aString = ShortenString(DenoteSpecialCharacters(*pStr),
|
|
|
|
|
nUndoStringLength,
|
|
|
|
|
String(SW_RES(STR_LDOTS)));
|
2004-05-18 13:08:42 +00:00
|
|
|
|
|
|
|
|
|
aResult.AddRule(UNDO_ARG1, aString);
|
|
|
|
|
|
|
|
|
|
bDone = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ! bDone )
|
|
|
|
|
{
|
|
|
|
|
aResult.AddRule(UNDO_ARG1, String("??", RTL_TEXTENCODING_ASCII_US));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
SwUndoReplace::SwUndoReplace()
|
|
|
|
|
: SwUndo( UNDO_REPLACE ), nAktPos( USHRT_MAX )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwUndoReplace::~SwUndoReplace()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoReplace::Undo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
// war dieses nicht die letze Undo-Aktion, dann setze den
|
|
|
|
|
// Count neu
|
|
|
|
|
if( rUndoIter.pLastUndoObj != this )
|
|
|
|
|
{
|
|
|
|
|
nAktPos = aArr.Count();
|
|
|
|
|
rUndoIter.pLastUndoObj = this;
|
|
|
|
|
bOldIterFlag = rUndoIter.bWeiter;
|
|
|
|
|
rUndoIter.bWeiter = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aArr[ --nAktPos ]->Undo( rUndoIter );
|
|
|
|
|
|
|
|
|
|
if( !nAktPos ) // alten Status wieder zurueck
|
|
|
|
|
rUndoIter.bWeiter = bOldIterFlag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoReplace::Redo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
// war dieses nicht die letze Undo-Aktion, dann setze den
|
|
|
|
|
// Count neu
|
|
|
|
|
if( rUndoIter.pLastUndoObj != this )
|
|
|
|
|
{
|
|
|
|
|
ASSERT( !nAktPos, "Redo ohne vorheriges Undo??" );
|
|
|
|
|
rUndoIter.pLastUndoObj = this;
|
|
|
|
|
bOldIterFlag = rUndoIter.bWeiter;
|
|
|
|
|
rUndoIter.bWeiter = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aArr[ nAktPos ]->Redo( rUndoIter );
|
|
|
|
|
|
|
|
|
|
if( ++nAktPos >= aArr.Count() ) // alten Status wieder zurueck
|
|
|
|
|
{
|
|
|
|
|
nAktPos = USHRT_MAX;
|
|
|
|
|
rUndoIter.bWeiter = bOldIterFlag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-18 13:08:42 +00:00
|
|
|
|
// #111827#
|
|
|
|
|
SwRewriter SwUndoReplace::GetRewriter() const
|
|
|
|
|
{
|
|
|
|
|
SwRewriter aResult;
|
|
|
|
|
|
|
|
|
|
if (aArr.Count() > 1)
|
|
|
|
|
{
|
|
|
|
|
aResult.AddRule(UNDO_ARG1, String::CreateFromInt32(aArr.Count()));
|
|
|
|
|
aResult.AddRule(UNDO_ARG2, String(SW_RES(STR_OCCURRENCES_OF)));
|
|
|
|
|
|
|
|
|
|
String aTmpStr;
|
|
|
|
|
aTmpStr += String(SW_RES(STR_START_QUOTE));
|
2004-11-09 12:50:28 +00:00
|
|
|
|
aTmpStr += ShortenString(aArr[0]->GetOld(), nUndoStringLength,
|
|
|
|
|
SW_RES(STR_LDOTS));
|
2004-05-18 13:08:42 +00:00
|
|
|
|
aTmpStr += String(SW_RES(STR_END_QUOTE));
|
|
|
|
|
aResult.AddRule(UNDO_ARG3, aTmpStr);
|
|
|
|
|
}
|
|
|
|
|
else if (aArr.Count() == 1)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
String aTmpStr;
|
|
|
|
|
|
|
|
|
|
aTmpStr += String(SW_RES(STR_START_QUOTE));
|
2004-11-09 12:50:28 +00:00
|
|
|
|
// #i33488 #
|
|
|
|
|
aTmpStr += ShortenString(aArr[0]->GetOld(), nUndoStringLength,
|
|
|
|
|
SW_RES(STR_LDOTS));
|
2004-05-18 13:08:42 +00:00
|
|
|
|
aTmpStr += String(SW_RES(STR_END_QUOTE));
|
|
|
|
|
aResult.AddRule(UNDO_ARG1, aTmpStr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aResult.AddRule(UNDO_ARG2, String(SW_RES(STR_YIELDS)));
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
String aTmpStr;
|
|
|
|
|
|
|
|
|
|
aTmpStr += String(SW_RES(STR_START_QUOTE));
|
2004-11-09 12:50:28 +00:00
|
|
|
|
// #i33488 #
|
|
|
|
|
aTmpStr += ShortenString(aArr[0]->GetIns(), nUndoStringLength,
|
|
|
|
|
SW_RES(STR_LDOTS));
|
2004-05-18 13:08:42 +00:00
|
|
|
|
aTmpStr += String(SW_RES(STR_END_QUOTE));
|
|
|
|
|
aResult.AddRule(UNDO_ARG3, aTmpStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
void SwUndoReplace::AddEntry( const SwPaM& rPam, const String& rInsert,
|
|
|
|
|
BOOL bRegExp )
|
|
|
|
|
{
|
|
|
|
|
_UnReplaceData* pNew = new _UnReplaceData( rPam, rInsert, bRegExp );
|
|
|
|
|
aArr.C40_INSERT(_UnReplaceData, pNew, aArr.Count() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoReplace::SetEntryEnd( const SwPaM& rPam )
|
|
|
|
|
{
|
|
|
|
|
_UnReplaceData* pEntry = aArr[ aArr.Count()-1 ];
|
|
|
|
|
pEntry->SetEnd( rPam );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns,
|
|
|
|
|
BOOL bRgExp )
|
2007-09-27 08:31:41 +00:00
|
|
|
|
: sIns( rIns ), nOffset( 0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
bRegExp = bRgExp;
|
|
|
|
|
|
|
|
|
|
const SwPosition *pStt = rPam.Start(),
|
|
|
|
|
*pEnd = rPam.GetPoint() == pStt
|
|
|
|
|
? rPam.GetMark()
|
|
|
|
|
: rPam.GetPoint();
|
|
|
|
|
|
|
|
|
|
nSttNd = nEndNd = pStt->nNode.GetIndex();
|
|
|
|
|
nSttCnt = pStt->nContent.GetIndex();
|
|
|
|
|
nSelEnd = nEndCnt = pEnd->nContent.GetIndex();
|
|
|
|
|
|
|
|
|
|
bSplitNext = nSttNd != pEnd->nNode.GetIndex();
|
|
|
|
|
|
|
|
|
|
SwTxtNode* pNd = pStt->nNode.GetNode().GetTxtNode();
|
|
|
|
|
ASSERT( pNd, "wo ist der TextNode" );
|
|
|
|
|
|
|
|
|
|
pHistory = new SwHistory;
|
|
|
|
|
DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() );
|
|
|
|
|
|
|
|
|
|
nSetPos = pHistory->Count();
|
|
|
|
|
|
|
|
|
|
ULONG nNewPos = pStt->nNode.GetIndex();
|
|
|
|
|
nOffset = nSttNd - nNewPos;
|
|
|
|
|
|
|
|
|
|
if( pNd->GetpSwpHints() )
|
|
|
|
|
pHistory->CopyAttr( pNd->GetpSwpHints(), nNewPos, 0,
|
|
|
|
|
pNd->GetTxt().Len(), TRUE );
|
|
|
|
|
|
|
|
|
|
if( bSplitNext )
|
|
|
|
|
{
|
2006-12-01 14:49:25 +00:00
|
|
|
|
if( pNd->HasSwAttrSet() )
|
2007-07-26 07:20:32 +00:00
|
|
|
|
pHistory->CopyFmtAttr( *pNd->GetpSwAttrSet(), nNewPos, *(pNd->GetDoc()) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pHistory->Add( pNd->GetTxtColl(), nNewPos, ND_TEXTNODE );
|
|
|
|
|
|
|
|
|
|
SwTxtNode* pNext = pEnd->nNode.GetNode().GetTxtNode();
|
|
|
|
|
ULONG nTmp = pNext->GetIndex();
|
|
|
|
|
pHistory->CopyAttr( pNext->GetpSwpHints(), nTmp, 0,
|
|
|
|
|
pNext->GetTxt().Len(), TRUE );
|
2006-12-01 14:49:25 +00:00
|
|
|
|
if( pNext->HasSwAttrSet() )
|
2007-07-26 07:20:32 +00:00
|
|
|
|
pHistory->CopyFmtAttr( *pNext->GetpSwAttrSet(), nTmp, *(pNext->GetDoc()) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pHistory->Add( pNext->GetTxtColl(),nTmp, ND_TEXTNODE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !pHistory->Count() )
|
|
|
|
|
delete pHistory, pHistory = 0;
|
|
|
|
|
|
|
|
|
|
xub_StrLen nECnt = bSplitNext ? pNd->GetTxt().Len() : pEnd->nContent.GetIndex();
|
|
|
|
|
sOld = pNd->GetTxt().Copy( nSttCnt, nECnt - nSttCnt );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_UnReplaceData::~_UnReplaceData()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _UnReplaceData::Undo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc* pDoc = &rIter.GetDoc();
|
|
|
|
|
SwPaM& rPam = *rIter.pAktPam;
|
|
|
|
|
rPam.DeleteMark();
|
|
|
|
|
|
|
|
|
|
SwTxtNode* pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode();
|
|
|
|
|
ASSERT( pNd, "Wo ist der TextNode geblieben?" )
|
|
|
|
|
|
|
|
|
|
SwAutoCorrExceptWord* pACEWord = pDoc->GetAutoCorrExceptWord();
|
|
|
|
|
if( pACEWord )
|
|
|
|
|
{
|
|
|
|
|
if( 1 == sIns.Len() && 1 == sOld.Len() )
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, nSttCnt );
|
|
|
|
|
pACEWord->CheckChar( aPos, sOld.GetChar( 0 ) );
|
|
|
|
|
}
|
|
|
|
|
pDoc->SetAutoCorrExceptWord( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwIndex aIdx( pNd, nSttCnt );
|
|
|
|
|
if( nSttNd == nEndNd )
|
|
|
|
|
{
|
|
|
|
|
pNd->Erase( aIdx, sIns.Len() );
|
|
|
|
|
/* if( bSplitNext )
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( *pNd, aIdx );
|
|
|
|
|
pDoc->SplitNode( aPos, FALSE );
|
|
|
|
|
pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode();
|
|
|
|
|
aIdx.Assign( pNd, nSttCnt );
|
|
|
|
|
}
|
|
|
|
|
*/ }
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rPam.GetPoint()->nNode = *pNd;
|
|
|
|
|
rPam.GetPoint()->nContent.Assign( pNd, nSttCnt );
|
|
|
|
|
rPam.SetMark();
|
|
|
|
|
rPam.GetPoint()->nNode = nEndNd - nOffset;
|
|
|
|
|
rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nEndCnt );
|
|
|
|
|
|
|
|
|
|
pDoc->DeleteAndJoin( rPam );
|
|
|
|
|
rPam.DeleteMark();
|
|
|
|
|
pNd = rPam.GetNode()->GetTxtNode();
|
|
|
|
|
ASSERT( pNd, "Wo ist der TextNode geblieben?" );
|
|
|
|
|
aIdx.Assign( pNd, nSttCnt );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bSplitNext )
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( *pNd, aIdx );
|
2006-08-14 15:50:19 +00:00
|
|
|
|
pDoc->SplitNode( aPos, false );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pNd = pDoc->GetNodes()[ nSttNd - nOffset ]->GetTxtNode();
|
|
|
|
|
aIdx.Assign( pNd, nSttCnt );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( sOld.Len() )
|
|
|
|
|
pNd->Insert( sOld, aIdx );
|
|
|
|
|
|
|
|
|
|
if( pHistory )
|
|
|
|
|
{
|
|
|
|
|
if( pNd->GetpSwpHints() )
|
2006-12-01 14:49:25 +00:00
|
|
|
|
pNd->ClearSwpHintsArr( true );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
pHistory->TmpRollback( pDoc, nSetPos, FALSE );
|
|
|
|
|
if( nSetPos ) // es gab Fussnoten/FlyFrames
|
|
|
|
|
{
|
|
|
|
|
// gibts ausser diesen noch andere ?
|
|
|
|
|
if( nSetPos < pHistory->Count() )
|
|
|
|
|
{
|
|
|
|
|
// dann sicher die Attribute anderen Attribute
|
|
|
|
|
SwHistory aHstr;
|
|
|
|
|
aHstr.Move( 0, pHistory, nSetPos );
|
|
|
|
|
pHistory->Rollback( pDoc );
|
|
|
|
|
pHistory->Move( 0, &aHstr );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pHistory->Rollback( pDoc );
|
|
|
|
|
DELETEZ( pHistory );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rPam.GetPoint()->nNode = nSttNd;
|
|
|
|
|
rPam.GetPoint()->nContent = aIdx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _UnReplaceData::Redo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
BOOL bUndo = rDoc.DoesUndo();
|
|
|
|
|
rDoc.DoUndo( FALSE );
|
|
|
|
|
|
|
|
|
|
SwPaM& rPam = *rIter.pAktPam;
|
|
|
|
|
rPam.DeleteMark();
|
|
|
|
|
rPam.GetPoint()->nNode = nSttNd;
|
|
|
|
|
|
|
|
|
|
SwTxtNode* pNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode();
|
|
|
|
|
ASSERT( pNd, "Wo ist der TextNode geblieben?" )
|
|
|
|
|
rPam.GetPoint()->nContent.Assign( pNd, nSttCnt );
|
|
|
|
|
rPam.SetMark();
|
|
|
|
|
if( bSplitNext )
|
|
|
|
|
{
|
|
|
|
|
rPam.GetPoint()->nNode = nSttNd + 1;
|
|
|
|
|
pNd = rPam.GetPoint()->nNode.GetNode().GetTxtNode();
|
|
|
|
|
}
|
|
|
|
|
rPam.GetPoint()->nContent.Assign( pNd, nSelEnd );
|
|
|
|
|
|
|
|
|
|
if( pHistory )
|
|
|
|
|
{
|
|
|
|
|
SwHistory* pSave = pHistory;
|
|
|
|
|
SwHistory aHst;
|
|
|
|
|
pHistory = &aHst;
|
|
|
|
|
DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() );
|
|
|
|
|
nSetPos = pHistory->Count();
|
|
|
|
|
|
|
|
|
|
pHistory = pSave;
|
|
|
|
|
pHistory->Move( 0, &aHst );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pHistory = new SwHistory;
|
|
|
|
|
DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() );
|
|
|
|
|
nSetPos = pHistory->Count();
|
|
|
|
|
if( !nSetPos )
|
|
|
|
|
delete pHistory, pHistory = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rDoc.Replace( rPam, sIns, bRegExp );
|
|
|
|
|
rPam.DeleteMark();
|
|
|
|
|
rDoc.DoUndo( bUndo );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _UnReplaceData::SetEnd( const SwPaM& rPam )
|
|
|
|
|
{
|
|
|
|
|
if( rPam.GetPoint()->nNode != rPam.GetMark()->nNode )
|
|
|
|
|
{
|
|
|
|
|
// es wurden mehrere Absaetze eingefuegt
|
|
|
|
|
const SwPosition* pEnd = rPam.End();
|
|
|
|
|
nEndNd = nOffset + pEnd->nNode.GetIndex();
|
|
|
|
|
nEndCnt = pEnd->nContent.GetIndex();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SwUndoReRead::SwUndoReRead( const SwPaM& rPam, const SwGrfNode& rGrfNd )
|
|
|
|
|
: SwUndo( UNDO_REREAD ), nPos( rPam.GetPoint()->nNode.GetIndex() )
|
|
|
|
|
{
|
|
|
|
|
SaveGraphicData( rGrfNd );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SwUndoReRead::~SwUndoReRead()
|
|
|
|
|
{
|
|
|
|
|
delete pGrf;
|
|
|
|
|
delete pNm;
|
|
|
|
|
delete pFltr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoReRead::SetAndSave( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
SwGrfNode* pGrfNd = rDoc.GetNodes()[ nPos ]->GetGrfNode();
|
|
|
|
|
|
|
|
|
|
if( !pGrfNd )
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
|
|
// die alten Werte zwischen speichern
|
|
|
|
|
Graphic* pOldGrf = pGrf;
|
|
|
|
|
String* pOldNm = pNm;
|
|
|
|
|
String* pOldFltr = pFltr;
|
|
|
|
|
USHORT nOldMirr = nMirr;
|
|
|
|
|
|
|
|
|
|
SaveGraphicData( *pGrfNd );
|
|
|
|
|
if( pOldNm )
|
|
|
|
|
{
|
2000-11-28 19:40:08 +00:00
|
|
|
|
pGrfNd->ReRead( *pOldNm, pFltr ? *pFltr : aEmptyStr, 0, 0, TRUE );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
delete pOldNm;
|
|
|
|
|
delete pOldFltr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-11-28 19:40:08 +00:00
|
|
|
|
pGrfNd->ReRead( aEmptyStr, aEmptyStr, pOldGrf, 0, TRUE );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
delete pOldGrf;
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-27 08:31:41 +00:00
|
|
|
|
if( RES_MIRROR_GRAPH_DONT != nOldMirr )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pGrfNd->SetAttr( SwMirrorGrf() );
|
2000-12-22 09:37:51 +00:00
|
|
|
|
|
|
|
|
|
rIter.pSelFmt = pGrfNd->GetFlyFmt();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoReRead::Undo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SetAndSave( rIter );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoReRead::Redo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SetAndSave( rIter );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd )
|
|
|
|
|
{
|
|
|
|
|
if( rGrfNd.IsGrfLink() )
|
|
|
|
|
{
|
|
|
|
|
pNm = new String;
|
|
|
|
|
pFltr = new String;
|
|
|
|
|
rGrfNd.GetFileFilterNms( pNm, pFltr );
|
|
|
|
|
pGrf = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
((SwGrfNode&)rGrfNd).SwapIn( TRUE );
|
|
|
|
|
pGrf = new Graphic( rGrfNd.GetGrf() );
|
|
|
|
|
pNm = pFltr = 0;
|
|
|
|
|
}
|
|
|
|
|
nMirr = rGrfNd.GetSwAttrSet().GetMirrorGrf().GetValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
SwUndoInsertLabel::SwUndoInsertLabel( const SwLabelType eTyp,
|
2004-06-28 12:45:45 +00:00
|
|
|
|
const String &rTxt,
|
2005-01-25 13:42:30 +00:00
|
|
|
|
const String& rSeparator,
|
2007-11-21 17:19:51 +00:00
|
|
|
|
const String& rNumberSeparator,
|
2004-06-28 12:45:45 +00:00
|
|
|
|
const BOOL bBef,
|
2007-09-27 08:31:41 +00:00
|
|
|
|
const USHORT nInitId,
|
2004-09-20 11:36:15 +00:00
|
|
|
|
const String& rCharacterStyle,
|
2004-06-28 12:45:45 +00:00
|
|
|
|
const BOOL bCpyBorder )
|
|
|
|
|
: SwUndo( UNDO_INSERTLABEL ),
|
|
|
|
|
sText( rTxt ),
|
2005-01-25 13:42:30 +00:00
|
|
|
|
sSeparator( rSeparator ),
|
2007-11-21 17:19:51 +00:00
|
|
|
|
sNumberSeparator( rNumberSeparator ),//#i61007# order of captions
|
2004-09-20 11:36:15 +00:00
|
|
|
|
sCharacterStyle( rCharacterStyle ),
|
2007-09-27 08:31:41 +00:00
|
|
|
|
nFldId( nInitId ),
|
|
|
|
|
eType( eTyp ),
|
2004-06-28 12:45:45 +00:00
|
|
|
|
nLayerId( 0 ),
|
2007-09-27 08:31:41 +00:00
|
|
|
|
bBefore( bBef ),
|
2004-06-28 12:45:45 +00:00
|
|
|
|
bCpyBrd( bCpyBorder )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
bUndoKeep = FALSE;
|
|
|
|
|
OBJECT.pUndoFly = 0;
|
|
|
|
|
OBJECT.pUndoAttr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwUndoInsertLabel::~SwUndoInsertLabel()
|
|
|
|
|
{
|
|
|
|
|
if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
delete OBJECT.pUndoFly;
|
|
|
|
|
delete OBJECT.pUndoAttr;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
delete NODE.pUndoInsNd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoInsertLabel::Undo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
|
|
|
|
|
if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
ASSERT( OBJECT.pUndoAttr && OBJECT.pUndoFly, "Pointer nicht initialisiert" )
|
|
|
|
|
SwFrmFmt* pFmt;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SdrObject *pSdrObj = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( OBJECT.pUndoAttr &&
|
|
|
|
|
0 != (pFmt = (SwFrmFmt*)OBJECT.pUndoAttr->GetFmt( rDoc )) &&
|
|
|
|
|
( LTYPE_DRAW != eType ||
|
|
|
|
|
0 != (pSdrObj = pFmt->FindSdrObject()) ) )
|
|
|
|
|
{
|
|
|
|
|
OBJECT.pUndoAttr->Undo( rIter );
|
|
|
|
|
OBJECT.pUndoFly->Undo( rIter );
|
|
|
|
|
if( LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
pSdrObj->SetLayer( nLayerId );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( NODE.nNode )
|
|
|
|
|
{
|
|
|
|
|
if ( eType == LTYPE_TABLE && bUndoKeep )
|
|
|
|
|
{
|
|
|
|
|
SwTableNode *pNd = rDoc.GetNodes()[
|
|
|
|
|
rDoc.GetNodes()[NODE.nNode-1]->StartOfSectionIndex()]->GetTableNode();
|
|
|
|
|
if ( pNd )
|
|
|
|
|
pNd->GetTable().GetFrmFmt()->ResetAttr( RES_KEEP );
|
|
|
|
|
}
|
|
|
|
|
SwPaM aPam( *rIter.pAktPam->GetPoint() );
|
|
|
|
|
aPam.GetPoint()->nNode = NODE.nNode;
|
|
|
|
|
aPam.SetMark();
|
|
|
|
|
aPam.GetPoint()->nNode = NODE.nNode + 1;
|
|
|
|
|
NODE.pUndoInsNd = new SwUndoDelete( aPam, TRUE );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwUndoInsertLabel::Redo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
|
|
|
|
|
if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
ASSERT( OBJECT.pUndoAttr && OBJECT.pUndoFly, "Pointer nicht initialisiert" )
|
|
|
|
|
SwFrmFmt* pFmt;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
SdrObject *pSdrObj = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
if( OBJECT.pUndoAttr &&
|
|
|
|
|
0 != (pFmt = (SwFrmFmt*)OBJECT.pUndoAttr->GetFmt( rDoc )) &&
|
|
|
|
|
( LTYPE_DRAW != eType ||
|
|
|
|
|
0 != (pSdrObj = pFmt->FindSdrObject()) ) )
|
|
|
|
|
{
|
|
|
|
|
OBJECT.pUndoFly->Redo( rIter );
|
|
|
|
|
OBJECT.pUndoAttr->Redo( rIter );
|
|
|
|
|
if( LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
pSdrObj->SetLayer( nLayerId );
|
|
|
|
|
if( pSdrObj->GetLayer() == rDoc.GetHellId() )
|
|
|
|
|
pSdrObj->SetLayer( rDoc.GetHeavenId() );
|
2003-07-04 12:25:28 +00:00
|
|
|
|
// OD 02.07.2003 #108784#
|
|
|
|
|
else if( pSdrObj->GetLayer() == rDoc.GetInvisibleHellId() )
|
|
|
|
|
pSdrObj->SetLayer( rDoc.GetInvisibleHeavenId() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( NODE.pUndoInsNd )
|
|
|
|
|
{
|
|
|
|
|
if ( eType == LTYPE_TABLE && bUndoKeep )
|
|
|
|
|
{
|
|
|
|
|
SwTableNode *pNd = rDoc.GetNodes()[
|
|
|
|
|
rDoc.GetNodes()[NODE.nNode-1]->StartOfSectionIndex()]->GetTableNode();
|
|
|
|
|
if ( pNd )
|
2007-05-10 15:02:13 +00:00
|
|
|
|
pNd->GetTable().GetFrmFmt()->SetAttr( SvxFmtKeepItem(TRUE, RES_KEEP) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
NODE.pUndoInsNd->Undo( rIter );
|
|
|
|
|
delete NODE.pUndoInsNd, NODE.pUndoInsNd = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoInsertLabel::Repeat( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
const SwPosition& rPos = *rIter.pAktPam->GetPoint();
|
|
|
|
|
|
|
|
|
|
ULONG nIdx = 0;
|
|
|
|
|
|
|
|
|
|
SwCntntNode* pCNd = rPos.nNode.GetNode().GetCntntNode();
|
|
|
|
|
if( pCNd )
|
|
|
|
|
switch( eType )
|
|
|
|
|
{
|
|
|
|
|
case LTYPE_TABLE:
|
|
|
|
|
{
|
|
|
|
|
const SwTableNode* pTNd = pCNd->FindTableNode();
|
|
|
|
|
if( pTNd )
|
|
|
|
|
nIdx = pTNd->GetIndex();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LTYPE_FLY:
|
|
|
|
|
case LTYPE_OBJECT:
|
|
|
|
|
{
|
|
|
|
|
SwFlyFrm* pFly;
|
|
|
|
|
SwCntntFrm *pCnt = pCNd->GetFrm();
|
|
|
|
|
if( pCnt && 0 != ( pFly = pCnt->FindFlyFrm() ) )
|
|
|
|
|
nIdx = pFly->GetFmt()->GetCntnt().GetCntntIdx()->GetIndex();
|
|
|
|
|
}
|
|
|
|
|
break;
|
2007-09-27 08:31:41 +00:00
|
|
|
|
case LTYPE_DRAW:
|
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( nIdx )
|
|
|
|
|
{
|
2007-11-21 17:19:51 +00:00
|
|
|
|
rDoc.InsertLabel( eType, sText, sSeparator, sNumberSeparator, bBefore,
|
|
|
|
|
nFldId, nIdx, sCharacterStyle, bCpyBrd );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-18 13:08:42 +00:00
|
|
|
|
// #111827#
|
|
|
|
|
SwRewriter SwUndoInsertLabel::GetRewriter() const
|
|
|
|
|
{
|
|
|
|
|
SwRewriter aRewriter;
|
|
|
|
|
|
|
|
|
|
String aTmpStr;
|
|
|
|
|
|
|
|
|
|
aTmpStr += String(SW_RES(STR_START_QUOTE));
|
2004-05-25 14:19:41 +00:00
|
|
|
|
aTmpStr += ShortenString(sText, nUndoStringLength,
|
|
|
|
|
String(SW_RES(STR_LDOTS)));
|
2004-05-18 13:08:42 +00:00
|
|
|
|
aTmpStr += String(SW_RES(STR_END_QUOTE));
|
|
|
|
|
|
|
|
|
|
aRewriter.AddRule(UNDO_ARG1, aTmpStr);
|
|
|
|
|
|
|
|
|
|
return aRewriter;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
void SwUndoInsertLabel::SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet,
|
|
|
|
|
SwFrmFmt& rNewFly )
|
|
|
|
|
{
|
|
|
|
|
if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
_UndoFmtAttr aTmp( rOldFly, FALSE );
|
|
|
|
|
rOldFly.SetAttr( rChgSet );
|
|
|
|
|
if( aTmp.pUndo )
|
|
|
|
|
OBJECT.pUndoAttr = aTmp.pUndo;
|
2007-12-12 12:25:29 +00:00
|
|
|
|
OBJECT.pUndoFly = new SwUndoInsLayFmt( &rNewFly,0,0 );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-28 12:45:45 +00:00
|
|
|
|
void SwUndoInsertLabel::SetDrawObj( BYTE nLId )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
if( LTYPE_DRAW == eType )
|
|
|
|
|
{
|
|
|
|
|
nLayerId = nLId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|