2000-09-18 23:08:29 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-10 15:06:48 +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:06:48 +00:00
|
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:06:48 +00:00
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:06:48 +00:00
|
|
|
|
* $RCSfile: undobj1.cxx,v $
|
2008-04-22 14:02:20 +00:00
|
|
|
|
* $Revision: 1.17 $
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:06:48 +00:00
|
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
*
|
2008-04-10 15:06:48 +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:06:48 +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:06:48 +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:51:23 +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>
|
|
|
|
|
#include <svtools/itemiter.hxx>
|
|
|
|
|
#include <fmtflcnt.hxx>
|
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
|
#include <fmtcntnt.hxx>
|
|
|
|
|
#include <txtflcnt.hxx>
|
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
|
#include <flyfrm.hxx>
|
|
|
|
|
#include <undobj.hxx>
|
|
|
|
|
#include <rolbck.hxx> // fuer die Attribut History
|
|
|
|
|
#include <doc.hxx>
|
|
|
|
|
#include <docary.hxx>
|
|
|
|
|
#include <rootfrm.hxx>
|
|
|
|
|
#include <swundo.hxx> // fuer die UndoIds
|
|
|
|
|
#include <pam.hxx>
|
|
|
|
|
#include <ndtxt.hxx>
|
2003-07-04 12:25:17 +00:00
|
|
|
|
// OD 26.06.2003 #108784#
|
|
|
|
|
#include <dcontact.hxx>
|
2004-09-08 14:00:05 +00:00
|
|
|
|
#include <ndole.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
// Inline Methode vom UndoIter
|
|
|
|
|
inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); }
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
|
2007-09-27 08:31:04 +00:00
|
|
|
|
SwUndoFlyBase::SwUndoFlyBase( SwFrmFmt* pFormat, SwUndoId nUndoId )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
: SwUndo( nUndoId ), pFrmFmt( pFormat )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwUndoFlyBase::~SwUndoFlyBase()
|
|
|
|
|
{
|
|
|
|
|
if( bDelFmt ) // loeschen waehrend eines Undo's ??
|
|
|
|
|
delete pFrmFmt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm )
|
|
|
|
|
{
|
|
|
|
|
SwDoc* pDoc = &rUndoIter.GetDoc();
|
|
|
|
|
|
|
|
|
|
// ins Array wieder eintragen
|
|
|
|
|
SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts();
|
|
|
|
|
rFlyFmts.Insert( pFrmFmt, rFlyFmts.Count() );
|
2003-07-04 12:25:17 +00:00
|
|
|
|
|
|
|
|
|
// OD 26.06.2003 #108784# - insert 'master' drawing object into drawing page
|
|
|
|
|
if ( RES_DRAWFRMFMT == pFrmFmt->Which() )
|
|
|
|
|
{
|
|
|
|
|
SwDrawContact* pDrawContact =
|
|
|
|
|
static_cast<SwDrawContact*>(pFrmFmt->FindContactObj());
|
|
|
|
|
if ( pDrawContact )
|
|
|
|
|
{
|
|
|
|
|
pDrawContact->InsertMasterIntoDrawPage();
|
2005-02-22 07:21:31 +00:00
|
|
|
|
// --> OD 2005-01-31 #i40845# - follow-up of #i35635#
|
|
|
|
|
// move object to visible layer
|
|
|
|
|
pDrawContact->MoveObjToVisibleLayer( pDrawContact->GetMaster() );
|
|
|
|
|
// <--
|
2003-07-04 12:25:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwFmtAnchor aAnchor( (RndStdIds)nRndId );
|
|
|
|
|
|
|
|
|
|
if( FLY_PAGE == nRndId )
|
|
|
|
|
aAnchor.SetPageNum( (USHORT)nNdPgPos );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SwPosition aNewPos( *rUndoIter.pAktPam->GetPoint() );
|
|
|
|
|
aNewPos.nNode = nNdPgPos;
|
|
|
|
|
if( FLY_IN_CNTNT == nRndId || FLY_AUTO_CNTNT == nRndId )
|
|
|
|
|
aNewPos.nContent.Assign( aNewPos.nNode.GetNode().GetCntntNode(),
|
|
|
|
|
nCntPos );
|
|
|
|
|
aAnchor.SetAnchor( &aNewPos );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pFrmFmt->SetAttr( aAnchor ); // Anker neu setzen
|
|
|
|
|
|
|
|
|
|
if( RES_DRAWFRMFMT != pFrmFmt->Which() )
|
|
|
|
|
{
|
|
|
|
|
// Content holen und -Attribut neu setzen
|
|
|
|
|
SwNodeIndex aIdx( pDoc->GetNodes() );
|
|
|
|
|
RestoreSection( pDoc, &aIdx, SwFlyStartNode );
|
|
|
|
|
pFrmFmt->SetAttr( SwFmtCntnt( aIdx.GetNode().GetStartNode() ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//JP 18.12.98: Bug 60505 - InCntntAttribut erst setzen, wenn der Inhalt
|
|
|
|
|
// vorhanden ist! Sonst wuerde das Layout den Fly vorher
|
|
|
|
|
// formatieren, aber keine Inhalt finden; so geschene bei
|
|
|
|
|
// Grafiken aus dem Internet
|
|
|
|
|
if( FLY_IN_CNTNT == nRndId )
|
|
|
|
|
{
|
|
|
|
|
// es muss mindestens das Attribut im TextNode stehen
|
|
|
|
|
SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode();
|
|
|
|
|
ASSERT( pCNd->IsTxtNode(), "Kein Textnode an dieser Position" );
|
2006-12-01 14:48:56 +00:00
|
|
|
|
((SwTxtNode*)pCNd)->InsertItem( SwFmtFlyCnt(
|
2000-09-18 23:08:29 +00:00
|
|
|
|
(SwFlyFrmFmt*)pFrmFmt ), nCntPos, nCntPos );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pFrmFmt->MakeFrms();
|
|
|
|
|
|
|
|
|
|
if( bShowSelFrm )
|
|
|
|
|
rUndoIter.pSelFmt = pFrmFmt;
|
|
|
|
|
|
|
|
|
|
if( GetHistory() )
|
|
|
|
|
GetHistory()->Rollback( pDoc );
|
|
|
|
|
|
|
|
|
|
switch( nRndId )
|
|
|
|
|
{
|
|
|
|
|
case FLY_IN_CNTNT:
|
|
|
|
|
case FLY_AUTO_CNTNT:
|
|
|
|
|
{
|
|
|
|
|
const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
|
|
|
|
|
nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
|
|
|
|
|
nCntPos = rAnchor.GetCntntAnchor()->nContent.GetIndex();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FLY_AT_CNTNT:
|
|
|
|
|
case FLY_AT_FLY:
|
|
|
|
|
{
|
|
|
|
|
const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
|
|
|
|
|
nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FLY_PAGE:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
bDelFmt = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoFlyBase::DelFly( SwDoc* pDoc )
|
|
|
|
|
{
|
|
|
|
|
bDelFmt = TRUE; // im DTOR das Format loeschen
|
|
|
|
|
pFrmFmt->DelFrms(); // Frms vernichten.
|
|
|
|
|
|
|
|
|
|
// alle Uno-Objecte sollten sich jetzt abmelden
|
|
|
|
|
{
|
|
|
|
|
SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, pFrmFmt );
|
|
|
|
|
pFrmFmt->Modify( &aMsgHint, &aMsgHint );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( RES_DRAWFRMFMT != pFrmFmt->Which() )
|
|
|
|
|
{
|
|
|
|
|
// gibt es ueberhaupt Inhalt, dann sicher diesen
|
|
|
|
|
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
|
|
|
|
|
ASSERT( rCntnt.GetCntntIdx(), "Fly ohne Inhalt" );
|
|
|
|
|
|
|
|
|
|
SaveSection( pDoc, *rCntnt.GetCntntIdx() );
|
|
|
|
|
((SwFmtCntnt&)rCntnt).SetNewCntntIdx( (const SwNodeIndex*)0 );
|
|
|
|
|
}
|
2003-07-04 12:25:17 +00:00
|
|
|
|
// OD 02.07.2003 #108784# - remove 'master' drawing object from drawing page
|
|
|
|
|
else if ( RES_DRAWFRMFMT == pFrmFmt->Which() )
|
|
|
|
|
{
|
|
|
|
|
SwDrawContact* pDrawContact =
|
|
|
|
|
static_cast<SwDrawContact*>(pFrmFmt->FindContactObj());
|
|
|
|
|
if ( pDrawContact )
|
|
|
|
|
{
|
|
|
|
|
pDrawContact->RemoveMasterFromDrawPage();
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
|
|
|
|
|
const SwPosition* pPos = rAnchor.GetCntntAnchor();
|
|
|
|
|
// die Positionen im Nodes-Array haben sich verschoben
|
2007-09-27 08:31:04 +00:00
|
|
|
|
if( FLY_IN_CNTNT == ( nRndId = static_cast<USHORT>(rAnchor.GetAnchorId()) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
nNdPgPos = pPos->nNode.GetIndex();
|
|
|
|
|
nCntPos = pPos->nContent.GetIndex();
|
|
|
|
|
SwTxtNode *pTxtNd = pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode();
|
|
|
|
|
ASSERT( pTxtNd, "Kein Textnode gefunden" );
|
|
|
|
|
SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntPos );
|
|
|
|
|
// Attribut steht noch im TextNode, loeschen
|
|
|
|
|
if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFrmFmt )
|
|
|
|
|
{
|
|
|
|
|
// Pointer auf 0, nicht loeschen
|
|
|
|
|
((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt();
|
|
|
|
|
SwIndex aIdx( pPos->nContent );
|
|
|
|
|
pTxtNd->Erase( aIdx, 1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( FLY_AUTO_CNTNT == nRndId )
|
|
|
|
|
{
|
|
|
|
|
nNdPgPos = pPos->nNode.GetIndex();
|
|
|
|
|
nCntPos = pPos->nContent.GetIndex();
|
|
|
|
|
}
|
|
|
|
|
else if( FLY_AT_CNTNT == nRndId || FLY_AT_FLY == nRndId )
|
|
|
|
|
nNdPgPos = pPos->nNode.GetIndex();
|
|
|
|
|
else
|
|
|
|
|
nNdPgPos = rAnchor.GetPageNum();
|
|
|
|
|
|
|
|
|
|
pFrmFmt->ResetAttr( RES_ANCHOR ); // Anchor loeschen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// aus dem Array austragen
|
|
|
|
|
SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts();
|
|
|
|
|
rFlyFmts.Remove( rFlyFmts.GetPos( pFrmFmt ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----- Undo-InsertFly ------
|
|
|
|
|
|
2007-12-12 12:25:16 +00:00
|
|
|
|
SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen nCntIdx )
|
|
|
|
|
: SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ?
|
|
|
|
|
UNDO_INSDRAWFMT : UNDO_INSLAYFMT ),
|
|
|
|
|
mnCrsrSaveIndexPara( nNodeIdx ), mnCrsrSaveIndexPos( nCntIdx )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
|
2007-09-27 08:31:04 +00:00
|
|
|
|
nRndId = static_cast<USHORT>(rAnchor.GetAnchorId());
|
2000-09-18 23:08:29 +00:00
|
|
|
|
bDelFmt = FALSE;
|
|
|
|
|
switch( nRndId )
|
|
|
|
|
{
|
|
|
|
|
case FLY_PAGE:
|
|
|
|
|
nNdPgPos = rAnchor.GetPageNum();
|
|
|
|
|
break;
|
|
|
|
|
case FLY_AT_CNTNT:
|
|
|
|
|
case FLY_AT_FLY:
|
|
|
|
|
nNdPgPos = rAnchor.GetCntntAnchor()->nNode.GetIndex();
|
|
|
|
|
break;
|
|
|
|
|
case FLY_IN_CNTNT:
|
|
|
|
|
case FLY_AUTO_CNTNT:
|
|
|
|
|
{
|
|
|
|
|
const SwPosition* pPos = rAnchor.GetCntntAnchor();
|
|
|
|
|
nCntPos = pPos->nContent.GetIndex();
|
|
|
|
|
nNdPgPos = pPos->nNode.GetIndex();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ASSERT( FALSE, "Was denn fuer ein FlyFrame?" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-05 13:41:16 +00:00
|
|
|
|
SwUndoInsLayFmt::~SwUndoInsLayFmt()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
void SwUndoInsLayFmt::Undo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
|
|
|
|
|
if( rCntnt.GetCntntIdx() ) // kein Inhalt
|
2007-12-12 12:25:16 +00:00
|
|
|
|
{
|
|
|
|
|
bool bRemoveIdx = true;
|
|
|
|
|
if( mnCrsrSaveIndexPara > 0 )
|
|
|
|
|
{
|
|
|
|
|
SwTxtNode *pNode = rUndoIter.GetDoc().GetNodes()[mnCrsrSaveIndexPara]->GetTxtNode();
|
|
|
|
|
if( pNode )
|
|
|
|
|
{
|
|
|
|
|
SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), rCntnt.GetCntntIdx()->GetIndex() );
|
|
|
|
|
SwNodeIndex aEndIdx( rUndoIter.GetDoc().GetNodes(), aIdx.GetNode().EndOfSectionIndex() );
|
|
|
|
|
SwIndex aIndex( pNode, mnCrsrSaveIndexPos );
|
|
|
|
|
SwPosition aPos( *pNode, aIndex );
|
|
|
|
|
rUndoIter.GetDoc().CorrAbs( aIdx, aEndIdx, aPos, TRUE );
|
|
|
|
|
bRemoveIdx = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( bRemoveIdx )
|
|
|
|
|
RemoveIdxFromSection( rUndoIter.GetDoc(),
|
2000-09-18 23:08:29 +00:00
|
|
|
|
rCntnt.GetCntntIdx()->GetIndex() );
|
2007-12-12 12:25:16 +00:00
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
DelFly( &rUndoIter.GetDoc() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoInsLayFmt::Redo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
rUndoIter.pLastUndoObj = 0;
|
|
|
|
|
InsFly( rUndoIter );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
if( UNDO_INSLAYFMT == rUndoIter.GetLastUndoId() &&
|
|
|
|
|
pFrmFmt == ((SwUndoInsLayFmt*)rUndoIter.pLastUndoObj)->pFrmFmt )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
SwDoc* pDoc = &rUndoIter.GetDoc();
|
|
|
|
|
// erfrage und setze den Anker neu
|
|
|
|
|
SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() );
|
|
|
|
|
if( FLY_AT_CNTNT == aAnchor.GetAnchorId() ||
|
|
|
|
|
FLY_AUTO_CNTNT == aAnchor.GetAnchorId() ||
|
|
|
|
|
FLY_IN_CNTNT == aAnchor.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( *rUndoIter.pAktPam->GetPoint() );
|
|
|
|
|
if( FLY_AT_CNTNT == aAnchor.GetAnchorId() )
|
|
|
|
|
aPos.nContent.Assign( 0, 0 );
|
|
|
|
|
aAnchor.SetAnchor( &aPos );
|
|
|
|
|
}
|
|
|
|
|
else if( FLY_AT_FLY == aAnchor.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
const SwStartNode* pSttNd = rUndoIter.pAktPam->GetNode()->FindFlyStartNode();
|
|
|
|
|
if( pSttNd )
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( *pSttNd );
|
|
|
|
|
aAnchor.SetAnchor( &aPos );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rUndoIter.pLastUndoObj = this;
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( FLY_PAGE == aAnchor.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
aAnchor.SetPageNum( pDoc->GetRootFrm()->GetCurrPage(
|
|
|
|
|
rUndoIter.pAktPam ));
|
|
|
|
|
}
|
2008-04-22 14:02:20 +00:00
|
|
|
|
else {
|
2000-09-18 23:08:29 +00:00
|
|
|
|
ASSERT( FALSE, "was fuer ein Anker ist es denn nun?" );
|
2008-04-22 14:02:20 +00:00
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
2006-08-14 15:49:43 +00:00
|
|
|
|
SwFrmFmt* pFlyFmt = pDoc->CopyLayoutFmt( *pFrmFmt, aAnchor, true, true );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
rUndoIter.pSelFmt = pFlyFmt;
|
|
|
|
|
|
|
|
|
|
rUndoIter.pLastUndoObj = this;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-18 13:08:06 +00:00
|
|
|
|
// #111827#
|
|
|
|
|
String SwUndoInsLayFmt::GetComment() const
|
|
|
|
|
{
|
|
|
|
|
String aResult;
|
|
|
|
|
|
2004-09-08 14:00:05 +00:00
|
|
|
|
if (! pComment)
|
2004-05-18 13:08:06 +00:00
|
|
|
|
{
|
2004-09-08 14:00:05 +00:00
|
|
|
|
/*
|
|
|
|
|
If frame format is present and has an SdrObject use the undo
|
|
|
|
|
comment of the SdrObject. Otherwise use the default comment.
|
|
|
|
|
*/
|
2004-05-18 13:08:06 +00:00
|
|
|
|
|
2004-09-08 14:00:05 +00:00
|
|
|
|
bool bDone = false;
|
|
|
|
|
if (pFrmFmt)
|
2004-05-18 13:08:06 +00:00
|
|
|
|
{
|
2004-09-08 14:00:05 +00:00
|
|
|
|
const SdrObject * pSdrObj = pFrmFmt->FindSdrObject();
|
2004-11-17 13:22:22 +00:00
|
|
|
|
if ( pSdrObj )
|
2004-07-05 13:41:16 +00:00
|
|
|
|
{
|
2004-11-17 13:22:22 +00:00
|
|
|
|
aResult = SdrUndoNewObj::GetComment( *pSdrObj );
|
2004-07-05 13:41:16 +00:00
|
|
|
|
bDone = true;
|
|
|
|
|
}
|
2004-05-18 13:08:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-09-08 14:00:05 +00:00
|
|
|
|
if (! bDone)
|
|
|
|
|
aResult = SwUndo::GetComment();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
aResult = *pComment;
|
2004-05-18 13:08:06 +00:00
|
|
|
|
|
|
|
|
|
return aResult;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
// ----- Undo-DeleteFly ------
|
|
|
|
|
|
|
|
|
|
SwUndoDelLayFmt::SwUndoDelLayFmt( SwFrmFmt* pFormat )
|
|
|
|
|
: SwUndoFlyBase( pFormat, UNDO_DELLAYFMT ), bShowSelFrm( TRUE )
|
|
|
|
|
{
|
|
|
|
|
SwDoc* pDoc = pFormat->GetDoc();
|
|
|
|
|
DelFly( pDoc );
|
|
|
|
|
|
|
|
|
|
SwNodeIndex* pIdx = GetMvSttIdx();
|
|
|
|
|
SwNode* pNd;
|
|
|
|
|
if( 1 == GetMvNodeCnt() && pIdx &&
|
|
|
|
|
( pNd = (*pDoc->GetUndoNds())[ *pIdx ] )->IsNoTxtNode() )
|
|
|
|
|
{
|
|
|
|
|
// dann setze eine andere Undo-ID; Grafik oder OLE
|
|
|
|
|
if( pNd->IsGrfNode() )
|
|
|
|
|
SetId( UNDO_DELGRF );
|
|
|
|
|
else if( pNd->IsOLENode() )
|
2004-09-08 14:00:05 +00:00
|
|
|
|
{
|
|
|
|
|
SetId( UNDO_DELETE );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwRewriter SwUndoDelLayFmt::GetRewriter() const
|
|
|
|
|
{
|
|
|
|
|
SwRewriter aRewriter;
|
|
|
|
|
|
|
|
|
|
SwDoc * pDoc = pFrmFmt->GetDoc();
|
|
|
|
|
|
|
|
|
|
if (pDoc)
|
|
|
|
|
{
|
|
|
|
|
SwNodeIndex* pIdx = GetMvSttIdx();
|
|
|
|
|
if( 1 == GetMvNodeCnt() && pIdx)
|
|
|
|
|
{
|
|
|
|
|
SwNode * pNd = (*pDoc->GetUndoNds())[ *pIdx ];
|
|
|
|
|
|
|
|
|
|
if ( pNd->IsNoTxtNode() && pNd->IsOLENode())
|
|
|
|
|
{
|
|
|
|
|
SwOLENode * pOLENd = pNd->GetOLENode();
|
|
|
|
|
|
|
|
|
|
aRewriter.AddRule(UNDO_ARG1, pOLENd->GetDescription());
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
2004-09-08 14:00:05 +00:00
|
|
|
|
|
|
|
|
|
return aRewriter;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoDelLayFmt::Undo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
InsFly( rUndoIter, bShowSelFrm );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoDelLayFmt::Redo( SwUndoIter& rUndoIter )
|
|
|
|
|
{
|
|
|
|
|
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
|
|
|
|
|
if( rCntnt.GetCntntIdx() ) // kein Inhalt
|
|
|
|
|
RemoveIdxFromSection( rUndoIter.GetDoc(),
|
|
|
|
|
rCntnt.GetCntntIdx()->GetIndex() );
|
|
|
|
|
|
|
|
|
|
DelFly( &rUndoIter.GetDoc() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoDelLayFmt::Redo()
|
|
|
|
|
{
|
|
|
|
|
const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
|
|
|
|
|
if( rCntnt.GetCntntIdx() ) // kein Inhalt
|
|
|
|
|
RemoveIdxFromSection( *pFrmFmt->GetDoc(),
|
|
|
|
|
rCntnt.GetCntntIdx()->GetIndex() );
|
|
|
|
|
|
|
|
|
|
DelFly( pFrmFmt->GetDoc() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
SwUndoSetFlyFmt::SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt )
|
|
|
|
|
: SwUndo( UNDO_SETFLYFRMFMT ), SwClient( &rFlyFmt ), pFrmFmt( &rFlyFmt ),
|
2007-09-27 08:31:04 +00:00
|
|
|
|
pOldFmt( (SwFrmFmt*)rFlyFmt.DerivedFrom() ), pNewFmt( &rNewFrmFmt ),
|
2000-09-18 23:08:29 +00:00
|
|
|
|
pItemSet( new SfxItemSet( *rFlyFmt.GetAttrSet().GetPool(),
|
|
|
|
|
rFlyFmt.GetAttrSet().GetRanges() )),
|
2007-09-27 08:31:04 +00:00
|
|
|
|
nOldNode( 0 ), nNewNode( 0 ),
|
|
|
|
|
nOldCntnt( 0 ), nNewCntnt( 0 ),
|
|
|
|
|
nOldAnchorTyp( 0 ), nNewAnchorTyp( 0 ), bAnchorChgd( FALSE )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-08 14:00:05 +00:00
|
|
|
|
SwRewriter SwUndoSetFlyFmt::GetRewriter() const
|
|
|
|
|
{
|
|
|
|
|
SwRewriter aRewriter;
|
|
|
|
|
|
|
|
|
|
if (pNewFmt)
|
|
|
|
|
aRewriter.AddRule(UNDO_ARG1, pNewFmt->GetName());
|
|
|
|
|
|
|
|
|
|
return aRewriter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwUndoSetFlyFmt::~SwUndoSetFlyFmt()
|
|
|
|
|
{
|
|
|
|
|
delete pItemSet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor,
|
|
|
|
|
ULONG nNode, xub_StrLen nCntnt )
|
|
|
|
|
{
|
|
|
|
|
RndStdIds nAnchorTyp = rAnchor.GetAnchorId();
|
|
|
|
|
if( FLY_PAGE != nAnchorTyp )
|
|
|
|
|
{
|
|
|
|
|
SwNode* pNd = pFrmFmt->GetDoc()->GetNodes()[ nNode ];
|
|
|
|
|
|
|
|
|
|
if( FLY_AT_FLY == nAnchorTyp
|
|
|
|
|
? ( !pNd->IsStartNode() || SwFlyStartNode !=
|
|
|
|
|
((SwStartNode*)pNd)->GetStartNodeType() )
|
|
|
|
|
: !pNd->IsTxtNode() )
|
|
|
|
|
pNd = 0; // ungueltige Position
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SwPosition aPos( *pNd );
|
|
|
|
|
if( FLY_IN_CNTNT == nAnchorTyp ||
|
|
|
|
|
FLY_AUTO_CNTNT == nAnchorTyp )
|
|
|
|
|
{
|
|
|
|
|
if( nCntnt > ((SwTxtNode*)pNd)->GetTxt().Len() )
|
|
|
|
|
pNd = 0; // ungueltige Position
|
|
|
|
|
else
|
|
|
|
|
aPos.nContent.Assign( (SwTxtNode*)pNd, nCntnt );
|
|
|
|
|
}
|
|
|
|
|
if( pNd )
|
|
|
|
|
rAnchor.SetAnchor( &aPos );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( !pNd )
|
|
|
|
|
{
|
|
|
|
|
// ungueltige Position - setze auf 1. Seite
|
|
|
|
|
rAnchor.SetType( FLY_PAGE );
|
|
|
|
|
rAnchor.SetPageNum( 1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
rAnchor.SetPageNum( nCntnt );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
|
|
|
|
|
// ist das neue Format noch vorhanden ??
|
|
|
|
|
if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pOldFmt ) )
|
|
|
|
|
{
|
|
|
|
|
if( bAnchorChgd )
|
|
|
|
|
pFrmFmt->DelFrms();
|
|
|
|
|
|
|
|
|
|
if( pFrmFmt->DerivedFrom() != pOldFmt )
|
|
|
|
|
pFrmFmt->SetDerivedFrom( pOldFmt );
|
|
|
|
|
|
|
|
|
|
SfxItemIter aIter( *pItemSet );
|
|
|
|
|
const SfxPoolItem* pItem = aIter.GetCurItem();
|
|
|
|
|
while( pItem )
|
|
|
|
|
{
|
|
|
|
|
if( IsInvalidItem( pItem ))
|
|
|
|
|
pFrmFmt->ResetAttr( pItemSet->GetWhichByPos(
|
|
|
|
|
aIter.GetCurPos() ));
|
|
|
|
|
else
|
|
|
|
|
pFrmFmt->SetAttr( *pItem );
|
|
|
|
|
|
|
|
|
|
if( aIter.IsAtEnd() )
|
|
|
|
|
break;
|
|
|
|
|
pItem = aIter.NextItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( bAnchorChgd )
|
|
|
|
|
{
|
|
|
|
|
const SwFmtAnchor& rOldAnch = pFrmFmt->GetAnchor();
|
|
|
|
|
if( FLY_IN_CNTNT == rOldAnch.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
// Bei InCntnt's wird es spannend: Das TxtAttribut muss
|
|
|
|
|
// vernichtet werden. Leider reisst dies neben den Frms
|
|
|
|
|
// auch noch das Format mit in sein Grab. Um dass zu
|
|
|
|
|
// unterbinden loesen wir vorher die Verbindung zwischen
|
|
|
|
|
// Attribut und Format.
|
|
|
|
|
const SwPosition *pPos = rOldAnch.GetCntntAnchor();
|
|
|
|
|
SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
|
|
|
|
|
ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." );
|
|
|
|
|
const xub_StrLen nIdx = pPos->nContent.GetIndex();
|
|
|
|
|
SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT );
|
|
|
|
|
#ifndef PRODUCT
|
|
|
|
|
ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT,
|
|
|
|
|
"Missing FlyInCnt-Hint." );
|
|
|
|
|
ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt,
|
|
|
|
|
"Wrong TxtFlyCnt-Hint." );
|
|
|
|
|
#endif
|
|
|
|
|
((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt();
|
|
|
|
|
|
|
|
|
|
// Die Verbindung ist geloest, jetzt muss noch das Attribut
|
|
|
|
|
// vernichtet werden.
|
|
|
|
|
pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Anker umsetzen
|
|
|
|
|
SwFmtAnchor aNewAnchor( (RndStdIds) nOldAnchorTyp );
|
|
|
|
|
GetAnchor( aNewAnchor, nOldNode, nOldCntnt );
|
|
|
|
|
pFrmFmt->SetAttr( aNewAnchor );
|
|
|
|
|
|
|
|
|
|
if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() )
|
|
|
|
|
{
|
|
|
|
|
SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor();
|
2006-12-01 14:48:56 +00:00
|
|
|
|
pPos->nNode.GetNode().GetTxtNode()->InsertItem(
|
2000-09-18 23:08:29 +00:00
|
|
|
|
SwFmtFlyCnt( (SwFlyFrmFmt*)pFrmFmt ), nOldCntnt, 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pFrmFmt->MakeFrms();
|
|
|
|
|
}
|
|
|
|
|
rIter.pSelFmt = pFrmFmt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoSetFlyFmt::Redo( SwUndoIter& rIter )
|
|
|
|
|
{
|
|
|
|
|
SwDoc& rDoc = rIter.GetDoc();
|
|
|
|
|
|
|
|
|
|
// ist das neue Format noch vorhanden ??
|
|
|
|
|
if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pNewFmt ) )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if( bAnchorChgd )
|
|
|
|
|
{
|
|
|
|
|
SwFmtAnchor aNewAnchor( (RndStdIds) nNewAnchorTyp );
|
|
|
|
|
GetAnchor( aNewAnchor, nNewNode, nNewCntnt );
|
|
|
|
|
SfxItemSet aSet( rDoc.GetAttrPool(), aFrmFmtSetRange );
|
|
|
|
|
aSet.Put( aNewAnchor );
|
|
|
|
|
rDoc.SetFrmFmtToFly( *pFrmFmt, *pNewFmt, &aSet );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
rDoc.SetFrmFmtToFly( *pFrmFmt, *pNewFmt, 0 );
|
|
|
|
|
|
|
|
|
|
rIter.pSelFmt = pFrmFmt;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoSetFlyFmt::PutAttr( USHORT nWhich, const SfxPoolItem* pItem )
|
|
|
|
|
{
|
|
|
|
|
if( pItem && pItem != GetDfltAttr( nWhich ) )
|
|
|
|
|
{
|
|
|
|
|
// Sonderbehandlung fuer den Anchor
|
|
|
|
|
if( RES_ANCHOR == nWhich )
|
|
|
|
|
{
|
|
|
|
|
// nur den 1. Ankerwechsel vermerken
|
|
|
|
|
ASSERT( !bAnchorChgd, "mehrfacher Ankerwechsel nicht erlaubt!" );
|
|
|
|
|
|
|
|
|
|
bAnchorChgd = TRUE;
|
|
|
|
|
|
|
|
|
|
const SwFmtAnchor* pAnchor = (SwFmtAnchor*)pItem;
|
2007-09-27 08:31:04 +00:00
|
|
|
|
switch( nOldAnchorTyp = static_cast<USHORT>(pAnchor->GetAnchorId()) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
case FLY_IN_CNTNT:
|
|
|
|
|
case FLY_AUTO_CNTNT:
|
|
|
|
|
nOldCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex();
|
|
|
|
|
case FLY_AT_CNTNT:
|
|
|
|
|
case FLY_AT_FLY:
|
|
|
|
|
nOldNode = pAnchor->GetCntntAnchor()->nNode.GetIndex();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
nOldCntnt = pAnchor->GetPageNum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pAnchor = (SwFmtAnchor*)&pFrmFmt->GetAnchor();
|
2007-09-27 08:31:04 +00:00
|
|
|
|
switch( nNewAnchorTyp = static_cast<USHORT>(pAnchor->GetAnchorId()) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|
{
|
|
|
|
|
case FLY_IN_CNTNT:
|
|
|
|
|
case FLY_AUTO_CNTNT:
|
|
|
|
|
nNewCntnt = pAnchor->GetCntntAnchor()->nContent.GetIndex();
|
|
|
|
|
case FLY_AT_CNTNT:
|
|
|
|
|
case FLY_AT_FLY:
|
|
|
|
|
nNewNode = pAnchor->GetCntntAnchor()->nNode.GetIndex();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
nNewCntnt = pAnchor->GetPageNum();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pItemSet->Put( *pItem );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pItemSet->InvalidateItem( nWhich );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SwUndoSetFlyFmt::Modify( SfxPoolItem* pOld, SfxPoolItem* )
|
|
|
|
|
{
|
|
|
|
|
if( pOld )
|
|
|
|
|
{
|
|
|
|
|
USHORT nWhich = pOld->Which();
|
|
|
|
|
|
|
|
|
|
if( nWhich < POOLATTR_END )
|
|
|
|
|
PutAttr( nWhich, pOld );
|
|
|
|
|
else if( RES_ATTRSET_CHG == nWhich )
|
|
|
|
|
{
|
|
|
|
|
SfxItemIter aIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
|
|
|
|
|
const SfxPoolItem* pItem = aIter.GetCurItem();
|
|
|
|
|
while( pItem )
|
|
|
|
|
{
|
|
|
|
|
PutAttr( pItem->Which(), pItem );
|
|
|
|
|
if( aIter.IsAtEnd() )
|
|
|
|
|
break;
|
|
|
|
|
pItem = aIter.NextItem();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|