2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:42:29 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:42:29 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:42:29 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:42:29 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:42:29 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:42:29 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 20:17:03 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <hintids.hxx>
|
|
|
|
#include "cntfrm.hxx"
|
|
|
|
#include "doc.hxx"
|
|
|
|
|
|
|
|
#include "hintids.hxx"
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/ulspitem.hxx>
|
|
|
|
#include <editeng/lrspitem.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtclds.hxx>
|
|
|
|
#include <fmtfordr.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
#include <node.hxx>
|
|
|
|
#include "frmtool.hxx"
|
|
|
|
#include "colfrm.hxx"
|
|
|
|
#include "pagefrm.hxx"
|
2012-02-13 11:36:53 +01:00
|
|
|
#include "bodyfrm.hxx" // ColumnFrms now with BodyFrm
|
2000-09-18 23:08:29 +00:00
|
|
|
#include "rootfrm.hxx" // wg. RemoveFtns
|
|
|
|
#include "sectfrm.hxx" // wg. FtnAtEnd-Flag
|
2010-12-17 09:02:23 +01:00
|
|
|
#include "switerator.hxx"
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// ftnfrm.cxx:
|
2012-10-12 16:49:40 +02:00
|
|
|
void sw_RemoveFtns( SwFtnBossFrm* pBoss, sal_Bool bPageOnly, sal_Bool bEndNotes );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwColumnFrm::SwColumnFrm()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2010-06-13 15:22:56 +02:00
|
|
|
SwColumnFrm::SwColumnFrm( SwFrmFmt *pFmt, SwFrm* pSib ):
|
|
|
|
SwFtnBossFrm( pFmt, pSib )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-08-23 13:41:20 +00:00
|
|
|
nType = FRMC_COLUMN;
|
2010-06-13 15:22:56 +02:00
|
|
|
SwBodyFrm* pColBody = new SwBodyFrm( pFmt->GetDoc()->GetDfltFrmFmt(), pSib );
|
2012-02-13 11:36:53 +01:00
|
|
|
pColBody->InsertBehind( this, 0 ); // ColumnFrms now with BodyFrm
|
2000-09-18 23:08:29 +00:00
|
|
|
SetMaxFtnHeight( LONG_MAX );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwColumnFrm::~SwColumnFrm()
|
|
|
|
{
|
|
|
|
SwFrmFmt *pFmt = GetFmt();
|
|
|
|
SwDoc *pDoc;
|
|
|
|
if ( !(pDoc = pFmt->GetDoc())->IsInDtor() && pFmt->IsLastDepend() )
|
|
|
|
{
|
2012-02-13 11:36:53 +01:00
|
|
|
//I'm the only one, delete the format.
|
|
|
|
//Get default format before, so the base class can cope with it.
|
2000-09-18 23:08:29 +00:00
|
|
|
pDoc->GetDfltFrmFmt()->Add( this );
|
|
|
|
pDoc->DelFrmFmt( pFmt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwLayoutFrm::ChgColumns()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_RemoveColumns( SwLayoutFrm *pCont, sal_uInt16 nCnt )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pCont && pCont->Lower() && pCont->Lower()->IsColumnFrm(),
|
2000-09-18 23:08:29 +00:00
|
|
|
"Keine Spalten zu entfernen." );
|
|
|
|
|
|
|
|
SwColumnFrm *pColumn = (SwColumnFrm*)pCont->Lower();
|
2012-10-12 16:49:40 +02:00
|
|
|
sw_RemoveFtns( pColumn, sal_True, sal_True );
|
2000-09-18 23:08:29 +00:00
|
|
|
while ( pColumn->GetNext() )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pColumn->GetNext()->IsColumnFrm(),
|
2000-09-18 23:08:29 +00:00
|
|
|
"Nachbar von ColFrm kein ColFrm." );
|
|
|
|
pColumn = (SwColumnFrm*)pColumn->GetNext();
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < nCnt; ++i )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwColumnFrm *pTmp = (SwColumnFrm*)pColumn->GetPrev();
|
|
|
|
pColumn->Cut();
|
2012-02-13 11:36:53 +01:00
|
|
|
delete pColumn; //format is going to be destroyed in the DTor if needed.
|
2000-09-18 23:08:29 +00:00
|
|
|
pColumn = pTmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static SwLayoutFrm * lcl_FindColumns( SwLayoutFrm *pLay, sal_uInt16 nCount )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwFrm *pCol = pLay->Lower();
|
|
|
|
if ( pLay->IsPageFrm() )
|
|
|
|
pCol = ((SwPageFrm*)pLay)->FindBodyCont()->Lower();
|
|
|
|
|
|
|
|
if ( pCol && pCol->IsColumnFrm() )
|
|
|
|
{
|
|
|
|
SwFrm *pTmp = pCol;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 i;
|
2000-09-18 23:08:29 +00:00
|
|
|
for ( i = 0; pTmp; pTmp = pTmp->GetNext(), ++i )
|
|
|
|
/* do nothing */;
|
|
|
|
return i == nCount ? (SwLayoutFrm*)pCol : 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
static sal_Bool lcl_AddColumns( SwLayoutFrm *pCont, sal_uInt16 nCount )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwDoc *pDoc = pCont->GetFmt()->GetDoc();
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bMod = pDoc->IsModified();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//Formats should be shared whenever possible. If a neighbour already has
|
|
|
|
//the same column settings we can add them to the same format.
|
|
|
|
//The neighbour can be searched using the format, however the owner of the
|
|
|
|
//attribute depends on the frame type.
|
2000-09-18 23:08:29 +00:00
|
|
|
SwLayoutFrm *pAttrOwner = pCont;
|
|
|
|
if ( pCont->IsBodyFrm() )
|
|
|
|
pAttrOwner = pCont->FindPageFrm();
|
|
|
|
SwLayoutFrm *pNeighbourCol = 0;
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwLayoutFrm,SwFmt> aIter( *pAttrOwner->GetFmt() );
|
|
|
|
SwLayoutFrm *pNeighbour = aIter.First();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nAdd = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *pCol = pCont->Lower();
|
|
|
|
if ( pCol && pCol->IsColumnFrm() )
|
|
|
|
for ( nAdd = 1; pCol; pCol = pCol->GetNext(), ++nAdd )
|
|
|
|
/* do nothing */;
|
|
|
|
while ( pNeighbour )
|
|
|
|
{
|
|
|
|
if ( 0 != (pNeighbourCol = lcl_FindColumns( pNeighbour, nCount+nAdd )) &&
|
|
|
|
pNeighbourCol != pCont )
|
|
|
|
break;
|
|
|
|
pNeighbourCol = 0;
|
2010-12-17 09:02:23 +01:00
|
|
|
pNeighbour = aIter.Next();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwTwips nMax = pCont->IsPageBodyFrm() ?
|
|
|
|
pCont->FindPageFrm()->GetMaxFtnHeight() : LONG_MAX;
|
|
|
|
if ( pNeighbourCol )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bRet = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *pTmp = pCont->Lower();
|
|
|
|
while ( pTmp )
|
|
|
|
{
|
|
|
|
pTmp = pTmp->GetNext();
|
|
|
|
pNeighbourCol = (SwLayoutFrm*)pNeighbourCol->GetNext();
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < nCount; ++i )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-06-13 15:22:56 +02:00
|
|
|
SwColumnFrm *pTmpCol = new SwColumnFrm( pNeighbourCol->GetFmt(), pCont );
|
2007-09-27 08:01:23 +00:00
|
|
|
pTmpCol->SetMaxFtnHeight( nMax );
|
|
|
|
pTmpCol->InsertBefore( pCont, NULL );
|
2000-09-18 23:08:29 +00:00
|
|
|
pNeighbourCol = (SwLayoutFrm*)pNeighbourCol->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bRet = sal_True;
|
|
|
|
for ( sal_uInt16 i = 0; i < nCount; ++i )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwFrmFmt *pFmt = pDoc->MakeFrmFmt( aEmptyStr, pDoc->GetDfltFrmFmt());
|
2010-06-13 15:22:56 +02:00
|
|
|
SwColumnFrm *pTmp = new SwColumnFrm( pFmt, pCont );
|
2000-09-18 23:08:29 +00:00
|
|
|
pTmp->SetMaxFtnHeight( nMax );
|
|
|
|
pTmp->Paste( pCont );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bMod )
|
|
|
|
pDoc->ResetModified();
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 21:50:08 +01:00
|
|
|
/*--------------------------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
* ChgColumns() adds or removes columns from a layoutframe.
|
|
|
|
* Normally, a layoutframe with a column attribut of 1 or 0 columns contains
|
|
|
|
* no columnframe. However, a sectionframe with "footnotes at the end" needs
|
|
|
|
* a columnframe. If the bChgFtn-flag is set, the columnframe will be inserted
|
|
|
|
* or remove, if necessary.
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
|
|
|
|
void SwLayoutFrm::ChgColumns( const SwFmtCol &rOld, const SwFmtCol &rNew,
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bChgFtn )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if ( rOld.GetNumCols() <= 1 && rNew.GetNumCols() <= 1 && !bChgFtn )
|
|
|
|
return;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i97379#
|
2009-08-27 14:36:29 +00:00
|
|
|
// If current lower is a no text frame, then columns are not allowed
|
|
|
|
if ( Lower() && Lower()->IsNoTxtFrm() &&
|
|
|
|
rNew.GetNumCols() > 1 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nNewNum, nOldNum = 1;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( Lower() && Lower()->IsColumnFrm() )
|
|
|
|
{
|
|
|
|
SwFrm* pCol = Lower();
|
|
|
|
while( 0 != (pCol=pCol->GetNext()) )
|
|
|
|
++nOldNum;
|
|
|
|
}
|
|
|
|
nNewNum = rNew.GetNumCols();
|
|
|
|
if( !nNewNum )
|
|
|
|
++nNewNum;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bAtEnd;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( IsSctFrm() )
|
|
|
|
bAtEnd = ((SwSectionFrm*)this)->IsAnyNoteAtEnd();
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
bAtEnd = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//Setting the column width is only needed for new formats.
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bAdjustAttributes = nOldNum != rOld.GetNumCols();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//The content is saved and restored if the column count is different.
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFrm *pSave = 0;
|
|
|
|
if( nOldNum != nNewNum || bChgFtn )
|
|
|
|
{
|
|
|
|
SwDoc *pDoc = GetFmt()->GetDoc();
|
2012-02-13 11:36:53 +01:00
|
|
|
OSL_ENSURE( pDoc, "FrmFmt doesn't return a document." );
|
|
|
|
// SaveCntnt would also suck up the content of the footnote container
|
|
|
|
// and store it within the normal text flow.
|
2000-09-18 23:08:29 +00:00
|
|
|
if( IsPageBodyFrm() )
|
2011-02-09 15:55:27 +01:00
|
|
|
pDoc->GetCurrentLayout()->RemoveFtns( (SwPageFrm*)GetUpper(), sal_True, sal_False ); //swmod 080218
|
2000-09-18 23:08:29 +00:00
|
|
|
pSave = ::SaveCntnt( this );
|
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//If columns exist, they get deleted if a column count of 0 or 1 is requested.
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( nNewNum == 1 && !bAtEnd )
|
|
|
|
{
|
|
|
|
::lcl_RemoveColumns( this, nOldNum );
|
|
|
|
if ( IsBodyFrm() )
|
|
|
|
SetFrmFmt( pDoc->GetDfltFrmFmt() );
|
|
|
|
else
|
2008-06-13 08:56:11 +00:00
|
|
|
GetFmt()->SetFmtAttr( SwFmtFillOrder() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( pSave )
|
2004-01-13 10:14:52 +00:00
|
|
|
::RestoreCntnt( pSave, this, 0, true );
|
2000-09-18 23:08:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( nOldNum == 1 )
|
|
|
|
{
|
|
|
|
if ( IsBodyFrm() )
|
|
|
|
SetFrmFmt( pDoc->GetColumnContFmt() );
|
|
|
|
else
|
2008-06-13 08:56:11 +00:00
|
|
|
GetFmt()->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !Lower() || !Lower()->IsColumnFrm() )
|
|
|
|
--nOldNum;
|
|
|
|
}
|
|
|
|
if ( nOldNum > nNewNum )
|
|
|
|
{
|
|
|
|
::lcl_RemoveColumns( this, nOldNum - nNewNum );
|
2011-01-17 15:06:54 +01:00
|
|
|
bAdjustAttributes = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else if( nOldNum < nNewNum )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nAdd = nNewNum - nOldNum;
|
2004-08-12 11:30:06 +00:00
|
|
|
bAdjustAttributes = lcl_AddColumns( this, nAdd );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bAdjustAttributes )
|
|
|
|
{
|
|
|
|
if ( rOld.GetLineWidth() != rNew.GetLineWidth() ||
|
|
|
|
rOld.GetWishWidth() != rNew.GetWishWidth() ||
|
|
|
|
rOld.IsOrtho() != rNew.IsOrtho() )
|
2011-01-17 15:06:54 +01:00
|
|
|
bAdjustAttributes = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
{
|
2012-04-25 12:12:02 +02:00
|
|
|
sal_uInt16 nCount = Min( rNew.GetColumns().size(), rOld.GetColumns().size() );
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < nCount; ++i )
|
2012-04-25 12:12:02 +02:00
|
|
|
if ( !(rOld.GetColumns()[i] == rNew.GetColumns()[i]) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
bAdjustAttributes = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//The columns can now be easily adjusted.
|
2000-09-18 23:08:29 +00:00
|
|
|
AdjustColumns( &rNew, bAdjustAttributes );
|
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//Don't restore the content before. An earlier restore would trigger useless
|
|
|
|
//actions during setup.
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( pSave )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( Lower() && Lower()->IsLayoutFrm() &&
|
2000-09-18 23:08:29 +00:00
|
|
|
((SwLayoutFrm*)Lower())->Lower() &&
|
|
|
|
((SwLayoutFrm*)Lower())->Lower()->IsLayoutFrm(),
|
|
|
|
"Gesucht: Spaltenbody (Tod oder Lebend)." ); // ColumnFrms jetzt mit BodyFrm
|
2004-01-13 10:14:52 +00:00
|
|
|
::RestoreCntnt( pSave, (SwLayoutFrm*)((SwLayoutFrm*)Lower())->Lower(), 0, true );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwLayoutFrm::AdjustColumns()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwLayoutFrm::AdjustColumns( const SwFmtCol *pAttr, sal_Bool bAdjustAttributes )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( !Lower()->GetNext() )
|
|
|
|
{
|
|
|
|
Lower()->ChgSize( Prt().SSize() );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bVert = IsVertical();
|
2009-03-04 16:19:59 +00:00
|
|
|
//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
|
|
|
|
SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
|
2001-08-29 12:23:19 +00:00
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//If we have a pointer or we have to configure an attribute, we set the
|
|
|
|
//column widths in any case. Otherwise we check if a configuration is needed.
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !pAttr )
|
|
|
|
{
|
|
|
|
pAttr = &GetFmt()->GetCol();
|
|
|
|
if ( !bAdjustAttributes )
|
|
|
|
{
|
2001-09-17 10:20:34 +00:00
|
|
|
long nAvail = (Prt().*fnRect->fnGetWidth)();
|
|
|
|
for ( SwLayoutFrm *pCol = (SwLayoutFrm*)Lower();
|
|
|
|
pCol;
|
|
|
|
pCol = (SwLayoutFrm*)pCol->GetNext() )
|
|
|
|
nAvail -= (pCol->Frm().*fnRect->fnGetWidth)();
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !nAvail )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//The columns can now be easily adjusted.
|
|
|
|
//The widths get counted so we can give the reminder to the last one.
|
2001-09-17 10:20:34 +00:00
|
|
|
SwTwips nAvail = (Prt().*fnRect->fnGetWidth)();
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bLine = pAttr->GetLineAdj() != COLADJ_NONE;
|
|
|
|
const sal_uInt16 nMin = bLine ? sal_uInt16( 20 + ( pAttr->GetLineWidth() / 2) ) : 0;
|
2004-08-02 12:07:09 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i27399#
|
2004-08-02 12:07:09 +00:00
|
|
|
// bOrtho means we have to adjust the column frames manually. Otherwise
|
|
|
|
// we may use the values returned by CalcColWidth:
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bOrtho = pAttr->IsOrtho() && pAttr->GetNumCols() > 0;
|
2001-10-19 09:25:19 +00:00
|
|
|
long nGutter = 0;
|
2012-06-17 13:33:03 -05:00
|
|
|
sal_uInt16 real_nb_col = 0;
|
|
|
|
|
|
|
|
SwFrm* pColHead = Lower();;
|
|
|
|
SwFrm* pColTail;
|
|
|
|
for ( pColTail = pColHead; pColTail; pColTail = pColTail->GetNext(), real_nb_col += 1 );
|
|
|
|
|
|
|
|
sal_uInt16 i = IsRightToLeft() ? real_nb_col : 0;
|
2004-08-02 12:07:09 +00:00
|
|
|
|
2012-06-17 13:33:03 -05:00
|
|
|
for ( SwFrm* pColCursor = IsRightToLeft() ? pColTail : pColHead;
|
|
|
|
pColCursor;
|
|
|
|
(pColCursor = IsRightToLeft() ? pColCursor->GetPrev() : pColCursor->GetNext()), (i += IsRightToLeft() ? -1 : +1) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-19 09:25:19 +00:00
|
|
|
if( !bOrtho )
|
|
|
|
{
|
2012-06-17 13:33:03 -05:00
|
|
|
const SwTwips nWidth = (pColCursor == (IsRightToLeft() ? pColTail : pColHead) ) ?
|
2004-08-02 12:07:09 +00:00
|
|
|
nAvail :
|
2011-01-17 15:06:54 +01:00
|
|
|
pAttr->CalcColWidth( i, sal_uInt16( (Prt().*fnRect->fnGetWidth)() ) );
|
2004-08-02 12:07:09 +00:00
|
|
|
|
|
|
|
const Size aColSz = bVert ?
|
|
|
|
Size( Prt().Width(), nWidth ) :
|
|
|
|
Size( nWidth, Prt().Height() );
|
|
|
|
|
2012-06-17 13:33:03 -05:00
|
|
|
pColCursor->ChgSize( aColSz );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
// With this, the ColumnBodyFrms from page columns gets adjusted and
|
|
|
|
// their bFixHeight flag is set so they won't shrink/grow.
|
2012-03-06 17:51:10 +01:00
|
|
|
// Don't use the flag with frame columns because BodyFrms in frame
|
2012-02-13 11:36:53 +01:00
|
|
|
// columns can grow/shrink.
|
2001-10-19 09:25:19 +00:00
|
|
|
if( IsBodyFrm() )
|
2012-06-17 13:33:03 -05:00
|
|
|
((SwLayoutFrm*)pColCursor)->Lower()->ChgSize( aColSz );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-10-19 09:25:19 +00:00
|
|
|
nAvail -= nWidth;
|
|
|
|
}
|
2002-07-02 08:32:46 +00:00
|
|
|
|
2004-08-02 12:07:09 +00:00
|
|
|
if ( bOrtho || bAdjustAttributes )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-04-25 12:12:02 +02:00
|
|
|
const SwColumn *pC = &pAttr->GetColumns()[i];
|
2012-06-17 13:33:03 -05:00
|
|
|
const SwAttrSet* pSet = pColCursor->GetAttrSet();
|
2000-09-18 23:08:29 +00:00
|
|
|
SvxLRSpaceItem aLR( pSet->GetLRSpace() );
|
|
|
|
|
2012-02-13 11:36:53 +01:00
|
|
|
//In order to have enough space for the separation lines, we have to
|
|
|
|
//take them into account here. Every time two columns meet we
|
|
|
|
//calculate a clearance of 20 + half the pen width on the left or
|
|
|
|
//right side, respectively.
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt16 nLeft = pC->GetLeft();
|
|
|
|
const sal_uInt16 nRight = pC->GetRight();
|
2004-08-02 12:07:09 +00:00
|
|
|
|
|
|
|
aLR.SetLeft ( nLeft );
|
|
|
|
aLR.SetRight( nRight );
|
|
|
|
|
|
|
|
if ( bLine )
|
|
|
|
{
|
|
|
|
if ( i == 0 )
|
2002-06-27 10:25:03 +00:00
|
|
|
{
|
2004-08-02 12:07:09 +00:00
|
|
|
aLR.SetRight( Max( nRight, nMin ) );
|
2002-06-27 10:25:03 +00:00
|
|
|
}
|
2004-08-02 12:07:09 +00:00
|
|
|
else if ( i == pAttr->GetNumCols() - 1 )
|
2001-08-30 07:49:33 +00:00
|
|
|
{
|
2004-08-02 12:07:09 +00:00
|
|
|
aLR.SetLeft ( Max( nLeft, nMin ) );
|
2001-08-30 07:49:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-02 12:07:09 +00:00
|
|
|
aLR.SetLeft ( Max( nLeft, nMin ) );
|
|
|
|
aLR.SetRight( Max( nRight, nMin ) );
|
2001-08-30 07:49:33 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2002-07-02 08:32:46 +00:00
|
|
|
|
|
|
|
if ( bAdjustAttributes )
|
|
|
|
{
|
2004-08-02 12:07:09 +00:00
|
|
|
SvxULSpaceItem aUL( pSet->GetULSpace() );
|
|
|
|
aUL.SetUpper( pC->GetUpper());
|
|
|
|
aUL.SetLower( pC->GetLower());
|
|
|
|
|
2012-06-17 13:33:03 -05:00
|
|
|
((SwLayoutFrm*)pColCursor)->GetFmt()->SetFmtAttr( aLR );
|
|
|
|
((SwLayoutFrm*)pColCursor)->GetFmt()->SetFmtAttr( aUL );
|
2002-07-02 08:32:46 +00:00
|
|
|
}
|
|
|
|
|
2001-10-19 09:25:19 +00:00
|
|
|
nGutter += aLR.GetLeft() + aLR.GetRight();
|
|
|
|
}
|
|
|
|
}
|
2004-08-02 12:07:09 +00:00
|
|
|
|
2001-10-19 09:25:19 +00:00
|
|
|
if( bOrtho )
|
|
|
|
{
|
2004-08-02 12:07:09 +00:00
|
|
|
long nInnerWidth = ( nAvail - nGutter ) / pAttr->GetNumCols();
|
2012-06-17 13:33:03 -05:00
|
|
|
i = 0;
|
|
|
|
for (SwFrm* pColCursor = pColHead; pColCursor; pColCursor = pColCursor->GetNext(), i++)
|
2001-10-19 09:25:19 +00:00
|
|
|
{
|
|
|
|
SwTwips nWidth;
|
2004-08-02 12:07:09 +00:00
|
|
|
if ( i == pAttr->GetNumCols() - 1 )
|
2012-06-17 13:33:03 -05:00
|
|
|
{
|
2001-10-19 09:25:19 +00:00
|
|
|
nWidth = nAvail;
|
2012-06-17 13:33:03 -05:00
|
|
|
}
|
2001-10-19 09:25:19 +00:00
|
|
|
else
|
|
|
|
{
|
2012-06-17 13:33:03 -05:00
|
|
|
SvxLRSpaceItem aLR( pColCursor->GetAttrSet()->GetLRSpace() );
|
2001-10-19 09:25:19 +00:00
|
|
|
nWidth = nInnerWidth + aLR.GetLeft() + aLR.GetRight();
|
|
|
|
}
|
|
|
|
if( nWidth < 0 )
|
2012-06-17 13:33:03 -05:00
|
|
|
{
|
2001-10-19 09:25:19 +00:00
|
|
|
nWidth = 0;
|
2012-06-17 13:33:03 -05:00
|
|
|
}
|
2004-08-02 12:07:09 +00:00
|
|
|
const Size aColSz = bVert ?
|
|
|
|
Size( Prt().Width(), nWidth ) :
|
|
|
|
Size( nWidth, Prt().Height() );
|
|
|
|
|
2012-06-17 13:33:03 -05:00
|
|
|
pColCursor->ChgSize( aColSz );
|
2004-08-02 12:07:09 +00:00
|
|
|
|
2001-10-19 09:25:19 +00:00
|
|
|
if( IsBodyFrm() )
|
2012-06-17 13:33:03 -05:00
|
|
|
{
|
|
|
|
((SwLayoutFrm*)pColCursor)->Lower()->ChgSize( aColSz );
|
|
|
|
}
|
2001-10-19 09:25:19 +00:00
|
|
|
nAvail -= nWidth;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|