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