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