2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:33:41 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:33:41 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:33:41 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:33:41 +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:33:41 +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:33:41 +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:01:37 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
#include <switerator.hxx>
|
|
|
|
#include <calbck.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <node.hxx>
|
|
|
|
#include <ndindex.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <ftnfrm.hxx>
|
|
|
|
#include <sectfrm.hxx>
|
|
|
|
#include "frmfmt.hxx"
|
|
|
|
#include "cntfrm.hxx"
|
|
|
|
#include "tabfrm.hxx"
|
|
|
|
#include "frmtool.hxx"
|
|
|
|
#include "section.hxx"
|
|
|
|
#include "node2lay.hxx"
|
|
|
|
|
2011-01-17 21:50:08 +01:00
|
|
|
/* --------------------------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
* Die SwNode2LayImpl-Klasse erledigt die eigentliche Arbeit,
|
|
|
|
* die SwNode2Layout-Klasse ist nur die der Oefffentlichkeit bekannte Schnittstelle
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
class SwNode2LayImpl
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwFrm,SwModify>* pIter;
|
|
|
|
SwModify* pMod;
|
2012-06-22 13:40:02 +02:00
|
|
|
std::vector<SwFrm*>* pUpperFrms;// Zum Einsammeln der Upper
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nIndex; // Der Index des einzufuegenden Nodes
|
|
|
|
sal_Bool bMaster : 1; // sal_True => nur Master , sal_False => nur Frames ohne Follow
|
|
|
|
sal_Bool bInit : 1; // Ist am SwClient bereits ein First()-Aufruf erfolgt?
|
2000-09-18 23:08:29 +00:00
|
|
|
public:
|
2011-01-17 15:06:54 +01:00
|
|
|
SwNode2LayImpl( const SwNode& rNode, sal_uLong nIdx, sal_Bool bSearch );
|
2000-09-18 23:08:29 +00:00
|
|
|
~SwNode2LayImpl() { delete pIter; delete pUpperFrms; }
|
|
|
|
SwFrm* NextFrm(); // liefert den naechsten "sinnvollen" Frame
|
|
|
|
SwLayoutFrm* UpperFrm( SwFrm* &rpFrm, const SwNode &rNode );
|
|
|
|
void SaveUpperFrms(); // Speichert (und lockt ggf.) die pUpper
|
|
|
|
// Fuegt unter jeden pUpper des Arrays einen Frame ein.
|
2011-01-17 15:06:54 +01:00
|
|
|
void RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong nEnd );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwFrm* GetFrm( const Point* pDocPos = 0,
|
|
|
|
const SwPosition *pPos = 0,
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bCalcFrm = sal_True ) const;
|
2000-09-18 23:08:29 +00:00
|
|
|
};
|
|
|
|
|
2011-01-17 21:50:08 +01:00
|
|
|
/* --------------------------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
* Hauptaufgabe des Ctor: Das richtige SwModify zu ermitteln,
|
|
|
|
* ueber das iteriert wird.
|
2011-01-17 15:06:54 +01:00
|
|
|
* Uebergibt man bSearch == sal_True, so wird der naechste Cntnt- oder TableNode
|
2000-09-18 23:08:29 +00:00
|
|
|
* gesucht, der Frames besitzt ( zum Einsammeln der pUpper ), ansonsten wird
|
|
|
|
* erwartet, das rNode bereits auf einem solchen Cntnt- oder TableNode sitzt,
|
|
|
|
* vor oder hinter den eingefuegt werden soll.
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
SwNode* GoNextWithFrm(const SwNodes& rNodes, SwNodeIndex *pIdx)
|
|
|
|
{
|
|
|
|
if( pIdx->GetIndex() >= rNodes.Count() - 1 )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SwNodeIndex aTmp(*pIdx, +1);
|
|
|
|
SwNode* pNd = 0;
|
|
|
|
while( aTmp < rNodes.Count()-1 )
|
|
|
|
{
|
|
|
|
pNd = &aTmp.GetNode();
|
|
|
|
bool bFound = false;
|
|
|
|
if ( pNd->IsCntntNode() )
|
|
|
|
bFound = ( SwIterator<SwFrm,SwCntntNode>::FirstElement(*(SwCntntNode*)pNd) != 0);
|
|
|
|
else if ( pNd->IsTableNode() )
|
|
|
|
bFound = ( SwIterator<SwFrm,SwFmt>::FirstElement(*((SwTableNode*)pNd)->GetTable().GetFrmFmt()) != 0 );
|
|
|
|
else if( pNd->IsEndNode() && !pNd->StartOfSectionNode()->IsSectionNode() )
|
|
|
|
{
|
|
|
|
pNd = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( bFound )
|
|
|
|
break;
|
|
|
|
aTmp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aTmp == rNodes.Count()-1 )
|
|
|
|
pNd = 0;
|
|
|
|
else if( pNd )
|
|
|
|
(*pIdx) = aTmp;
|
|
|
|
return pNd;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwNode* GoPreviousWithFrm(SwNodeIndex *pIdx)
|
|
|
|
{
|
|
|
|
if( !pIdx->GetIndex() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SwNodeIndex aTmp( *pIdx, -1 );
|
|
|
|
SwNode* pNd(0);
|
|
|
|
while( aTmp.GetIndex() )
|
|
|
|
{
|
|
|
|
pNd = &aTmp.GetNode();
|
|
|
|
bool bFound = false;
|
|
|
|
if ( pNd->IsCntntNode() )
|
|
|
|
bFound = ( SwIterator<SwFrm,SwCntntNode>::FirstElement(*(SwCntntNode*)pNd) != 0);
|
|
|
|
else if ( pNd->IsTableNode() )
|
|
|
|
bFound = ( SwIterator<SwFrm,SwFmt>::FirstElement(*((SwTableNode*)pNd)->GetTable().GetFrmFmt()) != 0 );
|
|
|
|
else if( pNd->IsStartNode() && !pNd->IsSectionNode() )
|
|
|
|
{
|
|
|
|
pNd = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( bFound )
|
|
|
|
break;
|
|
|
|
aTmp--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !aTmp.GetIndex() )
|
|
|
|
pNd = 0;
|
|
|
|
else if( pNd )
|
|
|
|
(*pIdx) = aTmp;
|
|
|
|
return pNd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwNode2LayImpl::SwNode2LayImpl( const SwNode& rNode, sal_uLong nIdx, sal_Bool bSearch )
|
|
|
|
: pUpperFrms( NULL ), nIndex( nIdx ), bInit( sal_False )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwNode* pNd;
|
|
|
|
if( bSearch || rNode.IsSectionNode() )
|
|
|
|
{
|
|
|
|
// Suche den naechsten Cntnt/TblNode, der einen Frame besitzt,
|
|
|
|
// damit wir uns vor/hinter ihn haengen koennen
|
|
|
|
if( !bSearch && rNode.GetIndex() < nIndex )
|
|
|
|
{
|
|
|
|
SwNodeIndex aTmp( *rNode.EndOfSectionNode(), +1 );
|
2010-12-17 09:02:23 +01:00
|
|
|
pNd = GoPreviousWithFrm( &aTmp );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !bSearch && pNd && rNode.GetIndex() > pNd->GetIndex() )
|
|
|
|
pNd = NULL; // Nicht ueber den Bereich hinausschiessen
|
2011-01-17 15:06:54 +01:00
|
|
|
bMaster = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwNodeIndex aTmp( rNode, -1 );
|
2010-12-17 09:02:23 +01:00
|
|
|
pNd = GoNextWithFrm( rNode.GetNodes(), &aTmp );
|
2011-01-17 15:06:54 +01:00
|
|
|
bMaster = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !bSearch && pNd && rNode.EndOfSectionIndex() < pNd->GetIndex() )
|
|
|
|
pNd = NULL; // Nicht ueber den Bereich hinausschiessen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pNd = &rNode;
|
|
|
|
bMaster = nIndex < rNode.GetIndex();
|
|
|
|
}
|
|
|
|
if( pNd )
|
|
|
|
{
|
|
|
|
if( pNd->IsCntntNode() )
|
|
|
|
pMod = (SwModify*)pNd->GetCntntNode();
|
|
|
|
else
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pNd->IsTableNode(), "For Tablenodes only" );
|
2000-09-18 23:08:29 +00:00
|
|
|
pMod = pNd->GetTableNode()->GetTable().GetFrmFmt();
|
|
|
|
}
|
2010-12-17 09:02:23 +01:00
|
|
|
pIter = new SwIterator<SwFrm,SwModify>( *pMod );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2010-12-17 09:02:23 +01:00
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
pIter = NULL;
|
2010-12-17 09:02:23 +01:00
|
|
|
pMod = 0;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 21:50:08 +01:00
|
|
|
/* --------------------------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
* SwNode2LayImpl::NextFrm() liefert den naechsten "sinnvollen" Frame,
|
|
|
|
* beim ersten Aufruf wird am eigentlichen Iterator ein First gerufen,
|
|
|
|
* danach die Next-Methode. Das Ergebnis wird auf Brauchbarkeit untersucht,
|
|
|
|
* so werden keine Follows akzeptiert, ein Master wird beim Einsammeln der
|
|
|
|
* pUpper und beim Einfuegen vor ihm akzeptiert. Beim Einfuegen dahinter
|
|
|
|
* wird vom Master ausgehend der letzte Follow gesucht und zurueckgegeben.
|
|
|
|
* Wenn der Frame innerhalb eines SectionFrms liegt, wird noch festgestellt,
|
|
|
|
* ob statt des Frames der SectionFrm der geeignete Rueckgabewert ist, dies
|
|
|
|
* ist der Fall, wenn der neu einzufuegende Node ausserhalb des Bereichs liegt.
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
SwFrm* SwNode2LayImpl::NextFrm()
|
|
|
|
{
|
|
|
|
SwFrm* pRet;
|
|
|
|
if( !pIter )
|
2012-09-11 10:58:50 +02:00
|
|
|
return NULL;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !bInit )
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
pRet = pIter->First();
|
2011-01-17 15:06:54 +01:00
|
|
|
bInit = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2010-12-17 09:02:23 +01:00
|
|
|
pRet = pIter->Next();
|
2000-09-18 23:08:29 +00:00
|
|
|
while( pRet )
|
|
|
|
{
|
|
|
|
SwFlowFrm* pFlow = SwFlowFrm::CastFlowFrm( pRet );
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFlow, "Cntnt or Table expected?!" );
|
2000-09-18 23:08:29 +00:00
|
|
|
// Follows sind fluechtige Gestalten, deshalb werden sie ignoriert.
|
|
|
|
// Auch wenn wir hinter dem Frame eingefuegt werden sollen, nehmen wir
|
|
|
|
// zunaechst den Master, hangeln uns dann aber zum letzten Follow durch.
|
|
|
|
if( !pFlow->IsFollow() )
|
|
|
|
{
|
|
|
|
if( !bMaster )
|
|
|
|
{
|
|
|
|
while( pFlow->HasFollow() )
|
|
|
|
pFlow = pFlow->GetFollow();
|
|
|
|
pRet = pFlow->GetFrm();
|
|
|
|
}
|
|
|
|
if( pRet->IsInSct() )
|
|
|
|
{
|
|
|
|
SwSectionFrm* pSct = pRet->FindSctFrm();
|
|
|
|
// Vorsicht: Wenn wir in einer Fussnote sind, so kann diese
|
|
|
|
// Layoutmaessig in einem spaltigen Bereich liegen, obwohl
|
|
|
|
// sie nodemaessig ausserhalb liegt. Deshalb muss bei Fussnoten
|
|
|
|
// ueberprueft werden, ob auch der SectionFrm in der Fussnote
|
|
|
|
// und nicht ausserhalb liegt.
|
|
|
|
if( !pRet->IsInFtn() || pSct->IsInFtn() )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pSct && pSct->GetSection(), "Where's my section?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
SwSectionNode* pNd = pSct->GetSection()->GetFmt()->GetSectionNode();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pNd, "Lost SectionNode" );
|
2000-09-18 23:08:29 +00:00
|
|
|
// Wenn der erhaltene Frame in einem Bereichsframe steht,
|
|
|
|
// dessen Bereich den Ausgangsnode nicht umfasst, so kehren
|
|
|
|
// wir mit dem SectionFrm zurueck, sonst mit dem Cntnt/TabFrm
|
|
|
|
if( bMaster )
|
|
|
|
{
|
|
|
|
if( pNd->GetIndex() >= nIndex )
|
|
|
|
pRet = pSct;
|
|
|
|
}
|
|
|
|
else if( pNd->EndOfSectionIndex() < nIndex )
|
|
|
|
pRet = pSct;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
2010-12-17 09:02:23 +01:00
|
|
|
pRet = pIter->Next();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwNode2LayImpl::SaveUpperFrms()
|
|
|
|
{
|
2012-06-22 13:40:02 +02:00
|
|
|
pUpperFrms = new std::vector<SwFrm*>;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm* pFrm;
|
|
|
|
while( 0 != (pFrm = NextFrm()) )
|
|
|
|
{
|
|
|
|
SwFrm* pPrv = pFrm->GetPrev();
|
|
|
|
pFrm = pFrm->GetUpper();
|
|
|
|
if( pFrm )
|
|
|
|
{
|
|
|
|
if( pFrm->IsFtnFrm() )
|
|
|
|
((SwFtnFrm*)pFrm)->ColLock();
|
|
|
|
else if( pFrm->IsInSct() )
|
|
|
|
pFrm->FindSctFrm()->ColLock();
|
|
|
|
if( pPrv && pPrv->IsSctFrm() )
|
|
|
|
((SwSectionFrm*)pPrv)->LockJoin();
|
2012-06-22 13:40:02 +02:00
|
|
|
pUpperFrms->push_back( pPrv );
|
|
|
|
pUpperFrms->push_back( pFrm );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delete pIter;
|
|
|
|
pIter = NULL;
|
2010-12-17 09:02:23 +01:00
|
|
|
pMod = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwLayoutFrm* SwNode2LayImpl::UpperFrm( SwFrm* &rpFrm, const SwNode &rNode )
|
|
|
|
{
|
|
|
|
rpFrm = NextFrm();
|
|
|
|
if( !rpFrm )
|
|
|
|
return NULL;
|
|
|
|
SwLayoutFrm* pUpper = rpFrm->GetUpper();
|
|
|
|
if( rpFrm->IsSctFrm() )
|
|
|
|
{
|
|
|
|
const SwNode* pNode = rNode.StartOfSectionNode();
|
|
|
|
if( pNode->IsSectionNode() )
|
|
|
|
{
|
|
|
|
SwFrm* pFrm = bMaster ? rpFrm->FindPrev() : rpFrm->FindNext();
|
|
|
|
if( pFrm && pFrm->IsSctFrm() )
|
|
|
|
{
|
2011-02-02 20:41:40 +09:00
|
|
|
// pFrm could be a "dummy"-section
|
2006-11-01 14:11:13 +00:00
|
|
|
if( ((SwSectionFrm*)pFrm)->GetSection() &&
|
2010-03-16 11:28:30 +01:00
|
|
|
(&((SwSectionNode*)pNode)->GetSection() ==
|
|
|
|
((SwSectionFrm*)pFrm)->GetSection()) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-02-02 20:41:40 +09:00
|
|
|
// #i22922# - consider columned sections
|
2004-06-28 11:58:50 +00:00
|
|
|
// 'Go down' the section frame as long as the layout frame
|
|
|
|
// is found, which would contain content.
|
|
|
|
while ( pFrm->IsLayoutFrm() &&
|
|
|
|
static_cast<SwLayoutFrm*>(pFrm)->Lower() &&
|
|
|
|
!static_cast<SwLayoutFrm*>(pFrm)->Lower()->IsFlowFrm() &&
|
|
|
|
static_cast<SwLayoutFrm*>(pFrm)->Lower()->IsLayoutFrm() )
|
|
|
|
{
|
|
|
|
pFrm = static_cast<SwLayoutFrm*>(pFrm)->Lower();
|
|
|
|
}
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFrm->IsLayoutFrm(),
|
2004-06-28 11:58:50 +00:00
|
|
|
"<SwNode2LayImpl::UpperFrm(..)> - expected upper frame isn't a layout frame." );
|
|
|
|
rpFrm = bMaster ? NULL
|
|
|
|
: static_cast<SwLayoutFrm*>(pFrm)->Lower();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !rpFrm || rpFrm->IsFlowFrm(),
|
2004-06-28 11:58:50 +00:00
|
|
|
"<SwNode2LayImpl::UpperFrm(..)> - expected sibling isn't a flow frame." );
|
|
|
|
return static_cast<SwLayoutFrm*>(pFrm);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2004-06-28 11:58:50 +00:00
|
|
|
|
2010-06-13 15:22:56 +02:00
|
|
|
pUpper = new SwSectionFrm(((SwSectionNode*)pNode)->GetSection(), rpFrm);
|
2000-09-18 23:08:29 +00:00
|
|
|
pUpper->Paste( rpFrm->GetUpper(),
|
|
|
|
bMaster ? rpFrm : rpFrm->GetNext() );
|
2002-11-15 10:07:52 +00:00
|
|
|
static_cast<SwSectionFrm*>(pUpper)->Init();
|
2000-09-18 23:08:29 +00:00
|
|
|
rpFrm = NULL;
|
2004-06-28 11:58:50 +00:00
|
|
|
// 'Go down' the section frame as long as the layout frame
|
|
|
|
// is found, which would contain content.
|
|
|
|
while ( pUpper->Lower() &&
|
|
|
|
!pUpper->Lower()->IsFlowFrm() &&
|
|
|
|
pUpper->Lower()->IsLayoutFrm() )
|
|
|
|
{
|
|
|
|
pUpper = static_cast<SwLayoutFrm*>(pUpper->Lower());
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
return pUpper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if( !bMaster )
|
|
|
|
rpFrm = rpFrm->GetNext();
|
|
|
|
return pUpper;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwNode2LayImpl::RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong nEnd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pUpperFrms, "RestoreUpper without SaveUpper?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
SwNode* pNd;
|
|
|
|
SwDoc *pDoc = rNds.GetDoc();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bFirst = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
for( ; nStt < nEnd; ++nStt )
|
|
|
|
{
|
|
|
|
SwFrm* pNew = 0;
|
|
|
|
SwFrm* pNxt;
|
|
|
|
SwLayoutFrm* pUp;
|
|
|
|
if( (pNd = rNds[nStt])->IsCntntNode() )
|
2012-06-22 13:40:02 +02:00
|
|
|
for( sal_uInt16 n = 0; n < pUpperFrms->size(); )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-22 13:40:02 +02:00
|
|
|
pNxt = (*pUpperFrms)[n++];
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bFirst && pNxt && pNxt->IsSctFrm() )
|
|
|
|
((SwSectionFrm*)pNxt)->UnlockJoin();
|
|
|
|
pUp = (SwLayoutFrm*)(*pUpperFrms)[n++];
|
|
|
|
if( pNxt )
|
|
|
|
pNxt = pNxt->GetNext();
|
|
|
|
else
|
|
|
|
pNxt = pUp->Lower();
|
2010-06-13 15:22:56 +02:00
|
|
|
pNew = ((SwCntntNode*)pNd)->MakeFrm( pUp );
|
2000-09-18 23:08:29 +00:00
|
|
|
pNew->Paste( pUp, pNxt );
|
|
|
|
(*pUpperFrms)[n-2] = pNew;
|
|
|
|
}
|
|
|
|
else if( pNd->IsTableNode() )
|
2012-06-22 13:40:02 +02:00
|
|
|
for( sal_uInt16 x = 0; x < pUpperFrms->size(); )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-22 13:40:02 +02:00
|
|
|
pNxt = (*pUpperFrms)[x++];
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bFirst && pNxt && pNxt->IsSctFrm() )
|
|
|
|
((SwSectionFrm*)pNxt)->UnlockJoin();
|
|
|
|
pUp = (SwLayoutFrm*)(*pUpperFrms)[x++];
|
|
|
|
if( pNxt )
|
|
|
|
pNxt = pNxt->GetNext();
|
|
|
|
else
|
|
|
|
pNxt = pUp->Lower();
|
2010-06-13 15:22:56 +02:00
|
|
|
pNew = ((SwTableNode*)pNd)->MakeFrm( pUp );
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pNew->IsTabFrm(), "Table exspected" );
|
2000-09-18 23:08:29 +00:00
|
|
|
pNew->Paste( pUp, pNxt );
|
|
|
|
((SwTabFrm*)pNew)->RegistFlys();
|
|
|
|
(*pUpperFrms)[x-2] = pNew;
|
|
|
|
}
|
|
|
|
else if( pNd->IsSectionNode() )
|
|
|
|
{
|
|
|
|
nStt = pNd->EndOfSectionIndex();
|
2012-06-22 13:40:02 +02:00
|
|
|
for( sal_uInt16 x = 0; x < pUpperFrms->size(); )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-22 13:40:02 +02:00
|
|
|
pNxt = (*pUpperFrms)[x++];
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bFirst && pNxt && pNxt->IsSctFrm() )
|
|
|
|
((SwSectionFrm*)pNxt)->UnlockJoin();
|
|
|
|
pUp = (SwLayoutFrm*)(*pUpperFrms)[x++];
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pUp->GetUpper() || pUp->IsFlyFrm(), "Lost Upper" );
|
2011-01-17 15:06:54 +01:00
|
|
|
::_InsertCnt( pUp, pDoc, pNd->GetIndex(), sal_False, nStt+1, pNxt );
|
2006-03-09 13:05:00 +00:00
|
|
|
pNxt = pUp->GetLastLower();
|
2000-09-18 23:08:29 +00:00
|
|
|
(*pUpperFrms)[x-2] = pNxt;
|
|
|
|
}
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
bFirst = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-06-22 13:40:02 +02:00
|
|
|
for( sal_uInt16 x = 0; x < pUpperFrms->size(); ++x )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-22 13:40:02 +02:00
|
|
|
SwFrm* pTmp = (*pUpperFrms)[++x];
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pTmp->IsFtnFrm() )
|
|
|
|
((SwFtnFrm*)pTmp)->ColUnlock();
|
2003-09-19 09:56:05 +00:00
|
|
|
else if ( pTmp->IsInSct() )
|
|
|
|
{
|
|
|
|
SwSectionFrm* pSctFrm = pTmp->FindSctFrm();
|
|
|
|
pSctFrm->ColUnlock();
|
2011-02-02 20:41:40 +09:00
|
|
|
// #i18103# - invalidate size of section in order to
|
2003-09-19 09:56:05 +00:00
|
|
|
// assure, that the section is formatted, unless it was 'Collocked'
|
|
|
|
// from its 'collection' until its 'restoration'.
|
|
|
|
pSctFrm->_InvalidateSize();
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm* SwNode2LayImpl::GetFrm( const Point* pDocPos,
|
|
|
|
const SwPosition *pPos,
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bCalcFrm ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
// mba: test if change of member pIter -> pMod broke anything
|
|
|
|
return pMod ? ::GetFrmOfModify( 0, *pMod, USHRT_MAX, pDocPos, pPos, bCalcFrm ) : 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwNode2Layout::SwNode2Layout( const SwNode& rNd, sal_uLong nIdx )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
pImpl = new SwNode2LayImpl( rNd, nIdx, sal_False );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwNode2Layout::SwNode2Layout( const SwNode& rNd )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
pImpl = new SwNode2LayImpl( rNd, rNd.GetIndex(), sal_True );
|
2000-09-18 23:08:29 +00:00
|
|
|
pImpl->SaveUpperFrms();
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwNode2Layout::RestoreUpperFrms( SwNodes& rNds, sal_uLong nStt, sal_uLong nEnd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pImpl, "RestoreUpperFrms without SaveUpperFrms" );
|
2000-09-18 23:08:29 +00:00
|
|
|
pImpl->RestoreUpperFrms( rNds, nStt, nEnd );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm* SwNode2Layout::NextFrm()
|
|
|
|
{
|
|
|
|
return pImpl->NextFrm();
|
|
|
|
}
|
|
|
|
|
|
|
|
SwLayoutFrm* SwNode2Layout::UpperFrm( SwFrm* &rpFrm, const SwNode &rNode )
|
|
|
|
{
|
|
|
|
return pImpl->UpperFrm( rpFrm, rNode );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwNode2Layout::~SwNode2Layout()
|
|
|
|
{
|
|
|
|
delete pImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm* SwNode2Layout::GetFrm( const Point* pDocPos,
|
|
|
|
const SwPosition *pPos,
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bCalcFrm ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return pImpl->GetFrm( pDocPos, pPos, bCalcFrm );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|