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 14:38:26 +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 14:38:26 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 14:38:26 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 14:38:26 +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 14:38:26 +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 14:38:26 +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-08-14 15:43:44 +00:00
|
|
|
|
2006-09-16 20:40:45 +00:00
|
|
|
|
2006-08-14 15:43:44 +00:00
|
|
|
#include <vcl/outdev.hxx>
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
#include "pagefrm.hxx"
|
|
|
|
#include "rootfrm.hxx"
|
|
|
|
#include "pam.hxx" // SwPosition
|
|
|
|
#include "swregion.hxx" // SwRegionRects
|
|
|
|
#include "dflyobj.hxx" // SdrObject
|
2012-03-14 18:55:03 +01:00
|
|
|
#include "flyfrm.hxx" // SwFlyFrm
|
|
|
|
#include "frmtool.hxx" // ::DrawGraphic
|
|
|
|
#include "porfly.hxx" // NewFlyCntPortion
|
|
|
|
#include "porfld.hxx" // SwGrfNumPortion
|
|
|
|
#include "txtfly.hxx" // SwTxtFly
|
|
|
|
#include "txtpaint.hxx" // SwSaveClip
|
|
|
|
#include "txtatr.hxx" // SwTxtFlyCnt
|
2006-08-14 15:43:44 +00:00
|
|
|
#include "notxtfrm.hxx"
|
2012-03-14 18:55:03 +01:00
|
|
|
#include "fmtcnct.hxx" // SwFmtChain
|
2012-03-14 16:38:43 +01:00
|
|
|
#include "inftxt.hxx"
|
2001-02-01 13:05:11 +00:00
|
|
|
#include <pormulti.hxx> // SwMultiPortion
|
2006-11-14 14:11:51 +00:00
|
|
|
#include <svx/obj3d.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/txtrange.hxx>
|
|
|
|
#include <editeng/lrspitem.hxx>
|
|
|
|
#include <editeng/ulspitem.hxx>
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i28701#
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/lspcitem.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtsrnd.hxx>
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
2002-02-05 15:50:43 +00:00
|
|
|
#include <pagedesc.hxx> // SwPageDesc
|
|
|
|
#include <tgrditem.hxx>
|
2004-08-02 13:15:54 +00:00
|
|
|
#include <sortedobjs.hxx>
|
2005-01-21 09:41:22 +00:00
|
|
|
#include <layouter.hxx>
|
2006-08-14 15:43:44 +00:00
|
|
|
#include <IDocumentDrawModelAccess.hxx>
|
|
|
|
#include <IDocumentLayoutAccess.hxx>
|
|
|
|
#include <IDocumentSettingAccess.hxx>
|
|
|
|
#include <svx/svdoedge.hxx>
|
|
|
|
|
2011-11-24 00:52:00 +01:00
|
|
|
#ifdef DBG_UTIL
|
2012-03-14 16:38:43 +01:00
|
|
|
#include "viewsh.hxx"
|
2012-03-14 18:55:03 +01:00
|
|
|
#include "viewopt.hxx" // SwViewOptions, only for testing (Test2)
|
2010-06-13 15:22:56 +02:00
|
|
|
#include "doc.hxx"
|
2000-09-18 23:08:29 +00:00
|
|
|
#endif
|
|
|
|
|
2010-01-05 16:37:41 +01:00
|
|
|
|
2007-09-27 08:20:23 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
namespace
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
// #i68520#
|
|
|
|
struct AnchoredObjOrder
|
2001-02-01 13:05:11 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
sal_Bool mbR2L;
|
|
|
|
SwRectFn mfnRect;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
AnchoredObjOrder( const sal_Bool bR2L,
|
|
|
|
SwRectFn fnRect )
|
|
|
|
: mbR2L( bR2L ),
|
|
|
|
mfnRect( fnRect )
|
|
|
|
{}
|
2004-02-26 16:01:02 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
bool operator()( const SwAnchoredObject* pListedAnchoredObj,
|
|
|
|
const SwAnchoredObject* pNewAnchoredObj )
|
|
|
|
{
|
|
|
|
const SwRect aBoundRectOfListedObj( pListedAnchoredObj->GetObjRectWithSpaces() );
|
|
|
|
const SwRect aBoundRectOfNewObj( pNewAnchoredObj->GetObjRectWithSpaces() );
|
|
|
|
if ( ( mbR2L &&
|
|
|
|
( (aBoundRectOfListedObj.*mfnRect->fnGetRight)() ==
|
|
|
|
(aBoundRectOfNewObj.*mfnRect->fnGetRight)() ) ) ||
|
|
|
|
( !mbR2L &&
|
|
|
|
( (aBoundRectOfListedObj.*mfnRect->fnGetLeft)() ==
|
|
|
|
(aBoundRectOfNewObj.*mfnRect->fnGetLeft)() ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
SwTwips nTopDiff =
|
|
|
|
(*mfnRect->fnYDiff)( (aBoundRectOfNewObj.*mfnRect->fnGetTop)(),
|
|
|
|
(aBoundRectOfListedObj.*mfnRect->fnGetTop)() );
|
|
|
|
if ( nTopDiff == 0 &&
|
|
|
|
( ( mbR2L &&
|
|
|
|
( (aBoundRectOfNewObj.*mfnRect->fnGetLeft)() >
|
|
|
|
(aBoundRectOfListedObj.*mfnRect->fnGetLeft)() ) ) ||
|
|
|
|
( !mbR2L &&
|
|
|
|
( (aBoundRectOfNewObj.*mfnRect->fnGetRight)() <
|
|
|
|
(aBoundRectOfListedObj.*mfnRect->fnGetRight)() ) ) ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if ( nTopDiff > 0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
else if ( ( mbR2L &&
|
|
|
|
( (aBoundRectOfListedObj.*mfnRect->fnGetRight)() >
|
|
|
|
(aBoundRectOfNewObj.*mfnRect->fnGetRight)() ) ) ||
|
|
|
|
( !mbR2L &&
|
|
|
|
( (aBoundRectOfListedObj.*mfnRect->fnGetLeft)() <
|
|
|
|
(aBoundRectOfNewObj.*mfnRect->fnGetLeft)() ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-04-19 08:26:03 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
return false;
|
2001-02-01 13:05:11 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
};
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
SwContourCache::SwContourCache() :
|
|
|
|
nPntCnt( 0 ), nObjCnt( 0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
memset( (SdrObject**)pSdrObj, 0, sizeof(pSdrObj) );
|
|
|
|
memset( pTextRanger, 0, sizeof(pTextRanger) );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
SwContourCache::~SwContourCache()
|
|
|
|
{
|
|
|
|
for( MSHORT i = 0; i < nObjCnt; delete pTextRanger[ i++ ] )
|
|
|
|
;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
void SwContourCache::ClrObject( MSHORT nPos )
|
|
|
|
{
|
|
|
|
OSL_ENSURE( pTextRanger[ nPos ], "ClrObject: Allready cleared. Good Bye!" );
|
|
|
|
nPntCnt -= pTextRanger[ nPos ]->GetPointCount();
|
|
|
|
delete pTextRanger[ nPos ];
|
|
|
|
--nObjCnt;
|
|
|
|
memmove( (SdrObject**)pSdrObj + nPos, pSdrObj + nPos + 1,
|
|
|
|
( nObjCnt - nPos ) * sizeof( SdrObject* ) );
|
|
|
|
memmove( pTextRanger + nPos, pTextRanger + nPos + 1,
|
|
|
|
( nObjCnt - nPos ) * sizeof( TextRanger* ) );
|
|
|
|
}
|
2004-02-26 16:01:02 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
void ClrContourCache( const SdrObject *pObj )
|
|
|
|
{
|
|
|
|
if( pContourCache && pObj )
|
|
|
|
for( MSHORT i = 0; i < pContourCache->GetCount(); ++i )
|
|
|
|
if( pObj == pContourCache->GetObject( i ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
pContourCache->ClrObject( i );
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
void ClrContourCache()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
if( pContourCache )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
for( MSHORT i = 0; i < pContourCache->GetCount();
|
|
|
|
delete pContourCache->pTextRanger[ i++ ] )
|
|
|
|
;
|
|
|
|
pContourCache->nObjCnt = 0;
|
|
|
|
pContourCache->nPntCnt = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
// #i68520#
|
|
|
|
const SwRect SwContourCache::CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
|
|
|
|
const SwRect &rLine,
|
|
|
|
const SwTxtFrm* pFrm,
|
|
|
|
const long nXPos,
|
|
|
|
const sal_Bool bRight )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
SwRect aRet;
|
|
|
|
const SwFrmFmt* pFmt = &(pAnchoredObj->GetFrmFmt());
|
|
|
|
if( pFmt->GetSurround().IsContour() &&
|
|
|
|
( !pAnchoredObj->ISA(SwFlyFrm) ||
|
|
|
|
( static_cast<const SwFlyFrm*>(pAnchoredObj)->Lower() &&
|
|
|
|
static_cast<const SwFlyFrm*>(pAnchoredObj)->Lower()->IsNoTxtFrm() ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
aRet = pAnchoredObj->GetObjRectWithSpaces();
|
|
|
|
if( aRet.IsOver( rLine ) )
|
|
|
|
{
|
|
|
|
if( !pContourCache )
|
|
|
|
pContourCache = new SwContourCache;
|
|
|
|
|
|
|
|
aRet = pContourCache->ContourRect(
|
|
|
|
pFmt, pAnchoredObj->GetDrawObj(), pFrm, rLine, nXPos, bRight );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aRet.Width( 0 );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
aRet = pAnchoredObj->GetObjRectWithSpaces();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-04-26 09:37:23 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
return aRet;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
const SwRect SwContourCache::ContourRect( const SwFmt* pFmt,
|
|
|
|
const SdrObject* pObj, const SwTxtFrm* pFrm, const SwRect &rLine,
|
|
|
|
const long nXPos, const sal_Bool bRight )
|
|
|
|
{
|
|
|
|
SwRect aRet;
|
|
|
|
MSHORT nPos = 0; // Suche im Cache ...
|
|
|
|
while( nPos < GetCount() && pObj != pSdrObj[ nPos ] )
|
|
|
|
++nPos;
|
|
|
|
if( GetCount() == nPos ) // nicht gefunden
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
if( nObjCnt == POLY_CNT )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
nPntCnt -= pTextRanger[ --nObjCnt ]->GetPointCount();
|
|
|
|
delete pTextRanger[ nObjCnt ];
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
::basegfx::B2DPolyPolygon aPolyPolygon;
|
|
|
|
::basegfx::B2DPolyPolygon* pPolyPolygon = 0L;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
if ( pObj->ISA(SwVirtFlyDrawObj) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
// Vorsicht #37347: Das GetContour() fuehrt zum Laden der Grafik,
|
|
|
|
// diese aendert dadurch ggf. ihre Groesse, ruft deshalb ein
|
|
|
|
// ClrObject() auf.
|
|
|
|
PolyPolygon aPoly;
|
|
|
|
if( !((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetContour( aPoly ) )
|
|
|
|
aPoly = PolyPolygon( ((SwVirtFlyDrawObj*)pObj)->
|
|
|
|
GetFlyFrm()->Frm().SVRect() );
|
|
|
|
aPolyPolygon.clear();
|
|
|
|
aPolyPolygon.append(aPoly.getB2DPolyPolygon());
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
else
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
if( !pObj->ISA( E3dObject ) )
|
2001-12-06 14:49:17 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
aPolyPolygon = pObj->TakeXorPoly();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
|
|
|
|
::basegfx::B2DPolyPolygon aContourPoly(pObj->TakeContour());
|
|
|
|
pPolyPolygon = new ::basegfx::B2DPolyPolygon(aContourPoly);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
const SvxLRSpaceItem &rLRSpace = pFmt->GetLRSpace();
|
|
|
|
const SvxULSpaceItem &rULSpace = pFmt->GetULSpace();
|
|
|
|
memmove( pTextRanger + 1, pTextRanger, nObjCnt * sizeof( TextRanger* ) );
|
|
|
|
memmove( (SdrObject**)pSdrObj + 1, pSdrObj, nObjCnt++ * sizeof( SdrObject* ) );
|
|
|
|
pSdrObj[ 0 ] = pObj; // Wg. #37347 darf das Object erst nach dem
|
|
|
|
// GetContour() eingetragen werden.
|
|
|
|
pTextRanger[ 0 ] = new TextRanger( aPolyPolygon, pPolyPolygon, 20,
|
|
|
|
(sal_uInt16)rLRSpace.GetLeft(), (sal_uInt16)rLRSpace.GetRight(),
|
|
|
|
pFmt->GetSurround().IsOutside(), sal_False, pFrm->IsVertical() );
|
|
|
|
pTextRanger[ 0 ]->SetUpper( rULSpace.GetUpper() );
|
|
|
|
pTextRanger[ 0 ]->SetLower( rULSpace.GetLower() );
|
|
|
|
|
|
|
|
delete pPolyPolygon;
|
|
|
|
// UPPER_LOWER_TEST
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
const ViewShell* pTmpViewShell = pFmt->GetDoc()->GetCurrentViewShell();
|
|
|
|
if( pTmpViewShell )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
sal_Bool bT2 = pTmpViewShell->GetViewOptions()->IsTest2();
|
|
|
|
sal_Bool bT6 = pTmpViewShell->GetViewOptions()->IsTest6();
|
|
|
|
if( bT2 || bT6 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
if( bT2 )
|
|
|
|
pTextRanger[ 0 ]->SetFlag7( sal_True );
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2012-03-14 16:38:43 +01:00
|
|
|
pTextRanger[ 0 ]->SetFlag6( sal_True );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
#endif
|
|
|
|
nPntCnt += pTextRanger[ 0 ]->GetPointCount();
|
|
|
|
while( nPntCnt > POLY_MAX && nObjCnt > POLY_MIN )
|
2002-01-16 08:50:11 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
nPntCnt -= pTextRanger[ --nObjCnt ]->GetPointCount();
|
|
|
|
delete pTextRanger[ nObjCnt ];
|
2002-01-16 08:50:11 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
else if( nPos )
|
2007-09-27 08:20:23 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
const SdrObject* pTmpObj = pSdrObj[ nPos ];
|
|
|
|
TextRanger* pTmpRanger = pTextRanger[ nPos ];
|
|
|
|
memmove( (SdrObject**)pSdrObj + 1, pSdrObj, nPos * sizeof( SdrObject* ) );
|
|
|
|
memmove( pTextRanger + 1, pTextRanger, nPos * sizeof( TextRanger* ) );
|
|
|
|
pSdrObj[ 0 ] = pTmpObj;
|
|
|
|
pTextRanger[ 0 ] = pTmpRanger;
|
2007-09-27 08:20:23 +00:00
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
SWRECTFN( pFrm )
|
|
|
|
long nTmpTop = (rLine.*fnRect->fnGetTop)();
|
|
|
|
// fnGetBottom is top + height
|
|
|
|
long nTmpBottom = (rLine.*fnRect->fnGetBottom)();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
Range aRange( Min( nTmpTop, nTmpBottom ), Max( nTmpTop, nTmpBottom ) );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
LongDqPtr pTmp = pTextRanger[ 0 ]->GetTextRanges( aRange );
|
2002-03-26 07:08:49 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
MSHORT nCount;
|
|
|
|
if( 0 != ( nCount = pTmp->size() ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
MSHORT nIdx = 0;
|
|
|
|
while( nIdx < nCount && (*pTmp)[ nIdx ] < nXPos )
|
|
|
|
++nIdx;
|
|
|
|
sal_Bool bOdd = (nIdx % 2) ? sal_True : sal_False;
|
|
|
|
sal_Bool bSet = sal_True;
|
|
|
|
if( bOdd )
|
|
|
|
--nIdx; // innerhalb eines Intervalls
|
|
|
|
else if( ! bRight && ( nIdx >= nCount || (*pTmp)[ nIdx ] != nXPos ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 16:38:43 +01:00
|
|
|
if( nIdx )
|
|
|
|
nIdx -= 2; // ein Intervall nach links gehen
|
|
|
|
else
|
|
|
|
bSet = sal_False; // vor dem erstem Intervall
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bSet && nIdx < nCount )
|
|
|
|
{
|
|
|
|
(aRet.*fnRect->fnSetTopAndHeight)( (rLine.*fnRect->fnGetTop)(),
|
|
|
|
(rLine.*fnRect->fnGetHeight)() );
|
|
|
|
(aRet.*fnRect->fnSetLeft)( (*pTmp)[ nIdx ] );
|
|
|
|
(aRet.*fnRect->fnSetRight)( (*pTmp)[ nIdx + 1 ] + 1 );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-14 16:38:43 +01:00
|
|
|
return aRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
SwTxtFly::SwTxtFly() :
|
|
|
|
pPage(0),
|
|
|
|
mpCurrAnchoredObj(0),
|
|
|
|
pCurrFrm(0),
|
|
|
|
pMaster(0),
|
|
|
|
mpAnchoredObjList(0),
|
|
|
|
nMinBottom(0),
|
|
|
|
nNextTop(0),
|
|
|
|
nIndex(0)
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
SwTxtFly::SwTxtFly( const SwTxtFrm *pFrm )
|
|
|
|
{
|
|
|
|
CtorInitTxtFly( pFrm );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwTxtFly::SwTxtFly( const SwTxtFly& rTxtFly )
|
|
|
|
{
|
|
|
|
pPage = rTxtFly.pPage;
|
2006-09-15 10:43:10 +00:00
|
|
|
mpCurrAnchoredObj = rTxtFly.mpCurrAnchoredObj;
|
2000-09-18 23:08:29 +00:00
|
|
|
pCurrFrm = rTxtFly.pCurrFrm;
|
|
|
|
pMaster = rTxtFly.pMaster;
|
2006-09-15 10:43:10 +00:00
|
|
|
if( rTxtFly.mpAnchoredObjList )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-09-15 10:43:10 +00:00
|
|
|
mpAnchoredObjList = new SwAnchoredObjList( *(rTxtFly.mpAnchoredObjList) );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2006-09-15 10:43:10 +00:00
|
|
|
{
|
|
|
|
mpAnchoredObjList = NULL;
|
|
|
|
}
|
2001-08-31 05:22:48 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
bOn = rTxtFly.bOn;
|
|
|
|
bLeftSide = rTxtFly.bLeftSide;
|
|
|
|
bTopRule = rTxtFly.bTopRule;
|
2010-12-10 20:32:10 +00:00
|
|
|
nMinBottom = rTxtFly.nMinBottom;
|
|
|
|
nNextTop = rTxtFly.nNextTop;
|
|
|
|
nIndex = rTxtFly.nIndex;
|
|
|
|
mbIgnoreCurrentFrame = rTxtFly.mbIgnoreCurrentFrame;
|
|
|
|
mbIgnoreContour = rTxtFly.mbIgnoreContour;
|
|
|
|
mbIgnoreObjsInHeaderFooter = rTxtFly.mbIgnoreObjsInHeaderFooter;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
SwTxtFly::~SwTxtFly()
|
|
|
|
{
|
|
|
|
delete mpAnchoredObjList;
|
|
|
|
}
|
|
|
|
|
2007-09-27 08:20:23 +00:00
|
|
|
void SwTxtFly::CtorInitTxtFly( const SwTxtFrm *pFrm )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-05-22 08:49:57 +00:00
|
|
|
mbIgnoreCurrentFrame = sal_False;
|
|
|
|
mbIgnoreContour = sal_False;
|
2011-04-18 12:37:38 -03:00
|
|
|
// #118809#
|
2005-01-05 13:31:24 +00:00
|
|
|
mbIgnoreObjsInHeaderFooter = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
pPage = pFrm->FindPageFrm();
|
|
|
|
const SwFlyFrm* pTmp = pFrm->FindFlyFrm();
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
mpCurrAnchoredObj = pTmp;
|
2000-09-18 23:08:29 +00:00
|
|
|
pCurrFrm = pFrm;
|
|
|
|
pMaster = pCurrFrm->IsFollow() ? NULL : pCurrFrm;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
mpAnchoredObjList = NULL;
|
2012-03-14 18:55:03 +01:00
|
|
|
// If we're not overlapped by a frame or if a FlyCollection does not exist
|
|
|
|
// at all, we switch off forever.
|
|
|
|
// It could be, however, that a line is added while formatting, that
|
|
|
|
// extends into a frame.
|
|
|
|
// That's why we do not optimize for: bOn = pSortedFlys && IsAnyFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
bOn = pPage->GetSortedObjs() != 0;
|
|
|
|
bTopRule = sal_True;
|
|
|
|
bLeftSide = sal_False;
|
|
|
|
nMinBottom = 0;
|
|
|
|
nIndex = ULONG_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SwRect SwTxtFly::_GetFrm( const SwRect &rRect, sal_Bool bTop ) const
|
|
|
|
{
|
|
|
|
SwRect aRet;
|
|
|
|
if( ForEach( rRect, &aRet, sal_True ) )
|
|
|
|
{
|
2001-12-06 14:49:17 +00:00
|
|
|
SWRECTFN( pCurrFrm )
|
|
|
|
if( bTop )
|
|
|
|
(aRet.*fnRect->fnSetTop)( (rRect.*fnRect->fnGetTop)() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 18:55:03 +01:00
|
|
|
// 8110: Do not always adapt the bottom
|
2001-12-06 14:49:17 +00:00
|
|
|
const SwTwips nRetBottom = (aRet.*fnRect->fnGetBottom)();
|
|
|
|
const SwTwips nRectBottom = (rRect.*fnRect->fnGetBottom)();
|
|
|
|
if ( (*fnRect->fnYDiff)( nRetBottom, nRectBottom ) > 0 ||
|
|
|
|
(aRet.*fnRect->fnGetHeight)() < 0 )
|
|
|
|
(aRet.*fnRect->fnSetBottom)( nRectBottom );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SwTxtFly::IsAnyFrm() const
|
|
|
|
{
|
2001-12-06 14:49:17 +00:00
|
|
|
SWAP_IF_SWAPPED( pCurrFrm )
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( bOn, "IsAnyFrm: Why?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
SwRect aRect( pCurrFrm->Frm().Pos() + pCurrFrm->Prt().Pos(),
|
|
|
|
pCurrFrm->Prt().SSize() );
|
2001-12-06 14:49:17 +00:00
|
|
|
|
|
|
|
const sal_Bool bRet = ForEach( aRect, NULL, sal_False );
|
2012-03-14 16:38:43 +01:00
|
|
|
UNDO_SWAP( pCurrFrm )
|
|
|
|
return bRet;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
sal_Bool SwTxtFly::IsAnyObj( const SwRect &rRect ) const
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( bOn, "SwTxtFly::IsAnyObj: Who's knocking?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SwRect aRect( rRect );
|
|
|
|
if ( aRect.IsEmpty() )
|
|
|
|
aRect = SwRect( pCurrFrm->Frm().Pos() + pCurrFrm->Prt().Pos(),
|
|
|
|
pCurrFrm->Prt().SSize() );
|
|
|
|
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwSortedObjs *pSorted = pPage->GetSortedObjs();
|
2012-03-14 18:55:03 +01:00
|
|
|
if( pSorted ) // bOn actually makes sure that we have objects on the side,
|
|
|
|
// but who knows who deleted somehting in the meantime?
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
for ( MSHORT i = 0; i < pSorted->Count(); ++i )
|
|
|
|
{
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwAnchoredObject* pObj = (*pSorted)[i];
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwRect aBound( pObj->GetObjRectWithSpaces() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 18:55:03 +01:00
|
|
|
// Optimization
|
2004-08-02 13:15:54 +00:00
|
|
|
if( pObj->GetObjRect().Left() > aRect.Right() )
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
if( mpCurrAnchoredObj != pObj && aBound.IsOver( aRect ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwCntntFrm* SwTxtFly::_GetMaster()
|
|
|
|
{
|
|
|
|
pMaster = pCurrFrm;
|
2011-06-23 15:14:00 +01:00
|
|
|
while( pMaster && pMaster->IsFollow() )
|
2000-09-18 23:08:29 +00:00
|
|
|
pMaster = (SwCntntFrm*)pMaster->FindMaster();
|
|
|
|
return pMaster;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SwTxtFly::DrawTextOpaque( SwDrawTextInfo &rInf )
|
|
|
|
{
|
|
|
|
SwSaveClip aClipSave( rInf.GetpOut() );
|
|
|
|
SwRect aRect( rInf.GetPos(), rInf.GetSize() );
|
|
|
|
if( rInf.GetSpace() )
|
|
|
|
{
|
|
|
|
xub_StrLen nTmpLen = STRING_LEN == rInf.GetLen() ? rInf.GetText().Len() :
|
|
|
|
rInf.GetLen();
|
|
|
|
if( rInf.GetSpace() > 0 )
|
|
|
|
{
|
|
|
|
xub_StrLen nSpaceCnt = 0;
|
|
|
|
const xub_StrLen nEndPos = rInf.GetIdx() + nTmpLen;
|
|
|
|
for( xub_StrLen nPos = rInf.GetIdx(); nPos < nEndPos; ++nPos )
|
|
|
|
{
|
|
|
|
if( CH_BLANK == rInf.GetText().GetChar( nPos ) )
|
|
|
|
++nSpaceCnt;
|
|
|
|
}
|
|
|
|
if( nSpaceCnt )
|
|
|
|
aRect.Width( aRect.Width() + nSpaceCnt * rInf.GetSpace() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aRect.Width( aRect.Width() - nTmpLen * rInf.GetSpace() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aClipSave.IsOn() && rInf.GetOut().IsClipRegion() )
|
|
|
|
{
|
|
|
|
SwRect aClipRect( rInf.GetOut().GetClipRegion().GetBoundRect() );
|
|
|
|
aRect.Intersection( aClipRect );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwRegionRects aRegion( aRect );
|
|
|
|
|
|
|
|
sal_Bool bOpaque = sal_False;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt32 nCurrOrd = mpCurrAnchoredObj
|
2006-09-15 10:43:10 +00:00
|
|
|
? mpCurrAnchoredObj->GetDrawObj()->GetOrdNum()
|
2007-09-27 08:20:23 +00:00
|
|
|
: SAL_MAX_UINT32;
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !bTopRule, "DrawTextOpaque: Wrong TopRule" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
|
|
|
|
if ( bOn && nCount > 0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-06-13 15:22:56 +02:00
|
|
|
MSHORT nHellId = pPage->getRootFrm()->GetCurrShell()->getIDocumentDrawModelAccess()->GetHellId();
|
2000-09-18 23:08:29 +00:00
|
|
|
for( MSHORT i = 0; i < nCount; ++i )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwAnchoredObject* pTmpAnchoredObj = (*mpAnchoredObjList)[i];
|
|
|
|
if( dynamic_cast<const SwFlyFrm*>(pTmpAnchoredObj) &&
|
|
|
|
mpCurrAnchoredObj != pTmpAnchoredObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFlyFrm* pFly = dynamic_cast<const SwFlyFrm*>(pTmpAnchoredObj);
|
2000-09-18 23:08:29 +00:00
|
|
|
if( aRegion.GetOrigin().IsOver( pFly->Frm() ) )
|
|
|
|
{
|
|
|
|
const SwFrmFmt *pFmt = pFly->GetFmt();
|
|
|
|
const SwFmtSurround &rSur = pFmt->GetSurround();
|
|
|
|
const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
|
2012-03-14 18:55:03 +01:00
|
|
|
// Only the ones who are opaque and more to the top
|
2002-10-11 10:31:19 +00:00
|
|
|
if( !( pFly->IsBackgroundTransparent()
|
|
|
|
|| pFly->IsShadowTransparent() ) &&
|
|
|
|
SURROUND_THROUGHT == rSur.GetSurround() &&
|
|
|
|
( !rSur.IsAnchorOnly() ||
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
GetMaster() == pFly->GetAnchorFrm() ||
|
2010-01-05 16:37:41 +01:00
|
|
|
((FLY_AT_PARA != rAnchor.GetAnchorId()) &&
|
|
|
|
(FLY_AT_CHAR != rAnchor.GetAnchorId())
|
2002-10-11 10:31:19 +00:00
|
|
|
)
|
|
|
|
) &&
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
pTmpAnchoredObj->GetDrawObj()->GetLayer() != nHellId &&
|
|
|
|
nCurrOrd < pTmpAnchoredObj->GetDrawObj()->GetOrdNum()
|
2002-10-11 10:31:19 +00:00
|
|
|
)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-14 18:55:03 +01:00
|
|
|
// Except for the content is transparent
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwNoTxtFrm *pNoTxt =
|
|
|
|
pFly->Lower() && pFly->Lower()->IsNoTxtFrm()
|
|
|
|
? (SwNoTxtFrm*)pFly->Lower()
|
|
|
|
: 0;
|
|
|
|
if ( !pNoTxt ||
|
|
|
|
(!pNoTxt->IsTransparent() && !rSur.IsContour()) )
|
|
|
|
{
|
|
|
|
bOpaque = sal_True;
|
|
|
|
aRegion -= pFly->Frm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Point aPos( rInf.GetPos().X(), rInf.GetPos().Y() + rInf.GetAscent() );
|
|
|
|
const Point &rOld = rInf.GetPos();
|
|
|
|
rInf.SetPos( aPos );
|
|
|
|
|
|
|
|
if( !bOpaque )
|
|
|
|
{
|
|
|
|
if( rInf.GetKern() )
|
|
|
|
rInf.GetFont()->_DrawStretchText( rInf );
|
|
|
|
else
|
|
|
|
rInf.GetFont()->_DrawText( rInf );
|
|
|
|
rInf.SetPos( rOld );
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
else if( aRegion.Count() )
|
|
|
|
{
|
2012-03-14 18:55:03 +01:00
|
|
|
// What a huge effort ...
|
2000-09-18 23:08:29 +00:00
|
|
|
SwSaveClip aClipVout( rInf.GetpOut() );
|
|
|
|
for( MSHORT i = 0; i < aRegion.Count(); ++i )
|
|
|
|
{
|
|
|
|
SwRect &rRect = aRegion[i];
|
|
|
|
if( rRect != aRegion.GetOrigin() )
|
|
|
|
aClipVout.ChgClip( rRect );
|
|
|
|
if( rInf.GetKern() )
|
|
|
|
rInf.GetFont()->_DrawStretchText( rInf );
|
|
|
|
else
|
|
|
|
rInf.GetFont()->_DrawText( rInf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rInf.SetPos( rOld );
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-15 08:57:33 +00:00
|
|
|
void SwTxtFly::DrawFlyRect( OutputDevice* pOut, const SwRect &rRect,
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwTxtPaintInfo &rInf, sal_Bool bNoGraphic )
|
|
|
|
{
|
|
|
|
SwRegionRects aRegion( rRect );
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !bTopRule, "DrawFlyRect: Wrong TopRule" );
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
|
|
|
|
if ( bOn && nCount > 0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-06-13 15:22:56 +02:00
|
|
|
MSHORT nHellId = pPage->getRootFrm()->GetCurrShell()->getIDocumentDrawModelAccess()->GetHellId();
|
2000-09-18 23:08:29 +00:00
|
|
|
for( MSHORT i = 0; i < nCount; ++i )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwAnchoredObject* pAnchoredObjTmp = (*mpAnchoredObjList)[i];
|
|
|
|
if( mpCurrAnchoredObj != pAnchoredObjTmp &&
|
|
|
|
dynamic_cast<const SwFlyFrm*>(pAnchoredObjTmp) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFmtSurround& rSur = pAnchoredObjTmp->GetFrmFmt().GetSurround();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// OD 24.01.2003 #106593# - correct clipping of fly frame area.
|
|
|
|
// Consider that fly frame background/shadow can be transparent
|
|
|
|
// and <SwAlignRect(..)> fly frame area
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFlyFrm* pFly = dynamic_cast<const SwFlyFrm*>(pAnchoredObjTmp);
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i47804# - consider transparent graphics
|
2005-09-28 10:20:42 +00:00
|
|
|
// and OLE objects.
|
2003-03-27 14:45:43 +00:00
|
|
|
bool bClipFlyArea =
|
2005-09-28 10:20:42 +00:00
|
|
|
( ( SURROUND_THROUGHT == rSur.GetSurround() )
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
? (pAnchoredObjTmp->GetDrawObj()->GetLayer() != nHellId)
|
2005-09-28 10:20:42 +00:00
|
|
|
: !rSur.IsContour() ) &&
|
2003-03-27 14:45:43 +00:00
|
|
|
!pFly->IsBackgroundTransparent() &&
|
2005-09-28 10:20:42 +00:00
|
|
|
!pFly->IsShadowTransparent() &&
|
|
|
|
( !pFly->Lower() ||
|
|
|
|
!pFly->Lower()->IsNoTxtFrm() ||
|
|
|
|
!static_cast<const SwNoTxtFrm*>(pFly->Lower())->IsTransparent() );
|
2003-03-27 14:45:43 +00:00
|
|
|
if ( bClipFlyArea )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwRect aFly( pAnchoredObjTmp->GetObjRect() );
|
2003-03-27 14:45:43 +00:00
|
|
|
// OD 24.01.2003 #106593#
|
2010-06-13 15:22:56 +02:00
|
|
|
::SwAlignRect( aFly, pPage->getRootFrm()->GetCurrShell() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( aFly.Width() > 0 && aFly.Height() > 0 )
|
|
|
|
aRegion -= aFly;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for( MSHORT i = 0; i < aRegion.Count(); ++i )
|
|
|
|
{
|
|
|
|
if ( bNoGraphic )
|
|
|
|
pOut->DrawRect( aRegion[i].SVRect() );
|
|
|
|
else
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( ((SvxBrushItem*)-1) != rInf.GetBrushItem(),
|
2000-09-18 23:08:29 +00:00
|
|
|
"DrawRect: Uninitialized BrushItem!" );
|
|
|
|
::DrawGraphic( rInf.GetBrushItem(), pOut, rInf.GetBrushRect(),
|
|
|
|
aRegion[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945# - change first parameter
|
2004-11-16 14:52:58 +00:00
|
|
|
// Now it's the <SwAnchoredObject> instance of the floating screen object
|
|
|
|
sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj,
|
|
|
|
const sal_Bool bInFtn,
|
2001-10-12 07:11:40 +00:00
|
|
|
const sal_Bool bInFooterOrHeader )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
// <mpCurrAnchoredObj> is set, if <pCurrFrm> is inside a fly frame
|
|
|
|
if( _pAnchoredObj != mpCurrAnchoredObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SdrObject* pNew = _pAnchoredObj->GetDrawObj();
|
2002-10-30 14:13:25 +00:00
|
|
|
// #102344# Ignore connectors which have one or more connections
|
|
|
|
if(pNew && pNew->ISA(SdrEdgeObj))
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
if(((SdrEdgeObj*)pNew)->GetConnectedNode(sal_True)
|
|
|
|
|| ((SdrEdgeObj*)pNew)->GetConnectedNode(sal_False))
|
2002-10-30 14:13:25 +00:00
|
|
|
{
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-12 07:11:40 +00:00
|
|
|
if( ( bInFtn || bInFooterOrHeader ) && bTopRule )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2004-11-16 14:52:58 +00:00
|
|
|
const SwFrmFmt& rFrmFmt = _pAnchoredObj->GetFrmFmt();
|
|
|
|
const SwFmtAnchor& rNewA = rFrmFmt.GetAnchor();
|
2010-01-05 16:37:41 +01:00
|
|
|
if (FLY_AT_PAGE == rNewA.GetAnchorId())
|
2001-10-12 07:11:40 +00:00
|
|
|
{
|
|
|
|
if ( bInFtn )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
if ( bInFooterOrHeader )
|
|
|
|
{
|
2004-11-16 14:52:58 +00:00
|
|
|
SwFmtVertOrient aVert( rFrmFmt.GetVertOrient() );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bVertPrt = aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ||
|
2007-09-27 08:20:23 +00:00
|
|
|
aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA;
|
2001-10-12 07:11:40 +00:00
|
|
|
if( bVertPrt )
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-10-12 07:11:40 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2004-05-11 10:28:25 +00:00
|
|
|
// bEvade: consider pNew, if we are not inside a fly
|
2006-09-15 10:43:10 +00:00
|
|
|
// consider pNew, if pNew is lower of <mpCurrAnchoredObj>
|
|
|
|
sal_Bool bEvade = !mpCurrAnchoredObj ||
|
|
|
|
Is_Lower_Of( dynamic_cast<const SwFlyFrm*>(mpCurrAnchoredObj), pNew);
|
2004-05-11 10:28:25 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !bEvade )
|
|
|
|
{
|
2004-05-11 10:28:25 +00:00
|
|
|
// We are currently inside a fly frame and pNew is not
|
|
|
|
// inside this fly frame. We can do some more checks if
|
|
|
|
// we have to consider pNew.
|
|
|
|
|
|
|
|
// If bTopRule is not set, we ignore the frame types.
|
|
|
|
// We directly check the z-order
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !bTopRule )
|
2004-05-11 10:28:25 +00:00
|
|
|
bEvade = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
{
|
2012-03-14 18:55:03 +01:00
|
|
|
// Within chained Flys we only avoid Lower
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFmtChain &rChain = mpCurrAnchoredObj->GetFrmFmt().GetChain();
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !rChain.GetPrev() && !rChain.GetNext() )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2004-11-16 14:52:58 +00:00
|
|
|
const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor();
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFmtAnchor& rCurrA = mpCurrAnchoredObj->GetFrmFmt().GetAnchor();
|
2004-05-11 10:28:25 +00:00
|
|
|
|
2006-09-15 10:43:10 +00:00
|
|
|
// If <mpCurrAnchoredObj> is anchored as character, its content
|
2004-05-11 10:28:25 +00:00
|
|
|
// does not wrap around pNew
|
2010-01-05 16:37:41 +01:00
|
|
|
if (FLY_AS_CHAR == rCurrA.GetAnchorId())
|
2004-05-11 10:28:25 +00:00
|
|
|
return sal_False;
|
|
|
|
|
2006-09-15 10:43:10 +00:00
|
|
|
// If pNew is anchored to page and <mpCurrAnchoredObj is not anchored
|
|
|
|
// to page, the content of <mpCurrAnchoredObj> does not wrap around pNew
|
|
|
|
// If both pNew and <mpCurrAnchoredObj> are anchored to page, we can do
|
2004-05-11 10:28:25 +00:00
|
|
|
// some more checks
|
2010-01-05 16:37:41 +01:00
|
|
|
if (FLY_AT_PAGE == rNewA.GetAnchorId())
|
2004-05-11 10:28:25 +00:00
|
|
|
{
|
2010-01-05 16:37:41 +01:00
|
|
|
if (FLY_AT_PAGE == rCurrA.GetAnchorId())
|
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
bEvade = sal_True;
|
2010-01-05 16:37:41 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
return sal_False;
|
|
|
|
}
|
2010-01-05 16:37:41 +01:00
|
|
|
else if (FLY_AT_PAGE == rCurrA.GetAnchorId())
|
2012-03-14 18:55:03 +01:00
|
|
|
return sal_False; // Page anchored ones only avoid page anchored ones
|
2010-01-05 16:37:41 +01:00
|
|
|
else if (FLY_AT_FLY == rNewA.GetAnchorId())
|
2012-03-14 18:55:03 +01:00
|
|
|
bEvade = sal_True; // Non-page anchored ones avoid frame anchored ones
|
2000-09-18 23:08:29 +00:00
|
|
|
else if( FLY_AT_FLY == rCurrA.GetAnchorId() )
|
2012-03-14 18:55:03 +01:00
|
|
|
return sal_False; // Frame anchored ones do not avoid paragraph anchored ones
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i57062#
|
2006-02-03 16:19:01 +00:00
|
|
|
// In order to avoid loop situation, it's decided to adjust
|
|
|
|
// the wrapping behaviour of content of at-paragraph/at-character
|
|
|
|
// anchored objects to one in the page header/footer and
|
|
|
|
// the document body --> content of at-paragraph/at-character
|
|
|
|
// anchored objects doesn't wrap around each other.
|
|
|
|
else
|
|
|
|
return sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-11 10:28:25 +00:00
|
|
|
|
2012-03-14 18:55:03 +01:00
|
|
|
// But: we never avoid a subordinate one and additionally we only avoid when overlapping.
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
bEvade &= ( mpCurrAnchoredObj->GetDrawObj()->GetOrdNum() < pNew->GetOrdNum() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bEvade )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwRect aTmp( _pAnchoredObj->GetObjRectWithSpaces() );
|
|
|
|
if ( !aTmp.IsOver( mpCurrAnchoredObj->GetObjRectWithSpaces() ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
bEvade = sal_False;
|
|
|
|
}
|
|
|
|
}
|
2004-05-11 10:28:25 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( bEvade )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2004-11-16 14:52:58 +00:00
|
|
|
const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( FLY_AS_CHAR != rNewA.GetAnchorId(),
|
2010-01-05 16:37:41 +01:00
|
|
|
"Don't call GetTop with a FlyInCntFrm" );
|
|
|
|
if (FLY_AT_PAGE == rNewA.GetAnchorId())
|
2012-03-14 18:55:03 +01:00
|
|
|
return sal_True; // We always avoid page anchored ones
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// Wenn absatzgebundene Flys in einem FlyCnt gefangen sind, so
|
|
|
|
// endet deren Einflussbereich an den Grenzen des FlyCnt!
|
|
|
|
// Wenn wir aber gerade den Text des FlyCnt formatieren, dann
|
|
|
|
// muss er natuerlich dem absatzgebundenen Frm ausweichen!
|
|
|
|
// pCurrFrm ist der Anker von pNew?
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2004-11-16 14:52:58 +00:00
|
|
|
const SwFrm* pTmp = _pAnchoredObj->GetAnchorFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pTmp == pCurrFrm )
|
|
|
|
return sal_True;
|
|
|
|
if( pTmp->IsTxtFrm() && ( pTmp->IsInFly() || pTmp->IsInFtn() ) )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2004-11-16 14:52:58 +00:00
|
|
|
Point aPos = _pAnchoredObj->GetObjRect().Pos();
|
2000-09-18 23:08:29 +00:00
|
|
|
pTmp = GetVirtualUpper( pTmp, aPos );
|
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945#
|
2011-04-18 12:37:38 -03:00
|
|
|
// #115759#
|
2004-12-23 09:10:13 +00:00
|
|
|
// If <pTmp> is a text frame inside a table, take the upper
|
|
|
|
// of the anchor frame, which contains the anchor position.
|
|
|
|
else if ( pTmp->IsTxtFrm() && pTmp->IsInTab() )
|
2004-11-16 14:52:58 +00:00
|
|
|
{
|
2004-12-23 09:10:13 +00:00
|
|
|
pTmp = const_cast<SwAnchoredObject*>(_pAnchoredObj)
|
|
|
|
->GetAnchorFrmContainingAnchPos()->GetUpper();
|
2004-11-16 14:52:58 +00:00
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i28701# - consider all objects in same context,
|
2004-08-02 13:15:54 +00:00
|
|
|
// if wrapping style is considered on object positioning.
|
|
|
|
// Thus, text will wrap around negative positioned objects.
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i3317# - remove condition on checking,
|
2004-09-09 09:59:23 +00:00
|
|
|
// if wrappings style is considered on object postioning.
|
|
|
|
// Thus, text is wrapping around negative positioned objects.
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i35640# - no consideration of negative
|
2004-11-16 14:52:58 +00:00
|
|
|
// positioned objects, if wrapping style isn't considered on
|
|
|
|
// object position and former text wrapping is applied.
|
|
|
|
// This condition is typically for documents imported from the
|
|
|
|
// OpenOffice.org file format.
|
2006-08-14 15:43:44 +00:00
|
|
|
const IDocumentSettingAccess* pIDSA = pCurrFrm->GetTxtNode()->getIDocumentSettingAccess();
|
|
|
|
if ( ( pIDSA->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) ||
|
|
|
|
!pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) ) &&
|
2004-11-16 14:52:58 +00:00
|
|
|
::FindKontext( pTmp, 0 ) == ::FindKontext( pCurrFrm, 0 ) )
|
2004-08-02 13:15:54 +00:00
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
2004-05-11 10:28:25 +00:00
|
|
|
|
|
|
|
const SwFrm* pHeader = 0;
|
|
|
|
if ( pCurrFrm->GetNext() != pTmp &&
|
2004-08-02 13:15:54 +00:00
|
|
|
( IsFrmInSameKontext( pTmp, pCurrFrm ) ||
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i13832#, #i24135# wrap around objects in page header
|
2006-08-14 15:43:44 +00:00
|
|
|
( !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) &&
|
2004-08-02 13:15:54 +00:00
|
|
|
0 != ( pHeader = pTmp->FindFooterOrHeader() ) &&
|
|
|
|
!pHeader->IsFooterFrm() &&
|
|
|
|
pCurrFrm->IsInDocBody() ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-05-11 10:28:25 +00:00
|
|
|
if( pHeader || FLY_AT_FLY == rNewA.GetAnchorId() )
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
// Compare indices:
|
2000-09-18 23:08:29 +00:00
|
|
|
// Den Index des anderen erhalten wir immer ueber das Ankerattr.
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nTmpIndex = rNewA.GetCntntAnchor()->nNode.GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
// Jetzt wird noch ueberprueft, ob der aktuelle Absatz vor dem
|
|
|
|
// Anker des verdraengenden Objekts im Text steht, dann wird
|
|
|
|
// nicht ausgewichen.
|
|
|
|
// Der Index wird moeglichst ueber einen SwFmtAnchor ermittelt,
|
|
|
|
// da sonst recht teuer.
|
|
|
|
if( ULONG_MAX == nIndex )
|
|
|
|
nIndex = pCurrFrm->GetNode()->GetIndex();
|
|
|
|
|
|
|
|
if( nIndex >= nTmpIndex )
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-03 16:19:01 +00:00
|
|
|
return sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2006-09-15 10:43:10 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList* SwTxtFly::InitAnchoredObjList()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pCurrFrm, "InitFlyList: No Frame, no FlyList" );
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !mpAnchoredObjList, "InitFlyList: FlyList already initialized" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-12-06 14:49:17 +00:00
|
|
|
SWAP_IF_SWAPPED( pCurrFrm )
|
2001-10-29 10:18:15 +00:00
|
|
|
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwSortedObjs *pSorted = pPage->GetSortedObjs();
|
|
|
|
const sal_uInt32 nCount = pSorted ? pSorted->Count() : 0;
|
2012-03-22 14:27:43 +01:00
|
|
|
// --> #108724# Page header/footer content doesn't have to wrap around
|
|
|
|
// floating screen objects
|
|
|
|
const bool bFooterHeader = 0 != pCurrFrm->FindFooterOrHeader();
|
|
|
|
const IDocumentSettingAccess* pIDSA = pCurrFrm->GetTxtNode()->getIDocumentSettingAccess();
|
|
|
|
// #i40155# - check, if frame is marked not to wrap
|
|
|
|
const sal_Bool bWrapAllowed = ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) ||
|
2012-03-22 14:52:37 +01:00
|
|
|
( !pCurrFrm->IsInFtn() && !bFooterHeader ) );
|
2004-05-11 10:28:25 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
bOn = sal_False;
|
2004-05-11 10:28:25 +00:00
|
|
|
|
|
|
|
if( nCount && bWrapAllowed )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
mpAnchoredObjList = new SwAnchoredObjList();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i28701# - consider complete frame area for new
|
2004-08-02 13:15:54 +00:00
|
|
|
// text wrapping
|
|
|
|
SwRect aRect;
|
2006-08-14 15:43:44 +00:00
|
|
|
if ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) )
|
2004-08-02 13:15:54 +00:00
|
|
|
{
|
|
|
|
aRect = pCurrFrm->Prt();
|
|
|
|
aRect += pCurrFrm->Frm().Pos();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aRect = pCurrFrm->Frm();
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
// Wir machen uns etwas kleiner als wir sind,
|
|
|
|
// damit Ein-Twip-Ueberlappungen ignoriert werden. (#49532)
|
2001-12-06 14:49:17 +00:00
|
|
|
SWRECTFN( pCurrFrm )
|
|
|
|
const long nRight = (aRect.*fnRect->fnGetRight)() - 1;
|
|
|
|
const long nLeft = (aRect.*fnRect->fnGetLeft)() + 1;
|
2003-05-22 08:49:57 +00:00
|
|
|
const sal_Bool bR2L = pCurrFrm->IsRightToLeft();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-08-14 15:43:44 +00:00
|
|
|
const IDocumentDrawModelAccess* pIDDMA = pCurrFrm->GetTxtNode()->getIDocumentDrawModelAccess();
|
|
|
|
|
2004-08-02 13:15:54 +00:00
|
|
|
for( sal_uInt32 i = 0; i < nCount; i++ )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
|
|
|
// do not consider hidden objects
|
|
|
|
// check, if object has to be considered for text wrap
|
|
|
|
// #118809# - If requested, do not consider
|
|
|
|
// objects in page header|footer for text frames not in page
|
|
|
|
// header|footer. This is requested for the calculation of
|
|
|
|
// the base offset for objects <SwTxtFrm::CalcBaseOfstForFly()>
|
|
|
|
// #i20505# Do not consider oversized objects
|
2004-08-02 13:15:54 +00:00
|
|
|
SwAnchoredObject* pAnchoredObj = (*pSorted)[ i ];
|
2006-08-14 15:43:44 +00:00
|
|
|
if ( !pIDDMA->IsVisibleLayerId( pAnchoredObj->GetDrawObj()->GetLayer() ) ||
|
2004-08-02 13:15:54 +00:00
|
|
|
!pAnchoredObj->ConsiderForTextWrap() ||
|
2006-09-15 10:43:10 +00:00
|
|
|
( mbIgnoreObjsInHeaderFooter && !bFooterHeader &&
|
|
|
|
pAnchoredObj->GetAnchorFrm()->FindFooterOrHeader() ) )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
|
|
|
|
if ( nRight < (aBound.*fnRect->fnGetLeft)() ||
|
2004-02-26 14:33:39 +00:00
|
|
|
(*fnRect->fnYDiff)( (aRect.*fnRect->fnGetTop)(),
|
|
|
|
(aBound.*fnRect->fnGetBottom)() ) > 0 ||
|
2004-08-02 12:09:31 +00:00
|
|
|
nLeft > (aBound.*fnRect->fnGetRight)() ||
|
|
|
|
(aBound.*fnRect->fnGetHeight)() >
|
2006-09-15 10:43:10 +00:00
|
|
|
2 * (pPage->Frm().*fnRect->fnGetHeight)() )
|
2004-02-26 14:33:39 +00:00
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
2004-02-26 14:33:39 +00:00
|
|
|
}
|
2001-10-12 07:11:40 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945# - pass <pAnchoredObj> to method
|
2004-11-16 14:52:58 +00:00
|
|
|
// <GetTop(..)> instead of only the <SdrObject> instance of the
|
|
|
|
// anchored object
|
|
|
|
if ( GetTop( pAnchoredObj, pCurrFrm->IsInFtn(), bFooterHeader ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-04-01 14:32:04 +00:00
|
|
|
// OD 11.03.2003 #107862# - adjust insert position:
|
|
|
|
// overlapping objects should be sorted from left to right and
|
|
|
|
// inside left to right sorting from top to bottom.
|
|
|
|
// If objects on the same position are found, they are sorted
|
|
|
|
// on its width.
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::iterator aInsPosIter =
|
|
|
|
std::lower_bound( mpAnchoredObjList->begin(),
|
|
|
|
mpAnchoredObjList->end(),
|
|
|
|
pAnchoredObj,
|
|
|
|
AnchoredObjOrder( bR2L, fnRect ) );
|
|
|
|
|
|
|
|
mpAnchoredObjList->insert( aInsPosIter, pAnchoredObj );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwFmtSurround &rFlyFmt = pAnchoredObj->GetFrmFmt().GetSurround();
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
if ( rFlyFmt.IsAnchorOnly() &&
|
|
|
|
pAnchoredObj->GetAnchorFrm() == GetMaster() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwFmtVertOrient &rTmpFmt =
|
|
|
|
pAnchoredObj->GetFrmFmt().GetVertOrient();
|
2007-09-27 08:20:23 +00:00
|
|
|
if( text::VertOrientation::BOTTOM != rTmpFmt.GetVertOrient() )
|
2001-12-06 14:49:17 +00:00
|
|
|
nMinBottom = ( bVert && nMinBottom ) ?
|
|
|
|
Min( nMinBottom, aBound.Left() ) :
|
|
|
|
Max( nMinBottom, (aBound.*fnRect->fnGetBottom)() );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bOn = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( nMinBottom )
|
|
|
|
{
|
2001-12-13 15:08:15 +00:00
|
|
|
SwTwips nMax = (pCurrFrm->GetUpper()->*fnRect->fnGetPrtBottom)();
|
2001-12-06 14:49:17 +00:00
|
|
|
if( (*fnRect->fnYDiff)( nMinBottom, nMax ) > 0 )
|
|
|
|
nMinBottom = nMax;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2006-09-15 10:43:10 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
mpAnchoredObjList = new SwAnchoredObjList();
|
|
|
|
}
|
2001-10-29 10:18:15 +00:00
|
|
|
|
|
|
|
UNDO_SWAP( pCurrFrm )
|
2001-08-31 05:22:48 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
return mpAnchoredObjList;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwTwips SwTxtFly::CalcMinBottom() const
|
|
|
|
{
|
|
|
|
SwTwips nRet = 0;
|
2011-06-23 15:14:00 +01:00
|
|
|
const SwCntntFrm *pLclMaster = GetMaster();
|
|
|
|
OSL_ENSURE(pLclMaster, "SwTxtFly without master");
|
|
|
|
const SwSortedObjs *pDrawObj = pLclMaster ? pLclMaster->GetDrawObjs() : NULL;
|
2004-08-02 13:15:54 +00:00
|
|
|
const sal_uInt32 nCount = pDrawObj ? pDrawObj->Count() : 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( nCount )
|
|
|
|
{
|
|
|
|
SwTwips nEndOfFrm = pCurrFrm->Frm().Bottom();
|
2004-08-02 13:15:54 +00:00
|
|
|
for( sal_uInt32 i = 0; i < nCount; i++ )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-08-02 13:15:54 +00:00
|
|
|
SwAnchoredObject* pAnchoredObj = (*pDrawObj)[ i ];
|
|
|
|
const SwFmtSurround &rFlyFmt = pAnchoredObj->GetFrmFmt().GetSurround();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( rFlyFmt.IsAnchorOnly() )
|
|
|
|
{
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwFmtVertOrient &rTmpFmt =
|
|
|
|
pAnchoredObj->GetFrmFmt().GetVertOrient();
|
2007-09-27 08:20:23 +00:00
|
|
|
if( text::VertOrientation::BOTTOM != rTmpFmt.GetVertOrient() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2004-08-02 13:15:54 +00:00
|
|
|
const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( aBound.Top() < nEndOfFrm )
|
|
|
|
nRet = Max( nRet, aBound.Bottom() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SwTwips nMax = pCurrFrm->GetUpper()->Frm().Top() +
|
|
|
|
pCurrFrm->GetUpper()->Prt().Bottom();
|
|
|
|
if( nRet > nMax )
|
|
|
|
nRet = nMax;
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sal_Bool SwTxtFly::ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid ) const
|
|
|
|
{
|
2001-12-06 14:49:17 +00:00
|
|
|
SWAP_IF_SWAPPED( pCurrFrm )
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_Bool bRet = sal_False;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
|
|
|
|
if ( bOn && nCount > 0 )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-09-15 10:43:10 +00:00
|
|
|
for( SwAnchoredObjList::size_type i = 0; i < nCount; ++i )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwAnchoredObject* pAnchoredObj = (*mpAnchoredObjList)[i];
|
2001-08-31 05:22:48 +00:00
|
|
|
|
2006-09-15 10:43:10 +00:00
|
|
|
SwRect aRect( pAnchoredObj->GetObjRectWithSpaces() );
|
2001-08-31 05:22:48 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
// Optimierung
|
2001-12-06 14:49:17 +00:00
|
|
|
SWRECTFN( pCurrFrm )
|
|
|
|
if( (aRect.*fnRect->fnGetLeft)() > (rRect.*fnRect->fnGetRight)() )
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
if ( mpCurrAnchoredObj != pAnchoredObj && aRect.IsOver( rRect ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFmt* pFmt( &(pAnchoredObj->GetFrmFmt()) );
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwFmtSurround &rSur = pFmt->GetSurround();
|
|
|
|
if( bAvoid )
|
|
|
|
{
|
|
|
|
// Wenn der Text drunter durchlaeuft, bleibt die
|
|
|
|
// Formatierung unbeeinflusst. Im LineIter::DrawText()
|
|
|
|
// muessen "nur" geschickt die ClippingRegions gesetzt werden ...
|
|
|
|
const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
|
|
|
|
if( ( SURROUND_THROUGHT == rSur.GetSurround() &&
|
|
|
|
( !rSur.IsAnchorOnly() ||
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
GetMaster() == pAnchoredObj->GetAnchorFrm() ||
|
2010-01-05 16:37:41 +01:00
|
|
|
((FLY_AT_PARA != rAnchor.GetAnchorId()) &&
|
|
|
|
(FLY_AT_CHAR != rAnchor.GetAnchorId())) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
|| aRect.Top() == WEIT_WECH )
|
|
|
|
continue;
|
|
|
|
}
|
2003-05-22 08:49:57 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i58642#
|
2006-02-03 16:19:01 +00:00
|
|
|
// Compare <GetMaster()> instead of <pCurrFrm> with the anchor
|
|
|
|
// frame of the anchored object, because a follow frame have
|
|
|
|
// to ignore the anchored objects of its master frame.
|
|
|
|
// Note: Anchored objects are always registered at the master
|
|
|
|
// frame, exception are as-character anchored objects,
|
|
|
|
// but these aren't handled here.
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
if ( mbIgnoreCurrentFrame &&
|
|
|
|
GetMaster() == pAnchoredObj->GetAnchorFrm() )
|
2003-05-22 08:49:57 +00:00
|
|
|
continue;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pRect )
|
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwRect aFly = AnchoredObjToRect( pAnchoredObj, rRect );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( aFly.IsEmpty() || !aFly.IsOver( rRect ) )
|
|
|
|
continue;
|
2010-09-30 15:43:54 +01:00
|
|
|
if( !bRet || (
|
2003-05-22 08:49:57 +00:00
|
|
|
( !pCurrFrm->IsRightToLeft() &&
|
|
|
|
( (aFly.*fnRect->fnGetLeft)() <
|
2010-09-30 15:43:54 +01:00
|
|
|
(pRect->*fnRect->fnGetLeft)() ) ) ||
|
2003-05-22 08:49:57 +00:00
|
|
|
( pCurrFrm->IsRightToLeft() &&
|
|
|
|
( (aFly.*fnRect->fnGetRight)() >
|
|
|
|
(pRect->*fnRect->fnGetRight)() ) ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
*pRect = aFly;
|
|
|
|
if( rSur.IsContour() )
|
|
|
|
{
|
|
|
|
bRet = sal_True;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bRet = sal_True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-06 14:49:17 +00:00
|
|
|
|
|
|
|
UNDO_SWAP( pCurrFrm )
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type SwTxtFly::GetPos( const SwAnchoredObject* pAnchoredObj ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nCount = GetAnchoredObjList()->size();
|
|
|
|
SwAnchoredObjList::size_type nRet = 0;
|
|
|
|
while ( nRet < nCount && pAnchoredObj != (*mpAnchoredObjList)[ nRet ] )
|
2000-09-18 23:08:29 +00:00
|
|
|
++nRet;
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
void SwTxtFly::CalcRightMargin( SwRect &rFly,
|
|
|
|
SwAnchoredObjList::size_type nFlyPos,
|
|
|
|
const SwRect &rLine ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
// Normalerweise ist der rechte Rand der rechte Rand der Printarea.
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( ! pCurrFrm->IsVertical() || ! pCurrFrm->IsSwapped(),
|
|
|
|
"SwTxtFly::CalcRightMargin with swapped frame" );
|
2001-12-06 14:49:17 +00:00
|
|
|
SWRECTFN( pCurrFrm )
|
2011-04-18 12:37:38 -03:00
|
|
|
// #118796# - correct determination of right of printing area
|
2005-01-05 13:31:24 +00:00
|
|
|
SwTwips nRight = (pCurrFrm->*fnRect->fnGetPrtRight)();
|
2001-12-06 14:49:17 +00:00
|
|
|
SwTwips nFlyRight = (rFly.*fnRect->fnGetRight)();
|
|
|
|
SwRect aLine( rLine );
|
|
|
|
(aLine.*fnRect->fnSetRight)( nRight );
|
|
|
|
(aLine.*fnRect->fnSetLeft)( (rFly.*fnRect->fnGetLeft)() );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// Es koennte aber sein, dass in die gleiche Zeile noch ein anderes
|
|
|
|
// Object hineinragt, welches _ueber_ uns liegt.
|
|
|
|
// Wunder der Technik: Flys mit Durchlauf sind fuer die darunterliegenden
|
|
|
|
// unsichtbar, das heisst, dass sie bei der Berechnung der Raender
|
|
|
|
// anderer Flys ebenfalls nicht auffallen.
|
|
|
|
// 3301: pNext->Frm().IsOver( rLine ) ist noetig
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwSurround eSurroundForTextWrap;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
sal_Bool bStop = sal_False;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nPos = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
while( nPos < mpAnchoredObjList->size() && !bStop )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( nPos == nFlyPos )
|
|
|
|
{
|
|
|
|
++nPos;
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwAnchoredObject* pNext = (*mpAnchoredObjList)[ nPos++ ];
|
|
|
|
if ( pNext == mpCurrAnchoredObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
2006-09-15 10:43:10 +00:00
|
|
|
eSurroundForTextWrap = _GetSurroundForTextWrap( pNext );
|
|
|
|
if( SURROUND_THROUGHT == eSurroundForTextWrap )
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
2001-12-06 14:49:17 +00:00
|
|
|
|
|
|
|
const SwRect aTmp( SwContourCache::CalcBoundRect
|
2001-12-06 14:54:16 +00:00
|
|
|
( pNext, aLine, pCurrFrm, nFlyRight, sal_True ) );
|
2001-12-06 14:49:17 +00:00
|
|
|
SwTwips nTmpRight = (aTmp.*fnRect->fnGetRight)();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// Optimierung:
|
|
|
|
// In nNextTop wird notiert, an welcher Y-Positon mit Aenderung der
|
|
|
|
// Rahmenverhaeltnisse gerechnet werden muss. Dies dient dazu, dass,
|
|
|
|
// obwohl nur die Rahmen in der aktuellen Zeilenhoehe betrachtet werden,
|
|
|
|
// bei Rahmen ohne Umlauf die Zeilenhoehe so erhoeht wird, dass mit einer
|
|
|
|
// einzigen Zeile die Unterkante das Rahmens oder ggf. die Oberkante des
|
|
|
|
// naechsten Rahmen erreicht wird.
|
|
|
|
// Insbesondere bei HTML-Dokumenten kommen oft (Dummy-)Absaetze in einer
|
|
|
|
// 2-Pt.-Schrift vor, bis diese einem groesseren Rahmen ausgewichen sind,
|
|
|
|
// erforderte es frueher Unmengen von Leerzeilen.
|
2001-12-06 14:49:17 +00:00
|
|
|
const long nTmpTop = (aTmp.*fnRect->fnGetTop)();
|
|
|
|
if( (*fnRect->fnYDiff)( nTmpTop, (aLine.*fnRect->fnGetTop)() ) > 0 )
|
|
|
|
{
|
|
|
|
if( (*fnRect->fnYDiff)( nNextTop, nTmpTop ) > 0 )
|
|
|
|
SetNextTop( nTmpTop ); // Die Oberkante des "naechsten" Rahmens
|
|
|
|
}
|
|
|
|
else if( ! (aTmp.*fnRect->fnGetWidth)() ) // Typisch fuer Objekte mit Konturumlauf
|
|
|
|
{ // Bei Objekten mit Konturumlauf, die vor der aktuellen Zeile beginnen
|
|
|
|
// und hinter ihr enden, trotzdem aber nicht mit ihr ueberlappen,
|
|
|
|
// muss die Optimierung ausgeschaltet werden, denn bereits in der
|
|
|
|
// naechsten Zeile kann sich dies aendern.
|
|
|
|
if( ! (aTmp.*fnRect->fnGetHeight)() ||
|
|
|
|
(*fnRect->fnYDiff)( (aTmp.*fnRect->fnGetBottom)(),
|
|
|
|
(aLine.*fnRect->fnGetTop)() ) > 0 )
|
|
|
|
SetNextTop( 0 );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
if( aTmp.IsOver( aLine ) && nTmpRight > nFlyRight )
|
|
|
|
{
|
|
|
|
nFlyRight = nTmpRight;
|
2007-09-27 08:20:23 +00:00
|
|
|
if( SURROUND_RIGHT == eSurroundForTextWrap ||
|
|
|
|
SURROUND_PARALLEL == eSurroundForTextWrap )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 08:20:23 +00:00
|
|
|
// der FlyFrm wird ueberstimmt.
|
|
|
|
if( nRight > nFlyRight )
|
|
|
|
nRight = nFlyRight;
|
|
|
|
bStop = sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-12-06 14:49:17 +00:00
|
|
|
(rFly.*fnRect->fnSetRight)( nRight );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
void SwTxtFly::CalcLeftMargin( SwRect &rFly,
|
|
|
|
SwAnchoredObjList::size_type nFlyPos,
|
|
|
|
const SwRect &rLine ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( ! pCurrFrm->IsVertical() || ! pCurrFrm->IsSwapped(),
|
|
|
|
"SwTxtFly::CalcLeftMargin with swapped frame" );
|
2001-12-06 14:49:17 +00:00
|
|
|
SWRECTFN( pCurrFrm )
|
2011-04-18 12:37:38 -03:00
|
|
|
// #118796# - correct determination of left of printing area
|
2005-01-05 13:31:24 +00:00
|
|
|
SwTwips nLeft = (pCurrFrm->*fnRect->fnGetPrtLeft)();
|
2001-12-06 14:49:17 +00:00
|
|
|
const SwTwips nFlyLeft = (rFly.*fnRect->fnGetLeft)();
|
|
|
|
|
|
|
|
if( nLeft > nFlyLeft )
|
|
|
|
nLeft = rFly.Left();
|
|
|
|
|
|
|
|
SwRect aLine( rLine );
|
|
|
|
(aLine.*fnRect->fnSetLeft)( nLeft );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// Es koennte aber sein, dass in die gleiche Zeile noch ein anderes
|
|
|
|
// Object hineinragt, welches _ueber_ uns liegt.
|
|
|
|
// Wunder der Technik: Flys mit Durchlauf sind fuer die darunterliegenden
|
|
|
|
// unsichtbar, das heisst, dass sie bei der Berechnung der Raender
|
|
|
|
// anderer Flys ebenfalls nicht auffallen.
|
|
|
|
// 3301: pNext->Frm().IsOver( rLine ) ist noetig
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nMyPos = nFlyPos;
|
|
|
|
while( ++nFlyPos < mpAnchoredObjList->size() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwAnchoredObject* pNext = (*mpAnchoredObjList)[ nFlyPos ];
|
|
|
|
const SwRect aTmp( pNext->GetObjRectWithSpaces() );
|
2001-12-06 14:49:17 +00:00
|
|
|
if( (aTmp.*fnRect->fnGetLeft)() >= nFlyLeft )
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( nFlyPos )
|
|
|
|
{
|
|
|
|
if( --nFlyPos == nMyPos )
|
|
|
|
continue;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwAnchoredObject* pNext = (*mpAnchoredObjList)[ nFlyPos ];
|
|
|
|
if( pNext == mpCurrAnchoredObj )
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
2006-09-15 10:43:10 +00:00
|
|
|
SwSurround eSurroundForTextWrap = _GetSurroundForTextWrap( pNext );
|
|
|
|
if( SURROUND_THROUGHT == eSurroundForTextWrap )
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
2001-08-31 05:22:48 +00:00
|
|
|
|
2001-12-06 14:49:17 +00:00
|
|
|
const SwRect aTmp( SwContourCache::CalcBoundRect
|
2001-12-06 14:54:16 +00:00
|
|
|
( pNext, aLine, pCurrFrm, nFlyLeft, sal_False ) );
|
2001-12-06 14:49:17 +00:00
|
|
|
|
|
|
|
if( (aTmp.*fnRect->fnGetLeft)() < nFlyLeft && aTmp.IsOver( aLine ) )
|
2001-08-31 05:22:48 +00:00
|
|
|
{
|
2011-04-18 12:37:38 -03:00
|
|
|
// #118796# - no '+1', because <..fnGetRight>
|
2005-01-05 13:31:24 +00:00
|
|
|
// returns the correct value.
|
2001-12-06 14:49:17 +00:00
|
|
|
SwTwips nTmpRight = (aTmp.*fnRect->fnGetRight)();
|
2005-01-05 13:31:24 +00:00
|
|
|
if ( nLeft <= nTmpRight )
|
|
|
|
nLeft = nTmpRight;
|
2001-12-06 14:49:17 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-12-06 14:49:17 +00:00
|
|
|
(rFly.*fnRect->fnSetLeft)( nLeft );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2006-09-15 10:43:10 +00:00
|
|
|
SwRect SwTxtFly::AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
|
|
|
|
const SwRect &rLine ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-12-06 14:49:17 +00:00
|
|
|
SWRECTFN( pCurrFrm )
|
2002-06-05 13:12:56 +00:00
|
|
|
|
|
|
|
const long nXPos = pCurrFrm->IsRightToLeft() ?
|
|
|
|
rLine.Right() :
|
|
|
|
(rLine.*fnRect->fnGetLeft)();
|
|
|
|
|
2003-05-22 08:49:57 +00:00
|
|
|
SwRect aFly = mbIgnoreContour ?
|
2006-09-15 10:43:10 +00:00
|
|
|
pAnchoredObj->GetObjRectWithSpaces() :
|
|
|
|
SwContourCache::CalcBoundRect( pAnchoredObj, rLine, pCurrFrm,
|
2002-06-05 13:12:56 +00:00
|
|
|
nXPos, ! pCurrFrm->IsRightToLeft() );
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !aFly.Width() )
|
|
|
|
return aFly;
|
|
|
|
|
2001-12-06 14:49:17 +00:00
|
|
|
SetNextTop( (aFly.*fnRect->fnGetBottom)() ); // Damit die Zeile ggf. bis zur Unterkante
|
|
|
|
// des Rahmens waechst.
|
2006-09-15 10:43:10 +00:00
|
|
|
SwAnchoredObjList::size_type nFlyPos = GetPos( pAnchoredObj );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-08 17:06:29 +01:00
|
|
|
// LEFT and RIGHT, we grow the rectangle.
|
|
|
|
// We have some problems, when several frames are to be seen.
|
|
|
|
// At the moment, only the easier case is assumed:
|
|
|
|
// + LEFT means that the text muss flaw on the left of the frame,
|
|
|
|
// that is that the trame expands to the right edge of the
|
|
|
|
// print area or to the the next frame.
|
|
|
|
// + RIGHT is the opposite.
|
|
|
|
// Otherwise the set distance between text and frame is always
|
|
|
|
// added up.
|
2006-09-15 10:43:10 +00:00
|
|
|
switch( _GetSurroundForTextWrap( pAnchoredObj ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
case SURROUND_LEFT :
|
|
|
|
{
|
|
|
|
CalcRightMargin( aFly, nFlyPos, rLine );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SURROUND_RIGHT :
|
|
|
|
{
|
|
|
|
CalcLeftMargin( aFly, nFlyPos, rLine );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SURROUND_NONE :
|
|
|
|
{
|
|
|
|
CalcRightMargin( aFly, nFlyPos, rLine );
|
|
|
|
CalcLeftMargin( aFly, nFlyPos, rLine );
|
|
|
|
break;
|
|
|
|
}
|
2007-09-27 08:20:23 +00:00
|
|
|
default:
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return aFly;
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i68520#
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-14 16:38:43 +01:00
|
|
|
// Wrap only on sides with at least 2cm space for the text
|
2000-09-18 23:08:29 +00:00
|
|
|
#define TEXT_MIN 1134
|
2012-03-14 16:38:43 +01:00
|
|
|
|
|
|
|
// Wrap on both sides up to a frame width of 1.5cm
|
2000-09-18 23:08:29 +00:00
|
|
|
#define FRAME_MAX 850
|
|
|
|
|
2006-09-15 10:43:10 +00:00
|
|
|
SwSurround SwTxtFly::_GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2006-09-15 10:43:10 +00:00
|
|
|
const SwFrmFmt* pFmt = &(pAnchoredObj->GetFrmFmt());
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwFmtSurround &rFlyFmt = pFmt->GetSurround();
|
2006-09-15 10:43:10 +00:00
|
|
|
SwSurround eSurroundForTextWrap = rFlyFmt.GetSurround();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-09-15 10:43:10 +00:00
|
|
|
if( rFlyFmt.IsAnchorOnly() && pAnchoredObj->GetAnchorFrm() != GetMaster() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
|
2010-01-05 16:37:41 +01:00
|
|
|
if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
|
|
|
|
(FLY_AT_CHAR == rAnchor.GetAnchorId()))
|
|
|
|
{
|
2000-09-18 23:08:29 +00:00
|
|
|
return SURROUND_NONE;
|
2010-01-05 16:37:41 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Beim Durchlauf und Nowrap wird smart ignoriert.
|
2006-09-15 10:43:10 +00:00
|
|
|
if( SURROUND_THROUGHT == eSurroundForTextWrap ||
|
|
|
|
SURROUND_NONE == eSurroundForTextWrap )
|
|
|
|
return eSurroundForTextWrap;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2002-06-17 10:51:47 +00:00
|
|
|
// left is left and right is right
|
|
|
|
if ( pCurrFrm->IsRightToLeft() )
|
|
|
|
{
|
2006-09-15 10:43:10 +00:00
|
|
|
if ( SURROUND_LEFT == eSurroundForTextWrap )
|
|
|
|
eSurroundForTextWrap = SURROUND_RIGHT;
|
|
|
|
else if ( SURROUND_RIGHT == eSurroundForTextWrap )
|
|
|
|
eSurroundForTextWrap = SURROUND_LEFT;
|
2002-06-17 10:51:47 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
// "idealer Seitenumlauf":
|
2006-09-15 10:43:10 +00:00
|
|
|
if ( SURROUND_IDEAL == eSurroundForTextWrap )
|
|
|
|
{
|
|
|
|
SWRECTFN( pCurrFrm )
|
|
|
|
const long nCurrLeft = (pCurrFrm->*fnRect->fnGetPrtLeft)();
|
|
|
|
const long nCurrRight = (pCurrFrm->*fnRect->fnGetPrtRight)();
|
|
|
|
const SwRect aRect( pAnchoredObj->GetObjRectWithSpaces() );
|
|
|
|
long nFlyLeft = (aRect.*fnRect->fnGetLeft)();
|
|
|
|
long nFlyRight = (aRect.*fnRect->fnGetRight)();
|
|
|
|
|
|
|
|
if ( nFlyRight < nCurrLeft || nFlyLeft > nCurrRight )
|
|
|
|
eSurroundForTextWrap = SURROUND_PARALLEL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
long nLeft = nFlyLeft - nCurrLeft;
|
|
|
|
long nRight = nCurrRight - nFlyRight;
|
|
|
|
if( nFlyRight - nFlyLeft > FRAME_MAX )
|
|
|
|
{
|
|
|
|
if( nLeft < nRight )
|
|
|
|
nLeft = 0;
|
|
|
|
else
|
|
|
|
nRight = 0;
|
|
|
|
}
|
|
|
|
if( nLeft < TEXT_MIN )
|
|
|
|
nLeft = 0;
|
|
|
|
if( nRight < TEXT_MIN )
|
|
|
|
nRight = 0;
|
|
|
|
if( nLeft )
|
|
|
|
eSurroundForTextWrap = nRight ? SURROUND_PARALLEL : SURROUND_LEFT;
|
|
|
|
else
|
|
|
|
eSurroundForTextWrap = nRight ? SURROUND_RIGHT: SURROUND_NONE;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2006-09-15 10:43:10 +00:00
|
|
|
return eSurroundForTextWrap;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SwTxtFly::IsAnyFrm( const SwRect &rLine ) const
|
|
|
|
{
|
2001-12-06 14:49:17 +00:00
|
|
|
|
|
|
|
SWAP_IF_SWAPPED( pCurrFrm )
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( bOn, "IsAnyFrm: Why?" );
|
2001-12-06 14:49:17 +00:00
|
|
|
|
|
|
|
const sal_Bool bRet = ForEach( rLine, NULL, sal_False );
|
|
|
|
UNDO_SWAP( pCurrFrm )
|
|
|
|
return bRet;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|