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:16:21 +00:00
2004-06-28 12:37:37 +00:00
# include <anchoredobject.hxx>
# include <pam.hxx>
# include <frame.hxx>
# include <txtfrm.hxx>
# include <frmfmt.hxx>
# include <fmtanchr.hxx>
# include <fmtornt.hxx>
2011-02-05 18:00:33 +01:00
// --> #i28701#
2004-08-03 05:05:14 +00:00
# include <doc.hxx>
# include <fmtsrnd.hxx>
# include <svx/svdobj.hxx>
# include <dcontact.hxx>
2010-01-08 18:32:51 +01:00
# include <editeng/ulspitem.hxx>
# include <editeng/lrspitem.hxx>
2004-08-03 05:05:14 +00:00
# include <sortedobjs.hxx>
# include <pagefrm.hxx>
# include <frmatr.hxx>
2011-02-05 18:00:33 +01:00
// --> #i3317#
2004-09-09 09:56:32 +00:00
# include <colfrm.hxx>
2011-02-05 18:00:33 +01:00
// --> #i35911#
2004-11-16 14:44:00 +00:00
# include <layouter.hxx>
2007-09-27 08:00:49 +00:00
using namespace : : com : : sun : : star ;
2004-08-03 05:05:14 +00:00
// ============================================================================
2011-02-05 18:00:33 +01:00
// --> #i28701# -
2004-08-03 05:05:14 +00:00
// implementation of helper class <SwObjPositioningInProgress>
// ============================================================================
SwObjPositioningInProgress : : SwObjPositioningInProgress ( SdrObject & _rSdrObj ) :
2005-09-28 10:10:14 +00:00
mpAnchoredObj ( 0L ) ,
2011-02-05 18:00:33 +01:00
// --> #i52904#
2005-09-28 10:10:14 +00:00
mbOldObjPositioningInProgress ( false )
2004-08-03 05:05:14 +00:00
{
mpAnchoredObj = : : GetUserCall ( & _rSdrObj ) - > GetAnchoredObj ( & _rSdrObj ) ;
2011-02-05 18:00:33 +01:00
// --> #i52904#
2005-09-28 10:10:14 +00:00
mbOldObjPositioningInProgress = mpAnchoredObj - > IsPositioningInProgress ( ) ;
2004-08-03 05:05:14 +00:00
mpAnchoredObj - > SetPositioningInProgress ( true ) ;
}
SwObjPositioningInProgress : : SwObjPositioningInProgress ( SwAnchoredObject & _rAnchoredObj ) :
2005-09-28 10:10:14 +00:00
mpAnchoredObj ( & _rAnchoredObj ) ,
2011-02-05 18:00:33 +01:00
// --> #i52904#
2005-09-28 10:10:14 +00:00
mbOldObjPositioningInProgress ( false )
2004-08-03 05:05:14 +00:00
{
2011-02-05 18:00:33 +01:00
// --> #i52904#
2005-09-28 10:10:14 +00:00
mbOldObjPositioningInProgress = mpAnchoredObj - > IsPositioningInProgress ( ) ;
2004-08-03 05:05:14 +00:00
mpAnchoredObj - > SetPositioningInProgress ( true ) ;
}
SwObjPositioningInProgress : : ~ SwObjPositioningInProgress ( )
{
if ( mpAnchoredObj )
{
2011-02-05 18:00:33 +01:00
// --> #i52904#
2005-09-28 10:10:14 +00:00
mpAnchoredObj - > SetPositioningInProgress ( mbOldObjPositioningInProgress ) ;
2004-08-03 05:05:14 +00:00
}
}
// ============================================================================
2004-06-28 12:37:37 +00:00
TYPEINIT0 ( SwAnchoredObject ) ;
SwAnchoredObject : : SwAnchoredObject ( ) :
mpDrawObj ( 0L ) ,
mpAnchorFrm ( 0L ) ,
2011-02-05 18:00:33 +01:00
// --> #i28701#
2004-08-03 05:05:14 +00:00
mpPageFrm ( 0L ) ,
2004-08-23 07:02:09 +00:00
maRelPos ( ) ,
2004-06-28 12:37:37 +00:00
maLastCharRect ( ) ,
mnLastTopOfLine ( 0L ) ,
2004-08-03 05:05:14 +00:00
mpVertPosOrientFrm ( 0L ) ,
2011-02-05 18:00:33 +01:00
// --> #i28701#
2004-08-03 05:05:14 +00:00
mbPositioningInProgress ( false ) ,
mbConsiderForTextWrap ( false ) ,
mbPositionLocked ( false ) ,
2011-02-05 18:00:33 +01:00
// --> #i40147#
2005-01-21 09:33:21 +00:00
mbKeepPositionLockedForSection ( false ) ,
2004-09-09 09:56:32 +00:00
mbRestartLayoutProcess ( false ) ,
2011-02-05 18:00:33 +01:00
// --> #i35911#
2004-11-16 14:44:00 +00:00
mbClearedEnvironment ( false ) ,
2011-02-05 18:00:33 +01:00
// --> #i3317#
2006-09-15 10:41:59 +00:00
mbTmpConsiderWrapInfluence ( false ) ,
2011-02-05 18:00:33 +01:00
// --> #i68520#
2006-09-15 10:41:59 +00:00
maObjRectWithSpaces ( ) ,
mbObjRectWithSpacesValid ( false ) ,
maLastObjRect ( )
2004-06-28 12:37:37 +00:00
{
}
SwAnchoredObject : : ~ SwAnchoredObject ( )
{
}
// =============================================================================
// accessors for member <mpDrawObj>
// =============================================================================
void SwAnchoredObject : : SetDrawObj ( SdrObject & _rDrawObj )
{
mpDrawObj = & _rDrawObj ;
}
const SdrObject * SwAnchoredObject : : GetDrawObj ( ) const
{
return mpDrawObj ;
}
SdrObject * SwAnchoredObject : : DrawObj ( )
{
return mpDrawObj ;
}
// =============================================================================
// accessors for member <mpAnchorFrm>
// =============================================================================
const SwFrm * SwAnchoredObject : : GetAnchorFrm ( ) const
{
return mpAnchorFrm ;
}
SwFrm * SwAnchoredObject : : AnchorFrm ( )
{
return mpAnchorFrm ;
}
void SwAnchoredObject : : ChgAnchorFrm ( SwFrm * _pNewAnchorFrm )
{
mpAnchorFrm = _pNewAnchorFrm ;
2006-03-22 11:24:22 +00:00
if ( mpAnchorFrm )
{
ObjectAttachedToAnchorFrame ( ) ;
}
2004-06-28 12:37:37 +00:00
}
2004-11-16 14:44:00 +00:00
/** determine anchor frame containing the anchor position
2011-02-05 18:00:33 +01:00
# i26945#
2004-11-16 14:44:00 +00:00
the anchor frame , which is determined , is < mpAnchorFrm >
for an at - page , at - frame or at - paragraph anchored object
and the anchor character frame for an at - character and as - character
anchored object .
@ author OD
*/
SwFrm * SwAnchoredObject : : GetAnchorFrmContainingAnchPos ( )
{
SwFrm * pAnchorFrmContainingAnchPos = FindAnchorCharFrm ( ) ;
if ( ! pAnchorFrmContainingAnchPos )
{
pAnchorFrmContainingAnchPos = AnchorFrm ( ) ;
}
return pAnchorFrmContainingAnchPos ;
}
2004-08-03 05:05:14 +00:00
// =============================================================================
2011-02-05 18:00:33 +01:00
// #i28701# accessors for member <mpPageFrm>
2004-08-03 05:05:14 +00:00
// =============================================================================
SwPageFrm * SwAnchoredObject : : GetPageFrm ( )
{
return mpPageFrm ;
}
const SwPageFrm * SwAnchoredObject : : GetPageFrm ( ) const
{
return mpPageFrm ;
}
void SwAnchoredObject : : SetPageFrm ( SwPageFrm * _pNewPageFrm )
{
2006-01-27 13:35:17 +00:00
if ( mpPageFrm ! = _pNewPageFrm )
{
// clear member, which denotes the layout frame at which the vertical
// position is oriented at, if it doesn't fit to the new page frame.
if ( GetVertPosOrientFrm ( ) & &
( ! _pNewPageFrm | |
_pNewPageFrm ! = GetVertPosOrientFrm ( ) - > FindPageFrm ( ) ) )
{
ClearVertPosOrientFrm ( ) ;
}
// assign new page frame
mpPageFrm = _pNewPageFrm ;
}
2004-08-03 05:05:14 +00:00
}
2004-06-28 12:37:37 +00:00
// =============================================================================
// accessors for member <maLastCharRect>
// =============================================================================
const SwRect & SwAnchoredObject : : GetLastCharRect ( ) const
{
return maLastCharRect ;
}
SwTwips SwAnchoredObject : : GetRelCharX ( const SwFrm * pFrm ) const
{
return maLastCharRect . Left ( ) - pFrm - > Frm ( ) . Left ( ) ;
}
SwTwips SwAnchoredObject : : GetRelCharY ( const SwFrm * pFrm ) const
{
return maLastCharRect . Bottom ( ) - pFrm - > Frm ( ) . Top ( ) ;
}
void SwAnchoredObject : : AddLastCharY ( long nDiff )
{
maLastCharRect . Pos ( ) . Y ( ) + = nDiff ;
}
void SwAnchoredObject : : ResetLastCharRectHeight ( )
{
maLastCharRect . Height ( 0 ) ;
}
// =============================================================================
// accessors for member <mpVertPosOrientFrm>
// =============================================================================
void SwAnchoredObject : : SetVertPosOrientFrm ( const SwLayoutFrm & _rVertPosOrientFrm )
{
mpVertPosOrientFrm = & _rVertPosOrientFrm ;
2004-08-03 05:05:14 +00:00
2011-04-16 22:42:13 -03:00
// #i28701# - take over functionality of deleted method
2004-08-03 05:05:14 +00:00
// <SwFlyAtCntFrm::AssertPage()>: assure for at-paragraph and at-character
// an anchored object, that it is registered at the correct page frame
RegisterAtCorrectPage ( ) ;
2004-06-28 12:37:37 +00:00
}
// =============================================================================
// accessors for member <mnLastTopOfLine>
// =============================================================================
2008-10-10 13:02:43 +00:00
SwTwips SwAnchoredObject : : GetLastTopOfLine ( ) const
2004-06-28 12:37:37 +00:00
{
return mnLastTopOfLine ;
}
2011-02-05 18:00:33 +01:00
// #i28701# - follow-up of #i22341#
2004-08-03 05:05:14 +00:00
void SwAnchoredObject : : AddLastTopOfLineY ( SwTwips _nDiff )
{
mnLastTopOfLine + = _nDiff ;
}
2004-06-28 12:37:37 +00:00
/** check anchor character rectangle and top of line
2011-02-05 18:00:33 +01:00
# i26791
2004-06-28 12:37:37 +00:00
For to - character anchored Writer fly frames the members < maLastCharRect >
and < maLastTopOfLine > are updated . These are checked for change and
depending on the applied positioning , it ' s decided , if the Writer fly
frame has to be invalidated .
2011-02-05 18:00:33 +01:00
2004-08-02 12:06:55 +00:00
add parameter < _bCheckForParaPorInf > , default value < true >
2004-06-28 12:37:37 +00:00
@ author OD
*/
2004-08-02 12:06:55 +00:00
void SwAnchoredObject : : CheckCharRectAndTopOfLine (
const bool _bCheckForParaPorInf )
2004-06-28 12:37:37 +00:00
{
2004-08-02 12:06:55 +00:00
if ( GetAnchorFrm ( ) & &
GetAnchorFrm ( ) - > IsTxtFrm ( ) )
2004-06-28 12:37:37 +00:00
{
const SwFmtAnchor & rAnch = GetFrmFmt ( ) . GetAnchor ( ) ;
2010-01-05 16:37:41 +01:00
if ( ( rAnch . GetAnchorId ( ) = = FLY_AT_CHAR ) & &
2004-08-02 12:06:55 +00:00
rAnch . GetCntntAnchor ( ) )
2004-06-28 12:37:37 +00:00
{
2011-02-05 18:00:33 +01:00
// --> if requested, assure that anchor frame,
2004-08-02 12:06:55 +00:00
// which contains the anchor character, has a paragraph portion information.
// The paragraph portion information is needed to determine the
// anchor character rectangle respectively the top of the line.
// Thus, a format of this frame is avoided to determine the
// paragraph portion information.
2011-02-05 18:00:33 +01:00
// --> #i26945# - use new method <FindAnchorCharFrm()>
2004-11-16 14:44:00 +00:00
const SwTxtFrm & aAnchorCharFrm = * ( FindAnchorCharFrm ( ) ) ;
2004-08-02 12:06:55 +00:00
if ( ! _bCheckForParaPorInf | | aAnchorCharFrm . HasPara ( ) )
{
_CheckCharRect ( rAnch , aAnchorCharFrm ) ;
_CheckTopOfLine ( rAnch , aAnchorCharFrm ) ;
}
2004-06-28 12:37:37 +00:00
}
}
}
/** check anchor character rectangle
2011-02-05 18:00:33 +01:00
# i22341#
2004-06-28 12:37:37 +00:00
helper method for method < CheckCharRectAndTopOfLine ( ) >
For to - character anchored Writer fly frames the member < maLastCharRect >
is updated . This is checked for change and depending on the applied
positioning , it ' s decided , if the Writer fly frame has to be invalidated .
2011-02-05 18:00:33 +01:00
2004-08-02 12:06:55 +00:00
improvement - add second parameter < _rAnchorCharFrm >
2004-06-28 12:37:37 +00:00
@ author OD
*/
2004-08-02 12:06:55 +00:00
void SwAnchoredObject : : _CheckCharRect ( const SwFmtAnchor & _rAnch ,
const SwTxtFrm & _rAnchorCharFrm )
2004-06-28 12:37:37 +00:00
{
// determine rectangle of anchor character. If not exist, abort operation
SwRect aCharRect ;
2004-08-02 12:06:55 +00:00
if ( ! _rAnchorCharFrm . GetAutoPos ( aCharRect , * _rAnch . GetCntntAnchor ( ) ) )
2004-06-28 12:37:37 +00:00
{
return ;
}
// check, if anchor character rectangle has changed
if ( aCharRect ! = maLastCharRect )
{
// check positioning and alignment for invalidation of position
{
2004-08-02 12:06:55 +00:00
SWRECTFN ( ( & _rAnchorCharFrm ) ) ;
2004-06-28 12:37:37 +00:00
// determine positioning and alignment
SwFmtVertOrient aVert ( GetFrmFmt ( ) . GetVertOrient ( ) ) ;
SwFmtHoriOrient aHori ( GetFrmFmt ( ) . GetHoriOrient ( ) ) ;
// check for anchor character rectangle changes for certain
// positionings and alignments
2011-02-05 18:00:33 +01:00
// add condition to invalidate position,
2004-06-28 12:37:37 +00:00
// if vertical aligned at frame/page area and vertical position
// of anchor character has changed.
2007-09-27 08:00:49 +00:00
const sal_Int16 eVertRelOrient = aVert . GetRelationOrient ( ) ;
if ( ( aHori . GetRelationOrient ( ) = = text : : RelOrientation : : CHAR & &
2004-06-28 12:37:37 +00:00
( aCharRect . * fnRect - > fnGetLeft ) ( ) ! =
( maLastCharRect . * fnRect - > fnGetLeft ) ( ) ) | |
2007-09-27 08:00:49 +00:00
( eVertRelOrient = = text : : RelOrientation : : CHAR & &
2004-06-28 12:37:37 +00:00
( ( aCharRect . * fnRect - > fnGetTop ) ( ) ! =
( maLastCharRect . * fnRect - > fnGetTop ) ( ) | |
( aCharRect . * fnRect - > fnGetHeight ) ( ) ! =
( maLastCharRect . * fnRect - > fnGetHeight ) ( ) ) ) | |
2007-09-27 08:00:49 +00:00
( ( ( eVertRelOrient = = text : : RelOrientation : : FRAME ) | |
( eVertRelOrient = = text : : RelOrientation : : PRINT_AREA ) | |
( eVertRelOrient = = text : : RelOrientation : : PAGE_FRAME ) | |
( eVertRelOrient = = text : : RelOrientation : : PAGE_PRINT_AREA ) ) & &
2004-06-28 12:37:37 +00:00
( ( aCharRect . * fnRect - > fnGetTop ) ( ) ! =
( maLastCharRect . * fnRect - > fnGetTop ) ( ) ) ) )
{
2011-04-16 22:42:13 -03:00
// #i26945#, #i35911# - unlock position of
2004-11-16 14:44:00 +00:00
// anchored object, if it isn't registered at the page,
// where its anchor character frame is on.
if ( GetPageFrm ( ) ! = _rAnchorCharFrm . FindPageFrm ( ) )
{
UnlockPosition ( ) ;
}
2004-06-28 12:37:37 +00:00
InvalidateObjPos ( ) ;
}
}
// keep new anchor character rectangle
maLastCharRect = aCharRect ;
}
}
/** check top of line
2011-02-05 18:00:33 +01:00
# i22341#
2004-06-28 12:37:37 +00:00
helper method for method < CheckCharRectAndTopOfLine ( ) >
For to - character anchored Writer fly frames the member < mnLastTopOfLine >
is updated . This is checked for change and depending on the applied
positioning , it ' s decided , if the Writer fly frame has to be invalidated .
2011-02-05 18:00:33 +01:00
2004-08-02 12:06:55 +00:00
improvement - add second parameter < _rAnchorCharFrm >
2004-06-28 12:37:37 +00:00
@ author OD
*/
2004-08-02 12:06:55 +00:00
void SwAnchoredObject : : _CheckTopOfLine ( const SwFmtAnchor & _rAnch ,
const SwTxtFrm & _rAnchorCharFrm )
2004-06-28 12:37:37 +00:00
{
SwTwips nTopOfLine = 0L ;
2004-08-02 12:06:55 +00:00
if ( _rAnchorCharFrm . GetTopOfLine ( nTopOfLine , * _rAnch . GetCntntAnchor ( ) ) )
2004-06-28 12:37:37 +00:00
{
if ( nTopOfLine ! = mnLastTopOfLine )
{
// check alignment for invalidation of position
2007-09-27 08:00:49 +00:00
if ( GetFrmFmt ( ) . GetVertOrient ( ) . GetRelationOrient ( ) = = text : : RelOrientation : : TEXT_LINE )
2004-06-28 12:37:37 +00:00
{
2011-04-16 22:42:13 -03:00
// #i26945#, #i35911# - unlock position of
2004-11-16 14:44:00 +00:00
// anchored object, if it isn't registered at the page,
// where its anchor character frame is on.
if ( GetPageFrm ( ) ! = _rAnchorCharFrm . FindPageFrm ( ) )
{
UnlockPosition ( ) ;
}
2004-06-28 12:37:37 +00:00
InvalidateObjPos ( ) ;
}
// keep new top of line value
mnLastTopOfLine = nTopOfLine ;
}
}
}
2004-08-03 05:05:14 +00:00
void SwAnchoredObject : : ClearCharRectAndTopOfLine ( )
{
maLastCharRect . Clear ( ) ;
mnLastTopOfLine = 0 ;
}
2004-06-28 12:37:37 +00:00
const Point SwAnchoredObject : : GetCurrRelPos ( ) const
{
return maRelPos ;
}
void SwAnchoredObject : : SetCurrRelPos ( Point _aRelPos )
{
maRelPos = _aRelPos ;
}
void SwAnchoredObject : : ObjectAttachedToAnchorFrame ( )
{
2004-08-23 07:02:09 +00:00
// default behaviour:
// update layout direction, the anchored object is assigned to
UpdateLayoutDir ( ) ;
}
/** method update layout direction the layout direction, the anchored
object is in
2011-02-05 18:00:33 +01:00
# i31698#
2004-08-23 07:02:09 +00:00
method has typically to be called , if the anchored object gets its
anchor frame assigned .
@ author OD
*/
void SwAnchoredObject : : UpdateLayoutDir ( )
{
SwFrmFmt : : tLayoutDir nLayoutDir = SwFrmFmt : : HORI_L2R ;
const SwFrm * pAnchorFrm = GetAnchorFrm ( ) ;
if ( pAnchorFrm )
{
const bool bVert = pAnchorFrm - > IsVertical ( ) ;
const bool bR2L = pAnchorFrm - > IsRightToLeft ( ) ;
if ( bVert )
{
nLayoutDir = SwFrmFmt : : VERT_R2L ;
}
else if ( bR2L )
{
nLayoutDir = SwFrmFmt : : HORI_R2L ;
}
}
GetFrmFmt ( ) . SetLayoutDir ( nLayoutDir ) ;
2004-06-28 12:37:37 +00:00
}
2004-08-03 05:05:14 +00:00
/** method to perform necessary invalidations for the positioning of
objects , for whose the wrapping style influence has to be considered
on the object positioning .
2011-02-05 18:00:33 +01:00
# i28701#
2004-08-03 05:05:14 +00:00
@ author OD
*/
void SwAnchoredObject : : InvalidateObjPosForConsiderWrapInfluence (
const bool _bNotifyBackgrd )
{
if ( ConsiderObjWrapInfluenceOnObjPos ( ) )
{
// indicate that object has not to be considered for text wrap
SetConsiderForTextWrap ( false ) ;
// unlock position
UnlockPosition ( ) ;
// invalidate position
InvalidateObjPos ( ) ;
// invalidate 'background', if requested
if ( _bNotifyBackgrd )
{
NotifyBackground ( GetPageFrm ( ) , GetObjRectWithSpaces ( ) , PREP_FLY_LEAVE ) ;
}
}
}
/** method to determine, if wrapping style influence of the anchored
object has to be considered on the object positioning
2011-02-05 18:00:33 +01:00
# i28701#
2004-09-09 09:56:32 +00:00
Note : result of this method also decides , if the booleans for the
2004-08-03 05:05:14 +00:00
layout process are of relevance .
@ author OD
*/
bool SwAnchoredObject : : ConsiderObjWrapInfluenceOnObjPos ( ) const
{
bool bRet ( false ) ;
const SwFrmFmt & rObjFmt = GetFrmFmt ( ) ;
2006-08-14 15:24:35 +00:00
2011-02-05 18:00:33 +01:00
// --> #i3317# - add condition <IsTmpConsiderWrapInfluence()>
// --> #i55204#
2005-10-27 15:01:12 +00:00
// - correction: wrapping style influence has been considered, if condition
// <IsTmpConsiderWrapInfluence()> is hold, regardless of its anchor type
// or its wrapping style.
if ( IsTmpConsiderWrapInfluence ( ) )
{
bRet = true ;
}
2006-08-14 15:24:35 +00:00
else if ( rObjFmt . getIDocumentSettingAccess ( ) - > get ( IDocumentSettingAccess : : CONSIDER_WRAP_ON_OBJECT_POSITION ) )
2004-08-03 05:05:14 +00:00
{
const SwFmtAnchor & rAnchor = rObjFmt . GetAnchor ( ) ;
2010-01-05 16:37:41 +01:00
if ( ( ( rAnchor . GetAnchorId ( ) = = FLY_AT_CHAR ) | |
( rAnchor . GetAnchorId ( ) = = FLY_AT_PARA ) ) & &
2004-08-03 05:05:14 +00:00
rObjFmt . GetSurround ( ) . GetSurround ( ) ! = SURROUND_THROUGHT )
{
2011-02-05 18:00:33 +01:00
// --> #i34520# - text also wraps around anchored
2004-11-09 12:46:39 +00:00
// objects in the layer Hell - see the text formatting.
// Thus, it hasn't to be checked here.
bRet = true ;
2004-08-03 05:05:14 +00:00
}
}
return bRet ;
}
2005-03-23 10:52:41 +00:00
/** method to determine, if other anchored objects, also attached at
to the anchor frame , have to consider its wrap influence .
2011-02-05 18:00:33 +01:00
// --> #i43255#
2005-03-23 10:52:41 +00:00
@ author OD
*/
bool SwAnchoredObject : : ConsiderObjWrapInfluenceOfOtherObjs ( ) const
{
bool bRet ( false ) ;
const SwSortedObjs * pObjs = GetAnchorFrm ( ) - > GetDrawObjs ( ) ;
if ( pObjs - > Count ( ) > 1 )
{
sal_uInt32 i = 0 ;
for ( ; i < pObjs - > Count ( ) ; + + i )
{
SwAnchoredObject * pAnchoredObj = ( * pObjs ) [ i ] ;
if ( pAnchoredObj ! = this & &
pAnchoredObj - > ConsiderObjWrapInfluenceOnObjPos ( ) )
{
bRet = true ;
break ;
}
}
}
return bRet ;
}
2004-08-03 05:05:14 +00:00
// =============================================================================
2011-02-05 18:00:33 +01:00
// --> #i28701# - accessors to booleans for layout process
2004-08-03 05:05:14 +00:00
// =============================================================================
bool SwAnchoredObject : : ConsiderForTextWrap ( ) const
{
if ( ConsiderObjWrapInfluenceOnObjPos ( ) )
return mbConsiderForTextWrap ;
else
return true ;
}
void SwAnchoredObject : : SetConsiderForTextWrap ( const bool _bConsiderForTextWrap )
{
mbConsiderForTextWrap = _bConsiderForTextWrap ;
}
bool SwAnchoredObject : : PositionLocked ( ) const
{
if ( ConsiderObjWrapInfluenceOnObjPos ( ) )
return mbPositionLocked ;
else
return false ;
}
bool SwAnchoredObject : : RestartLayoutProcess ( ) const
{
if ( ConsiderObjWrapInfluenceOnObjPos ( ) )
return mbRestartLayoutProcess ;
else
return false ;
}
void SwAnchoredObject : : SetRestartLayoutProcess ( const bool _bRestartLayoutProcess )
{
mbRestartLayoutProcess = _bRestartLayoutProcess ;
}
2011-02-05 18:00:33 +01:00
// --> #i35911#
2004-11-16 14:44:00 +00:00
bool SwAnchoredObject : : ClearedEnvironment ( ) const
{
if ( ConsiderObjWrapInfluenceOnObjPos ( ) )
return mbClearedEnvironment ;
else
return false ;
}
void SwAnchoredObject : : SetClearedEnvironment ( const bool _bClearedEnvironment )
{
mbClearedEnvironment = _bClearedEnvironment ;
}
/** method to determine, if due to anchored object size and wrapping
style , its layout environment is cleared .
2011-02-05 18:00:33 +01:00
# i35911#
2004-11-16 14:44:00 +00:00
@ author OD
*/
bool SwAnchoredObject : : HasClearedEnvironment ( ) const
{
bool bHasClearedEnvironment ( false ) ;
2011-02-05 18:00:33 +01:00
// --> #i43913# - layout frame, vertical position is orient at, has to be set.
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( GetVertPosOrientFrm ( ) ,
2005-03-23 10:52:41 +00:00
" <SwAnchoredObject::HasClearedEnvironment()> - layout frame missing, at which the vertical position is oriented at. " ) ;
if ( GetVertPosOrientFrm ( ) & &
GetAnchorFrm ( ) - > IsTxtFrm ( ) & &
2004-11-16 14:44:00 +00:00
! static_cast < const SwTxtFrm * > ( GetAnchorFrm ( ) ) - > IsFollow ( ) & &
static_cast < const SwTxtFrm * > ( GetAnchorFrm ( ) ) - > FindPageFrm ( ) - > GetPhyPageNum ( ) > =
GetPageFrm ( ) - > GetPhyPageNum ( ) )
{
const SwFrm * pTmpFrm = GetVertPosOrientFrm ( ) - > Lower ( ) ;
while ( pTmpFrm & & pTmpFrm - > IsLayoutFrm ( ) & & ! pTmpFrm - > IsTabFrm ( ) )
{
pTmpFrm = static_cast < const SwLayoutFrm * > ( pTmpFrm ) - > Lower ( ) ;
}
if ( ! pTmpFrm )
{
bHasClearedEnvironment = true ;
}
else if ( pTmpFrm - > IsTxtFrm ( ) & & ! pTmpFrm - > GetNext ( ) )
{
const SwTxtFrm * pTmpTxtFrm = static_cast < const SwTxtFrm * > ( pTmpFrm ) ;
if ( pTmpTxtFrm - > IsUndersized ( ) | |
( pTmpTxtFrm - > GetFollow ( ) & &
pTmpTxtFrm - > GetFollow ( ) - > GetOfst ( ) = = 0 ) )
{
bHasClearedEnvironment = true ;
}
}
}
return bHasClearedEnvironment ;
}
2004-08-03 05:05:14 +00:00
/** method to add spacing to object area
2011-02-05 18:00:33 +01:00
# i28701#
# i68520# - return constant reference and use cache
2004-08-03 05:05:14 +00:00
@ author OD
*/
2006-09-15 10:41:59 +00:00
const SwRect & SwAnchoredObject : : GetObjRectWithSpaces ( ) const
{
if ( mbObjRectWithSpacesValid & &
maLastObjRect ! = GetObjRect ( ) )
{
2011-03-12 11:51:35 +01:00
OSL_FAIL ( " <SwAnchoredObject::GetObjRectWithSpaces> - cache for object rectangle inclusive spaces marked as valid, but it couldn't be. Missing invalidation of cache. Please inform OD. " ) ;
2006-09-15 10:41:59 +00:00
InvalidateObjRectWithSpaces ( ) ;
}
if ( ! mbObjRectWithSpacesValid )
{
2011-02-05 18:00:33 +01:00
// --> #i70122# - correction:
2006-11-01 14:12:28 +00:00
// use bounding rectangle of anchored objects.
// maObjRectWithSpaces = GetObjRect();
maObjRectWithSpaces = GetObjBoundRect ( ) ;
2006-09-15 10:41:59 +00:00
const SwFrmFmt & rFmt = GetFrmFmt ( ) ;
const SvxULSpaceItem & rUL = rFmt . GetULSpace ( ) ;
const SvxLRSpaceItem & rLR = rFmt . GetLRSpace ( ) ;
{
maObjRectWithSpaces . Top ( Max ( maObjRectWithSpaces . Top ( ) - long ( rUL . GetUpper ( ) ) , 0L ) ) ;
maObjRectWithSpaces . Left ( Max ( maObjRectWithSpaces . Left ( ) - long ( rLR . GetLeft ( ) ) , 0L ) ) ;
maObjRectWithSpaces . SSize ( ) . Height ( ) + = rUL . GetLower ( ) ;
maObjRectWithSpaces . SSize ( ) . Width ( ) + = rLR . GetRight ( ) ;
}
mbObjRectWithSpacesValid = true ;
maLastObjRect = GetObjRect ( ) ;
}
return maObjRectWithSpaces ;
}
2011-02-05 18:00:33 +01:00
// --> #i68520#
2006-09-15 10:41:59 +00:00
void SwAnchoredObject : : SetObjTop ( const SwTwips _nTop )
2004-08-03 05:05:14 +00:00
{
2006-09-15 10:41:59 +00:00
const bool bTopChanged ( _SetObjTop ( _nTop ) ) ;
if ( bTopChanged )
2004-08-03 05:05:14 +00:00
{
2006-09-15 10:41:59 +00:00
mbObjRectWithSpacesValid = false ;
2004-08-03 05:05:14 +00:00
}
}
2006-09-15 10:41:59 +00:00
void SwAnchoredObject : : SetObjLeft ( const SwTwips _nLeft )
{
const bool bLeftChanged ( _SetObjLeft ( _nLeft ) ) ;
if ( bLeftChanged )
{
mbObjRectWithSpacesValid = false ;
}
}
2004-08-03 05:05:14 +00:00
/** method to update anchored object in the <SwSortedObjs> lists
2011-02-05 18:00:33 +01:00
# i28701#
2004-08-03 05:05:14 +00:00
If document compatibility option ' Consider wrapping style influence
on object positioning ' is ON , additionally all anchored objects
at the anchor frame and all following anchored objects on the page
frame are invalidated .
@ author OD
*/
void SwAnchoredObject : : UpdateObjInSortedList ( )
{
if ( GetAnchorFrm ( ) )
{
2006-08-14 15:24:35 +00:00
if ( GetFrmFmt ( ) . getIDocumentSettingAccess ( ) - > get ( IDocumentSettingAccess : : CONSIDER_WRAP_ON_OBJECT_POSITION ) )
2004-08-03 05:05:14 +00:00
{
// invalidate position of all anchored objects at anchor frame
if ( GetAnchorFrm ( ) - > GetDrawObjs ( ) )
{
const SwSortedObjs * pObjs = GetAnchorFrm ( ) - > GetDrawObjs ( ) ;
// determine start index
sal_uInt32 i = 0 ;
for ( ; i < pObjs - > Count ( ) ; + + i )
{
SwAnchoredObject * pAnchoredObj = ( * pObjs ) [ i ] ;
if ( pAnchoredObj - > ConsiderObjWrapInfluenceOnObjPos ( ) )
pAnchoredObj - > InvalidateObjPosForConsiderWrapInfluence ( true ) ;
else
pAnchoredObj - > InvalidateObjPos ( ) ;
}
}
// invalidate all following anchored objects on the page frame
if ( GetPageFrm ( ) & & GetPageFrm ( ) - > GetSortedObjs ( ) )
{
const SwSortedObjs * pObjs = GetPageFrm ( ) - > GetSortedObjs ( ) ;
// determine start index
sal_uInt32 i = pObjs - > ListPosOf ( * this ) + 1 ;
for ( ; i < pObjs - > Count ( ) ; + + i )
{
SwAnchoredObject * pAnchoredObj = ( * pObjs ) [ i ] ;
if ( pAnchoredObj - > ConsiderObjWrapInfluenceOnObjPos ( ) )
pAnchoredObj - > InvalidateObjPosForConsiderWrapInfluence ( true ) ;
else
pAnchoredObj - > InvalidateObjPos ( ) ;
}
}
}
// update its position in the sorted object list of its anchor frame
AnchorFrm ( ) - > GetDrawObjs ( ) - > Update ( * this ) ;
// update its position in the sorted object list of its page frame
// note: as-character anchored object aren't registered at a page frame
2010-01-05 16:37:41 +01:00
if ( GetFrmFmt ( ) . GetAnchor ( ) . GetAnchorId ( ) ! = FLY_AS_CHAR )
2004-08-03 05:05:14 +00:00
{
GetPageFrm ( ) - > GetSortedObjs ( ) - > Update ( * this ) ;
}
}
}
/** method to determine, if invalidation of position is allowed
2011-02-05 18:00:33 +01:00
# i28701#
2004-08-03 05:05:14 +00:00
@ author OD
*/
bool SwAnchoredObject : : InvalidationOfPosAllowed ( ) const
{
2011-02-05 18:00:33 +01:00
// --> Check, if page frame layout is in progress,
2004-11-16 14:44:00 +00:00
// isn't needed, because of anchored object, whose are moved forward.
return ! PositionLocked ( ) ;
2004-08-03 05:05:14 +00:00
}
/** method to determine the page frame, on which the 'anchor' of
the given anchored object is .
2011-02-05 18:00:33 +01:00
# i28701#
# i33751#, #i34060#
2004-11-09 12:46:39 +00:00
Adjust meaning of method and thus its name : If the anchored object
or its anchor isn ' t correctly inserted in the layout , no page frame
can be found . Thus , the return type changed to be a pointer and can
be NULL .
2004-08-03 05:05:14 +00:00
@ author OD
*/
2004-11-09 12:46:39 +00:00
SwPageFrm * SwAnchoredObject : : FindPageFrmOfAnchor ( )
2004-08-03 05:05:14 +00:00
{
SwPageFrm * pRetPageFrm = 0L ;
2011-02-05 18:00:33 +01:00
// --> #i44339# - check, if anchor frame exists.
2005-03-23 11:58:31 +00:00
if ( mpAnchorFrm )
{
2011-02-05 18:00:33 +01:00
// --> #i26945# - use new method <GetAnchorFrmContainingAnchPos()>
2005-03-23 11:58:31 +00:00
pRetPageFrm = GetAnchorFrmContainingAnchPos ( ) - > FindPageFrm ( ) ;
}
2004-11-16 14:44:00 +00:00
return pRetPageFrm ;
}
/** get frame, which contains the anchor character, if the object
is anchored at - character or as - character .
2011-02-05 18:00:33 +01:00
# i26945#
2004-11-16 14:44:00 +00:00
@ author OD
@ return SwTxtFrm *
text frame containing the anchor character . It ' s NULL , if the object
isn ' t anchored at - character resp . as - character .
*/
SwTxtFrm * SwAnchoredObject : : FindAnchorCharFrm ( )
{
SwTxtFrm * pAnchorCharFrm ( 0L ) ;
2011-02-05 18:00:33 +01:00
// --> #i44339# - check, if anchor frame exists.
2005-03-23 11:58:31 +00:00
if ( mpAnchorFrm )
2004-08-03 05:05:14 +00:00
{
2005-03-23 11:58:31 +00:00
const SwFmtAnchor & rAnch = GetFrmFmt ( ) . GetAnchor ( ) ;
2010-01-05 16:37:41 +01:00
if ( ( rAnch . GetAnchorId ( ) = = FLY_AT_CHAR ) | |
( rAnch . GetAnchorId ( ) = = FLY_AS_CHAR ) )
2005-03-23 11:58:31 +00:00
{
pAnchorCharFrm = & ( static_cast < SwTxtFrm * > ( AnchorFrm ( ) ) - >
GetFrmAtOfst ( rAnch . GetCntntAnchor ( ) - > nContent . GetIndex ( ) ) ) ;
}
2004-08-03 05:05:14 +00:00
}
2004-11-16 14:44:00 +00:00
return pAnchorCharFrm ;
2004-08-03 05:05:14 +00:00
}
/** method to determine, if a format on the anchored object is possible
2011-02-05 18:00:33 +01:00
# i28701#
2004-08-03 05:05:14 +00:00
A format is possible , if anchored object is in an invisible layer .
Note : method is virtual to refine the conditions for the sub - classes .
@ author OD
*/
bool SwAnchoredObject : : IsFormatPossible ( ) const
{
return GetFrmFmt ( ) . GetDoc ( ) - > IsVisibleLayerId ( GetDrawObj ( ) - > GetLayer ( ) ) ;
}
2004-09-09 09:56:32 +00:00
2011-02-05 18:00:33 +01:00
// --> #i3317#
2004-09-09 09:56:32 +00:00
void SwAnchoredObject : : SetTmpConsiderWrapInfluence ( const bool _bTmpConsiderWrapInfluence )
{
mbTmpConsiderWrapInfluence = _bTmpConsiderWrapInfluence ;
2011-02-05 18:00:33 +01:00
// --> #i35911#
2004-11-16 14:44:00 +00:00
if ( mbTmpConsiderWrapInfluence )
{
SwLayouter : : InsertObjForTmpConsiderWrapInfluence ( * ( GetFrmFmt ( ) . GetDoc ( ) ) ,
* this ) ;
}
2004-09-09 09:56:32 +00:00
}
bool SwAnchoredObject : : IsTmpConsiderWrapInfluence ( ) const
{
return mbTmpConsiderWrapInfluence ;
}
2006-07-26 07:16:52 +00:00
void SwAnchoredObject : : SetTmpConsiderWrapInfluenceOfOtherObjs ( const bool bTmpConsiderWrapInfluence )
{
const SwSortedObjs * pObjs = GetAnchorFrm ( ) - > GetDrawObjs ( ) ;
if ( pObjs - > Count ( ) > 1 )
{
sal_uInt32 i = 0 ;
for ( ; i < pObjs - > Count ( ) ; + + i )
{
SwAnchoredObject * pAnchoredObj = ( * pObjs ) [ i ] ;
if ( pAnchoredObj ! = this )
{
pAnchoredObj - > SetTmpConsiderWrapInfluence ( bTmpConsiderWrapInfluence ) ;
}
}
}
}
2004-09-09 09:56:32 +00:00
/** method to determine, if the anchored object is overlapping with a
previous column
2011-02-05 18:00:33 +01:00
# i3317#
2004-09-09 09:56:32 +00:00
overlapping with a previous column means , that the object overlaps
with a column , which is a previous one of the column its anchor
frame is in .
Only applied for at - paragraph and at - character anchored objects .
@ author OD
*/
bool SwAnchoredObject : : OverlapsPrevColumn ( ) const
{
bool bOverlapsPrevColumn ( false ) ;
if ( mpAnchorFrm & & mpAnchorFrm - > IsTxtFrm ( ) )
{
const SwFrm * pColFrm = mpAnchorFrm - > FindColFrm ( ) ;
if ( pColFrm & & pColFrm - > GetPrev ( ) )
{
const SwFrm * pTmpColFrm = pColFrm - > GetPrev ( ) ;
SwRect aChkRect ;
while ( pTmpColFrm )
{
aChkRect . Union ( pTmpColFrm - > Frm ( ) ) ;
pTmpColFrm = pTmpColFrm - > GetPrev ( ) ;
}
bOverlapsPrevColumn = GetObjRect ( ) . IsOver ( aChkRect ) ;
}
}
return bOverlapsPrevColumn ;
}
2005-01-21 09:33:21 +00:00
/** method to determine position of anchored object relative to
anchor frame
2011-02-05 18:00:33 +01:00
# i30669#
2005-01-21 09:33:21 +00:00
Usage : Needed layout information for WW8 export
@ author OD
*/
Point SwAnchoredObject : : GetRelPosToAnchorFrm ( ) const
{
Point aRelPos ;
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( GetAnchorFrm ( ) ,
2005-01-21 09:33:21 +00:00
" <SwAnchoredObject::GetRelPosToAnchorFrm()> - missing anchor frame. " ) ;
aRelPos = GetObjRect ( ) . Pos ( ) ;
aRelPos - = GetAnchorFrm ( ) - > Frm ( ) . Pos ( ) ;
return aRelPos ;
}
/** method to determine position of anchored object relative to
page frame
2011-02-05 18:00:33 +01:00
# i30669#
2005-01-21 09:33:21 +00:00
Usage : Needed layout information for WW8 export
2011-02-05 18:00:33 +01:00
# i33818# - add parameters <_bFollowTextFlow> and
2005-02-22 07:19:21 +00:00
< _obRelToTableCell >
If < _bFollowTextFlow > is set and object is anchored inside table ,
the position relative to the table cell is determined . Output
parameter < _obRelToTableCell > reflects this situation
2005-01-21 09:33:21 +00:00
@ author OD
*/
2005-02-22 07:19:21 +00:00
Point SwAnchoredObject : : GetRelPosToPageFrm ( const bool _bFollowTextFlow ,
bool & _obRelToTableCell ) const
2005-01-21 09:33:21 +00:00
{
Point aRelPos ;
2005-02-22 07:19:21 +00:00
_obRelToTableCell = false ;
2005-01-21 09:33:21 +00:00
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( GetAnchorFrm ( ) ,
2005-01-21 09:33:21 +00:00
" <SwAnchoredObject::GetRelPosToPageFrm()> - missing anchor frame. " ) ;
2010-11-25 17:08:45 +01:00
OSL_ENSURE ( GetAnchorFrm ( ) - > FindPageFrm ( ) ,
2005-01-21 09:33:21 +00:00
" <SwAnchoredObject::GetRelPosToPageFrm()> - missing page frame. " ) ;
aRelPos = GetObjRect ( ) . Pos ( ) ;
2011-02-05 18:00:33 +01:00
// --> #i33818# - search for cell frame, if object has to
2005-02-22 07:19:21 +00:00
// follow the text flow.
const SwFrm * pFrm ( 0L ) ;
2005-03-30 09:53:19 +00:00
if ( _bFollowTextFlow & & ! GetAnchorFrm ( ) - > IsPageFrm ( ) )
2005-02-22 07:19:21 +00:00
{
pFrm = GetAnchorFrm ( ) - > GetUpper ( ) ;
while ( ! pFrm - > IsCellFrm ( ) & & ! pFrm - > IsPageFrm ( ) )
{
pFrm = pFrm - > GetUpper ( ) ;
}
}
else
{
pFrm = GetAnchorFrm ( ) - > FindPageFrm ( ) ;
}
if ( pFrm - > IsCellFrm ( ) )
{
aRelPos - = ( pFrm - > Frm ( ) . Pos ( ) + pFrm - > Prt ( ) . Pos ( ) ) ;
_obRelToTableCell = true ;
}
else
{
aRelPos - = pFrm - > Frm ( ) . Pos ( ) ;
}
2005-01-21 09:33:21 +00:00
return aRelPos ;
}
/** method to determine position of anchored object relative to
anchor character
2011-02-05 18:00:33 +01:00
# i30669#
2005-01-21 09:33:21 +00:00
Usage : Needed layout information for WW8 export
@ author OD
*/
Point SwAnchoredObject : : GetRelPosToChar ( ) const
{
Point aRelPos ;
aRelPos = GetObjRect ( ) . Pos ( ) ;
aRelPos - = GetLastCharRect ( ) . Pos ( ) ;
return aRelPos ;
}
/** method to determine position of anchored object relative to
top of line
2011-02-05 18:00:33 +01:00
# i30669#
2005-01-21 09:33:21 +00:00
Usage : Needed layout information for WW8 export
@ author OD
*/
Point SwAnchoredObject : : GetRelPosToLine ( ) const
{
Point aRelPos ;
aRelPos = GetObjRect ( ) . Pos ( ) ;
aRelPos . Y ( ) - = GetLastTopOfLine ( ) ;
return aRelPos ;
}
2010-10-14 08:30:41 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */