2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2006-09-16 20:21:09 +00:00
|
|
|
|
2004-08-02 13:11:16 +00:00
|
|
|
#include <objectformatter.hxx>
|
|
|
|
#include <objectformattertxtfrm.hxx>
|
|
|
|
#include <objectformatterlayfrm.hxx>
|
|
|
|
#include <anchoredobject.hxx>
|
|
|
|
#include <anchoreddrawobject.hxx>
|
|
|
|
#include <sortedobjs.hxx>
|
|
|
|
#include <pagefrm.hxx>
|
|
|
|
#include <flyfrms.hxx>
|
|
|
|
#include <txtfrm.hxx>
|
|
|
|
#include <layact.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
// =============================================================================
|
2004-11-16 14:48:18 +00:00
|
|
|
// helper class <SwPageNumAndTypeOfAnchors>
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945# - Additionally the type of the anchor text frame
|
2004-11-16 14:48:18 +00:00
|
|
|
// is collected - by type is meant 'master' or 'follow'.
|
2004-08-02 13:11:16 +00:00
|
|
|
// =============================================================================
|
2004-11-16 14:48:18 +00:00
|
|
|
class SwPageNumAndTypeOfAnchors
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
struct tEntry
|
|
|
|
{
|
|
|
|
SwAnchoredObject* mpAnchoredObj;
|
|
|
|
sal_uInt32 mnPageNumOfAnchor;
|
2004-11-16 14:48:18 +00:00
|
|
|
bool mbAnchoredAtMaster;
|
2004-08-02 13:11:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector< tEntry* > maObjList;
|
|
|
|
|
|
|
|
public:
|
2004-11-16 14:48:18 +00:00
|
|
|
inline SwPageNumAndTypeOfAnchors()
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
}
|
2004-11-16 14:48:18 +00:00
|
|
|
inline ~SwPageNumAndTypeOfAnchors()
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
for ( std::vector< tEntry* >::iterator aIter = maObjList.begin();
|
|
|
|
aIter != maObjList.end(); ++aIter )
|
|
|
|
{
|
|
|
|
delete (*aIter);
|
|
|
|
}
|
|
|
|
maObjList.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Collect( SwAnchoredObject& _rAnchoredObj )
|
|
|
|
{
|
|
|
|
tEntry* pNewEntry = new tEntry();
|
|
|
|
pNewEntry->mpAnchoredObj = &_rAnchoredObj;
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i33751#, #i34060# - method <GetPageFrmOfAnchor()>
|
2004-11-09 12:47:25 +00:00
|
|
|
// is replaced by method <FindPageFrmOfAnchor()>. It's return value
|
|
|
|
// have to be checked.
|
|
|
|
SwPageFrm* pPageFrmOfAnchor = _rAnchoredObj.FindPageFrmOfAnchor();
|
|
|
|
if ( pPageFrmOfAnchor )
|
|
|
|
{
|
|
|
|
pNewEntry->mnPageNumOfAnchor = pPageFrmOfAnchor->GetPhyPageNum();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pNewEntry->mnPageNumOfAnchor = 0;
|
|
|
|
}
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945# - collect type of anchor
|
2004-11-16 14:48:18 +00:00
|
|
|
SwTxtFrm* pAnchorCharFrm = _rAnchoredObj.FindAnchorCharFrm();
|
|
|
|
if ( pAnchorCharFrm )
|
|
|
|
{
|
|
|
|
pNewEntry->mbAnchoredAtMaster = !pAnchorCharFrm->IsFollow();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pNewEntry->mbAnchoredAtMaster = true;
|
|
|
|
}
|
2004-08-02 13:11:16 +00:00
|
|
|
maObjList.push_back( pNewEntry );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline SwAnchoredObject* operator[]( sal_uInt32 _nIndex )
|
|
|
|
{
|
|
|
|
SwAnchoredObject* bRetObj = 0L;
|
|
|
|
|
|
|
|
if ( _nIndex < Count())
|
|
|
|
{
|
|
|
|
bRetObj = maObjList[_nIndex]->mpAnchoredObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRetObj;
|
|
|
|
}
|
|
|
|
|
2010-11-26 21:21:15 +00:00
|
|
|
inline sal_uInt32 GetPageNum( sal_uInt32 _nIndex ) const
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
sal_uInt32 nRetPgNum = 0L;
|
|
|
|
|
|
|
|
if ( _nIndex < Count())
|
|
|
|
{
|
|
|
|
nRetPgNum = maObjList[_nIndex]->mnPageNumOfAnchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nRetPgNum;
|
|
|
|
}
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945#
|
2004-11-16 14:48:18 +00:00
|
|
|
inline bool AnchoredAtMaster( sal_uInt32 _nIndex )
|
|
|
|
{
|
|
|
|
bool bAnchoredAtMaster( true );
|
|
|
|
|
|
|
|
if ( _nIndex < Count())
|
|
|
|
{
|
|
|
|
bAnchoredAtMaster = maObjList[_nIndex]->mbAnchoredAtMaster;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bAnchoredAtMaster;
|
|
|
|
}
|
|
|
|
|
2004-08-02 13:11:16 +00:00
|
|
|
inline sal_uInt32 Count() const
|
|
|
|
{
|
|
|
|
return maObjList.size();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// =============================================================================
|
|
|
|
// implementation of class <SwObjectFormatter>
|
|
|
|
// =============================================================================
|
|
|
|
SwObjectFormatter::SwObjectFormatter( const SwPageFrm& _rPageFrm,
|
|
|
|
SwLayAction* _pLayAction,
|
|
|
|
const bool _bCollectPgNumOfAnchors )
|
|
|
|
: mrPageFrm( _rPageFrm ),
|
|
|
|
mbFormatOnlyAsCharAnchored( false ),
|
2006-08-14 15:28:15 +00:00
|
|
|
mbConsiderWrapOnObjPos( _rPageFrm.GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) ),
|
2004-08-02 13:11:16 +00:00
|
|
|
mpLayAction( _pLayAction ),
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945#
|
2004-11-16 14:48:18 +00:00
|
|
|
mpPgNumAndTypeOfAnchors( _bCollectPgNumOfAnchors ? new SwPageNumAndTypeOfAnchors() : 0L )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwObjectFormatter::~SwObjectFormatter()
|
|
|
|
{
|
2004-11-16 14:48:18 +00:00
|
|
|
delete mpPgNumAndTypeOfAnchors;
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwObjectFormatter* SwObjectFormatter::CreateObjFormatter(
|
|
|
|
SwFrm& _rAnchorFrm,
|
|
|
|
const SwPageFrm& _rPageFrm,
|
|
|
|
SwLayAction* _pLayAction )
|
|
|
|
{
|
|
|
|
SwObjectFormatter* pObjFormatter = 0L;
|
|
|
|
if ( _rAnchorFrm.IsTxtFrm() )
|
|
|
|
{
|
|
|
|
pObjFormatter = SwObjectFormatterTxtFrm::CreateObjFormatter(
|
|
|
|
static_cast<SwTxtFrm&>(_rAnchorFrm),
|
|
|
|
_rPageFrm, _pLayAction );
|
|
|
|
}
|
|
|
|
else if ( _rAnchorFrm.IsLayoutFrm() )
|
|
|
|
{
|
|
|
|
pObjFormatter = SwObjectFormatterLayFrm::CreateObjFormatter(
|
|
|
|
static_cast<SwLayoutFrm&>(_rAnchorFrm),
|
|
|
|
_rPageFrm, _pLayAction );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "<SwObjectFormatter::CreateObjFormatter(..)> - unexcepted type of anchor frame" );
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pObjFormatter;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** method to format all floating screen objects at the given anchor frame
|
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
bool SwObjectFormatter::FormatObjsAtFrm( SwFrm& _rAnchorFrm,
|
|
|
|
const SwPageFrm& _rPageFrm,
|
|
|
|
SwLayAction* _pLayAction )
|
|
|
|
{
|
|
|
|
bool bSuccess( true );
|
|
|
|
|
|
|
|
// create corresponding object formatter
|
|
|
|
SwObjectFormatter* pObjFormatter =
|
|
|
|
SwObjectFormatter::CreateObjFormatter( _rAnchorFrm, _rPageFrm, _pLayAction );
|
|
|
|
|
|
|
|
if ( pObjFormatter )
|
|
|
|
{
|
|
|
|
// format anchored floating screen objects
|
|
|
|
bSuccess = pObjFormatter->DoFormatObjs();
|
|
|
|
}
|
|
|
|
delete pObjFormatter;
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** method to format a given floating screen object
|
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
bool SwObjectFormatter::FormatObj( SwAnchoredObject& _rAnchoredObj,
|
|
|
|
SwFrm* _pAnchorFrm,
|
|
|
|
const SwPageFrm* _pPageFrm,
|
|
|
|
SwLayAction* _pLayAction )
|
|
|
|
{
|
|
|
|
bool bSuccess( true );
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( _pAnchorFrm || _rAnchoredObj.GetAnchorFrm(),
|
2004-08-02 13:11:16 +00:00
|
|
|
"<SwObjectFormatter::FormatObj(..)> - missing anchor frame" );
|
|
|
|
SwFrm& rAnchorFrm = _pAnchorFrm ? *(_pAnchorFrm) : *(_rAnchoredObj.AnchorFrm());
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( _pPageFrm || rAnchorFrm.FindPageFrm(),
|
2004-08-02 13:11:16 +00:00
|
|
|
"<SwObjectFormatter::FormatObj(..)> - missing page frame" );
|
|
|
|
const SwPageFrm& rPageFrm = _pPageFrm ? *(_pPageFrm) : *(rAnchorFrm.FindPageFrm());
|
|
|
|
|
|
|
|
// create corresponding object formatter
|
|
|
|
SwObjectFormatter* pObjFormatter =
|
|
|
|
SwObjectFormatter::CreateObjFormatter( rAnchorFrm, rPageFrm, _pLayAction );
|
|
|
|
|
|
|
|
if ( pObjFormatter )
|
|
|
|
{
|
|
|
|
// format given floating screen object
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i40147# - check for moved forward anchor frame
|
2005-01-21 09:36:52 +00:00
|
|
|
bSuccess = pObjFormatter->DoFormatObj( _rAnchoredObj, true );
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
delete pObjFormatter;
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** helper method for method <_FormatObj(..)> - performs the intrinsic format
|
|
|
|
of the layout of the given layout frame and all its lower layout frames.
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
2004-08-02 13:11:16 +00:00
|
|
|
IMPORTANT NOTE:
|
|
|
|
Method corresponds to methods <SwLayAction::FormatLayoutFly(..)> and
|
|
|
|
<SwLayAction::FormatLayout(..)>. Thus, its code for the formatting have
|
|
|
|
to be synchronised.
|
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
void SwObjectFormatter::_FormatLayout( SwLayoutFrm& _rLayoutFrm )
|
|
|
|
{
|
|
|
|
_rLayoutFrm.Calc();
|
|
|
|
|
|
|
|
SwFrm* pLowerFrm = _rLayoutFrm.Lower();
|
|
|
|
while ( pLowerFrm )
|
|
|
|
{
|
|
|
|
if ( pLowerFrm->IsLayoutFrm() )
|
|
|
|
{
|
|
|
|
_FormatLayout( *(static_cast<SwLayoutFrm*>(pLowerFrm)) );
|
|
|
|
}
|
|
|
|
pLowerFrm = pLowerFrm->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** helper method for method <_FormatObj(..)> - performs the intrinsic
|
|
|
|
format of the content of the given floating screen object.
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
void SwObjectFormatter::_FormatObjCntnt( SwAnchoredObject& _rAnchoredObj )
|
|
|
|
{
|
|
|
|
if ( !_rAnchoredObj.ISA(SwFlyFrm) )
|
|
|
|
{
|
|
|
|
// only Writer fly frames have content
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFlyFrm& rFlyFrm = static_cast<SwFlyFrm&>(_rAnchoredObj);
|
|
|
|
SwCntntFrm* pCntnt = rFlyFrm.ContainsCntnt();
|
|
|
|
|
|
|
|
while ( pCntnt )
|
|
|
|
{
|
|
|
|
// format content
|
|
|
|
pCntnt->OptCalc();
|
|
|
|
|
|
|
|
// format floating screen objects at content text frame
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i23129#, #i36347# - pass correct page frame to
|
2004-11-16 14:48:18 +00:00
|
|
|
// the object formatter
|
2004-08-02 13:11:16 +00:00
|
|
|
if ( pCntnt->IsTxtFrm() &&
|
2004-11-16 14:48:18 +00:00
|
|
|
!SwObjectFormatter::FormatObjsAtFrm( *pCntnt,
|
|
|
|
*(pCntnt->FindPageFrm()),
|
|
|
|
GetLayAction() ) )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
// restart format with first content
|
|
|
|
pCntnt = rFlyFrm.ContainsCntnt();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// continue with next content
|
|
|
|
pCntnt = pCntnt->GetNextCntntFrm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** performs the intrinsic format of a given floating screen object and its content.
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
void SwObjectFormatter::_FormatObj( SwAnchoredObject& _rAnchoredObj )
|
|
|
|
{
|
|
|
|
// check, if only as-character anchored object have to be formatted, and
|
|
|
|
// check the anchor type
|
|
|
|
if ( FormatOnlyAsCharAnchored() &&
|
2010-01-05 16:37:41 +01:00
|
|
|
!(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// collect anchor object and its 'anchor' page number, if requested
|
2004-11-16 14:48:18 +00:00
|
|
|
if ( mpPgNumAndTypeOfAnchors )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
2004-11-16 14:48:18 +00:00
|
|
|
mpPgNumAndTypeOfAnchors->Collect( _rAnchoredObj );
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( _rAnchoredObj.ISA(SwFlyFrm) )
|
|
|
|
{
|
|
|
|
SwFlyFrm& rFlyFrm = static_cast<SwFlyFrm&>(_rAnchoredObj);
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i34753# - reset flag, which prevents a positioning
|
2004-12-23 09:08:35 +00:00
|
|
|
if ( rFlyFrm.IsFlyLayFrm() )
|
|
|
|
{
|
|
|
|
static_cast<SwFlyLayFrm&>(rFlyFrm).SetNoMakePos( false );
|
|
|
|
}
|
2007-09-20 10:49:50 +00:00
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
// #i81146# new loop control
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nLoopControlRuns = 0;
|
|
|
|
const sal_uInt16 nLoopControlMax = 15;
|
2007-09-20 10:49:50 +00:00
|
|
|
|
2004-08-02 13:11:16 +00:00
|
|
|
do {
|
|
|
|
if ( mpLayAction )
|
|
|
|
{
|
|
|
|
mpLayAction->FormatLayoutFly( &rFlyFrm );
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> consider, if the layout action
|
2005-09-28 10:13:33 +00:00
|
|
|
// has to be restarted due to a delete of a page frame.
|
|
|
|
if ( mpLayAction->IsAgain() )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_FormatLayout( rFlyFrm );
|
|
|
|
}
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i34753# - prevent further positioning, if
|
2004-12-23 09:08:35 +00:00
|
|
|
// to-page|to-fly anchored Writer fly frame is already clipped.
|
|
|
|
if ( rFlyFrm.IsFlyLayFrm() && rFlyFrm.IsClipped() )
|
|
|
|
{
|
|
|
|
static_cast<SwFlyLayFrm&>(rFlyFrm).SetNoMakePos( true );
|
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i23129#, #i36347# - pass correct page frame
|
2004-11-16 14:48:18 +00:00
|
|
|
// to the object formatter
|
|
|
|
SwObjectFormatter::FormatObjsAtFrm( rFlyFrm,
|
|
|
|
*(rFlyFrm.FindPageFrm()),
|
|
|
|
mpLayAction );
|
2004-08-02 13:11:16 +00:00
|
|
|
if ( mpLayAction )
|
|
|
|
{
|
|
|
|
mpLayAction->_FormatFlyCntnt( &rFlyFrm );
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> consider, if the layout action
|
2005-09-28 10:13:33 +00:00
|
|
|
// has to be restarted due to a delete of a page frame.
|
|
|
|
if ( mpLayAction->IsAgain() )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_FormatObjCntnt( rFlyFrm );
|
|
|
|
}
|
2007-09-20 10:49:50 +00:00
|
|
|
|
|
|
|
if ( ++nLoopControlRuns >= nLoopControlMax )
|
|
|
|
{
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "LoopControl in SwObjectFormatter::_FormatObj: Stage 3!!!" );
|
2007-09-20 10:49:50 +00:00
|
|
|
rFlyFrm.ValidateThisAndAllLowers( 2 );
|
|
|
|
nLoopControlRuns = 0;
|
|
|
|
}
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i57917#
|
2006-02-06 15:31:02 +00:00
|
|
|
// stop formatting of anchored object, if restart of layout process is requested.
|
2004-08-02 13:11:16 +00:00
|
|
|
} while ( !rFlyFrm.IsValid() &&
|
2006-02-06 15:31:02 +00:00
|
|
|
!_rAnchoredObj.RestartLayoutProcess() &&
|
2004-08-02 13:11:16 +00:00
|
|
|
rFlyFrm.GetAnchorFrm() == &GetAnchorFrm() );
|
|
|
|
}
|
|
|
|
else if ( _rAnchoredObj.ISA(SwAnchoredDrawObject) )
|
|
|
|
{
|
|
|
|
_rAnchoredObj.MakeObjPos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** invokes the intrinsic format method for all floating screen objects,
|
|
|
|
anchored at anchor frame on the given page frame
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
|
|
|
#i26945# - for format of floating screen objects for
|
2004-11-16 14:48:18 +00:00
|
|
|
follow text frames, the 'master' text frame is passed to the method.
|
|
|
|
Thus, the objects, whose anchor character is inside the follow text
|
|
|
|
frame can be formatted.
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
2004-11-16 14:48:18 +00:00
|
|
|
bool SwObjectFormatter::_FormatObjsAtFrm( SwTxtFrm* _pMasterTxtFrm )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945#
|
2004-11-16 14:48:18 +00:00
|
|
|
SwFrm* pAnchorFrm( 0L );
|
|
|
|
if ( GetAnchorFrm().IsTxtFrm() &&
|
|
|
|
static_cast<SwTxtFrm&>(GetAnchorFrm()).IsFollow() &&
|
|
|
|
_pMasterTxtFrm )
|
|
|
|
{
|
|
|
|
pAnchorFrm = _pMasterTxtFrm;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pAnchorFrm = &GetAnchorFrm();
|
|
|
|
}
|
|
|
|
if ( !pAnchorFrm->GetDrawObjs() )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
// nothing to do, if no floating screen object is registered at the anchor frame.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bSuccess( true );
|
|
|
|
|
|
|
|
sal_uInt32 i = 0;
|
2004-11-16 14:48:18 +00:00
|
|
|
for ( ; i < pAnchorFrm->GetDrawObjs()->Count(); ++i )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
2004-11-16 14:48:18 +00:00
|
|
|
SwAnchoredObject* pAnchoredObj = (*pAnchorFrm->GetDrawObjs())[i];
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
// check, if object's anchor is on the given page frame or
|
|
|
|
// object is registered at the given page frame.
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945# - check, if the anchor character of the
|
2004-11-16 14:48:18 +00:00
|
|
|
// anchored object is located in a follow text frame. If this anchor
|
|
|
|
// follow text frame differs from the given anchor frame, the given
|
|
|
|
// anchor frame is a 'master' text frame of the anchor follow text frame.
|
|
|
|
// If the anchor follow text frame is in the same body as its 'master'
|
|
|
|
// text frame, do not format the anchored object.
|
|
|
|
// E.g., this situation can occur during the table row splitting algorithm.
|
|
|
|
SwTxtFrm* pAnchorCharFrm = pAnchoredObj->FindAnchorCharFrm();
|
|
|
|
const bool bAnchoredAtFollowInSameBodyAsMaster =
|
|
|
|
pAnchorCharFrm && pAnchorCharFrm->IsFollow() &&
|
|
|
|
pAnchorCharFrm != pAnchoredObj->GetAnchorFrm() &&
|
|
|
|
pAnchorCharFrm->FindBodyFrm() ==
|
|
|
|
static_cast<SwTxtFrm*>(pAnchoredObj->AnchorFrm())->FindBodyFrm();
|
|
|
|
if ( bAnchoredAtFollowInSameBodyAsMaster )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i33751#, #i34060# - method <GetPageFrmOfAnchor()>
|
2004-11-09 12:47:25 +00:00
|
|
|
// is replaced by method <FindPageFrmOfAnchor()>. It's return value
|
|
|
|
// have to be checked.
|
|
|
|
SwPageFrm* pPageFrmOfAnchor = pAnchoredObj->FindPageFrmOfAnchor();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pPageFrmOfAnchor,
|
2004-11-16 14:48:18 +00:00
|
|
|
"<SwObjectFormatter::_FormatObjsAtFrm()> - missing page frame." );
|
2011-02-05 18:00:33 +01:00
|
|
|
// --> #i26945#
|
2004-11-16 14:48:18 +00:00
|
|
|
if ( pPageFrmOfAnchor && pPageFrmOfAnchor == &mrPageFrm )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
// if format of object fails, stop formatting and pass fail to
|
|
|
|
// calling method via the return value.
|
|
|
|
if ( !DoFormatObj( *pAnchoredObj ) )
|
|
|
|
{
|
|
|
|
bSuccess = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-11-16 14:48:18 +00:00
|
|
|
// considering changes at <pAnchorFrm->GetDrawObjs()> during
|
2004-08-02 13:11:16 +00:00
|
|
|
// format of the object.
|
2004-11-16 14:48:18 +00:00
|
|
|
if ( !pAnchorFrm->GetDrawObjs() ||
|
|
|
|
i > pAnchorFrm->GetDrawObjs()->Count() )
|
2004-08-02 13:11:16 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_uInt32 nActPosOfObj =
|
2004-11-16 14:48:18 +00:00
|
|
|
pAnchorFrm->GetDrawObjs()->ListPosOf( *pAnchoredObj );
|
|
|
|
if ( nActPosOfObj == pAnchorFrm->GetDrawObjs()->Count() ||
|
2004-08-02 13:11:16 +00:00
|
|
|
nActPosOfObj > i )
|
|
|
|
{
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
else if ( nActPosOfObj < i )
|
|
|
|
{
|
|
|
|
i = nActPosOfObj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-16 14:48:18 +00:00
|
|
|
} // end of loop on <pAnchorFrm->.GetDrawObjs()>
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** accessor to collected anchored object
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
SwAnchoredObject* SwObjectFormatter::GetCollectedObj( const sal_uInt32 _nIndex )
|
|
|
|
{
|
2004-11-16 14:48:18 +00:00
|
|
|
return mpPgNumAndTypeOfAnchors ? (*mpPgNumAndTypeOfAnchors)[_nIndex] : 0L;
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** accessor to 'anchor' page number of collected anchored object
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
sal_uInt32 SwObjectFormatter::GetPgNumOfCollected( const sal_uInt32 _nIndex )
|
|
|
|
{
|
2004-11-16 14:48:18 +00:00
|
|
|
return mpPgNumAndTypeOfAnchors ? mpPgNumAndTypeOfAnchors->GetPageNum(_nIndex) : 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** accessor to 'anchor' type of collected anchored object
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i26945#
|
2004-11-16 14:48:18 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
bool SwObjectFormatter::IsCollectedAnchoredAtMaster( const sal_uInt32 _nIndex )
|
|
|
|
{
|
|
|
|
return mpPgNumAndTypeOfAnchors
|
|
|
|
? mpPgNumAndTypeOfAnchors->AnchoredAtMaster(_nIndex)
|
|
|
|
: true;
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** accessor to total number of collected anchored objects
|
|
|
|
|
2011-02-05 18:00:33 +01:00
|
|
|
#i28701#
|
2004-08-02 13:11:16 +00:00
|
|
|
|
|
|
|
@author OD
|
|
|
|
*/
|
|
|
|
sal_uInt32 SwObjectFormatter::CountOfCollected()
|
|
|
|
{
|
2004-11-16 14:48:18 +00:00
|
|
|
return mpPgNumAndTypeOfAnchors ? mpPgNumAndTypeOfAnchors->Count() : 0L;
|
2004-08-02 13:11:16 +00:00
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|