summaryrefslogtreecommitdiff
path: root/sw/source/core/layout/anchoredobject.cxx
diff options
context:
space:
mode:
authorOliver Düsterhoff <od@openoffice.org>2004-08-03 05:05:14 +0000
committerOliver Düsterhoff <od@openoffice.org>2004-08-03 05:05:14 +0000
commita36111f17c4eb2e5b2222ef86b55cfad7732f3bd (patch)
treefd7e3406de6e968275de005853552556d8fd496d /sw/source/core/layout/anchoredobject.cxx
parentdcb411604705394d999aeb68204b757809b1dcca (diff)
#i28701# integration of cws swobjpos04 into master
Diffstat (limited to 'sw/source/core/layout/anchoredobject.cxx')
-rw-r--r--sw/source/core/layout/anchoredobject.cxx369
1 files changed, 364 insertions, 5 deletions
diff --git a/sw/source/core/layout/anchoredobject.cxx b/sw/source/core/layout/anchoredobject.cxx
index b4ff0eea75ce..f81b178d8ae4 100644
--- a/sw/source/core/layout/anchoredobject.cxx
+++ b/sw/source/core/layout/anchoredobject.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: anchoredobject.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: hr $ $Date: 2004-08-02 13:06:55 $
+ * last change: $Author: od $ $Date: 2004-08-03 06:05:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -80,15 +80,80 @@
#ifndef _FMTORNT_HXX
#include <fmtornt.hxx>
#endif
+// --> OD 2004-06-29 #i28701#
+#ifndef _DOC_HXX
+#include <doc.hxx>
+#endif
+#ifndef _FMTSRND_HXX
+#include <fmtsrnd.hxx>
+#endif
+#ifndef _SVDOBJ_HXX
+#include <svx/svdobj.hxx>
+#endif
+#ifndef _DCONTACT_HXX
+#include <dcontact.hxx>
+#endif
+#ifndef _SVX_ULSPITEM_HXX
+#include <svx/ulspitem.hxx>
+#endif
+#ifndef _SVX_LRSPITEM_HXX
+#include <svx/lrspitem.hxx>
+#endif
+#ifndef _SORTEDOBJS_HXX
+#include <sortedobjs.hxx>
+#endif
+#ifndef _PAGEFRM_HXX
+#include <pagefrm.hxx>
+#endif
+// <--
+#ifndef _FRMATR_HXX
+#include <frmatr.hxx>
+#endif
+
+// ============================================================================
+// --> OD 2004-06-30 #i28701# -
+// implementation of helper class <SwObjPositioningInProgress>
+// ============================================================================
+SwObjPositioningInProgress::SwObjPositioningInProgress( SdrObject& _rSdrObj ) :
+ mpAnchoredObj( 0L )
+{
+ mpAnchoredObj = ::GetUserCall( &_rSdrObj )->GetAnchoredObj( &_rSdrObj );
+ mpAnchoredObj->SetPositioningInProgress( true );
+}
+
+SwObjPositioningInProgress::SwObjPositioningInProgress( SwAnchoredObject& _rAnchoredObj ) :
+ mpAnchoredObj( &_rAnchoredObj )
+{
+ mpAnchoredObj->SetPositioningInProgress( true );
+}
+
+SwObjPositioningInProgress::~SwObjPositioningInProgress()
+{
+ if ( mpAnchoredObj )
+ {
+ mpAnchoredObj->SetPositioningInProgress( false );
+ }
+}
+
+// ============================================================================
TYPEINIT0(SwAnchoredObject);
SwAnchoredObject::SwAnchoredObject() :
mpDrawObj( 0L ),
mpAnchorFrm( 0L ),
+ // --> OD 2004-06-30 #i28701#
+ mpPageFrm( 0L ),
+ // <--
maLastCharRect(),
mnLastTopOfLine( 0L ),
- mpVertPosOrientFrm( 0L )
+ mpVertPosOrientFrm( 0L ),
+ // --> OD 2004-06-29 #i28701#
+ mbPositioningInProgress( false ),
+ mbConsiderForTextWrap( false ),
+ mbPositionLocked( false ),
+ mbRestartLayoutProcess( false )
+ // <--
{
}
@@ -135,6 +200,24 @@ void SwAnchoredObject::ChgAnchorFrm( SwFrm* _pNewAnchorFrm )
}
// =============================================================================
+// OD 2004-06-30 #i28701# accessors for member <mpPageFrm>
+// =============================================================================
+SwPageFrm* SwAnchoredObject::GetPageFrm()
+{
+ return mpPageFrm;
+}
+
+const SwPageFrm* SwAnchoredObject::GetPageFrm() const
+{
+ return mpPageFrm;
+}
+
+void SwAnchoredObject::SetPageFrm( SwPageFrm* _pNewPageFrm )
+{
+ mpPageFrm = _pNewPageFrm;
+}
+
+// =============================================================================
// accessors for member <maLastCharRect>
// =============================================================================
const SwRect& SwAnchoredObject::GetLastCharRect() const
@@ -177,6 +260,11 @@ const SwLayoutFrm* SwAnchoredObject::GetVertPosOrientFrm() const
void SwAnchoredObject::SetVertPosOrientFrm( const SwLayoutFrm& _rVertPosOrientFrm )
{
mpVertPosOrientFrm = &_rVertPosOrientFrm;
+
+ // --> OD 2004-07-02 #i28701# - take over functionality of deleted method
+ // <SwFlyAtCntFrm::AssertPage()>: assure for at-paragraph and at-character
+ // an anchored object, that it is registered at the correct page frame
+ RegisterAtCorrectPage();
}
// =============================================================================
@@ -187,6 +275,12 @@ const SwTwips SwAnchoredObject::GetLastTopOfLine() const
return mnLastTopOfLine;
}
+// OD 2004-05-18 #i28701# - follow-up of #i22341#
+void SwAnchoredObject::AddLastTopOfLineY( SwTwips _nDiff )
+{
+ mnLastTopOfLine += _nDiff;
+}
+
/** check anchor character rectangle and top of line
OD 2004-03-24 #i26791
@@ -318,14 +412,20 @@ void SwAnchoredObject::_CheckTopOfLine( const SwFmtAnchor& _rAnch,
}
}
+void SwAnchoredObject::ClearCharRectAndTopOfLine()
+{
+ maLastCharRect.Clear();
+ mnLastTopOfLine = 0;
+}
+
void SwAnchoredObject::SetPositioningInProgress( const bool _bPosInProgress )
{
- // empty method body
+ mbPositioningInProgress = _bPosInProgress;
}
bool SwAnchoredObject::IsPositioningInProgress() const
{
- return false;
+ return mbPositioningInProgress;
}
const Point SwAnchoredObject::GetCurrRelPos() const
@@ -341,3 +441,262 @@ void SwAnchoredObject::ObjectAttachedToAnchorFrame()
{
// default behaviour: nothing to do
}
+
+/** method to perform necessary invalidations for the positioning of
+ objects, for whose the wrapping style influence has to be considered
+ on the object positioning.
+
+ OD 2004-06-30 #i28701#
+
+ @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
+
+ OD 2004-06-30 #i28701#
+ Note: result of this method also decides, if the boolean for the
+ layout process are of relevance.
+
+ @author OD
+*/
+bool SwAnchoredObject::ConsiderObjWrapInfluenceOnObjPos() const
+{
+ bool bRet( false );
+
+ const SwFrmFmt& rObjFmt = GetFrmFmt();
+ if ( rObjFmt.GetDoc()->ConsiderWrapOnObjPos() )
+ {
+ const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor();
+ if ( ( rAnchor.GetAnchorId() == FLY_AUTO_CNTNT ||
+ rAnchor.GetAnchorId() == FLY_AT_CNTNT ) &&
+ rObjFmt.GetSurround().GetSurround() != SURROUND_THROUGHT )
+ {
+ SdrLayerID nHellId = rObjFmt.GetDoc()->GetHellId();
+ SdrLayerID nInvisibleHellId = rObjFmt.GetDoc()->GetInvisibleHellId();
+ if ( GetDrawObj()->GetLayer() != nHellId &&
+ GetDrawObj()->GetLayer() != nInvisibleHellId )
+ {
+ bRet = true;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// =============================================================================
+// --> OD 2004-06-29 #i28701# - accessors to booleans for layout process
+// =============================================================================
+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;
+}
+
+void SwAnchoredObject::LockPosition()
+{
+ mbPositionLocked = true;
+}
+
+void SwAnchoredObject::UnlockPosition()
+{
+ mbPositionLocked = false;
+}
+
+bool SwAnchoredObject::RestartLayoutProcess() const
+{
+ if ( ConsiderObjWrapInfluenceOnObjPos() )
+ return mbRestartLayoutProcess;
+ else
+ return false;
+}
+
+void SwAnchoredObject::SetRestartLayoutProcess( const bool _bRestartLayoutProcess )
+{
+ mbRestartLayoutProcess = _bRestartLayoutProcess;
+}
+
+/** method to add spacing to object area
+
+ OD 2004-06-30 #i28701#
+
+ @author OD
+*/
+const SwRect SwAnchoredObject::GetObjRectWithSpaces() const
+{
+ SwRect aRet( GetObjRect() );
+ const SwFrmFmt& rFmt = GetFrmFmt();
+ const SvxULSpaceItem& rUL = rFmt.GetULSpace();
+ const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
+ {
+ aRet.Top ( Max( aRet.Top() - long(rUL.GetUpper()), 0L ));
+ aRet.Left( Max( aRet.Left()- long(rLR.GetLeft()), 0L ));
+ aRet.SSize().Height() += rUL.GetLower();
+ aRet.SSize().Width() += rLR.GetRight();
+ }
+ return aRet;
+}
+
+/** method to update anchored object in the <SwSortedObjs> lists
+
+ OD 2004-07-01 #i28701#
+ 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() )
+ {
+ if ( GetFrmFmt().GetDoc()->ConsiderWrapOnObjPos() )
+ {
+ // 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
+ if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_IN_CNTNT )
+ {
+ GetPageFrm()->GetSortedObjs()->Update( *this );
+ }
+ }
+}
+
+/** method to determine, if invalidation of position is allowed
+
+ OD 2004-07-01 #i28701#
+
+ @author OD
+*/
+bool SwAnchoredObject::InvalidationOfPosAllowed() const
+{
+ bool bAllowed( true );
+
+ if ( ConsiderObjWrapInfluenceOnObjPos() )
+ {
+ const SwPageFrm* pPageFrm = GetPageFrm();
+ if ( pPageFrm && pPageFrm->IsLayoutInProgress() &&
+ PositionLocked() )
+ {
+ bAllowed = false;
+ }
+ }
+
+ return bAllowed;
+}
+
+/** method to determine the page frame, on which the 'anchor' of
+ the given anchored object is.
+
+ OD 2004-07-02 #i28701#
+
+ @author OD
+*/
+SwPageFrm& SwAnchoredObject::GetPageFrmOfAnchor()
+{
+ SwPageFrm* pRetPageFrm = 0L;
+
+ const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor();
+ if ( rAnch.GetAnchorId() == FLY_AUTO_CNTNT ||
+ rAnch.GetAnchorId() == FLY_IN_CNTNT )
+ {
+ SwTxtFrm& aAnchorCharFrm = static_cast<SwTxtFrm*>(AnchorFrm())->
+ GetFrmAtOfst( rAnch.GetCntntAnchor()->nContent.GetIndex() );
+ pRetPageFrm = aAnchorCharFrm.FindPageFrm();
+ }
+ else if ( rAnch.GetAnchorId() == FLY_AT_CNTNT ||
+ rAnch.GetAnchorId() == FLY_AT_FLY ||
+ rAnch.GetAnchorId() == FLY_PAGE )
+ {
+ pRetPageFrm = AnchorFrm()->FindPageFrm();
+ }
+ else
+ {
+ ASSERT( false,
+ "<SwAnchoredObject::_GetPageFrmOfAnchor(..)> - unexcepted anchor type" );
+ }
+
+ ASSERT( pRetPageFrm,
+ "<SwAnchoredObject::_GetPageFrmOfAnchor(..)> - missing page frame -> crash." );
+ return *pRetPageFrm;
+}
+
+/** method to determine, if a format on the anchored object is possible
+
+ OD 2004-07-23 #i28701#
+ 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() );
+}