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