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