xref: /trunk/main/sw/source/ui/uiview/viewtab.cxx (revision 870262e3)
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 
lcl_FillSvxColumn(const SwFmtCol & rCol,sal_uInt16 nTotalWidth,SvxColumnItem & rColItem,long nDistance)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 
lcl_ConvertToCols(const SvxColumnItem & rColItem,sal_uInt16 nTotalWidth,SwFmtCol & rCols)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 
lcl_EraseDefTabs(SvxTabStopItem & rTabStops)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 
SwapPageMargin(const SwPageDesc & rDesc,SvxLRSpaceItem & rLRSpace)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 
lcl_Scale(long & nVal,long nScale)219 void lcl_Scale(long& nVal, long nScale)
220 {
221 	nVal *= nScale;
222 	nVal >>= 8;
223 }
224 
ResizeFrameCols(SwFmtCol & rCol,long nOldWidth,long nNewWidth,long nLeftDelta)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 
ExecTabWin(SfxRequest & rReq)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.SetAttrItem( 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.SetAttrItem( 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.SetAttrItem( 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.SetAttrItem( 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( sal_False, "Wrong 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 
StateTabWin(SfxItemSet & rSet)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     const 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                 const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
1193                 const SvxLongLRSpaceItem aLongLR(
1194                     (long)aTmpPageLRSpace.GetLeft(),
1195                     (long)aTmpPageLRSpace.GetRight(),
1196                     SID_ATTR_PAGE_LRSPACE );
1197                 rSet.Put( aLongLR );
1198             }
1199             break;
1200 
1201         case SID_ATTR_LONG_ULSPACE:
1202             {
1203                 // Rand Seite Oben Unten
1204                 SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
1205                 SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
1206                     (long)aUL.GetLower(),
1207                     SID_ATTR_LONG_ULSPACE);
1208 
1209                 if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
1210                 {
1211                     // Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
1212                     const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
1213                     aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() ));
1214                     aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() ));
1215                 }
1216                 else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
1217                 {
1218                     SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
1219                     aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
1220                     aLongUL.SetUpper( (sal_uInt16)aRect.Top() );
1221                     aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) );
1222                 }
1223                 else if( nFrmType & FRMTYPE_DRAWOBJ)
1224                 {
1225                     const SwRect &rRect = rSh.GetObjRect();
1226                     aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
1227                     aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
1228                 }
1229                 else if(bBrowse)
1230                 {
1231                     aLongUL.SetUpper(rPagePrtRect.Top());
1232                     aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
1233                 }
1234                 if( nWhich == SID_ATTR_LONG_ULSPACE )
1235                     rSet.Put( aLongUL );
1236                 else
1237                 {
1238                     SvxULSpaceItem aULTmp((sal_uInt16)aLongUL.GetUpper(),
1239                         (sal_uInt16)aLongUL.GetLower(),
1240                         nWhich);
1241                     rSet.Put(aULTmp);
1242                 }
1243                 break;
1244             }
1245 
1246         // provide top and bottom margins of current page style
1247         case SID_ATTR_PAGE_ULSPACE:
1248             {
1249                 const SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
1250                 SvxLongULSpaceItem aLongUL(
1251                     (long)aUL.GetUpper(),
1252                     (long)aUL.GetLower(),
1253                     SID_ATTR_PAGE_ULSPACE );
1254 
1255                 rSet.Put( aLongUL );
1256             }
1257             break;
1258 
1259         case SID_ATTR_TABSTOP_VERTICAL :
1260         case RES_PARATR_TABSTOP:
1261             {
1262                 if ( ISA( SwWebView ) ||
1263                     IsTabColFromDoc() ||
1264                     IsTabRowFromDoc() ||
1265                     ( nSelType & nsSelectionType::SEL_GRF) ||
1266                     (nSelType & nsSelectionType::SEL_FRM) ||
1267                     (nSelType & nsSelectionType::SEL_OLE) ||
1268                     SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE)||
1269                     (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich))||
1270                     (bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
1271                     )
1272                     rSet.DisableItem( nWhich );
1273                 else
1274                 {
1275                     SvxTabStopItem aTabStops((const SvxTabStopItem&)
1276                         aCoreSet.Get( RES_PARATR_TABSTOP ));
1277 
1278                     const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
1279                         rSh.GetDefault(RES_PARATR_TABSTOP);
1280 
1281                     DBG_ASSERT(pHRuler, "warum ist das Lineal nicht da?");
1282                     long nDefTabDist = ::GetTabDist(rDefTabs);
1283                     pHRuler->SetDefTabDist( nDefTabDist );
1284                     pVRuler->SetDefTabDist( nDefTabDist );
1285                     ::lcl_EraseDefTabs(aTabStops);
1286                     rSet.Put(aTabStops, nWhich);
1287                 }
1288                 break;
1289             }
1290 
1291         case SID_ATTR_PARA_LRSPACE_VERTICAL:
1292         case SID_ATTR_PARA_LRSPACE:
1293             {
1294                 if ( nSelType & nsSelectionType::SEL_GRF ||
1295                     nSelType & nsSelectionType::SEL_FRM ||
1296                     nSelType & nsSelectionType::SEL_OLE ||
1297                     nFrmType == FRMTYPE_DRAWOBJ ||
1298                     (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich))||
1299                     (bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
1300                     )
1301                 {
1302                     rSet.DisableItem(nWhich);
1303                 }
1304                 else
1305                 {
1306                     SvxLRSpaceItem aLR( RES_LR_SPACE );
1307                     if ( !IsTabColFromDoc() )
1308                     {
1309                         aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
1310 
1311                         // #i23726#
1312                         if (pNumRuleNodeFromDoc)
1313                         {
1314                             short nOffset = static_cast< short >(aLR.GetTxtLeft() +
1315                                 // --> FME 2005-02-22 #i42922# Mouse move of numbering label
1316                                 // has to consider the left indent of the paragraph
1317                                 pNumRuleNodeFromDoc->GetLeftMarginWithNum( sal_True ) );
1318                             // <--
1319 
1320                             short nFLOffset;
1321                             pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
1322 
1323                             aLR.SetLeft( nOffset + nFLOffset );
1324                         }
1325                     }
1326                     aLR.SetWhich(nWhich);
1327                     rSet.Put(aLR);
1328                 }
1329                 break;
1330             }
1331 
1332 	case SID_ATTR_PARA_ULSPACE:
1333 	{
1334 		SvxULSpaceItem aUL = (const SvxULSpaceItem&)aCoreSet.Get(RES_UL_SPACE);
1335 		aUL.SetWhich(nWhich);
1336 
1337 		SfxItemState e = aCoreSet.GetItemState(RES_UL_SPACE);
1338 		if( e >= SFX_ITEM_AVAILABLE )
1339 			rSet.Put( aUL );
1340 		else
1341 			rSet.InvalidateItem(nWhich);
1342 	}
1343 	break;
1344 
1345         case SID_RULER_BORDER_DISTANCE:
1346             {
1347                 nLeftBorderDistance = 0;
1348                 nRightBorderDistance = 0;
1349                 if ( nSelType & nsSelectionType::SEL_GRF ||
1350                     nSelType & nsSelectionType::SEL_FRM ||
1351                     nSelType & nsSelectionType::SEL_OLE ||
1352                     nFrmType == FRMTYPE_DRAWOBJ )
1353                     rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
1354                 else
1355                 {
1356                     SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
1357                     if(nFrmType & FRMTYPE_FLY_ANY)
1358                     {
1359                         if( IsTabColFromDoc() )
1360                         {
1361                             const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
1362                             aDistLR.SetLeft(rFlyPrtRect.Left());
1363                             aDistLR.SetRight(rFlyPrtRect.Left());
1364                         }
1365                         else
1366                         {
1367                             SfxItemSet aCoreSet2( GetPool(),
1368                                 RES_BOX, RES_BOX,
1369                                 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1370                             SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1371                             aCoreSet.Put( aBoxInfo );
1372                             rSh.GetFlyFrmAttr( aCoreSet );
1373                             const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
1374                             aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
1375                             aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
1376 
1377                             //add the paragraph border distance
1378                             SfxItemSet aCoreSet1( GetPool(),
1379                                 RES_BOX, RES_BOX,
1380                                 0 );
1381                             rSh.GetCurAttr( aCoreSet1 );
1382                             const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
1383                             aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
1384                             aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
1385                         }
1386                         rSet.Put(aDistLR);
1387                         nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1388                         nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1389                     }
1390                     else if ( IsTabColFromDoc() ||
1391                         ( rSh.GetTableFmt() && !bFrmSelection &&
1392                         !(nFrmType & FRMTYPE_COLSECT ) ) )
1393                     {
1394                         SfxItemSet aCoreSet2( GetPool(),
1395                             RES_BOX, RES_BOX,
1396                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1397                         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1398                         aBoxInfo.SetTable(sal_False);
1399                         aBoxInfo.SetDist((sal_Bool) sal_True);
1400                         aCoreSet2.Put(aBoxInfo);
1401                         rSh.GetTabBorders( aCoreSet2 );
1402                         const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
1403                         aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
1404                         aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
1405 
1406                         //add the border distance of the paragraph
1407                         SfxItemSet aCoreSet1( GetPool(),
1408                             RES_BOX, RES_BOX,
1409                             0 );
1410                         rSh.GetCurAttr( aCoreSet1 );
1411                         const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
1412                         aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
1413                         aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
1414                         rSet.Put(aDistLR);
1415                         nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1416                         nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1417                     }
1418                     else if ( !rSh.IsDirectlyInSection() )
1419                     {
1420                         //get the page/header/footer border distance
1421                         const SwFrmFmt& rMaster = rDesc.GetMaster();
1422                         const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
1423                         aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
1424                         aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
1425 
1426                         const SvxBoxItem* pBox = 0;
1427                         if(nFrmType & FRMTYPE_HEADER)
1428                         {
1429                             rMaster.GetHeader();
1430                             const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
1431                             SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
1432                             if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
1433                                 pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
1434                         }
1435                         else if(nFrmType & FRMTYPE_FOOTER )
1436                         {
1437                             const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
1438                             SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
1439                             if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
1440                                 pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
1441                         }
1442                         if(pBox)
1443                         {
1444                             aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT ));
1445                             aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT));
1446                         }
1447 
1448                         //add the border distance of the paragraph
1449                         SfxItemSet aCoreSetTmp( GetPool(),
1450                             RES_BOX, RES_BOX,
1451                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1452                         rSh.GetCurAttr( aCoreSetTmp );
1453                         const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
1454                         aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
1455                         aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
1456                         rSet.Put(aDistLR);
1457                         nLeftBorderDistance  = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1458                         nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1459                     }
1460                 }
1461             }
1462             break;
1463 
1464         case SID_RULER_TEXT_RIGHT_TO_LEFT:
1465             {
1466                 if ( nSelType & nsSelectionType::SEL_GRF ||
1467                     nSelType & nsSelectionType::SEL_FRM ||
1468                     nSelType & nsSelectionType::SEL_OLE ||
1469                     nFrmType == FRMTYPE_DRAWOBJ)
1470                     rSet.DisableItem(nWhich);
1471                 else
1472                 {
1473                     sal_Bool bFlag = rSh.IsInRightToLeftText();
1474                     rSet.Put(SfxBoolItem(nWhich, bFlag));
1475                 }
1476             }
1477             break;
1478 
1479         case SID_RULER_BORDERS_VERTICAL:
1480         case SID_RULER_BORDERS:
1481             {
1482                 sal_Bool bFrameHasVerticalColumns(sal_False);
1483                 {
1484                     sal_Bool bFrameRTL;
1485                     sal_Bool bFrameVertL2R;
1486                     bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
1487                         bFrmSelection;
1488                 }
1489                 sal_Bool bHasTable = ( IsTabColFromDoc() ||
1490                     ( rSh.GetTableFmt() && !bFrmSelection &&
1491                     !(nFrmType & FRMTYPE_COLSECT ) ) );
1492 
1493                 sal_Bool bTableVertical = bHasTable && rSh.IsTableVertical();
1494 
1495                 if( ( (SID_RULER_BORDERS_VERTICAL == nWhich) &&
1496                     ((bHasTable && !bTableVertical)||
1497                     (!bVerticalWriting && !bFrmSelection && !bHasTable ) || (bFrmSelection && !bFrameHasVerticalColumns)) ) ||
1498                     ((SID_RULER_BORDERS == nWhich) &&
1499                     ((bHasTable && bTableVertical)||
1500                     (bVerticalWriting && !bFrmSelection&& !bHasTable) || bFrameHasVerticalColumns)))
1501                     rSet.DisableItem(nWhich);
1502                 else if ( bHasTable )
1503                 {
1504                     SwTabCols aTabCols;
1505                     sal_uInt16	  nNum;
1506                     if ( 0 != ( bSetTabColFromDoc = IsTabColFromDoc() ) )
1507                     {
1508                         rSh.GetMouseTabCols( aTabCols, aTabColFromDocPos );
1509                         nNum = rSh.GetCurMouseTabColNum( aTabColFromDocPos );
1510                     }
1511                     else
1512                     {
1513                         rSh.GetTabCols( aTabCols );
1514                         nNum = rSh.GetCurTabColNum();
1515                         if(rSh.IsTableRightToLeft())
1516                             nNum = aTabCols.Count() - nNum;
1517                     }
1518 
1519                     ASSERT(nNum <= aTabCols.Count(), "TabCol not found");
1520                     const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
1521                     const int nRgt = (sal_uInt16)(bTableVertical ? nPageHeight : nPageWidth) -
1522                         (aTabCols.GetLeftMin() +
1523                         aTabCols.GetRight());
1524 
1525                     const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
1526                     const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
1527 
1528                     SvxColumnItem aColItem(nNum, nL, nR);
1529 
1530                     sal_uInt16 nStart = 0,
1531                         nEnd;
1532 
1533                     //columns in right-to-left tables need to be mirrored
1534                     sal_Bool bIsTableRTL =
1535                         IsTabColFromDoc() ?
1536                         rSh.IsMouseTableRightToLeft(aTabColFromDocPos)
1537                         : rSh.IsTableRightToLeft();
1538                     if(bIsTableRTL)
1539                     {
1540                         for ( sal_uInt16 i = aTabCols.Count(); i ; --i )
1541                         {
1542                             const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
1543                             nEnd  = (sal_uInt16)aTabCols.GetRight();
1544                             nEnd  = nEnd - (sal_uInt16)rEntry.nPos;
1545                             SvxColumnDescription aColDesc( nStart, nEnd,
1546                                 (sal_uInt16(aTabCols.GetRight() - rEntry.nMax)),
1547                                 (sal_uInt16(aTabCols.GetRight() - rEntry.nMin)),
1548                                 !aTabCols.IsHidden(i - 1) );
1549                             aColItem.Append(aColDesc);
1550                             nStart = nEnd;
1551                         }
1552                         SvxColumnDescription aColDesc(nStart,
1553                             aTabCols.GetRight() - aTabCols.GetLeft(), sal_True);
1554                         aColItem.Append(aColDesc);
1555                     }
1556                     else
1557                     {
1558                         for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
1559                         {
1560                             const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
1561                             nEnd  = static_cast< sal_uInt16 >(rEntry.nPos - aTabCols.GetLeft());
1562                             SvxColumnDescription aColDesc( nStart, nEnd,
1563                                 rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
1564                                 !aTabCols.IsHidden(i) );
1565                             aColItem.Append(aColDesc);
1566                             nStart = nEnd;
1567                         }
1568                         SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
1569                             0, 0,
1570                             sal_True);
1571                         aColItem.Append(aColDesc);
1572                     }
1573                     rSet.Put(aColItem, nWhich);
1574                 }
1575                 else if ( bFrmSelection || nFrmType & ( FRMTYPE_COLUMN | FRMTYPE_COLSECT ) )
1576                 {
1577                     // Aus Rahmen oder Seite ?
1578                     sal_uInt16 nNum = 0;
1579                     if(bFrmSelection)
1580                     {
1581                         const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
1582                         if(pFmt)
1583                             nNum = pFmt->GetCol().GetNumCols();
1584                     }
1585                     else
1586                         nNum = rSh.GetCurColNum();
1587 
1588                     if(
1589                         //eigentlich sollte FRMTYPE_COLSECT nicht enthalten sein, wenn der Rahmen selektiert ist!
1590                             !bFrmSelection &&
1591                             nFrmType & FRMTYPE_COLSECT )
1592                     {
1593                         const SwSection *pSect = rSh.GetAnySection(sal_False, pPt);
1594                         ASSERT( pSect, "Welcher Bereich?");
1595                         if( pSect )
1596                         {
1597                             SwSectionFmt *pFmt = pSect->GetFmt();
1598                             const SwFmtCol& rCol = pFmt->GetCol();
1599                             if(rSh.IsInRightToLeftText())
1600                                 nNum = rCol.GetColumns().Count() - nNum;
1601                             else
1602                                 --nNum;
1603                             SvxColumnItem aColItem(nNum);
1604                             SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
1605                             const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
1606 
1607                             ::lcl_FillSvxColumn(rCol, sal_uInt16(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0);
1608 
1609                             if(bVerticalWriting)
1610                             {
1611                                 aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
1612                                 aRect.Pos().Y() -= rPageRect.Top();
1613                                 aColItem.SetLeft ((sal_uInt16)(aRect.Top()));
1614                                 aColItem.SetRight((sal_uInt16)(nPageHeight   - aRect.Bottom() ));
1615                             }
1616                             else
1617                             {
1618                                 aRect.Pos() += aTmpRect.Pos();
1619 
1620                                 // PAGES01
1621                                 // make relative to page position:
1622                                 aColItem.SetLeft ((sal_uInt16)( aRect.Left() - rPageRect.Left() ));
1623                                 aColItem.SetRight((sal_uInt16)( rPageRect.Right() - aRect.Right()));
1624                             }
1625                             aColItem.SetOrtho(aColItem.CalcOrtho());
1626 
1627                             rSet.Put(aColItem, nWhich);
1628                         }
1629                     }
1630                     else if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
1631                     {
1632                         // Spalten in Rahmen
1633                         if ( nNum  )
1634                         {
1635                             const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
1636 
1637                             const SwFmtCol& rCol = pFmt->GetCol();
1638                             if(rSh.IsInRightToLeftText())
1639                                 nNum = rCol.GetColumns().Count() - nNum;
1640                             else
1641                                 nNum--;
1642                             SvxColumnItem aColItem(nNum);
1643                             const SwRect &rSizeRect = rSh.GetAnyCurRect(RECT_FLY_PRT_EMBEDDED, pPt);
1644 
1645                             sal_Bool bUseVertical = bFrameHasVerticalColumns || (!bFrmSelection && bVerticalWriting);
1646                             const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
1647                             const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
1648                             long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
1649                             ::lcl_FillSvxColumn(rCol, sal_uInt16(lWidth), aColItem, nDist2);
1650 
1651                             SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
1652                             rSh.GetFlyFrmAttr( aFrameSet );
1653 
1654                             if(bUseVertical)
1655                             {
1656                                 aColItem.SetLeft ((sal_uInt16)(rRect.Top()- rPageRect.Top()));
1657                                 aColItem.SetRight((sal_uInt16)(nPageHeight + rPageRect.Top() - rRect.Bottom() ));
1658                             }
1659                             else
1660                             {
1661                                 aColItem.SetLeft ((sal_uInt16)(rRect.Left() - rPageRect.Left()   ));
1662                                 aColItem.SetRight((sal_uInt16)(rPageRect.Right() - rRect.Right() ));
1663                             }
1664 
1665                             aColItem.SetOrtho(aColItem.CalcOrtho());
1666 
1667                             rSet.Put(aColItem, nWhich);
1668                         }
1669                         else
1670                             rSet.DisableItem(nWhich);
1671                     }
1672                     else
1673                     {	// Spalten auf der Seite
1674                         const SwFrmFmt& rMaster = rDesc.GetMaster();
1675                         SwFmtCol aCol(rMaster.GetCol());
1676                         if(rFrameDir.GetValue() == FRMDIR_HORI_RIGHT_TOP)
1677                             nNum = aCol.GetColumns().Count() - nNum;
1678                         else
1679                             nNum--;
1680 
1681                         SvxColumnItem aColItem(nNum);
1682                         const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
1683                         const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
1684                         long nDist = rBox.GetDistance();
1685                         ::lcl_FillSvxColumn(aCol,
1686                             sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
1687                             aColItem, nDist);
1688 
1689                         if(bBrowse)
1690                         {
1691                             aColItem.SetLeft((sal_uInt16)rPagePrtRect.Left());
1692                             aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
1693                         }
1694                         else
1695                         {
1696                             aColItem.SetLeft (aPageLRSpace.GetLeft());
1697                             aColItem.SetRight(aPageLRSpace.GetRight());
1698                         }
1699                         aColItem.SetOrtho(aColItem.CalcOrtho());
1700 
1701                         rSet.Put(aColItem, nWhich);
1702                     }
1703                 }
1704                 else
1705                     rSet.DisableItem(nWhich);
1706                 break;
1707             }
1708 
1709         case SID_RULER_ROWS :
1710         case SID_RULER_ROWS_VERTICAL:
1711             {
1712                 sal_Bool bFrameHasVerticalColumns(sal_False);
1713                 {
1714                     sal_Bool bFrameRTL;
1715                     sal_Bool bFrameVertL2R;
1716                     bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
1717                         bFrmSelection;
1718                 }
1719 
1720                 if( ( (SID_RULER_ROWS == nWhich) &&
1721                     ((!bVerticalWriting && !bFrmSelection) || (bFrmSelection && !bFrameHasVerticalColumns)) ) ||
1722                     ((SID_RULER_ROWS_VERTICAL == nWhich) &&
1723                     ((bVerticalWriting && !bFrmSelection) || bFrameHasVerticalColumns)))
1724                     rSet.DisableItem(nWhich);
1725                 else if ( IsTabRowFromDoc() ||
1726                     ( rSh.GetTableFmt() && !bFrmSelection &&
1727                     !(nFrmType & FRMTYPE_COLSECT ) ) )
1728                 {
1729                     SwTabCols aTabCols;
1730                     //no current value necessary
1731                     sal_uInt16    nNum = 0;
1732                     if ( 0 != ( bSetTabRowFromDoc = IsTabRowFromDoc() ) )
1733                     {
1734                         rSh.GetMouseTabRows( aTabCols, aTabColFromDocPos );
1735                     }
1736                     else
1737                     {
1738                         rSh.GetTabRows( aTabCols );
1739                     }
1740 
1741                     //                ASSERT(nNum <= aTabCols.Count(), "TabCol not found");
1742                     const int nLft = aTabCols.GetLeftMin();
1743                     const int nRgt = (sal_uInt16)(bVerticalWriting ? nPageWidth : nPageHeight) -
1744                         (aTabCols.GetLeftMin() +
1745                         aTabCols.GetRight());
1746 
1747                     const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
1748                     const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
1749 
1750                     SvxColumnItem aColItem(nNum, nL, nR);
1751 
1752                     sal_uInt16 nStart = 0,
1753                         nEnd;
1754 
1755                     for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
1756                     {
1757                         const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
1758                         if(bVerticalWriting)
1759                         {
1760                             nEnd  = sal_uInt16(aTabCols.GetRight() - rEntry.nPos);
1761                             SvxColumnDescription aColDesc( nStart, nEnd,
1762                                 aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin,
1763                                 !aTabCols.IsHidden(i) );
1764                             aColItem.Append(aColDesc);
1765                         }
1766                         else
1767                         {
1768                             nEnd  = sal_uInt16(rEntry.nPos - aTabCols.GetLeft());
1769                             SvxColumnDescription aColDesc( nStart, nEnd,
1770                                 sal_uInt16(rEntry.nMin - aTabCols.GetLeft()), sal_uInt16(rEntry.nMax - aTabCols.GetLeft()),
1771                                 !aTabCols.IsHidden(i) );
1772                             aColItem.Append(aColDesc);
1773                         }
1774                         nStart = nEnd;
1775                     }
1776                     if(bVerticalWriting)
1777                         nEnd = static_cast< sal_uInt16 >(aTabCols.GetRight());
1778                     else
1779                         nEnd = static_cast< sal_uInt16 >(aTabCols.GetLeft());
1780                     // put a position protection when the last row cannot be moved
1781                     // due to a page break inside of a row
1782                     if(!aTabCols.IsLastRowAllowedToChange())
1783                         bPutContentProtection = sal_True;
1784 
1785                     SvxColumnDescription aColDesc( nStart, nEnd,
1786                         aTabCols.GetRight(), aTabCols.GetRight(),
1787                         sal_False );
1788                     aColItem.Append(aColDesc);
1789 
1790                     rSet.Put(aColItem, nWhich);
1791                 }
1792                 else
1793                     rSet.DisableItem(nWhich);
1794             }
1795             break;
1796 
1797         case SID_RULER_PAGE_POS:
1798             {
1799                 // PAGES01
1800                 SvxPagePosSizeItem aPagePosSize(
1801                     Point( rPageRect.Left(), rPageRect.Top()) ,	nPageWidth, nPageHeight);
1802 
1803                 rSet.Put(aPagePosSize);
1804                 break;
1805             }
1806 
1807         case SID_RULER_LR_MIN_MAX:
1808             {
1809                 Rectangle aRectangle;
1810                 if( ( nFrmType & FRMTYPE_COLSECT ) && !IsTabColFromDoc() &&
1811                     ( nFrmType & ( FRMTYPE_TABLE|FRMTYPE_COLUMN ) ) )
1812                 {
1813                     if( nFrmType & FRMTYPE_TABLE )
1814                     {
1815                         const sal_uInt16 nNum = rSh.GetCurTabColNum();
1816                         SwTabCols aTabCols;
1817                         rSh.GetTabCols( aTabCols );
1818 
1819                         const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
1820                         const int nRgt = (sal_uInt16)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
1821 
1822                         const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
1823                         const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
1824 
1825                         aRectangle.Left() = nL;
1826                         if(nNum > 1)
1827                             aRectangle.Left() += aTabCols[nNum - 2];
1828                         if(nNum)
1829                             aRectangle.Left() += MINLAY;
1830                         if(aTabCols.Count() <= nNum + 1 )
1831                             aRectangle.Right() = nR;
1832                         else
1833                             aRectangle.Right() = nPageWidth - (nL + aTabCols[nNum + 1]);
1834 
1835                         if(nNum < aTabCols.Count())
1836                             aRectangle.Right() += MINLAY;
1837                     }
1838                     else
1839                     {
1840                         const SwFrmFmt* pFmt =  rSh.GetFlyFrmFmt();
1841                         const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
1842                             &rDesc.GetMaster().GetCol();
1843                         const SwColumns& rCols = pCols->GetColumns();
1844                         sal_uInt16 nNum = rSh.GetCurOutColNum();
1845                         sal_uInt16 nCount = Min(sal_uInt16(nNum + 1), rCols.Count());
1846                         const SwRect aRect( rSh.GetAnyCurRect( pFmt
1847                             ? RECT_FLY_PRT_EMBEDDED
1848                             : RECT_PAGE_PRT, pPt ));
1849                         const SwRect aAbsRect( rSh.GetAnyCurRect( pFmt
1850                             ? RECT_FLY_EMBEDDED
1851                             : RECT_PAGE, pPt ));
1852 
1853                         //die Breite im Rahmen bzw. innerhalbe der Seitenraender
1854                         const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
1855                         //die gesamte Rahmenbreite - die Differenz ist der doppelte Abstand zum Rand
1856                         const sal_uInt16 nOuterWidth = (sal_uInt16)aAbsRect.Width();
1857                         int nWidth = 0,
1858                             nStart = 0,
1859                             nEnd = 0;
1860                         aRectangle.Left() = 0;
1861                         for ( sal_uInt16 i = 0; i < nCount; ++i )
1862                         {
1863                             SwColumn* pCol = rCols[i];
1864                             nStart = pCol->GetLeft() + nWidth;
1865                             if(i == nNum - 2)
1866                                 aRectangle.Left() = nStart;
1867                             nWidth += pCols->CalcColWidth( i, nTotalWidth );
1868                             nEnd = nWidth - pCol->GetRight();
1869                         }
1870                         aRectangle.Right() = rPageRect.Right() - nEnd;
1871                         aRectangle.Left() -= rPageRect.Left();
1872 
1873                         if(nNum > 1)
1874                         {
1875                             aRectangle.Left() += MINLAY;
1876                             aRectangle.Left() += aRect.Left();
1877                         }
1878                         if(pFmt) //Bereich in Rahmen - hier darf man bis zum Rand
1879                             aRectangle.Left()  = aRectangle.Right() = 0;
1880                         else
1881                         {
1882                             // das Rechteck an die richtige absolute Position verschieben
1883                             aRectangle.Left() += aAbsRect.Left();
1884                             aRectangle.Right() -= aAbsRect.Left();
1885                             // Abstand zur Umrandung mit einbeziehen
1886                             aRectangle.Right() -= (nOuterWidth - nTotalWidth) / 2;
1887                         }
1888 
1889                         if(nNum < rCols.Count())
1890                         {
1891                             aRectangle.Right() += MINLAY;
1892                         }
1893                         else
1894                             // rechts ist jetzt nur noch der Seitenrand
1895                             aRectangle.Right() = 0;
1896 
1897 
1898                     }
1899                 }
1900                 else if ( ((nFrmType & FRMTYPE_TABLE) || IsTabColFromDoc()) &&
1901                     !bFrmSelection )
1902                 {
1903                     sal_Bool bColumn;
1904                     if ( IsTabColFromDoc() )
1905                         bColumn = rSh.GetCurMouseColNum( aTabColFromDocPos ) != 0;
1906                     else
1907                         bColumn = (nFrmType & (FRMTYPE_COLUMN|FRMTYPE_FLY_ANY|FRMTYPE_COLSECTOUTTAB))
1908                                   ? sal_True
1909                                   : sal_False;
1910                     if ( !bColumn )
1911                     {
1912                         if( nFrmType & FRMTYPE_FLY_ANY && IsTabColFromDoc() )
1913                         {
1914                             SwRect aRect( rSh.GetAnyCurRect(
1915                                 RECT_FLY_PRT_EMBEDDED, pPt ) );
1916                             aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
1917                                 pPt ).Pos();
1918 
1919                             aRectangle.Left()  = aRect.Left() - rPageRect.Left();
1920                             aRectangle.Right() = rPageRect.Right() - aRect.Right();
1921                         }
1922                         else if( bBrowse )
1923                         {
1924                             aRectangle.Left()  = rPagePrtRect.Left();
1925                             aRectangle.Right() = nPageWidth - rPagePrtRect.Right();
1926                         }
1927                         else
1928                         {
1929                             aRectangle.Left()  = aPageLRSpace.GetLeft();
1930                             aRectangle.Right() = aPageLRSpace.GetRight();
1931                         }
1932                     }
1933                     else
1934                     {	//hier nur fuer Tabelle in mehrspaltigen Seiten und Rahmen
1935                         sal_Bool bSectOutTbl = (nFrmType & FRMTYPE_TABLE) ? sal_True : sal_False;
1936                         sal_Bool bFrame = (nFrmType & FRMTYPE_FLY_ANY) ? sal_True : sal_False;
1937                         sal_Bool bColSct = 	(nFrmType & ( bSectOutTbl
1938                             ? FRMTYPE_COLSECTOUTTAB
1939                             : FRMTYPE_COLSECT )
1940                             ) ? sal_True : sal_False;
1941                         //Damit man auch mit der Mouse ziehen kann,
1942                         //ohne in der Tabelle zu stehen
1943                         CurRectType eRecType = RECT_PAGE_PRT;
1944                         sal_uInt16 nNum = IsTabColFromDoc() ?
1945                             rSh.GetCurMouseColNum( aTabColFromDocPos ):
1946                             rSh.GetCurOutColNum();
1947                         const SwFrmFmt* pFmt = NULL;
1948                         if( bColSct )
1949                         {
1950                             eRecType = bSectOutTbl ? RECT_OUTTABSECTION
1951                                 : RECT_SECTION;
1952                             const SwSection *pSect = rSh.GetAnySection( bSectOutTbl, pPt );
1953                             ASSERT( pSect, "Welcher Bereich?");
1954                             pFmt = pSect->GetFmt();
1955                         }
1956                         else if( bFrame )
1957                         {
1958                             pFmt = rSh.GetFlyFrmFmt();
1959                             eRecType = RECT_FLY_PRT_EMBEDDED;
1960                         }
1961 
1962                         const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
1963                             &rDesc.GetMaster().GetCol();
1964                         const SwColumns& rCols = pCols->GetColumns();
1965                         const sal_uInt16 nBorder = pFmt ? pFmt->GetBox().GetDistance() :
1966                             rDesc.GetMaster().GetBox().GetDistance();
1967 
1968                         /* RECT_FLY_PRT_EMBEDDED returns the relative position to
1969                         RECT_FLY_EMBEDDED
1970                         the absolute position must be added here
1971                         */
1972                         SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
1973                         if(RECT_FLY_PRT_EMBEDDED == eRecType)
1974                             aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
1975                             pPt ).Pos();
1976 
1977                         const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
1978                         //nStart und nEnd initialisieren fuer nNum == 0
1979                         int nWidth = 0,
1980                             nStart = 0,
1981                             nEnd = nTotalWidth;
1982 
1983                         if( nNum > rCols.Count() )
1984                         {
1985                             ASSERT( sal_False, "it is working on the wrong FmtCol!" );
1986                             nNum = rCols.Count();
1987                         }
1988 
1989                         for( sal_uInt16 i = 0; i < nNum; ++i )
1990                         {
1991                             SwColumn* pCol = rCols[i];
1992                             nStart = pCol->GetLeft() + nWidth;
1993                             nWidth += pCols->CalcColWidth( i, nTotalWidth );
1994                             nEnd = nWidth - pCol->GetRight();
1995                         }
1996                         if( bFrame | bColSct )
1997                         {
1998                             aRectangle.Left()  = aRect.Left() - rPageRect.Left() + nStart;
1999                             aRectangle.Right() = nPageWidth	- aRectangle.Left() - nEnd + nStart;
2000                         }
2001                         else if(!bBrowse)
2002                         {
2003                             aRectangle.Left()  = aPageLRSpace.GetLeft() + nStart;
2004                             aRectangle.Right() = nPageWidth - nEnd - aPageLRSpace.GetLeft();
2005                         }
2006                         else
2007                         {
2008                             long nLeft = rPagePrtRect.Left();
2009                             aRectangle.Left()  = nStart + nLeft;
2010                             aRectangle.Right() = nPageWidth - nEnd - nLeft;
2011                         }
2012                         if(!bFrame)
2013                         {
2014                             aRectangle.Left() += nBorder;
2015                             aRectangle.Right() -= nBorder;
2016                         }
2017                     }
2018                 }
2019                 else if ( nFrmType & ( FRMTYPE_HEADER  | FRMTYPE_FOOTER ))
2020                 {
2021                     aRectangle.Left()  = aPageLRSpace.GetLeft();
2022                     aRectangle.Right() = aPageLRSpace.GetRight();
2023                 }
2024                 else
2025                     aRectangle.Left()  = aRectangle.Right() = 0;
2026 
2027                 SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
2028                 rSet.Put(aLR);
2029             }
2030             break;
2031 
2032         case SID_RULER_PROTECT:
2033             {
2034                 if(bFrmSelection)
2035                 {
2036                     sal_uInt8 nProtect = pWrtShell->IsSelObjProtected( FLYPROTECT_SIZE|FLYPROTECT_POS|FLYPROTECT_CONTENT );
2037 
2038                     SvxProtectItem aProt(SID_RULER_PROTECT);
2039                     aProt.SetCntntProtect((nProtect & FLYPROTECT_CONTENT)	!= 0);
2040                     aProt.SetSizeProtect ((nProtect & FLYPROTECT_SIZE)		!= 0);
2041                     aProt.SetPosProtect  ((nProtect & FLYPROTECT_POS)		!= 0);
2042                     rSet.Put(aProt);
2043                 }
2044                 else
2045                 {
2046                     SvxProtectItem aProtect(SID_RULER_PROTECT);
2047                     if(bBrowse && !(nFrmType & (FRMTYPE_DRAWOBJ|FRMTYPE_COLUMN)) && !rSh.GetTableFmt())
2048                     {
2049                         aProtect.SetSizeProtect(sal_True);
2050                         aProtect.SetPosProtect(sal_True);
2051                     }
2052                     rSet.Put(aProtect);
2053                 }
2054             }
2055             break;
2056         }
2057         nWhich = aIter.NextWhich();
2058     }
2059     if(bPutContentProtection)
2060     {
2061         SvxProtectItem aProtect(SID_RULER_PROTECT);
2062         aProtect.SetCntntProtect(sal_True);
2063         rSet.Put(aProtect);
2064     }
2065 }
2066 
2067 
2068