You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2013/03/19 16:50:03 UTC

svn commit: r1458352 [2/2] - in /openoffice/branches/sidebar/main/sw: inc/cmdid.h sdi/_viewsh.sdi sdi/swriter.sdi source/core/doc/docdesc.cxx source/ui/sidebar/PagePropertyPanel.cxx source/ui/uiview/viewtab.cxx

Modified: openoffice/branches/sidebar/main/sw/source/ui/uiview/viewtab.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/sw/source/ui/uiview/viewtab.cxx?rev=1458352&r1=1458351&r2=1458352&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/sw/source/ui/uiview/viewtab.cxx (original)
+++ openoffice/branches/sidebar/main/sw/source/ui/uiview/viewtab.cxx Tue Mar 19 15:50:03 2013
@@ -199,15 +199,15 @@ void lcl_EraseDefTabs(SvxTabStopItem& rT
 
 void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
 {
-	sal_uInt16 nPhyPage, nVirPage;
-	GetWrtShell().GetPageNum( nPhyPage, nVirPage );
+    sal_uInt16 nPhyPage, nVirPage;
+    GetWrtShell().GetPageNum( nPhyPage, nVirPage );
 
-	if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
-	{
+    if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
+    {
         long nTmp = rLRSpace.GetRight();
-		rLRSpace.SetRight( rLRSpace.GetLeft() );
-		rLRSpace.SetLeft( nTmp );
-	}
+        rLRSpace.SetRight( rLRSpace.GetLeft() );
+        rLRSpace.SetLeft( nTmp );
+    }
 }
 
 /*--------------------------------------------------------------------
@@ -268,691 +268,730 @@ void ResizeFrameCols(SwFmtCol& rCol,
 
 void SwView::ExecTabWin( SfxRequest& rReq )
 {
-	SwWrtShell &rSh 		= GetWrtShell();
-	const sal_uInt16 nFrmType	= rSh.IsObjSelected() ?
-									FRMTYPE_DRAWOBJ :
-										rSh.GetFrmType(0,sal_True);
-	const sal_Bool bFrmSelection = rSh.IsFrmSelected();
-	const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
-
-	const sal_uInt16 nSlot 	  	= rReq.GetSlot();
-	const sal_uInt16 nDescId  	= rSh.GetCurPageDesc();
-	const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
+    SwWrtShell &rSh 		= GetWrtShell();
+    const sal_uInt16 nFrmType	= rSh.IsObjSelected() ?
+                                    FRMTYPE_DRAWOBJ :
+                                        rSh.GetFrmType(0,sal_True);
+    const sal_Bool bFrmSelection = rSh.IsFrmSelected();
+    const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
+
+    const sal_uInt16 nSlot 	  	= rReq.GetSlot();
+    const sal_uInt16 nDescId  	= rSh.GetCurPageDesc();
+    const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
 
     const sal_Bool bVerticalWriting = rSh.IsInVerticalText();
     const SwFmtHeader& rHeaderFmt = rDesc.GetMaster().GetHeader();
-	SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
+    SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
 
-	const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
-	SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
+    const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
+    SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
 
-	const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();
+    const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();
 
     const SwRect& rPageRect = rSh.GetAnyCurRect(RECT_PAGE);
     const long nPageWidth  = bBrowse ? rPageRect.Width() : rFrmSize.GetWidth();
     const long nPageHeight = bBrowse ? rPageRect.Height() : rFrmSize.GetHeight();
 
-	sal_Bool bUnlockView = sal_False;
-	rSh.StartAllAction();
-	sal_Bool bSect = 0 != (nFrmType & FRMTYPE_COLSECT);
+    sal_Bool bUnlockView = sal_False;
+    rSh.StartAllAction();
+    sal_Bool bSect = 0 != (nFrmType & FRMTYPE_COLSECT);
 
-	switch	( nSlot )
-	{
+    switch( nSlot )
+    {
     case SID_ATTR_LONG_LRSPACE:
-	{
-		SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)rReq.GetArgs()->
-													Get( SID_ATTR_LONG_LRSPACE ) );
-        SvxLRSpaceItem aLR(RES_LR_SPACE);
-        if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
-		{
-            SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
-			const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+        {
+            SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)rReq.GetArgs()->
+                Get( SID_ATTR_LONG_LRSPACE ) );
+            SvxLRSpaceItem aLR(RES_LR_SPACE);
+            if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
+            {
+                SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
+                const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+
+                sal_Bool bVerticalFrame(sal_False);
+                {
+                    sal_Bool bRTL;
+                    sal_Bool bVertL2R;
+                    bVerticalFrame = ( bFrmSelection &&
+                        rSh.IsFrmVertical(sal_True, bRTL, bVertL2R) ) ||
+                        ( !bFrmSelection && bVerticalWriting);
+                }
+                long nDeltaX = bVerticalFrame ?
+                    rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
+                    rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
+
+                SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+                    RES_VERT_ORIENT, RES_HORI_ORIENT,
+                    RES_COL, RES_COL, 0 );
 
-            sal_Bool bVerticalFrame(sal_False);
+                if(bVerticalFrame)
+                {
+                    SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
+                    aVertOrient.SetVertOrient(text::VertOrientation::NONE);
+                    aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
+                    aSet.Put( aVertOrient );
+                }
+                else
+                {
+                    SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
+                    aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
+                    aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
+                    aSet.Put( aHoriOrient );
+                }
+
+                SwFmtFrmSize aSize( pFmt->GetFrmSize() );
+                long nOldWidth = (long) aSize.GetWidth();
+
+                if(aSize.GetWidthPercent())
+                {
+                    SwRect aRect;
+                    rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+                    long nPrtWidth = aRect.Width();
+                    aSize.SetWidthPercent(sal_uInt8((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
+                }
+                else
+                    aSize.SetWidth( nPageWidth -
+                    (aLongLR.GetLeft() + aLongLR.GetRight()));
+
+                if( nFrmType & FRMTYPE_COLUMN )
+                {
+                    SwFmtCol aCol(pFmt->GetCol());
+
+                    ::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
+                    aSet.Put(aCol);
+                }
+
+                aSet.Put( aSize );
+
+                rSh.StartAction();
+                rSh.Push();
+                rSh.SetFlyFrmAttr( aSet );
+                //die Rahmenselektion wieder aufheben
+                if(!bFrmSelection && rSh.IsFrmSelected())
+                {
+                    rSh.UnSelectFrm();
+                    rSh.LeaveSelFrmMode();
+                }
+                rSh.Pop();
+                rSh.EndAction();
+            }
+            else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
             {
-                sal_Bool bRTL;
-                sal_Bool bVertL2R;
-                bVerticalFrame = ( bFrmSelection &&
-                                   rSh.IsFrmVertical(sal_True, bRTL, bVertL2R) ) ||
-                                 ( !bFrmSelection && bVerticalWriting);
-            }
-            long nDeltaX = bVerticalFrame ?
-                rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
-				rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
-
-            SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
-                                        RES_VERT_ORIENT, RES_HORI_ORIENT,
-										RES_COL, RES_COL, 0 );
-
-            if(bVerticalFrame)
-            {
-                SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
-                aVertOrient.SetVertOrient(text::VertOrientation::NONE);
-                aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
-                aSet.Put( aVertOrient );
+                // Seitenraender rausrechnen
+                long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
+                aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
+
+                nOld = rDesc.GetMaster().GetLRSpace().GetRight();
+                aLongLR.SetRight( nOld > (sal_uInt16)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
+                aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
+                aLR.SetRight((sal_uInt16)aLongLR.GetRight());
+
+                if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
+                    pHeaderFmt->SetFmtAttr( aLR );
+                else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
+                    pFooterFmt->SetFmtAttr( aLR );
+            }
+            else if( nFrmType == FRMTYPE_DRAWOBJ)
+            {
+                SwRect aRect( rSh.GetObjRect() );
+                aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
+                aRect.Right( rPageRect.Right() - aLongLR.GetRight());
+                rSh.SetObjRect( aRect );
+            }
+            else if(bSect || rSh.IsDirectlyInSection())
+            {
+                //change the section indents and the columns if available
+                //at first determine the changes
+                SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
+                const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
+                aSectRect.Pos() += aTmpRect.Pos();
+                long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
+                long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
+                //change the LRSpaceItem of the section accordingly
+                const SwSection* pCurrSect = rSh.GetCurrSection();
+                const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
+                SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
+                aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
+                aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
+                SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
+                aSet.Put(aLRTmp);
+                //change the first/last column
+                if(bSect)
+                {
+                    SwFmtCol aCols( pSectFmt->GetCol() );
+                    long nDiffWidth = nLeftDiff + nRightDiff;
+                    ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
+                    aSet.Put( aCols );
+                }
+                SwSectionData aData(*pCurrSect);
+                rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
             }
             else
+            {	// Seitenraender einstellen
+                aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
+                aLR.SetRight((sal_uInt16)aLongLR.GetRight());
+                SwapPageMargin( rDesc, aLR );
+                SwPageDesc aDesc( rDesc );
+                aDesc.GetMaster().SetFmtAttr( aLR );
+                rSh.ChgPageDesc( nDescId, aDesc );
+            }
+        }
+        break;
+
+        // apply new left and right margins to current page style
+    case SID_ATTR_PAGE_LRSPACE:
+        {
+            const SvxLongLRSpaceItem aLongLR( static_cast<const SvxLongLRSpaceItem&>(rReq.GetArgs()->Get( SID_ATTR_PAGE_LRSPACE )) );
+
+            SwPageDesc aDesc( rDesc );
             {
-                SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
-                aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
-                aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
-                aSet.Put( aHoriOrient );
-            }
-
-			SwFmtFrmSize aSize( pFmt->GetFrmSize() );
-			long nOldWidth = (long) aSize.GetWidth();
-
-			if(aSize.GetWidthPercent())
-			{
-				SwRect aRect;
-                rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
-				long nPrtWidth = aRect.Width();
-				aSize.SetWidthPercent(sal_uInt8((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
-			}
-			else
-				aSize.SetWidth( nPageWidth -
-						(aLongLR.GetLeft() + aLongLR.GetRight()));
-
-			if( nFrmType & FRMTYPE_COLUMN )
-			{
-				SwFmtCol aCol(pFmt->GetCol());
-
-				::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
-				aSet.Put(aCol);
-			}
-
-			aSet.Put( aSize );
-
-			rSh.StartAction();
-			rSh.Push();
-			rSh.SetFlyFrmAttr( aSet );
-			//die Rahmenselektion wieder aufheben
-			if(!bFrmSelection && rSh.IsFrmSelected())
-			{
-				rSh.UnSelectFrm();
-				rSh.LeaveSelFrmMode();
-			}
-			rSh.Pop();
-			rSh.EndAction();
-		}
-		else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
-		{
-			// Seitenraender rausrechnen
-            long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
-            aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
-
-			nOld = rDesc.GetMaster().GetLRSpace().GetRight();
-			aLongLR.SetRight( nOld > (sal_uInt16)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
-			aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
-			aLR.SetRight((sal_uInt16)aLongLR.GetRight());
-
-			if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
-                pHeaderFmt->SetFmtAttr( aLR );
-			else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
-                pFooterFmt->SetFmtAttr( aLR );
-		}
-		else if( nFrmType == FRMTYPE_DRAWOBJ)
-		{
-			SwRect aRect( rSh.GetObjRect() );
-			aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
-			aRect.Right( rPageRect.Right() - aLongLR.GetRight());
-			rSh.SetObjRect( aRect );
-		}
-        else if(bSect || rSh.IsDirectlyInSection())
-		{
-			//change the section indents and the columns if available
-			//at first determine the changes
-            SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
-            const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
-            aSectRect.Pos() += aTmpRect.Pos();
-            long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
-            long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
-			//change the LRSpaceItem of the section accordingly
-            const SwSection* pCurrSect = rSh.GetCurrSection();
-            const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
-            SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
-            aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
-            aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
-            SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
-            aSet.Put(aLRTmp);
-			//change the first/last column
-			if(bSect)
-			{
-                SwFmtCol aCols( pSectFmt->GetCol() );
-                long nDiffWidth = nLeftDiff + nRightDiff;
-                ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
-                aSet.Put( aCols );
-			}
-            SwSectionData aData(*pCurrSect);
-            rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
+                SvxLRSpaceItem aLR( RES_LR_SPACE );
+                aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
+                aLR.SetRight((sal_uInt16)aLongLR.GetRight());
+                SwapPageMargin( rDesc, aLR );
+                aDesc.GetMaster().SetFmtAttr( aLR );
+            }
+            rSh.ChgPageDesc( nDescId, aDesc );
         }
-		else
-		{	// Seitenraender einstellen
-			aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
-			aLR.SetRight((sal_uInt16)aLongLR.GetRight());
-			SwapPageMargin( rDesc, aLR );
-			SwPageDesc aDesc( rDesc );
-            aDesc.GetMaster().SetFmtAttr( aLR );
-			rSh.ChgPageDesc( nDescId, aDesc );
-		}
-	}
-	break;
+        break;
+
     case SID_ATTR_LONG_ULSPACE:
-	{
-		SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)rReq.GetArgs()->
-														Get( SID_ATTR_LONG_ULSPACE ));
+        {
+            SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)rReq.GetArgs()->
+                Get( SID_ATTR_LONG_ULSPACE ));
 
-		if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
-		{
-            SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
-			const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
-            const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
-			const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
-
-            SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
-                                        RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
-            //which of the orientation attributes is to be put depends on the frame's environment
-            sal_Bool bRTL;
-            sal_Bool bVertL2R;
-            if ( ( bFrmSelection &&
-                   rSh.IsFrmVertical(sal_True, bRTL, bVertL2R ) ) ||
-                 ( !bFrmSelection && bVerticalWriting ) )
-            {
-                SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
-                aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
-                aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
-                aSet.Put( aHoriOrient );
-            }
-            else
+            if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
             {
-                SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
-                aVertOrient.SetVertOrient(text::VertOrientation::NONE);
-                aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
-                aSet.Put( aVertOrient );
-            }
-			SwFmtFrmSize aSize(pFmt->GetFrmSize());
-			if(aSize.GetHeightPercent())
-			{
-				SwRect aRect;
-                rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
-				long nPrtHeight = aRect.Height();
-				aSize.SetHeightPercent(sal_uInt8(nHeight * 100 /nPrtHeight));
-			}
-			else
-				aSize.SetHeight(nHeight );
+                SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
+                const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
+                const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
+                const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
+
+                SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
+                    RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
+                //which of the orientation attributes is to be put depends on the frame's environment
+                sal_Bool bRTL;
+                sal_Bool bVertL2R;
+                if ( ( bFrmSelection &&
+                    rSh.IsFrmVertical(sal_True, bRTL, bVertL2R ) ) ||
+                    ( !bFrmSelection && bVerticalWriting ) )
+                {
+                    SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
+                    aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
+                    aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
+                    aSet.Put( aHoriOrient );
+                }
+                else
+                {
+                    SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
+                    aVertOrient.SetVertOrient(text::VertOrientation::NONE);
+                    aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
+                    aSet.Put( aVertOrient );
+                }
+                SwFmtFrmSize aSize(pFmt->GetFrmSize());
+                if(aSize.GetHeightPercent())
+                {
+                    SwRect aRect;
+                    rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
+                    long nPrtHeight = aRect.Height();
+                    aSize.SetHeightPercent(sal_uInt8(nHeight * 100 /nPrtHeight));
+                }
+                else
+                    aSize.SetHeight(nHeight );
 
-            aSet.Put( aSize );
-            rSh.SetFlyFrmAttr( aSet );
-		}
-		else if( nFrmType == FRMTYPE_DRAWOBJ )
-		{
-			SwRect aRect( rSh.GetObjRect() );
-            aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
-			aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
-			rSh.SetObjRect( aRect ) ;
-		}
-        else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
-		{
-			//change the section indents and the columns if available
-			//at first determine the changes
-            SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
-            const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
-            aSectRect.Pos() += aTmpRect.Pos();
-            const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
-            const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
-			//change the LRSpaceItem of the section accordingly
-            const SwSection* pCurrSect = rSh.GetCurrSection();
-            const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
-            SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
-            aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
-            aLR.SetRight(aLR.GetRight() + nRightDiff);
-            SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
-            aSet.Put(aLR);
-			//change the first/last column
-			if(bSect)
-			{
-                SwFmtCol aCols( pSectFmt->GetCol() );
-                long nDiffWidth = nLeftDiff + nRightDiff;
-                ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
-                aSet.Put( aCols );
-			}
-            SwSectionData aData(*pCurrSect);
-            rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
-        }
-		else
-		{	SwPageDesc aDesc( rDesc );
+                aSet.Put( aSize );
+                rSh.SetFlyFrmAttr( aSet );
+            }
+            else if( nFrmType == FRMTYPE_DRAWOBJ )
+            {
+                SwRect aRect( rSh.GetObjRect() );
+                aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
+                aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
+                rSh.SetObjRect( aRect ) ;
+            }
+            else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
+            {
+                //change the section indents and the columns if available
+                //at first determine the changes
+                SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
+                const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
+                aSectRect.Pos() += aTmpRect.Pos();
+                const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
+                const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
+                //change the LRSpaceItem of the section accordingly
+                const SwSection* pCurrSect = rSh.GetCurrSection();
+                const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
+                SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
+                aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
+                aLR.SetRight(aLR.GetRight() + nRightDiff);
+                SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
+                aSet.Put(aLR);
+                //change the first/last column
+                if(bSect)
+                {
+                    SwFmtCol aCols( pSectFmt->GetCol() );
+                    long nDiffWidth = nLeftDiff + nRightDiff;
+                    ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
+                    aSet.Put( aCols );
+                }
+                SwSectionData aData(*pCurrSect);
+                rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
+            }
+            else
+            {	SwPageDesc aDesc( rDesc );
 
-			if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
-			{
+            if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
+            {
 
-				const sal_Bool bHead = nFrmType & FRMTYPE_HEADER ? sal_True : sal_False;
-				SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
-				if ( bHead )
-					aUL.SetUpper( (sal_uInt16)aLongULSpace.GetUpper() );
-				else
-					aUL.SetLower( (sal_uInt16)aLongULSpace.GetLower() );
+                const sal_Bool bHead = nFrmType & FRMTYPE_HEADER ? sal_True : sal_False;
+                SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+                if ( bHead )
+                    aUL.SetUpper( (sal_uInt16)aLongULSpace.GetUpper() );
+                else
+                    aUL.SetLower( (sal_uInt16)aLongULSpace.GetLower() );
                 aDesc.GetMaster().SetFmtAttr( aUL );
 
-				if( (bHead && pHeaderFmt) || (!bHead && pFooterFmt) )
+                if( (bHead && pHeaderFmt) || (!bHead && pFooterFmt) )
                 {
                     SwFmtFrmSize aSz( bHead ? pHeaderFmt->GetFrmSize() :
-										      pFooterFmt->GetFrmSize() );
+                        pFooterFmt->GetFrmSize() );
                     aSz.SetHeightSizeType( ATT_FIX_SIZE );
-				    aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
-											    aLongULSpace.GetUpper() );
-				    if ( bHead )
+                    aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
+                        aLongULSpace.GetUpper() );
+                    if ( bHead )
                         pHeaderFmt->SetFmtAttr( aSz );
-				    else
+                    else
                         pFooterFmt->SetFmtAttr( aSz );
                 }
-			}
-			else
-			{
+            }
+            else
+            {
                 SvxULSpaceItem aUL(RES_UL_SPACE);
-				aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
-				aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
+                aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
+                aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
                 aDesc.GetMaster().SetFmtAttr(aUL);
-			}
-
-			rSh.ChgPageDesc( nDescId, aDesc );
-		}
-	}
-	break;
-    case SID_ATTR_SWPAGE_COLUMN:
-    {
-        const SfxInt16Item aColumnItem( (const SfxInt16Item&)rReq.GetArgs()->Get(nSlot) );
-        const sal_uInt16 nPageColumnType = aColumnItem.GetValue();
+            }
 
-        // nPageColumnType =
-        // 1 - single-columned page
-        // 2 - two-columned page
-        // 3 - three-columned page
-        // 4 - two-columned page with left column width of 2/3 of page width
-        // 5 - two-columned page with right column width of 2/3 of page width
+            rSh.ChgPageDesc( nDescId, aDesc );
+            }
+        }
+        break;
 
-        sal_uInt16 nCount = 2;
-        if ( nPageColumnType == 1 )
+        // apply new top and bottom margins to current page style
+    case SID_ATTR_PAGE_ULSPACE:
         {
-            nCount = 0;
+            SvxLongULSpaceItem aLongULSpace(
+                static_cast<const SvxLongULSpaceItem&>(rReq.GetArgs()->Get( SID_ATTR_PAGE_ULSPACE ) ) );
+
+            SwPageDesc aDesc( rDesc );
+            {
+                SvxULSpaceItem aUL(RES_UL_SPACE);
+                aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
+                aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
+                aDesc.GetMaster().SetFmtAttr(aUL);
+            }
+            rSh.ChgPageDesc( nDescId, aDesc );
         }
-        else if ( nPageColumnType == 3 )
+        break;
+
+    case SID_ATTR_PAGE_COLUMN:
         {
-            nCount = 3;
-        }
+            const SfxInt16Item aColumnItem( (const SfxInt16Item&)rReq.GetArgs()->Get(nSlot) );
+            const sal_uInt16 nPageColumnType = aColumnItem.GetValue();
 
-        const sal_uInt16 nGutterWidth = 0;
+            // nPageColumnType =
+            // 1 - single-columned page
+            // 2 - two-columned page
+            // 3 - three-columned page
+            // 4 - two-columned page with left column width of 2/3 of page width
+            // 5 - two-columned page with right column width of 2/3 of page width
 
-        const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() );
-        const long nLeft = aLR.GetLeft();
-        const long nRight = aLR.GetRight();
-        const long nWidth = nPageWidth - nLeft - nRight;
-
-        SwFmtCol aCols( rDesc.GetMaster().GetCol() );
-        aCols.Init( nCount, nGutterWidth, nWidth );
-        aCols.SetWishWidth( nWidth );
-        aCols.SetGutterWidth( nGutterWidth, nWidth );
-        aCols.SetOrtho( sal_False, nGutterWidth, nWidth );
-
-        long nColumnLeft = 0;
-        long nColumnRight = 0;
-        if ( nPageColumnType == 4 )
-        {
-            nColumnRight = (long)(nWidth/3);
-            nColumnLeft = nWidth - nColumnRight;
-            aCols.GetColumns()[0]->SetWishWidth( nColumnLeft );
-            aCols.GetColumns()[1]->SetWishWidth( nColumnRight );
-        }
-        else if ( nPageColumnType == 5 )
-        {
-            nColumnLeft = (long)(nWidth/3);
-            nColumnRight = nWidth - nColumnLeft;
-            aCols.GetColumns()[0]->SetWishWidth( nColumnLeft );
-            aCols.GetColumns()[1]->SetWishWidth( nColumnRight );
+            sal_uInt16 nCount = 2;
+            if ( nPageColumnType == 1 )
+            {
+                nCount = 0;
+            }
+            else if ( nPageColumnType == 3 )
+            {
+                nCount = 3;
+            }
+
+            const sal_uInt16 nGutterWidth = 0;
+
+            const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() );
+            const long nLeft = aLR.GetLeft();
+            const long nRight = aLR.GetRight();
+            const long nWidth = nPageWidth - nLeft - nRight;
+
+            SwFmtCol aCols( rDesc.GetMaster().GetCol() );
+            aCols.Init( nCount, nGutterWidth, nWidth );
+            aCols.SetWishWidth( nWidth );
+            aCols.SetGutterWidth( nGutterWidth, nWidth );
+            aCols.SetOrtho( sal_False, nGutterWidth, nWidth );
+
+            long nColumnLeft = 0;
+            long nColumnRight = 0;
+            if ( nPageColumnType == 4 )
+            {
+                nColumnRight = (long)(nWidth/3);
+                nColumnLeft = nWidth - nColumnRight;
+                aCols.GetColumns()[0]->SetWishWidth( nColumnLeft );
+                aCols.GetColumns()[1]->SetWishWidth( nColumnRight );
+            }
+            else if ( nPageColumnType == 5 )
+            {
+                nColumnLeft = (long)(nWidth/3);
+                nColumnRight = nWidth - nColumnLeft;
+                aCols.GetColumns()[0]->SetWishWidth( nColumnLeft );
+                aCols.GetColumns()[1]->SetWishWidth( nColumnRight );
+            }
+
+            SwPageDesc aDesc( rDesc );
+            aDesc.GetMaster().SetFmtAttr( aCols );
+            rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
         }
+        break;
 
-        SwPageDesc aDesc( rDesc );
-        aDesc.GetMaster().SetFmtAttr( aCols );
-        rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
-    }
-    break;
     case SID_ATTR_TABSTOP_VERTICAL:
     case SID_ATTR_TABSTOP:
-    {
-		sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
-		SvxTabStopItem aTabStops( (const SvxTabStopItem&)rReq.GetArgs()->
-                                                    Get( nWhich ));
-		aTabStops.SetWhich(RES_PARATR_TABSTOP);
- 		const SvxTabStopItem& rDefTabs =
-					(const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
-
-		// Default-Tab an Pos 0
-		SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
-        rSh.GetCurAttr( aSet );
-		const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);
+        {
+            sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
+            SvxTabStopItem aTabStops( (const SvxTabStopItem&)rReq.GetArgs()->
+                Get( nWhich ));
+            aTabStops.SetWhich(RES_PARATR_TABSTOP);
+            const SvxTabStopItem& rDefTabs =
+                (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
 
-		if ( rLR.GetTxtFirstLineOfst() < 0 )
-		{
-			SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
-			aTabStops.Insert( aSwTabStop );
-		}
+            // Default-Tab an Pos 0
+            SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
+            rSh.GetCurAttr( aSet );
+            const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);
 
-		// auffuellen mit Default-Tabs
-		sal_uInt16 nDef = ::GetTabDist( rDefTabs );
-		::MakeDefTabs( nDef, aTabStops );
+            if ( rLR.GetTxtFirstLineOfst() < 0 )
+            {
+                SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
+                aTabStops.Insert( aSwTabStop );
+            }
+
+            // auffuellen mit Default-Tabs
+            sal_uInt16 nDef = ::GetTabDist( rDefTabs );
+            ::MakeDefTabs( nDef, aTabStops );
+
+            SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+            if(	pColl && pColl->IsAutoUpdateFmt() )
+            {
+                SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
+                aTmp.Put(aTabStops);
+                rSh.AutoUpdatePara( pColl, aTmp );
+            }
+            else
+                rSh.SetAttr( aTabStops );
+            break;
+        }
 
-		SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
-		if(	pColl && pColl->IsAutoUpdateFmt() )
-		{
-			SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
-			aTmp.Put(aTabStops);
-			rSh.AutoUpdatePara( pColl, aTmp );
-		}
-		else
-			rSh.SetAttr( aTabStops );
-		break;
-	}
     case SID_ATTR_PARA_LRSPACE_VERTICAL:
     case SID_ATTR_PARA_LRSPACE:
-	{
-		SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
-										GetArgs()->Get(nSlot));
-		if(nFrmType & FRMTYPE_FLY_ANY)
-		{
-            sal_Bool bFirstColumn = sal_True;
-            sal_Bool bLastColumn = sal_True;
-            if(nFrmType & FRMTYPE_COLUMN)
-            {
-                sal_uInt16 nCurFrameCol = rSh.GetCurColNum() - 1;
-                bFirstColumn = !nCurFrameCol;
-                const SwFrmFmt* pFmt =  rSh.GetFlyFrmFmt();
-                const SwFmtCol* pCols = &pFmt->GetCol();
-                const SwColumns& rCols = pCols->GetColumns();
-                sal_uInt16 nColumnCount = rCols.Count();
-                bLastColumn = nColumnCount == nCurFrameCol + 1;
+        {
+            SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)rReq.
+                GetArgs()->Get(nSlot));
+            if(nFrmType & FRMTYPE_FLY_ANY)
+            {
+                sal_Bool bFirstColumn = sal_True;
+                sal_Bool bLastColumn = sal_True;
+                if(nFrmType & FRMTYPE_COLUMN)
+                {
+                    sal_uInt16 nCurFrameCol = rSh.GetCurColNum() - 1;
+                    bFirstColumn = !nCurFrameCol;
+                    const SwFrmFmt* pFmt =  rSh.GetFlyFrmFmt();
+                    const SwFmtCol* pCols = &pFmt->GetCol();
+                    const SwColumns& rCols = pCols->GetColumns();
+                    sal_uInt16 nColumnCount = rCols.Count();
+                    bLastColumn = nColumnCount == nCurFrameCol + 1;
+                }
             }
-		}
-        aParaMargin.SetRight( aParaMargin.GetRight() - nRightBorderDistance );
-        aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - nLeftBorderDistance );
+            aParaMargin.SetRight( aParaMargin.GetRight() - nRightBorderDistance );
+            aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - nLeftBorderDistance );
 
-		aParaMargin.SetWhich( RES_LR_SPACE );
-		SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
+            aParaMargin.SetWhich( RES_LR_SPACE );
+            SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
 
-        // #i23726#
-        if (pNumRuleNodeFromDoc)
-        {
-            // --> FME 2005-02-22 #i42922# Mouse move of numbering label
-            // has to consider the left indent of the paragraph
-	        SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
-            rSh.GetCurAttr( aSet );
-            const SvxLRSpaceItem& rLR =
+            // #i23726#
+            if (pNumRuleNodeFromDoc)
+            {
+                // --> FME 2005-02-22 #i42922# Mouse move of numbering label
+                // has to consider the left indent of the paragraph
+                SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
+                rSh.GetCurAttr( aSet );
+                const SvxLRSpaceItem& rLR =
                     static_cast<const SvxLRSpaceItem&>(aSet.Get(RES_LR_SPACE));
-            // <--
+                // <--
 
-            SwPosition aPos(*pNumRuleNodeFromDoc);
-            // --> OD 2008-06-09 #i90078#
-            rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
-            // <--
-            // --> OD 2005-02-18 #i42921# - invalidate state of indent in order
-            // to get a ruler update.
-            aParaMargin.SetWhich( nSlot );
-            GetViewFrame()->GetBindings().SetState( aParaMargin );
-            // <--
-        }
-		else if( pColl && pColl->IsAutoUpdateFmt() )
-		{
-			SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
-			aSet.Put(aParaMargin);
-			rSh.AutoUpdatePara( pColl, aSet);
-		}
-		else
-			rSh.SetAttr( aParaMargin );
+                SwPosition aPos(*pNumRuleNodeFromDoc);
+                // --> OD 2008-06-09 #i90078#
+                rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
+                // <--
+                // --> OD 2005-02-18 #i42921# - invalidate state of indent in order
+                // to get a ruler update.
+                aParaMargin.SetWhich( nSlot );
+                GetViewFrame()->GetBindings().SetState( aParaMargin );
+                // <--
+            }
+            else if( pColl && pColl->IsAutoUpdateFmt() )
+            {
+                SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
+                aSet.Put(aParaMargin);
+                rSh.AutoUpdatePara( pColl, aSet);
+            }
+            else
+                rSh.SetAttr( aParaMargin );
 
-		if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
-		{
-			SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );
+            if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
+            {
+                SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );
 
-            rSh.GetCurAttr( aSet );
-			const SvxTabStopItem&  rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);
+                rSh.GetCurAttr( aSet );
+                const SvxTabStopItem&  rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);
 
-			// Haben wir einen Tab an Stelle Null
-			sal_uInt16 i;
+                // Haben wir einen Tab an Stelle Null
+                sal_uInt16 i;
+
+                for ( i = 0; i < rTabStops.Count(); ++i )
+                    if ( rTabStops[i].GetTabPos() == 0 )
+                        break;
+
+                if ( i >= rTabStops.Count() )
+                {
+                    // Kein DefTab
+                    SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
+                    aTabStops = rTabStops;
+
+                    ::lcl_EraseDefTabs(aTabStops);
+
+                    SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
+                    aTabStops.Insert(aSwTabStop);
+
+                    const SvxTabStopItem& rDefTabs =
+                        (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
+                    sal_uInt16 nDef = ::GetTabDist(rDefTabs);
+                    ::MakeDefTabs( nDef, aTabStops );
+
+                    if(	pColl && pColl->IsAutoUpdateFmt())
+                    {
+                        SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
+                        aSetTmp.Put(aTabStops);
+                        rSh.AutoUpdatePara( pColl, aSetTmp );
+                    }
+                    else
+                        rSh.SetAttr( aTabStops );
+                }
+            }
+        }
+        break;
 
-			for ( i = 0; i < rTabStops.Count(); ++i )
-				if ( rTabStops[i].GetTabPos() == 0 )
-					break;
-
-			if ( i >= rTabStops.Count() )
-			{
-				// Kein DefTab
-                SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
-				aTabStops = rTabStops;
-
-				::lcl_EraseDefTabs(aTabStops);
-
-				SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
-				aTabStops.Insert(aSwTabStop);
-
-				const SvxTabStopItem& rDefTabs =
-					(const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
-				sal_uInt16 nDef = ::GetTabDist(rDefTabs);
-				::MakeDefTabs( nDef, aTabStops );
-
-				if(	pColl && pColl->IsAutoUpdateFmt())
-				{
-					SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
-					aSetTmp.Put(aTabStops);
-					rSh.AutoUpdatePara( pColl, aSetTmp );
-				}
-				else
-					rSh.SetAttr( aTabStops );
-			}
-		}
-	}
-	break;
     case SID_RULER_BORDERS_VERTICAL:
     case SID_RULER_BORDERS:
-	{
-		SvxColumnItem aColItem((const SvxColumnItem&)rReq.
-                                            GetArgs()->Get(nSlot));
+        {
+            SvxColumnItem aColItem((const SvxColumnItem&)rReq.
+                GetArgs()->Get(nSlot));
 
-		if( bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
-		{
-			ASSERT(aColItem.Count(), "ColDesc ist leer!!");
+            if( bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
+            {
+                ASSERT(aColItem.Count(), "ColDesc ist leer!!");
 
-			const sal_Bool bSingleLine = ((const SfxBoolItem&)rReq.
-							GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();
+                const sal_Bool bSingleLine = ((const SfxBoolItem&)rReq.
+                    GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();
+
+                SwTabCols aTabCols;
+                if ( bSetTabColFromDoc )
+                    rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
+                else
+                    rSh.GetTabCols(aTabCols);
 
-			SwTabCols aTabCols;
-			if ( bSetTabColFromDoc )
-				rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
-			else
-				rSh.GetTabCols(aTabCols);
-
-			// linker Tabellenrand
-			long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
-			aTabCols.SetLeft( nBorder );
+                // linker Tabellenrand
+                long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
+                aTabCols.SetLeft( nBorder );
 
-            nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
+                nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
 
 #ifdef DEBUG
-            long nTmp1 = nPageWidth;
-            long nTmp2 = aTabCols.GetLeftMin() + nBorder;
-            (void)nTmp1;
-            (void)nTmp2;
+                long nTmp1 = nPageWidth;
+                long nTmp2 = aTabCols.GetLeftMin() + nBorder;
+                (void)nTmp1;
+                (void)nTmp2;
 #endif
 
-            if ( aColItem.GetRight() > 0 )
-        		aTabCols.SetRight( nBorder );
+                if ( aColItem.GetRight() > 0 )
+                    aTabCols.SetRight( nBorder );
 
-			// Tabcols der Reihe nach
-			// Die letzte Col wird durch den Rand definiert
-            //columns in right-to-left tables need to be mirrored
-            sal_Bool bIsTableRTL =
-                IsTabColFromDoc() ?
-                      rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
+                // Tabcols der Reihe nach
+                // Die letzte Col wird durch den Rand definiert
+                //columns in right-to-left tables need to be mirrored
+                sal_Bool bIsTableRTL =
+                    IsTabColFromDoc() ?
+                    rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
                     : rSh.IsTableRightToLeft();
-            if(bIsTableRTL)
-			{
-				sal_uInt16 nColCount = aColItem.Count() - 1;
-				for ( sal_uInt16 i = 0; i < nColCount; ++i )
-				{
-					const SvxColumnDescription& rCol = aColItem[nColCount - i];
-					aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
-					aTabCols.SetHidden( i, !rCol.bVisible );
-				}
-			}
-			else
-			{
-				for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
-				{
-					const SvxColumnDescription& rCol = aColItem[i];
-					aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
-					aTabCols.SetHidden( i, !rCol.bVisible );
-				}
-			}
-
-            if ( bSetTabColFromDoc )
-			{
-				if( !rSh.IsViewLocked() )
-				{
-					bUnlockView = sal_True;
-					rSh.LockView( sal_True );
-				}
-				rSh.SetMouseTabCols( aTabCols, bSingleLine,
-											   aTabColFromDocPos );
-			}
-			else
-				rSh.SetTabCols(aTabCols, bSingleLine);
+                if(bIsTableRTL)
+                {
+                    sal_uInt16 nColCount = aColItem.Count() - 1;
+                    for ( sal_uInt16 i = 0; i < nColCount; ++i )
+                    {
+                        const SvxColumnDescription& rCol = aColItem[nColCount - i];
+                        aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
+                        aTabCols.SetHidden( i, !rCol.bVisible );
+                    }
+                }
+                else
+                {
+                    for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
+                    {
+                        const SvxColumnDescription& rCol = aColItem[i];
+                        aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
+                        aTabCols.SetHidden( i, !rCol.bVisible );
+                    }
+                }
 
-		}
-		else
-		{
-			if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
-			{
-				SwSectionFmt *pSectFmt = 0;
-				SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
-				if(bSect)
-				{
-					const SwSection *pSect = rSh.GetAnySection();
-					ASSERT( pSect, "Welcher Bereich?");
-					pSectFmt = pSect->GetFmt();
-				}
-				else
-				{
-					rSh.GetFlyFrmAttr( aSet );
-				}
-				SwFmtCol aCols(
-					bSect ?
-						pSectFmt->GetCol() :
-							(const SwFmtCol&)aSet.Get( RES_COL, sal_False ));
-				SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
-				const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
-				::lcl_ConvertToCols( aColItem, sal_uInt16(lWidth), aCols );
-				aSet.Put( aCols );
-				if(bSect)
-					rSh.SetSectionAttr( aSet, pSectFmt );
-				else
-				{
-					rSh.StartAction();
-					rSh.Push();
-					rSh.SetFlyFrmAttr( aSet );
-					//die Rahmenselektion wieder aufheben
-					if(!bFrmSelection && rSh.IsFrmSelected())
-					{
-						rSh.UnSelectFrm();
-						rSh.LeaveSelFrmMode();
-					}
-					rSh.Pop();
-					rSh.EndAction();
-				}
-			}
-			else
-			{
-				SwFmtCol aCols( rDesc.GetMaster().GetCol() );
-                const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
-				::lcl_ConvertToCols( aColItem,
-					sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
-								aCols );
-				SwPageDesc aDesc( rDesc );
-                aDesc.GetMaster().SetFmtAttr( aCols );
-				rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
-			}
-		}
-	}
-	break;
+                if ( bSetTabColFromDoc )
+                {
+                    if( !rSh.IsViewLocked() )
+                    {
+                        bUnlockView = sal_True;
+                        rSh.LockView( sal_True );
+                    }
+                    rSh.SetMouseTabCols( aTabCols, bSingleLine,
+                        aTabColFromDocPos );
+                }
+                else
+                    rSh.SetTabCols(aTabCols, bSingleLine);
 
-	case SID_RULER_ROWS :
-	case SID_RULER_ROWS_VERTICAL:
-	{
-		SvxColumnItem aColItem((const SvxColumnItem&)rReq.
-											GetArgs()->Get(nSlot));
+            }
+            else
+            {
+                if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
+                {
+                    SwSectionFmt *pSectFmt = 0;
+                    SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
+                    if(bSect)
+                    {
+                        const SwSection *pSect = rSh.GetAnySection();
+                        ASSERT( pSect, "Welcher Bereich?");
+                        pSectFmt = pSect->GetFmt();
+                    }
+                    else
+                    {
+                        rSh.GetFlyFrmAttr( aSet );
+                    }
+                    SwFmtCol aCols(
+                        bSect ?
+                        pSectFmt->GetCol() :
+                        (const SwFmtCol&)aSet.Get( RES_COL, sal_False ));
+                    SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
+                    const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
+                    ::lcl_ConvertToCols( aColItem, sal_uInt16(lWidth), aCols );
+                    aSet.Put( aCols );
+                    if(bSect)
+                        rSh.SetSectionAttr( aSet, pSectFmt );
+                    else
+                    {
+                        rSh.StartAction();
+                        rSh.Push();
+                        rSh.SetFlyFrmAttr( aSet );
+                        //die Rahmenselektion wieder aufheben
+                        if(!bFrmSelection && rSh.IsFrmSelected())
+                        {
+                            rSh.UnSelectFrm();
+                            rSh.LeaveSelFrmMode();
+                        }
+                        rSh.Pop();
+                        rSh.EndAction();
+                    }
+                }
+                else
+                {
+                    SwFmtCol aCols( rDesc.GetMaster().GetCol() );
+                    const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
+                    ::lcl_ConvertToCols( aColItem,
+                        sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
+                        aCols );
+                    SwPageDesc aDesc( rDesc );
+                    aDesc.GetMaster().SetFmtAttr( aCols );
+                    rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
+                }
+            }
+        }
+        break;
 
-		if( bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
-		{
-			ASSERT(aColItem.Count(), "ColDesc ist leer!!");
+    case SID_RULER_ROWS :
+    case SID_RULER_ROWS_VERTICAL:
+        {
+            SvxColumnItem aColItem((const SvxColumnItem&)rReq.
+                GetArgs()->Get(nSlot));
 
-			SwTabCols aTabCols;
-			if ( bSetTabRowFromDoc )
-				rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
-			else
-				rSh.GetTabRows(aTabCols);
-
-			if ( bVerticalWriting )
-			{
-				aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
-                aTabCols.SetLeftMin(aColItem.GetLeft());
-			}
-			else
-			{
-                long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
-				aTabCols.SetRight( nBorder );
-			}
-
-			if(bVerticalWriting)
-			{
-				for ( sal_uInt16 i = aColItem.Count() - 1; i; --i )
-				{
-					const SvxColumnDescription& rCol = aColItem[i - 1];
-					long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
-					aTabCols[i - 1] = nColumnPos;
-					aTabCols.SetHidden( i - 1, !rCol.bVisible );
-				}
-			}
-			else
-			{
-				for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
-				{
-					const SvxColumnDescription& rCol = aColItem[i];
-					aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
-					aTabCols.SetHidden( i, !rCol.bVisible );
-				}
-			}
-			sal_Bool bSingleLine = sal_False;
-			const SfxPoolItem* pSingleLine;
-			if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, sal_False, &pSingleLine))
-				bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
-			if ( bSetTabRowFromDoc )
-			{
-				if( !rSh.IsViewLocked() )
-				{
-					bUnlockView = sal_True;
-					rSh.LockView( sal_True );
-				}
-				rSh.SetMouseTabRows( aTabCols, bSingleLine, aTabColFromDocPos );
-			}
-			else
-				rSh.SetTabRows(aTabCols, bSingleLine);
-		}
-	}
-	break;
+            if( bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
+            {
+                ASSERT(aColItem.Count(), "ColDesc ist leer!!");
+
+                SwTabCols aTabCols;
+                if ( bSetTabRowFromDoc )
+                    rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
+                else
+                    rSh.GetTabRows(aTabCols);
+
+                if ( bVerticalWriting )
+                {
+                    aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
+                    aTabCols.SetLeftMin(aColItem.GetLeft());
+                }
+                else
+                {
+                    long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
+                    aTabCols.SetRight( nBorder );
+                }
+
+                if(bVerticalWriting)
+                {
+                    for ( sal_uInt16 i = aColItem.Count() - 1; i; --i )
+                    {
+                        const SvxColumnDescription& rCol = aColItem[i - 1];
+                        long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
+                        aTabCols[i - 1] = nColumnPos;
+                        aTabCols.SetHidden( i - 1, !rCol.bVisible );
+                    }
+                }
+                else
+                {
+                    for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
+                    {
+                        const SvxColumnDescription& rCol = aColItem[i];
+                        aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
+                        aTabCols.SetHidden( i, !rCol.bVisible );
+                    }
+                }
+                sal_Bool bSingleLine = sal_False;
+                const SfxPoolItem* pSingleLine;
+                if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, sal_False, &pSingleLine))
+                    bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
+                if ( bSetTabRowFromDoc )
+                {
+                    if( !rSh.IsViewLocked() )
+                    {
+                        bUnlockView = sal_True;
+                        rSh.LockView( sal_True );
+                    }
+                    rSh.SetMouseTabRows( aTabCols, bSingleLine, aTabColFromDocPos );
+                }
+                else
+                    rSh.SetTabRows(aTabCols, bSingleLine);
+            }
+        }
+        break;
 
     default:
-		ASSERT( !this, "Falsche SlotId");
-	}
-	rSh.EndAllAction();
+        ASSERT( !this, "Falsche SlotId");
+    }
+    rSh.EndAllAction();
 
-	if( bUnlockView )
-		rSh.LockView( sal_False );
+    if( bUnlockView )
+        rSh.LockView( sal_False );
 
     bSetTabColFromDoc = bSetTabRowFromDoc = bTabColFromDoc = bTabRowFromDoc = sal_False;
     SetNumRuleNodeFromDoc(NULL);
@@ -967,20 +1006,20 @@ void SwView::ExecTabWin( SfxRequest& rRe
 
 void SwView::StateTabWin(SfxItemSet& rSet)
 {
-	SwWrtShell &rSh 		= GetWrtShell();
+    SwWrtShell &rSh 		= GetWrtShell();
 
     const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &aTabColFromDocPos : 0;
-	const sal_uInt16 nFrmType	= rSh.IsObjSelected()
-				? FRMTYPE_DRAWOBJ
-				: rSh.GetFrmType( pPt, sal_True );
-
-	const sal_Bool 	bFrmSelection = rSh.IsFrmSelected();
-	const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
-	// PageOffset/Begrenzer
-	const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
-	const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
-	const long nPageWidth  = rPageRect.Width();
-	const long nPageHeight = rPageRect.Height();
+    const sal_uInt16 nFrmType	= rSh.IsObjSelected()
+                ? FRMTYPE_DRAWOBJ
+                : rSh.GetFrmType( pPt, sal_True );
+
+    const sal_Bool 	bFrmSelection = rSh.IsFrmSelected();
+    const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
+    // PageOffset/Begrenzer
+    const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
+    const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
+    const long nPageWidth  = rPageRect.Width();
+    const long nPageHeight = rPageRect.Height();
 
     const SwPageDesc& rDesc = rSh.GetPageDesc(
                 IsTabColFromDoc() || bTabRowFromDoc ?
@@ -1001,949 +1040,978 @@ void SwView::StateTabWin(SfxItemSet& rSe
     pVRuler->SetTabsRelativeToIndent( bRelative );
 
     SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
-	SwapPageMargin( rDesc, aPageLRSpace );
+    SwapPageMargin( rDesc, aPageLRSpace );
 
-	SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
-									RES_LR_SPACE, 		 RES_UL_SPACE, 0 );
-    // --> OD 2008-01-17 #newlistlevelattrs#
+    SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
+                                    RES_LR_SPACE, 		 RES_UL_SPACE, 0 );
     // get also the list level indent values merged as LR-SPACE item, if needed.
     rSh.GetCurAttr( aCoreSet, true );
-    // <--
     SelectionType nSelType = rSh.GetSelectionType();
 
-	SfxWhichIter aIter( rSet );
-	sal_uInt16 nWhich = aIter.FirstWhich();
+    SfxWhichIter aIter( rSet );
+    sal_uInt16 nWhich = aIter.FirstWhich();
     sal_Bool bPutContentProtection = sal_False;
 
     while ( nWhich )
     {
         switch ( nWhich )
         {
-        case SID_ATTR_SWPAGE_COLUMN:
-        {
-            sal_uInt16 nColumnType = 0;
-
-            const SwFrmFmt& rMaster = rDesc.GetMaster();
-            SwFmtCol aCol(rMaster.GetCol());
-            const sal_uInt16 nCols = aCol.GetNumCols();
-            if ( nCols == 0 )
+        case SID_ATTR_PAGE_COLUMN:
             {
-                nColumnType = 1;
+                sal_uInt16 nColumnType = 0;
+
+                const SwFrmFmt& rMaster = rDesc.GetMaster();
+                SwFmtCol aCol(rMaster.GetCol());
+                const sal_uInt16 nCols = aCol.GetNumCols();
+                if ( nCols == 0 )
+                {
+                    nColumnType = 1;
+                }
+                else if ( nCols == 2 )
+                {
+                    const sal_uInt16 nColLeft = aCol.CalcPrtColWidth(0, aCol.GetWishWidth());
+                    const sal_uInt16 nColRight = aCol.CalcPrtColWidth(1, aCol.GetWishWidth());
+
+                    if ( abs(nColLeft - nColRight) <= 10 )
+                    {
+                        nColumnType = 2;
+                    }
+                    else if( abs(nColLeft - nColRight*2) < 20 )
+                    {
+                        nColumnType = 4;
+                    }
+                    else if( abs(nColLeft*2 - nColRight) < 20 )
+                    {
+                        nColumnType = 5;
+                    }
+                }
+                else if( nCols == 3 )
+                {
+                    nColumnType = 3;
+                }
+
+                rSet.Put( SfxInt16Item( SID_ATTR_PAGE_COLUMN, nColumnType ) );
             }
-            else if ( nCols == 2 )
-            {
-                const sal_uInt16 nColLeft = aCol.CalcPrtColWidth(0, aCol.GetWishWidth());
-                const sal_uInt16 nColRight = aCol.CalcPrtColWidth(1, aCol.GetWishWidth());
+            break;
 
-                if ( abs(nColLeft - nColRight) <= 10 )
+        case SID_ATTR_LONG_LRSPACE:
+            {
+                SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
+                    (long)aPageLRSpace.GetRight(),
+                    SID_ATTR_LONG_LRSPACE);
+                if(bBrowse)
                 {
-                    nColumnType = 2;
+                    aLongLR.SetLeft(rPagePrtRect.Left());
+                    aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
                 }
-                else if( abs(nColLeft - nColRight*2) < 20 )
+                if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
+                    !(nFrmType & FRMTYPE_COLSECT) )
                 {
-                    nColumnType = 4;
+                    SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
+                        rDesc.GetMaster().GetHeader().GetHeaderFmt() :
+                        rDesc.GetMaster().GetFooter().GetFooterFmt());
+                    if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+                    {
+                        SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
+                        aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
+                        const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
+                        aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
+                        aLongLR.SetRight( (nPageWidth -
+                            (long)aRect.Right() + (long)aLR.GetRight()));
+                    }
+                }
+                else
+                {
+                    SwRect aRect;
+                    if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
+                    {
+                        aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
+                        const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
+                        aRect.Pos() += aTmpRect.Pos();
+                    }
+
+                    else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+                        aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+                    else if( nFrmType & FRMTYPE_DRAWOBJ)
+                        aRect = rSh.GetObjRect();
+
+                    if( aRect.Width() )
+                    {
+                        // PAGES01
+                        // make relative to page position:
+                        aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
+                        aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
+                    }
                 }
-                else if( abs(nColLeft*2 - nColRight) < 20 )
+                if( nWhich == SID_ATTR_LONG_LRSPACE )
+                    rSet.Put( aLongLR );
+                else
                 {
-                    nColumnType = 5;
+                    SvxLRSpaceItem aLR( aLongLR.GetLeft(),
+                        aLongLR.GetRight(),
+                        0, 0,
+                        nWhich);
+                    rSet.Put(aLR);
                 }
+                break;
             }
-            else if( nCols == 3 )
+
+        // provide left and right margins of current page style
+        case SID_ATTR_PAGE_LRSPACE:
             {
-                nColumnType = 3;
+                SvxLongLRSpaceItem aLongLR(
+                    (long)aPageLRSpace.GetLeft(),
+                    (long)aPageLRSpace.GetRight(),
+                    SID_ATTR_PAGE_LRSPACE );
+                rSet.Put( aLongLR );
             }
+            break;
 
-            rSet.Put( SfxInt16Item( SID_ATTR_SWPAGE_COLUMN, nColumnType ) );
-        }
-        break;
-//        case RES_LR_SPACE:
-//        case SID_ATTR_LRSPACE:
-		case SID_ATTR_LONG_LRSPACE:
-        {
-			SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
-										(long)aPageLRSpace.GetRight(),
-										SID_ATTR_LONG_LRSPACE);
-			if(bBrowse)
-			{
-				aLongLR.SetLeft(rPagePrtRect.Left());
-				aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
-			}
-			if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
-				 !(nFrmType & FRMTYPE_COLSECT) )
-			{
-				SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
-								rDesc.GetMaster().GetHeader().GetHeaderFmt() :
-								rDesc.GetMaster().GetFooter().GetFooterFmt());
-                if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+        case SID_ATTR_LONG_ULSPACE:
+            {
+                // Rand Seite Oben Unten
+                SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+                SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
+                    (long)aUL.GetLower(),
+                    SID_ATTR_LONG_ULSPACE);
+
+                if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
+                {
+                    // Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
+                    const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
+                    aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() ));
+                    aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() ));
+                }
+                else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
                 {
                     SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
                     aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
-                    const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
-                    aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
-                    aLongLR.SetRight( (nPageWidth -
-                                        (long)aRect.Right() + (long)aLR.GetRight()));
-                }
-			}
-			else
-			{
-				SwRect aRect;
-				if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
-                {
-                    aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
-                    const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
-                    aRect.Pos() += aTmpRect.Pos();
-                }
-
-				else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
-					aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
-				else if( nFrmType & FRMTYPE_DRAWOBJ)
-					aRect = rSh.GetObjRect();
-
-				if( aRect.Width() )
-				{
-                    // PAGES01
-                    // make relative to page position:
-					aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
-					aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
-				}
-			}
-			if( nWhich == SID_ATTR_LONG_LRSPACE )
-				rSet.Put( aLongLR );
-            else
-			{
-				SvxLRSpaceItem aLR( aLongLR.GetLeft(),
-								    aLongLR.GetRight(),
-                                    0, 0,
-									nWhich);
-				rSet.Put(aLR);
-			}
-			break;
-		}
-		case SID_ATTR_LONG_ULSPACE:
-//        case SID_ATTR_ULSPACE:
-//        case RES_UL_SPACE:
-		{
-			// Rand Seite Oben Unten
-			SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
-			SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
-										(long)aUL.GetLower(),
-										SID_ATTR_LONG_ULSPACE);
-
-			if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
-			{
-				// Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
-				const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
-				aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() ));
-				aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() ));
-			}
-			else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
-			{
-				SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
-				aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
-				aLongUL.SetUpper( (sal_uInt16)aRect.Top() );
-				aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) );
-			}
-			else if( nFrmType & FRMTYPE_DRAWOBJ)
-			{
-				const SwRect &rRect = rSh.GetObjRect();
-				aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
-				aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
-			}
-			else if(bBrowse)
-			{
-				aLongUL.SetUpper(rPagePrtRect.Top());
-				aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
-			}
-			if( nWhich == SID_ATTR_LONG_ULSPACE )
-				rSet.Put( aLongUL );
-			else
-			{
-				SvxULSpaceItem aULTmp((sal_uInt16)aLongUL.GetUpper(),
-									  (sal_uInt16)aLongUL.GetLower(),
-									  nWhich);
-				rSet.Put(aULTmp);
-			}
-			break;
-		}
+                    aLongUL.SetUpper( (sal_uInt16)aRect.Top() );
+                    aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) );
+                }
+                else if( nFrmType & FRMTYPE_DRAWOBJ)
+                {
+                    const SwRect &rRect = rSh.GetObjRect();
+                    aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
+                    aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
+                }
+                else if(bBrowse)
+                {
+                    aLongUL.SetUpper(rPagePrtRect.Top());
+                    aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
+                }
+                if( nWhich == SID_ATTR_LONG_ULSPACE )
+                    rSet.Put( aLongUL );
+                else
+                {
+                    SvxULSpaceItem aULTmp((sal_uInt16)aLongUL.GetUpper(),
+                        (sal_uInt16)aLongUL.GetLower(),
+                        nWhich);
+                    rSet.Put(aULTmp);
+                }
+                break;
+            }
+
+        // provide top and bottom margins of current page style
+        case SID_ATTR_PAGE_ULSPACE:
+            {
+                const SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+                SvxLongULSpaceItem aLongUL(
+                    (long)aUL.GetUpper(),
+                    (long)aUL.GetLower(),
+                    SID_ATTR_PAGE_ULSPACE );
+
+                rSet.Put( aLongUL );
+            }
+            break;
+
         case SID_ATTR_TABSTOP_VERTICAL :
         case RES_PARATR_TABSTOP:
-		{
-			if ( ISA( SwWebView ) ||
-				 IsTabColFromDoc() ||
-                 IsTabRowFromDoc() ||
-				 ( nSelType & nsSelectionType::SEL_GRF) ||
-					(nSelType & nsSelectionType::SEL_FRM) ||
-					(nSelType & nsSelectionType::SEL_OLE) ||
+            {
+                if ( ISA( SwWebView ) ||
+                    IsTabColFromDoc() ||
+                    IsTabRowFromDoc() ||
+                    ( nSelType & nsSelectionType::SEL_GRF) ||
+                    (nSelType & nsSelectionType::SEL_FRM) ||
+                    (nSelType & nsSelectionType::SEL_OLE) ||
                     SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE)||
                     (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich))||
                     (bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
-                 )
-                rSet.DisableItem( nWhich );
-			else
-            {
-                SvxTabStopItem aTabStops((const SvxTabStopItem&)
-											aCoreSet.Get( RES_PARATR_TABSTOP ));
-
-				const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
-											rSh.GetDefault(RES_PARATR_TABSTOP);
-
-                DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
-				long nDefTabDist = ::GetTabDist(rDefTabs);
-                pHRuler->SetDefTabDist( nDefTabDist );
-                pVRuler->SetDefTabDist( nDefTabDist );
-				::lcl_EraseDefTabs(aTabStops);
-                rSet.Put(aTabStops, nWhich);
-			}
-			break;
-		}
+                    )
+                    rSet.DisableItem( nWhich );
+                else
+                {
+                    SvxTabStopItem aTabStops((const SvxTabStopItem&)
+                        aCoreSet.Get( RES_PARATR_TABSTOP ));
+
+                    const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
+                        rSh.GetDefault(RES_PARATR_TABSTOP);
+
+                    DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
+                    long nDefTabDist = ::GetTabDist(rDefTabs);
+                    pHRuler->SetDefTabDist( nDefTabDist );
+                    pVRuler->SetDefTabDist( nDefTabDist );
+                    ::lcl_EraseDefTabs(aTabStops);
+                    rSet.Put(aTabStops, nWhich);
+                }
+                break;
+            }
+
         case SID_ATTR_PARA_LRSPACE_VERTICAL:
         case SID_ATTR_PARA_LRSPACE:
-		{
-			if ( nSelType & nsSelectionType::SEL_GRF ||
-					nSelType & nsSelectionType::SEL_FRM ||
-					nSelType & nsSelectionType::SEL_OLE ||
+            {
+                if ( nSelType & nsSelectionType::SEL_GRF ||
+                    nSelType & nsSelectionType::SEL_FRM ||
+                    nSelType & nsSelectionType::SEL_OLE ||
                     nFrmType == FRMTYPE_DRAWOBJ ||
                     (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich))||
                     (bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
                     )
-            {
-                rSet.DisableItem(nWhich);
-            }
-			else
-			{
-                SvxLRSpaceItem aLR( RES_LR_SPACE );
-				if ( !IsTabColFromDoc() )
                 {
-					aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
-
-                    // #i23726#
-                    if (pNumRuleNodeFromDoc)
+                    rSet.DisableItem(nWhich);
+                }
+                else
+                {
+                    SvxLRSpaceItem aLR( RES_LR_SPACE );
+                    if ( !IsTabColFromDoc() )
                     {
-                        short nOffset = static_cast< short >(aLR.GetTxtLeft() +
-                                        // --> FME 2005-02-22 #i42922# Mouse move of numbering label
-                                        // has to consider the left indent of the paragraph
-                                        pNumRuleNodeFromDoc->GetLeftMarginWithNum( sal_True ) );
-                                       // <--
+                        aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
+
+                        // #i23726#
+                        if (pNumRuleNodeFromDoc)
+                        {
+                            short nOffset = static_cast< short >(aLR.GetTxtLeft() +
+                                // --> FME 2005-02-22 #i42922# Mouse move of numbering label
+                                // has to consider the left indent of the paragraph
+                                pNumRuleNodeFromDoc->GetLeftMarginWithNum( sal_True ) );
+                            // <--
 
-                        short nFLOffset;
-                        pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
+                            short nFLOffset;
+                            pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
 
-                        aLR.SetLeft( nOffset + nFLOffset );
+                            aLR.SetLeft( nOffset + nFLOffset );
+                        }
                     }
+                    aLR.SetWhich(nWhich);
+                    rSet.Put(aLR);
                 }
-				aLR.SetWhich(nWhich);
-				rSet.Put(aLR);
-			}
-        break;
-		}
+                break;
+            }
+
         case SID_RULER_BORDER_DISTANCE:
-        {
-            nLeftBorderDistance = 0;
-            nRightBorderDistance = 0;
-            if ( nSelType & nsSelectionType::SEL_GRF ||
-					nSelType & nsSelectionType::SEL_FRM ||
-					nSelType & nsSelectionType::SEL_OLE ||
-					nFrmType == FRMTYPE_DRAWOBJ )
-                rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
-			else
-			{
-                SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
-                if(nFrmType & FRMTYPE_FLY_ANY)
-				{
-					if( IsTabColFromDoc() )
-					{
-                        const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
-                        aDistLR.SetLeft(rFlyPrtRect.Left());
-                        aDistLR.SetRight(rFlyPrtRect.Left());
-					}
-					else
-					{
-						SfxItemSet aCoreSet2( GetPool(),
-												RES_BOX, RES_BOX,
-												SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+            {
+                nLeftBorderDistance = 0;
+                nRightBorderDistance = 0;
+                if ( nSelType & nsSelectionType::SEL_GRF ||
+                    nSelType & nsSelectionType::SEL_FRM ||
+                    nSelType & nsSelectionType::SEL_OLE ||
+                    nFrmType == FRMTYPE_DRAWOBJ )
+                    rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
+                else
+                {
+                    SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
+                    if(nFrmType & FRMTYPE_FLY_ANY)
+                    {
+                        if( IsTabColFromDoc() )
+                        {
+                            const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
+                            aDistLR.SetLeft(rFlyPrtRect.Left());
+                            aDistLR.SetRight(rFlyPrtRect.Left());
+                        }
+                        else
+                        {
+                            SfxItemSet aCoreSet2( GetPool(),
+                                RES_BOX, RES_BOX,
+                                SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+                            SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
+                            aCoreSet.Put( aBoxInfo );
+                            rSh.GetFlyFrmAttr( aCoreSet );
+                            const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
+                            aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
+                            aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
+
+                            //add the paragraph border distance
+                            SfxItemSet aCoreSet1( GetPool(),
+                                RES_BOX, RES_BOX,
+                                0 );
+                            rSh.GetCurAttr( aCoreSet1 );
+                            const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
+                            aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
+                            aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
+                        }
+                        rSet.Put(aDistLR);
+                        nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
+                        nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+                    }
+                    else if ( IsTabColFromDoc() ||
+                        ( rSh.GetTableFmt() && !bFrmSelection &&
+                        !(nFrmType & FRMTYPE_COLSECT ) ) )
+                    {
+                        SfxItemSet aCoreSet2( GetPool(),
+                            RES_BOX, RES_BOX,
+                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
                         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
-						aCoreSet.Put( aBoxInfo );
-						rSh.GetFlyFrmAttr( aCoreSet );
-						const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
+                        aBoxInfo.SetTable(sal_False);
+                        aBoxInfo.SetDist((sal_Bool) sal_True);
+                        aCoreSet2.Put(aBoxInfo);
+                        rSh.GetTabBorders( aCoreSet2 );
+                        const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
                         aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
                         aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
 
-						//add the paragraph border distance
+                        //add the border distance of the paragraph
                         SfxItemSet aCoreSet1( GetPool(),
-                                                RES_BOX, RES_BOX,
-                                                0 );
+                            RES_BOX, RES_BOX,
+                            0 );
                         rSh.GetCurAttr( aCoreSet1 );
                         const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
-						aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
-						aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
-					}
-                    rSet.Put(aDistLR);
-                    nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
-                    nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
-                }
-                else if ( IsTabColFromDoc() ||
-					( rSh.GetTableFmt() && !bFrmSelection &&
-					!(nFrmType & FRMTYPE_COLSECT ) ) )
-                {
-                    SfxItemSet aCoreSet2( GetPool(),
-                                            RES_BOX, RES_BOX,
-                                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
-                    SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
-                    aBoxInfo.SetTable(sal_False);
-                    aBoxInfo.SetDist((sal_Bool) sal_True);
-                    aCoreSet2.Put(aBoxInfo);
-                    rSh.GetTabBorders( aCoreSet2 );
-                    const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
-                    aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
-                    aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
-
-                    //add the border distance of the paragraph
-                    SfxItemSet aCoreSet1( GetPool(),
-                                            RES_BOX, RES_BOX,
-                                            0 );
-                    rSh.GetCurAttr( aCoreSet1 );
-                    const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
-                    aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
-                    aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
-                    rSet.Put(aDistLR);
-                    nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
-                    nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
-                }
-                else if ( !rSh.IsDirectlyInSection() )
-                {
-                    //get the page/header/footer border distance
-                    const SwFrmFmt& rMaster = rDesc.GetMaster();
-                    const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
-                    aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
-                    aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
-
-                    const SvxBoxItem* pBox = 0;
-                    if(nFrmType & FRMTYPE_HEADER)
-                    {
-                        rMaster.GetHeader();
-                        const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
-                        SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
-                        if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
-                            pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
-                    }
-                    else if(nFrmType & FRMTYPE_FOOTER )
-                    {
-                        const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
-                        SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
-                        if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
-                            pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
-                    }
-                    if(pBox)
-                    {
-                        aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT ));
-                        aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT));
-                    }
-
-                    //add the border distance of the paragraph
-                    SfxItemSet aCoreSetTmp( GetPool(),
-                                            RES_BOX, RES_BOX,
-                                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
-                    rSh.GetCurAttr( aCoreSetTmp );
-                    const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
-                    aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
-                    aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
-                    rSet.Put(aDistLR);
-                    nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
-                    nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+                        aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
+                        aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
+                        rSet.Put(aDistLR);
+                        nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
+                        nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+                    }
+                    else if ( !rSh.IsDirectlyInSection() )
+                    {
+                        //get the page/header/footer border distance
+                        const SwFrmFmt& rMaster = rDesc.GetMaster();
+                        const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
+                        aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
+                        aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
+
+                        const SvxBoxItem* pBox = 0;
+                        if(nFrmType & FRMTYPE_HEADER)
+                        {
+                            rMaster.GetHeader();
+                            const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
+                            SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
+                            if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+                                pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
+                        }
+                        else if(nFrmType & FRMTYPE_FOOTER )
+                        {
+                            const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
+                            SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
+                            if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
+                                pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
+                        }
+                        if(pBox)
+                        {
+                            aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT ));
+                            aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT));
+                        }
+
+                        //add the border distance of the paragraph
+                        SfxItemSet aCoreSetTmp( GetPool(),
+                            RES_BOX, RES_BOX,
+                            SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
+                        rSh.GetCurAttr( aCoreSetTmp );
+                        const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
+                        aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
+                        aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
+                        rSet.Put(aDistLR);
+                        nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
+                        nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
+                    }
                 }
             }
-        }
-        break;
+            break;
+
         case SID_RULER_TEXT_RIGHT_TO_LEFT:
-        {
-            if ( nSelType & nsSelectionType::SEL_GRF ||
-					nSelType & nsSelectionType::SEL_FRM ||
-					nSelType & nsSelectionType::SEL_OLE ||
-                    nFrmType == FRMTYPE_DRAWOBJ)
-                rSet.DisableItem(nWhich);
-            else
             {
-                sal_Bool bFlag = rSh.IsInRightToLeftText();
-                rSet.Put(SfxBoolItem(nWhich, bFlag));
+                if ( nSelType & nsSelectionType::SEL_GRF ||
+                    nSelType & nsSelectionType::SEL_FRM ||
+                    nSelType & nsSelectionType::SEL_OLE ||
+                    nFrmType == FRMTYPE_DRAWOBJ)
+                    rSet.DisableItem(nWhich);
+                else
+                {
+                    sal_Bool bFlag = rSh.IsInRightToLeftText();
+                    rSet.Put(SfxBoolItem(nWhich, bFlag));
+                }
             }
-        }
-        break;
+            break;
+
         case SID_RULER_BORDERS_VERTICAL:
         case SID_RULER_BORDERS:
-		{
-            sal_Bool bFrameHasVerticalColumns(sal_False);
             {
-                sal_Bool bFrameRTL;
-                sal_Bool bFrameVertL2R;
-                bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
-                                           bFrmSelection;
-            }
-            sal_Bool bHasTable = ( IsTabColFromDoc() ||
+                sal_Bool bFrameHasVerticalColumns(sal_False);
+                {
+                    sal_Bool bFrameRTL;
+                    sal_Bool bFrameVertL2R;
+                    bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
+                        bFrmSelection;
+                }

[... 1094 lines stripped ...]