2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include "pagefrm.hxx"
|
|
|
|
#include "rootfrm.hxx"
|
|
|
|
#include "cntfrm.hxx"
|
|
|
|
#include "node.hxx"
|
|
|
|
#include "doc.hxx"
|
|
|
|
#include "frmtool.hxx"
|
|
|
|
#include "flyfrm.hxx"
|
|
|
|
#include <frmfmt.hxx>
|
2004-01-13 10:15:19 +00:00
|
|
|
#include <cellfrm.hxx>
|
|
|
|
#include <rowfrm.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
#include "tabfrm.hxx"
|
|
|
|
#include "sectfrm.hxx"
|
|
|
|
#include "flyfrms.hxx"
|
|
|
|
#include "ftnfrm.hxx"
|
|
|
|
#include "txtftn.hxx"
|
|
|
|
#include "fmtftn.hxx"
|
2004-02-26 15:59:50 +00:00
|
|
|
#include <txtfrm.hxx> // SwTxtFrm
|
2010-12-17 09:02:23 +01:00
|
|
|
#include <switerator.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* FindBodyCont, FindLastBodyCntnt()
|
|
|
|
|*
|
2012-02-13 11:37:08 +01:00
|
|
|
|* Description Searches the first/last CntntFrm in BodyText below the page.
|
2000-09-18 23:08:29 +00:00
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
SwLayoutFrm *SwFtnBossFrm::FindBodyCont()
|
|
|
|
{
|
|
|
|
SwFrm *pLay = Lower();
|
|
|
|
while ( pLay && !pLay->IsBodyFrm() )
|
|
|
|
pLay = pLay->GetNext();
|
|
|
|
return (SwLayoutFrm*)pLay;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwCntntFrm *SwPageFrm::FindLastBodyCntnt()
|
|
|
|
{
|
|
|
|
SwCntntFrm *pRet = FindFirstBodyCntnt();
|
|
|
|
SwCntntFrm *pNxt = pRet;
|
|
|
|
while ( pNxt && pNxt->IsInDocBody() && IsAnLower( pNxt ) )
|
|
|
|
{ pRet = pNxt;
|
|
|
|
pNxt = pNxt->FindNextCnt();
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwLayoutFrm::ContainsCntnt
|
|
|
|
|*
|
2012-02-13 11:37:08 +01:00
|
|
|
|* Description Checks if the frame contains one or more CntntFrm's
|
|
|
|
|* anywhere in his subsidiary structure; if so the first found CntntFrm
|
|
|
|
|* is returned
|
2000-09-18 23:08:29 +00:00
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
|
|
|
|
const SwCntntFrm *SwLayoutFrm::ContainsCntnt() const
|
|
|
|
{
|
2012-03-06 17:51:10 +01:00
|
|
|
//Search downwards the layout leaf and if there is no content, jump to the
|
|
|
|
//next leaf until content is found or we leave "this".
|
2012-02-13 11:37:08 +01:00
|
|
|
//Sections: Cntnt next to sections would not be found this way (empty
|
2012-03-06 17:51:10 +01:00
|
|
|
//sections directly next to CntntFrm) therefore we need to recursively
|
|
|
|
//search for them even if it's more complex.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
const SwLayoutFrm *pLayLeaf = this;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
while ( (!pLayLeaf->IsSctFrm() || pLayLeaf == this ) &&
|
|
|
|
pLayLeaf->Lower() && pLayLeaf->Lower()->IsLayoutFrm() )
|
|
|
|
pLayLeaf = (SwLayoutFrm*)pLayLeaf->Lower();
|
|
|
|
|
|
|
|
if( pLayLeaf->IsSctFrm() && pLayLeaf != this )
|
|
|
|
{
|
|
|
|
const SwCntntFrm *pCnt = pLayLeaf->ContainsCntnt();
|
|
|
|
if( pCnt )
|
|
|
|
return pCnt;
|
|
|
|
if( pLayLeaf->GetNext() )
|
|
|
|
{
|
|
|
|
if( pLayLeaf->GetNext()->IsLayoutFrm() )
|
|
|
|
{
|
|
|
|
pLayLeaf = (SwLayoutFrm*)pLayLeaf->GetNext();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return (SwCntntFrm*)pLayLeaf->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( pLayLeaf->Lower() )
|
|
|
|
return (SwCntntFrm*)pLayLeaf->Lower();
|
|
|
|
|
|
|
|
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
|
|
|
|
if( !IsAnLower( pLayLeaf) )
|
|
|
|
return 0;
|
|
|
|
} while( pLayLeaf );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwLayoutFrm::FirstCell
|
|
|
|
|*
|
2012-02-13 11:37:08 +01:00
|
|
|
|* Description Calls ContainsAny first to reach the innermost cell. From
|
|
|
|
|* there we walk back up to the first SwCellFrm. Since we use
|
|
|
|
|* SectionFrms ContainsCntnt()->GetUpper() is not enough any
|
|
|
|
|* more.
|
2000-09-18 23:08:29 +00:00
|
|
|
|*************************************************************************/
|
|
|
|
|
|
|
|
const SwCellFrm *SwLayoutFrm::FirstCell() const
|
|
|
|
{
|
|
|
|
const SwFrm* pCnt = ContainsAny();
|
|
|
|
while( pCnt && !pCnt->IsCellFrm() )
|
|
|
|
pCnt = pCnt->GetUpper();
|
|
|
|
return (const SwCellFrm*)pCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwLayoutFrm::ContainsAny
|
|
|
|
|*
|
2012-03-06 17:51:10 +01:00
|
|
|
|* like ComtainsCntnt, but does not only return CntntFrms but
|
|
|
|
|* also sections and tables.
|
2000-09-18 23:08:29 +00:00
|
|
|
|*************************************************************************/
|
|
|
|
|
2011-04-18 12:37:38 -03:00
|
|
|
// #130797#
|
2006-02-06 15:30:17 +00:00
|
|
|
// New parameter <_bInvestigateFtnForSections> controls investigation of
|
|
|
|
// content of footnotes for sections.
|
|
|
|
const SwFrm *SwLayoutFrm::ContainsAny( const bool _bInvestigateFtnForSections ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-06 17:51:10 +01:00
|
|
|
//Search downwards the layout leaf and if there is no content, jump to the
|
|
|
|
//next leaf until content is found, we leave "this" or until we found
|
2012-02-13 11:37:08 +01:00
|
|
|
//a SectionFrm or a TabFrm.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
const SwLayoutFrm *pLayLeaf = this;
|
2011-04-18 12:37:38 -03:00
|
|
|
// #130797#
|
2006-02-06 15:30:17 +00:00
|
|
|
const bool bNoFtn = IsSctFrm() && !_bInvestigateFtnForSections;
|
2000-09-18 23:08:29 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
while ( ( (!pLayLeaf->IsSctFrm() && !pLayLeaf->IsTabFrm())
|
|
|
|
|| pLayLeaf == this ) &&
|
|
|
|
pLayLeaf->Lower() && pLayLeaf->Lower()->IsLayoutFrm() )
|
|
|
|
pLayLeaf = (SwLayoutFrm*)pLayLeaf->Lower();
|
|
|
|
|
|
|
|
if( ( pLayLeaf->IsTabFrm() || pLayLeaf->IsSctFrm() )
|
|
|
|
&& pLayLeaf != this )
|
|
|
|
{
|
2012-02-13 11:37:08 +01:00
|
|
|
// Now we also return "deleted" SectionFrms so they can be
|
|
|
|
// maintained on SaveCntnt and RestoreCntnt
|
2000-09-18 23:08:29 +00:00
|
|
|
return pLayLeaf;
|
|
|
|
}
|
|
|
|
else if ( pLayLeaf->Lower() )
|
|
|
|
return (SwCntntFrm*)pLayLeaf->Lower();
|
|
|
|
|
|
|
|
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
|
|
|
|
if( bNoFtn && pLayLeaf && pLayLeaf->IsInFtn() )
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
|
|
|
|
} while( pLayLeaf && pLayLeaf->IsInFtn() );
|
|
|
|
}
|
|
|
|
if( !IsAnLower( pLayLeaf) )
|
|
|
|
return 0;
|
|
|
|
} while( pLayLeaf );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrm::GetLower()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
const SwFrm* SwFrm::GetLower() const
|
|
|
|
{
|
|
|
|
return IsLayoutFrm() ? ((SwLayoutFrm*)this)->Lower() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm* SwFrm::GetLower()
|
|
|
|
{
|
|
|
|
return IsLayoutFrm() ? ((SwLayoutFrm*)this)->Lower() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwLayoutFrm::IsAnLower()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwLayoutFrm::IsAnLower( const SwFrm *pAssumed ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwFrm *pUp = pAssumed;
|
|
|
|
while ( pUp )
|
|
|
|
{
|
|
|
|
if ( pUp == this )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( pUp->IsFlyFrm() )
|
2004-06-28 12:38:25 +00:00
|
|
|
pUp = ((SwFlyFrm*)pUp)->GetAnchorFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
pUp = pUp->GetUpper();
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 08:36:02 +00:00
|
|
|
/** method to check relative position of layout frame to
|
|
|
|
a given layout frame.
|
|
|
|
|
|
|
|
OD 08.11.2002 - refactoring of pseudo-local method <lcl_Apres(..)> in
|
|
|
|
<txtftn.cxx> for #104840#.
|
|
|
|
|
|
|
|
@param _aCheckRefLayFrm
|
|
|
|
constant reference of an instance of class <SwLayoutFrm> which
|
|
|
|
is used as the reference for the relative position check.
|
|
|
|
|
|
|
|
@author OD
|
|
|
|
|
|
|
|
@return true, if <this> is positioned before the layout frame <p>
|
|
|
|
*/
|
|
|
|
bool SwLayoutFrm::IsBefore( const SwLayoutFrm* _pCheckRefLayFrm ) const
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !IsRootFrm() , "<IsBefore> called at a <SwRootFrm>.");
|
|
|
|
OSL_ENSURE( !_pCheckRefLayFrm->IsRootFrm() , "<IsBefore> called with a <SwRootFrm>.");
|
2002-11-11 08:36:02 +00:00
|
|
|
|
|
|
|
bool bReturn;
|
|
|
|
|
|
|
|
// check, if on different pages
|
|
|
|
const SwPageFrm *pMyPage = FindPageFrm();
|
|
|
|
const SwPageFrm *pCheckRefPage = _pCheckRefLayFrm->FindPageFrm();
|
|
|
|
if( pMyPage != pCheckRefPage )
|
|
|
|
{
|
|
|
|
// being on different page as check reference
|
|
|
|
bReturn = pMyPage->GetPhyPageNum() < pCheckRefPage->GetPhyPageNum();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// being on same page as check reference
|
|
|
|
// --> search my supreme parent <pUp>, which doesn't contain check reference.
|
|
|
|
const SwLayoutFrm* pUp = this;
|
|
|
|
while ( pUp->GetUpper() &&
|
|
|
|
!pUp->GetUpper()->IsAnLower( _pCheckRefLayFrm )
|
|
|
|
)
|
|
|
|
pUp = pUp->GetUpper();
|
|
|
|
if( !pUp->GetUpper() )
|
|
|
|
{
|
|
|
|
// can occur, if <this> is a fly frm
|
|
|
|
bReturn = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// travel through the next's of <pUp> and check if one of these
|
|
|
|
// contain the check reference.
|
|
|
|
SwLayoutFrm* pUpNext = (SwLayoutFrm*)pUp->GetNext();
|
|
|
|
while ( pUpNext &&
|
|
|
|
!pUpNext->IsAnLower( _pCheckRefLayFrm ) )
|
|
|
|
{
|
|
|
|
pUpNext = (SwLayoutFrm*)pUpNext->GetNext();
|
|
|
|
}
|
|
|
|
bReturn = pUpNext != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bReturn;
|
|
|
|
}
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
//
|
|
|
|
// Local helper functions for GetNextLayoutLeaf
|
|
|
|
//
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static const SwFrm* lcl_FindLayoutFrame( const SwFrm* pFrm, bool bNext )
|
2004-01-13 10:15:19 +00:00
|
|
|
{
|
|
|
|
const SwFrm* pRet = 0;
|
|
|
|
if ( pFrm->IsFlyFrm() )
|
|
|
|
pRet = bNext ? ((SwFlyFrm*)pFrm)->GetNextLink() : ((SwFlyFrm*)pFrm)->GetPrevLink();
|
|
|
|
else
|
|
|
|
pRet = bNext ? pFrm->GetNext() : pFrm->GetPrev();
|
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static const SwFrm* lcl_GetLower( const SwFrm* pFrm, bool bFwd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-03-09 13:06:56 +00:00
|
|
|
if ( !pFrm->IsLayoutFrm() )
|
|
|
|
return 0;
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2006-03-09 13:06:56 +00:00
|
|
|
return bFwd ?
|
|
|
|
static_cast<const SwLayoutFrm*>(pFrm)->Lower() :
|
|
|
|
static_cast<const SwLayoutFrm*>(pFrm)->GetLastLower();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrm::ImplGetNextLayoutLeaf
|
|
|
|
|*
|
|
|
|
|* Finds the next layout leaf. This is a layout frame, which does not
|
|
|
|
* have a lower which is a LayoutFrame. That means, pLower can be 0 or a
|
|
|
|
* content frame.
|
|
|
|
*
|
|
|
|
* However, pLower may be a TabFrm
|
|
|
|
*
|
|
|
|
|*************************************************************************/
|
|
|
|
|
|
|
|
const SwLayoutFrm *SwFrm::ImplGetNextLayoutLeaf( bool bFwd ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwFrm *pFrm = this;
|
|
|
|
const SwLayoutFrm *pLayoutFrm = 0;
|
2007-09-27 08:01:45 +00:00
|
|
|
const SwFrm *p = 0;
|
2004-01-13 10:15:19 +00:00
|
|
|
bool bGoingUp = !bFwd; // false for forward, true for backward
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2012-10-21 16:36:51 +02:00
|
|
|
bool bGoingFwdOrBwd = false;
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2012-10-21 16:36:51 +02:00
|
|
|
bool bGoingDown = ( !bGoingUp && ( 0 != (p = lcl_GetLower( pFrm, bFwd ) ) ) );
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( !bGoingDown )
|
|
|
|
{
|
|
|
|
// I cannot go down, because either I'm currently going up or
|
|
|
|
// because the is no lower.
|
|
|
|
// I'll try to go forward:
|
2007-02-28 14:47:20 +00:00
|
|
|
bGoingFwdOrBwd = (0 != (p = lcl_FindLayoutFrame( pFrm, bFwd ) ) );
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( !bGoingFwdOrBwd )
|
|
|
|
{
|
|
|
|
// I cannot go forward, because there is no next frame.
|
|
|
|
// I'll try to go up:
|
|
|
|
bGoingUp = (0 != (p = pFrm->GetUpper() ) );
|
|
|
|
if ( !bGoingUp )
|
|
|
|
{
|
|
|
|
// I cannot go up, because there is no upper frame.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If I could not go down or forward, I'll have to go up
|
|
|
|
bGoingUp = !bGoingFwdOrBwd && !bGoingDown;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
pFrm = p;
|
2004-01-13 10:15:19 +00:00
|
|
|
p = lcl_GetLower( pFrm, true );
|
|
|
|
|
|
|
|
} while( ( p && !p->IsFlowFrm() ) ||
|
2000-09-18 23:08:29 +00:00
|
|
|
pFrm == this ||
|
2004-01-13 10:15:19 +00:00
|
|
|
0 == ( pLayoutFrm = pFrm->IsLayoutFrm() ? (SwLayoutFrm*)pFrm : 0 ) ||
|
2000-09-18 23:08:29 +00:00
|
|
|
pLayoutFrm->IsAnLower( this ) );
|
|
|
|
|
|
|
|
return pLayoutFrm;
|
|
|
|
}
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
2004-01-13 10:15:19 +00:00
|
|
|
|* SwFrm::ImplGetNextCntntFrm( bool )
|
2000-09-18 23:08:29 +00:00
|
|
|
|*
|
2012-02-13 11:37:08 +01:00
|
|
|
|* Walk back inside the tree: grab the subordinate Frm if one exists and
|
|
|
|
|* the last step was not moving up a level (this would lead to an infinite
|
2012-03-06 17:51:10 +01:00
|
|
|
|* up/down loop!). With this we ensure that during walking back we search
|
2012-02-13 11:37:08 +01:00
|
|
|
|* through all sub trees. If we walked downwards we have to go to the end
|
|
|
|
|* of the chain first because we go backwards from the last Frm inside
|
|
|
|
|* another Frm. Walking forward works the same.
|
2000-09-18 23:08:29 +00:00
|
|
|
|*************************************************************************/
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2012-02-13 11:37:08 +01:00
|
|
|
// Caution: fixes in ImplGetNextCntntFrm() may also need to be applied to the
|
|
|
|
// lcl_NextFrm(..) method above
|
2004-01-13 10:15:19 +00:00
|
|
|
const SwCntntFrm* SwCntntFrm::ImplGetNextCntntFrm( bool bFwd ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-01-13 10:15:19 +00:00
|
|
|
const SwFrm *pFrm = this;
|
|
|
|
// #100926#
|
|
|
|
SwCntntFrm *pCntntFrm = 0;
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bGoingUp = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
2007-09-27 08:01:45 +00:00
|
|
|
const SwFrm *p = 0;
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bGoingFwdOrBwd = false;
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bGoingDown = ( !bGoingUp && ( 0 != ( p = lcl_GetLower( pFrm, true ) ) ) );
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( !bGoingDown )
|
|
|
|
{
|
2007-02-28 14:47:20 +00:00
|
|
|
bGoingFwdOrBwd = ( 0 != ( p = lcl_FindLayoutFrame( pFrm, bFwd ) ) );
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( !bGoingFwdOrBwd )
|
|
|
|
{
|
|
|
|
bGoingUp = ( 0 != ( p = pFrm->GetUpper() ) );
|
|
|
|
if ( !bGoingUp )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bGoingUp = !(bGoingFwdOrBwd || bGoingDown);
|
|
|
|
|
|
|
|
if ( !bFwd )
|
|
|
|
{
|
|
|
|
if( bGoingDown && p )
|
|
|
|
while ( p->GetNext() )
|
|
|
|
p = p->GetNext();
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
pFrm = p;
|
2004-01-13 10:15:19 +00:00
|
|
|
} while ( 0 == (pCntntFrm = (pFrm->IsCntntFrm() ? (SwCntntFrm*)pFrm:0) ));
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
return pCntntFrm;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrm::FindRootFrm(), FindTabFrm(), FindFtnFrm(), FindFlyFrm(),
|
|
|
|
|* FindPageFrm(), FindColFrm()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
SwPageFrm* SwFrm::FindPageFrm()
|
|
|
|
{
|
|
|
|
SwFrm *pRet = this;
|
|
|
|
while ( pRet && !pRet->IsPageFrm() )
|
|
|
|
{
|
|
|
|
if ( pRet->GetUpper() )
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
else if ( pRet->IsFlyFrm() )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i28701# - use new method <GetPageFrm()>
|
2004-08-02 13:08:25 +00:00
|
|
|
if ( static_cast<SwFlyFrm*>(pRet)->GetPageFrm() )
|
|
|
|
pRet = static_cast<SwFlyFrm*>(pRet)->GetPageFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2004-08-02 13:08:25 +00:00
|
|
|
pRet = static_cast<SwFlyFrm*>(pRet)->AnchorFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (SwPageFrm*)pRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwFtnBossFrm* SwFrm::FindFtnBossFrm( sal_Bool bFootnotes )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwFrm *pRet = this;
|
2012-03-06 17:51:10 +01:00
|
|
|
// Footnote bosses can't exist inside a table; also sections with columns
|
|
|
|
// don't contain footnote texts there
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pRet->IsInTab() )
|
|
|
|
pRet = pRet->FindTabFrm();
|
|
|
|
while ( pRet && !pRet->IsFtnBossFrm() )
|
|
|
|
{
|
|
|
|
if ( pRet->GetUpper() )
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
else if ( pRet->IsFlyFrm() )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i28701# - use new method <GetPageFrm()>
|
2004-08-02 13:08:25 +00:00
|
|
|
if ( static_cast<SwFlyFrm*>(pRet)->GetPageFrm() )
|
|
|
|
pRet = static_cast<SwFlyFrm*>(pRet)->GetPageFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2004-08-02 13:08:25 +00:00
|
|
|
pRet = static_cast<SwFlyFrm*>(pRet)->AnchorFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if( bFootnotes && pRet && pRet->IsColumnFrm() &&
|
|
|
|
!pRet->GetNext() && !pRet->GetPrev() )
|
|
|
|
{
|
|
|
|
SwSectionFrm* pSct = pRet->FindSctFrm();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pSct, "FindFtnBossFrm: Single column outside section?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pSct->IsFtnAtEnd() )
|
2011-01-17 15:06:54 +01:00
|
|
|
return pSct->FindFtnBossFrm( sal_True );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return (SwFtnBossFrm*)pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTabFrm* SwFrm::ImplFindTabFrm()
|
|
|
|
{
|
|
|
|
SwFrm *pRet = this;
|
|
|
|
while ( !pRet->IsTabFrm() )
|
|
|
|
{
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
if ( !pRet )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (SwTabFrm*)pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwSectionFrm* SwFrm::ImplFindSctFrm()
|
|
|
|
{
|
|
|
|
SwFrm *pRet = this;
|
|
|
|
while ( !pRet->IsSctFrm() )
|
|
|
|
{
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
if ( !pRet )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (SwSectionFrm*)pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFtnFrm *SwFrm::ImplFindFtnFrm()
|
|
|
|
{
|
|
|
|
SwFrm *pRet = this;
|
|
|
|
while ( !pRet->IsFtnFrm() )
|
|
|
|
{
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
if ( !pRet )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return (SwFtnFrm*)pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFlyFrm *SwFrm::ImplFindFlyFrm()
|
|
|
|
{
|
|
|
|
const SwFrm *pRet = this;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( pRet->IsFlyFrm() )
|
|
|
|
return (SwFlyFrm*)pRet;
|
|
|
|
else
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
} while ( pRet );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm *SwFrm::FindColFrm()
|
|
|
|
{
|
|
|
|
SwFrm *pFrm = this;
|
|
|
|
do
|
|
|
|
{ pFrm = pFrm->GetUpper();
|
|
|
|
} while ( pFrm && !pFrm->IsColumnFrm() );
|
|
|
|
return pFrm;
|
|
|
|
}
|
|
|
|
|
2010-09-14 14:40:15 +02:00
|
|
|
SwRowFrm *SwFrm::FindRowFrm()
|
|
|
|
{
|
|
|
|
SwFrm *pFrm = this;
|
|
|
|
do
|
|
|
|
{ pFrm = pFrm->GetUpper();
|
|
|
|
} while ( pFrm && !pFrm->IsRowFrm() );
|
|
|
|
return dynamic_cast< SwRowFrm* >( pFrm );
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm* SwFrm::FindFooterOrHeader()
|
|
|
|
{
|
|
|
|
SwFrm* pRet = this;
|
|
|
|
do
|
2012-02-13 11:37:08 +01:00
|
|
|
{ if ( pRet->GetType() & 0x0018 ) //header and footer
|
2000-09-18 23:08:29 +00:00
|
|
|
return pRet;
|
|
|
|
else if ( pRet->GetUpper() )
|
|
|
|
pRet = pRet->GetUpper();
|
|
|
|
else if ( pRet->IsFlyFrm() )
|
2004-06-28 12:38:25 +00:00
|
|
|
pRet = ((SwFlyFrm*)pRet)->AnchorFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
} while ( pRet );
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwFtnFrm* SwFtnContFrm::FindFootNote() const
|
|
|
|
{
|
|
|
|
const SwFtnFrm* pRet = (SwFtnFrm*)Lower();
|
|
|
|
if( pRet && !pRet->GetAttr()->GetFtn().IsEndNote() )
|
|
|
|
return pRet;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-03-07 13:55:01 +00:00
|
|
|
const SwPageFrm* SwRootFrm::GetPageAtPos( const Point& rPt, const Size* pSize, bool bExtend ) const
|
2002-05-06 09:05:11 +00:00
|
|
|
{
|
2008-03-07 13:55:01 +00:00
|
|
|
const SwPageFrm* pRet = 0;
|
|
|
|
|
|
|
|
SwRect aRect;
|
|
|
|
if ( pSize )
|
|
|
|
{
|
|
|
|
aRect.Pos() = rPt;
|
|
|
|
aRect.SSize() = *pSize;
|
|
|
|
}
|
|
|
|
|
2002-05-06 09:05:11 +00:00
|
|
|
const SwFrm* pPage = Lower();
|
2008-03-07 13:55:01 +00:00
|
|
|
|
|
|
|
if ( !bExtend )
|
|
|
|
{
|
|
|
|
if( !Frm().IsInside( rPt ) )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// skip pages above point:
|
|
|
|
while( pPage && rPt.Y() > pPage->Frm().Bottom() )
|
|
|
|
pPage = pPage->GetNext();
|
|
|
|
}
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( GetPageNum() <= maPageRects.size(), "number of pages differes from page rect array size" );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPageIdx = 0;
|
2008-03-07 13:55:01 +00:00
|
|
|
|
|
|
|
while ( pPage && !pRet )
|
|
|
|
{
|
|
|
|
const SwRect& rBoundRect = bExtend ? maPageRects[ nPageIdx++ ] : pPage->Frm();
|
|
|
|
|
2010-09-30 15:36:19 +01:00
|
|
|
if ( (!pSize && rBoundRect.IsInside(rPt)) ||
|
|
|
|
(pSize && rBoundRect.IsOver(aRect)) )
|
|
|
|
{
|
2008-03-07 13:55:01 +00:00
|
|
|
pRet = static_cast<const SwPageFrm*>(pPage);
|
2010-09-30 15:36:19 +01:00
|
|
|
}
|
2008-03-07 13:55:01 +00:00
|
|
|
|
2002-05-06 09:05:11 +00:00
|
|
|
pPage = pPage->GetNext();
|
2008-03-07 13:55:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrmFrm::GetAttrSet()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
const SwAttrSet* SwFrm::GetAttrSet() const
|
|
|
|
{
|
|
|
|
if ( IsCntntFrm() )
|
|
|
|
return &((const SwCntntFrm*)this)->GetNode()->GetSwAttrSet();
|
|
|
|
else
|
|
|
|
return &((const SwLayoutFrm*)this)->GetFmt()->GetAttrSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrm::_FindNext(), _FindPrev(), InvalidateNextPos()
|
2012-02-13 11:37:08 +01:00
|
|
|
|* _FindNextCnt() visits tables and sections and only returns SwCntntFrms.
|
2000-09-18 23:08:29 +00:00
|
|
|
|*
|
2012-02-13 11:37:08 +01:00
|
|
|
|* Description Invalidates the position of the next frame.
|
2012-03-06 17:51:10 +01:00
|
|
|
|* This is the direct successor or in case of CntntFrms the next
|
2012-02-13 11:37:08 +01:00
|
|
|
|* CntntFrm which sits in the same flow as I do:
|
|
|
|
|* - body,
|
|
|
|
|* - footnote,
|
2012-03-06 17:51:10 +01:00
|
|
|
|* - in headers/footers the notification only needs to be forwarded
|
2012-02-13 11:37:08 +01:00
|
|
|
|* inside the section
|
|
|
|
|* - same for Flys
|
|
|
|
|* - Cntnts in tabs remain only inside their cell
|
|
|
|
|* - in principle tables behave exactly like the Cntnts
|
|
|
|
|* - sections also
|
2000-09-18 23:08:29 +00:00
|
|
|
|*************************************************************************/
|
|
|
|
|
2012-02-13 11:37:08 +01:00
|
|
|
// This helper function is an equivalent to the ImplGetNextCntntFrm() method,
|
|
|
|
// besides ContentFrames this function also returns TabFrms and SectionFrms.
|
2012-10-12 16:49:40 +02:00
|
|
|
static SwFrm* lcl_NextFrm( SwFrm* pFrm )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwFrm *pRet = 0;
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bGoingUp = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
2007-02-28 14:47:20 +00:00
|
|
|
SwFrm *p = 0;
|
2007-09-27 08:01:45 +00:00
|
|
|
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bGoingFwd = false;
|
|
|
|
bool bGoingDown = (!bGoingUp && ( 0 != (p = pFrm->IsLayoutFrm() ? ((SwLayoutFrm*)pFrm)->Lower() : 0)));
|
2007-09-27 08:01:45 +00:00
|
|
|
|
|
|
|
if( !bGoingDown )
|
|
|
|
{
|
|
|
|
bGoingFwd = (0 != (p = ( pFrm->IsFlyFrm() ? ((SwFlyFrm*)pFrm)->GetNextLink() : pFrm->GetNext())));
|
|
|
|
if ( !bGoingFwd )
|
|
|
|
{
|
|
|
|
bGoingUp = (0 != (p = pFrm->GetUpper()));
|
|
|
|
if ( !bGoingUp )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
bGoingUp = !(bGoingFwd || bGoingDown);
|
|
|
|
pFrm = p;
|
|
|
|
} while ( 0 == (pRet = ( ( pFrm->IsCntntFrm() || ( !bGoingUp &&
|
|
|
|
( pFrm->IsTabFrm() || pFrm->IsSctFrm() ) ) )? pFrm : 0 ) ) );
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm *SwFrm::_FindNext()
|
|
|
|
{
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bIgnoreTab = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *pThis = this;
|
|
|
|
|
|
|
|
if ( IsTabFrm() )
|
|
|
|
{
|
2012-02-13 11:37:08 +01:00
|
|
|
//The last Cntnt of the table gets picked up and his follower is
|
|
|
|
//returned. To be able to deactivate the special case for tables
|
|
|
|
//(see below) bIgnoreTab will be set.
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( ((SwTabFrm*)this)->GetFollow() )
|
|
|
|
return ((SwTabFrm*)this)->GetFollow();
|
|
|
|
|
|
|
|
pThis = ((SwTabFrm*)this)->FindLastCntnt();
|
|
|
|
if ( !pThis )
|
|
|
|
pThis = this;
|
2012-11-25 21:47:12 +09:00
|
|
|
bIgnoreTab = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else if ( IsSctFrm() )
|
|
|
|
{
|
2012-02-13 11:37:08 +01:00
|
|
|
//The last Cntnt of the section gets picked and his follower is returned.
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( ((SwSectionFrm*)this)->GetFollow() )
|
|
|
|
return ((SwSectionFrm*)this)->GetFollow();
|
|
|
|
|
|
|
|
pThis = ((SwSectionFrm*)this)->FindLastCntnt();
|
|
|
|
if ( !pThis )
|
|
|
|
pThis = this;
|
|
|
|
}
|
|
|
|
else if ( IsCntntFrm() )
|
|
|
|
{
|
|
|
|
if( ((SwCntntFrm*)this)->GetFollow() )
|
|
|
|
return ((SwCntntFrm*)this)->GetFollow();
|
|
|
|
}
|
2003-03-27 14:45:43 +00:00
|
|
|
else if ( IsRowFrm() )
|
|
|
|
{
|
2007-09-27 08:01:45 +00:00
|
|
|
SwFrm* pMyUpper = GetUpper();
|
|
|
|
if ( pMyUpper->IsTabFrm() && ((SwTabFrm*)pMyUpper)->GetFollow() )
|
|
|
|
return ((SwTabFrm*)pMyUpper)->GetFollow()->GetLower();
|
2003-03-27 14:45:43 +00:00
|
|
|
else return NULL;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
SwFrm* pRet = NULL;
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bFtn = pThis->IsInFtn();
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !bIgnoreTab && pThis->IsInTab() )
|
|
|
|
{
|
|
|
|
SwLayoutFrm *pUp = pThis->GetUpper();
|
|
|
|
while ( !pUp->IsCellFrm() )
|
|
|
|
pUp = pUp->GetUpper();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pUp, "Cntnt in Tabelle aber nicht in Zelle." );
|
2004-01-13 10:15:19 +00:00
|
|
|
SwFrm* pNxt = ((SwCellFrm*)pUp)->GetFollowCell();
|
|
|
|
if ( pNxt )
|
|
|
|
pNxt = ((SwCellFrm*)pNxt)->ContainsCntnt();
|
|
|
|
if ( !pNxt )
|
|
|
|
{
|
|
|
|
pNxt = lcl_NextFrm( pThis );
|
|
|
|
if ( pUp->IsAnLower( pNxt ) )
|
|
|
|
pRet = pNxt;
|
|
|
|
}
|
|
|
|
else
|
2000-09-18 23:08:29 +00:00
|
|
|
pRet = pNxt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-17 19:04:02 +09:00
|
|
|
const bool bBody = pThis->IsInDocBody();
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *pNxtCnt = lcl_NextFrm( pThis );
|
|
|
|
if ( pNxtCnt )
|
|
|
|
{
|
|
|
|
if ( bBody || bFtn )
|
|
|
|
{
|
|
|
|
while ( pNxtCnt )
|
|
|
|
{
|
2003-04-17 15:06:34 +00:00
|
|
|
// OD 02.04.2003 #108446# - check for endnote, only if found
|
|
|
|
// next content isn't contained in a section, that collect its
|
|
|
|
// endnotes at its end.
|
|
|
|
bool bEndn = IsInSct() && !IsSctFrm() &&
|
|
|
|
( !pNxtCnt->IsInSct() ||
|
|
|
|
!pNxtCnt->FindSctFrm()->IsEndnAtEnd()
|
|
|
|
);
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( ( bBody && pNxtCnt->IsInDocBody() ) ||
|
2003-04-17 15:06:34 +00:00
|
|
|
( pNxtCnt->IsInFtn() &&
|
|
|
|
( bFtn ||
|
|
|
|
( bEndn && pNxtCnt->FindFtnFrm()->GetAttr()->GetFtn().IsEndNote() )
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
pRet = pNxtCnt->IsInTab() ? pNxtCnt->FindTabFrm()
|
|
|
|
: (SwFrm*)pNxtCnt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pNxtCnt = lcl_NextFrm( pNxtCnt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( pThis->IsInFly() )
|
|
|
|
{
|
|
|
|
pRet = pNxtCnt->IsInTab() ? pNxtCnt->FindTabFrm()
|
|
|
|
: (SwFrm*)pNxtCnt;
|
|
|
|
}
|
2012-02-13 11:37:08 +01:00
|
|
|
else //footer-/or header section
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwFrm *pUp = pThis->GetUpper();
|
|
|
|
const SwFrm *pCntUp = pNxtCnt->GetUpper();
|
|
|
|
while ( pUp && pUp->GetUpper() &&
|
|
|
|
!pUp->IsHeaderFrm() && !pUp->IsFooterFrm() )
|
|
|
|
pUp = pUp->GetUpper();
|
|
|
|
while ( pCntUp && pCntUp->GetUpper() &&
|
|
|
|
!pCntUp->IsHeaderFrm() && !pCntUp->IsFooterFrm() )
|
|
|
|
pCntUp = pCntUp->GetUpper();
|
|
|
|
if ( pCntUp == pUp )
|
|
|
|
{
|
|
|
|
pRet = pNxtCnt->IsInTab() ? pNxtCnt->FindTabFrm()
|
|
|
|
: (SwFrm*)pNxtCnt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( pRet && pRet->IsInSct() )
|
|
|
|
{
|
|
|
|
SwSectionFrm* pSct = pRet->FindSctFrm();
|
2012-03-06 17:51:10 +01:00
|
|
|
//Footnotes in frames with columns must not return the section which
|
2012-02-13 11:37:08 +01:00
|
|
|
//contains the footnote
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pSct->IsAnLower( this ) &&
|
|
|
|
(!bFtn || pSct->IsInFtn() ) )
|
|
|
|
return pSct;
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i27138# - add parameter <_bInSameFtn>
|
2006-02-01 13:23:50 +00:00
|
|
|
SwCntntFrm *SwFrm::_FindNextCnt( const bool _bInSameFtn )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwFrm *pThis = this;
|
|
|
|
|
|
|
|
if ( IsTabFrm() )
|
|
|
|
{
|
|
|
|
if ( ((SwTabFrm*)this)->GetFollow() )
|
|
|
|
{
|
|
|
|
pThis = ((SwTabFrm*)this)->GetFollow()->ContainsCntnt();
|
|
|
|
if( pThis )
|
|
|
|
return (SwCntntFrm*)pThis;
|
|
|
|
}
|
|
|
|
pThis = ((SwTabFrm*)this)->FindLastCntnt();
|
|
|
|
if ( !pThis )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if ( IsSctFrm() )
|
|
|
|
{
|
|
|
|
if ( ((SwSectionFrm*)this)->GetFollow() )
|
|
|
|
{
|
|
|
|
pThis = ((SwSectionFrm*)this)->GetFollow()->ContainsCntnt();
|
|
|
|
if( pThis )
|
|
|
|
return (SwCntntFrm*)pThis;
|
|
|
|
}
|
|
|
|
pThis = ((SwSectionFrm*)this)->FindLastCntnt();
|
|
|
|
if ( !pThis )
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if ( IsCntntFrm() && ((SwCntntFrm*)this)->GetFollow() )
|
|
|
|
return ((SwCntntFrm*)this)->GetFollow();
|
|
|
|
|
|
|
|
if ( pThis->IsCntntFrm() )
|
|
|
|
{
|
2012-11-17 19:04:02 +09:00
|
|
|
const bool bBody = pThis->IsInDocBody();
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bFtn = pThis->IsInFtn();
|
2000-09-18 23:08:29 +00:00
|
|
|
SwCntntFrm *pNxtCnt = ((SwCntntFrm*)pThis)->GetNextCntntFrm();
|
|
|
|
if ( pNxtCnt )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i27138#
|
2006-02-01 13:23:50 +00:00
|
|
|
if ( bBody || ( bFtn && !_bInSameFtn ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-02-01 13:23:50 +00:00
|
|
|
// handling for environments 'footnotes' and 'document body frames':
|
2000-09-18 23:08:29 +00:00
|
|
|
while ( pNxtCnt )
|
|
|
|
{
|
|
|
|
if ( (bBody && pNxtCnt->IsInDocBody()) ||
|
|
|
|
(bFtn && pNxtCnt->IsInFtn()) )
|
|
|
|
return pNxtCnt;
|
|
|
|
pNxtCnt = pNxtCnt->GetNextCntntFrm();
|
|
|
|
}
|
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i27138#
|
2006-02-01 13:23:50 +00:00
|
|
|
else if ( bFtn && _bInSameFtn )
|
|
|
|
{
|
|
|
|
// handling for environments 'each footnote':
|
|
|
|
// Assure that found next content frame belongs to the same footnotes
|
|
|
|
const SwFtnFrm* pFtnFrmOfNext( pNxtCnt->FindFtnFrm() );
|
|
|
|
const SwFtnFrm* pFtnFrmOfCurr( pThis->FindFtnFrm() );
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFtnFrmOfCurr,
|
2006-02-01 13:23:50 +00:00
|
|
|
"<SwFrm::_FindNextCnt() - unknown layout situation: current frame has to have an upper footnote frame." );
|
|
|
|
if ( pFtnFrmOfNext == pFtnFrmOfCurr )
|
|
|
|
{
|
|
|
|
return pNxtCnt;
|
|
|
|
}
|
|
|
|
else if ( pFtnFrmOfCurr->GetFollow() )
|
|
|
|
{
|
|
|
|
// next content frame has to be the first content frame
|
|
|
|
// in the follow footnote, which contains a content frame.
|
|
|
|
SwFtnFrm* pFollowFtnFrmOfCurr(
|
|
|
|
const_cast<SwFtnFrm*>(pFtnFrmOfCurr) );
|
|
|
|
pNxtCnt = 0L;
|
|
|
|
do {
|
|
|
|
pFollowFtnFrmOfCurr = pFollowFtnFrmOfCurr->GetFollow();
|
|
|
|
pNxtCnt = pFollowFtnFrmOfCurr->ContainsCntnt();
|
|
|
|
} while ( !pNxtCnt && pFollowFtnFrmOfCurr->GetFollow() );
|
|
|
|
return pNxtCnt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// current content frame is the last content frame in the
|
|
|
|
// footnote - no next content frame exists.
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else if ( pThis->IsInFly() )
|
2006-02-01 13:23:50 +00:00
|
|
|
// handling for environments 'unlinked fly frame' and
|
|
|
|
// 'group of linked fly frames':
|
2000-09-18 23:08:29 +00:00
|
|
|
return pNxtCnt;
|
2006-02-01 13:23:50 +00:00
|
|
|
else
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-02-01 13:23:50 +00:00
|
|
|
// handling for environments 'page header' and 'page footer':
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwFrm *pUp = pThis->GetUpper();
|
|
|
|
const SwFrm *pCntUp = pNxtCnt->GetUpper();
|
|
|
|
while ( pUp && pUp->GetUpper() &&
|
|
|
|
!pUp->IsHeaderFrm() && !pUp->IsFooterFrm() )
|
|
|
|
pUp = pUp->GetUpper();
|
|
|
|
while ( pCntUp && pCntUp->GetUpper() &&
|
|
|
|
!pCntUp->IsHeaderFrm() && !pCntUp->IsFooterFrm() )
|
|
|
|
pCntUp = pCntUp->GetUpper();
|
|
|
|
if ( pCntUp == pUp )
|
|
|
|
return pNxtCnt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-01 13:23:50 +00:00
|
|
|
/** method to determine previous content frame in the same environment
|
|
|
|
for a flow frame (content frame, table frame, section frame)
|
|
|
|
|
|
|
|
OD 2005-11-30 #i27138#
|
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
SwCntntFrm* SwFrm::_FindPrevCnt( const bool _bInSameFtn )
|
|
|
|
{
|
|
|
|
if ( !IsFlowFrm() )
|
|
|
|
{
|
|
|
|
// nothing to do, if current frame isn't a flow frame.
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwCntntFrm* pPrevCntntFrm( 0L );
|
|
|
|
|
|
|
|
// Because method <SwCntntFrm::GetPrevCntntFrm()> is used to travel
|
|
|
|
// through the layout, a content frame, at which the travel starts, is needed.
|
|
|
|
SwCntntFrm* pCurrCntntFrm = dynamic_cast<SwCntntFrm*>(this);
|
|
|
|
|
|
|
|
// perform shortcut, if current frame is a follow, and
|
|
|
|
// determine <pCurrCntntFrm>, if current frame is a table or section frame
|
|
|
|
if ( pCurrCntntFrm && pCurrCntntFrm->IsFollow() )
|
|
|
|
{
|
|
|
|
// previous content frame is its master content frame
|
|
|
|
pPrevCntntFrm = pCurrCntntFrm->FindMaster();
|
|
|
|
}
|
|
|
|
else if ( IsTabFrm() )
|
|
|
|
{
|
|
|
|
SwTabFrm* pTabFrm( static_cast<SwTabFrm*>(this) );
|
|
|
|
if ( pTabFrm->IsFollow() )
|
|
|
|
{
|
|
|
|
// previous content frame is the last content of its master table frame
|
|
|
|
pPrevCntntFrm = pTabFrm->FindMaster()->FindLastCntnt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// start content frame for the search is the first content frame of
|
|
|
|
// the table frame.
|
|
|
|
pCurrCntntFrm = pTabFrm->ContainsCntnt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( IsSctFrm() )
|
|
|
|
{
|
|
|
|
SwSectionFrm* pSectFrm( static_cast<SwSectionFrm*>(this) );
|
|
|
|
if ( pSectFrm->IsFollow() )
|
|
|
|
{
|
|
|
|
// previous content frame is the last content of its master section frame
|
|
|
|
pPrevCntntFrm = pSectFrm->FindMaster()->FindLastCntnt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// start content frame for the search is the first content frame of
|
|
|
|
// the section frame.
|
|
|
|
pCurrCntntFrm = pSectFrm->ContainsCntnt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// search for next content frame, depending on the environment, in which
|
|
|
|
// the current frame is in.
|
|
|
|
if ( !pPrevCntntFrm && pCurrCntntFrm )
|
|
|
|
{
|
|
|
|
pPrevCntntFrm = pCurrCntntFrm->GetPrevCntntFrm();
|
|
|
|
if ( pPrevCntntFrm )
|
|
|
|
{
|
|
|
|
if ( pCurrCntntFrm->IsInFly() )
|
|
|
|
{
|
|
|
|
// handling for environments 'unlinked fly frame' and
|
|
|
|
// 'group of linked fly frames':
|
|
|
|
// Nothing to do, <pPrevCntntFrm> is the one
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool bInDocBody = pCurrCntntFrm->IsInDocBody();
|
|
|
|
const bool bInFtn = pCurrCntntFrm->IsInFtn();
|
|
|
|
if ( bInDocBody || ( bInFtn && !_bInSameFtn ) )
|
|
|
|
{
|
|
|
|
// handling for environments 'footnotes' and 'document body frames':
|
|
|
|
// Assure that found previous frame is also in one of these
|
|
|
|
// environments. Otherwise, travel further
|
|
|
|
while ( pPrevCntntFrm )
|
|
|
|
{
|
|
|
|
if ( ( bInDocBody && pPrevCntntFrm->IsInDocBody() ) ||
|
|
|
|
( bInFtn && pPrevCntntFrm->IsInFtn() ) )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pPrevCntntFrm = pPrevCntntFrm->GetPrevCntntFrm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( bInFtn && _bInSameFtn )
|
|
|
|
{
|
|
|
|
// handling for environments 'each footnote':
|
|
|
|
// Assure that found next content frame belongs to the same footnotes
|
|
|
|
const SwFtnFrm* pFtnFrmOfPrev( pPrevCntntFrm->FindFtnFrm() );
|
|
|
|
const SwFtnFrm* pFtnFrmOfCurr( pCurrCntntFrm->FindFtnFrm() );
|
|
|
|
if ( pFtnFrmOfPrev != pFtnFrmOfCurr )
|
|
|
|
{
|
|
|
|
if ( pFtnFrmOfCurr->GetMaster() )
|
|
|
|
{
|
|
|
|
SwFtnFrm* pMasterFtnFrmOfCurr(
|
|
|
|
const_cast<SwFtnFrm*>(pFtnFrmOfCurr) );
|
|
|
|
pPrevCntntFrm = 0L;
|
2011-04-18 12:37:38 -03:00
|
|
|
// #146872#
|
2007-07-26 07:19:27 +00:00
|
|
|
// correct wrong loop-condition
|
2006-02-01 13:23:50 +00:00
|
|
|
do {
|
|
|
|
pMasterFtnFrmOfCurr = pMasterFtnFrmOfCurr->GetMaster();
|
|
|
|
pPrevCntntFrm = pMasterFtnFrmOfCurr->FindLastCntnt();
|
|
|
|
} while ( !pPrevCntntFrm &&
|
2007-07-26 07:19:27 +00:00
|
|
|
pMasterFtnFrmOfCurr->GetMaster() );
|
2006-02-01 13:23:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// current content frame is the first content in the
|
|
|
|
// footnote - no previous content exists.
|
|
|
|
pPrevCntntFrm = 0L;;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// handling for environments 'page header' and 'page footer':
|
|
|
|
// Assure that found previous frame is also in the same
|
|
|
|
// page header respectively page footer as <pCurrCntntFrm>
|
|
|
|
// Note: At this point its clear, that <pCurrCntntFrm> has
|
|
|
|
// to be inside a page header or page footer and that
|
|
|
|
// neither <pCurrCntntFrm> nor <pPrevCntntFrm> are
|
|
|
|
// inside a fly frame.
|
|
|
|
// Thus, method <FindFooterOrHeader()> can be used.
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pCurrCntntFrm->FindFooterOrHeader(),
|
2006-02-01 13:23:50 +00:00
|
|
|
"<SwFrm::_FindPrevCnt()> - unknown layout situation: current frame should be in page header or page footer" );
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !pPrevCntntFrm->IsInFly(),
|
2006-02-01 13:23:50 +00:00
|
|
|
"<SwFrm::_FindPrevCnt()> - unknown layout situation: found previous frame should *not* be inside a fly frame." );
|
|
|
|
if ( pPrevCntntFrm->FindFooterOrHeader() !=
|
|
|
|
pCurrCntntFrm->FindFooterOrHeader() )
|
|
|
|
{
|
|
|
|
pPrevCntntFrm = 0L;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pPrevCntntFrm;
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *SwFrm::_FindPrev()
|
|
|
|
{
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bIgnoreTab = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *pThis = this;
|
|
|
|
|
|
|
|
if ( IsTabFrm() )
|
|
|
|
{
|
2012-02-13 11:37:08 +01:00
|
|
|
//The first Cntnt of the table gets picked up and his predecessor is
|
|
|
|
//returnd. To be able to deactivate the special case for tables
|
|
|
|
//(see below) bIgnoreTab will be set.
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( ((SwTabFrm*)this)->IsFollow() )
|
|
|
|
return ((SwTabFrm*)this)->FindMaster();
|
|
|
|
else
|
|
|
|
pThis = ((SwTabFrm*)this)->ContainsCntnt();
|
2012-11-25 21:47:12 +09:00
|
|
|
bIgnoreTab = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( pThis && pThis->IsCntntFrm() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwCntntFrm *pPrvCnt = ((SwCntntFrm*)pThis)->GetPrevCntntFrm();
|
|
|
|
if( !pPrvCnt )
|
|
|
|
return 0;
|
|
|
|
if ( !bIgnoreTab && pThis->IsInTab() )
|
|
|
|
{
|
|
|
|
SwLayoutFrm *pUp = pThis->GetUpper();
|
|
|
|
while ( !pUp->IsCellFrm() )
|
|
|
|
pUp = pUp->GetUpper();
|
2012-02-13 11:37:08 +01:00
|
|
|
OSL_ENSURE( pUp, "Cntnt in table but not in cell." );
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( pUp->IsAnLower( pPrvCnt ) )
|
|
|
|
return pPrvCnt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwFrm* pRet;
|
2012-11-17 19:04:02 +09:00
|
|
|
const bool bBody = pThis->IsInDocBody();
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bFtn = bBody ? sal_False : pThis->IsInFtn();
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( bBody || bFtn )
|
|
|
|
{
|
|
|
|
while ( pPrvCnt )
|
|
|
|
{
|
|
|
|
if ( (bBody && pPrvCnt->IsInDocBody()) ||
|
|
|
|
(bFtn && pPrvCnt->IsInFtn()) )
|
|
|
|
{
|
|
|
|
pRet = pPrvCnt->IsInTab() ? pPrvCnt->FindTabFrm()
|
|
|
|
: (SwFrm*)pPrvCnt;
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
pPrvCnt = pPrvCnt->GetPrevCntntFrm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( pThis->IsInFly() )
|
|
|
|
{
|
|
|
|
pRet = pPrvCnt->IsInTab() ? pPrvCnt->FindTabFrm()
|
|
|
|
: (SwFrm*)pPrvCnt;
|
|
|
|
return pRet;
|
|
|
|
}
|
2012-03-06 17:51:10 +01:00
|
|
|
else // footer or header or Fly
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwFrm *pUp = pThis->GetUpper();
|
|
|
|
const SwFrm *pCntUp = pPrvCnt->GetUpper();
|
|
|
|
while ( pUp && pUp->GetUpper() &&
|
|
|
|
!pUp->IsHeaderFrm() && !pUp->IsFooterFrm() )
|
|
|
|
pUp = pUp->GetUpper();
|
|
|
|
while ( pCntUp && pCntUp->GetUpper() )
|
|
|
|
pCntUp = pCntUp->GetUpper();
|
|
|
|
if ( pCntUp == pUp )
|
|
|
|
{
|
|
|
|
pRet = pPrvCnt->IsInTab() ? pPrvCnt->FindTabFrm()
|
|
|
|
: (SwFrm*)pPrvCnt;
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwFrm::ImplInvalidateNextPos( sal_Bool bNoFtn )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwFrm *pFrm;
|
|
|
|
if ( 0 != (pFrm = _FindNext()) )
|
|
|
|
{
|
|
|
|
if( pFrm->IsSctFrm() )
|
|
|
|
{
|
|
|
|
while( pFrm && pFrm->IsSctFrm() )
|
|
|
|
{
|
|
|
|
if( ((SwSectionFrm*)pFrm)->GetSection() )
|
|
|
|
{
|
|
|
|
SwFrm* pTmp = ((SwSectionFrm*)pFrm)->ContainsAny();
|
|
|
|
if( pTmp )
|
2001-06-15 10:37:53 +00:00
|
|
|
pTmp->InvalidatePos();
|
2000-09-18 23:08:29 +00:00
|
|
|
else if( !bNoFtn )
|
|
|
|
((SwSectionFrm*)pFrm)->InvalidateFtnPos();
|
|
|
|
if( !IsInSct() || FindSctFrm()->GetFollow() != pFrm )
|
|
|
|
pFrm->InvalidatePos();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pFrm = pFrm->FindNext();
|
|
|
|
}
|
|
|
|
if( pFrm )
|
|
|
|
{
|
|
|
|
if ( pFrm->IsSctFrm())
|
2012-03-06 17:51:10 +01:00
|
|
|
{
|
|
|
|
// We need to invalidate the section's content so it gets
|
|
|
|
// the chance to flow to a different page.
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm* pTmp = ((SwSectionFrm*)pFrm)->ContainsAny();
|
|
|
|
if( pTmp )
|
2001-06-15 10:37:53 +00:00
|
|
|
pTmp->InvalidatePos();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !IsInSct() || FindSctFrm()->GetFollow() != pFrm )
|
|
|
|
pFrm->InvalidatePos();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pFrm->InvalidatePos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pFrm->InvalidatePos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-26 15:59:50 +00:00
|
|
|
/** method to invalidate printing area of next frame
|
|
|
|
|
|
|
|
OD 09.01.2004 #i11859#
|
|
|
|
|
|
|
|
@author OD
|
2004-06-04 07:44:20 +00:00
|
|
|
|
|
|
|
FME 2004-04-19 #i27145# Moved function from SwTxtFrm to SwFrm
|
2004-02-26 15:59:50 +00:00
|
|
|
*/
|
2004-06-04 07:44:20 +00:00
|
|
|
void SwFrm::InvalidateNextPrtArea()
|
2004-02-26 15:59:50 +00:00
|
|
|
{
|
|
|
|
// determine next frame
|
|
|
|
SwFrm* pNextFrm = FindNext();
|
|
|
|
// skip empty section frames and hidden text frames
|
|
|
|
{
|
|
|
|
while ( pNextFrm &&
|
|
|
|
( ( pNextFrm->IsSctFrm() &&
|
|
|
|
!static_cast<SwSectionFrm*>(pNextFrm)->GetSection() ) ||
|
|
|
|
( pNextFrm->IsTxtFrm() &&
|
|
|
|
static_cast<SwTxtFrm*>(pNextFrm)->IsHiddenNow() ) ) )
|
|
|
|
{
|
|
|
|
pNextFrm = pNextFrm->FindNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Invalidate printing area of found next frame
|
|
|
|
if ( pNextFrm )
|
|
|
|
{
|
|
|
|
if ( pNextFrm->IsSctFrm() )
|
|
|
|
{
|
|
|
|
// Invalidate printing area of found section frame, if
|
|
|
|
// (1) this text frame isn't in a section OR
|
|
|
|
// (2) found section frame isn't a follow of the section frame this
|
|
|
|
// text frame is in.
|
2004-06-04 07:44:20 +00:00
|
|
|
if ( !IsInSct() || FindSctFrm()->GetFollow() != pNextFrm )
|
2004-02-26 15:59:50 +00:00
|
|
|
{
|
|
|
|
pNextFrm->InvalidatePrt();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Invalidate printing area of first content in found section.
|
|
|
|
SwFrm* pFstCntntOfSctFrm =
|
|
|
|
static_cast<SwSectionFrm*>(pNextFrm)->ContainsAny();
|
|
|
|
if ( pFstCntntOfSctFrm )
|
|
|
|
{
|
|
|
|
pFstCntntOfSctFrm->InvalidatePrt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pNextFrm->InvalidatePrt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* lcl_IsInColSect()
|
|
|
|
|*
|
2012-03-06 17:51:10 +01:00
|
|
|
|* returns true if the frame _directly_ sits in a section with columns
|
|
|
|
|* but not if it sits in a table which itself sits in a section with columns.
|
2000-09-18 23:08:29 +00:00
|
|
|
|*************************************************************************/
|
|
|
|
|
2012-11-25 21:47:12 +09:00
|
|
|
static bool lcl_IsInColSct( const SwFrm *pUp )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-11-25 21:47:12 +09:00
|
|
|
bool bRet = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
while( pUp )
|
|
|
|
{
|
|
|
|
if( pUp->IsColumnFrm() )
|
2012-11-25 21:47:12 +09:00
|
|
|
bRet = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
else if( pUp->IsSctFrm() )
|
|
|
|
return bRet;
|
|
|
|
else if( pUp->IsTabFrm() )
|
2012-11-25 21:47:12 +09:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
pUp = pUp->GetUpper();
|
|
|
|
}
|
2012-11-25 21:47:12 +09:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrm::IsMoveable();
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2004-02-02 17:20:31 +00:00
|
|
|
/** determine, if frame is moveable in given environment
|
|
|
|
|
|
|
|
OD 08.08.2003 #110978#
|
2011-01-17 15:06:54 +01:00
|
|
|
method replaced 'old' method <sal_Bool IsMoveable() const>.
|
2004-02-02 17:20:31 +00:00
|
|
|
Determines, if frame is moveable in given environment. if no environment
|
|
|
|
is given (parameter _pLayoutFrm == 0L), the movability in the actual
|
|
|
|
environment (<this->GetUpper()) is checked.
|
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
2007-02-28 14:47:20 +00:00
|
|
|
|
2004-02-02 17:20:31 +00:00
|
|
|
bool SwFrm::IsMoveable( const SwLayoutFrm* _pLayoutFrm ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-02-02 17:20:31 +00:00
|
|
|
bool bRetVal = false;
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2004-02-02 17:20:31 +00:00
|
|
|
if ( !_pLayoutFrm )
|
|
|
|
{
|
|
|
|
_pLayoutFrm = GetUpper();
|
|
|
|
}
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2004-02-02 17:20:31 +00:00
|
|
|
if ( _pLayoutFrm && IsFlowFrm() )
|
|
|
|
{
|
|
|
|
if ( _pLayoutFrm->IsInSct() && lcl_IsInColSct( _pLayoutFrm ) )
|
|
|
|
{
|
|
|
|
bRetVal = true;
|
|
|
|
}
|
|
|
|
else if ( _pLayoutFrm->IsInFly() ||
|
|
|
|
_pLayoutFrm->IsInDocBody() ||
|
|
|
|
_pLayoutFrm->IsInFtn() )
|
|
|
|
{
|
|
|
|
if ( _pLayoutFrm->IsInTab() && !IsTabFrm() &&
|
2007-02-28 14:47:20 +00:00
|
|
|
( !IsCntntFrm() || !const_cast<SwFrm*>(this)->GetNextCellLeaf( MAKEPAGE_NONE ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-02-02 17:20:31 +00:00
|
|
|
bRetVal = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( _pLayoutFrm->IsInFly() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-02-02 17:20:31 +00:00
|
|
|
// if fly frame has a follow (next linked fly frame),
|
|
|
|
// frame is moveable.
|
|
|
|
if ( const_cast<SwLayoutFrm*>(_pLayoutFrm)->FindFlyFrm()->GetNextLink() )
|
|
|
|
{
|
|
|
|
bRetVal = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if environment is columned, frame is moveable, if
|
|
|
|
// it isn't in last column.
|
|
|
|
// search for column frame
|
|
|
|
const SwFrm* pCol = _pLayoutFrm;
|
|
|
|
while ( pCol && !pCol->IsColumnFrm() )
|
|
|
|
{
|
|
|
|
pCol = pCol->GetUpper();
|
|
|
|
}
|
|
|
|
// frame is moveable, if found column frame isn't last one.
|
|
|
|
if ( pCol && pCol->GetNext() )
|
|
|
|
{
|
|
|
|
bRetVal = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bRetVal = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-02 17:20:31 +00:00
|
|
|
|
|
|
|
return bRetVal;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwFrm::SetInfFlags();
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
void SwFrm::SetInfFlags()
|
|
|
|
{
|
2012-02-13 11:37:08 +01:00
|
|
|
if ( !IsFlyFrm() && !GetUpper() ) //not yet pasted, no information available
|
|
|
|
return;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfInvalid = mbInfBody = mbInfTab = mbInfFly = mbInfFtn = mbInfSct = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwFrm *pFrm = this;
|
|
|
|
if( IsFtnContFrm() )
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfFtn = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
do
|
2012-02-27 15:09:52 +01:00
|
|
|
{
|
2013-02-09 11:35:20 +01:00
|
|
|
// mbInfBody is only set in the page body, but not in the column body
|
|
|
|
if ( pFrm->IsBodyFrm() && !mbInfFtn && pFrm->GetUpper()
|
2000-09-18 23:08:29 +00:00
|
|
|
&& pFrm->GetUpper()->IsPageFrm() )
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfBody = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
else if ( pFrm->IsTabFrm() || pFrm->IsCellFrm() )
|
|
|
|
{
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfTab = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else if ( pFrm->IsFlyFrm() )
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfFly = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
else if ( pFrm->IsSctFrm() )
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfSct = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
else if ( pFrm->IsFtnFrm() )
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInfFtn = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-06-28 12:38:25 +00:00
|
|
|
pFrm = pFrm->GetUpper();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-02-13 11:37:08 +01:00
|
|
|
} while ( pFrm && !pFrm->IsPageFrm() ); //there is nothing above the page
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-04-10 22:40:05 -03:00
|
|
|
/*
|
2011-01-17 15:06:54 +01:00
|
|
|
* SwFrm::SetDirFlags( sal_Bool )
|
2001-08-23 13:41:20 +00:00
|
|
|
* actualizes the vertical or the righttoleft-flags.
|
|
|
|
* If the property is derived, it's from the upper or (for fly frames) from
|
|
|
|
* the anchor. Otherwise we've to call a virtual method to check the property.
|
2011-04-10 22:40:05 -03:00
|
|
|
*/
|
2001-08-23 13:41:20 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwFrm::SetDirFlags( sal_Bool bVert )
|
2001-08-23 13:41:20 +00:00
|
|
|
{
|
|
|
|
if( bVert )
|
|
|
|
{
|
2004-02-26 10:39:36 +00:00
|
|
|
// OD 2004-01-21 #114969# - if derived, valid vertical flag only if
|
|
|
|
// vertical flag of upper/anchor is valid.
|
2013-02-09 11:35:20 +01:00
|
|
|
if( mbDerivedVert )
|
2001-08-23 13:41:20 +00:00
|
|
|
{
|
2004-06-28 12:38:25 +00:00
|
|
|
const SwFrm* pAsk = IsFlyFrm() ?
|
|
|
|
((SwFlyFrm*)this)->GetAnchorFrm() : GetUpper();
|
2004-03-17 11:48:39 +00:00
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pAsk != this, "Autsch! Stack overflow is about to happen" );
|
2004-03-17 11:48:39 +00:00
|
|
|
|
2001-10-05 11:36:10 +00:00
|
|
|
if( pAsk )
|
|
|
|
{
|
2013-02-09 11:35:20 +01:00
|
|
|
mbVertical = pAsk->IsVertical() ? 1 : 0;
|
|
|
|
mbReverse = pAsk->IsReverse() ? 1 : 0;
|
2009-03-04 16:19:59 +00:00
|
|
|
|
2013-02-09 11:35:20 +01:00
|
|
|
mbVertLR = pAsk->IsVertLR() ? 1 : 0;
|
2009-03-04 16:19:59 +00:00
|
|
|
//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
|
2013-02-09 11:35:20 +01:00
|
|
|
if ( !pAsk->mbInvalidVert )
|
|
|
|
mbInvalidVert = sal_False;
|
2001-10-05 11:36:10 +00:00
|
|
|
}
|
2001-08-23 13:41:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
CheckDirection( bVert );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bInv = 0;
|
2013-02-09 11:35:20 +01:00
|
|
|
if( !mbDerivedR2L ) // CheckDirection is able to set bDerivedR2L!
|
2002-07-11 15:06:38 +00:00
|
|
|
CheckDirection( bVert );
|
2013-02-09 11:35:20 +01:00
|
|
|
if( mbDerivedR2L )
|
2001-08-23 13:41:20 +00:00
|
|
|
{
|
2004-06-28 12:38:25 +00:00
|
|
|
const SwFrm* pAsk = IsFlyFrm() ?
|
|
|
|
((SwFlyFrm*)this)->GetAnchorFrm() : GetUpper();
|
2004-03-17 11:48:39 +00:00
|
|
|
|
2012-02-13 11:37:08 +01:00
|
|
|
OSL_ENSURE( pAsk != this, "Oops! Stack overflow is about to happen" );
|
2004-03-17 11:48:39 +00:00
|
|
|
|
2001-11-09 12:32:26 +00:00
|
|
|
if( pAsk )
|
2013-02-09 11:35:20 +01:00
|
|
|
mbRightToLeft = pAsk->IsRightToLeft() ? 1 : 0;
|
|
|
|
if( !pAsk || pAsk->mbInvalidR2L )
|
|
|
|
bInv = mbInvalidR2L;
|
2001-08-23 13:41:20 +00:00
|
|
|
}
|
2013-02-09 11:35:20 +01:00
|
|
|
mbInvalidR2L = bInv;
|
2001-08-23 13:41:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
SwLayoutFrm* SwFrm::GetNextCellLeaf( MakePageType )
|
2004-01-13 10:15:19 +00:00
|
|
|
{
|
|
|
|
SwFrm* pTmpFrm = this;
|
|
|
|
while ( !pTmpFrm->IsCellFrm() )
|
|
|
|
pTmpFrm = pTmpFrm->GetUpper();
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pTmpFrm, "SwFrm::GetNextCellLeaf() without cell" );
|
2004-01-13 10:15:19 +00:00
|
|
|
return ((SwCellFrm*)pTmpFrm)->GetFollowCell();
|
|
|
|
}
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
SwLayoutFrm* SwFrm::GetPrevCellLeaf( MakePageType )
|
2004-01-13 10:15:19 +00:00
|
|
|
{
|
|
|
|
SwFrm* pTmpFrm = this;
|
|
|
|
while ( !pTmpFrm->IsCellFrm() )
|
|
|
|
pTmpFrm = pTmpFrm->GetUpper();
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pTmpFrm, "SwFrm::GetNextPreviousLeaf() without cell" );
|
2004-01-13 10:15:19 +00:00
|
|
|
return ((SwCellFrm*)pTmpFrm)->GetPreviousCell();
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static SwCellFrm* lcl_FindCorrespondingCellFrm( const SwRowFrm& rOrigRow,
|
2004-01-13 10:15:19 +00:00
|
|
|
const SwCellFrm& rOrigCell,
|
|
|
|
const SwRowFrm& rCorrRow,
|
|
|
|
bool bInFollow )
|
|
|
|
{
|
|
|
|
SwCellFrm* pRet = NULL;
|
|
|
|
SwCellFrm* pCell = (SwCellFrm*)rOrigRow.Lower();
|
|
|
|
SwCellFrm* pCorrCell = (SwCellFrm*)rCorrRow.Lower();
|
|
|
|
|
|
|
|
while ( pCell != &rOrigCell && !pCell->IsAnLower( &rOrigCell ) )
|
|
|
|
{
|
|
|
|
pCell = (SwCellFrm*)pCell->GetNext();
|
|
|
|
pCorrCell = (SwCellFrm*)pCorrCell->GetNext();
|
|
|
|
}
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pCell && pCorrCell, "lcl_FindCorrespondingCellFrm does not work" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
if ( pCell != &rOrigCell )
|
|
|
|
{
|
|
|
|
// rOrigCell must be a lower of pCell. We need to recurse into the rows:
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pCell->Lower() && pCell->Lower()->IsRowFrm(),
|
|
|
|
"lcl_FindCorrespondingCellFrm does not work" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
SwRowFrm* pRow = (SwRowFrm*)pCell->Lower();
|
|
|
|
while ( !pRow->IsAnLower( &rOrigCell ) )
|
|
|
|
pRow = (SwRowFrm*)pRow->GetNext();
|
|
|
|
|
|
|
|
SwRowFrm* pCorrRow = 0;
|
|
|
|
if ( bInFollow )
|
|
|
|
pCorrRow = pRow->GetFollowRow();
|
|
|
|
else
|
|
|
|
{
|
2006-03-09 13:06:56 +00:00
|
|
|
SwRowFrm* pTmpRow = static_cast<SwRowFrm*>(pCorrCell->GetLastLower());
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2004-12-23 09:06:49 +00:00
|
|
|
if ( pTmpRow && pTmpRow->GetFollowRow() == pRow )
|
2004-01-13 10:15:19 +00:00
|
|
|
pCorrRow = pTmpRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pCorrRow )
|
|
|
|
pRet = lcl_FindCorrespondingCellFrm( *pRow, rOrigCell, *pCorrRow, bInFollow );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pRet = pCorrCell;
|
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
// VERSION OF GetFollowCell() that assumes that we always have a follow flow line:
|
2004-01-13 10:15:19 +00:00
|
|
|
SwCellFrm* SwCellFrm::GetFollowCell() const
|
|
|
|
{
|
|
|
|
SwCellFrm* pRet = NULL;
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
// NEW TABLES
|
|
|
|
// Covered cells do not have follow cells!
|
|
|
|
const long nRowSpan = GetLayoutRowSpan();
|
|
|
|
if ( nRowSpan < 1 )
|
|
|
|
return NULL;
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
// find most upper row frame
|
|
|
|
const SwFrm* pRow = GetUpper();
|
|
|
|
while( !pRow->IsRowFrm() || !pRow->GetUpper()->IsTabFrm() )
|
|
|
|
pRow = pRow->GetUpper();
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
if ( !pRow )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( pRow->GetUpper() );
|
|
|
|
if ( !pRow || !pTabFrm->GetFollow() || !pTabFrm->HasFollowFlowLine() )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
const SwCellFrm* pThisCell = this;
|
|
|
|
|
|
|
|
// Get last cell of the current table frame that belongs to the rowspan:
|
|
|
|
if ( nRowSpan > 1 )
|
|
|
|
{
|
|
|
|
// optimization: Will end of row span be in last row or exceed row?
|
|
|
|
long nMax = 0;
|
|
|
|
while ( pRow->GetNext() && ++nMax < nRowSpan )
|
|
|
|
pRow = pRow->GetNext();
|
|
|
|
|
|
|
|
if ( !pRow->GetNext() )
|
|
|
|
{
|
|
|
|
pThisCell = &pThisCell->FindStartEndOfRowSpanCell( false, true );
|
|
|
|
pRow = pThisCell->GetUpper();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
const SwRowFrm* pFollowRow = NULL;
|
|
|
|
if ( !pRow->GetNext() &&
|
2007-02-28 14:47:20 +00:00
|
|
|
NULL != ( pFollowRow = pRow->IsInSplitTableRow() ) &&
|
|
|
|
( !pFollowRow->IsRowSpanLine() || nRowSpan > 1 ) )
|
|
|
|
pRet = lcl_FindCorrespondingCellFrm( *((SwRowFrm*)pRow), *pThisCell, *pFollowRow, true );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
// VERSION OF GetPreviousCell() THAT ASSUMES THAT WE ALWAYS HAVE A FFL
|
2004-01-13 10:15:19 +00:00
|
|
|
SwCellFrm* SwCellFrm::GetPreviousCell() const
|
|
|
|
{
|
|
|
|
SwCellFrm* pRet = NULL;
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
// NEW TABLES
|
|
|
|
// Covered cells do not have previous cells!
|
|
|
|
if ( GetLayoutRowSpan() < 1 )
|
|
|
|
return NULL;
|
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
// find most upper row frame
|
|
|
|
const SwFrm* pRow = GetUpper();
|
|
|
|
while( !pRow->IsRowFrm() || !pRow->GetUpper()->IsTabFrm() )
|
|
|
|
pRow = pRow->GetUpper();
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pRow->GetUpper() && pRow->GetUpper()->IsTabFrm(), "GetPreviousCell without Table" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2004-05-03 12:46:43 +00:00
|
|
|
SwTabFrm* pTab = (SwTabFrm*)pRow->GetUpper();
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2004-05-03 12:46:43 +00:00
|
|
|
if ( pTab->IsFollow() )
|
2004-01-13 10:15:19 +00:00
|
|
|
{
|
2004-05-03 12:46:43 +00:00
|
|
|
const SwFrm* pTmp = pTab->GetFirstNonHeadlineRow();
|
|
|
|
const bool bIsInFirstLine = ( pTmp == pRow );
|
|
|
|
|
|
|
|
if ( bIsInFirstLine )
|
2004-01-13 10:15:19 +00:00
|
|
|
{
|
2004-05-03 12:46:43 +00:00
|
|
|
SwTabFrm *pMaster = (SwTabFrm*)pTab->FindMaster();
|
|
|
|
if ( pMaster && pMaster->HasFollowFlowLine() )
|
2004-01-13 10:15:19 +00:00
|
|
|
{
|
2006-03-09 13:06:56 +00:00
|
|
|
SwRowFrm* pMasterRow = static_cast<SwRowFrm*>(pMaster->GetLastLower());
|
2007-07-31 16:41:48 +00:00
|
|
|
if ( pMasterRow )
|
|
|
|
pRet = lcl_FindCorrespondingCellFrm( *((SwRowFrm*)pRow), *this, *pMasterRow, false );
|
2007-02-28 14:47:20 +00:00
|
|
|
if ( pRet && pRet->GetTabBox()->getRowSpan() < 1 )
|
|
|
|
pRet = &const_cast<SwCellFrm&>(pRet->FindStartEndOfRowSpanCell( true, true ));
|
2004-05-03 12:46:43 +00:00
|
|
|
}
|
2004-01-13 10:15:19 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-03 12:46:43 +00:00
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
// --> NEW TABLES
|
|
|
|
const SwCellFrm& SwCellFrm::FindStartEndOfRowSpanCell( bool bStart, bool bCurrentTableOnly ) const
|
|
|
|
{
|
|
|
|
const SwCellFrm* pRet = 0;
|
|
|
|
|
|
|
|
const SwTabFrm* pTableFrm = dynamic_cast<const SwTabFrm*>(GetUpper()->GetUpper());
|
|
|
|
|
|
|
|
if ( !bStart && pTableFrm->IsFollow() && pTableFrm->IsInHeadline( *this ) )
|
|
|
|
return *this;
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pTableFrm &&
|
2010-12-16 16:00:18 +00:00
|
|
|
( (bStart && GetTabBox()->getRowSpan() < 1) ||
|
|
|
|
(!bStart && GetLayoutRowSpan() > 1) ),
|
2010-11-25 17:08:45 +01:00
|
|
|
"SwCellFrm::FindStartRowSpanCell: No rowspan, no table, no cookies" );
|
2007-02-28 14:47:20 +00:00
|
|
|
|
|
|
|
if ( pTableFrm )
|
|
|
|
{
|
|
|
|
const SwTable* pTable = pTableFrm->GetTable();
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nMax = USHRT_MAX;
|
2007-02-28 14:47:20 +00:00
|
|
|
if ( bCurrentTableOnly )
|
|
|
|
{
|
|
|
|
const SwFrm* pCurrentRow = GetUpper();
|
2008-02-12 12:25:57 +00:00
|
|
|
const bool bDoNotEnterHeadline = bStart && pTableFrm->IsFollow() &&
|
|
|
|
!pTableFrm->IsInHeadline( *pCurrentRow );
|
2007-10-15 16:33:05 +00:00
|
|
|
|
|
|
|
// check how many rows we are allowed to go up or down until we reach the end of
|
|
|
|
// the current table frame:
|
2007-02-28 14:47:20 +00:00
|
|
|
nMax = 0;
|
|
|
|
while ( bStart ? pCurrentRow->GetPrev() : pCurrentRow->GetNext() )
|
|
|
|
{
|
2007-10-15 16:33:05 +00:00
|
|
|
if ( bStart )
|
|
|
|
{
|
2008-02-12 12:25:57 +00:00
|
|
|
// do not enter a repeated headline:
|
|
|
|
if ( bDoNotEnterHeadline && pTableFrm->IsFollow() &&
|
|
|
|
pTableFrm->IsInHeadline( *pCurrentRow->GetPrev() ) )
|
2007-10-15 16:33:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
pCurrentRow = pCurrentRow->GetPrev();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pCurrentRow = pCurrentRow->GetNext();
|
|
|
|
|
2007-02-28 14:47:20 +00:00
|
|
|
++nMax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// By passing the nMax value for Find*OfRowSpan (in case of bCurrentTableOnly
|
|
|
|
// is set) we assure that we find a rMasterBox that has a SwCellFrm in
|
|
|
|
// the current table frame:
|
|
|
|
const SwTableBox& rMasterBox = bStart ?
|
|
|
|
GetTabBox()->FindStartOfRowSpan( *pTable, nMax ) :
|
|
|
|
GetTabBox()->FindEndOfRowSpan( *pTable, nMax );
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwCellFrm,SwFmt> aIter( *rMasterBox.GetFrmFmt() );
|
2007-02-28 14:47:20 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
for ( SwCellFrm* pMasterCell = aIter.First(); pMasterCell; pMasterCell = aIter.Next() )
|
2007-02-28 14:47:20 +00:00
|
|
|
{
|
|
|
|
if ( pMasterCell->GetTabBox() == &rMasterBox )
|
|
|
|
{
|
|
|
|
const SwTabFrm* pMasterTable = static_cast<const SwTabFrm*>(pMasterCell->GetUpper()->GetUpper());
|
|
|
|
|
|
|
|
if ( bCurrentTableOnly )
|
|
|
|
{
|
|
|
|
if ( pMasterTable == pTableFrm )
|
|
|
|
{
|
|
|
|
pRet = pMasterCell;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( pMasterTable == pTableFrm ||
|
2010-09-30 15:36:19 +01:00
|
|
|
( (bStart && pMasterTable->IsAnFollow(pTableFrm)) ||
|
|
|
|
(!bStart && pTableFrm->IsAnFollow(pMasterTable)) ) )
|
2007-02-28 14:47:20 +00:00
|
|
|
{
|
|
|
|
pRet = pMasterCell;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pRet, "SwCellFrm::FindStartRowSpanCell: No result" );
|
2007-02-28 14:47:20 +00:00
|
|
|
|
|
|
|
return *pRet;
|
|
|
|
}
|
|
|
|
// <-- NEW TABLES
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
const SwRowFrm* SwFrm::IsInSplitTableRow() const
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( IsInTab(), "IsInSplitTableRow should only be called for frames in tables" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
const SwFrm* pRow = this;
|
2007-02-28 14:47:20 +00:00
|
|
|
|
|
|
|
// find most upper row frame
|
2004-01-13 10:15:19 +00:00
|
|
|
while( pRow && ( !pRow->IsRowFrm() || !pRow->GetUpper()->IsTabFrm() ) )
|
|
|
|
pRow = pRow->GetUpper();
|
|
|
|
|
|
|
|
if ( !pRow ) return NULL;
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pRow->GetUpper()->IsTabFrm(), "Confusion in table layout" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
const SwTabFrm* pTab = (SwTabFrm*)pRow->GetUpper();
|
2011-04-16 16:19:09 -03:00
|
|
|
//
|
2006-07-10 14:16:22 +00:00
|
|
|
// If most upper row frame is a headline row, the current frame
|
|
|
|
// can't be in a splitted table row. Thus, add corresponding condition.
|
2004-01-13 10:15:19 +00:00
|
|
|
if ( pRow->GetNext() ||
|
2006-07-10 14:16:22 +00:00
|
|
|
pTab->GetTable()->IsHeadline(
|
|
|
|
*(static_cast<const SwRowFrm*>(pRow)->GetTabLine()) ) ||
|
|
|
|
!pTab->HasFollowFlowLine() ||
|
|
|
|
!pTab->GetFollow() )
|
2004-01-13 10:15:19 +00:00
|
|
|
return NULL;
|
|
|
|
|
2004-05-03 12:46:43 +00:00
|
|
|
// skip headline
|
|
|
|
const SwRowFrm* pFollowRow = pTab->GetFollow()->GetFirstNonHeadlineRow();
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFollowRow, "SwFrm::IsInSplitTableRow() does not work" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
return pFollowRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwRowFrm* SwFrm::IsInFollowFlowRow() const
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( IsInTab(), "IsInSplitTableRow should only be called for frames in tables" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
// find most upper row frame
|
|
|
|
const SwFrm* pRow = this;
|
|
|
|
while( pRow && ( !pRow->IsRowFrm() || !pRow->GetUpper()->IsTabFrm() ) )
|
|
|
|
pRow = pRow->GetUpper();
|
|
|
|
|
|
|
|
if ( !pRow ) return NULL;
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pRow->GetUpper()->IsTabFrm(), "Confusion in table layout" );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
|
|
|
const SwTabFrm* pTab = (SwTabFrm*)pRow->GetUpper();
|
2004-05-03 12:46:43 +00:00
|
|
|
|
2004-01-13 10:15:19 +00:00
|
|
|
const SwTabFrm* pMaster = pTab->IsFollow() ? pTab->FindMaster() : 0;
|
|
|
|
|
2004-05-03 12:46:43 +00:00
|
|
|
if ( !pMaster || !pMaster->HasFollowFlowLine() )
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
const SwFrm* pTmp = pTab->GetFirstNonHeadlineRow();
|
|
|
|
const bool bIsInFirstLine = ( pTmp == pRow );
|
2004-01-13 10:15:19 +00:00
|
|
|
|
2004-05-03 12:46:43 +00:00
|
|
|
if ( !bIsInFirstLine )
|
2004-01-13 10:15:19 +00:00
|
|
|
return NULL;
|
|
|
|
|
2006-03-09 13:06:56 +00:00
|
|
|
const SwRowFrm* pMasterRow = static_cast<const SwRowFrm*>(pMaster->GetLastLower());
|
2004-01-13 10:15:19 +00:00
|
|
|
return pMasterRow;
|
|
|
|
}
|
|
|
|
|
2005-02-22 07:19:51 +00:00
|
|
|
bool SwFrm::IsInBalancedSection() const
|
|
|
|
{
|
|
|
|
bool bRet = false;
|
|
|
|
|
|
|
|
if ( IsInSct() )
|
|
|
|
{
|
|
|
|
const SwSectionFrm* pSectionFrm = FindSctFrm();
|
|
|
|
if ( pSectionFrm )
|
|
|
|
bRet = pSectionFrm->IsBalancedSection();
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2006-03-09 13:06:56 +00:00
|
|
|
/*
|
|
|
|
* SwLayoutFrm::GetLastLower()
|
|
|
|
*/
|
|
|
|
const SwFrm* SwLayoutFrm::GetLastLower() const
|
|
|
|
{
|
2007-09-27 08:01:45 +00:00
|
|
|
const SwFrm* pRet = Lower();
|
|
|
|
if ( !pRet )
|
2006-03-09 13:06:56 +00:00
|
|
|
return 0;
|
2007-09-27 08:01:45 +00:00
|
|
|
while ( pRet->GetNext() )
|
|
|
|
pRet = pRet->GetNext();
|
|
|
|
return pRet;
|
2006-03-09 13:06:56 +00:00
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|