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:23 +00:00
|
|
|
|
2004-08-02 13:11:27 +00:00
|
|
|
#include <objectformatterlayfrm.hxx>
|
|
|
|
#include <anchoredobject.hxx>
|
|
|
|
#include <sortedobjs.hxx>
|
|
|
|
#include <layfrm.hxx>
|
|
|
|
#include <pagefrm.hxx>
|
|
|
|
|
2011-04-18 12:37:38 -03:00
|
|
|
// #124218#
|
2005-09-28 10:13:52 +00:00
|
|
|
#include <layact.hxx>
|
|
|
|
|
2004-08-02 13:11:27 +00:00
|
|
|
// =============================================================================
|
|
|
|
// implementation of class <SwObjectFormatterLayFrm>
|
|
|
|
// =============================================================================
|
|
|
|
SwObjectFormatterLayFrm::SwObjectFormatterLayFrm( SwLayoutFrm& _rAnchorLayFrm,
|
|
|
|
const SwPageFrm& _rPageFrm,
|
|
|
|
SwLayAction* _pLayAction )
|
|
|
|
: SwObjectFormatter( _rPageFrm, _pLayAction ),
|
|
|
|
mrAnchorLayFrm( _rAnchorLayFrm )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwObjectFormatterLayFrm::~SwObjectFormatterLayFrm()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwObjectFormatterLayFrm* SwObjectFormatterLayFrm::CreateObjFormatter(
|
|
|
|
SwLayoutFrm& _rAnchorLayFrm,
|
|
|
|
const SwPageFrm& _rPageFrm,
|
|
|
|
SwLayAction* _pLayAction )
|
|
|
|
{
|
|
|
|
if ( !_rAnchorLayFrm.IsPageFrm() &&
|
|
|
|
!_rAnchorLayFrm.IsFlyFrm() )
|
|
|
|
{
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "<SwObjectFormatterLayFrm::CreateObjFormatter(..)> - unexcepted type of anchor frame " );
|
2004-08-02 13:11:27 +00:00
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwObjectFormatterLayFrm* pObjFormatter = 0L;
|
|
|
|
|
|
|
|
// create object formatter, if floating screen objects are registered at
|
|
|
|
// given anchor layout frame.
|
|
|
|
if ( _rAnchorLayFrm.GetDrawObjs() ||
|
|
|
|
( _rAnchorLayFrm.IsPageFrm() &&
|
|
|
|
static_cast<SwPageFrm&>(_rAnchorLayFrm).GetSortedObjs() ) )
|
|
|
|
{
|
|
|
|
pObjFormatter =
|
|
|
|
new SwObjectFormatterLayFrm( _rAnchorLayFrm, _rPageFrm, _pLayAction );
|
|
|
|
}
|
|
|
|
|
|
|
|
return pObjFormatter;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFrm& SwObjectFormatterLayFrm::GetAnchorFrm()
|
|
|
|
{
|
|
|
|
return mrAnchorLayFrm;
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i40147# - add parameter <_bCheckForMovedFwd>.
|
2005-01-21 09:37:43 +00:00
|
|
|
// Not relevant for objects anchored at layout frame.
|
|
|
|
bool SwObjectFormatterLayFrm::DoFormatObj( SwAnchoredObject& _rAnchoredObj,
|
2007-09-27 08:05:08 +00:00
|
|
|
const bool )
|
2004-08-02 13:11:27 +00:00
|
|
|
{
|
|
|
|
_FormatObj( _rAnchoredObj );
|
|
|
|
|
2011-04-18 12:37:38 -03:00
|
|
|
// #124218# - consider that the layout action has to be
|
2005-09-28 10:13:52 +00:00
|
|
|
// restarted due to a deleted page frame.
|
|
|
|
return GetLayAction() ? !GetLayAction()->IsAgain() : true;
|
2004-08-02 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SwObjectFormatterLayFrm::DoFormatObjs()
|
|
|
|
{
|
|
|
|
bool bSuccess( true );
|
|
|
|
|
|
|
|
bSuccess = _FormatObjsAtFrm();
|
|
|
|
|
2005-09-28 10:13:52 +00:00
|
|
|
if ( bSuccess && GetAnchorFrm().IsPageFrm() )
|
2004-08-02 13:11:27 +00:00
|
|
|
{
|
|
|
|
// anchor layout frame is a page frame.
|
|
|
|
// Thus, format also all anchored objects, which are registered at
|
|
|
|
// this page frame, whose 'anchor' isn't on this page frame and whose
|
|
|
|
// anchor frame is valid.
|
|
|
|
bSuccess = _AdditionalFormatObjsOnPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** method to format all anchored objects, which are registered at
|
|
|
|
the page frame, whose 'anchor' isn't on this page frame and whose
|
|
|
|
anchor frame is valid.
|
|
|
|
|
|
|
|
OD 2004-07-02 #i28701#
|
|
|
|
|
|
|
|
@author
|
|
|
|
*/
|
|
|
|
bool SwObjectFormatterLayFrm::_AdditionalFormatObjsOnPage()
|
|
|
|
{
|
|
|
|
if ( !GetAnchorFrm().IsPageFrm() )
|
|
|
|
{
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "<SwObjectFormatterLayFrm::_AdditionalFormatObjsOnPage()> - mis-usage of method, call only for anchor frames of type page frame" );
|
2004-08-02 13:11:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
2005-09-28 10:13:52 +00:00
|
|
|
|
2011-04-18 12:37:38 -03:00
|
|
|
// #124218# - consider, if the layout action
|
2005-09-28 10:13:52 +00:00
|
|
|
// has to be restarted due to a delete of a page frame.
|
|
|
|
if ( GetLayAction() && GetLayAction()->IsAgain() )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-02 13:11:27 +00:00
|
|
|
SwPageFrm& rPageFrm = static_cast<SwPageFrm&>(GetAnchorFrm());
|
|
|
|
|
|
|
|
if ( !rPageFrm.GetSortedObjs() )
|
|
|
|
{
|
|
|
|
// nothing to do, if no floating screen object is registered at the anchor frame.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bSuccess( true );
|
|
|
|
|
|
|
|
sal_uInt32 i = 0;
|
|
|
|
for ( ; i < rPageFrm.GetSortedObjs()->Count(); ++i )
|
|
|
|
{
|
|
|
|
SwAnchoredObject* pAnchoredObj = (*rPageFrm.GetSortedObjs())[i];
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i51941# - do not format object, which are anchored
|
2005-09-28 10:13:52 +00:00
|
|
|
// inside or at fly frame.
|
|
|
|
if ( pAnchoredObj->GetAnchorFrm()->FindFlyFrm() )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i33751#, #i34060# - method <GetPageFrmOfAnchor()>
|
2004-11-09 12:47:43 +00:00
|
|
|
// is replaced by method <FindPageFrmOfAnchor()>. It's return value
|
|
|
|
// have to be checked.
|
|
|
|
SwPageFrm* pPageFrmOfAnchor = pAnchoredObj->FindPageFrmOfAnchor();
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i26945# - check, if the page frame of the
|
2004-11-16 14:48:36 +00:00
|
|
|
// object's anchor frame isn't the given page frame
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pPageFrmOfAnchor,
|
|
|
|
"<SwObjectFormatterLayFrm::_AdditionalFormatObjsOnPage()> - missing page frame" );
|
2004-11-16 14:48:36 +00:00
|
|
|
if ( pPageFrmOfAnchor &&
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i35911#
|
2004-11-16 14:48:36 +00:00
|
|
|
pPageFrmOfAnchor->GetPhyPageNum() < rPageFrm.GetPhyPageNum() )
|
2004-08-02 13:11:27 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// considering changes at <GetAnchorFrm().GetDrawObjs()> during
|
|
|
|
// format of the object.
|
|
|
|
if ( !rPageFrm.GetSortedObjs() ||
|
|
|
|
i > rPageFrm.GetSortedObjs()->Count() )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_uInt32 nActPosOfObj =
|
|
|
|
rPageFrm.GetSortedObjs()->ListPosOf( *pAnchoredObj );
|
|
|
|
if ( nActPosOfObj == rPageFrm.GetSortedObjs()->Count() ||
|
|
|
|
nActPosOfObj > i )
|
|
|
|
{
|
|
|
|
--i;
|
|
|
|
}
|
|
|
|
else if ( nActPosOfObj < i )
|
|
|
|
{
|
|
|
|
i = nActPosOfObj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end of loop on <rPageFrm.GetSortedObjs()>
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|