LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/uiview - viewtab.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 257 1100 23.4 %
Date: 2013-07-09 Functions: 5 10 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <hintids.hxx>
      22             : #include "uitool.hxx"
      23             : #include <sfx2/app.hxx>
      24             : #include <svx/rulritem.hxx>
      25             : #include <editeng/tstpitem.hxx>
      26             : #include <sfx2/request.hxx>
      27             : #include <editeng/lrspitem.hxx>
      28             : #include <editeng/ulspitem.hxx>
      29             : #include <editeng/boxitem.hxx>
      30             : #include <editeng/frmdiritem.hxx>
      31             : #include <svl/eitem.hxx>
      32             : #include <svl/whiter.hxx>
      33             : #include <svx/ruler.hxx>
      34             : #include <editeng/protitem.hxx>
      35             : #include <svl/rectitem.hxx>
      36             : #include <sfx2/bindings.hxx>
      37             : #include <fmtfsize.hxx>
      38             : #include <fmthdft.hxx>
      39             : #include <fmtclds.hxx>
      40             : #include <fmtornt.hxx>
      41             : #include <frmatr.hxx>
      42             : #include <edtwin.hxx>
      43             : #include "view.hxx"
      44             : #include "wrtsh.hxx"
      45             : #include "basesh.hxx"
      46             : #include "cmdid.h"
      47             : #include "viewopt.hxx"
      48             : #include "tabcol.hxx"
      49             : #include "frmfmt.hxx"       // FrameFormat
      50             : #include "pagedesc.hxx"     // Aktuelles Seitenformat
      51             : #include "wview.hxx"
      52             : #include "fmtcol.hxx"
      53             : #include "section.hxx"
      54             : 
      55             : #include "ndtxt.hxx"
      56             : #include "pam.hxx"
      57             : 
      58             : #include <IDocumentSettingAccess.hxx>
      59             : 
      60             : using namespace ::com::sun::star;
      61             : 
      62             : 
      63             : /*--------------------------------------------------------------------
      64             :     Beschreibung:   Debug-Methode
      65             :  --------------------------------------------------------------------*/
      66             : 
      67             : /*--------------------------------------------------------------------
      68             :     Beschreibung:   Columns eintueten
      69             :  --------------------------------------------------------------------*/
      70           0 : static void lcl_FillSvxColumn(const SwFmtCol& rCol,
      71             :                           sal_uInt16 nTotalWidth,
      72             :                           SvxColumnItem& rColItem,
      73             :                           long nDistance)
      74             : {
      75           0 :     const SwColumns& rCols = rCol.GetColumns();
      76           0 :     sal_uInt16 nWidth = 0;
      77             : 
      78           0 :     bool bOrtho = rCol.IsOrtho() && rCols.size();
      79           0 :     long nInnerWidth = 0;
      80           0 :     if( bOrtho )
      81             :     {
      82           0 :         nInnerWidth = nTotalWidth;
      83           0 :         for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
      84             :         {
      85           0 :             const SwColumn* pCol = &rCols[i];
      86           0 :             nInnerWidth -= pCol->GetLeft() + pCol->GetRight();
      87             :         }
      88           0 :         if( nInnerWidth < 0 )
      89           0 :             nInnerWidth = 0;
      90             :         else
      91           0 :             nInnerWidth /= rCols.size();
      92             :     }
      93           0 :     for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
      94             :     {
      95           0 :         const SwColumn* pCol = &rCols[i];
      96           0 :         const sal_uInt16 nStart = sal_uInt16(pCol->GetLeft() + nWidth + nDistance);
      97           0 :         if( bOrtho )
      98           0 :             nWidth = static_cast< sal_uInt16 >(nWidth + nInnerWidth + pCol->GetLeft() + pCol->GetRight());
      99             :         else
     100           0 :             nWidth = static_cast< sal_uInt16 >(nWidth + rCol.CalcColWidth(i, nTotalWidth));
     101           0 :         const sal_uInt16 nEnd = sal_uInt16(nWidth - pCol->GetRight() + nDistance);
     102             : 
     103           0 :         SvxColumnDescription aColDesc(nStart, nEnd, sal_True);
     104           0 :         rColItem.Append(aColDesc);
     105             :     }
     106           0 : }
     107             : 
     108             : /*--------------------------------------------------------------------
     109             :     Beschreibung:   ColumnItem in ColumnInfo ueberfuehren
     110             :  --------------------------------------------------------------------*/
     111           0 : static void lcl_ConvertToCols(const SvxColumnItem& rColItem,
     112             :                           sal_uInt16 nTotalWidth,
     113             :                           SwFmtCol& rCols)
     114             : {
     115             :     OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
     116             :     // ruler executes that change the columns shortly after the selection has changed
     117             :     // can result in a crash
     118           0 :     if(rCols.GetNumCols() != rColItem.Count())
     119           0 :         return;
     120             : 
     121           0 :     sal_uInt16 nLeft    = 0;
     122           0 :     SwTwips nSumAll= 0;  // Summiere alle Spalten und Raender auf
     123             : 
     124           0 :     SwColumns& rArr = rCols.GetColumns();
     125             : 
     126             :     // Tabcols der Reihe nach
     127           0 :     for( sal_uInt16 i=0; i < rColItem.Count()-1; ++i )
     128             :     {
     129             :         OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" );
     130           0 :         sal_uInt16 nStart = static_cast< sal_uInt16 >(rColItem[i+1].nStart);
     131           0 :         sal_uInt16 nEnd = static_cast< sal_uInt16 >(rColItem[i].nEnd);
     132           0 :         if(nStart < nEnd)
     133           0 :             nStart = nEnd;
     134           0 :         const sal_uInt16 nDiff  = nStart - nEnd;
     135           0 :         const sal_uInt16 nRight = nDiff / 2;
     136             : 
     137           0 :         sal_uInt16 nWidth = static_cast< sal_uInt16 >(rColItem[i].nEnd - rColItem[i].nStart);
     138           0 :         nWidth += nLeft + nRight;
     139             : 
     140           0 :         SwColumn* pCol = &rArr[i];
     141           0 :         pCol->SetWishWidth( sal_uInt16(long(rCols.GetWishWidth()) * long(nWidth) /
     142           0 :                                                             long(nTotalWidth) ));
     143           0 :         pCol->SetLeft( nLeft );
     144           0 :         pCol->SetRight( nRight );
     145           0 :         nSumAll += pCol->GetWishWidth();
     146             : 
     147           0 :         nLeft = nRight;
     148             :     }
     149           0 :     rArr[rColItem.Count()-1].SetLeft( nLeft );
     150             : 
     151             :     //Die Differenz aus der Gesamtwunschbreite und der Summe der bisher berechneten
     152             :     // Spalten und Raender sollte die Breite der letzten Spalte ergeben.
     153           0 :     rArr[rColItem.Count()-1].SetWishWidth( rCols.GetWishWidth() - (sal_uInt16)nSumAll );
     154             : 
     155           0 :     rCols.SetOrtho(sal_False, 0, 0 );
     156             : }
     157             : 
     158             : /*--------------------------------------------------------------------
     159             :     Beschreibung:   Tabs loeschen
     160             :  --------------------------------------------------------------------*/
     161         261 : static void lcl_EraseDefTabs(SvxTabStopItem& rTabStops)
     162             : {
     163             :     // Def Tabs loeschen
     164         783 :     for ( sal_uInt16 i = 0; i < rTabStops.Count(); )
     165             :     {
     166             :         // Hier auch den DefTab auf Null rausschmeissen
     167         261 :         if ( SVX_TAB_ADJUST_DEFAULT == rTabStops[i].GetAdjustment() ||
     168           0 :             rTabStops[i].GetTabPos() == 0 )
     169             :         {
     170         261 :             rTabStops.Remove(i);
     171         261 :             continue;
     172             :         }
     173           0 :         ++i;
     174             :     }
     175         261 : }
     176             : 
     177             : /*--------------------------------------------------------------------
     178             :     Beschreibung:   Seitenrand umdrehen
     179             :  --------------------------------------------------------------------*/
     180         270 : void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
     181             : {
     182             :     sal_uInt16 nPhyPage, nVirPage;
     183         270 :     GetWrtShell().GetPageNum( nPhyPage, nVirPage );
     184             : 
     185         270 :     if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
     186             :     {
     187           0 :         long nTmp = rLRSpace.GetRight();
     188           0 :         rLRSpace.SetRight( rLRSpace.GetLeft() );
     189           0 :         rLRSpace.SetLeft( nTmp );
     190             :     }
     191         270 : }
     192             : 
     193             : /*--------------------------------------------------------------------
     194             :     Beschreibung:   Wenn der Rahmenrand verschoben wird, sollen die
     195             :                     Spaltentrenner an der gleichen absoluten Position bleiben
     196             :  --------------------------------------------------------------------*/
     197           0 : static void lcl_Scale(long& nVal, long nScale)
     198             : {
     199           0 :     nVal *= nScale;
     200           0 :     nVal >>= 8;
     201           0 : }
     202             : 
     203           0 : void ResizeFrameCols(SwFmtCol& rCol,
     204             :                     long nOldWidth,
     205             :                     long nNewWidth,
     206             :                     long nLeftDelta )
     207             : {
     208           0 :     SwColumns& rArr = rCol.GetColumns();
     209           0 :     long nWishSum = (long)rCol.GetWishWidth();
     210           0 :     long nWishDiff = (nWishSum * 100/nOldWidth * nNewWidth) / 100 - nWishSum;
     211           0 :     long nNewWishWidth = nWishSum + nWishDiff;
     212           0 :     if(nNewWishWidth > 0xffffl)
     213             :     {
     214             :         // wenn die Wunschbreite zu gross wird, dann muessen alle Werte passend skaliert werden
     215           0 :         long nScale = (0xffffl << 8)/ nNewWishWidth;
     216           0 :         for(sal_uInt16 i = 0; i < rArr.size(); i++)
     217             :         {
     218           0 :             SwColumn* pCol = &rArr[i];
     219           0 :             long nVal = pCol->GetWishWidth();
     220           0 :             lcl_Scale(nVal, nScale);
     221           0 :             pCol->SetWishWidth((sal_uInt16) nVal);
     222           0 :             nVal = pCol->GetLeft();
     223           0 :             lcl_Scale(nVal, nScale);
     224           0 :             pCol->SetLeft((sal_uInt16) nVal);
     225           0 :             nVal = pCol->GetRight();
     226           0 :             lcl_Scale(nVal, nScale);
     227           0 :             pCol->SetRight((sal_uInt16) nVal);
     228             :         }
     229           0 :         lcl_Scale(nNewWishWidth, nScale);
     230           0 :         lcl_Scale(nWishDiff, nScale);
     231             :     }
     232           0 :     rCol.SetWishWidth( (sal_uInt16) (nNewWishWidth) );
     233             : 
     234           0 :     if( nLeftDelta >= 2 || nLeftDelta <= -2)
     235           0 :         rArr.front().SetWishWidth(rArr.front().GetWishWidth() + (sal_uInt16)nWishDiff);
     236             :     else
     237           0 :         rArr.back().SetWishWidth(rArr.back().GetWishWidth() + (sal_uInt16)nWishDiff);
     238             :     //reset auto width
     239           0 :     rCol.SetOrtho(sal_False, 0, 0 );
     240           0 : }
     241             : 
     242             : /*--------------------------------------------------------------------
     243             :     Beschreibung:   Hier werden alle Aenderungen der Tableiste
     244             :                     wieder in das Modell geschossen
     245             :  --------------------------------------------------------------------*/
     246           0 : void SwView::ExecTabWin( SfxRequest& rReq )
     247             : {
     248           0 :     SwWrtShell &rSh         = GetWrtShell();
     249           0 :     const sal_uInt16 nFrmType   = rSh.IsObjSelected() ?
     250             :                                     FRMTYPE_DRAWOBJ :
     251           0 :                                         rSh.GetFrmType(0,sal_True);
     252           0 :     const sal_Bool bFrmSelection = rSh.IsFrmSelected();
     253           0 :     const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
     254             : 
     255           0 :     const sal_uInt16 nSlot      = rReq.GetSlot();
     256           0 :     const SfxItemSet* pReqArgs = rReq.GetArgs();
     257           0 :     const sal_uInt16 nDescId    = rSh.GetCurPageDesc();
     258           0 :     const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
     259             : 
     260           0 :     const bool bVerticalWriting = rSh.IsInVerticalText();
     261           0 :     const SwFmtHeader& rHeaderFmt = rDesc.GetMaster().GetHeader();
     262           0 :     SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
     263             : 
     264           0 :     const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
     265           0 :     SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
     266             : 
     267           0 :     const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();
     268             : 
     269           0 :     const SwRect& rPageRect = rSh.GetAnyCurRect(RECT_PAGE);
     270           0 :     const long nPageWidth  = bBrowse ? rPageRect.Width() : rFrmSize.GetWidth();
     271           0 :     const long nPageHeight = bBrowse ? rPageRect.Height() : rFrmSize.GetHeight();
     272             : 
     273           0 :     bool bUnlockView = false;
     274           0 :     rSh.StartAllAction();
     275           0 :     bool bSect = 0 != (nFrmType & FRMTYPE_COLSECT);
     276             : 
     277           0 :     switch  (nSlot)
     278             :     {
     279             :     case SID_ATTR_LONG_LRSPACE:
     280           0 :         if ( pReqArgs )
     281             :         {
     282             :             SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)pReqArgs->
     283           0 :                                                         Get( SID_ATTR_LONG_LRSPACE ) );
     284           0 :             SvxLRSpaceItem aLR(RES_LR_SPACE);
     285           0 :             if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
     286             :             {
     287           0 :                 SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
     288           0 :                 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
     289             : 
     290           0 :                 bool bVerticalFrame(false);
     291             :                 {
     292             :                     sal_Bool bRTL;
     293             :                     sal_Bool bVertL2R;
     294           0 :                     bVerticalFrame = ( bFrmSelection &&
     295           0 :                                        rSh.IsFrmVertical(sal_True, bRTL, bVertL2R) ) ||
     296           0 :                                      ( !bFrmSelection && bVerticalWriting);
     297             :                 }
     298             :                 long nDeltaX = bVerticalFrame ?
     299           0 :                     rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
     300           0 :                     rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
     301             : 
     302           0 :                 SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
     303             :                                             RES_VERT_ORIENT, RES_HORI_ORIENT,
     304           0 :                                             RES_COL, RES_COL, 0 );
     305             : 
     306           0 :                 if(bVerticalFrame)
     307             :                 {
     308           0 :                     SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
     309           0 :                     aVertOrient.SetVertOrient(text::VertOrientation::NONE);
     310           0 :                     aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
     311           0 :                     aSet.Put( aVertOrient );
     312             :                 }
     313             :                 else
     314             :                 {
     315           0 :                     SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
     316           0 :                     aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
     317           0 :                     aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
     318           0 :                     aSet.Put( aHoriOrient );
     319             :                 }
     320             : 
     321           0 :                 SwFmtFrmSize aSize( pFmt->GetFrmSize() );
     322           0 :                 long nOldWidth = (long) aSize.GetWidth();
     323             : 
     324           0 :                 if(aSize.GetWidthPercent())
     325             :                 {
     326           0 :                     SwRect aRect;
     327           0 :                     rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
     328           0 :                     long nPrtWidth = aRect.Width();
     329           0 :                     aSize.SetWidthPercent(sal_uInt8((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
     330             :                 }
     331             :                 else
     332             :                     aSize.SetWidth( nPageWidth -
     333           0 :                             (aLongLR.GetLeft() + aLongLR.GetRight()));
     334             : 
     335           0 :                 if( nFrmType & FRMTYPE_COLUMN )
     336             :                 {
     337           0 :                     SwFmtCol aCol(pFmt->GetCol());
     338             : 
     339           0 :                     ::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
     340           0 :                     aSet.Put(aCol);
     341             :                 }
     342             : 
     343           0 :                 aSet.Put( aSize );
     344             : 
     345           0 :                 rSh.StartAction();
     346           0 :                 rSh.Push();
     347           0 :                 rSh.SetFlyFrmAttr( aSet );
     348             :                 //die Rahmenselektion wieder aufheben
     349           0 :                 if(!bFrmSelection && rSh.IsFrmSelected())
     350             :                 {
     351           0 :                     rSh.UnSelectFrm();
     352           0 :                     rSh.LeaveSelFrmMode();
     353             :                 }
     354           0 :                 rSh.Pop();
     355           0 :                 rSh.EndAction();
     356             :             }
     357           0 :             else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
     358             :             {
     359             :                 // Seitenraender rausrechnen
     360           0 :                 long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
     361           0 :                 aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
     362             : 
     363           0 :                 nOld = rDesc.GetMaster().GetLRSpace().GetRight();
     364           0 :                 aLongLR.SetRight( nOld > (sal_uInt16)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
     365           0 :                 aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
     366           0 :                 aLR.SetRight((sal_uInt16)aLongLR.GetRight());
     367             : 
     368           0 :                 if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
     369           0 :                     pHeaderFmt->SetFmtAttr( aLR );
     370           0 :                 else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
     371           0 :                     pFooterFmt->SetFmtAttr( aLR );
     372             :             }
     373           0 :             else if( nFrmType == FRMTYPE_DRAWOBJ)
     374             :             {
     375           0 :                 SwRect aRect( rSh.GetObjRect() );
     376           0 :                 aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
     377           0 :                 aRect.Right( rPageRect.Right() - aLongLR.GetRight());
     378           0 :                 rSh.SetObjRect( aRect );
     379             :             }
     380           0 :             else if(bSect || rSh.IsDirectlyInSection())
     381             :             {
     382             :                 //change the section indents and the columns if available
     383             :                 //at first determine the changes
     384           0 :                 SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
     385           0 :                 const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
     386           0 :                 aSectRect.Pos() += aTmpRect.Pos();
     387           0 :                 long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
     388           0 :                 long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
     389             :                 //change the LRSpaceItem of the section accordingly
     390           0 :                 const SwSection* pCurrSect = rSh.GetCurrSection();
     391           0 :                 const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
     392           0 :                 SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
     393           0 :                 aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
     394           0 :                 aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
     395           0 :                 SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
     396           0 :                 aSet.Put(aLRTmp);
     397             :                 //change the first/last column
     398           0 :                 if(bSect)
     399             :                 {
     400           0 :                     SwFmtCol aCols( pSectFmt->GetCol() );
     401           0 :                     long nDiffWidth = nLeftDiff + nRightDiff;
     402           0 :                     ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
     403           0 :                     aSet.Put( aCols );
     404             :                 }
     405           0 :                 SwSectionData aData(*pCurrSect);
     406           0 :                 rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
     407             :             }
     408             :             else
     409             :             {   // Seitenraender einstellen
     410           0 :                 aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
     411           0 :                 aLR.SetRight((sal_uInt16)aLongLR.GetRight());
     412           0 :                 SwapPageMargin( rDesc, aLR );
     413           0 :                 SwPageDesc aDesc( rDesc );
     414           0 :                 aDesc.GetMaster().SetFmtAttr( aLR );
     415           0 :                 rSh.ChgPageDesc( nDescId, aDesc );
     416           0 :             }
     417             :         }
     418           0 :         break;
     419             : 
     420             :     // apply new left and right margins to current page style
     421             :     case SID_ATTR_PAGE_LRSPACE:
     422           0 :         if ( pReqArgs )
     423             :         {
     424           0 :             const SvxLongLRSpaceItem aLongLR( static_cast<const SvxLongLRSpaceItem&>(pReqArgs->Get( SID_ATTR_PAGE_LRSPACE )) );
     425             : 
     426           0 :             SwPageDesc aDesc( rDesc );
     427             :             {
     428           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
     429           0 :                 aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
     430           0 :                 aLR.SetRight((sal_uInt16)aLongLR.GetRight());
     431           0 :                 SwapPageMargin( rDesc, aLR );
     432           0 :                 aDesc.GetMaster().SetFmtAttr( aLR );
     433             :             }
     434           0 :             rSh.ChgPageDesc( nDescId, aDesc );
     435             :         }
     436           0 :         break;
     437             : 
     438             :     case SID_ATTR_LONG_ULSPACE:
     439           0 :         if ( pReqArgs )
     440             :         {
     441             :             SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)pReqArgs->
     442           0 :                                                             Get( SID_ATTR_LONG_ULSPACE ));
     443             : 
     444           0 :             if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
     445             :             {
     446           0 :                 SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
     447           0 :                 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
     448           0 :                 const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
     449           0 :                 const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
     450             : 
     451           0 :                 SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
     452           0 :                                             RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
     453             :                 //which of the orientation attributes is to be put depends on the frame's environment
     454             :                 sal_Bool bRTL;
     455             :                 sal_Bool bVertL2R;
     456           0 :                 if ( ( bFrmSelection &&
     457           0 :                        rSh.IsFrmVertical(sal_True, bRTL, bVertL2R ) ) ||
     458           0 :                      ( !bFrmSelection && bVerticalWriting ) )
     459             :                 {
     460           0 :                     SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
     461           0 :                     aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
     462           0 :                     aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
     463           0 :                     aSet.Put( aHoriOrient );
     464             :                 }
     465             :                 else
     466             :                 {
     467           0 :                     SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
     468           0 :                     aVertOrient.SetVertOrient(text::VertOrientation::NONE);
     469           0 :                     aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
     470           0 :                     aSet.Put( aVertOrient );
     471             :                 }
     472           0 :                 SwFmtFrmSize aSize(pFmt->GetFrmSize());
     473           0 :                 if(aSize.GetHeightPercent())
     474             :                 {
     475           0 :                     SwRect aRect;
     476           0 :                     rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
     477           0 :                     long nPrtHeight = aRect.Height();
     478           0 :                     aSize.SetHeightPercent(sal_uInt8(nHeight * 100 /nPrtHeight));
     479             :                 }
     480             :                 else
     481           0 :                     aSize.SetHeight(nHeight );
     482             : 
     483           0 :                 aSet.Put( aSize );
     484           0 :                 rSh.SetFlyFrmAttr( aSet );
     485             :             }
     486           0 :             else if( nFrmType == FRMTYPE_DRAWOBJ )
     487             :             {
     488           0 :                 SwRect aRect( rSh.GetObjRect() );
     489           0 :                 aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
     490           0 :                 aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
     491           0 :                 rSh.SetObjRect( aRect ) ;
     492             :             }
     493           0 :             else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
     494             :             {
     495             :                 //change the section indents and the columns if available
     496             :                 //at first determine the changes
     497           0 :                 SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
     498           0 :                 const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
     499           0 :                 aSectRect.Pos() += aTmpRect.Pos();
     500           0 :                 const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
     501           0 :                 const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
     502             :                 //change the LRSpaceItem of the section accordingly
     503           0 :                 const SwSection* pCurrSect = rSh.GetCurrSection();
     504           0 :                 const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
     505           0 :                 SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
     506           0 :                 aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
     507           0 :                 aLR.SetRight(aLR.GetRight() + nRightDiff);
     508           0 :                 SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
     509           0 :                 aSet.Put(aLR);
     510             :                 //change the first/last column
     511           0 :                 if(bSect)
     512             :                 {
     513           0 :                     SwFmtCol aCols( pSectFmt->GetCol() );
     514           0 :                     long nDiffWidth = nLeftDiff + nRightDiff;
     515           0 :                     ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
     516           0 :                     aSet.Put( aCols );
     517             :                 }
     518           0 :                 SwSectionData aData(*pCurrSect);
     519           0 :                 rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
     520             :             }
     521             :             else
     522           0 :             {   SwPageDesc aDesc( rDesc );
     523             : 
     524           0 :                 if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
     525             :                 {
     526             : 
     527           0 :                     const bool bHead = nFrmType & FRMTYPE_HEADER;
     528           0 :                     SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
     529           0 :                     if ( bHead )
     530           0 :                         aUL.SetUpper( (sal_uInt16)aLongULSpace.GetUpper() );
     531             :                     else
     532           0 :                         aUL.SetLower( (sal_uInt16)aLongULSpace.GetLower() );
     533           0 :                     aDesc.GetMaster().SetFmtAttr( aUL );
     534             : 
     535           0 :                     if( (bHead && pHeaderFmt) || (!bHead && pFooterFmt) )
     536             :                     {
     537           0 :                         SwFmtFrmSize aSz( bHead ? pHeaderFmt->GetFrmSize() :
     538           0 :                                                   pFooterFmt->GetFrmSize() );
     539           0 :                         aSz.SetHeightSizeType( ATT_FIX_SIZE );
     540           0 :                         aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
     541           0 :                                                     aLongULSpace.GetUpper() );
     542           0 :                         if ( bHead )
     543           0 :                             pHeaderFmt->SetFmtAttr( aSz );
     544             :                         else
     545           0 :                             pFooterFmt->SetFmtAttr( aSz );
     546           0 :                     }
     547             :                 }
     548             :                 else
     549             :                 {
     550           0 :                     SvxULSpaceItem aUL(RES_UL_SPACE);
     551           0 :                     aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
     552           0 :                     aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
     553           0 :                     aDesc.GetMaster().SetFmtAttr(aUL);
     554             :                 }
     555             : 
     556           0 :                 rSh.ChgPageDesc( nDescId, aDesc );
     557           0 :             }
     558             :         }
     559           0 :         break;
     560             : 
     561             :     // apply new top and bottom margins to current page style
     562             :     case SID_ATTR_PAGE_ULSPACE:
     563           0 :         if ( pReqArgs )
     564             :         {
     565             :             SvxLongULSpaceItem aLongULSpace(
     566           0 :                 static_cast<const SvxLongULSpaceItem&>(pReqArgs->Get( SID_ATTR_PAGE_ULSPACE ) ) );
     567             : 
     568           0 :             SwPageDesc aDesc( rDesc );
     569             :             {
     570           0 :                 SvxULSpaceItem aUL(RES_UL_SPACE);
     571           0 :                 aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
     572           0 :                 aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
     573           0 :                 aDesc.GetMaster().SetFmtAttr(aUL);
     574             :             }
     575           0 :             rSh.ChgPageDesc( nDescId, aDesc );
     576             :         }
     577           0 :         break;
     578             : 
     579             :     case SID_ATTR_PAGE_COLUMN:
     580           0 :         if ( pReqArgs )
     581             :         {
     582           0 :             const SfxInt16Item aColumnItem( (const SfxInt16Item&)pReqArgs->Get(nSlot) );
     583           0 :             const sal_uInt16 nPageColumnType = aColumnItem.GetValue();
     584             : 
     585             :             // nPageColumnType =
     586             :             // 1 - single-columned page
     587             :             // 2 - two-columned page
     588             :             // 3 - three-columned page
     589             :             // 4 - two-columned page with left column width of 2/3 of page width
     590             :             // 5 - two-columned page with right column width of 2/3 of page width
     591             : 
     592           0 :             sal_uInt16 nCount = 2;
     593           0 :             if ( nPageColumnType == 1 )
     594             :             {
     595           0 :                 nCount = 0;
     596             :             }
     597           0 :             else if ( nPageColumnType == 3 )
     598             :             {
     599           0 :                 nCount = 3;
     600             :             }
     601             : 
     602           0 :             const sal_uInt16 nGutterWidth = 0;
     603             : 
     604           0 :             const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() );
     605           0 :             const long nLeft = aLR.GetLeft();
     606           0 :             const long nRight = aLR.GetRight();
     607           0 :             const long nWidth = nPageWidth - nLeft - nRight;
     608             : 
     609           0 :             SwFmtCol aCols( rDesc.GetMaster().GetCol() );
     610           0 :             aCols.Init( nCount, nGutterWidth, nWidth );
     611           0 :             aCols.SetWishWidth( nWidth );
     612           0 :             aCols.SetGutterWidth( nGutterWidth, nWidth );
     613           0 :             aCols.SetOrtho( sal_False, nGutterWidth, nWidth );
     614             : 
     615           0 :             long nColumnLeft = 0;
     616           0 :             long nColumnRight = 0;
     617           0 :             if ( nPageColumnType == 4 )
     618             :             {
     619           0 :                 nColumnRight = (long)(nWidth/3);
     620           0 :                 nColumnLeft = nWidth - nColumnRight;
     621           0 :                 aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
     622           0 :                 aCols.GetColumns()[1].SetWishWidth( nColumnRight );
     623             :             }
     624           0 :             else if ( nPageColumnType == 5 )
     625             :             {
     626           0 :                 nColumnLeft = (long)(nWidth/3);
     627           0 :                 nColumnRight = nWidth - nColumnLeft;
     628           0 :                 aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
     629           0 :                 aCols.GetColumns()[1].SetWishWidth( nColumnRight );
     630             :             }
     631             : 
     632           0 :             SwPageDesc aDesc( rDesc );
     633           0 :             aDesc.GetMaster().SetFmtAttr( aCols );
     634           0 :             rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
     635             :         }
     636           0 :         break;
     637             : 
     638             :     case SID_ATTR_TABSTOP_VERTICAL:
     639             :     case SID_ATTR_TABSTOP:
     640           0 :         if (pReqArgs)
     641             :         {
     642           0 :             sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
     643             :             SvxTabStopItem aTabStops( (const SvxTabStopItem&)pReqArgs->
     644           0 :                                                         Get( nWhich ));
     645           0 :             aTabStops.SetWhich(RES_PARATR_TABSTOP);
     646             :              const SvxTabStopItem& rDefTabs =
     647           0 :                         (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
     648             : 
     649             :             // Default-Tab an Pos 0
     650           0 :             SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
     651           0 :             rSh.GetCurAttr( aSet );
     652           0 :             const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);
     653             : 
     654           0 :             if ( rLR.GetTxtFirstLineOfst() < 0 )
     655             :             {
     656           0 :                 SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
     657           0 :                 aTabStops.Insert( aSwTabStop );
     658             :             }
     659             : 
     660             :             // auffuellen mit Default-Tabs
     661           0 :             sal_uInt16 nDef = ::GetTabDist( rDefTabs );
     662           0 :             ::MakeDefTabs( nDef, aTabStops );
     663             : 
     664           0 :             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
     665           0 :             if( pColl && pColl->IsAutoUpdateFmt() )
     666             :             {
     667           0 :                 SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
     668           0 :                 aTmp.Put(aTabStops);
     669           0 :                 rSh.AutoUpdatePara( pColl, aTmp );
     670             :             }
     671             :             else
     672           0 :                 rSh.SetAttr( aTabStops );
     673             :         }
     674           0 :         break;
     675             : 
     676             :     case SID_ATTR_PARA_LRSPACE_VERTICAL:
     677             :     case SID_ATTR_PARA_LRSPACE:
     678           0 :         if ( pReqArgs )
     679             :         {
     680           0 :             SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pReqArgs->Get(nSlot));
     681             : 
     682           0 :             aParaMargin.SetRight( aParaMargin.GetRight() - m_nRightBorderDistance );
     683           0 :             aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - m_nLeftBorderDistance );
     684             : 
     685           0 :             aParaMargin.SetWhich( RES_LR_SPACE );
     686           0 :             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
     687             : 
     688             :             // #i23726#
     689           0 :             if (m_pNumRuleNodeFromDoc)
     690             :             {
     691             :                 // --> #i42922# Mouse move of numbering label
     692             :                 // has to consider the left indent of the paragraph
     693           0 :                 SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
     694           0 :                 rSh.GetCurAttr( aSet );
     695             :                 const SvxLRSpaceItem& rLR =
     696           0 :                         static_cast<const SvxLRSpaceItem&>(aSet.Get(RES_LR_SPACE));
     697             : 
     698           0 :                 SwPosition aPos(*m_pNumRuleNodeFromDoc);
     699             :                 // #i90078#
     700           0 :                 rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
     701             :                 // #i42921# invalidate state of indent in order to get a ruler update.
     702           0 :                 aParaMargin.SetWhich( nSlot );
     703           0 :                 GetViewFrame()->GetBindings().SetState( aParaMargin );
     704             :             }
     705           0 :             else if( pColl && pColl->IsAutoUpdateFmt() )
     706             :             {
     707           0 :                 SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
     708           0 :                 aSet.Put(aParaMargin);
     709           0 :                 rSh.AutoUpdatePara( pColl, aSet);
     710             :             }
     711             :             else
     712           0 :                 rSh.SetAttr( aParaMargin );
     713             : 
     714           0 :             if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
     715             :             {
     716           0 :                 SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );
     717             : 
     718           0 :                 rSh.GetCurAttr( aSet );
     719           0 :                 const SvxTabStopItem&  rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);
     720             : 
     721             :                 // Haben wir einen Tab an Stelle Null
     722             :                 sal_uInt16 i;
     723             : 
     724           0 :                 for ( i = 0; i < rTabStops.Count(); ++i )
     725           0 :                     if ( rTabStops[i].GetTabPos() == 0 )
     726           0 :                         break;
     727             : 
     728           0 :                 if ( i >= rTabStops.Count() )
     729             :                 {
     730             :                     // Kein DefTab
     731           0 :                     SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
     732           0 :                     aTabStops = rTabStops;
     733             : 
     734           0 :                     ::lcl_EraseDefTabs(aTabStops);
     735             : 
     736           0 :                     SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
     737           0 :                     aTabStops.Insert(aSwTabStop);
     738             : 
     739             :                     const SvxTabStopItem& rDefTabs =
     740           0 :                         (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
     741           0 :                     sal_uInt16 nDef = ::GetTabDist(rDefTabs);
     742           0 :                     ::MakeDefTabs( nDef, aTabStops );
     743             : 
     744           0 :                     if( pColl && pColl->IsAutoUpdateFmt())
     745             :                     {
     746           0 :                         SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
     747           0 :                         aSetTmp.Put(aTabStops);
     748           0 :                         rSh.AutoUpdatePara( pColl, aSetTmp );
     749             :                     }
     750             :                     else
     751           0 :                         rSh.SetAttr( aTabStops );
     752           0 :                 }
     753           0 :             }
     754             :         }
     755           0 :         break;
     756             : 
     757             :     case SID_ATTR_PARA_ULSPACE:
     758           0 :         if ( pReqArgs )
     759             :         {
     760           0 :             SvxULSpaceItem aParaMargin((const SvxULSpaceItem&)pReqArgs->Get(nSlot));
     761             : 
     762           0 :             long nUDist = 0;
     763           0 :             long nLDist = 0;
     764           0 :             aParaMargin.SetUpper( aParaMargin.GetUpper() - nUDist );
     765           0 :             aParaMargin.SetLower(aParaMargin.GetLower() - nLDist);
     766             : 
     767           0 :             aParaMargin.SetWhich( RES_UL_SPACE );
     768           0 :             SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
     769           0 :             if( pColl && pColl->IsAutoUpdateFmt() )
     770             :             {
     771           0 :                 SfxItemSet aSet(GetPool(), RES_UL_SPACE, RES_UL_SPACE);
     772           0 :                 aSet.Put(aParaMargin);
     773           0 :                 rSh.AutoUpdatePara( pColl, aSet);
     774             :             }
     775             :             else
     776           0 :                 rSh.SetAttr( aParaMargin );
     777             :         }
     778           0 :         break;
     779             : 
     780             :     case SID_RULER_BORDERS_VERTICAL:
     781             :     case SID_RULER_BORDERS:
     782           0 :         if ( pReqArgs )
     783             :         {
     784           0 :             SvxColumnItem aColItem((const SvxColumnItem&)pReqArgs->Get(nSlot));
     785             : 
     786           0 :             if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
     787             :             {
     788             :                 OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
     789             : 
     790             :                 const sal_Bool bSingleLine = ((const SfxBoolItem&)rReq.
     791           0 :                                 GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();
     792             : 
     793           0 :                 SwTabCols aTabCols;
     794           0 :                 if ( m_bSetTabColFromDoc )
     795           0 :                     rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
     796             :                 else
     797           0 :                     rSh.GetTabCols(aTabCols);
     798             : 
     799             :                 // linker Tabellenrand
     800           0 :                 long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
     801           0 :                 aTabCols.SetLeft( nBorder );
     802             : 
     803           0 :                 nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
     804             : 
     805           0 :                 if ( aColItem.GetRight() > 0 )
     806           0 :                     aTabCols.SetRight( nBorder );
     807             : 
     808             :                 // Tabcols der Reihe nach
     809             :                 // Die letzte Col wird durch den Rand definiert
     810             :                 //columns in right-to-left tables need to be mirrored
     811             :                 sal_Bool bIsTableRTL =
     812           0 :                     IsTabColFromDoc() ?
     813           0 :                           rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
     814           0 :                         : rSh.IsTableRightToLeft();
     815           0 :                 if(bIsTableRTL)
     816             :                 {
     817           0 :                     sal_uInt16 nColCount = aColItem.Count() - 1;
     818           0 :                     for ( sal_uInt16 i = 0; i < nColCount && i < aTabCols.Count(); ++i )
     819             :                     {
     820           0 :                         const SvxColumnDescription& rCol = aColItem[nColCount - i];
     821           0 :                         aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
     822           0 :                         aTabCols.SetHidden( i, !rCol.bVisible );
     823             :                     }
     824             :                 }
     825             :                 else
     826             :                 {
     827           0 :                     for ( sal_uInt16 i = 0; i < aColItem.Count()-1 && i < aTabCols.Count(); ++i )
     828             :                     {
     829           0 :                         const SvxColumnDescription& rCol = aColItem[i];
     830           0 :                         aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
     831           0 :                         aTabCols.SetHidden( i, !rCol.bVisible );
     832             :                     }
     833             :                 }
     834             : 
     835           0 :                 if ( m_bSetTabColFromDoc )
     836             :                 {
     837           0 :                     if( !rSh.IsViewLocked() )
     838             :                     {
     839           0 :                         bUnlockView = true;
     840           0 :                         rSh.LockView( sal_True );
     841             :                     }
     842             :                     rSh.SetMouseTabCols( aTabCols, bSingleLine,
     843           0 :                                                    m_aTabColFromDocPos );
     844             :                 }
     845             :                 else
     846           0 :                     rSh.SetTabCols(aTabCols, bSingleLine);
     847             : 
     848             :             }
     849             :             else
     850             :             {
     851           0 :                 if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
     852             :                 {
     853           0 :                     SwSectionFmt *pSectFmt = 0;
     854           0 :                     SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
     855           0 :                     if(bSect)
     856             :                     {
     857           0 :                         const SwSection *pSect = rSh.GetAnySection();
     858             :                         OSL_ENSURE( pSect, "Which section?");
     859           0 :                         pSectFmt = pSect->GetFmt();
     860             :                     }
     861             :                     else
     862             :                     {
     863           0 :                         rSh.GetFlyFrmAttr( aSet );
     864             :                     }
     865             :                     SwFmtCol aCols(
     866             :                         bSect ?
     867           0 :                             pSectFmt->GetCol() :
     868           0 :                                 (const SwFmtCol&)aSet.Get( RES_COL, sal_False ));
     869           0 :                     SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
     870           0 :                     const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
     871           0 :                     ::lcl_ConvertToCols( aColItem, sal_uInt16(lWidth), aCols );
     872           0 :                     aSet.Put( aCols );
     873           0 :                     if(bSect)
     874           0 :                         rSh.SetSectionAttr( aSet, pSectFmt );
     875             :                     else
     876             :                     {
     877           0 :                         rSh.StartAction();
     878           0 :                         rSh.Push();
     879           0 :                         rSh.SetFlyFrmAttr( aSet );
     880             :                         //die Rahmenselektion wieder aufheben
     881           0 :                         if(!bFrmSelection && rSh.IsFrmSelected())
     882             :                         {
     883           0 :                             rSh.UnSelectFrm();
     884           0 :                             rSh.LeaveSelFrmMode();
     885             :                         }
     886           0 :                         rSh.Pop();
     887           0 :                         rSh.EndAction();
     888           0 :                     }
     889             :                 }
     890             :                 else
     891             :                 {
     892           0 :                     SwFmtCol aCols( rDesc.GetMaster().GetCol() );
     893           0 :                     const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
     894             :                     ::lcl_ConvertToCols( aColItem,
     895           0 :                         sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
     896           0 :                                     aCols );
     897           0 :                     SwPageDesc aDesc( rDesc );
     898           0 :                     aDesc.GetMaster().SetFmtAttr( aCols );
     899           0 :                     rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
     900             :                 }
     901           0 :             }
     902             :         }
     903           0 :         break;
     904             : 
     905             :     case SID_RULER_ROWS :
     906             :     case SID_RULER_ROWS_VERTICAL:
     907           0 :         if (pReqArgs)
     908             :         {
     909           0 :             SvxColumnItem aColItem((const SvxColumnItem&)pReqArgs->Get(nSlot));
     910             : 
     911           0 :             if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
     912             :             {
     913             :                 OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
     914             : 
     915           0 :                 SwTabCols aTabCols;
     916           0 :                 if ( m_bSetTabRowFromDoc )
     917           0 :                     rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
     918             :                 else
     919           0 :                     rSh.GetTabRows(aTabCols);
     920             : 
     921           0 :                 if ( bVerticalWriting )
     922             :                 {
     923           0 :                     aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
     924           0 :                     aTabCols.SetLeftMin(aColItem.GetLeft());
     925             :                 }
     926             :                 else
     927             :                 {
     928           0 :                     long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
     929           0 :                     aTabCols.SetRight( nBorder );
     930             :                 }
     931             : 
     932           0 :                 if(bVerticalWriting)
     933             :                 {
     934           0 :                     for ( sal_uInt16 i = aColItem.Count() - 1; i; --i )
     935             :                     {
     936           0 :                         const SvxColumnDescription& rCol = aColItem[i - 1];
     937           0 :                         long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
     938           0 :                         aTabCols[i - 1] = nColumnPos;
     939           0 :                         aTabCols.SetHidden( i - 1, !rCol.bVisible );
     940             :                     }
     941             :                 }
     942             :                 else
     943             :                 {
     944           0 :                     for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
     945             :                     {
     946           0 :                         const SvxColumnDescription& rCol = aColItem[i];
     947           0 :                         aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
     948           0 :                         aTabCols.SetHidden( i, !rCol.bVisible );
     949             :                     }
     950             :                 }
     951           0 :                 sal_Bool bSingleLine = sal_False;
     952             :                 const SfxPoolItem* pSingleLine;
     953           0 :                 if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, sal_False, &pSingleLine))
     954           0 :                     bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
     955           0 :                 if ( m_bSetTabRowFromDoc )
     956             :                 {
     957           0 :                     if( !rSh.IsViewLocked() )
     958             :                     {
     959           0 :                         bUnlockView = true;
     960           0 :                         rSh.LockView( sal_True );
     961             :                     }
     962           0 :                     rSh.SetMouseTabRows( aTabCols, bSingleLine, m_aTabColFromDocPos );
     963             :                 }
     964             :                 else
     965           0 :                     rSh.SetTabRows(aTabCols, bSingleLine);
     966           0 :             }
     967             :         }
     968           0 :         break;
     969             : 
     970             :     default:
     971             :         OSL_ENSURE( !this, "wrong SlotId");
     972             :     }
     973           0 :     rSh.EndAllAction();
     974             : 
     975           0 :     if( bUnlockView )
     976           0 :         rSh.LockView( sal_False );
     977             : 
     978           0 :     m_bSetTabColFromDoc = m_bSetTabRowFromDoc = m_bTabColFromDoc = m_bTabRowFromDoc = sal_False;
     979           0 :     SetNumRuleNodeFromDoc(NULL);
     980           0 : }
     981             : 
     982             : /*--------------------------------------------------------------------
     983             :     Beschreibung:   Hier wird der Status der Tableiste ermittelt
     984             :                     sprich alle relevanten Attribute an der CursorPos
     985             :                     werden der Tableiste uebermittelt
     986             :  --------------------------------------------------------------------*/
     987         270 : void SwView::StateTabWin(SfxItemSet& rSet)
     988             : {
     989         270 :     SwWrtShell &rSh         = GetWrtShell();
     990             : 
     991         270 :     const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &m_aTabColFromDocPos : 0;
     992         270 :     const sal_uInt16 nFrmType   = rSh.IsObjSelected()
     993             :                 ? FRMTYPE_DRAWOBJ
     994         270 :                 : rSh.GetFrmType( pPt, sal_True );
     995             : 
     996         270 :     const sal_Bool  bFrmSelection = rSh.IsFrmSelected();
     997         270 :     const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
     998             :     // PageOffset/Begrenzer
     999         270 :     const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
    1000         270 :     const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
    1001         270 :     const long nPageWidth  = rPageRect.Width();
    1002         270 :     const long nPageHeight = rPageRect.Height();
    1003             : 
    1004             :     const SwPageDesc& rDesc = rSh.GetPageDesc(
    1005         540 :                 IsTabColFromDoc() || m_bTabRowFromDoc ?
    1006         270 :                     rSh.GetMousePageDesc(m_aTabColFromDocPos) : rSh.GetCurPageDesc() );
    1007             : 
    1008         270 :     const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrmDir();
    1009         270 :     const bool bVerticalWriting = rSh.IsInVerticalText();
    1010             : 
    1011             :     //enable tab stop display on the rulers depending on the writing direction
    1012         270 :     WinBits nRulerStyle = m_pHRuler->GetStyle() & ~WB_EXTRAFIELD;
    1013         270 :     m_pHRuler->SetStyle(bVerticalWriting||bBrowse ? nRulerStyle : nRulerStyle|WB_EXTRAFIELD);
    1014         270 :     nRulerStyle = m_pVRuler->GetStyle() & ~WB_EXTRAFIELD;
    1015         270 :     m_pVRuler->SetStyle(bVerticalWriting ? nRulerStyle|WB_EXTRAFIELD : nRulerStyle);
    1016             : 
    1017             :     //#i24363# tab stops relative to indent
    1018         270 :     bool bRelative = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
    1019         270 :     m_pHRuler->SetTabsRelativeToIndent( bRelative );
    1020         270 :     m_pVRuler->SetTabsRelativeToIndent( bRelative );
    1021             : 
    1022         270 :     SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
    1023         270 :     SwapPageMargin( rDesc, aPageLRSpace );
    1024             : 
    1025         270 :     SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
    1026         540 :                                     RES_LR_SPACE,        RES_UL_SPACE, 0 );
    1027             :     // get also the list level indent values merged as LR-SPACE item, if needed.
    1028         270 :     rSh.GetCurAttr( aCoreSet, true );
    1029         270 :     SelectionType nSelType = rSh.GetSelectionType();
    1030             : 
    1031         540 :     SfxWhichIter aIter( rSet );
    1032         270 :     sal_uInt16 nWhich = aIter.FirstWhich();
    1033         270 :     bool bPutContentProtection = false;
    1034             : 
    1035        4280 :     while ( nWhich )
    1036             :     {
    1037        3740 :         switch ( nWhich )
    1038             :         {
    1039             : 
    1040             :         case SID_ATTR_PAGE_COLUMN:
    1041             :         {
    1042           0 :             sal_uInt16 nColumnType = 0;
    1043             : 
    1044           0 :             const SwFrmFmt& rMaster = rDesc.GetMaster();
    1045           0 :             SwFmtCol aCol(rMaster.GetCol());
    1046           0 :             const sal_uInt16 nCols = aCol.GetNumCols();
    1047           0 :             if ( nCols == 0 )
    1048             :             {
    1049           0 :                 nColumnType = 1;
    1050             :             }
    1051           0 :             else if ( nCols == 2 )
    1052             :             {
    1053           0 :                 const sal_uInt16 nColLeft = aCol.CalcPrtColWidth(0, aCol.GetWishWidth());
    1054           0 :                 const sal_uInt16 nColRight = aCol.CalcPrtColWidth(1, aCol.GetWishWidth());
    1055             : 
    1056           0 :                 if ( abs(nColLeft - nColRight) <= 10 )
    1057             :                 {
    1058           0 :                     nColumnType = 2;
    1059             :                 }
    1060           0 :                 else if( abs(nColLeft - nColRight*2) < 20 )
    1061             :                 {
    1062           0 :                     nColumnType = 4;
    1063             :                 }
    1064           0 :                 else if( abs(nColLeft*2 - nColRight) < 20 )
    1065             :                 {
    1066           0 :                     nColumnType = 5;
    1067             :                 }
    1068             :             }
    1069           0 :             else if( nCols == 3 )
    1070             :             {
    1071           0 :                 nColumnType = 3;
    1072             :             }
    1073             : 
    1074           0 :             rSet.Put( SfxInt16Item( SID_ATTR_PAGE_COLUMN, nColumnType ) );
    1075             :         }
    1076           0 :         break;
    1077             : 
    1078             :         case SID_ATTR_LONG_LRSPACE:
    1079             :         {
    1080             :             SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
    1081             :                                         (long)aPageLRSpace.GetRight(),
    1082         268 :                                         SID_ATTR_LONG_LRSPACE);
    1083         268 :             if(bBrowse)
    1084             :             {
    1085           2 :                 aLongLR.SetLeft(rPagePrtRect.Left());
    1086           2 :                 aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
    1087             :             }
    1088         268 :             if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
    1089           0 :                  !(nFrmType & FRMTYPE_COLSECT) )
    1090             :             {
    1091           0 :                 SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
    1092           0 :                                 rDesc.GetMaster().GetHeader().GetHeaderFmt() :
    1093           0 :                                 rDesc.GetMaster().GetFooter().GetFooterFmt());
    1094           0 :                 if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
    1095             :                 {
    1096           0 :                     SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
    1097           0 :                     aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
    1098           0 :                     const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
    1099           0 :                     aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
    1100           0 :                     aLongLR.SetRight( (nPageWidth -
    1101           0 :                                         (long)aRect.Right() + (long)aLR.GetRight()));
    1102           0 :                 }
    1103             :             }
    1104             :             else
    1105             :             {
    1106         268 :                 SwRect aRect;
    1107         268 :                 if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
    1108             :                 {
    1109           0 :                     aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
    1110           0 :                     const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
    1111           0 :                     aRect.Pos() += aTmpRect.Pos();
    1112             :                 }
    1113             : 
    1114         268 :                 else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
    1115           0 :                     aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
    1116         268 :                 else if( nFrmType & FRMTYPE_DRAWOBJ)
    1117           0 :                     aRect = rSh.GetObjRect();
    1118             : 
    1119         268 :                 if( aRect.Width() )
    1120             :                 {
    1121             :                     // make relative to page position:
    1122           0 :                     aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
    1123           0 :                     aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
    1124             :                 }
    1125             :             }
    1126         268 :             if( nWhich == SID_ATTR_LONG_LRSPACE )
    1127         268 :                 rSet.Put( aLongLR );
    1128             :             else
    1129             :             {
    1130             :                 SvxLRSpaceItem aLR( aLongLR.GetLeft(),
    1131             :                                     aLongLR.GetRight(),
    1132             :                                     0, 0,
    1133           0 :                                     nWhich);
    1134           0 :                 rSet.Put(aLR);
    1135             :             }
    1136         268 :             break;
    1137             :         }
    1138             : 
    1139             :         // provide left and right margins of current page style
    1140             :         case SID_ATTR_PAGE_LRSPACE:
    1141             :         {
    1142           0 :             const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
    1143             :             const SvxLongLRSpaceItem aLongLR(
    1144             :                 (long)aTmpPageLRSpace.GetLeft(),
    1145             :                 (long)aTmpPageLRSpace.GetRight(),
    1146           0 :                 SID_ATTR_PAGE_LRSPACE );
    1147           0 :             rSet.Put( aLongLR );
    1148             :         }
    1149           0 :         break;
    1150             : 
    1151             :         case SID_ATTR_LONG_ULSPACE:
    1152             :         {
    1153             :             // Rand Seite Oben Unten
    1154         268 :             SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
    1155         268 :             SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
    1156         268 :                                         (long)aUL.GetLower(),
    1157         804 :                                         SID_ATTR_LONG_ULSPACE);
    1158             : 
    1159         268 :             if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
    1160             :             {
    1161             :                 // Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
    1162           0 :                 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
    1163           0 :                 aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() ));
    1164           0 :                 aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() ));
    1165             :             }
    1166         268 :             else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
    1167             :             {
    1168           0 :                 SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
    1169           0 :                 aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
    1170           0 :                 aLongUL.SetUpper( (sal_uInt16)aRect.Top() );
    1171           0 :                 aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) );
    1172             :             }
    1173         268 :             else if( nFrmType & FRMTYPE_DRAWOBJ)
    1174             :             {
    1175           0 :                 const SwRect &rRect = rSh.GetObjRect();
    1176           0 :                 aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
    1177           0 :                 aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
    1178             :             }
    1179         268 :             else if(bBrowse)
    1180             :             {
    1181           2 :                 aLongUL.SetUpper(rPagePrtRect.Top());
    1182           2 :                 aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
    1183             :             }
    1184         268 :             if( nWhich == SID_ATTR_LONG_ULSPACE )
    1185         268 :                 rSet.Put( aLongUL );
    1186             :             else
    1187             :             {
    1188           0 :                 SvxULSpaceItem aULTmp((sal_uInt16)aLongUL.GetUpper(),
    1189           0 :                                       (sal_uInt16)aLongUL.GetLower(),
    1190           0 :                                       nWhich);
    1191           0 :                 rSet.Put(aULTmp);
    1192             :             }
    1193         536 :             break;
    1194             :         }
    1195             : 
    1196             :         // provide top and bottom margins of current page style
    1197             :         case SID_ATTR_PAGE_ULSPACE:
    1198             :         {
    1199           0 :             const SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
    1200             :             SvxLongULSpaceItem aLongUL(
    1201           0 :                 (long)aUL.GetUpper(),
    1202           0 :                 (long)aUL.GetLower(),
    1203           0 :                 SID_ATTR_PAGE_ULSPACE );
    1204             : 
    1205           0 :             rSet.Put( aLongUL );
    1206             :         }
    1207           0 :         break;
    1208             : 
    1209             :         case SID_ATTR_TABSTOP_VERTICAL :
    1210             :         case RES_PARATR_TABSTOP:
    1211             :         {
    1212        1570 :             if ( ISA( SwWebView ) ||
    1213        1044 :                  IsTabColFromDoc() ||
    1214        1044 :                  IsTabRowFromDoc() ||
    1215        1044 :                  ( nSelType & nsSelectionType::SEL_GRF ) ||
    1216        1044 :                  ( nSelType & nsSelectionType::SEL_FRM ) ||
    1217        1044 :                  ( nSelType & nsSelectionType::SEL_OLE ) ||
    1218        1044 :                  ( SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE) ) ||
    1219        1831 :                  (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich) ) ||
    1220           0 :                  ( bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
    1221             :                )
    1222         263 :                 rSet.DisableItem( nWhich );
    1223             :             else
    1224             :             {
    1225             :                 SvxTabStopItem aTabStops((const SvxTabStopItem&)
    1226         261 :                                             aCoreSet.Get( RES_PARATR_TABSTOP ));
    1227             : 
    1228             :                 const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
    1229         261 :                                             rSh.GetDefault(RES_PARATR_TABSTOP);
    1230             : 
    1231             :                 OSL_ENSURE(m_pHRuler, "why is there no ruler?");
    1232         261 :                 long nDefTabDist = ::GetTabDist(rDefTabs);
    1233         261 :                 m_pHRuler->SetDefTabDist( nDefTabDist );
    1234         261 :                 m_pVRuler->SetDefTabDist( nDefTabDist );
    1235         261 :                 ::lcl_EraseDefTabs(aTabStops);
    1236         261 :                 rSet.Put(aTabStops, nWhich);
    1237             :             }
    1238         524 :             break;
    1239             :         }
    1240             : 
    1241             :         case SID_ATTR_PARA_LRSPACE_VERTICAL:
    1242             :         case SID_ATTR_PARA_LRSPACE:
    1243             :         {
    1244         536 :             if ( nSelType & nsSelectionType::SEL_GRF ||
    1245         536 :                  nSelType & nsSelectionType::SEL_FRM ||
    1246         536 :                  nSelType & nsSelectionType::SEL_OLE ||
    1247         268 :                  nFrmType == FRMTYPE_DRAWOBJ ||
    1248         536 :                  (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich)) ||
    1249           0 :                  ( bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
    1250             :                 )
    1251             :             {
    1252         268 :                 rSet.DisableItem(nWhich);
    1253             :             }
    1254             :             else
    1255             :             {
    1256           0 :                 SvxLRSpaceItem aLR( RES_LR_SPACE );
    1257           0 :                 if ( !IsTabColFromDoc() )
    1258             :                 {
    1259           0 :                     aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
    1260             : 
    1261             :                     // #i23726#
    1262           0 :                     if (m_pNumRuleNodeFromDoc)
    1263             :                     {
    1264           0 :                         short nOffset = static_cast< short >(aLR.GetTxtLeft() +
    1265             :                                         // #i42922# Mouse move of numbering label
    1266             :                                         // has to consider the left indent of the paragraph
    1267           0 :                                         m_pNumRuleNodeFromDoc->GetLeftMarginWithNum( sal_True ) );
    1268             : 
    1269             :                         short nFLOffset;
    1270           0 :                         m_pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
    1271             : 
    1272           0 :                         aLR.SetLeft( nOffset + nFLOffset );
    1273             :                     }
    1274             :                 }
    1275           0 :                 aLR.SetWhich(nWhich);
    1276           0 :                 rSet.Put(aLR);
    1277             :             }
    1278         268 :         break;
    1279             :         }
    1280             : 
    1281             :         case SID_ATTR_PARA_ULSPACE:
    1282             :         {
    1283           0 :             SvxULSpaceItem aUL = (const SvxULSpaceItem&)aCoreSet.Get(RES_UL_SPACE);
    1284           0 :             aUL.SetWhich(nWhich);
    1285             : 
    1286           0 :             SfxItemState e = aCoreSet.GetItemState(RES_UL_SPACE);
    1287           0 :             if( e >= SFX_ITEM_AVAILABLE )
    1288           0 :                 rSet.Put( aUL );
    1289             :             else
    1290           0 :                 rSet.InvalidateItem(nWhich);
    1291             :         }
    1292           0 :         break;
    1293             : 
    1294             :         case SID_RULER_BORDER_DISTANCE:
    1295             :         {
    1296         268 :             m_nLeftBorderDistance = 0;
    1297         268 :             m_nRightBorderDistance = 0;
    1298         536 :             if ( nSelType & nsSelectionType::SEL_GRF ||
    1299         536 :                     nSelType & nsSelectionType::SEL_FRM ||
    1300         536 :                     nSelType & nsSelectionType::SEL_OLE ||
    1301             :                     nFrmType == FRMTYPE_DRAWOBJ )
    1302           0 :                 rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
    1303             :             else
    1304             :             {
    1305         268 :                 SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
    1306         268 :                 if(nFrmType & FRMTYPE_FLY_ANY)
    1307             :                 {
    1308           0 :                     if( IsTabColFromDoc() )
    1309             :                     {
    1310           0 :                         const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
    1311           0 :                         aDistLR.SetLeft(rFlyPrtRect.Left());
    1312           0 :                         aDistLR.SetRight(rFlyPrtRect.Left());
    1313             :                     }
    1314             :                     else
    1315             :                     {
    1316           0 :                         SfxItemSet aCoreSet2( GetPool(),
    1317             :                                                 RES_BOX, RES_BOX,
    1318           0 :                                                 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
    1319           0 :                         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
    1320           0 :                         aCoreSet.Put( aBoxInfo );
    1321           0 :                         rSh.GetFlyFrmAttr( aCoreSet );
    1322           0 :                         const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
    1323           0 :                         aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
    1324           0 :                         aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
    1325             : 
    1326             :                         //add the paragraph border distance
    1327           0 :                         SfxItemSet aCoreSet1( GetPool(),
    1328             :                                                 RES_BOX, RES_BOX,
    1329           0 :                                                 0 );
    1330           0 :                         rSh.GetCurAttr( aCoreSet1 );
    1331           0 :                         const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
    1332           0 :                         aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
    1333           0 :                         aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
    1334             :                     }
    1335           0 :                     rSet.Put(aDistLR);
    1336           0 :                     m_nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
    1337           0 :                     m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
    1338             :                 }
    1339         538 :                 else if ( IsTabColFromDoc() ||
    1340         272 :                     ( rSh.GetTableFmt() && !bFrmSelection &&
    1341           2 :                     !(nFrmType & FRMTYPE_COLSECT ) ) )
    1342             :                 {
    1343           2 :                     SfxItemSet aCoreSet2( GetPool(),
    1344             :                                             RES_BOX, RES_BOX,
    1345           2 :                                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
    1346           4 :                     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
    1347           2 :                     aBoxInfo.SetTable(sal_False);
    1348           2 :                     aBoxInfo.SetDist((sal_Bool) sal_True);
    1349           2 :                     aCoreSet2.Put(aBoxInfo);
    1350           2 :                     rSh.GetTabBorders( aCoreSet2 );
    1351           2 :                     const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
    1352           2 :                     aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
    1353           2 :                     aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
    1354             : 
    1355             :                     //add the border distance of the paragraph
    1356           4 :                     SfxItemSet aCoreSet1( GetPool(), RES_BOX, RES_BOX );
    1357           2 :                     rSh.GetCurAttr( aCoreSet1 );
    1358           2 :                     const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
    1359           2 :                     aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
    1360           2 :                     aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
    1361           2 :                     rSet.Put(aDistLR);
    1362           2 :                     m_nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
    1363           4 :                     m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
    1364             :                 }
    1365         266 :                 else if ( !rSh.IsDirectlyInSection() )
    1366             :                 {
    1367             :                     //get the page/header/footer border distance
    1368         266 :                     const SwFrmFmt& rMaster = rDesc.GetMaster();
    1369         266 :                     const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
    1370         266 :                     aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
    1371         266 :                     aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
    1372             : 
    1373         266 :                     const SvxBoxItem* pBox = 0;
    1374         266 :                     if(nFrmType & FRMTYPE_HEADER)
    1375             :                     {
    1376           0 :                         rMaster.GetHeader();
    1377           0 :                         const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
    1378           0 :                         SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
    1379           0 :                         if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
    1380           0 :                             pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
    1381             :                     }
    1382         266 :                     else if(nFrmType & FRMTYPE_FOOTER )
    1383             :                     {
    1384           0 :                         const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
    1385           0 :                         SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
    1386           0 :                         if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
    1387           0 :                             pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
    1388             :                     }
    1389         266 :                     if(pBox)
    1390             :                     {
    1391           0 :                         aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT ));
    1392           0 :                         aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT));
    1393             :                     }
    1394             : 
    1395             :                     //add the border distance of the paragraph
    1396         266 :                     SfxItemSet aCoreSetTmp( GetPool(),
    1397             :                                             RES_BOX, RES_BOX,
    1398         266 :                                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
    1399         266 :                     rSh.GetCurAttr( aCoreSetTmp );
    1400         266 :                     const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
    1401         266 :                     aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
    1402         266 :                     aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
    1403         266 :                     rSet.Put(aDistLR);
    1404         266 :                     m_nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
    1405         266 :                     m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
    1406         268 :                 }
    1407             :             }
    1408             :         }
    1409         268 :         break;
    1410             : 
    1411             :         case SID_RULER_TEXT_RIGHT_TO_LEFT:
    1412             :         {
    1413         536 :             if ( nSelType & nsSelectionType::SEL_GRF ||
    1414         536 :                     nSelType & nsSelectionType::SEL_FRM ||
    1415         536 :                     nSelType & nsSelectionType::SEL_OLE ||
    1416             :                     nFrmType == FRMTYPE_DRAWOBJ)
    1417           0 :                 rSet.DisableItem(nWhich);
    1418             :             else
    1419             :             {
    1420         268 :                 sal_Bool bFlag = rSh.IsInRightToLeftText();
    1421         268 :                 rSet.Put(SfxBoolItem(nWhich, bFlag));
    1422             :             }
    1423             :         }
    1424         268 :         break;
    1425             : 
    1426             :         case SID_RULER_BORDERS_VERTICAL:
    1427             :         case SID_RULER_BORDERS:
    1428             :         {
    1429         536 :             bool bFrameHasVerticalColumns(false);
    1430             :             {
    1431             :                 sal_Bool bFrameRTL;
    1432             :                 sal_Bool bFrameVertL2R;
    1433         536 :                 bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
    1434         536 :                                            bFrmSelection;
    1435             :             }
    1436        1076 :             bool bHasTable = ( IsTabColFromDoc() ||
    1437         544 :                     ( rSh.GetTableFmt() && !bFrmSelection &&
    1438         540 :                     !(nFrmType & FRMTYPE_COLSECT ) ) );
    1439             : 
    1440         536 :             bool bTableVertical = bHasTable && rSh.IsTableVertical();
    1441             : 
    1442         536 :             if(((SID_RULER_BORDERS_VERTICAL == nWhich) &&
    1443         268 :                 ((bHasTable && !bTableVertical) ||
    1444         532 :                  (!bVerticalWriting && !bFrmSelection && !bHasTable ) ||
    1445           0 :                  ( bFrmSelection && !bFrameHasVerticalColumns))) ||
    1446         268 :                ((SID_RULER_BORDERS == nWhich) &&
    1447           2 :                 ((bHasTable && bTableVertical) ||
    1448           0 :                  (bVerticalWriting && !bFrmSelection&& !bHasTable) || bFrameHasVerticalColumns)))
    1449         268 :                 rSet.DisableItem(nWhich);
    1450         268 :             else if ( bHasTable )
    1451             :             {
    1452           2 :                 SwTabCols aTabCols;
    1453             :                 sal_uInt16    nNum;
    1454           2 :                 if ( 0 != ( m_bSetTabColFromDoc = IsTabColFromDoc() ) )
    1455             :                 {
    1456           0 :                     rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
    1457           0 :                     nNum = rSh.GetCurMouseTabColNum( m_aTabColFromDocPos );
    1458             :                 }
    1459             :                 else
    1460             :                 {
    1461           2 :                     rSh.GetTabCols( aTabCols );
    1462           2 :                     nNum = rSh.GetCurTabColNum();
    1463           2 :                     if(rSh.IsTableRightToLeft())
    1464           0 :                         nNum = aTabCols.Count() - nNum;
    1465             :                 }
    1466             : 
    1467             :                 OSL_ENSURE(nNum <= aTabCols.Count(), "TabCol not found");
    1468           2 :                 const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
    1469             :                 const int nRgt = (sal_uInt16)(bTableVertical ? nPageHeight : nPageWidth) -
    1470           4 :                                   (aTabCols.GetLeftMin() +
    1471           6 :                                   aTabCols.GetRight());
    1472             : 
    1473           2 :                 const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
    1474           2 :                 const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
    1475             : 
    1476           4 :                 SvxColumnItem aColItem(nNum, nL, nR);
    1477             : 
    1478           2 :                 sal_uInt16 nStart = 0,
    1479             :                        nEnd;
    1480             : 
    1481             :                 //columns in right-to-left tables need to be mirrored
    1482             :                 sal_Bool bIsTableRTL =
    1483           2 :                     IsTabColFromDoc() ?
    1484           0 :                           rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
    1485           2 :                         : rSh.IsTableRightToLeft();
    1486           2 :                 if(bIsTableRTL)
    1487             :                 {
    1488           0 :                     for ( sal_uInt16 i = aTabCols.Count(); i ; --i )
    1489             :                     {
    1490           0 :                         const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
    1491           0 :                         nEnd  = (sal_uInt16)aTabCols.GetRight();
    1492           0 :                         nEnd  = nEnd - (sal_uInt16)rEntry.nPos;
    1493             :                         SvxColumnDescription aColDesc( nStart, nEnd,
    1494           0 :                                     (sal_uInt16(aTabCols.GetRight() - rEntry.nMax)),
    1495           0 :                                     (sal_uInt16(aTabCols.GetRight() - rEntry.nMin)),
    1496           0 :                                                     !aTabCols.IsHidden(i - 1) );
    1497           0 :                         aColItem.Append(aColDesc);
    1498           0 :                         nStart = nEnd;
    1499             :                     }
    1500             :                     SvxColumnDescription aColDesc(nStart,
    1501           0 :                                     aTabCols.GetRight() - aTabCols.GetLeft(), sal_True);
    1502           0 :                     aColItem.Append(aColDesc);
    1503             :                 }
    1504             :                 else
    1505             :                 {
    1506           4 :                     for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
    1507             :                     {
    1508           2 :                         const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
    1509           2 :                         nEnd  = static_cast< sal_uInt16 >(rEntry.nPos - aTabCols.GetLeft());
    1510             :                         SvxColumnDescription aColDesc( nStart, nEnd,
    1511           4 :                                 rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
    1512           6 :                                                     !aTabCols.IsHidden(i) );
    1513           2 :                         aColItem.Append(aColDesc);
    1514           2 :                         nStart = nEnd;
    1515             :                     }
    1516           2 :                     SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
    1517             :                                 0, 0,
    1518           2 :                                     sal_True);
    1519           2 :                     aColItem.Append(aColDesc);
    1520             :                 }
    1521           4 :                 rSet.Put(aColItem, nWhich);
    1522             :             }
    1523         266 :             else if ( bFrmSelection || nFrmType & ( FRMTYPE_COLUMN | FRMTYPE_COLSECT ) )
    1524             :             {
    1525             :                 // Aus Rahmen oder Seite ?
    1526           0 :                 sal_uInt16 nNum = 0;
    1527           0 :                 if(bFrmSelection)
    1528             :                 {
    1529           0 :                     const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
    1530           0 :                     if(pFmt)
    1531           0 :                         nNum = pFmt->GetCol().GetNumCols();
    1532             :                 }
    1533             :                 else
    1534           0 :                     nNum = rSh.GetCurColNum();
    1535             : 
    1536           0 :                 if(
    1537             :                     //eigentlich sollte FRMTYPE_COLSECT nicht enthalten sein, wenn der Rahmen selektiert ist!
    1538           0 :                     !bFrmSelection &&
    1539           0 :                      nFrmType & FRMTYPE_COLSECT )
    1540             :                 {
    1541           0 :                     const SwSection *pSect = rSh.GetAnySection(sal_False, pPt);
    1542             :                     OSL_ENSURE( pSect, "Which section?");
    1543           0 :                     if( pSect )
    1544             :                     {
    1545           0 :                         SwSectionFmt *pFmt = pSect->GetFmt();
    1546           0 :                         const SwFmtCol& rCol = pFmt->GetCol();
    1547           0 :                         if(rSh.IsInRightToLeftText())
    1548           0 :                             nNum = rCol.GetColumns().size() - nNum;
    1549             :                         else
    1550           0 :                             --nNum;
    1551           0 :                         SvxColumnItem aColItem(nNum);
    1552           0 :                         SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
    1553           0 :                         const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
    1554             : 
    1555           0 :                         ::lcl_FillSvxColumn(rCol, sal_uInt16(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0);
    1556             : 
    1557           0 :                         if(bVerticalWriting)
    1558             :                         {
    1559           0 :                             aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
    1560           0 :                             aRect.Pos().Y() -= rPageRect.Top();
    1561           0 :                             aColItem.SetLeft ((sal_uInt16)(aRect.Top()));
    1562           0 :                             aColItem.SetRight((sal_uInt16)(nPageHeight   - aRect.Bottom() ));
    1563             :                         }
    1564             :                         else
    1565             :                         {
    1566           0 :                             aRect.Pos() += aTmpRect.Pos();
    1567             : 
    1568             :                             // make relative to page position:
    1569           0 :                             aColItem.SetLeft ((sal_uInt16)( aRect.Left() - rPageRect.Left() ));
    1570           0 :                             aColItem.SetRight((sal_uInt16)( rPageRect.Right() - aRect.Right()));
    1571             :                         }
    1572           0 :                         aColItem.SetOrtho(aColItem.CalcOrtho());
    1573             : 
    1574           0 :                         rSet.Put(aColItem, nWhich);
    1575           0 :                     }
    1576             :                 }
    1577           0 :                 else if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
    1578             :                 {
    1579             :                     // Spalten in Rahmen
    1580           0 :                     if ( nNum  )
    1581             :                     {
    1582           0 :                         const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
    1583             : 
    1584           0 :                         const SwFmtCol& rCol = pFmt->GetCol();
    1585           0 :                         if(rSh.IsInRightToLeftText())
    1586           0 :                             nNum = rCol.GetColumns().size() - nNum;
    1587             :                         else
    1588           0 :                             nNum--;
    1589           0 :                         SvxColumnItem aColItem(nNum);
    1590           0 :                         const SwRect &rSizeRect = rSh.GetAnyCurRect(RECT_FLY_PRT_EMBEDDED, pPt);
    1591             : 
    1592           0 :                         bool bUseVertical = bFrameHasVerticalColumns || (!bFrmSelection && bVerticalWriting);
    1593           0 :                         const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
    1594           0 :                         const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
    1595           0 :                         long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
    1596           0 :                         ::lcl_FillSvxColumn(rCol, sal_uInt16(lWidth), aColItem, nDist2);
    1597             : 
    1598           0 :                         SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
    1599           0 :                         rSh.GetFlyFrmAttr( aFrameSet );
    1600             : 
    1601           0 :                         if(bUseVertical)
    1602             :                         {
    1603           0 :                             aColItem.SetLeft ((sal_uInt16)(rRect.Top()- rPageRect.Top()));
    1604           0 :                             aColItem.SetRight((sal_uInt16)(nPageHeight + rPageRect.Top() - rRect.Bottom() ));
    1605             :                         }
    1606             :                         else
    1607             :                         {
    1608           0 :                             aColItem.SetLeft ((sal_uInt16)(rRect.Left() - rPageRect.Left()   ));
    1609           0 :                             aColItem.SetRight((sal_uInt16)(rPageRect.Right() - rRect.Right() ));
    1610             :                         }
    1611             : 
    1612           0 :                         aColItem.SetOrtho(aColItem.CalcOrtho());
    1613             : 
    1614           0 :                         rSet.Put(aColItem, nWhich);
    1615             :                     }
    1616             :                     else
    1617           0 :                         rSet.DisableItem(nWhich);
    1618             :                 }
    1619             :                 else
    1620             :                 {   // Spalten auf der Seite
    1621           0 :                     const SwFrmFmt& rMaster = rDesc.GetMaster();
    1622           0 :                     SwFmtCol aCol(rMaster.GetCol());
    1623           0 :                     if(rFrameDir.GetValue() == FRMDIR_HORI_RIGHT_TOP)
    1624           0 :                         nNum = aCol.GetColumns().size() - nNum;
    1625             :                     else
    1626           0 :                         nNum--;
    1627             : 
    1628           0 :                     SvxColumnItem aColItem(nNum);
    1629           0 :                     const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
    1630           0 :                     const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
    1631           0 :                     long nDist = rBox.GetDistance();
    1632             :                     ::lcl_FillSvxColumn(aCol,
    1633           0 :                         sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
    1634           0 :                         aColItem, nDist);
    1635             : 
    1636           0 :                     if(bBrowse)
    1637             :                     {
    1638           0 :                         aColItem.SetLeft((sal_uInt16)rPagePrtRect.Left());
    1639           0 :                         aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
    1640             :                     }
    1641             :                     else
    1642             :                     {
    1643           0 :                         aColItem.SetLeft (aPageLRSpace.GetLeft());
    1644           0 :                         aColItem.SetRight(aPageLRSpace.GetRight());
    1645             :                     }
    1646           0 :                     aColItem.SetOrtho(aColItem.CalcOrtho());
    1647             : 
    1648           0 :                     rSet.Put(aColItem, nWhich);
    1649           0 :                 }
    1650             :             }
    1651             :             else
    1652         266 :                 rSet.DisableItem(nWhich);
    1653         536 :             break;
    1654             :         }
    1655             : 
    1656             :         case SID_RULER_ROWS :
    1657             :         case SID_RULER_ROWS_VERTICAL:
    1658             :         {
    1659         536 :             bool bFrameHasVerticalColumns(false);
    1660             :             {
    1661             :                 sal_Bool bFrameRTL;
    1662             :                 sal_Bool bFrameVertL2R;
    1663         536 :                 bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
    1664         536 :                                            bFrmSelection;
    1665             :             }
    1666             : 
    1667         804 :             if(((SID_RULER_ROWS == nWhich) &&
    1668         536 :                 ((!bVerticalWriting && !bFrmSelection) || (bFrmSelection && !bFrameHasVerticalColumns))) ||
    1669         268 :                ((SID_RULER_ROWS_VERTICAL == nWhich) &&
    1670           0 :                 ((bVerticalWriting && !bFrmSelection) || bFrameHasVerticalColumns)))
    1671         268 :                 rSet.DisableItem(nWhich);
    1672         538 :             else if ( IsTabRowFromDoc() ||
    1673         272 :                     ( rSh.GetTableFmt() && !bFrmSelection &&
    1674           2 :                     !(nFrmType & FRMTYPE_COLSECT ) ) )
    1675             :             {
    1676           2 :                 SwTabCols aTabCols;
    1677             :                 //no current value necessary
    1678           2 :                 sal_uInt16    nNum = 0;
    1679           2 :                 if ( 0 != ( m_bSetTabRowFromDoc = IsTabRowFromDoc() ) )
    1680             :                 {
    1681           0 :                     rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
    1682             :                 }
    1683             :                 else
    1684             :                 {
    1685           2 :                     rSh.GetTabRows( aTabCols );
    1686             :                 }
    1687             : 
    1688           2 :                 const int nLft = aTabCols.GetLeftMin();
    1689             :                 const int nRgt = (sal_uInt16)(bVerticalWriting ? nPageWidth : nPageHeight) -
    1690           4 :                                   (aTabCols.GetLeftMin() +
    1691           6 :                                   aTabCols.GetRight());
    1692             : 
    1693           2 :                 const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
    1694           2 :                 const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
    1695             : 
    1696           4 :                 SvxColumnItem aColItem(nNum, nL, nR);
    1697             : 
    1698           2 :                 sal_uInt16 nStart = 0,
    1699             :                        nEnd;
    1700             : 
    1701           4 :                 for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
    1702             :                 {
    1703           2 :                     const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
    1704           2 :                     if(bVerticalWriting)
    1705             :                     {
    1706           0 :                         nEnd  = sal_uInt16(aTabCols.GetRight() - rEntry.nPos);
    1707             :                         SvxColumnDescription aColDesc( nStart, nEnd,
    1708           0 :                             aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin,
    1709           0 :                                                     !aTabCols.IsHidden(i) );
    1710           0 :                         aColItem.Append(aColDesc);
    1711             :                     }
    1712             :                     else
    1713             :                     {
    1714           2 :                         nEnd  = sal_uInt16(rEntry.nPos - aTabCols.GetLeft());
    1715             :                         SvxColumnDescription aColDesc( nStart, nEnd,
    1716           4 :                                 sal_uInt16(rEntry.nMin - aTabCols.GetLeft()), sal_uInt16(rEntry.nMax - aTabCols.GetLeft()),
    1717           6 :                                                     !aTabCols.IsHidden(i) );
    1718           2 :                         aColItem.Append(aColDesc);
    1719             :                     }
    1720           2 :                     nStart = nEnd;
    1721             :                 }
    1722           2 :                 if(bVerticalWriting)
    1723           0 :                     nEnd = static_cast< sal_uInt16 >(aTabCols.GetRight());
    1724             :                 else
    1725           2 :                     nEnd = static_cast< sal_uInt16 >(aTabCols.GetLeft());
    1726             :                 // put a position protection when the last row cannot be moved
    1727             :                 // due to a page break inside of a row
    1728           2 :                 if(!aTabCols.IsLastRowAllowedToChange())
    1729           0 :                     bPutContentProtection = true;
    1730             : 
    1731             :                 SvxColumnDescription aColDesc( nStart, nEnd,
    1732             :                     aTabCols.GetRight(), aTabCols.GetRight(),
    1733           2 :                                             sal_False );
    1734           2 :                 aColItem.Append(aColDesc);
    1735             : 
    1736           4 :                 rSet.Put(aColItem, nWhich);
    1737             :             }
    1738             :             else
    1739         266 :                 rSet.DisableItem(nWhich);
    1740             :         }
    1741         536 :         break;
    1742             : 
    1743             :         case SID_RULER_PAGE_POS:
    1744             :         {
    1745             :             SvxPagePosSizeItem aPagePosSize(
    1746         270 :                     Point( rPageRect.Left(), rPageRect.Top()) , nPageWidth, nPageHeight);
    1747             : 
    1748         270 :             rSet.Put(aPagePosSize);
    1749         270 :             break;
    1750             :         }
    1751             : 
    1752             :         case SID_RULER_LR_MIN_MAX:
    1753             :         {
    1754         270 :             Rectangle aRectangle;
    1755         270 :             if( ( nFrmType & FRMTYPE_COLSECT ) && !IsTabColFromDoc() &&
    1756           0 :                 ( nFrmType & ( FRMTYPE_TABLE|FRMTYPE_COLUMN ) ) )
    1757             :             {
    1758           0 :                 if( nFrmType & FRMTYPE_TABLE )
    1759             :                 {
    1760           0 :                     const sal_uInt16 nNum = rSh.GetCurTabColNum();
    1761           0 :                     SwTabCols aTabCols;
    1762           0 :                     rSh.GetTabCols( aTabCols );
    1763             : 
    1764           0 :                     const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
    1765           0 :                     const int nRgt = (sal_uInt16)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
    1766             : 
    1767           0 :                     const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
    1768           0 :                     const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
    1769             : 
    1770           0 :                     aRectangle.Left() = nL;
    1771           0 :                     if(nNum > 1)
    1772           0 :                         aRectangle.Left() += aTabCols[nNum - 2];
    1773           0 :                     if(nNum)
    1774           0 :                         aRectangle.Left() += MINLAY;
    1775           0 :                     if(aTabCols.Count() <= nNum + 1 )
    1776           0 :                         aRectangle.Right() = nR;
    1777             :                     else
    1778           0 :                         aRectangle.Right() = nPageWidth - (nL + aTabCols[nNum + 1]);
    1779             : 
    1780           0 :                     if(nNum < aTabCols.Count())
    1781           0 :                         aRectangle.Right() += MINLAY;
    1782             :                 }
    1783             :                 else
    1784             :                 {
    1785           0 :                     const SwFrmFmt* pFmt =  rSh.GetFlyFrmFmt();
    1786           0 :                     const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
    1787           0 :                                                    &rDesc.GetMaster().GetCol();
    1788           0 :                     const SwColumns& rCols = pCols->GetColumns();
    1789           0 :                     sal_uInt16 nNum = rSh.GetCurOutColNum();
    1790           0 :                     sal_uInt16 nCount = std::min(sal_uInt16(nNum + 1), sal_uInt16(rCols.size()));
    1791             :                     const SwRect aRect( rSh.GetAnyCurRect( pFmt
    1792             :                                                     ? RECT_FLY_PRT_EMBEDDED
    1793           0 :                                                     : RECT_PAGE_PRT, pPt ));
    1794             :                     const SwRect aAbsRect( rSh.GetAnyCurRect( pFmt
    1795             :                                                     ? RECT_FLY_EMBEDDED
    1796           0 :                                                     : RECT_PAGE, pPt ));
    1797             : 
    1798             :                     //die Breite im Rahmen bzw. innerhalbe der Seitenraender
    1799           0 :                     const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
    1800             :                     //die gesamte Rahmenbreite - die Differenz ist der doppelte Abstand zum Rand
    1801           0 :                     const sal_uInt16 nOuterWidth = (sal_uInt16)aAbsRect.Width();
    1802           0 :                     int nWidth = 0,
    1803           0 :                         nStart = 0,
    1804           0 :                         nEnd = 0;
    1805           0 :                     aRectangle.Left() = 0;
    1806           0 :                     for ( sal_uInt16 i = 0; i < nCount; ++i )
    1807             :                     {
    1808           0 :                         const SwColumn* pCol = &rCols[i];
    1809           0 :                         nStart = pCol->GetLeft() + nWidth;
    1810           0 :                         if(i == nNum - 2)
    1811           0 :                             aRectangle.Left() = nStart;
    1812           0 :                         nWidth += pCols->CalcColWidth( i, nTotalWidth );
    1813           0 :                         nEnd = nWidth - pCol->GetRight();
    1814             :                     }
    1815           0 :                     aRectangle.Right() = rPageRect.Right() - nEnd;
    1816           0 :                     aRectangle.Left() -= rPageRect.Left();
    1817             : 
    1818           0 :                     if(nNum > 1)
    1819             :                     {
    1820           0 :                         aRectangle.Left() += MINLAY;
    1821           0 :                         aRectangle.Left() += aRect.Left();
    1822             :                     }
    1823           0 :                     if(pFmt) //Bereich in Rahmen - hier darf man bis zum Rand
    1824           0 :                         aRectangle.Left()  = aRectangle.Right() = 0;
    1825             :                     else
    1826             :                     {
    1827             :                         // das Rechteck an die richtige absolute Position verschieben
    1828           0 :                         aRectangle.Left() += aAbsRect.Left();
    1829           0 :                         aRectangle.Right() -= aAbsRect.Left();
    1830             :                         // Abstand zur Umrandung mit einbeziehen
    1831           0 :                         aRectangle.Right() -= (nOuterWidth - nTotalWidth) / 2;
    1832             :                     }
    1833             : 
    1834           0 :                     if(nNum < rCols.size())
    1835             :                     {
    1836           0 :                         aRectangle.Right() += MINLAY;
    1837             :                     }
    1838             :                     else
    1839             :                         // rechts ist jetzt nur noch der Seitenrand
    1840           0 :                         aRectangle.Right() = 0;
    1841             : 
    1842             : 
    1843             :                 }
    1844             :             }
    1845         270 :             else if ( ((nFrmType & FRMTYPE_TABLE) || IsTabColFromDoc()) &&
    1846             :                  !bFrmSelection )
    1847             :             {
    1848             :                 bool bColumn;
    1849           2 :                 if ( IsTabColFromDoc() )
    1850           0 :                     bColumn = rSh.GetCurMouseColNum( m_aTabColFromDocPos ) != 0;
    1851             :                 else
    1852           2 :                     bColumn = (nFrmType & (FRMTYPE_COLUMN|FRMTYPE_FLY_ANY|FRMTYPE_COLSECTOUTTAB))
    1853             :                               ? sal_True
    1854           2 :                               : sal_False;
    1855             : 
    1856           2 :                 if ( !bColumn )
    1857             :                 {
    1858           2 :                     if( nFrmType & FRMTYPE_FLY_ANY && IsTabColFromDoc() )
    1859             :                     {
    1860             :                         SwRect aRect( rSh.GetAnyCurRect(
    1861           0 :                                             RECT_FLY_PRT_EMBEDDED, pPt ) );
    1862           0 :                         aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
    1863           0 :                                                                 pPt ).Pos();
    1864             : 
    1865           0 :                         aRectangle.Left()  = aRect.Left() - rPageRect.Left();
    1866           0 :                         aRectangle.Right() = rPageRect.Right() - aRect.Right();
    1867             :                     }
    1868           2 :                     else if( bBrowse )
    1869             :                     {
    1870           0 :                         aRectangle.Left()  = rPagePrtRect.Left();
    1871           0 :                         aRectangle.Right() = nPageWidth - rPagePrtRect.Right();
    1872             :                     }
    1873             :                     else
    1874             :                     {
    1875           2 :                         aRectangle.Left()  = aPageLRSpace.GetLeft();
    1876           2 :                         aRectangle.Right() = aPageLRSpace.GetRight();
    1877             :                     }
    1878             :                 }
    1879             :                 else
    1880             :                 {   //hier nur fuer Tabelle in mehrspaltigen Seiten und Rahmen
    1881           0 :                     sal_Bool bSectOutTbl = (nFrmType & FRMTYPE_TABLE) ? sal_True : sal_False;
    1882           0 :                     bool bFrame = (nFrmType & FRMTYPE_FLY_ANY);
    1883           0 :                     bool bColSct =  (nFrmType & ( bSectOutTbl
    1884             :                                                     ? FRMTYPE_COLSECTOUTTAB
    1885             :                                                     : FRMTYPE_COLSECT )
    1886           0 :                                                 );
    1887             :                     //Damit man auch mit der Mouse ziehen kann,
    1888             :                     //ohne in der Tabelle zu stehen
    1889           0 :                     CurRectType eRecType = RECT_PAGE_PRT;
    1890           0 :                     sal_uInt16 nNum = IsTabColFromDoc() ?
    1891           0 :                                 rSh.GetCurMouseColNum( m_aTabColFromDocPos ):
    1892           0 :                                 rSh.GetCurOutColNum();
    1893           0 :                     const SwFrmFmt* pFmt = NULL;
    1894           0 :                     if( bColSct )
    1895             :                     {
    1896             :                         eRecType = bSectOutTbl ? RECT_OUTTABSECTION
    1897           0 :                                                : RECT_SECTION;
    1898           0 :                         const SwSection *pSect = rSh.GetAnySection( bSectOutTbl, pPt );
    1899             :                         OSL_ENSURE( pSect, "Which section?");
    1900           0 :                         pFmt = pSect->GetFmt();
    1901             :                     }
    1902           0 :                     else if( bFrame )
    1903             :                     {
    1904           0 :                         pFmt = rSh.GetFlyFrmFmt();
    1905           0 :                         eRecType = RECT_FLY_PRT_EMBEDDED;
    1906             :                     }
    1907             : 
    1908           0 :                     const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
    1909           0 :                                                    &rDesc.GetMaster().GetCol();
    1910           0 :                     const SwColumns& rCols = pCols->GetColumns();
    1911           0 :                     const sal_uInt16 nBorder = pFmt ? pFmt->GetBox().GetDistance() :
    1912           0 :                                                   rDesc.GetMaster().GetBox().GetDistance();
    1913             : 
    1914             :                     /* RECT_FLY_PRT_EMBEDDED returns the relative position to
    1915             :                         RECT_FLY_EMBEDDED
    1916             :                         the absolute position must be added here
    1917             :                     */
    1918           0 :                     SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
    1919           0 :                     if(RECT_FLY_PRT_EMBEDDED == eRecType)
    1920           0 :                         aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
    1921           0 :                                                                 pPt ).Pos();
    1922             : 
    1923           0 :                     const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
    1924             :                     //nStart und nEnd initialisieren fuer nNum == 0
    1925           0 :                     int nWidth = 0,
    1926           0 :                         nStart = 0,
    1927           0 :                         nEnd = nTotalWidth;
    1928             : 
    1929           0 :                     if( nNum > rCols.size() )
    1930             :                     {
    1931             :                         OSL_ENSURE( !this, "wrong FmtCol is being edited!" );
    1932           0 :                         nNum = rCols.size();
    1933             :                     }
    1934             : 
    1935           0 :                     for( sal_uInt16 i = 0; i < nNum; ++i )
    1936             :                     {
    1937           0 :                         const SwColumn* pCol = &rCols[i];
    1938           0 :                         nStart = pCol->GetLeft() + nWidth;
    1939           0 :                         nWidth += pCols->CalcColWidth( i, nTotalWidth );
    1940           0 :                         nEnd = nWidth - pCol->GetRight();
    1941             :                     }
    1942           0 :                     if( bFrame || bColSct )
    1943             :                     {
    1944           0 :                         aRectangle.Left()  = aRect.Left() - rPageRect.Left() + nStart;
    1945           0 :                         aRectangle.Right() = nPageWidth - aRectangle.Left() - nEnd + nStart;
    1946             :                     }
    1947           0 :                     else if(!bBrowse)
    1948             :                     {
    1949           0 :                         aRectangle.Left()  = aPageLRSpace.GetLeft() + nStart;
    1950           0 :                         aRectangle.Right() = nPageWidth - nEnd - aPageLRSpace.GetLeft();
    1951             :                     }
    1952             :                     else
    1953             :                     {
    1954           0 :                         long nLeft = rPagePrtRect.Left();
    1955           0 :                         aRectangle.Left()  = nStart + nLeft;
    1956           0 :                         aRectangle.Right() = nPageWidth - nEnd - nLeft;
    1957             :                     }
    1958           0 :                     if(!bFrame)
    1959             :                     {
    1960           0 :                         aRectangle.Left() += nBorder;
    1961           0 :                         aRectangle.Right() -= nBorder;
    1962             :                     }
    1963             :                 }
    1964             :             }
    1965         268 :             else if ( nFrmType & ( FRMTYPE_HEADER  | FRMTYPE_FOOTER ))
    1966             :             {
    1967           0 :                 aRectangle.Left()  = aPageLRSpace.GetLeft();
    1968           0 :                 aRectangle.Right() = aPageLRSpace.GetRight();
    1969             :             }
    1970             :             else
    1971         268 :                 aRectangle.Left()  = aRectangle.Right() = 0;
    1972             : 
    1973         270 :             SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
    1974         270 :             rSet.Put(aLR);
    1975             :         }
    1976         270 :         break;
    1977             : 
    1978             :         case SID_RULER_PROTECT:
    1979             :         {
    1980         264 :             if(bFrmSelection)
    1981             :             {
    1982           0 :                 sal_uInt8 nProtect = m_pWrtShell->IsSelObjProtected( FLYPROTECT_SIZE|FLYPROTECT_POS|FLYPROTECT_CONTENT );
    1983             : 
    1984           0 :                 SvxProtectItem aProt(SID_RULER_PROTECT);
    1985           0 :                 aProt.SetCntntProtect((nProtect & FLYPROTECT_CONTENT)   != 0);
    1986           0 :                 aProt.SetSizeProtect ((nProtect & FLYPROTECT_SIZE)      != 0);
    1987           0 :                 aProt.SetPosProtect  ((nProtect & FLYPROTECT_POS)       != 0);
    1988           0 :                 rSet.Put(aProt);
    1989             :             }
    1990             :             else
    1991             :             {
    1992         264 :                 SvxProtectItem aProtect(SID_RULER_PROTECT);
    1993         264 :                 if(bBrowse && !(nFrmType & (FRMTYPE_DRAWOBJ|FRMTYPE_COLUMN)) && !rSh.GetTableFmt())
    1994             :                 {
    1995           2 :                     aProtect.SetSizeProtect(sal_True);
    1996           2 :                     aProtect.SetPosProtect(sal_True);
    1997             :                 }
    1998         264 :                 rSet.Put(aProtect);
    1999             :             }
    2000             :         }
    2001         264 :         break;
    2002             :         }
    2003        3740 :         nWhich = aIter.NextWhich();
    2004             :     }
    2005         270 :     if(bPutContentProtection)
    2006             :     {
    2007           0 :         SvxProtectItem aProtect(SID_RULER_PROTECT);
    2008           0 :         aProtect.SetCntntProtect(sal_True);
    2009           0 :         rSet.Put(aProtect);
    2010         270 :     }
    2011         369 : }
    2012             : 
    2013             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10