Files
libreoffice/sw/source/core/layout/sectfrm.cxx

2739 lines
96 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
2000-09-18 23:08:29 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
* 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/.
2000-09-18 23:08:29 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
* This file incorporates work covered by the following license notice:
2000-09-18 23:08:29 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
* 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 <svl/smplhint.hxx>
#include <svl/itemiter.hxx>
2000-09-18 23:08:29 +00:00
#include <hints.hxx>
#include <txtftn.hxx>
#include <fmtftn.hxx>
#include <fmtclbl.hxx>
#include "sectfrm.hxx"
#include "section.hxx" // SwSection
#include "frmtool.hxx" // StackHack
#include "doc.hxx" // SwDoc
#include "cntfrm.hxx" // SwCntntFrm
#include "rootfrm.hxx" // SwRootFrm
#include "pagefrm.hxx" // SwPageFrm
#include "fmtpdsc.hxx" // SwFmtPageDesc
#include "fmtcntnt.hxx" // SwFmtCntnt
#include "ndindex.hxx" // SwNodeIndex
#include "ftnidx.hxx"
#include "txtfrm.hxx" // SwTxtFrm
#include "fmtclds.hxx" // SwFmtCol
#include "colfrm.hxx" // SwColumnFrm
#include "tabfrm.hxx" // SwTabFrm
#include "flyfrm.hxx" // SwFlyFrm
#include "ftnfrm.hxx" // SwFtnFrm
#include "layouter.hxx" // SwLayouter
#include "dbg_lay.hxx"
#include "viewsh.hxx"
#include "viewopt.hxx"
#include "viewimp.hxx"
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/brshitem.hxx>
2000-09-18 23:08:29 +00:00
#include <fmtftntx.hxx>
// OD 2004-05-24 #i28701#
#include <dflyobj.hxx>
#include <flyfrms.hxx>
#include <sortedobjs.hxx>
2000-09-18 23:08:29 +00:00
/*************************************************************************
|*
|* SwSectionFrm::SwSectionFrm(), ~SwSectionFrm()
|*
|*************************************************************************/
SwSectionFrm::SwSectionFrm( SwSection &rSect, SwFrm* pSib )
: SwLayoutFrm( rSect.GetFmt(), pSib )
, SwFlowFrm( static_cast<SwFrm&>(*this) )
, pSection( &rSect )
, bFtnAtEnd(false)
, bEndnAtEnd(false)
, bCntntLock(false)
, bOwnFtnNum(false)
, bFtnLock(false)
2000-09-18 23:08:29 +00:00
{
nType = FRMC_SECTION;
2000-09-18 23:08:29 +00:00
CalcFtnAtEndFlag();
CalcEndAtEndFlag();
}
SwSectionFrm::SwSectionFrm( SwSectionFrm &rSect, sal_Bool bMaster ) :
SwLayoutFrm( rSect.GetFmt(), rSect.getRootFrm() ),
2000-09-18 23:08:29 +00:00
SwFlowFrm( (SwFrm&)*this ),
pSection( rSect.GetSection() ),
bFtnAtEnd( rSect.IsFtnAtEnd() ),
bEndnAtEnd( rSect.IsEndnAtEnd() ),
bCntntLock( false ),
bOwnFtnNum( false ),
bFtnLock( false )
2000-09-18 23:08:29 +00:00
{
nType = FRMC_SECTION;
2000-09-18 23:08:29 +00:00
PROTOCOL( this, PROT_SECTION, bMaster ? ACT_CREATE_MASTER : ACT_CREATE_FOLLOW, &rSect )
if( bMaster )
{
if( rSect.IsFollow() )
{
SwSectionFrm* pMaster = rSect.FindMaster();
2000-09-18 23:08:29 +00:00
pMaster->SetFollow( this );
}
SetFollow( &rSect );
}
else
{
SetFollow( rSect.GetFollow() );
rSect.SetFollow( this );
if( !GetFollow() )
rSect.SimpleFormat();
if( !rSect.IsColLocked() )
rSect.InvalidateSize();
}
2001-11-13 14:21:55 +00:00
}
// NOTE: call <SwSectionFrm::Init()> directly after creation of a new section
// frame and its insert in the layout.
2001-11-13 14:21:55 +00:00
void SwSectionFrm::Init()
{
OSL_ENSURE( GetUpper(), "SwSectionFrm::Init before insertion?!" );
2001-11-13 14:21:55 +00:00
SWRECTFN( this )
long nWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
(Frm().*fnRect->fnSetWidth)( nWidth );
(Frm().*fnRect->fnSetHeight)( 0 );
// #109700# LRSpace for sections
const SvxLRSpaceItem& rLRSpace = GetFmt()->GetLRSpace();
(Prt().*fnRect->fnSetLeft)( rLRSpace.GetLeft() );
(Prt().*fnRect->fnSetWidth)( nWidth - rLRSpace.GetLeft() -
rLRSpace.GetRight() );
2001-11-13 14:21:55 +00:00
(Prt().*fnRect->fnSetHeight)( 0 );
2001-11-13 14:21:55 +00:00
const SwFmtCol &rCol = GetFmt()->GetCol();
if( ( rCol.GetNumCols() > 1 || IsAnyNoteAtEnd() ) && !IsInFtn() )
{
const SwFmtCol *pOld = Lower() ? &rCol : new SwFmtCol;
ChgColumns( *pOld, rCol, IsAnyNoteAtEnd() );
if( pOld != &rCol )
delete pOld;
}
2000-09-18 23:08:29 +00:00
}
SwSectionFrm::~SwSectionFrm()
{
if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
{
SwRootFrm *pRootFrm = getRootFrm();
2000-09-18 23:08:29 +00:00
if( pRootFrm )
pRootFrm->RemoveFromList( this ); //swmod 071108//swmod 071225
2000-09-18 23:08:29 +00:00
if( IsFollow() )
{
SwSectionFrm *pMaster = FindMaster();
2000-09-18 23:08:29 +00:00
if( pMaster )
{
PROTOCOL( this, PROT_SECTION, ACT_DEL_FOLLOW, pMaster )
pMaster->SetFollow( GetFollow() );
2012-02-16 12:01:24 +01:00
// A Master always grabs the space until the lower edge of his
// Upper. If he doesn't have a Follow anymore, he can
// release it, which is why the Size of the Master is
// invalidated.
2000-09-18 23:08:29 +00:00
if( !GetFollow() )
pMaster->InvalidateSize();
}
}
else if( HasFollow() )
{
PROTOCOL( this, PROT_SECTION, ACT_DEL_MASTER, GetFollow() )
}
}
}
/*************************************************************************
|*
|* SwSectionFrm::DelEmpty()
|*
|*************************************************************************/
void SwSectionFrm::DelEmpty( sal_Bool bRemove )
2000-09-18 23:08:29 +00:00
{
if( IsColLocked() )
{
OSL_ENSURE( !bRemove, "Don't delete locked SectionFrms" );
2000-09-18 23:08:29 +00:00
return;
}
SwFrm* pUp = GetUpper();
if( pUp )
{
// #i27138#
// notify accessibility paragraphs objects about changed
// CONTENT_FLOWS_FROM/_TO relation.
// Relation CONTENT_FLOWS_FROM for current next paragraph will change
// and relation CONTENT_FLOWS_TO for current previous paragraph will change.
{
ViewShell* pViewShell( getRootFrm()->GetCurrShell() );
if ( pViewShell && pViewShell->GetLayout() &&
pViewShell->GetLayout()->IsAnyShellAccessible() )
{
pViewShell->InvalidateAccessibleParaFlowRelation(
dynamic_cast<SwTxtFrm*>(FindNextCnt( true )),
dynamic_cast<SwTxtFrm*>(FindPrevCnt( true )) );
}
}
2000-09-18 23:08:29 +00:00
_Cut( bRemove );
}
2000-09-18 23:08:29 +00:00
if( IsFollow() )
{
SwSectionFrm *pMaster = FindMaster();
2000-09-18 23:08:29 +00:00
pMaster->SetFollow( GetFollow() );
2012-02-16 12:01:24 +01:00
// A Master always grabs the space until the lower edge of his
// Upper. If he doesn't have a Follow anymore, he can
// release it, which is why the Size of the Master is
// invalidated.
2000-09-18 23:08:29 +00:00
if( !GetFollow() && !pMaster->IsColLocked() )
pMaster->InvalidateSize();
}
SetFollow(0);
2000-09-18 23:08:29 +00:00
if( pUp )
{
Frm().Height( 0 );
2012-02-16 12:01:24 +01:00
// If we are destroyed immediately anyway, we don't need
// to put us into the list
2000-09-18 23:08:29 +00:00
if( bRemove )
2012-02-16 12:01:24 +01:00
{ // If we already were half dead before this DelEmpty,
// we are likely in the list and have to remove us from
// it
if( !pSection && getRootFrm() )
getRootFrm()->RemoveFromList( this );
2000-09-18 23:08:29 +00:00
}
else if( getRootFrm() )
getRootFrm()->InsertEmptySct( this ); //swmod 071108//swmod 071225
2012-02-16 12:01:24 +01:00
pSection = NULL; // like this a reanimation is virtually impossible though
2000-09-18 23:08:29 +00:00
}
}
/*************************************************************************
|*
|* SwSectionFrm::Cut()
|*
|*************************************************************************/
void SwSectionFrm::Cut()
{
_Cut( sal_True );
2000-09-18 23:08:29 +00:00
}
void SwSectionFrm::_Cut( sal_Bool bRemove )
2000-09-18 23:08:29 +00:00
{
OSL_ENSURE( GetUpper(), "Cut ohne Upper()." );
2000-09-18 23:08:29 +00:00
PROTOCOL( this, PROT_CUT, 0, GetUpper() )
SwPageFrm *pPage = FindPageFrm();
InvalidatePage( pPage );
SwFrm *pFrm = GetNext();
SwFrm* pPrepFrm = NULL;
while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
pFrm = pFrm->GetNext();
if( pFrm )
2012-02-16 12:01:24 +01:00
{ // The former successor might have calculated a gap to the predecessor
// which is now obsolete since he becomes the first
2000-09-18 23:08:29 +00:00
pFrm->_InvalidatePrt();
pFrm->_InvalidatePos();
if( pFrm->IsSctFrm() )
pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
if ( pFrm && pFrm->IsCntntFrm() )
{
pFrm->InvalidatePage( pPage );
if( IsInFtn() && !GetIndPrev() )
pPrepFrm = pFrm;
}
}
else
{
InvalidateNextPos();
2012-02-16 12:01:24 +01:00
// Someone has to take over the retouching: predecessor or Upper
2000-09-18 23:08:29 +00:00
if ( 0 != (pFrm = GetPrev()) )
{ pFrm->SetRetouche();
pFrm->Prepare( PREP_WIDOWS_ORPHANS );
if ( pFrm->IsCntntFrm() )
pFrm->InvalidatePage( pPage );
}
2012-02-16 12:01:24 +01:00
// If I am (was) the only FlowFrm in my Upper, then he has to take over
// the retouching.
// Furthermore a blank page could have emerged
2000-09-18 23:08:29 +00:00
else
{ SwRootFrm *pRoot = (SwRootFrm*)pPage->GetUpper();
pRoot->SetSuperfluous();
GetUpper()->SetCompletePaint();
}
}
2012-02-16 12:01:24 +01:00
// First remove, then shrink Upper
2000-09-18 23:08:29 +00:00
SwLayoutFrm *pUp = GetUpper();
if( bRemove )
{
Remove();
if( pUp && !pUp->Lower() && pUp->IsFtnFrm() && !pUp->IsColLocked() &&
pUp->GetUpper() )
{
pUp->Cut();
delete pUp;
pUp = NULL;
}
}
if( pPrepFrm )
pPrepFrm->Prepare( PREP_FTN );
if ( pUp )
{
2001-11-09 12:32:26 +00:00
SWRECTFN( this );
SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if( nFrmHeight > 0 )
{
if( !bRemove )
{
(Frm().*fnRect->fnSetHeight)( 0 );
(Prt().*fnRect->fnSetHeight)( 0 );
}
pUp->Shrink( nFrmHeight );
}
2000-09-18 23:08:29 +00:00
}
}
/*************************************************************************
|*
|* SwSectionFrm::Paste()
|*
|*************************************************************************/
void SwSectionFrm::Paste( SwFrm* pParent, SwFrm* pSibling )
{
OSL_ENSURE( pParent, "Kein Parent fuer Paste." );
OSL_ENSURE( pParent->IsLayoutFrm(), "Parent ist CntntFrm." );
OSL_ENSURE( pParent != this, "Bin selbst der Parent." );
OSL_ENSURE( pSibling != this, "Bin mein eigener Nachbar." );
OSL_ENSURE( !GetPrev() && !GetUpper(),
2000-09-18 23:08:29 +00:00
"Bin noch irgendwo angemeldet." );
PROTOCOL( this, PROT_PASTE, 0, GetUpper() )
2012-02-16 12:01:24 +01:00
// Add to the tree
2000-09-18 23:08:29 +00:00
SwSectionFrm* pSect = pParent->FindSctFrm();
2011-04-18 12:37:38 -03:00
// #156927#
// Assure that parent is not inside a table frame, which is inside the found section frame.
if ( pSect )
{
SwTabFrm* pTableFrm = pParent->FindTabFrm();
if ( pTableFrm &&
pSect->IsAnLower( pTableFrm ) )
{
pSect = 0;
}
}
2001-11-09 12:32:26 +00:00
SWRECTFN( pParent )
2000-09-18 23:08:29 +00:00
if( pSect && HasToBreak( pSect ) )
{
2012-02-16 12:01:24 +01:00
if( pParent->IsColBodyFrm() ) // dealing with a single-column area
2000-09-18 23:08:29 +00:00
{
2012-02-16 12:01:24 +01:00
// If we are coincidentally at the end of a column, pSibling
// has to point to the first frame of the next column in order
// for the content of the next column to be moved correctly to the
// newly created pSect by the InsertGroup
2000-09-18 23:08:29 +00:00
SwColumnFrm *pCol = (SwColumnFrm*)pParent->GetUpper();
while( !pSibling && 0 != ( pCol = (SwColumnFrm*)pCol->GetNext() ) )
pSibling = ((SwLayoutFrm*)((SwColumnFrm*)pCol)->Lower())->Lower();
if( pSibling )
{
2012-02-16 12:01:24 +01:00
// Even worse: every following column content has to
// be attached to the pSibling-chain in order to be
// taken along
2000-09-18 23:08:29 +00:00
SwFrm *pTmp = pSibling;
while ( 0 != ( pCol = (SwColumnFrm*)pCol->GetNext() ) )
{
while ( pTmp->GetNext() )
pTmp = pTmp->GetNext();
SwFrm* pSave = ::SaveCntnt( pCol );
::RestoreCntnt( pSave, pSibling->GetUpper(), pTmp, true );
2000-09-18 23:08:29 +00:00
}
}
}
pParent = pSect;
pSect = new SwSectionFrm( *((SwSectionFrm*)pParent)->GetSection(), pParent );
2012-02-16 12:01:24 +01:00
// if pParent is decomposed into two parts, its Follow has to be attached
// to the new second part
2000-09-18 23:08:29 +00:00
pSect->SetFollow( ((SwSectionFrm*)pParent)->GetFollow() );
((SwSectionFrm*)pParent)->SetFollow( NULL );
if( pSect->GetFollow() )
pParent->_InvalidateSize();
InsertGroupBefore( pParent, pSibling, pSect );
pSect->Init();
(pSect->*fnRect->fnMakePos)( pSect->GetUpper(), pSect->GetPrev(), sal_True);
2000-09-18 23:08:29 +00:00
if( !((SwLayoutFrm*)pParent)->Lower() )
{
SwSectionFrm::MoveCntntAndDelete( (SwSectionFrm*)pParent, sal_False );
2000-09-18 23:08:29 +00:00
pParent = this;
}
}
else
InsertGroupBefore( pParent, pSibling, NULL );
_InvalidateAll();
SwPageFrm *pPage = FindPageFrm();
InvalidatePage( pPage );
if ( pSibling )
{
pSibling->_InvalidatePos();
pSibling->_InvalidatePrt();
if ( pSibling->IsCntntFrm() )
pSibling->InvalidatePage( pPage );
}
2001-11-09 12:32:26 +00:00
SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if( nFrmHeight )
pParent->Grow( nFrmHeight );
2000-09-18 23:08:29 +00:00
if ( GetPrev() )
{
if ( !IsFollow() )
{
GetPrev()->InvalidateSize();
if ( GetPrev()->IsCntntFrm() )
GetPrev()->InvalidatePage( pPage );
}
}
}
/*************************************************************************
|*
|* SwSectionFrm::HasToBreak()
|*
2012-02-16 12:01:24 +01:00
|* Here it's decided whether the this-SectionFrm should break up
|* the passed (Section)frm (or not).
|* Initiall, all superior sections are broken up. Later on that could
|* be made configurable.
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
sal_Bool SwSectionFrm::HasToBreak( const SwFrm* pFrm ) const
2000-09-18 23:08:29 +00:00
{
if( !pFrm->IsSctFrm() )
return sal_False;
2000-09-18 23:08:29 +00:00
SwSectionFmt *pTmp = (SwSectionFmt*)GetFmt();
// if( !pTmp->GetSect().GetValue() )
// return sal_False;
2000-09-18 23:08:29 +00:00
const SwFrmFmt *pOtherFmt = ((SwSectionFrm*)pFrm)->GetFmt();
do
{
pTmp = pTmp->GetParent();
if( !pTmp )
return sal_False;
2000-09-18 23:08:29 +00:00
if( pTmp == pOtherFmt )
return sal_True;
} while( true ); // ( pTmp->GetSect().GetValue() );
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwSectionFrm::MergeNext()
|*
2012-02-16 12:01:24 +01:00
|* Merges two SectionFrms, in case it's about the same section.
|* This can be necessary when a (sub)section is deleted that had
|* divided another part into two.
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
void SwSectionFrm::MergeNext( SwSectionFrm* pNxt )
{
if( !pNxt->IsJoinLocked() && GetSection() == pNxt->GetSection() )
{
PROTOCOL( this, PROT_SECTION, ACT_MERGE, pNxt )
SwFrm* pTmp = ::SaveCntnt( pNxt );
if( pTmp )
{
SwFrm* pLast = Lower();
SwLayoutFrm* pLay = this;
if( pLast )
{
while( pLast->GetNext() )
pLast = pLast->GetNext();
if( pLast->IsColumnFrm() )
2012-02-16 12:01:24 +01:00
{ // Columns now with BodyFrm
2000-09-18 23:08:29 +00:00
pLay = (SwLayoutFrm*)((SwLayoutFrm*)pLast)->Lower();
pLast = pLay->Lower();
if( pLast )
while( pLast->GetNext() )
pLast = pLast->GetNext();
}
}
::RestoreCntnt( pTmp, pLay, pLast, true );
2000-09-18 23:08:29 +00:00
}
SetFollow( pNxt->GetFollow() );
pNxt->SetFollow( NULL );
pNxt->Cut();
delete pNxt;
InvalidateSize();
}
}
/*************************************************************************
|*
|* SwSectionFrm::SplitSect()
|*
2012-02-16 12:01:24 +01:00
|* Divides a SectionFrm into two parts. The second one starts with the
|* passed frame.
|* This is required when inserting an inner section, because the MoveFwd
|* cannot have the desired effect within a frame or a table cell.
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
sal_Bool SwSectionFrm::SplitSect( SwFrm* pFrm, sal_Bool bApres )
2000-09-18 23:08:29 +00:00
{
OSL_ENSURE( pFrm, "SplitSect: Why?" );
2000-09-18 23:08:29 +00:00
SwFrm* pOther = bApres ? pFrm->FindNext() : pFrm->FindPrev();
if( !pOther )
return sal_False;
2000-09-18 23:08:29 +00:00
SwSectionFrm* pSect = pOther->FindSctFrm();
2001-11-22 14:03:19 +00:00
if( pSect != this )
return sal_False;
2012-02-16 12:01:24 +01:00
// Put the content aside
2000-09-18 23:08:29 +00:00
SwFrm* pSav = ::SaveCntnt( this, bApres ? pOther : pFrm );
OSL_ENSURE( pSav, "SplitSect: What's on?" );
2012-02-16 12:01:24 +01:00
if( pSav ) // be robust
{ // Create a new SctFrm, not as a Follower/master
SwSectionFrm* pNew = new SwSectionFrm( *pSect->GetSection(), pSect );
2000-09-18 23:08:29 +00:00
pNew->InsertBehind( pSect->GetUpper(), pSect );
pNew->Init();
2001-11-22 14:03:19 +00:00
SWRECTFN( this )
(pNew->*fnRect->fnMakePos)( NULL, pSect, sal_True );
// OD 25.03.2003 #108339# - restore content:
// determine layout frame for restoring content after the initialization
// of the section frame. In the section initialization the columns are
// created.
{
SwLayoutFrm* pLay = pNew;
// Search for last layout frame, e.g. for columned sections.
while( pLay->Lower() && pLay->Lower()->IsLayoutFrm() )
pLay = (SwLayoutFrm*)pLay->Lower();
::RestoreCntnt( pSav, pLay, NULL, true );
}
2001-11-22 14:03:19 +00:00
_InvalidateSize();
if( HasFollow() )
{
pNew->SetFollow( GetFollow() );
SetFollow( NULL );
}
return sal_True;
2000-09-18 23:08:29 +00:00
}
return sal_False;
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwSectionFrm::MoveCntntAndDelete()
|*
2012-02-16 12:01:24 +01:00
|* MoveCntnt is called for destroying a SectionFrms, due to
|* the cancellation or hiding of a section, to handle the content.
|* If the SectionFrm hasn't broken up another one, then the content
|* is moved to the Upper. Otherwise the content is moved to another
|* SectionFrm, which has to be potentially merged.
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
2012-02-16 12:01:24 +01:00
// If a multi-column section is cancelled, the ContentFrms have to be
// invalidated
2000-09-18 23:08:29 +00:00
static void lcl_InvalidateInfFlags( SwFrm* pFrm, bool bInva )
2000-09-18 23:08:29 +00:00
{
while ( pFrm )
{
pFrm->InvalidateInfFlags();
if( bInva )
{
pFrm->_InvalidatePos();
pFrm->_InvalidateSize();
pFrm->_InvalidatePrt();
}
if( pFrm->IsLayoutFrm() )
lcl_InvalidateInfFlags( ((SwLayoutFrm*)pFrm)->GetLower(), sal_False );
2000-09-18 23:08:29 +00:00
pFrm = pFrm->GetNext();
}
}
//
// Works like SwCntntFrm::ImplGetNextCntntFrm, but starts with a LayoutFrm
//
static SwCntntFrm* lcl_GetNextCntntFrm( const SwLayoutFrm* pLay, bool bFwd )
{
if ( bFwd )
{
if ( pLay->GetNext() && pLay->GetNext()->IsCntntFrm() )
return (SwCntntFrm*)pLay->GetNext();
}
else
{
if ( pLay->GetPrev() && pLay->GetPrev()->IsCntntFrm() )
return (SwCntntFrm*)pLay->GetPrev();
}
// #100926#
const SwFrm* pFrm = pLay;
SwCntntFrm *pCntntFrm = 0;
bool bGoingUp = true;
do {
const SwFrm *p = 0;
bool bGoingFwdOrBwd = false;
bool bGoingDown = !bGoingUp && ( 0 != ( p = pFrm->IsLayoutFrm() ? ((SwLayoutFrm*)pFrm)->Lower() : 0 ) );
if ( !bGoingDown )
{
bGoingFwdOrBwd = ( 0 != ( p = pFrm->IsFlyFrm() ?
( bFwd ? ((SwFlyFrm*)pFrm)->GetNextLink() : ((SwFlyFrm*)pFrm)->GetPrevLink() ) :
( bFwd ? pFrm->GetNext() :pFrm->GetPrev() ) ) );
if ( !bGoingFwdOrBwd )
{
bGoingUp = (0 != (p = pFrm->GetUpper() ) );
if ( !bGoingUp )
return 0;
}
}
bGoingUp = !( bGoingFwdOrBwd || bGoingDown );
if( !bFwd && bGoingDown && p )
while ( p->GetNext() )
p = p->GetNext();
pFrm = p;
} while ( 0 == (pCntntFrm = (pFrm->IsCntntFrm() ? (SwCntntFrm*)pFrm:0) ));
return pCntntFrm;
}
2000-09-18 23:08:29 +00:00
#define FIRSTLEAF( pLayFrm ) ( ( pLayFrm->Lower() && pLayFrm->Lower()->IsColumnFrm() )\
? pLayFrm->GetNextLayoutLeaf() \
: pLayFrm )
void SwSectionFrm::MoveCntntAndDelete( SwSectionFrm* pDel, sal_Bool bSave )
2000-09-18 23:08:29 +00:00
{
bool bSize = pDel->Lower() && pDel->Lower()->IsColumnFrm();
2000-09-18 23:08:29 +00:00
SwFrm* pPrv = pDel->GetPrev();
SwLayoutFrm* pUp = pDel->GetUpper();
// OD 27.03.2003 #i12711# - initialize local pointer variables.
SwSectionFrm* pPrvSct = NULL;
SwSectionFrm* pNxtSct = NULL;
SwSectionFmt* pParent = static_cast<SwSectionFmt*>(pDel->GetFmt())->GetParent();
2000-09-18 23:08:29 +00:00
if( pDel->IsInTab() && pParent )
{
SwTabFrm *pTab = pDel->FindTabFrm();
2012-02-16 12:01:24 +01:00
// If we are within a table, we can only have broken up sections that
// are inside as well, but not a section that contains the whole table.
2000-09-18 23:08:29 +00:00
if( pTab->IsInSct() && pParent == pTab->FindSctFrm()->GetFmt() )
pParent = NULL;
}
2012-02-16 12:01:24 +01:00
// If our Format has a parent, we have probably broken up another
// SectionFrm, which has to be checked. To do so we first acquire the
// succeeding and the preceding CntntFrm, let's see if they
// lay in the SectionFrms.
// OD 27.03.2003 #i12711# - check, if previous and next section belonging
// together and can be joined, *not* only if deleted section contains content.
if ( pParent )
2000-09-18 23:08:29 +00:00
{
SwFrm* pPrvCntnt = lcl_GetNextCntntFrm( pDel, false );
2000-09-18 23:08:29 +00:00
pPrvSct = pPrvCntnt ? pPrvCntnt->FindSctFrm() : NULL;
SwFrm* pNxtCntnt = lcl_GetNextCntntFrm( pDel, true );
pNxtSct = pNxtCntnt ? pNxtCntnt->FindSctFrm() : NULL;
2000-09-18 23:08:29 +00:00
}
else
{
pParent = NULL;
pPrvSct = pNxtSct = NULL;
}
2012-02-16 12:01:24 +01:00
// Now the content is put aside and the frame is destroyed
2000-09-18 23:08:29 +00:00
SwFrm *pSave = bSave ? ::SaveCntnt( pDel ) : NULL;
sal_Bool bOldFtn = sal_True;
2000-09-18 23:08:29 +00:00
if( pSave && pUp->IsFtnFrm() )
{
bOldFtn = ((SwFtnFrm*)pUp)->IsColLocked();
((SwFtnFrm*)pUp)->ColLock();
}
pDel->DelEmpty( sal_True );
2000-09-18 23:08:29 +00:00
delete pDel;
if( pParent )
2012-02-16 12:01:24 +01:00
{ // Search for the appropriate insert position
2000-09-18 23:08:29 +00:00
if( pNxtSct && pNxtSct->GetFmt() == pParent )
2012-02-16 12:01:24 +01:00
{ // Here we can insert outselves at the beginning
2000-09-18 23:08:29 +00:00
pUp = FIRSTLEAF( pNxtSct );
pPrv = NULL;
if( pPrvSct && !( pPrvSct->GetFmt() == pParent ) )
2012-02-16 12:01:24 +01:00
pPrvSct = NULL; // In order that nothing is merged
2000-09-18 23:08:29 +00:00
}
else if( pPrvSct && pPrvSct->GetFmt() == pParent )
2012-02-16 12:01:24 +01:00
{ // Wonderful, here we can insert ourselves at the end
2000-09-18 23:08:29 +00:00
pUp = pPrvSct;
if( pUp->Lower() && pUp->Lower()->IsColumnFrm() )
{
pUp = static_cast<SwLayoutFrm*>(pUp->GetLastLower());
2012-02-16 12:01:24 +01:00
// The body of the last column
pUp = static_cast<SwLayoutFrm*>(pUp->Lower());
2000-09-18 23:08:29 +00:00
}
2012-02-16 12:01:24 +01:00
// In order to perform the insertion after the last one
pPrv = pUp->GetLastLower();
2012-02-16 12:01:24 +01:00
pPrvSct = NULL; // Such that nothing is merged
2000-09-18 23:08:29 +00:00
}
else
{
if( pSave )
2012-02-16 12:01:24 +01:00
{ // Following situations: before and after the section-to-be
// deleted there is the section boundary of the enclosing
// section, or another (sibling) section connects subsequently,
// that derives from the same Parent.
// In that case, there's not (yet) a part of our parent available
// that can store the content, so we create it here.
pPrvSct = new SwSectionFrm( *pParent->GetSection(), pUp );
2000-09-18 23:08:29 +00:00
pPrvSct->InsertBehind( pUp, pPrv );
pPrvSct->Init();
2001-11-09 12:32:26 +00:00
SWRECTFN( pUp )
(pPrvSct->*fnRect->fnMakePos)( pUp, pPrv, sal_True );
2000-09-18 23:08:29 +00:00
pUp = FIRSTLEAF( pPrvSct );
pPrv = NULL;
}
2012-02-16 12:01:24 +01:00
pPrvSct = NULL; // Such that nothing will be merged
2000-09-18 23:08:29 +00:00
}
}
2012-02-16 12:01:24 +01:00
// The content is going to be inserted..
2000-09-18 23:08:29 +00:00
if( pSave )
{
lcl_InvalidateInfFlags( pSave, bSize );
::RestoreCntnt( pSave, pUp, pPrv, true );
2000-09-18 23:08:29 +00:00
pUp->FindPageFrm()->InvalidateCntnt();
if( !bOldFtn )
((SwFtnFrm*)pUp)->ColUnlock();
}
2012-02-16 12:01:24 +01:00
// Now two parts of the superior section could possibly be merged
2000-09-18 23:08:29 +00:00
if( pPrvSct && !pPrvSct->IsJoinLocked() )
{
OSL_ENSURE( pNxtSct, "MoveCntnt: No Merge" );
2000-09-18 23:08:29 +00:00
pPrvSct->MergeNext( pNxtSct );
}
}
void SwSectionFrm::MakeAll()
{
if ( IsJoinLocked() || IsColLocked() || StackHack::IsLocked() || StackHack::Count() > 50 )
return;
2012-02-16 12:01:24 +01:00
if( !pSection ) // Via DelEmpty
2000-09-18 23:08:29 +00:00
{
#ifdef DBG_UTIL
Merge commit 'ooo/DEV300_m103' Conflicts: sw/inc/calbck.hxx sw/inc/crsrsh.hxx sw/inc/dcontact.hxx sw/inc/doc.hxx sw/inc/docufld.hxx sw/inc/editsh.hxx sw/inc/expfld.hxx sw/inc/fchrfmt.hxx sw/inc/fmtcol.hxx sw/inc/fmthdft.hxx sw/inc/fmtpdsc.hxx sw/inc/format.hxx sw/inc/frmfmt.hxx sw/inc/ndhints.hxx sw/inc/ndtxt.hxx sw/inc/node.hxx sw/inc/numrule.hxx sw/inc/paratr.hxx sw/inc/swtable.hxx sw/inc/unocrsr.hxx sw/inc/unofield.hxx sw/inc/unoframe.hxx sw/inc/unoport.hxx sw/inc/unostyle.hxx sw/inc/usrfld.hxx sw/inc/viewopt.hxx sw/inc/viewsh.hxx sw/source/core/access/accframebase.cxx sw/source/core/access/accmap.cxx sw/source/core/access/accnotextframe.cxx sw/source/core/access/accpara.cxx sw/source/core/access/accpara.hxx sw/source/core/attr/calbck.cxx sw/source/core/crsr/callnk.cxx sw/source/core/crsr/crsrsh.cxx sw/source/core/doc/acmplwrd.cxx sw/source/core/doc/doc.cxx sw/source/core/doc/docdesc.cxx sw/source/core/doc/docdraw.cxx sw/source/core/doc/docfly.cxx sw/source/core/doc/docfmt.cxx sw/source/core/doc/doclay.cxx sw/source/core/doc/docnew.cxx sw/source/core/doc/docnum.cxx sw/source/core/doc/doctxm.cxx sw/source/core/doc/fmtcol.cxx sw/source/core/doc/htmltbl.cxx sw/source/core/doc/number.cxx sw/source/core/docnode/ndsect.cxx sw/source/core/docnode/ndtbl.cxx sw/source/core/docnode/node.cxx sw/source/core/docnode/node2lay.cxx sw/source/core/docnode/section.cxx sw/source/core/docnode/swbaslnk.cxx sw/source/core/draw/dcontact.cxx sw/source/core/draw/dview.cxx sw/source/core/edit/autofmt.cxx sw/source/core/edit/editsh.cxx sw/source/core/edit/edlingu.cxx sw/source/core/fields/authfld.cxx sw/source/core/fields/dbfld.cxx sw/source/core/fields/docufld.cxx sw/source/core/fields/expfld.cxx sw/source/core/fields/reffld.cxx sw/source/core/fields/tblcalc.cxx sw/source/core/frmedt/fefly1.cxx sw/source/core/frmedt/feshview.cxx sw/source/core/frmedt/tblsel.cxx sw/source/core/inc/flyfrm.hxx sw/source/core/inc/prevwpage.hxx sw/source/core/inc/rolbck.hxx sw/source/core/inc/txtfrm.hxx sw/source/core/layout/atrfrm.cxx sw/source/core/layout/findfrm.cxx sw/source/core/layout/flowfrm.cxx sw/source/core/layout/fly.cxx sw/source/core/layout/flycnt.cxx sw/source/core/layout/flylay.cxx sw/source/core/layout/frmtool.cxx sw/source/core/layout/hffrm.cxx sw/source/core/layout/pagechg.cxx sw/source/core/layout/pagedesc.cxx sw/source/core/layout/paintfrm.cxx sw/source/core/layout/sectfrm.cxx sw/source/core/layout/ssfrm.cxx sw/source/core/layout/tabfrm.cxx sw/source/core/layout/wsfrm.cxx sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx sw/source/core/table/swtable.cxx sw/source/core/text/EnhancedPDFExportHelper.cxx sw/source/core/text/inftxt.cxx sw/source/core/text/porfld.cxx sw/source/core/text/txtdrop.cxx sw/source/core/text/txtfly.cxx sw/source/core/text/txtfrm.cxx sw/source/core/text/txtio.cxx sw/source/core/text/txttab.cxx sw/source/core/tox/tox.cxx sw/source/core/txtnode/atrflyin.cxx sw/source/core/txtnode/fmtatr2.cxx sw/source/core/txtnode/ndtxt.cxx sw/source/core/undo/SwUndoPageDesc.cxx sw/source/core/undo/undraw.cxx sw/source/core/unocore/unochart.cxx sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unodraw.cxx sw/source/core/unocore/unofield.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unoftn.cxx sw/source/core/unocore/unoidx.cxx sw/source/core/unocore/unoobj2.cxx sw/source/core/unocore/unoparagraph.cxx sw/source/core/unocore/unoport.cxx sw/source/core/unocore/unoportenum.cxx sw/source/core/unocore/unoredline.cxx sw/source/core/unocore/unoredlines.cxx sw/source/core/unocore/unorefmk.cxx sw/source/core/unocore/unosect.cxx sw/source/core/unocore/unosett.cxx sw/source/core/unocore/unostyle.cxx sw/source/core/unocore/unotbl.cxx sw/source/core/unocore/unotext.cxx sw/source/core/view/viewimp.cxx sw/source/core/view/viewpg.cxx sw/source/core/view/viewsh.cxx sw/source/core/view/vnew.cxx sw/source/core/view/vprint.cxx sw/source/filter/ww8/rtfexport.cxx sw/source/filter/ww8/rtfexport.hxx sw/source/filter/ww8/wrtw8nds.cxx sw/source/filter/ww8/wrtww8gr.cxx sw/source/filter/xml/XMLRedlineImportHelper.cxx sw/source/ui/app/apphdl.cxx sw/source/ui/app/docsh.cxx sw/source/ui/app/docsh2.cxx sw/source/ui/app/swmodul1.cxx sw/source/ui/config/viewopt.cxx sw/source/ui/fldui/fldpage.cxx sw/source/ui/uiview/srcview.cxx sw/source/ui/uiview/view.cxx sw/source/ui/uno/unotxdoc.cxx sw/source/ui/vba/wordvbahelper.cxx sw/source/ui/wrtsh/wrtsh1.cxx
2011-03-23 17:00:12 +01:00
OSL_ENSURE( getRootFrm()->IsInDelList( this ), "SectionFrm without Section" );
#endif
2000-09-18 23:08:29 +00:00
if( !bValidPos )
{
2001-11-09 12:32:26 +00:00
if( GetUpper() )
{
SWRECTFN( GetUpper() )
(this->*fnRect->fnMakePos)( GetUpper(), GetPrev(), sal_False );
2001-11-09 12:32:26 +00:00
}
2000-09-18 23:08:29 +00:00
}
bValidSize = bValidPos = bValidPrtArea = sal_True;
2000-09-18 23:08:29 +00:00
return;
}
2012-02-16 12:01:24 +01:00
LockJoin(); // I don't let myself to be destroyed on the way
2000-09-18 23:08:29 +00:00
while( GetNext() && GetNext() == GetFollow() )
{
const SwFrm* pFoll = GetFollow();
MergeNext( (SwSectionFrm*)GetNext() );
if( pFoll == GetFollow() )
break;
}
// OD 2004-03-15 #116561# - In online layout join the follows, if section
// can grow.
const ViewShell *pSh = getRootFrm()->GetCurrShell();
if( pSh && pSh->GetViewOptions()->getBrowseMode() &&
( Grow( LONG_MAX, true ) > 0 ) )
{
while( GetFollow() )
{
const SwFrm* pFoll = GetFollow();
MergeNext( GetFollow() );
if( pFoll == GetFollow() )
break;
}
}
2012-02-16 12:01:24 +01:00
// A section with Follow uses all the space until the lower edge of the
// Upper. If it moves, its size can grow or decrease...
if( !bValidPos && ToMaximize( sal_False ) )
bValidSize = sal_False;
2000-09-18 23:08:29 +00:00
#if OSL_DEBUG_LEVEL > 1
2000-09-18 23:08:29 +00:00
const SwFmtCol &rCol = GetFmt()->GetCol();
(void)rCol;
2000-09-18 23:08:29 +00:00
#endif
SwLayoutFrm::MakeAll();
UnlockJoin();
if( pSection && IsSuperfluous() )
DelEmpty( sal_False );
2000-09-18 23:08:29 +00:00
}
sal_Bool SwSectionFrm::ShouldBwdMoved( SwLayoutFrm *, sal_Bool , sal_Bool & )
2000-09-18 23:08:29 +00:00
{
OSL_FAIL( "Hups, wo ist meine Tarnkappe?" );
return sal_False;
2000-09-18 23:08:29 +00:00
}
const SwSectionFmt* SwSectionFrm::_GetEndSectFmt() const
{
const SwSectionFmt *pFmt = pSection->GetFmt();
while( !pFmt->GetEndAtTxtEnd().IsAtEnd() )
{
if( pFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pFmt = (SwSectionFmt*)pFmt->GetRegisteredIn();
else
return NULL;
}
return pFmt;
}
static void lcl_FindCntntFrm( SwCntntFrm* &rpCntntFrm, SwFtnFrm* &rpFtnFrm,
SwFrm* pFrm, sal_Bool &rbChkFtn )
2000-09-18 23:08:29 +00:00
{
if( pFrm )
{
while( pFrm->GetNext() )
pFrm = pFrm->GetNext();
while( !rpCntntFrm && pFrm )
{
if( pFrm->IsCntntFrm() )
rpCntntFrm = (SwCntntFrm*)pFrm;
else if( pFrm->IsLayoutFrm() )
{
if( pFrm->IsFtnFrm() )
{
if( rbChkFtn )
{
rpFtnFrm = (SwFtnFrm*)pFrm;
rbChkFtn = rpFtnFrm->GetAttr()->GetFtn().IsEndNote();
}
}
else
lcl_FindCntntFrm( rpCntntFrm, rpFtnFrm,
((SwLayoutFrm*)pFrm)->Lower(), rbChkFtn );
}
pFrm = pFrm->GetPrev();
}
}
}
SwCntntFrm *SwSectionFrm::FindLastCntnt( sal_uInt8 nMode )
2000-09-18 23:08:29 +00:00
{
SwCntntFrm *pRet = NULL;
SwFtnFrm *pFtnFrm = NULL;
SwSectionFrm *pSect = this;
if( nMode )
{
const SwSectionFmt *pFmt = IsEndnAtEnd() ? GetEndSectFmt() :
pSection->GetFmt();
do {
while( pSect->HasFollow() )
pSect = pSect->GetFollow();
SwFrm* pTmp = pSect->FindNext();
while( pTmp && pTmp->IsSctFrm() &&
!((SwSectionFrm*)pTmp)->GetSection() )
pTmp = pTmp->FindNext();
if( pTmp && pTmp->IsSctFrm() &&
((SwSectionFrm*)pTmp)->IsDescendantFrom( pFmt ) )
pSect = (SwSectionFrm*)pTmp;
else
break;
} while( true );
2000-09-18 23:08:29 +00:00
}
sal_Bool bFtnFound = nMode == FINDMODE_ENDNOTE;
2000-09-18 23:08:29 +00:00
do
{
lcl_FindCntntFrm( pRet, pFtnFrm, pSect->Lower(), bFtnFound );
if( pRet || !pSect->IsFollow() || !nMode ||
( FINDMODE_MYLAST == nMode && this == pSect ) )
break;
pSect = pSect->FindMaster();
2000-09-18 23:08:29 +00:00
} while( pSect );
if( ( nMode == FINDMODE_ENDNOTE ) && pFtnFrm )
pRet = pFtnFrm->ContainsCntnt();
return pRet;
}
sal_Bool SwSectionFrm::CalcMinDiff( SwTwips& rMinDiff ) const
2000-09-18 23:08:29 +00:00
{
if( ToMaximize( sal_True ) )
2000-09-18 23:08:29 +00:00
{
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
2001-12-12 13:44:09 +00:00
rMinDiff = (GetUpper()->*fnRect->fnGetPrtBottom)();
rMinDiff = (Frm().*fnRect->fnBottomDist)( rMinDiff );
return sal_True;
2000-09-18 23:08:29 +00:00
}
return sal_False;
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
*
* SwSectionFrm::CollectEndnotes( )
*
* CollectEndnotes looks for endnotes in the sectionfrm and his follows,
* the endnotes will cut off the layout and put into the array.
* If the first endnote is not a master-SwFtnFrm, the whole sectionfrm
* contains only endnotes and it is not necessary to collect them.
*
*************************************************************************/
static SwFtnFrm* lcl_FindEndnote( SwSectionFrm* &rpSect, bool &rbEmpty,
2000-09-18 23:08:29 +00:00
SwLayouter *pLayouter )
{
// if rEmpty is set, the rpSect is already searched
SwSectionFrm* pSect = rbEmpty ? rpSect->GetFollow() : rpSect;
while( pSect )
{
OSL_ENSURE( (pSect->Lower() && pSect->Lower()->IsColumnFrm()) || pSect->GetUpper()->IsFtnFrm(),
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
"InsertEndnotes: Where's my column?" );
// i73332: Columned section in endnote
SwColumnFrm* pCol = 0;
if(pSect->Lower() && pSect->Lower()->IsColumnFrm())
pCol = (SwColumnFrm*)pSect->Lower();
while( pCol ) // check all columns
2000-09-18 23:08:29 +00:00
{
SwFtnContFrm* pFtnCont = pCol->FindFtnCont();
if( pFtnCont )
{
SwFtnFrm* pRet = (SwFtnFrm*)pFtnCont->Lower();
while( pRet ) // look for endnotes
{
if( pRet->GetAttr()->GetFtn().IsEndNote() )
{
if( pRet->GetMaster() )
{
if( pLayouter )
pLayouter->CollectEndnote( pRet );
else
return 0;
}
else
return pRet; // Found
}
pRet = (SwFtnFrm*)pRet->GetNext();
}
}
pCol = (SwColumnFrm*)pCol->GetNext();
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
}
2000-09-18 23:08:29 +00:00
rpSect = pSect;
pSect = pLayouter ? pSect->GetFollow() : NULL;
rbEmpty = true;
2000-09-18 23:08:29 +00:00
}
return NULL;
}
static void lcl_ColumnRefresh( SwSectionFrm* pSect, bool bFollow )
2000-09-18 23:08:29 +00:00
{
while( pSect )
{
sal_Bool bOldLock = pSect->IsColLocked();
2000-09-18 23:08:29 +00:00
pSect->ColLock();
if( pSect->Lower() && pSect->Lower()->IsColumnFrm() )
{
SwColumnFrm *pCol = (SwColumnFrm*)pSect->Lower();
do
{ pCol->_InvalidateSize();
pCol->_InvalidatePos();
((SwLayoutFrm*)pCol)->Lower()->_InvalidateSize();
pCol->Calc(); // calculation of column and
((SwLayoutFrm*)pCol)->Lower()->Calc(); // body
pCol = (SwColumnFrm*)pCol->GetNext();
} while ( pCol );
}
if( !bOldLock )
pSect->ColUnlock();
if( bFollow )
pSect = pSect->GetFollow();
else
pSect = NULL;
}
}
void SwSectionFrm::CollectEndnotes( SwLayouter* pLayouter )
{
OSL_ENSURE( IsColLocked(), "CollectEndnotes: You love the risk?" );
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
// i73332: Section in footnode does not have columns!
OSL_ENSURE( (Lower() && Lower()->IsColumnFrm()) || GetUpper()->IsFtnFrm(), "Where's my column?" );
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
2000-09-18 23:08:29 +00:00
SwSectionFrm* pSect = this;
SwFtnFrm* pFtn;
bool bEmpty = false;
2000-09-18 23:08:29 +00:00
// pSect is the last sectionfrm without endnotes or the this-pointer
// the first sectionfrm with endnotes may be destroyed, when the endnotes
// is cutted
while( 0 != (pFtn = lcl_FindEndnote( pSect, bEmpty, pLayouter )) )
pLayouter->CollectEndnote( pFtn );
if( pLayouter->HasEndnotes() )
lcl_ColumnRefresh( this, true );
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwSectionFrm::_CheckClipping( sal_Bool bGrow, sal_Bool bMaximize )
2000-09-18 23:08:29 +00:00
|*
2012-02-16 12:01:24 +01:00
|* Description: Fits the size to the surroundings.
|* Those that have a Follow or foot notes, have to extend until
|* the lower edge of a upper (bMaximize)
|* They must not extend above the Upper, as the case may be one can
|* try to grow its upper (bGrow)
|* If the size had to be changed, the content is calculated.
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
/// OD 18.09.2002 #100522#
/// perform calculation of content, only if height has changed.
void SwSectionFrm::_CheckClipping( sal_Bool bGrow, sal_Bool bMaximize )
2000-09-18 23:08:29 +00:00
{
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
long nDiff;
2001-12-12 13:44:09 +00:00
SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
2001-11-09 12:32:26 +00:00
if( bGrow && ( !IsInFly() || !GetUpper()->IsColBodyFrm() ||
!FindFlyFrm()->IsLocked() ) )
{
2001-12-12 13:44:09 +00:00
nDiff = -(Frm().*fnRect->fnBottomDist)( nDeadLine );
2001-11-09 12:32:26 +00:00
if( !bMaximize )
nDiff += Undersize();
if( nDiff > 0 )
{
long nAdd = GetUpper()->Grow( nDiff );
if( bVert && !bRev )
nDeadLine -= nAdd;
else
nDeadLine += nAdd;
}
}
2001-12-12 13:44:09 +00:00
nDiff = -(Frm().*fnRect->fnBottomDist)( nDeadLine );
2001-11-09 12:32:26 +00:00
SetUndersized( !bMaximize && nDiff >= 0 );
const bool bCalc = ( IsUndersized() || bMaximize ) &&
( nDiff ||
(Prt().*fnRect->fnGetTop)() > (Frm().*fnRect->fnGetHeight)() );
// OD 03.11.2003 #i19737# - introduce local variable <bExtraCalc> to indicate
// that a calculation has to be done beside the value of <bCalc>.
bool bExtraCalc = false;
2001-11-09 12:32:26 +00:00
if( !bCalc && !bGrow && IsAnyNoteAtEnd() && !IsInFtn() )
{
SwSectionFrm *pSect = this;
bool bEmpty = false;
2001-11-09 12:32:26 +00:00
SwLayoutFrm* pFtn = IsEndnAtEnd() ?
lcl_FindEndnote( pSect, bEmpty, NULL ) : NULL;
if( pFtn )
{
pFtn = pFtn->FindFtnBossFrm();
SwFrm* pTmp = FindLastCntnt( FINDMODE_LASTCNT );
// OD 08.11.2002 #104840# - use <SwLayoutFrm::IsBefore(..)>
if ( pTmp && pFtn->IsBefore( pTmp->FindFtnBossFrm() ) )
bExtraCalc = true;
2001-11-09 12:32:26 +00:00
}
else if( GetFollow() && !GetFollow()->ContainsAny() )
bExtraCalc = true;
2001-11-09 12:32:26 +00:00
}
if ( bCalc || bExtraCalc )
2001-11-09 12:32:26 +00:00
{
nDiff = (*fnRect->fnYDiff)( nDeadLine, (Frm().*fnRect->fnGetTop)() );
if( nDiff < 0 )
2001-11-13 14:21:55 +00:00
{
2001-11-09 12:32:26 +00:00
nDiff = 0;
2001-11-13 14:21:55 +00:00
nDeadLine = (Frm().*fnRect->fnGetTop)();
}
2001-11-09 12:32:26 +00:00
const Size aOldSz( Prt().SSize() );
2001-11-22 14:03:19 +00:00
long nTop = (this->*fnRect->fnGetTopMargin)();
2001-11-13 14:21:55 +00:00
(Frm().*fnRect->fnSetBottom)( nDeadLine );
2001-11-09 12:32:26 +00:00
nDiff = (Frm().*fnRect->fnGetHeight)();
2001-11-13 14:21:55 +00:00
if( nTop > nDiff )
nTop = nDiff;
(this->*fnRect->fnSetYMargins)( nTop, 0 );
// OD 18.09.2002 #100522#
// Determine, if height has changed.
// Note: In vertical layout the height equals the width value.
bool bHeightChanged = bVert ?
(aOldSz.Width() != Prt().Width()) :
(aOldSz.Height() != Prt().Height());
2012-02-16 12:01:24 +01:00
// Last but not least we have changed the height again, thus the inner
// layout (columns) is calculated and the content as well.
// OD 18.09.2002 #100522#
// calculate content, only if height has changed.
// OD 03.11.2003 #i19737# - restriction of content calculation too strong.
// If an endnote has an incorrect position or a follow section contains
// no content except footnotes/endnotes, the content has also been calculated.
if ( ( bHeightChanged || bExtraCalc ) && Lower() )
2000-09-18 23:08:29 +00:00
{
if( Lower()->IsColumnFrm() )
{
lcl_ColumnRefresh( this, false );
2000-09-18 23:08:29 +00:00
::CalcCntnt( this );
}
else
{
ChgLowersProp( aOldSz );
if( !bMaximize && !IsCntntLocked() )
::CalcCntnt( this );
}
}
}
}
void SwSectionFrm::SimpleFormat()
{
if ( IsJoinLocked() || IsColLocked() )
return;
// OSL_ENSURE( pFollow, "SimpleFormat: Follow required" );
2000-09-18 23:08:29 +00:00
LockJoin();
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
if( GetPrev() || GetUpper() )
{
//
// assure notifications on position changes.
const SwLayNotify aNotify( this );
(this->*fnRect->fnMakePos)( GetUpper(), GetPrev(), sal_False );
bValidPos = sal_True;
2001-11-09 12:32:26 +00:00
}
2001-12-12 13:44:09 +00:00
SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
// OD 22.10.2002 #97265# - call always method <lcl_ColumnRefresh(..)>, in
// order to get calculated lowers, not only if there space left in its upper.
if( (Frm().*fnRect->fnBottomDist)( nDeadLine ) >= 0 )
2001-11-09 12:32:26 +00:00
{
2001-11-14 13:40:22 +00:00
(Frm().*fnRect->fnSetBottom)( nDeadLine );
2001-11-19 11:27:23 +00:00
long nHeight = (Frm().*fnRect->fnGetHeight)();
long nTop = CalcUpperSpace();
if( nTop > nHeight )
nTop = nHeight;
(this->*fnRect->fnSetYMargins)( nTop, 0 );
2001-11-09 12:32:26 +00:00
}
lcl_ColumnRefresh( this, false );
2000-09-18 23:08:29 +00:00
UnlockJoin();
}
// #i40147# - helper class to perform extra section format
// to position anchored objects and to keep the position of whose objects locked.
class ExtraFormatToPositionObjs
{
private:
SwSectionFrm* mpSectFrm;
bool mbExtraFormatPerformed;
public:
ExtraFormatToPositionObjs( SwSectionFrm& _rSectFrm)
: mpSectFrm( &_rSectFrm ),
mbExtraFormatPerformed( false )
{}
~ExtraFormatToPositionObjs()
{
if ( mbExtraFormatPerformed )
{
// release keep locked position of lower floating screen objects
SwPageFrm* pPageFrm = mpSectFrm->FindPageFrm();
SwSortedObjs* pObjs = pPageFrm ? pPageFrm->GetSortedObjs() : 0L;
if ( pObjs )
{
sal_uInt32 i = 0;
for ( i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
if ( mpSectFrm->IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
{
pAnchoredObj->SetKeepPosLocked( false );
}
}
}
}
}
// #i81555#
void InitObjs( SwFrm& rFrm )
{
SwSortedObjs* pObjs = rFrm.GetDrawObjs();
if ( pObjs )
{
sal_uInt32 i = 0;
for ( i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
pAnchoredObj->UnlockPosition();
pAnchoredObj->SetClearedEnvironment( false );
}
}
SwLayoutFrm* pLayoutFrm = dynamic_cast<SwLayoutFrm*>(&rFrm);
if ( pLayoutFrm != 0 )
{
SwFrm* pLowerFrm = pLayoutFrm->GetLower();
while ( pLowerFrm != 0 )
{
InitObjs( *pLowerFrm );
pLowerFrm = pLowerFrm->GetNext();
}
}
}
void FormatSectionToPositionObjs()
{
// perform extra format for multi-columned section.
if ( mpSectFrm->Lower() && mpSectFrm->Lower()->IsColumnFrm() &&
mpSectFrm->Lower()->GetNext() )
{
// grow section till bottom of printing area of upper frame
SWRECTFN( mpSectFrm );
SwTwips nTopMargin = (mpSectFrm->*fnRect->fnGetTopMargin)();
Size aOldSectPrtSize( mpSectFrm->Prt().SSize() );
SwTwips nDiff = (mpSectFrm->Frm().*fnRect->fnBottomDist)(
(mpSectFrm->GetUpper()->*fnRect->fnGetPrtBottom)() );
(mpSectFrm->Frm().*fnRect->fnAddBottom)( nDiff );
(mpSectFrm->*fnRect->fnSetYMargins)( nTopMargin, 0 );
// #i59789#
// suppress formatting, if printing area of section is too narrow
if ( (mpSectFrm->Prt().*fnRect->fnGetHeight)() <= 0 )
{
return;
}
mpSectFrm->ChgLowersProp( aOldSectPrtSize );
// format column frames and its body and footnote container
SwColumnFrm* pColFrm = static_cast<SwColumnFrm*>(mpSectFrm->Lower());
while ( pColFrm )
{
pColFrm->Calc();
pColFrm->Lower()->Calc();
if ( pColFrm->Lower()->GetNext() )
{
pColFrm->Lower()->GetNext()->Calc();
}
pColFrm = static_cast<SwColumnFrm*>(pColFrm->GetNext());
}
// unlock position of lower floating screen objects for the extra format
// #i81555#
// Section frame can already have changed the page and its content
// can still be on the former page.
// Thus, initialize objects via lower-relationship
InitObjs( *mpSectFrm );
// format content - first with collecting its foot-/endnotes before content
// format, second without collecting its foot-/endnotes.
::CalcCntnt( mpSectFrm );
::CalcCntnt( mpSectFrm, true );
// keep locked position of lower floating screen objects
SwPageFrm* pPageFrm = mpSectFrm->FindPageFrm();
SwSortedObjs* pObjs = pPageFrm ? pPageFrm->GetSortedObjs() : 0L;
if ( pObjs )
{
sal_uInt32 i = 0;
for ( i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
if ( mpSectFrm->IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
{
pAnchoredObj->SetKeepPosLocked( true );
}
}
}
mbExtraFormatPerformed = true;
}
}
};
2000-09-18 23:08:29 +00:00
/*************************************************************************
|*
|* SwSectionFrm::Format()
|*
2012-02-16 12:01:24 +01:00
|* Description: "formats" the frame; Frm and PrtArea
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
void SwSectionFrm::Format( const SwBorderAttrs *pAttr )
{
2012-02-16 12:01:24 +01:00
if( !pSection ) // via DelEmpty
2000-09-18 23:08:29 +00:00
{
#ifdef DBG_UTIL
Merge commit 'ooo/DEV300_m103' Conflicts: sw/inc/calbck.hxx sw/inc/crsrsh.hxx sw/inc/dcontact.hxx sw/inc/doc.hxx sw/inc/docufld.hxx sw/inc/editsh.hxx sw/inc/expfld.hxx sw/inc/fchrfmt.hxx sw/inc/fmtcol.hxx sw/inc/fmthdft.hxx sw/inc/fmtpdsc.hxx sw/inc/format.hxx sw/inc/frmfmt.hxx sw/inc/ndhints.hxx sw/inc/ndtxt.hxx sw/inc/node.hxx sw/inc/numrule.hxx sw/inc/paratr.hxx sw/inc/swtable.hxx sw/inc/unocrsr.hxx sw/inc/unofield.hxx sw/inc/unoframe.hxx sw/inc/unoport.hxx sw/inc/unostyle.hxx sw/inc/usrfld.hxx sw/inc/viewopt.hxx sw/inc/viewsh.hxx sw/source/core/access/accframebase.cxx sw/source/core/access/accmap.cxx sw/source/core/access/accnotextframe.cxx sw/source/core/access/accpara.cxx sw/source/core/access/accpara.hxx sw/source/core/attr/calbck.cxx sw/source/core/crsr/callnk.cxx sw/source/core/crsr/crsrsh.cxx sw/source/core/doc/acmplwrd.cxx sw/source/core/doc/doc.cxx sw/source/core/doc/docdesc.cxx sw/source/core/doc/docdraw.cxx sw/source/core/doc/docfly.cxx sw/source/core/doc/docfmt.cxx sw/source/core/doc/doclay.cxx sw/source/core/doc/docnew.cxx sw/source/core/doc/docnum.cxx sw/source/core/doc/doctxm.cxx sw/source/core/doc/fmtcol.cxx sw/source/core/doc/htmltbl.cxx sw/source/core/doc/number.cxx sw/source/core/docnode/ndsect.cxx sw/source/core/docnode/ndtbl.cxx sw/source/core/docnode/node.cxx sw/source/core/docnode/node2lay.cxx sw/source/core/docnode/section.cxx sw/source/core/docnode/swbaslnk.cxx sw/source/core/draw/dcontact.cxx sw/source/core/draw/dview.cxx sw/source/core/edit/autofmt.cxx sw/source/core/edit/editsh.cxx sw/source/core/edit/edlingu.cxx sw/source/core/fields/authfld.cxx sw/source/core/fields/dbfld.cxx sw/source/core/fields/docufld.cxx sw/source/core/fields/expfld.cxx sw/source/core/fields/reffld.cxx sw/source/core/fields/tblcalc.cxx sw/source/core/frmedt/fefly1.cxx sw/source/core/frmedt/feshview.cxx sw/source/core/frmedt/tblsel.cxx sw/source/core/inc/flyfrm.hxx sw/source/core/inc/prevwpage.hxx sw/source/core/inc/rolbck.hxx sw/source/core/inc/txtfrm.hxx sw/source/core/layout/atrfrm.cxx sw/source/core/layout/findfrm.cxx sw/source/core/layout/flowfrm.cxx sw/source/core/layout/fly.cxx sw/source/core/layout/flycnt.cxx sw/source/core/layout/flylay.cxx sw/source/core/layout/frmtool.cxx sw/source/core/layout/hffrm.cxx sw/source/core/layout/pagechg.cxx sw/source/core/layout/pagedesc.cxx sw/source/core/layout/paintfrm.cxx sw/source/core/layout/sectfrm.cxx sw/source/core/layout/ssfrm.cxx sw/source/core/layout/tabfrm.cxx sw/source/core/layout/wsfrm.cxx sw/source/core/objectpositioning/tocntntanchoredobjectposition.cxx sw/source/core/table/swtable.cxx sw/source/core/text/EnhancedPDFExportHelper.cxx sw/source/core/text/inftxt.cxx sw/source/core/text/porfld.cxx sw/source/core/text/txtdrop.cxx sw/source/core/text/txtfly.cxx sw/source/core/text/txtfrm.cxx sw/source/core/text/txtio.cxx sw/source/core/text/txttab.cxx sw/source/core/tox/tox.cxx sw/source/core/txtnode/atrflyin.cxx sw/source/core/txtnode/fmtatr2.cxx sw/source/core/txtnode/ndtxt.cxx sw/source/core/undo/SwUndoPageDesc.cxx sw/source/core/undo/undraw.cxx sw/source/core/unocore/unochart.cxx sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unodraw.cxx sw/source/core/unocore/unofield.cxx sw/source/core/unocore/unoframe.cxx sw/source/core/unocore/unoftn.cxx sw/source/core/unocore/unoidx.cxx sw/source/core/unocore/unoobj2.cxx sw/source/core/unocore/unoparagraph.cxx sw/source/core/unocore/unoport.cxx sw/source/core/unocore/unoportenum.cxx sw/source/core/unocore/unoredline.cxx sw/source/core/unocore/unoredlines.cxx sw/source/core/unocore/unorefmk.cxx sw/source/core/unocore/unosect.cxx sw/source/core/unocore/unosett.cxx sw/source/core/unocore/unostyle.cxx sw/source/core/unocore/unotbl.cxx sw/source/core/unocore/unotext.cxx sw/source/core/view/viewimp.cxx sw/source/core/view/viewpg.cxx sw/source/core/view/viewsh.cxx sw/source/core/view/vnew.cxx sw/source/core/view/vprint.cxx sw/source/filter/ww8/rtfexport.cxx sw/source/filter/ww8/rtfexport.hxx sw/source/filter/ww8/wrtw8nds.cxx sw/source/filter/ww8/wrtww8gr.cxx sw/source/filter/xml/XMLRedlineImportHelper.cxx sw/source/ui/app/apphdl.cxx sw/source/ui/app/docsh.cxx sw/source/ui/app/docsh2.cxx sw/source/ui/app/swmodul1.cxx sw/source/ui/config/viewopt.cxx sw/source/ui/fldui/fldpage.cxx sw/source/ui/uiview/srcview.cxx sw/source/ui/uiview/view.cxx sw/source/ui/uno/unotxdoc.cxx sw/source/ui/vba/wordvbahelper.cxx sw/source/ui/wrtsh/wrtsh1.cxx
2011-03-23 17:00:12 +01:00
OSL_ENSURE( getRootFrm()->IsInDelList( this ), "SectionFrm without Section" );
#endif
bValidSize = bValidPos = bValidPrtArea = sal_True;
2000-09-18 23:08:29 +00:00
return;
}
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
2000-09-18 23:08:29 +00:00
if ( !bValidPrtArea )
{
PROTOCOL( this, PROT_PRTAREA, 0, 0 )
bValidPrtArea = sal_True;
2001-11-09 12:32:26 +00:00
SwTwips nUpper = CalcUpperSpace();
// #109700# LRSpace for sections
const SvxLRSpaceItem& rLRSpace = GetFmt()->GetLRSpace();
(this->*fnRect->fnSetXMargins)( rLRSpace.GetLeft(), rLRSpace.GetRight() );
2001-11-09 12:32:26 +00:00
if( nUpper != (this->*fnRect->fnGetTopMargin)() )
{
bValidSize = sal_False;
2001-11-09 12:32:26 +00:00
SwFrm* pOwn = ContainsAny();
if( pOwn )
pOwn->_InvalidatePos();
}
(this->*fnRect->fnSetYMargins)( nUpper, 0 );
2000-09-18 23:08:29 +00:00
}
if ( !bValidSize )
{
PROTOCOL_ENTER( this, PROT_SIZE, 0, 0 )
2001-11-09 12:32:26 +00:00
const long nOldHeight = (Frm().*fnRect->fnGetHeight)();
sal_Bool bOldLock = IsColLocked();
2000-09-18 23:08:29 +00:00
ColLock();
bValidSize = sal_True;
2000-09-18 23:08:29 +00:00
2012-02-16 12:01:24 +01:00
// The size is only determined by the content, if the SectFrm does not have a
// Follow. Otherwise it fills (occupies) the Upper down to the lower edge.
// It is not responsible for the text flow, but the content is.
sal_Bool bMaximize = ToMaximize( sal_False );
2000-09-18 23:08:29 +00:00
// OD 2004-05-17 #i28701# - If the wrapping style has to be considered
// on object positioning, an extra formatting has to be performed
// to determine the correct positions the floating screen objects.
// #i40147#
// use new helper class <ExtraFormatToPositionObjs>.
// This class additionally keep the locked position of the objects
// and releases this position lock keeping on destruction.
ExtraFormatToPositionObjs aExtraFormatToPosObjs( *this );
if ( !bMaximize &&
GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
!GetFmt()->GetBalancedColumns().GetValue() )
{
aExtraFormatToPosObjs.FormatSectionToPositionObjs();
}
// Column widths have to be adjusted before calling _CheckClipping.
// _CheckClipping can cause the formatting of the lower frames
// which still have a width of 0.
const bool bHasColumns = Lower() && Lower()->IsColumnFrm();
if ( bHasColumns && Lower()->GetNext() )
AdjustColumns( 0, sal_False );
2000-09-18 23:08:29 +00:00
if( GetUpper() )
{
2001-11-09 12:32:26 +00:00
long nWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
(aFrm.*fnRect->fnSetWidth)( nWidth );
// #109700# LRSpace for sections
const SvxLRSpaceItem& rLRSpace = GetFmt()->GetLRSpace();
(aPrt.*fnRect->fnSetWidth)( nWidth - rLRSpace.GetLeft() -
rLRSpace.GetRight() );
// OD 15.10.2002 #103517# - allow grow in online layout
// Thus, set <..IsBrowseMode()> as parameter <bGrow> on calling
// method <_CheckClipping(..)>.
const ViewShell *pSh = getRootFrm()->GetCurrShell();
_CheckClipping( pSh && pSh->GetViewOptions()->getBrowseMode(), bMaximize );
bMaximize = ToMaximize( sal_False );
bValidSize = sal_True;
2000-09-18 23:08:29 +00:00
}
2012-02-16 12:01:24 +01:00
// Check the width of the columns and adjust if necessary
if ( bHasColumns && ! Lower()->GetNext() && bMaximize )
((SwColumnFrm*)Lower())->Lower()->Calc();
2000-09-18 23:08:29 +00:00
if ( !bMaximize )
{
SwTwips nRemaining = (this->*fnRect->fnGetTopMargin)();
2000-09-18 23:08:29 +00:00
SwFrm *pFrm = pLower;
if( pFrm )
{
if( pFrm->IsColumnFrm() && pFrm->GetNext() )
{
// #i61435#
// suppress formatting, if upper frame has height <= 0
if ( (GetUpper()->Frm().*fnRect->fnGetHeight)() > 0 )
{
FormatWidthCols( *pAttr, nRemaining, MINLAY );
}
2011-04-18 12:37:38 -03:00
// #126020# - adjust check for empty section
// #130797# - correct fix #126020#
while( HasFollow() && !GetFollow()->ContainsCntnt() &&
!GetFollow()->ContainsAny( true ) )
2000-09-18 23:08:29 +00:00
{
SwFrm* pOld = GetFollow();
GetFollow()->DelEmpty( sal_False );
2000-09-18 23:08:29 +00:00
if( pOld == GetFollow() )
break;
}
bMaximize = ToMaximize( sal_False );
2001-11-09 12:32:26 +00:00
nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
2000-09-18 23:08:29 +00:00
}
else
{
if( pFrm->IsColumnFrm() )
{
pFrm->Calc();
pFrm = ((SwColumnFrm*)pFrm)->Lower();
pFrm->Calc();
pFrm = ((SwLayoutFrm*)pFrm)->Lower();
CalcFtnCntnt();
}
2012-02-16 12:01:24 +01:00
// If we are in a columned frame which calls a CalcCntnt
// in the FormatWidthCols, the content might need calculating
2000-09-18 23:08:29 +00:00
if( pFrm && !pFrm->IsValid() && IsInFly() &&
FindFlyFrm()->IsColLocked() )
::CalcCntnt( this );
nRemaining += InnerHeight();
bMaximize = HasFollow();
}
}
SwTwips nDiff = (Frm().*fnRect->fnGetHeight)() - nRemaining;
2001-11-09 12:32:26 +00:00
if( nDiff < 0)
{
2001-12-12 13:44:09 +00:00
SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
2001-11-09 12:32:26 +00:00
{
long nBottom = (Frm().*fnRect->fnGetBottom)();
nBottom = (*fnRect->fnYInc)( nBottom, -nDiff );
long nTmpDiff = (*fnRect->fnYDiff)( nBottom, nDeadLine );
if( nTmpDiff > 0 )
{
nTmpDiff = GetUpper()->Grow( nTmpDiff, sal_True );
2001-11-09 12:32:26 +00:00
nDeadLine = (*fnRect->fnYInc)( nDeadLine, nTmpDiff );
nTmpDiff = (*fnRect->fnYDiff)( nBottom, nDeadLine );
if( nTmpDiff > 0 )
nDiff += nTmpDiff;
if( nDiff > 0 )
nDiff = 0;
}
}
}
if( nDiff )
{
long nTmp = nRemaining - (Frm().*fnRect->fnGetHeight)();
long nTop = (this->*fnRect->fnGetTopMargin)();
(Frm().*fnRect->fnAddBottom)( nTmp );
(this->*fnRect->fnSetYMargins)( nTop, 0 );
2000-09-18 23:08:29 +00:00
InvalidateNextPos();
if( pLower && ( !pLower->IsColumnFrm() || !pLower->GetNext() ) )
{
2012-02-16 12:01:24 +01:00
// If a single-column section just created the space that
// was requested by the "undersized" paragraphs, then they
// have to be invalidated and calculated, so they fully cover it
2000-09-18 23:08:29 +00:00
pFrm = pLower;
if( pFrm->IsColumnFrm() )
{
pFrm->_InvalidateSize();
pFrm->_InvalidatePos();
pFrm->Calc();
pFrm = ((SwColumnFrm*)pFrm)->Lower();
pFrm->Calc();
pFrm = ((SwLayoutFrm*)pFrm)->Lower();
CalcFtnCntnt();
}
bool bUnderSz = false;
2000-09-18 23:08:29 +00:00
while( pFrm )
{
if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
{
pFrm->Prepare( PREP_ADJUST_FRM );
bUnderSz = true;
2000-09-18 23:08:29 +00:00
}
pFrm = pFrm->GetNext();
}
if( bUnderSz && !IsCntntLocked() )
::CalcCntnt( this );
}
}
}
2012-02-16 12:01:24 +01:00
// Do not exceed the lower edge of the Upper.
// Do not extend below the lower edge with Sections with Follows
2000-09-18 23:08:29 +00:00
if ( GetUpper() )
_CheckClipping( sal_True, bMaximize );
2000-09-18 23:08:29 +00:00
if( !bOldLock )
ColUnlock();
2001-11-09 12:32:26 +00:00
long nDiff = nOldHeight - (Frm().*fnRect->fnGetHeight)();
if( nDiff > 0 )
2000-09-18 23:08:29 +00:00
{
if( !GetNext() )
2012-02-16 12:01:24 +01:00
SetRetouche(); // Take over the retouching ourselves
if( GetUpper() && !GetUpper()->IsFooterFrm() )
GetUpper()->Shrink( nDiff );
2000-09-18 23:08:29 +00:00
}
if( IsUndersized() )
bValidPrtArea = sal_True;
2000-09-18 23:08:29 +00:00
}
}
/*************************************************************************
|*
|* SwFrm::GetNextSctLeaf()
|*
2012-02-16 12:01:24 +01:00
|* Description: Returns the next layout sheet where the frame
|* can be moved in.
|* New pages are created only if the parameter sal_True is set
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
SwLayoutFrm *SwFrm::GetNextSctLeaf( MakePageType eMakePage )
{
2012-02-16 12:01:24 +01:00
// Attention: Nested sections are currently not supported
2000-09-18 23:08:29 +00:00
PROTOCOL_ENTER( this, PROT_LEAF, ACT_NEXT_SECT, GetUpper()->FindSctFrm() )
2012-02-16 12:01:24 +01:00
// Shortcuts for "columned" sections, if we're not in the last column
// Can we slide to the next column of the section?
2000-09-18 23:08:29 +00:00
if( IsColBodyFrm() && GetUpper()->GetNext() )
return (SwLayoutFrm*)((SwLayoutFrm*)GetUpper()->GetNext())->Lower();
if( GetUpper()->IsColBodyFrm() && GetUpper()->GetUpper()->GetNext() )
return (SwLayoutFrm*)((SwLayoutFrm*)GetUpper()->GetUpper()->GetNext())->Lower();
2012-02-16 12:01:24 +01:00
// Inside a section, in tables, or sections of headers/footers, there can be only
// one column shift be made, one of the above shortcuts should have applied!
if( GetUpper()->IsInTab() || FindFooterOrHeader() )
2000-09-18 23:08:29 +00:00
return 0;
2012-02-16 12:01:24 +01:00
// Why GetUpper()? This crashes sometimes, because in
// FlyAtCnt::MakeFlyPos there is an Orient of the SectionFrm and on this a
// GetLeaf is called
2000-09-18 23:08:29 +00:00
// SwSectionFrm *pSect = GetUpper()->FindSctFrm();
SwSectionFrm *pSect = FindSctFrm();
bool bWrongPage = false;
OSL_ENSURE( pSect, "GetNextSctLeaf: Missing SectionFrm" );
2000-09-18 23:08:29 +00:00
2012-02-16 12:01:24 +01:00
// Shortcut for sections with Follows. That's ok,
// if no columns or pages (except dummy pages) lie in between.
// In case of linked frames and in footnotes the shortcut would get
// even more costly
2000-09-18 23:08:29 +00:00
if( pSect->HasFollow() && pSect->IsInDocBody() )
{
if( pSect->GetFollow() == pSect->GetNext() )
2000-09-18 23:08:29 +00:00
{
SwPageFrm *pPg = pSect->GetFollow()->FindPageFrm();
if( WrongPageDesc( pPg ) )
bWrongPage = true;
else
return FIRSTLEAF( pSect->GetFollow() );
}
else
{
SwFrm* pTmp;
if( !pSect->GetUpper()->IsColBodyFrm() ||
0 == ( pTmp = pSect->GetUpper()->GetUpper()->GetNext() ) )
pTmp = pSect->FindPageFrm()->GetNext();
2012-02-16 12:01:24 +01:00
if( pTmp ) // is now the next column or page
2000-09-18 23:08:29 +00:00
{
SwFrm* pTmpX = pTmp;
if( pTmp->IsPageFrm() && ((SwPageFrm*)pTmp)->IsEmptyPage() )
2012-02-16 12:01:24 +01:00
pTmp = pTmp->GetNext(); // skip dummy pages
SwFrm *pUp = pSect->GetFollow()->GetUpper();
2012-02-16 12:01:24 +01:00
// pUp becomes the next column if the Follow lies in a column
// that is not a "not first" one, otherwise the page
if( !pUp->IsColBodyFrm() ||
!( pUp = pUp->GetUpper() )->GetPrev() )
pUp = pUp->FindPageFrm();
2012-02-16 12:01:24 +01:00
// Now pUp and pTmp have to be the same page/column, otherwise
// pages or columns lie between Master and Follow
if( pUp == pTmp || pUp->GetNext() == pTmpX )
{
SwPageFrm* pNxtPg = pUp->IsPageFrm() ?
(SwPageFrm*)pUp : pUp->FindPageFrm();
if( WrongPageDesc( pNxtPg ) )
bWrongPage = true;
else
return FIRSTLEAF( pSect->GetFollow() );
}
2000-09-18 23:08:29 +00:00
}
}
}
2012-02-16 12:01:24 +01:00
// Always end up in the same section: Body again inside Body etc.
const sal_Bool bBody = IsInDocBody();
const sal_Bool bFtnPage = FindPageFrm()->IsFtnPage();
2000-09-18 23:08:29 +00:00
SwLayoutFrm *pLayLeaf;
2012-02-16 12:01:24 +01:00
// A shortcut for TabFrms such that not all cells need to be visited
2000-09-18 23:08:29 +00:00
if( bWrongPage )
pLayLeaf = 0;
else if( IsTabFrm() )
{
SwCntntFrm* pTmpCnt = ((SwTabFrm*)this)->FindLastCntnt();
pLayLeaf = pTmpCnt ? pTmpCnt->GetUpper() : 0;
}
2000-09-18 23:08:29 +00:00
else
{
pLayLeaf = GetNextLayoutLeaf();
if( IsColumnFrm() )
{
while( pLayLeaf && ((SwColumnFrm*)this)->IsAnLower( pLayLeaf ) )
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
}
}
2012-02-16 12:01:24 +01:00
SwLayoutFrm *pOldLayLeaf = 0; // Such that in case of newly
// created pages, the search is
// not started over at the beginning
2000-09-18 23:08:29 +00:00
while( true )
2000-09-18 23:08:29 +00:00
{
if( pLayLeaf )
{
2012-02-16 12:01:24 +01:00
// A layout leaf was found, let's see whether it can store me or
// another SectionFrm can be inserted here, or we have to continue
// searching
2000-09-18 23:08:29 +00:00
SwPageFrm* pNxtPg = pLayLeaf->FindPageFrm();
if ( !bFtnPage && pNxtPg->IsFtnPage() )
2012-02-16 12:01:24 +01:00
{ // If I reached the end note pages it's over
2000-09-18 23:08:29 +00:00
pLayLeaf = 0;
continue;
}
2012-02-16 12:01:24 +01:00
// Once inBody always inBody, don't step into tables and not into other sections
2000-09-18 23:08:29 +00:00
if ( (bBody && !pLayLeaf->IsInDocBody()) ||
(IsInFtn() != pLayLeaf->IsInFtn() ) ||
pLayLeaf->IsInTab() ||
( pLayLeaf->IsInSct() && ( !pSect->HasFollow()
|| pSect->GetFollow() != pLayLeaf->FindSctFrm() ) ) )
{
2012-02-16 12:01:24 +01:00
// Rejected - try again.
2000-09-18 23:08:29 +00:00
pOldLayLeaf = pLayLeaf;
pLayLeaf = pLayLeaf->GetNextLayoutLeaf();
continue;
}
if( WrongPageDesc( pNxtPg ) )
{
if( bWrongPage )
break; // there's a column between me and my right page
pLayLeaf = 0;
bWrongPage = true;
2000-09-18 23:08:29 +00:00
pOldLayLeaf = 0;
continue;
}
}
2012-02-16 12:01:24 +01:00
// There is no further LayoutFrm that fits, so a new page
// has to be created, although new pages are worthless within a frame
2000-09-18 23:08:29 +00:00
else if( !pSect->IsInFly() &&
( eMakePage == MAKEPAGE_APPEND || eMakePage == MAKEPAGE_INSERT ) )
{
InsertPage(pOldLayLeaf ? pOldLayLeaf->FindPageFrm() : FindPageFrm(),
sal_False );
2012-02-16 12:01:24 +01:00
// and again the whole thing
2000-09-18 23:08:29 +00:00
pLayLeaf = pOldLayLeaf ? pOldLayLeaf : GetNextLayoutLeaf();
continue;
}
break;
}
if( pLayLeaf )
{
2012-02-16 12:01:24 +01:00
// We have found the suitable layout sheet. If there (in the sheet) is
// already a Follow of our section, we take its first layout sheet,
// otherwise it is time to create a section follow
2000-09-18 23:08:29 +00:00
SwSectionFrm* pNew;
2012-02-16 12:01:24 +01:00
// This can be omitted if existing Follows were cut short
2000-09-18 23:08:29 +00:00
SwFrm* pFirst = pLayLeaf->Lower();
2012-02-16 12:01:24 +01:00
// Here SectionFrms that are to be deleted must be ignored
2000-09-18 23:08:29 +00:00
while( pFirst && pFirst->IsSctFrm() && !((SwSectionFrm*)pFirst)->GetSection() )
pFirst = pFirst->GetNext();
if( pFirst && pFirst->IsSctFrm() && pSect->GetFollow() == pFirst )
pNew = pSect->GetFollow();
else if( MAKEPAGE_NOSECTION == eMakePage )
return pLayLeaf;
2000-09-18 23:08:29 +00:00
else
{
pNew = new SwSectionFrm( *pSect, sal_False );
2000-09-18 23:08:29 +00:00
pNew->InsertBefore( pLayLeaf, pLayLeaf->Lower() );
2001-11-13 14:21:55 +00:00
pNew->Init();
2001-11-09 12:32:26 +00:00
SWRECTFN( pNew )
(pNew->*fnRect->fnMakePos)( pLayLeaf, NULL, sal_True );
2000-09-18 23:08:29 +00:00
2012-02-16 12:01:24 +01:00
// If our section frame has a successor then that has to be
// moved behind the new Follow of the section frames
2000-09-18 23:08:29 +00:00
SwFrm* pTmp = pSect->GetNext();
if( pTmp && pTmp != pSect->GetFollow() )
{
SwFlowFrm* pNxt;
SwCntntFrm* pNxtCntnt = NULL;
if( pTmp->IsCntntFrm() )
{
pNxt = (SwCntntFrm*)pTmp;
pNxtCntnt = (SwCntntFrm*)pTmp;
}
else
{
pNxtCntnt = ((SwLayoutFrm*)pTmp)->ContainsCntnt();
if( pTmp->IsSctFrm() )
pNxt = (SwSectionFrm*)pTmp;
else
{
OSL_ENSURE( pTmp->IsTabFrm(), "GetNextSctLeaf: Wrong Type" );
2000-09-18 23:08:29 +00:00
pNxt = (SwTabFrm*)pTmp;
}
while( !pNxtCntnt && 0 != ( pTmp = pTmp->GetNext() ) )
{
if( pTmp->IsCntntFrm() )
pNxtCntnt = (SwCntntFrm*)pTmp;
else
pNxtCntnt = ((SwLayoutFrm*)pTmp)->ContainsCntnt();
}
}
if( pNxtCntnt )
{
SwFtnBossFrm* pOldBoss = pSect->FindFtnBossFrm( sal_True );
if( pOldBoss == pNxtCntnt->FindFtnBossFrm( sal_True ) )
2000-09-18 23:08:29 +00:00
{
SwSaveFtnHeight aHeight( pOldBoss,
pOldBoss->Frm().Top() + pOldBoss->Frm().Height() );
pSect->GetUpper()->MoveLowerFtns( pNxtCntnt, pOldBoss,
pLayLeaf->FindFtnBossFrm( sal_True ), sal_False );
2000-09-18 23:08:29 +00:00
}
}
((SwFlowFrm*)pNxt)->MoveSubTree( pLayLeaf, pNew->GetNext() );
}
if( pNew->GetFollow() )
pNew->SimpleFormat();
}
2012-02-16 12:01:24 +01:00
// The wanted layout sheet is now the first of the determined SctFrms:
2000-09-18 23:08:29 +00:00
pLayLeaf = FIRSTLEAF( pNew );
}
return pLayLeaf;
}
/*************************************************************************
|*
|* SwFrm::GetPrevSctLeaf()
|*
2012-02-16 12:01:24 +01:00
|* Description Returns the preceding layout sheet where the frame
|* can be moved into
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
SwLayoutFrm *SwFrm::GetPrevSctLeaf( MakePageType )
2000-09-18 23:08:29 +00:00
{
PROTOCOL_ENTER( this, PROT_LEAF, ACT_PREV_SECT, GetUpper()->FindSctFrm() )
SwLayoutFrm* pCol;
2012-02-16 12:01:24 +01:00
// ColumnFrm always contain a BodyFrm now
2000-09-18 23:08:29 +00:00
if( IsColBodyFrm() )
pCol = GetUpper();
else if( GetUpper()->IsColBodyFrm() )
pCol = GetUpper()->GetUpper();
else
pCol = NULL;
bool bJump = false;
2000-09-18 23:08:29 +00:00
if( pCol )
{
if( pCol->GetPrev() )
{
do
{
pCol = (SwLayoutFrm*)pCol->GetPrev();
2012-02-16 12:01:24 +01:00
// Is there any content?
2000-09-18 23:08:29 +00:00
// Gibt es dort Inhalt?
if( ((SwLayoutFrm*)pCol->Lower())->Lower() )
{
2012-02-16 12:01:24 +01:00
if( bJump ) // Did we skip a blank page?
SwFlowFrm::SetMoveBwdJump( sal_True );
2012-02-16 12:01:24 +01:00
return (SwLayoutFrm*)pCol->Lower(); // The columnm body
2000-09-18 23:08:29 +00:00
}
bJump = true;
2000-09-18 23:08:29 +00:00
} while( pCol->GetPrev() );
2012-02-16 12:01:24 +01:00
// We get here when all columns are empty, pCol is now the
// first column, we need the body though
2000-09-18 23:08:29 +00:00
pCol = (SwLayoutFrm*)pCol->Lower();
}
else
pCol = NULL;
}
2012-02-16 12:01:24 +01:00
if( bJump ) // Did we skip a blank page?
SwFlowFrm::SetMoveBwdJump( sal_True );
2000-09-18 23:08:29 +00:00
2012-02-16 12:01:24 +01:00
// Within sections in tables or section in headers/footers there can
// be only one column change be made, one of the above shortcuts should
// have applied, also when the section has a pPrev.
// Now we even consider an empty column...
OSL_ENSURE( FindSctFrm(), "GetNextSctLeaf: Missing SectionFrm" );
2000-09-18 23:08:29 +00:00
if( ( IsInTab() && !IsTabFrm() ) || FindFooterOrHeader() )
return pCol;
// === IMPORTANT ===
// Precondition, which needs to be hold, is that the <this> frame can be
// inside a table, but then the found section frame <pSect> is also inside
// this table.
2000-09-18 23:08:29 +00:00
SwSectionFrm *pSect = FindSctFrm();
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
// #i95698#
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
// A table cell containing directly a section does not break - see lcl_FindSectionsInRow(..)
// Thus, a table inside a section, which is inside another table can only
// flow backward in the columns of its section.
// Note: The table cell, which contains the section, can not have a master table cell.
if ( IsTabFrm() && pSect->IsInTab() )
{
return pCol;
}
2000-09-18 23:08:29 +00:00
{
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
SwFrm *pPrv;
if( 0 != ( pPrv = pSect->GetIndPrev() ) )
{
2012-02-16 12:01:24 +01:00
// Mooching, half dead SectionFrms shouldn't confuse us
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
while( pPrv && pPrv->IsSctFrm() && !((SwSectionFrm*)pPrv)->GetSection() )
pPrv = pPrv->GetPrev();
if( pPrv )
return pCol;
}
2000-09-18 23:08:29 +00:00
}
const sal_Bool bBody = IsInDocBody();
const sal_Bool bFly = IsInFly();
2000-09-18 23:08:29 +00:00
SwLayoutFrm *pLayLeaf = GetPrevLayoutLeaf();
SwLayoutFrm *pPrevLeaf = 0;
while ( pLayLeaf )
{
2012-02-16 12:01:24 +01:00
// Never step into tables or sections
CWS-TOOLING: integrate CWS sw31bf04 2009-01-21 14:24:10 +0100 od r266670 : #i59051# correction of metric change for PolyPolygonBezier needed 2009-01-21 09:35:44 +0100 od r266632 : #i96062# adjustment of fix after rebasing 2009-01-21 09:34:56 +0100 od r266631 : #i94152# adjustment of fix after rebasing 2009-01-20 16:43:12 +0100 od r266596 : CWS-TOOLING: rebase CWS sw31bf04 to trunk@266428 (milestone: DEV300:m39) 2009-01-20 11:52:22 +0100 od r266561 : #i94152 method <SwDoc::SetOutlineNumRule(..)> - assure that at outline list style registered text node have the correct list level set 2009-01-20 10:43:53 +0100 od r266556 : #i93399# methods <SwNumRule::SetIndent(..)> and <SwNumRule::ChangeIndent(..)> - adjust also the list tab position, if a list tab stop is applied 2009-01-16 16:26:56 +0100 od r266432 : #i59051# adjust Writer's UNO-API for drawing objects - correct conversion of "StartPosition" and "EndPosition" - conversion of "PolyPolygonBezier" 2009-01-16 16:20:49 +0100 od r266430 : #i59051# - adjust UNO-API of connector shape -- convert "PolyPolygonBezier" to correct metric -- convert "StartPosition" and "EndPosition" in set-method before applying anchor position - adjust UNO-API of measure shape -- convert "StartPosition" and "EndPosition" to correct metric 2009-01-16 15:01:21 +0100 od r266419 : #i95698# method <SwFrm::GetPrevSctLeaf(..)> - only columns as previous section leaves for tables inside sections, which are inside another table. 2009-01-14 14:34:58 +0100 od r266304 : #i96092# method <HandleResetAttrAtTxtNode::~HandleResetAttrAtTxtNode()> - set list level to outline level, if needed. 2009-01-13 17:09:43 +0100 od r266238 : #i98037# method <SwWW8ImplReader::IsObjectLayoutInTableCell(..)> - adjust evaluation of WW8 attributes 2009-01-13 11:49:48 +0100 od r266203 : #i94187# method <SwTxtFormatter::NewTabPortion(..)> - correct consideration of compatibility option TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST 2009-01-13 11:48:45 +0100 od r266202 : #i94187# method <OutWW8_SwTxtNode(..)> - set list style directly at paragraph only in position and space mode LABEL_WIDTH_AND_POSITION 2009-01-12 12:22:58 +0100 od r266143 : #i70582# method <SwFlyAtCntFrm::SetAbsPos(..)> and local method <lcl_CalcDownDist(..)> - correct determination of anchor's frame top for object positioning.
2009-02-13 10:05:35 +00:00
if ( pLayLeaf->IsInTab() || pLayLeaf->IsInSct() )
{
2000-09-18 23:08:29 +00:00
pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
}
2000-09-18 23:08:29 +00:00
else if ( bBody && pLayLeaf->IsInDocBody() )
{
// If there is a pLayLeaf has a lower pLayLeaf is the frame we are looking for.
// Exception: pLayLeaf->Lower() is a zombie section frame
const SwFrm* pTmp = pLayLeaf->Lower();
// OD 11.04.2003 #108824# - consider, that the zombie section frame
// can have frame below it in the found layout leaf.
// Thus, skipping zombie section frame, if possible.
while ( pTmp && pTmp->IsSctFrm() &&
!( static_cast<const SwSectionFrm*>(pTmp)->GetSection() ) &&
pTmp->GetNext()
)
{
pTmp = pTmp->GetNext();
}
if ( pTmp &&
( !pTmp->IsSctFrm() ||
( static_cast<const SwSectionFrm*>(pTmp)->GetSection() )
)
)
{
2000-09-18 23:08:29 +00:00
break;
}
2000-09-18 23:08:29 +00:00
pPrevLeaf = pLayLeaf;
pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
if ( pLayLeaf )
SwFlowFrm::SetMoveBwdJump( sal_True );
2000-09-18 23:08:29 +00:00
}
else if ( bFly )
2012-02-16 12:01:24 +01:00
break; // Cntnts in Flys every layout sheet should be right. Why?
2000-09-18 23:08:29 +00:00
else
pLayLeaf = pLayLeaf->GetPrevLayoutLeaf();
}
if( !pLayLeaf )
{
if( !pPrevLeaf )
return pCol;
pLayLeaf = pPrevLeaf;
}
SwSectionFrm* pNew = NULL;
2012-02-16 12:01:24 +01:00
// At first go to the end of the layout sheet
2000-09-18 23:08:29 +00:00
SwFrm *pTmp = pLayLeaf->Lower();
if( pTmp )
{
while( pTmp->GetNext() )
pTmp = pTmp->GetNext();
if( pTmp->IsSctFrm() )
{
2012-02-16 12:01:24 +01:00
// Half dead ones only interfere here
2000-09-18 23:08:29 +00:00
while( !((SwSectionFrm*)pTmp)->GetSection() && pTmp->GetPrev() &&
pTmp->GetPrev()->IsSctFrm() )
pTmp = pTmp->GetPrev();
if( ((SwSectionFrm*)pTmp)->GetFollow() == pSect )
pNew = (SwSectionFrm*)pTmp;
}
}
if( !pNew )
{
pNew = new SwSectionFrm( *pSect, sal_True );
2000-09-18 23:08:29 +00:00
pNew->InsertBefore( pLayLeaf, NULL );
2001-11-13 14:21:55 +00:00
pNew->Init();
2001-11-09 12:32:26 +00:00
SWRECTFN( pNew )
(pNew->*fnRect->fnMakePos)( pLayLeaf, pNew->GetPrev(), sal_True );
2000-09-18 23:08:29 +00:00
pLayLeaf = FIRSTLEAF( pNew );
2012-02-16 12:01:24 +01:00
if( !pNew->Lower() ) // Format single column sections
2000-09-18 23:08:29 +00:00
{
pNew->MakePos();
2012-02-16 12:01:24 +01:00
pLayLeaf->Format(); // In order that the PrtArea is correct for the MoveBwd
2000-09-18 23:08:29 +00:00
}
else
pNew->SimpleFormat();
}
else
{
pLayLeaf = FIRSTLEAF( pNew );
if( pLayLeaf->IsColBodyFrm() )
{
// In existent section columns we're looking for the last not empty
// column.
SwLayoutFrm *pTmpLay = pLayLeaf;
2000-09-18 23:08:29 +00:00
while( pLayLeaf->GetUpper()->GetNext() )
{
2000-09-18 23:08:29 +00:00
pLayLeaf = (SwLayoutFrm*)((SwLayoutFrm*)pLayLeaf->GetUpper()->GetNext())->Lower();
if( pLayLeaf->Lower() )
pTmpLay = pLayLeaf;
}
// If we skipped an empty column, we've to set the jump-flag
if( pLayLeaf != pTmpLay )
{
pLayLeaf = pTmpLay;
SwFlowFrm::SetMoveBwdJump( sal_True );
}
2000-09-18 23:08:29 +00:00
}
}
return pLayLeaf;
}
static SwTwips lcl_DeadLine( const SwFrm* pFrm )
2000-09-18 23:08:29 +00:00
{
const SwLayoutFrm* pUp = pFrm->GetUpper();
while( pUp && pUp->IsInSct() )
{
if( pUp->IsSctFrm() )
pUp = pUp->GetUpper();
2012-02-16 12:01:24 +01:00
// Columns now with BodyFrm
2000-09-18 23:08:29 +00:00
else if( pUp->IsColBodyFrm() && pUp->GetUpper()->GetUpper()->IsSctFrm() )
pUp = pUp->GetUpper()->GetUpper();
else
break;
}
2001-11-09 12:32:26 +00:00
SWRECTFN( pFrm )
2001-12-12 13:44:09 +00:00
return pUp ? (pUp->*fnRect->fnGetPrtBottom)() :
2001-11-09 12:32:26 +00:00
(pFrm->Frm().*fnRect->fnGetBottom)();
2000-09-18 23:08:29 +00:00
}
2012-02-16 12:01:24 +01:00
// SwSectionFrm::Growable(..) checks whether the SectionFrm is still able to
// grow, as case may be the environment has to be asked
2000-09-18 23:08:29 +00:00
sal_Bool SwSectionFrm::Growable() const
2000-09-18 23:08:29 +00:00
{
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
if( (*fnRect->fnYDiff)( lcl_DeadLine( this ),
(Frm().*fnRect->fnGetBottom)() ) > 0 )
return sal_True;
return ( GetUpper() && ((SwFrm*)GetUpper())->Grow( LONG_MAX, sal_True ) );
2000-09-18 23:08:29 +00:00
}
/*************************************************************************
|*
|* SwSectionFrm::_Grow(), _Shrink()
|*
|*************************************************************************/
SwTwips SwSectionFrm::_Grow( SwTwips nDist, sal_Bool bTst )
2001-10-19 09:25:19 +00:00
{
if ( !IsColLocked() && !HasFixSize() )
{
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if( nFrmHeight > 0 && nDist > (LONG_MAX - nFrmHeight) )
nDist = LONG_MAX - nFrmHeight;
2000-09-18 23:08:29 +00:00
if ( nDist <= 0L )
return 0L;
bool bInCalcCntnt = GetUpper() && IsInFly() && FindFlyFrm()->IsLocked();
// OD 2004-03-15 #116561# - allow grow in online layout
bool bGrow = !Lower() || !Lower()->IsColumnFrm() || !Lower()->GetNext() ||
GetSection()->GetFmt()->GetBalancedColumns().GetValue();
if( !bGrow )
{
const ViewShell *pSh = getRootFrm()->GetCurrShell();
bGrow = pSh && pSh->GetViewOptions()->getBrowseMode();
}
if( bGrow )
2000-09-18 23:08:29 +00:00
{
2001-11-09 12:32:26 +00:00
SwTwips nGrow;
if( IsInFtn() )
nGrow = 0;
else
{
nGrow = lcl_DeadLine( this );
nGrow = (*fnRect->fnYDiff)( nGrow,
(Frm().*fnRect->fnGetBottom)() );
}
2000-09-18 23:08:29 +00:00
SwTwips nSpace = nGrow;
2001-11-13 14:21:55 +00:00
if( !bInCalcCntnt && nGrow < nDist && GetUpper() )
nGrow += GetUpper()->Grow( LONG_MAX, sal_True );
2000-09-18 23:08:29 +00:00
if( nGrow > nDist )
nGrow = nDist;
if( nGrow <= 0 )
{
nGrow = 0;
if( nDist && !bTst )
{
if( bInCalcCntnt )
_InvalidateSize();
else
InvalidateSize();
}
}
else if( !bTst )
{
if( bInCalcCntnt )
_InvalidateSize();
else if( nSpace < nGrow && nDist != nSpace + GetUpper()->
Grow( nGrow - nSpace, sal_False ) )
2000-09-18 23:08:29 +00:00
InvalidateSize();
else
{
const SvxGraphicPosition ePos =
GetAttrSet()->GetBackground().GetGraphicPos();
if ( GPOS_RT < ePos && GPOS_TILED != ePos )
{
SetCompletePaint();
InvalidatePage();
}
if( GetUpper() && GetUpper()->IsHeaderFrm() )
GetUpper()->InvalidateSize();
2000-09-18 23:08:29 +00:00
}
2001-11-09 12:32:26 +00:00
(Frm().*fnRect->fnAddBottom)( nGrow );
long nPrtHeight = (Prt().*fnRect->fnGetHeight)() + nGrow;
(Prt().*fnRect->fnSetHeight)( nPrtHeight );
2000-09-18 23:08:29 +00:00
if( Lower() && Lower()->IsColumnFrm() && Lower()->GetNext() )
{
SwFrm* pTmp = Lower();
do
{
pTmp->_InvalidateSize();
pTmp = pTmp->GetNext();
} while ( pTmp );
_InvalidateSize();
}
if( GetNext() )
{
SwFrm *pFrm = GetNext();
while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
pFrm = pFrm->GetNext();
if( pFrm )
{
if( bInCalcCntnt )
pFrm->_InvalidatePos();
else
pFrm->InvalidatePos();
}
}
// #i28701# - Due to the new object positioning
// the frame on the next page/column can flow backward (e.g. it
// was moved forward due to the positioning of its objects ).
// Thus, invalivate this next frame, if document compatibility
// option 'Consider wrapping style influence on object positioning' is ON.
else if ( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
{
InvalidateNextPos();
}
2000-09-18 23:08:29 +00:00
}
return nGrow;
}
if ( !bTst )
{
if( bInCalcCntnt )
_InvalidateSize();
else
InvalidateSize();
}
}
return 0L;
}
SwTwips SwSectionFrm::_Shrink( SwTwips nDist, sal_Bool bTst )
2001-10-19 09:25:19 +00:00
{
if ( Lower() && !IsColLocked() && !HasFixSize() )
2000-09-18 23:08:29 +00:00
{
if( ToMaximize( sal_False ) )
2000-09-18 23:08:29 +00:00
{
if( !bTst )
InvalidateSize();
}
else
{
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
if ( nDist > nFrmHeight )
nDist = nFrmHeight;
2000-09-18 23:08:29 +00:00
if ( Lower()->IsColumnFrm() && Lower()->GetNext() && // FtnAtEnd
!GetSection()->GetFmt()->GetBalancedColumns().GetValue() )
2012-02-16 12:01:24 +01:00
{ // With column bases the format takes over the control of the
// growth (because of the balance)
2000-09-18 23:08:29 +00:00
if ( !bTst )
InvalidateSize();
return nDist;
}
else if( !bTst )
{
const SvxGraphicPosition ePos =
GetAttrSet()->GetBackground().GetGraphicPos();
if ( GPOS_RT < ePos && GPOS_TILED != ePos )
{
SetCompletePaint();
InvalidatePage();
}
2001-11-09 12:32:26 +00:00
(Frm().*fnRect->fnAddBottom)( -nDist );
long nPrtHeight = (Prt().*fnRect->fnGetHeight)() - nDist;
(Prt().*fnRect->fnSetHeight)( nPrtHeight );
// We do not allow a section frame to shrink the its upper
// footer frame. This is because in the calculation of a
// footer frame, the content of the section frame is _not_
// calculated. If there is a fly frame overlapping with the
// footer frame, the section frame is not affected by this
// during the calculation of the footer frame size.
// The footer frame does not grow in its FormatSize function
// but during the calculation of the content of the section
// frame. The section frame grows until some of its text is
// located on top of the fly frame. The next call of CalcCntnt
// tries to shrink the section and here it would also shrink
// the footer. This may not happen, because shrinking the footer
// would cause the top of the section frame to overlap with the
// fly frame again, this would result in a perfect loop.
if( GetUpper() && !GetUpper()->IsFooterFrm() )
2010-12-10 20:32:10 +00:00
GetUpper()->Shrink( nDist, bTst );
2000-09-18 23:08:29 +00:00
if( Lower() && Lower()->IsColumnFrm() && Lower()->GetNext() )
{
SwFrm* pTmp = Lower();
do
{
pTmp->_InvalidateSize();
pTmp = pTmp->GetNext();
} while ( pTmp );
}
if( GetNext() )
{
SwFrm* pFrm = GetNext();
while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
pFrm = pFrm->GetNext();
if( pFrm )
pFrm->InvalidatePos();
else
SetRetouche();
}
else
SetRetouche();
return nDist;
}
}
}
return 0L;
}
/*************************************************************************
|*
|* SwSectionFrm::MoveAllowed()
|*
2012-02-16 12:01:24 +01:00
|* When are Frms within a SectionFrms moveable?
|* If they are not in the last column of a SectionFrms yet,
|* if there is no Follow,
|* if the SectionFrm cannot grow anymore, then it gets more complicated,
|* in that case it depends on whether the SectionFrm can find a next
|* layout sheet. In (column based/chained) Flys this is checked via
|* GetNextLayout, in tables and headers/footers there is none, however in the
|* DocBody and in foot notes there is always one.
|* This routine is used in the TxtFormatter to decided whether it's allowed to
|* create a (paragraph-)Follow or whether the paragraph has to stick together
2000-09-18 23:08:29 +00:00
|*
|*************************************************************************/
sal_Bool SwSectionFrm::MoveAllowed( const SwFrm* pFrm) const
2000-09-18 23:08:29 +00:00
{
2012-02-16 12:01:24 +01:00
// Is there a Follow or is the Frame not in the last column?
2000-09-18 23:08:29 +00:00
if( HasFollow() || ( pFrm->GetUpper()->IsColBodyFrm() &&
pFrm->GetUpper()->GetUpper()->GetNext() ) )
return sal_True;
2000-09-18 23:08:29 +00:00
if( pFrm->IsInFtn() )
{
if( IsInFtn() )
{
if( GetUpper()->IsInSct() )
{
if( Growable() )
return sal_False;
2000-09-18 23:08:29 +00:00
return GetUpper()->FindSctFrm()->MoveAllowed( this );
}
else
return sal_True;
2000-09-18 23:08:29 +00:00
}
// The content of footnote inside a columned sectionfrm is moveable
// except in the last column
const SwLayoutFrm *pLay = pFrm->FindFtnFrm()->GetUpper()->GetUpper();
if( pLay->IsColumnFrm() && pLay->GetNext() )
{
// The first paragraph in the first footnote in the first column
// in the sectionfrm at the top of the page is not moveable,
// if the columnbody is empty.
bool bRet = false;
2000-09-18 23:08:29 +00:00
if( pLay->GetIndPrev() || pFrm->GetIndPrev() ||
pFrm->FindFtnFrm()->GetPrev() )
bRet = true;
2000-09-18 23:08:29 +00:00
else
{
SwLayoutFrm* pBody = ((SwColumnFrm*)pLay)->FindBodyCont();
if( pBody && pBody->Lower() )
bRet = true;
2000-09-18 23:08:29 +00:00
}
if( bRet && ( IsFtnAtEnd() || !Growable() ) )
return sal_True;
2000-09-18 23:08:29 +00:00
}
}
2012-02-16 12:01:24 +01:00
// Or can the section still grow?
2000-09-18 23:08:29 +00:00
if( !IsColLocked() && Growable() )
return sal_False;
2012-02-16 12:01:24 +01:00
// Now it has to be examined whether there is a layout sheet wherein
// a section Follow can be created
2000-09-18 23:08:29 +00:00
if( IsInTab() || ( !IsInDocBody() && FindFooterOrHeader() ) )
2012-02-16 12:01:24 +01:00
return sal_False; // It doesn't work in tables/headers/footers
if( IsInFly() ) // In column based or chained frames
2000-09-18 23:08:29 +00:00
return 0 != ((SwFrm*)GetUpper())->GetNextLeaf( MAKEPAGE_NONE );
return sal_True;
2000-09-18 23:08:29 +00:00
}
/** Called for a frame inside a section with no direct previous frame (or only
previous empty section frames) the previous frame of the outer section is
returned, if the frame is the first flowing content of this section.
Note: For a frame inside a table frame, which is inside a section frame,
NULL is returned.
*/
SwFrm* SwFrm::_GetIndPrev() const
2000-09-18 23:08:29 +00:00
{
SwFrm *pRet = NULL;
// #i79774#
// Do not assert, if the frame has a direct previous frame, because it
// could be an empty section frame. The caller has to assure, that the
// frame has no direct previous frame or only empty section frames as
// previous frames.
OSL_ENSURE( /*!pPrev &&*/ IsInSct(), "Why?" );
const SwFrm* pSct = GetUpper();
2000-09-18 23:08:29 +00:00
if( !pSct )
return NULL;
if( pSct->IsSctFrm() )
pRet = pSct->GetIndPrev();
else if( pSct->IsColBodyFrm() && (pSct = pSct->GetUpper()->GetUpper())->IsSctFrm() )
{
// Do not return the previous frame of the outer section, if in one
// of the previous columns is content.
const SwFrm* pCol = GetUpper()->GetUpper()->GetPrev();
2000-09-18 23:08:29 +00:00
while( pCol )
{
OSL_ENSURE( pCol->IsColumnFrm(), "GetIndPrev(): ColumnFrm expected" );
OSL_ENSURE( pCol->GetLower() && pCol->GetLower()->IsBodyFrm(),
2000-09-18 23:08:29 +00:00
"GetIndPrev(): Where's the body?");
if( ((SwLayoutFrm*)((SwLayoutFrm*)pCol)->Lower())->Lower() )
return NULL;
pCol = pCol->GetPrev();
}
pRet = pSct->GetIndPrev();
}
// skip empty section frames
2000-09-18 23:08:29 +00:00
while( pRet && pRet->IsSctFrm() && !((SwSectionFrm*)pRet)->GetSection() )
pRet = pRet->GetIndPrev();
return pRet;
}
SwFrm* SwFrm::_GetIndNext()
{
OSL_ENSURE( !pNext && IsInSct(), "Why?" );
2000-09-18 23:08:29 +00:00
SwFrm* pSct = GetUpper();
if( !pSct )
return NULL;
if( pSct->IsSctFrm() )
return pSct->GetIndNext();
if( pSct->IsColBodyFrm() && (pSct = pSct->GetUpper()->GetUpper())->IsSctFrm() )
2012-02-16 12:01:24 +01:00
{ // We can only return the successor of the SectionFrms if there is no
// content in the successing columns
2000-09-18 23:08:29 +00:00
SwFrm* pCol = GetUpper()->GetUpper()->GetNext();
while( pCol )
{
OSL_ENSURE( pCol->IsColumnFrm(), "GetIndNext(): ColumnFrm expected" );
OSL_ENSURE( pCol->GetLower() && pCol->GetLower()->IsBodyFrm(),
2000-09-18 23:08:29 +00:00
"GetIndNext(): Where's the body?");
if( ((SwLayoutFrm*)((SwLayoutFrm*)pCol)->Lower())->Lower() )
return NULL;
pCol = pCol->GetNext();
}
return pSct->GetIndNext();
}
return NULL;
}
sal_Bool SwSectionFrm::IsDescendantFrom( const SwSectionFmt* pFmt ) const
2000-09-18 23:08:29 +00:00
{
if( !pSection || !pFmt )
return sal_False;
2000-09-18 23:08:29 +00:00
const SwSectionFmt *pMyFmt = pSection->GetFmt();
while( pFmt != pMyFmt )
{
if( pMyFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pMyFmt = (SwSectionFmt*)pMyFmt->GetRegisteredIn();
else
return sal_False;
2000-09-18 23:08:29 +00:00
}
return sal_True;
2000-09-18 23:08:29 +00:00
}
void SwSectionFrm::CalcFtnAtEndFlag()
{
SwSectionFmt *pFmt = GetSection()->GetFmt();
sal_uInt16 nVal = pFmt->GetFtnAtTxtEnd( sal_False ).GetValue();
2000-09-18 23:08:29 +00:00
bFtnAtEnd = FTNEND_ATPGORDOCEND != nVal;
bOwnFtnNum = FTNEND_ATTXTEND_OWNNUMSEQ == nVal ||
FTNEND_ATTXTEND_OWNNUMANDFMT == nVal;
while( !bFtnAtEnd && !bOwnFtnNum )
{
if( pFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pFmt = (SwSectionFmt*)pFmt->GetRegisteredIn();
else
break;
nVal = pFmt->GetFtnAtTxtEnd( sal_False ).GetValue();
2000-09-18 23:08:29 +00:00
if( FTNEND_ATPGORDOCEND != nVal )
{
bFtnAtEnd = sal_True;
2000-09-18 23:08:29 +00:00
bOwnFtnNum = bOwnFtnNum ||FTNEND_ATTXTEND_OWNNUMSEQ == nVal ||
FTNEND_ATTXTEND_OWNNUMANDFMT == nVal;
}
}
}
2011-11-18 18:55:47 +01:00
bool SwSectionFrm::IsEndnoteAtMyEnd() const
2000-09-18 23:08:29 +00:00
{
return pSection->GetFmt()->GetEndAtTxtEnd( sal_False ).IsAtEnd();
2000-09-18 23:08:29 +00:00
}
void SwSectionFrm::CalcEndAtEndFlag()
{
SwSectionFmt *pFmt = GetSection()->GetFmt();
bEndnAtEnd = pFmt->GetEndAtTxtEnd( sal_False ).IsAtEnd();
2000-09-18 23:08:29 +00:00
while( !bEndnAtEnd )
{
if( pFmt->GetRegisteredIn()->ISA( SwSectionFmt ) )
pFmt = (SwSectionFmt*)pFmt->GetRegisteredIn();
else
break;
bEndnAtEnd = pFmt->GetEndAtTxtEnd( sal_False ).IsAtEnd();
2000-09-18 23:08:29 +00:00
}
}
/*************************************************************************
|*
|* SwSectionFrm::Modify()
|*
|*************************************************************************/
void SwSectionFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
2000-09-18 23:08:29 +00:00
{
sal_uInt8 nInvFlags = 0;
2000-09-18 23:08:29 +00:00
if( pNew && RES_ATTRSET_CHG == pNew->Which() )
{
SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
while( true )
2000-09-18 23:08:29 +00:00
{
_UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
(SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
&aOldSet, &aNewSet );
if( aNIter.IsAtEnd() )
break;
aNIter.NextItem();
aOIter.NextItem();
}
if ( aOldSet.Count() || aNewSet.Count() )
SwLayoutFrm::Modify( &aOldSet, &aNewSet );
}
else
_UpdateAttr( pOld, pNew, nInvFlags );
if ( nInvFlags != 0 )
{
if ( nInvFlags & 0x01 )
InvalidateSize();
if ( nInvFlags & 0x10 )
SetCompletePaint();
}
}
void SwSectionFrm::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
{
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
// #i117863#
const SwSectionFrmMoveAndDeleteHint* pHint =
dynamic_cast<const SwSectionFrmMoveAndDeleteHint*>(&rHint);
if ( pHint && pHint->GetId() == SFX_HINT_DYING && &rMod == GetRegisteredIn() )
{
SwSectionFrm::MoveCntntAndDelete( this, pHint->IsSaveCntnt() );
}
}
void SwSectionFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
sal_uInt8 &rInvFlags,
2000-09-18 23:08:29 +00:00
SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
{
bool bClear = true;
const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
2000-09-18 23:08:29 +00:00
switch( nWhich )
2012-02-16 12:01:24 +01:00
{ // Suppress multi columns in foot notes
2000-09-18 23:08:29 +00:00
case RES_FMT_CHG:
{
const SwFmtCol& rNewCol = GetFmt()->GetCol();
if( !IsInFtn() )
{
2012-02-16 12:01:24 +01:00
// Nasty case. When allocating a template we can not count
// on the old column attribute. We're left with creating a
// temporary attribute here.
2000-09-18 23:08:29 +00:00
SwFmtCol aCol;
if ( Lower() && Lower()->IsColumnFrm() )
{
sal_uInt16 nCol = 0;
2000-09-18 23:08:29 +00:00
SwFrm *pTmp = Lower();
do
{ ++nCol;
pTmp = pTmp->GetNext();
} while ( pTmp );
aCol.Init( nCol, 0, 1000 );
}
2011-11-18 18:55:47 +01:00
bool bChgFtn = IsFtnAtEnd();
bool const bChgEndn = IsEndnAtEnd();
bool const bChgMyEndn = IsEndnoteAtMyEnd();
2000-09-18 23:08:29 +00:00
CalcFtnAtEndFlag();
CalcEndAtEndFlag();
2011-11-18 18:55:47 +01:00
bChgFtn = ( bChgFtn != IsFtnAtEnd() ) ||
( bChgEndn != IsEndnAtEnd() ) ||
2000-09-18 23:08:29 +00:00
( bChgMyEndn != IsEndnoteAtMyEnd() );
ChgColumns( aCol, rNewCol, bChgFtn );
rInvFlags |= 0x10;
}
rInvFlags |= 0x01;
bClear = false;
2000-09-18 23:08:29 +00:00
}
break;
case RES_COL:
if( !IsInFtn() )
{
ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew );
rInvFlags |= 0x11;
}
break;
case RES_FTN_AT_TXTEND:
if( !IsInFtn() )
{
2011-11-18 18:55:47 +01:00
bool const bOld = IsFtnAtEnd();
2000-09-18 23:08:29 +00:00
CalcFtnAtEndFlag();
2011-11-18 18:55:47 +01:00
if (bOld != IsFtnAtEnd())
2000-09-18 23:08:29 +00:00
{
const SwFmtCol& rNewCol = GetFmt()->GetCol();
ChgColumns( rNewCol, rNewCol, sal_True );
2000-09-18 23:08:29 +00:00
rInvFlags |= 0x01;
}
}
break;
case RES_END_AT_TXTEND:
if( !IsInFtn() )
{
2011-11-18 18:55:47 +01:00
bool const bOld = IsEndnAtEnd();
bool const bMyOld = IsEndnoteAtMyEnd();
2000-09-18 23:08:29 +00:00
CalcEndAtEndFlag();
2011-11-18 18:55:47 +01:00
if (bOld != IsEndnAtEnd() || bMyOld != IsEndnoteAtMyEnd())
2000-09-18 23:08:29 +00:00
{
const SwFmtCol& rNewCol = GetFmt()->GetCol();
ChgColumns( rNewCol, rNewCol, sal_True );
2000-09-18 23:08:29 +00:00
rInvFlags |= 0x01;
}
}
break;
case RES_COLUMNBALANCE:
rInvFlags |= 0x01;
break;
case RES_FRAMEDIR :
SetDerivedR2L( sal_False );
CheckDirChange();
break;
case RES_PROTECT:
{
ViewShell *pSh = getRootFrm()->GetCurrShell();
if( pSh && pSh->GetLayout()->IsAnyShellAccessible() )
pSh->Imp()->InvalidateAccessibleEditableState( sal_True, this );
}
break;
2000-09-18 23:08:29 +00:00
default:
bClear = false;
2000-09-18 23:08:29 +00:00
}
if ( bClear )
{
if ( pOldSet || pNewSet )
{
if ( pOldSet )
pOldSet->ClearItem( nWhich );
if ( pNewSet )
pNewSet->ClearItem( nWhich );
}
else
SwLayoutFrm::Modify( pOld, pNew );
}
}
/*--------------------------------------------------
2000-09-18 23:08:29 +00:00
* SwSectionFrm::ToMaximize(..): A follow or a ftncontainer at the end of the
* page causes a maximal Size of the sectionframe.
* --------------------------------------------------*/
sal_Bool SwSectionFrm::ToMaximize( sal_Bool bCheckFollow ) const
2000-09-18 23:08:29 +00:00
{
if( HasFollow() )
{
if( !bCheckFollow ) // Don't check superfluous follows
return sal_True;
2000-09-18 23:08:29 +00:00
const SwSectionFrm* pFoll = GetFollow();
while( pFoll && pFoll->IsSuperfluous() )
pFoll = pFoll->GetFollow();
if( pFoll )
return sal_True;
2000-09-18 23:08:29 +00:00
}
if( IsFtnAtEnd() )
return sal_False;
2000-09-18 23:08:29 +00:00
const SwFtnContFrm* pCont = ContainsFtnCont();
if( !IsEndnAtEnd() )
return 0 != pCont;
sal_Bool bRet = sal_False;
2000-09-18 23:08:29 +00:00
while( pCont && !bRet )
{
if( pCont->FindFootNote() )
bRet = sal_True;
2000-09-18 23:08:29 +00:00
else
pCont = ContainsFtnCont( pCont );
}
return bRet;
}
/*--------------------------------------------------
* sal_Bool SwSectionFrm::ContainsFtnCont()
2000-09-18 23:08:29 +00:00
* checks every Column for FtnContFrms.
* --------------------------------------------------*/
SwFtnContFrm* SwSectionFrm::ContainsFtnCont( const SwFtnContFrm* pCont ) const
{
SwFtnContFrm* pRet = NULL;
const SwLayoutFrm* pLay;
if( pCont )
{
pLay = pCont->FindFtnBossFrm( 0 );
OSL_ENSURE( IsAnLower( pLay ), "ConatainsFtnCont: Wrong FtnContainer" );
2000-09-18 23:08:29 +00:00
pLay = (SwLayoutFrm*)pLay->GetNext();
}
else if( Lower() && Lower()->IsColumnFrm() )
pLay = (SwLayoutFrm*)Lower();
else
pLay = NULL;
while ( !pRet && pLay )
{
if( pLay->Lower() && pLay->Lower()->GetNext() )
{
OSL_ENSURE( pLay->Lower()->GetNext()->IsFtnContFrm(),
2000-09-18 23:08:29 +00:00
"ToMaximize: Unexspected Frame" );
pRet = (SwFtnContFrm*)pLay->Lower()->GetNext();
}
OSL_ENSURE( !pLay->GetNext() || pLay->GetNext()->IsLayoutFrm(),
2000-09-18 23:08:29 +00:00
"ToMaximize: ColFrm exspected" );
pLay = (SwLayoutFrm*)pLay->GetNext();
}
return pRet;
}
void SwSectionFrm::InvalidateFtnPos()
{
SwFtnContFrm* pCont = ContainsFtnCont( NULL );
if( pCont )
{
SwFrm *pTmp = pCont->ContainsCntnt();
if( pTmp )
pTmp->_InvalidatePos();
}
}
/*--------------------------------------------------
2012-02-16 12:01:24 +01:00
* SwSectionFrm::Undersize() returns the value that the section
* would like to be greater if it has undersized TxtFrms in it,
* otherwise Null..
* If necessary the undersized-flag is corrected.
2000-09-18 23:08:29 +00:00
* --------------------------------------------------*/
long SwSectionFrm::Undersize( sal_Bool bOverSize )
2000-09-18 23:08:29 +00:00
{
bUndersized = sal_False;
2001-11-09 12:32:26 +00:00
SWRECTFN( this )
long nRet = InnerHeight() - (Prt().*fnRect->fnGetHeight)();
2000-09-18 23:08:29 +00:00
if( nRet > 0 )
bUndersized = sal_True;
2000-09-18 23:08:29 +00:00
else if( !bOverSize )
nRet = 0;
return nRet;
}
/// OD 01.04.2003 #108446# - determine next frame for footnote/endnote formatting
/// before format of current one, because current one can move backward.
/// After moving backward to a previous page method <FindNext()> will return
/// the text frame presenting the first page footnote, if it exists. Thus, the
/// rest of the footnote/endnote container would not be formatted.
2000-09-18 23:08:29 +00:00
void SwSectionFrm::CalcFtnCntnt()
{
SwFtnContFrm* pCont = ContainsFtnCont();
if( pCont )
{
SwFrm* pFrm = pCont->ContainsAny();
if( pFrm )
pCont->Calc();
while( pFrm && IsAnLower( pFrm ) )
{
SwFtnFrm* pFtn = pFrm->FindFtnFrm();
if( pFtn )
pFtn->Calc();
// OD 01.04.2003 #108446# - determine next frame before format current frame.
SwFrm* pNextFrm = 0;
2000-09-18 23:08:29 +00:00
{
if( pFrm->IsSctFrm() )
2000-09-18 23:08:29 +00:00
{
pNextFrm = static_cast<SwSectionFrm*>(pFrm)->ContainsAny();
}
if( !pNextFrm )
{
pNextFrm = pFrm->FindNext();
2000-09-18 23:08:29 +00:00
}
}
pFrm->Calc();
pFrm = pNextFrm;
2000-09-18 23:08:29 +00:00
}
}
}
/* --------------------------------------------------
2012-02-16 12:01:24 +01:00
* If a SectionFrm gets empty, e.g. because its content changes the page/column,
* it is not destroyed immediately (there could be a pointer left to it on the
* stack), instead it puts itself in a list at the RootFrm, which is processed
* later on (in Layaction::Action among others). Its size is set to Null and
* the pointer to its page as well. Such SectionFrms that are to be deleted
* must be ignored by the layout/during formatting.
2000-09-18 23:08:29 +00:00
*
2012-02-16 12:01:24 +01:00
* With InsertEmptySct the RootFrm stores a SectionFrm in the list,
* with RemoveFromList it can be removed from the list (Dtor),
* with DeleteEmptySct the list is processed and the SectionFrms are destroyed.
2000-09-18 23:08:29 +00:00
* --------------------------------------------------*/
void SwRootFrm::InsertEmptySct( SwSectionFrm* pDel )
{
if( !pDestroy )
pDestroy = new SwDestroyList;
pDestroy->insert( pDel );
2000-09-18 23:08:29 +00:00
}
void SwRootFrm::_DeleteEmptySct()
{
OSL_ENSURE( pDestroy, "Keine Liste, keine Kekse" );
while( !pDestroy->empty() )
2000-09-18 23:08:29 +00:00
{
SwSectionFrm* pSect = *pDestroy->begin();
pDestroy->erase( pDestroy->begin() );
OSL_ENSURE( !pSect->IsColLocked() && !pSect->IsJoinLocked(),
2000-09-18 23:08:29 +00:00
"DeleteEmptySct: Locked SectionFrm" );
if( !pSect->Frm().HasArea() && !pSect->ContainsCntnt() )
{
SwLayoutFrm* pUp = pSect->GetUpper();
pSect->Remove();
delete pSect;
if( pUp && !pUp->Lower() )
{
if( pUp->IsPageBodyFrm() )
pUp->getRootFrm()->SetSuperfluous();
2000-09-18 23:08:29 +00:00
else if( pUp->IsFtnFrm() && !pUp->IsColLocked() &&
pUp->GetUpper() )
{
pUp->Cut();
delete pUp;
}
}
}
else {
OSL_ENSURE( pSect->GetSection(), "DeleteEmptySct: Halbtoter SectionFrm?!" );
}
2000-09-18 23:08:29 +00:00
}
}
void SwRootFrm::_RemoveFromList( SwSectionFrm* pSct )
{
OSL_ENSURE( pDestroy, "Where's my list?" );
pDestroy->erase( pSct );
2000-09-18 23:08:29 +00:00
}
#ifdef DBG_UTIL
bool SwRootFrm::IsInDelList( SwSectionFrm* pSct ) const
2000-09-18 23:08:29 +00:00
{
return pDestroy && pDestroy->find( pSct ) != pDestroy->end();
2000-09-18 23:08:29 +00:00
}
#endif
bool SwSectionFrm::IsBalancedSection() const
{
bool bRet = false;
if ( GetSection() && Lower() && Lower()->IsColumnFrm() && Lower()->GetNext() )
{
bRet = !GetSection()->GetFmt()->GetBalancedColumns().GetValue();
}
return bRet;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */