bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / uiview / viewtab.cxx
blob92a39d742cd11b547258a35a4776dde423c3c31f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <hintids.hxx>
22 #include "uitool.hxx"
23 #include <sfx2/app.hxx>
24 #include <svx/rulritem.hxx>
25 #include <editeng/tstpitem.hxx>
26 #include <sfx2/request.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <editeng/ulspitem.hxx>
29 #include <editeng/boxitem.hxx>
30 #include <editeng/frmdiritem.hxx>
31 #include <svl/eitem.hxx>
32 #include <svl/whiter.hxx>
33 #include <svx/ruler.hxx>
34 #include <editeng/protitem.hxx>
35 #include <svl/rectitem.hxx>
36 #include <sfx2/bindings.hxx>
37 #include <fmtfsize.hxx>
38 #include <fmthdft.hxx>
39 #include <fmtclds.hxx>
40 #include <fmtornt.hxx>
41 #include <frmatr.hxx>
42 #include <edtwin.hxx>
43 #include "view.hxx"
44 #include "wrtsh.hxx"
45 #include "basesh.hxx"
46 #include "cmdid.h"
47 #include "viewopt.hxx"
48 #include "tabcol.hxx"
49 #include "frmfmt.hxx" // FrameFormat
50 #include "pagedesc.hxx" // Aktuelles Seitenformat
51 #include "wview.hxx"
52 #include "fmtcol.hxx"
53 #include "section.hxx"
55 #include "ndtxt.hxx"
56 #include "pam.hxx"
58 #include <IDocumentSettingAccess.hxx>
60 using namespace ::com::sun::star;
63 /*--------------------------------------------------------------------
64 Beschreibung: Debug-Methode
65 --------------------------------------------------------------------*/
67 /*--------------------------------------------------------------------
68 Beschreibung: Columns eintueten
69 --------------------------------------------------------------------*/
70 static void lcl_FillSvxColumn(const SwFmtCol& rCol,
71 sal_uInt16 nTotalWidth,
72 SvxColumnItem& rColItem,
73 long nDistance)
75 const SwColumns& rCols = rCol.GetColumns();
76 sal_uInt16 nWidth = 0;
78 bool bOrtho = rCol.IsOrtho() && rCols.size();
79 long nInnerWidth = 0;
80 if( bOrtho )
82 nInnerWidth = nTotalWidth;
83 for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
85 const SwColumn* pCol = &rCols[i];
86 nInnerWidth -= pCol->GetLeft() + pCol->GetRight();
88 if( nInnerWidth < 0 )
89 nInnerWidth = 0;
90 else
91 nInnerWidth /= rCols.size();
93 for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
95 const SwColumn* pCol = &rCols[i];
96 const sal_uInt16 nStart = sal_uInt16(pCol->GetLeft() + nWidth + nDistance);
97 if( bOrtho )
98 nWidth = static_cast< sal_uInt16 >(nWidth + nInnerWidth + pCol->GetLeft() + pCol->GetRight());
99 else
100 nWidth = static_cast< sal_uInt16 >(nWidth + rCol.CalcColWidth(i, nTotalWidth));
101 const sal_uInt16 nEnd = sal_uInt16(nWidth - pCol->GetRight() + nDistance);
103 SvxColumnDescription aColDesc(nStart, nEnd, sal_True);
104 rColItem.Append(aColDesc);
108 /*--------------------------------------------------------------------
109 Beschreibung: ColumnItem in ColumnInfo ueberfuehren
110 --------------------------------------------------------------------*/
111 static void lcl_ConvertToCols(const SvxColumnItem& rColItem,
112 sal_uInt16 nTotalWidth,
113 SwFmtCol& rCols)
115 OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
116 // ruler executes that change the columns shortly after the selection has changed
117 // can result in a crash
118 if(rCols.GetNumCols() != rColItem.Count())
119 return;
121 sal_uInt16 nLeft = 0;
122 SwTwips nSumAll= 0; // Summiere alle Spalten und Raender auf
124 SwColumns& rArr = rCols.GetColumns();
126 // Tabcols der Reihe nach
127 for( sal_uInt16 i=0; i < rColItem.Count()-1; ++i )
129 OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" );
130 sal_uInt16 nStart = static_cast< sal_uInt16 >(rColItem[i+1].nStart);
131 sal_uInt16 nEnd = static_cast< sal_uInt16 >(rColItem[i].nEnd);
132 if(nStart < nEnd)
133 nStart = nEnd;
134 const sal_uInt16 nDiff = nStart - nEnd;
135 const sal_uInt16 nRight = nDiff / 2;
137 sal_uInt16 nWidth = static_cast< sal_uInt16 >(rColItem[i].nEnd - rColItem[i].nStart);
138 nWidth += nLeft + nRight;
140 SwColumn* pCol = &rArr[i];
141 pCol->SetWishWidth( sal_uInt16(long(rCols.GetWishWidth()) * long(nWidth) /
142 long(nTotalWidth) ));
143 pCol->SetLeft( nLeft );
144 pCol->SetRight( nRight );
145 nSumAll += pCol->GetWishWidth();
147 nLeft = nRight;
149 rArr[rColItem.Count()-1].SetLeft( nLeft );
151 //Die Differenz aus der Gesamtwunschbreite und der Summe der bisher berechneten
152 // Spalten und Raender sollte die Breite der letzten Spalte ergeben.
153 rArr[rColItem.Count()-1].SetWishWidth( rCols.GetWishWidth() - (sal_uInt16)nSumAll );
155 rCols.SetOrtho(sal_False, 0, 0 );
158 /*--------------------------------------------------------------------
159 Beschreibung: Tabs loeschen
160 --------------------------------------------------------------------*/
161 static void lcl_EraseDefTabs(SvxTabStopItem& rTabStops)
163 // Def Tabs loeschen
164 for ( sal_uInt16 i = 0; i < rTabStops.Count(); )
166 // Hier auch den DefTab auf Null rausschmeissen
167 if ( SVX_TAB_ADJUST_DEFAULT == rTabStops[i].GetAdjustment() ||
168 rTabStops[i].GetTabPos() == 0 )
170 rTabStops.Remove(i);
171 continue;
173 ++i;
177 /*--------------------------------------------------------------------
178 Beschreibung: Seitenrand umdrehen
179 --------------------------------------------------------------------*/
180 void SwView::SwapPageMargin(const SwPageDesc& rDesc, SvxLRSpaceItem& rLRSpace)
182 sal_uInt16 nPhyPage, nVirPage;
183 GetWrtShell().GetPageNum( nPhyPage, nVirPage );
185 if ( rDesc.GetUseOn() == nsUseOnPage::PD_MIRROR && (nPhyPage % 2) == 0 )
187 long nTmp = rLRSpace.GetRight();
188 rLRSpace.SetRight( rLRSpace.GetLeft() );
189 rLRSpace.SetLeft( nTmp );
193 /*--------------------------------------------------------------------
194 Beschreibung: Wenn der Rahmenrand verschoben wird, sollen die
195 Spaltentrenner an der gleichen absoluten Position bleiben
196 --------------------------------------------------------------------*/
197 static void lcl_Scale(long& nVal, long nScale)
199 nVal *= nScale;
200 nVal >>= 8;
203 void ResizeFrameCols(SwFmtCol& rCol,
204 long nOldWidth,
205 long nNewWidth,
206 long nLeftDelta )
208 SwColumns& rArr = rCol.GetColumns();
209 long nWishSum = (long)rCol.GetWishWidth();
210 long nWishDiff = (nWishSum * 100/nOldWidth * nNewWidth) / 100 - nWishSum;
211 long nNewWishWidth = nWishSum + nWishDiff;
212 if(nNewWishWidth > 0xffffl)
214 // wenn die Wunschbreite zu gross wird, dann muessen alle Werte passend skaliert werden
215 long nScale = (0xffffl << 8)/ nNewWishWidth;
216 for(sal_uInt16 i = 0; i < rArr.size(); i++)
218 SwColumn* pCol = &rArr[i];
219 long nVal = pCol->GetWishWidth();
220 lcl_Scale(nVal, nScale);
221 pCol->SetWishWidth((sal_uInt16) nVal);
222 nVal = pCol->GetLeft();
223 lcl_Scale(nVal, nScale);
224 pCol->SetLeft((sal_uInt16) nVal);
225 nVal = pCol->GetRight();
226 lcl_Scale(nVal, nScale);
227 pCol->SetRight((sal_uInt16) nVal);
229 lcl_Scale(nNewWishWidth, nScale);
230 lcl_Scale(nWishDiff, nScale);
232 rCol.SetWishWidth( (sal_uInt16) (nNewWishWidth) );
234 if( nLeftDelta >= 2 || nLeftDelta <= -2)
235 rArr.front().SetWishWidth(rArr.front().GetWishWidth() + (sal_uInt16)nWishDiff);
236 else
237 rArr.back().SetWishWidth(rArr.back().GetWishWidth() + (sal_uInt16)nWishDiff);
238 //reset auto width
239 rCol.SetOrtho(sal_False, 0, 0 );
242 /*--------------------------------------------------------------------
243 Beschreibung: Hier werden alle Aenderungen der Tableiste
244 wieder in das Modell geschossen
245 --------------------------------------------------------------------*/
246 void SwView::ExecTabWin( SfxRequest& rReq )
248 SwWrtShell &rSh = GetWrtShell();
249 const sal_uInt16 nFrmType = rSh.IsObjSelected() ?
250 FRMTYPE_DRAWOBJ :
251 rSh.GetFrmType(0,sal_True);
252 const sal_Bool bFrmSelection = rSh.IsFrmSelected();
253 const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
255 const sal_uInt16 nSlot = rReq.GetSlot();
256 const SfxItemSet* pReqArgs = rReq.GetArgs();
257 const sal_uInt16 nDescId = rSh.GetCurPageDesc();
258 const SwPageDesc& rDesc = rSh.GetPageDesc( nDescId );
260 const bool bVerticalWriting = rSh.IsInVerticalText();
261 const SwFmtHeader& rHeaderFmt = rDesc.GetMaster().GetHeader();
262 SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
264 const SwFmtFooter& rFooterFmt = rDesc.GetMaster().GetFooter();
265 SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
267 const SwFmtFrmSize &rFrmSize = rDesc.GetMaster().GetFrmSize();
269 const SwRect& rPageRect = rSh.GetAnyCurRect(RECT_PAGE);
270 const long nPageWidth = bBrowse ? rPageRect.Width() : rFrmSize.GetWidth();
271 const long nPageHeight = bBrowse ? rPageRect.Height() : rFrmSize.GetHeight();
273 bool bUnlockView = false;
274 rSh.StartAllAction();
275 bool bSect = 0 != (nFrmType & FRMTYPE_COLSECT);
277 switch (nSlot)
279 case SID_ATTR_LONG_LRSPACE:
280 if ( pReqArgs )
282 SvxLongLRSpaceItem aLongLR( (const SvxLongLRSpaceItem&)pReqArgs->
283 Get( SID_ATTR_LONG_LRSPACE ) );
284 SvxLRSpaceItem aLR(RES_LR_SPACE);
285 if ( !bSect && (bFrmSelection || nFrmType & FRMTYPE_FLY_ANY) )
287 SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
288 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
290 bool bVerticalFrame(false);
292 sal_Bool bRTL;
293 sal_Bool bVertL2R;
294 bVerticalFrame = ( bFrmSelection &&
295 rSh.IsFrmVertical(sal_True, bRTL, bVertL2R) ) ||
296 ( !bFrmSelection && bVerticalWriting);
298 long nDeltaX = bVerticalFrame ?
299 rRect.Right() - rPageRect.Right() + aLongLR.GetRight() :
300 rPageRect.Left() + aLongLR.GetLeft() - rRect.Left();
302 SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
303 RES_VERT_ORIENT, RES_HORI_ORIENT,
304 RES_COL, RES_COL, 0 );
306 if(bVerticalFrame)
308 SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
309 aVertOrient.SetVertOrient(text::VertOrientation::NONE);
310 aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaX );
311 aSet.Put( aVertOrient );
313 else
315 SwFmtHoriOrient aHoriOrient( pFmt->GetHoriOrient() );
316 aHoriOrient.SetHoriOrient( text::HoriOrientation::NONE );
317 aHoriOrient.SetPos( aHoriOrient.GetPos() + nDeltaX );
318 aSet.Put( aHoriOrient );
321 SwFmtFrmSize aSize( pFmt->GetFrmSize() );
322 long nOldWidth = (long) aSize.GetWidth();
324 if(aSize.GetWidthPercent())
326 SwRect aRect;
327 rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
328 long nPrtWidth = aRect.Width();
329 aSize.SetWidthPercent(sal_uInt8((nPageWidth - aLongLR.GetLeft() - aLongLR.GetRight()) * 100 /nPrtWidth));
331 else
332 aSize.SetWidth( nPageWidth -
333 (aLongLR.GetLeft() + aLongLR.GetRight()));
335 if( nFrmType & FRMTYPE_COLUMN )
337 SwFmtCol aCol(pFmt->GetCol());
339 ::ResizeFrameCols(aCol, nOldWidth, (long)aSize.GetWidth(), nDeltaX );
340 aSet.Put(aCol);
343 aSet.Put( aSize );
345 rSh.StartAction();
346 rSh.Push();
347 rSh.SetFlyFrmAttr( aSet );
348 //die Rahmenselektion wieder aufheben
349 if(!bFrmSelection && rSh.IsFrmSelected())
351 rSh.UnSelectFrm();
352 rSh.LeaveSelFrmMode();
354 rSh.Pop();
355 rSh.EndAction();
357 else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
359 // Seitenraender rausrechnen
360 long nOld = rDesc.GetMaster().GetLRSpace().GetLeft();
361 aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
363 nOld = rDesc.GetMaster().GetLRSpace().GetRight();
364 aLongLR.SetRight( nOld > (sal_uInt16)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
365 aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
366 aLR.SetRight((sal_uInt16)aLongLR.GetRight());
368 if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
369 pHeaderFmt->SetFmtAttr( aLR );
370 else if( nFrmType & FRMTYPE_FOOTER && pFooterFmt )
371 pFooterFmt->SetFmtAttr( aLR );
373 else if( nFrmType == FRMTYPE_DRAWOBJ)
375 SwRect aRect( rSh.GetObjRect() );
376 aRect.Left( aLongLR.GetLeft() + rPageRect.Left() );
377 aRect.Right( rPageRect.Right() - aLongLR.GetRight());
378 rSh.SetObjRect( aRect );
380 else if(bSect || rSh.IsDirectlyInSection())
382 //change the section indents and the columns if available
383 //at first determine the changes
384 SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
385 const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
386 aSectRect.Pos() += aTmpRect.Pos();
387 long nLeftDiff = aLongLR.GetLeft() - (long)(aSectRect.Left() - rPageRect.Left() );
388 long nRightDiff = aLongLR.GetRight() - (long)( rPageRect.Right() - aSectRect.Right());
389 //change the LRSpaceItem of the section accordingly
390 const SwSection* pCurrSect = rSh.GetCurrSection();
391 const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
392 SvxLRSpaceItem aLRTmp = pSectFmt->GetLRSpace();
393 aLRTmp.SetLeft(aLRTmp.GetLeft() + nLeftDiff);
394 aLRTmp.SetRight(aLRTmp.GetRight() + nRightDiff);
395 SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
396 aSet.Put(aLRTmp);
397 //change the first/last column
398 if(bSect)
400 SwFmtCol aCols( pSectFmt->GetCol() );
401 long nDiffWidth = nLeftDiff + nRightDiff;
402 ::ResizeFrameCols(aCols, aSectRect.Width(), aSectRect.Width() - nDiffWidth, nLeftDiff );
403 aSet.Put( aCols );
405 SwSectionData aData(*pCurrSect);
406 rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
408 else
409 { // Seitenraender einstellen
410 aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
411 aLR.SetRight((sal_uInt16)aLongLR.GetRight());
412 SwapPageMargin( rDesc, aLR );
413 SwPageDesc aDesc( rDesc );
414 aDesc.GetMaster().SetFmtAttr( aLR );
415 rSh.ChgPageDesc( nDescId, aDesc );
418 break;
420 // apply new left and right margins to current page style
421 case SID_ATTR_PAGE_LRSPACE:
422 if ( pReqArgs )
424 const SvxLongLRSpaceItem aLongLR( static_cast<const SvxLongLRSpaceItem&>(pReqArgs->Get( SID_ATTR_PAGE_LRSPACE )) );
426 SwPageDesc aDesc( rDesc );
428 SvxLRSpaceItem aLR( RES_LR_SPACE );
429 aLR.SetLeft((sal_uInt16)aLongLR.GetLeft());
430 aLR.SetRight((sal_uInt16)aLongLR.GetRight());
431 SwapPageMargin( rDesc, aLR );
432 aDesc.GetMaster().SetFmtAttr( aLR );
434 rSh.ChgPageDesc( nDescId, aDesc );
436 break;
438 case SID_ATTR_LONG_ULSPACE:
439 if ( pReqArgs )
441 SvxLongULSpaceItem aLongULSpace( (const SvxLongULSpaceItem&)pReqArgs->
442 Get( SID_ATTR_LONG_ULSPACE ));
444 if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
446 SwFrmFmt* pFmt = ((SwFrmFmt*)rSh.GetFlyFrmFmt());
447 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED);
448 const long nDeltaY = rPageRect.Top() + aLongULSpace.GetUpper() - rRect.Top();
449 const long nHeight = nPageHeight - (aLongULSpace.GetUpper() + aLongULSpace.GetLower());
451 SfxItemSet aSet( GetPool(), RES_FRM_SIZE, RES_FRM_SIZE,
452 RES_VERT_ORIENT, RES_HORI_ORIENT, 0 );
453 //which of the orientation attributes is to be put depends on the frame's environment
454 sal_Bool bRTL;
455 sal_Bool bVertL2R;
456 if ( ( bFrmSelection &&
457 rSh.IsFrmVertical(sal_True, bRTL, bVertL2R ) ) ||
458 ( !bFrmSelection && bVerticalWriting ) )
460 SwFmtHoriOrient aHoriOrient(pFmt->GetHoriOrient());
461 aHoriOrient.SetHoriOrient(text::HoriOrientation::NONE);
462 aHoriOrient.SetPos(aHoriOrient.GetPos() + nDeltaY );
463 aSet.Put( aHoriOrient );
465 else
467 SwFmtVertOrient aVertOrient(pFmt->GetVertOrient());
468 aVertOrient.SetVertOrient(text::VertOrientation::NONE);
469 aVertOrient.SetPos(aVertOrient.GetPos() + nDeltaY );
470 aSet.Put( aVertOrient );
472 SwFmtFrmSize aSize(pFmt->GetFrmSize());
473 if(aSize.GetHeightPercent())
475 SwRect aRect;
476 rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
477 long nPrtHeight = aRect.Height();
478 aSize.SetHeightPercent(sal_uInt8(nHeight * 100 /nPrtHeight));
480 else
481 aSize.SetHeight(nHeight );
483 aSet.Put( aSize );
484 rSh.SetFlyFrmAttr( aSet );
486 else if( nFrmType == FRMTYPE_DRAWOBJ )
488 SwRect aRect( rSh.GetObjRect() );
489 aRect.Top( aLongULSpace.GetUpper() + rPageRect.Top() );
490 aRect.Bottom( rPageRect.Bottom() - aLongULSpace.GetLower() );
491 rSh.SetObjRect( aRect ) ;
493 else if(bVerticalWriting && (bSect || rSh.IsDirectlyInSection()))
495 //change the section indents and the columns if available
496 //at first determine the changes
497 SwRect aSectRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, 0);
498 const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, 0);
499 aSectRect.Pos() += aTmpRect.Pos();
500 const long nLeftDiff = aLongULSpace.GetUpper() - (long)(aSectRect.Top() - rPageRect.Top());
501 const long nRightDiff = aLongULSpace.GetLower() - (long)(nPageHeight - aSectRect.Bottom() + rPageRect.Top());
502 //change the LRSpaceItem of the section accordingly
503 const SwSection* pCurrSect = rSh.GetCurrSection();
504 const SwSectionFmt* pSectFmt = pCurrSect->GetFmt();
505 SvxLRSpaceItem aLR = pSectFmt->GetLRSpace();
506 aLR.SetLeft(aLR.GetLeft() + nLeftDiff);
507 aLR.SetRight(aLR.GetRight() + nRightDiff);
508 SfxItemSet aSet(rSh.GetAttrPool(), RES_LR_SPACE, RES_LR_SPACE, RES_COL, RES_COL, 0L);
509 aSet.Put(aLR);
510 //change the first/last column
511 if(bSect)
513 SwFmtCol aCols( pSectFmt->GetCol() );
514 long nDiffWidth = nLeftDiff + nRightDiff;
515 ::ResizeFrameCols(aCols, aSectRect.Height(), aSectRect.Height() - nDiffWidth, nLeftDiff );
516 aSet.Put( aCols );
518 SwSectionData aData(*pCurrSect);
519 rSh.UpdateSection(rSh.GetSectionFmtPos(*pSectFmt), aData, &aSet);
521 else
522 { SwPageDesc aDesc( rDesc );
524 if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
527 const bool bHead = nFrmType & FRMTYPE_HEADER;
528 SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
529 if ( bHead )
530 aUL.SetUpper( (sal_uInt16)aLongULSpace.GetUpper() );
531 else
532 aUL.SetLower( (sal_uInt16)aLongULSpace.GetLower() );
533 aDesc.GetMaster().SetFmtAttr( aUL );
535 if( (bHead && pHeaderFmt) || (!bHead && pFooterFmt) )
537 SwFmtFrmSize aSz( bHead ? pHeaderFmt->GetFrmSize() :
538 pFooterFmt->GetFrmSize() );
539 aSz.SetHeightSizeType( ATT_FIX_SIZE );
540 aSz.SetHeight(nPageHeight - aLongULSpace.GetLower() -
541 aLongULSpace.GetUpper() );
542 if ( bHead )
543 pHeaderFmt->SetFmtAttr( aSz );
544 else
545 pFooterFmt->SetFmtAttr( aSz );
548 else
550 SvxULSpaceItem aUL(RES_UL_SPACE);
551 aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
552 aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
553 aDesc.GetMaster().SetFmtAttr(aUL);
556 rSh.ChgPageDesc( nDescId, aDesc );
559 break;
561 // apply new top and bottom margins to current page style
562 case SID_ATTR_PAGE_ULSPACE:
563 if ( pReqArgs )
565 SvxLongULSpaceItem aLongULSpace(
566 static_cast<const SvxLongULSpaceItem&>(pReqArgs->Get( SID_ATTR_PAGE_ULSPACE ) ) );
568 SwPageDesc aDesc( rDesc );
570 SvxULSpaceItem aUL(RES_UL_SPACE);
571 aUL.SetUpper((sal_uInt16)aLongULSpace.GetUpper());
572 aUL.SetLower((sal_uInt16)aLongULSpace.GetLower());
573 aDesc.GetMaster().SetFmtAttr(aUL);
575 rSh.ChgPageDesc( nDescId, aDesc );
577 break;
579 case SID_ATTR_PAGE_COLUMN:
580 if ( pReqArgs )
582 const SfxInt16Item aColumnItem( (const SfxInt16Item&)pReqArgs->Get(nSlot) );
583 const sal_uInt16 nPageColumnType = aColumnItem.GetValue();
585 // nPageColumnType =
586 // 1 - single-columned page
587 // 2 - two-columned page
588 // 3 - three-columned page
589 // 4 - two-columned page with left column width of 2/3 of page width
590 // 5 - two-columned page with right column width of 2/3 of page width
592 sal_uInt16 nCount = 2;
593 if ( nPageColumnType == 1 )
595 nCount = 0;
597 else if ( nPageColumnType == 3 )
599 nCount = 3;
602 const sal_uInt16 nGutterWidth = 0;
604 const SvxLRSpaceItem aLR( rDesc.GetMaster().GetLRSpace() );
605 const long nLeft = aLR.GetLeft();
606 const long nRight = aLR.GetRight();
607 const long nWidth = nPageWidth - nLeft - nRight;
609 SwFmtCol aCols( rDesc.GetMaster().GetCol() );
610 aCols.Init( nCount, nGutterWidth, nWidth );
611 aCols.SetWishWidth( nWidth );
612 aCols.SetGutterWidth( nGutterWidth, nWidth );
613 aCols.SetOrtho( sal_False, nGutterWidth, nWidth );
615 long nColumnLeft = 0;
616 long nColumnRight = 0;
617 if ( nPageColumnType == 4 )
619 nColumnRight = (long)(nWidth/3);
620 nColumnLeft = nWidth - nColumnRight;
621 aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
622 aCols.GetColumns()[1].SetWishWidth( nColumnRight );
624 else if ( nPageColumnType == 5 )
626 nColumnLeft = (long)(nWidth/3);
627 nColumnRight = nWidth - nColumnLeft;
628 aCols.GetColumns()[0].SetWishWidth( nColumnLeft );
629 aCols.GetColumns()[1].SetWishWidth( nColumnRight );
632 SwPageDesc aDesc( rDesc );
633 aDesc.GetMaster().SetFmtAttr( aCols );
634 rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
636 break;
638 case SID_ATTR_TABSTOP_VERTICAL:
639 case SID_ATTR_TABSTOP:
640 if (pReqArgs)
642 sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
643 SvxTabStopItem aTabStops( (const SvxTabStopItem&)pReqArgs->
644 Get( nWhich ));
645 aTabStops.SetWhich(RES_PARATR_TABSTOP);
646 const SvxTabStopItem& rDefTabs =
647 (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
649 // Default-Tab an Pos 0
650 SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
651 rSh.GetCurAttr( aSet );
652 const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)aSet.Get(RES_LR_SPACE);
654 if ( rLR.GetTxtFirstLineOfst() < 0 )
656 SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
657 aTabStops.Insert( aSwTabStop );
660 // auffuellen mit Default-Tabs
661 sal_uInt16 nDef = ::GetTabDist( rDefTabs );
662 ::MakeDefTabs( nDef, aTabStops );
664 SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
665 if( pColl && pColl->IsAutoUpdateFmt() )
667 SfxItemSet aTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
668 aTmp.Put(aTabStops);
669 rSh.AutoUpdatePara( pColl, aTmp );
671 else
672 rSh.SetAttr( aTabStops );
674 break;
676 case SID_ATTR_PARA_LRSPACE_VERTICAL:
677 case SID_ATTR_PARA_LRSPACE:
678 if ( pReqArgs )
680 SvxLRSpaceItem aParaMargin((const SvxLRSpaceItem&)pReqArgs->Get(nSlot));
682 aParaMargin.SetRight( aParaMargin.GetRight() - m_nRightBorderDistance );
683 aParaMargin.SetTxtLeft(aParaMargin.GetTxtLeft() - m_nLeftBorderDistance );
685 aParaMargin.SetWhich( RES_LR_SPACE );
686 SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
688 // #i23726#
689 if (m_pNumRuleNodeFromDoc)
691 // --> #i42922# Mouse move of numbering label
692 // has to consider the left indent of the paragraph
693 SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE );
694 rSh.GetCurAttr( aSet );
695 const SvxLRSpaceItem& rLR =
696 static_cast<const SvxLRSpaceItem&>(aSet.Get(RES_LR_SPACE));
698 SwPosition aPos(*m_pNumRuleNodeFromDoc);
699 // #i90078#
700 rSh.SetIndent( static_cast< short >(aParaMargin.GetTxtLeft() - rLR.GetTxtLeft()), aPos);
701 // #i42921# invalidate state of indent in order to get a ruler update.
702 aParaMargin.SetWhich( nSlot );
703 GetViewFrame()->GetBindings().SetState( aParaMargin );
705 else if( pColl && pColl->IsAutoUpdateFmt() )
707 SfxItemSet aSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
708 aSet.Put(aParaMargin);
709 rSh.AutoUpdatePara( pColl, aSet);
711 else
712 rSh.SetAttr( aParaMargin );
714 if ( aParaMargin.GetTxtFirstLineOfst() < 0 )
716 SfxItemSet aSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP );
718 rSh.GetCurAttr( aSet );
719 const SvxTabStopItem& rTabStops = (const SvxTabStopItem&)aSet.Get(RES_PARATR_TABSTOP);
721 // Haben wir einen Tab an Stelle Null
722 sal_uInt16 i;
724 for ( i = 0; i < rTabStops.Count(); ++i )
725 if ( rTabStops[i].GetTabPos() == 0 )
726 break;
728 if ( i >= rTabStops.Count() )
730 // Kein DefTab
731 SvxTabStopItem aTabStops( RES_PARATR_TABSTOP );
732 aTabStops = rTabStops;
734 ::lcl_EraseDefTabs(aTabStops);
736 SvxTabStop aSwTabStop( 0, SVX_TAB_ADJUST_DEFAULT );
737 aTabStops.Insert(aSwTabStop);
739 const SvxTabStopItem& rDefTabs =
740 (const SvxTabStopItem&)rSh.GetDefault(RES_PARATR_TABSTOP);
741 sal_uInt16 nDef = ::GetTabDist(rDefTabs);
742 ::MakeDefTabs( nDef, aTabStops );
744 if( pColl && pColl->IsAutoUpdateFmt())
746 SfxItemSet aSetTmp(GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP);
747 aSetTmp.Put(aTabStops);
748 rSh.AutoUpdatePara( pColl, aSetTmp );
750 else
751 rSh.SetAttr( aTabStops );
755 break;
757 case SID_ATTR_PARA_ULSPACE:
758 if ( pReqArgs )
760 SvxULSpaceItem aParaMargin((const SvxULSpaceItem&)pReqArgs->Get(nSlot));
762 long nUDist = 0;
763 long nLDist = 0;
764 aParaMargin.SetUpper( aParaMargin.GetUpper() - nUDist );
765 aParaMargin.SetLower(aParaMargin.GetLower() - nLDist);
767 aParaMargin.SetWhich( RES_UL_SPACE );
768 SwTxtFmtColl* pColl = rSh.GetCurTxtFmtColl();
769 if( pColl && pColl->IsAutoUpdateFmt() )
771 SfxItemSet aSet(GetPool(), RES_UL_SPACE, RES_UL_SPACE);
772 aSet.Put(aParaMargin);
773 rSh.AutoUpdatePara( pColl, aSet);
775 else
776 rSh.SetAttr( aParaMargin );
778 break;
780 case SID_RULER_BORDERS_VERTICAL:
781 case SID_RULER_BORDERS:
782 if ( pReqArgs )
784 SvxColumnItem aColItem((const SvxColumnItem&)pReqArgs->Get(nSlot));
786 if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
788 OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
790 const sal_Bool bSingleLine = ((const SfxBoolItem&)rReq.
791 GetArgs()->Get(SID_RULER_ACT_LINE_ONLY)).GetValue();
793 SwTabCols aTabCols;
794 if ( m_bSetTabColFromDoc )
795 rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
796 else
797 rSh.GetTabCols(aTabCols);
799 // linker Tabellenrand
800 long nBorder = (long)(aColItem.GetLeft() - aTabCols.GetLeftMin());
801 aTabCols.SetLeft( nBorder );
803 nBorder = (bVerticalWriting ? nPageHeight : nPageWidth) - aTabCols.GetLeftMin() - aColItem.GetRight();
805 if ( aColItem.GetRight() > 0 )
806 aTabCols.SetRight( nBorder );
808 // Tabcols der Reihe nach
809 // Die letzte Col wird durch den Rand definiert
810 //columns in right-to-left tables need to be mirrored
811 sal_Bool bIsTableRTL =
812 IsTabColFromDoc() ?
813 rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
814 : rSh.IsTableRightToLeft();
815 if(bIsTableRTL)
817 sal_uInt16 nColCount = aColItem.Count() - 1;
818 for ( sal_uInt16 i = 0; i < nColCount && i < aTabCols.Count(); ++i )
820 const SvxColumnDescription& rCol = aColItem[nColCount - i];
821 aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
822 aTabCols.SetHidden( i, !rCol.bVisible );
825 else
827 for ( sal_uInt16 i = 0; i < aColItem.Count()-1 && i < aTabCols.Count(); ++i )
829 const SvxColumnDescription& rCol = aColItem[i];
830 aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
831 aTabCols.SetHidden( i, !rCol.bVisible );
835 if ( m_bSetTabColFromDoc )
837 if( !rSh.IsViewLocked() )
839 bUnlockView = true;
840 rSh.LockView( sal_True );
842 rSh.SetMouseTabCols( aTabCols, bSingleLine,
843 m_aTabColFromDocPos );
845 else
846 rSh.SetTabCols(aTabCols, bSingleLine);
849 else
851 if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY || bSect)
853 SwSectionFmt *pSectFmt = 0;
854 SfxItemSet aSet( GetPool(), RES_COL, RES_COL );
855 if(bSect)
857 const SwSection *pSect = rSh.GetAnySection();
858 OSL_ENSURE( pSect, "Which section?");
859 pSectFmt = pSect->GetFmt();
861 else
863 rSh.GetFlyFrmAttr( aSet );
865 SwFmtCol aCols(
866 bSect ?
867 pSectFmt->GetCol() :
868 (const SwFmtCol&)aSet.Get( RES_COL, sal_False ));
869 SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
870 const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
871 ::lcl_ConvertToCols( aColItem, sal_uInt16(lWidth), aCols );
872 aSet.Put( aCols );
873 if(bSect)
874 rSh.SetSectionAttr( aSet, pSectFmt );
875 else
877 rSh.StartAction();
878 rSh.Push();
879 rSh.SetFlyFrmAttr( aSet );
880 //die Rahmenselektion wieder aufheben
881 if(!bFrmSelection && rSh.IsFrmSelected())
883 rSh.UnSelectFrm();
884 rSh.LeaveSelFrmMode();
886 rSh.Pop();
887 rSh.EndAction();
890 else
892 SwFmtCol aCols( rDesc.GetMaster().GetCol() );
893 const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
894 ::lcl_ConvertToCols( aColItem,
895 sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()),
896 aCols );
897 SwPageDesc aDesc( rDesc );
898 aDesc.GetMaster().SetFmtAttr( aCols );
899 rSh.ChgPageDesc( rSh.GetCurPageDesc(), aDesc );
903 break;
905 case SID_RULER_ROWS :
906 case SID_RULER_ROWS_VERTICAL:
907 if (pReqArgs)
909 SvxColumnItem aColItem((const SvxColumnItem&)pReqArgs->Get(nSlot));
911 if( m_bSetTabColFromDoc || (!bSect && rSh.GetTableFmt()) )
913 OSL_ENSURE(aColItem.Count(), "ColDesc is empty!!");
915 SwTabCols aTabCols;
916 if ( m_bSetTabRowFromDoc )
917 rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
918 else
919 rSh.GetTabRows(aTabCols);
921 if ( bVerticalWriting )
923 aTabCols.SetRight(nPageWidth - aColItem.GetRight() - aColItem.GetLeft());
924 aTabCols.SetLeftMin(aColItem.GetLeft());
926 else
928 long nBorder = nPageHeight - aTabCols.GetLeftMin() - aColItem.GetRight();
929 aTabCols.SetRight( nBorder );
932 if(bVerticalWriting)
934 for ( sal_uInt16 i = aColItem.Count() - 1; i; --i )
936 const SvxColumnDescription& rCol = aColItem[i - 1];
937 long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
938 aTabCols[i - 1] = nColumnPos;
939 aTabCols.SetHidden( i - 1, !rCol.bVisible );
942 else
944 for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i )
946 const SvxColumnDescription& rCol = aColItem[i];
947 aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
948 aTabCols.SetHidden( i, !rCol.bVisible );
951 sal_Bool bSingleLine = sal_False;
952 const SfxPoolItem* pSingleLine;
953 if( SFX_ITEM_SET == rReq.GetArgs()->GetItemState(SID_RULER_ACT_LINE_ONLY, sal_False, &pSingleLine))
954 bSingleLine = ((const SfxBoolItem*)pSingleLine)->GetValue();
955 if ( m_bSetTabRowFromDoc )
957 if( !rSh.IsViewLocked() )
959 bUnlockView = true;
960 rSh.LockView( sal_True );
962 rSh.SetMouseTabRows( aTabCols, bSingleLine, m_aTabColFromDocPos );
964 else
965 rSh.SetTabRows(aTabCols, bSingleLine);
968 break;
970 default:
971 OSL_ENSURE( !this, "wrong SlotId");
973 rSh.EndAllAction();
975 if( bUnlockView )
976 rSh.LockView( sal_False );
978 m_bSetTabColFromDoc = m_bSetTabRowFromDoc = m_bTabColFromDoc = m_bTabRowFromDoc = sal_False;
979 SetNumRuleNodeFromDoc(NULL);
982 /*--------------------------------------------------------------------
983 Beschreibung: Hier wird der Status der Tableiste ermittelt
984 sprich alle relevanten Attribute an der CursorPos
985 werden der Tableiste uebermittelt
986 --------------------------------------------------------------------*/
987 void SwView::StateTabWin(SfxItemSet& rSet)
989 SwWrtShell &rSh = GetWrtShell();
991 const Point* pPt = IsTabColFromDoc() || IsTabRowFromDoc() ? &m_aTabColFromDocPos : 0;
992 const sal_uInt16 nFrmType = rSh.IsObjSelected()
993 ? FRMTYPE_DRAWOBJ
994 : rSh.GetFrmType( pPt, sal_True );
996 const sal_Bool bFrmSelection = rSh.IsFrmSelected();
997 const sal_Bool bBrowse = rSh.GetViewOptions()->getBrowseMode();
998 // PageOffset/Begrenzer
999 const SwRect& rPageRect = rSh.GetAnyCurRect( RECT_PAGE, pPt );
1000 const SwRect& rPagePrtRect = rSh.GetAnyCurRect( RECT_PAGE_PRT, pPt );
1001 const long nPageWidth = rPageRect.Width();
1002 const long nPageHeight = rPageRect.Height();
1004 const SwPageDesc& rDesc = rSh.GetPageDesc(
1005 IsTabColFromDoc() || m_bTabRowFromDoc ?
1006 rSh.GetMousePageDesc(m_aTabColFromDocPos) : rSh.GetCurPageDesc() );
1008 const SvxFrameDirectionItem& rFrameDir = rDesc.GetMaster().GetFrmDir();
1009 const bool bVerticalWriting = rSh.IsInVerticalText();
1011 //enable tab stop display on the rulers depending on the writing direction
1012 WinBits nRulerStyle = m_pHRuler->GetStyle() & ~WB_EXTRAFIELD;
1013 m_pHRuler->SetStyle(bVerticalWriting||bBrowse ? nRulerStyle : nRulerStyle|WB_EXTRAFIELD);
1014 nRulerStyle = m_pVRuler->GetStyle() & ~WB_EXTRAFIELD;
1015 m_pVRuler->SetStyle(bVerticalWriting ? nRulerStyle|WB_EXTRAFIELD : nRulerStyle);
1017 //#i24363# tab stops relative to indent
1018 bool bRelative = rSh.getIDocumentSettingAccess()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
1019 m_pHRuler->SetTabsRelativeToIndent( bRelative );
1020 m_pVRuler->SetTabsRelativeToIndent( bRelative );
1022 SvxLRSpaceItem aPageLRSpace( rDesc.GetMaster().GetLRSpace() );
1023 SwapPageMargin( rDesc, aPageLRSpace );
1025 SfxItemSet aCoreSet( GetPool(), RES_PARATR_TABSTOP, RES_PARATR_TABSTOP,
1026 RES_LR_SPACE, RES_UL_SPACE, 0 );
1027 // get also the list level indent values merged as LR-SPACE item, if needed.
1028 rSh.GetCurAttr( aCoreSet, true );
1029 SelectionType nSelType = rSh.GetSelectionType();
1031 SfxWhichIter aIter( rSet );
1032 sal_uInt16 nWhich = aIter.FirstWhich();
1033 bool bPutContentProtection = false;
1035 while ( nWhich )
1037 switch ( nWhich )
1040 case SID_ATTR_PAGE_COLUMN:
1042 sal_uInt16 nColumnType = 0;
1044 const SwFrmFmt& rMaster = rDesc.GetMaster();
1045 SwFmtCol aCol(rMaster.GetCol());
1046 const sal_uInt16 nCols = aCol.GetNumCols();
1047 if ( nCols == 0 )
1049 nColumnType = 1;
1051 else if ( nCols == 2 )
1053 const sal_uInt16 nColLeft = aCol.CalcPrtColWidth(0, aCol.GetWishWidth());
1054 const sal_uInt16 nColRight = aCol.CalcPrtColWidth(1, aCol.GetWishWidth());
1056 if ( abs(nColLeft - nColRight) <= 10 )
1058 nColumnType = 2;
1060 else if( abs(nColLeft - nColRight*2) < 20 )
1062 nColumnType = 4;
1064 else if( abs(nColLeft*2 - nColRight) < 20 )
1066 nColumnType = 5;
1069 else if( nCols == 3 )
1071 nColumnType = 3;
1074 rSet.Put( SfxInt16Item( SID_ATTR_PAGE_COLUMN, nColumnType ) );
1076 break;
1078 case SID_ATTR_LONG_LRSPACE:
1080 SvxLongLRSpaceItem aLongLR( (long)aPageLRSpace.GetLeft(),
1081 (long)aPageLRSpace.GetRight(),
1082 SID_ATTR_LONG_LRSPACE);
1083 if(bBrowse)
1085 aLongLR.SetLeft(rPagePrtRect.Left());
1086 aLongLR.SetRight(nPageWidth - rPagePrtRect.Right());
1088 if ( ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) &&
1089 !(nFrmType & FRMTYPE_COLSECT) )
1091 SwFrmFmt *pFmt = (SwFrmFmt*) (nFrmType & FRMTYPE_HEADER ?
1092 rDesc.GetMaster().GetHeader().GetHeaderFmt() :
1093 rDesc.GetMaster().GetFooter().GetFooterFmt());
1094 if( pFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
1096 SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
1097 aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
1098 const SvxLRSpaceItem& aLR = pFmt->GetLRSpace();
1099 aLongLR.SetLeft ( (long)aLR.GetLeft() + (long)aRect.Left() );
1100 aLongLR.SetRight( (nPageWidth -
1101 (long)aRect.Right() + (long)aLR.GetRight()));
1104 else
1106 SwRect aRect;
1107 if( !bFrmSelection && ((nFrmType & FRMTYPE_COLSECT) || rSh.IsDirectlyInSection()) )
1109 aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
1110 const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
1111 aRect.Pos() += aTmpRect.Pos();
1114 else if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
1115 aRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
1116 else if( nFrmType & FRMTYPE_DRAWOBJ)
1117 aRect = rSh.GetObjRect();
1119 if( aRect.Width() )
1121 // make relative to page position:
1122 aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() ));
1123 aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right()));
1126 if( nWhich == SID_ATTR_LONG_LRSPACE )
1127 rSet.Put( aLongLR );
1128 else
1130 SvxLRSpaceItem aLR( aLongLR.GetLeft(),
1131 aLongLR.GetRight(),
1132 0, 0,
1133 nWhich);
1134 rSet.Put(aLR);
1136 break;
1139 // provide left and right margins of current page style
1140 case SID_ATTR_PAGE_LRSPACE:
1142 const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
1143 const SvxLongLRSpaceItem aLongLR(
1144 (long)aTmpPageLRSpace.GetLeft(),
1145 (long)aTmpPageLRSpace.GetRight(),
1146 SID_ATTR_PAGE_LRSPACE );
1147 rSet.Put( aLongLR );
1149 break;
1151 case SID_ATTR_LONG_ULSPACE:
1153 // Rand Seite Oben Unten
1154 SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
1155 SvxLongULSpaceItem aLongUL( (long)aUL.GetUpper(),
1156 (long)aUL.GetLower(),
1157 SID_ATTR_LONG_ULSPACE);
1159 if ( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
1161 // Dokumentkoordinaten Frame auf Seitenkoordinaten umbrechen
1162 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
1163 aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() ));
1164 aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() ));
1166 else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
1168 SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
1169 aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
1170 aLongUL.SetUpper( (sal_uInt16)aRect.Top() );
1171 aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) );
1173 else if( nFrmType & FRMTYPE_DRAWOBJ)
1175 const SwRect &rRect = rSh.GetObjRect();
1176 aLongUL.SetUpper((rRect.Top() - rPageRect.Top()));
1177 aLongUL.SetLower((rPageRect.Bottom() - rRect.Bottom()));
1179 else if(bBrowse)
1181 aLongUL.SetUpper(rPagePrtRect.Top());
1182 aLongUL.SetLower(nPageHeight - rPagePrtRect.Bottom());
1184 if( nWhich == SID_ATTR_LONG_ULSPACE )
1185 rSet.Put( aLongUL );
1186 else
1188 SvxULSpaceItem aULTmp((sal_uInt16)aLongUL.GetUpper(),
1189 (sal_uInt16)aLongUL.GetLower(),
1190 nWhich);
1191 rSet.Put(aULTmp);
1193 break;
1196 // provide top and bottom margins of current page style
1197 case SID_ATTR_PAGE_ULSPACE:
1199 const SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
1200 SvxLongULSpaceItem aLongUL(
1201 (long)aUL.GetUpper(),
1202 (long)aUL.GetLower(),
1203 SID_ATTR_PAGE_ULSPACE );
1205 rSet.Put( aLongUL );
1207 break;
1209 case SID_ATTR_TABSTOP_VERTICAL :
1210 case RES_PARATR_TABSTOP:
1212 if ( ISA( SwWebView ) ||
1213 IsTabColFromDoc() ||
1214 IsTabRowFromDoc() ||
1215 ( nSelType & nsSelectionType::SEL_GRF ) ||
1216 ( nSelType & nsSelectionType::SEL_FRM ) ||
1217 ( nSelType & nsSelectionType::SEL_OLE ) ||
1218 ( SFX_ITEM_AVAILABLE > aCoreSet.GetItemState(RES_LR_SPACE) ) ||
1219 (!bVerticalWriting && (SID_ATTR_TABSTOP_VERTICAL == nWhich) ) ||
1220 ( bVerticalWriting && (RES_PARATR_TABSTOP == nWhich))
1222 rSet.DisableItem( nWhich );
1223 else
1225 SvxTabStopItem aTabStops((const SvxTabStopItem&)
1226 aCoreSet.Get( RES_PARATR_TABSTOP ));
1228 const SvxTabStopItem& rDefTabs = (const SvxTabStopItem&)
1229 rSh.GetDefault(RES_PARATR_TABSTOP);
1231 OSL_ENSURE(m_pHRuler, "why is there no ruler?");
1232 long nDefTabDist = ::GetTabDist(rDefTabs);
1233 m_pHRuler->SetDefTabDist( nDefTabDist );
1234 m_pVRuler->SetDefTabDist( nDefTabDist );
1235 ::lcl_EraseDefTabs(aTabStops);
1236 rSet.Put(aTabStops, nWhich);
1238 break;
1241 case SID_ATTR_PARA_LRSPACE_VERTICAL:
1242 case SID_ATTR_PARA_LRSPACE:
1244 if ( nSelType & nsSelectionType::SEL_GRF ||
1245 nSelType & nsSelectionType::SEL_FRM ||
1246 nSelType & nsSelectionType::SEL_OLE ||
1247 nFrmType == FRMTYPE_DRAWOBJ ||
1248 (!bVerticalWriting && (SID_ATTR_PARA_LRSPACE_VERTICAL == nWhich)) ||
1249 ( bVerticalWriting && (SID_ATTR_PARA_LRSPACE == nWhich))
1252 rSet.DisableItem(nWhich);
1254 else
1256 SvxLRSpaceItem aLR( RES_LR_SPACE );
1257 if ( !IsTabColFromDoc() )
1259 aLR = (const SvxLRSpaceItem&)aCoreSet.Get(RES_LR_SPACE);
1261 // #i23726#
1262 if (m_pNumRuleNodeFromDoc)
1264 short nOffset = static_cast< short >(aLR.GetTxtLeft() +
1265 // #i42922# Mouse move of numbering label
1266 // has to consider the left indent of the paragraph
1267 m_pNumRuleNodeFromDoc->GetLeftMarginWithNum( sal_True ) );
1269 short nFLOffset;
1270 m_pNumRuleNodeFromDoc->GetFirstLineOfsWithNum( nFLOffset );
1272 aLR.SetLeft( nOffset + nFLOffset );
1275 aLR.SetWhich(nWhich);
1276 rSet.Put(aLR);
1278 break;
1281 case SID_ATTR_PARA_ULSPACE:
1283 SvxULSpaceItem aUL = (const SvxULSpaceItem&)aCoreSet.Get(RES_UL_SPACE);
1284 aUL.SetWhich(nWhich);
1286 SfxItemState e = aCoreSet.GetItemState(RES_UL_SPACE);
1287 if( e >= SFX_ITEM_AVAILABLE )
1288 rSet.Put( aUL );
1289 else
1290 rSet.InvalidateItem(nWhich);
1292 break;
1294 case SID_RULER_BORDER_DISTANCE:
1296 m_nLeftBorderDistance = 0;
1297 m_nRightBorderDistance = 0;
1298 if ( nSelType & nsSelectionType::SEL_GRF ||
1299 nSelType & nsSelectionType::SEL_FRM ||
1300 nSelType & nsSelectionType::SEL_OLE ||
1301 nFrmType == FRMTYPE_DRAWOBJ )
1302 rSet.DisableItem(SID_RULER_BORDER_DISTANCE);
1303 else
1305 SvxLRSpaceItem aDistLR(SID_RULER_BORDER_DISTANCE);
1306 if(nFrmType & FRMTYPE_FLY_ANY)
1308 if( IsTabColFromDoc() )
1310 const SwRect& rFlyPrtRect = rSh.GetAnyCurRect( RECT_FLY_PRT_EMBEDDED, pPt );
1311 aDistLR.SetLeft(rFlyPrtRect.Left());
1312 aDistLR.SetRight(rFlyPrtRect.Left());
1314 else
1316 SfxItemSet aCoreSet2( GetPool(),
1317 RES_BOX, RES_BOX,
1318 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1319 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1320 aCoreSet.Put( aBoxInfo );
1321 rSh.GetFlyFrmAttr( aCoreSet );
1322 const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
1323 aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
1324 aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
1326 //add the paragraph border distance
1327 SfxItemSet aCoreSet1( GetPool(),
1328 RES_BOX, RES_BOX,
1329 0 );
1330 rSh.GetCurAttr( aCoreSet1 );
1331 const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
1332 aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
1333 aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
1335 rSet.Put(aDistLR);
1336 m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1337 m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1339 else if ( IsTabColFromDoc() ||
1340 ( rSh.GetTableFmt() && !bFrmSelection &&
1341 !(nFrmType & FRMTYPE_COLSECT ) ) )
1343 SfxItemSet aCoreSet2( GetPool(),
1344 RES_BOX, RES_BOX,
1345 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1346 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1347 aBoxInfo.SetTable(sal_False);
1348 aBoxInfo.SetDist((sal_Bool) sal_True);
1349 aCoreSet2.Put(aBoxInfo);
1350 rSh.GetTabBorders( aCoreSet2 );
1351 const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
1352 aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
1353 aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
1355 //add the border distance of the paragraph
1356 SfxItemSet aCoreSet1( GetPool(), RES_BOX, RES_BOX );
1357 rSh.GetCurAttr( aCoreSet1 );
1358 const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
1359 aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
1360 aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
1361 rSet.Put(aDistLR);
1362 m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1363 m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1365 else if ( !rSh.IsDirectlyInSection() )
1367 //get the page/header/footer border distance
1368 const SwFrmFmt& rMaster = rDesc.GetMaster();
1369 const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
1370 aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT ));
1371 aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT));
1373 const SvxBoxItem* pBox = 0;
1374 if(nFrmType & FRMTYPE_HEADER)
1376 rMaster.GetHeader();
1377 const SwFmtHeader& rHeaderFmt = rMaster.GetHeader();
1378 SwFrmFmt *pHeaderFmt = (SwFrmFmt*)rHeaderFmt.GetHeaderFmt();
1379 if( pHeaderFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
1380 pBox = & (const SvxBoxItem&)pHeaderFmt->GetBox();
1382 else if(nFrmType & FRMTYPE_FOOTER )
1384 const SwFmtFooter& rFooterFmt = rMaster.GetFooter();
1385 SwFrmFmt *pFooterFmt = (SwFrmFmt*)rFooterFmt.GetFooterFmt();
1386 if( pFooterFmt )// #i80890# if rDesc is not the one belonging to the current page is might crash
1387 pBox = & (const SvxBoxItem&)pFooterFmt->GetBox();
1389 if(pBox)
1391 aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT ));
1392 aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT));
1395 //add the border distance of the paragraph
1396 SfxItemSet aCoreSetTmp( GetPool(),
1397 RES_BOX, RES_BOX,
1398 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1399 rSh.GetCurAttr( aCoreSetTmp );
1400 const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
1401 aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT ));
1402 aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT));
1403 rSet.Put(aDistLR);
1404 m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
1405 m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
1409 break;
1411 case SID_RULER_TEXT_RIGHT_TO_LEFT:
1413 if ( nSelType & nsSelectionType::SEL_GRF ||
1414 nSelType & nsSelectionType::SEL_FRM ||
1415 nSelType & nsSelectionType::SEL_OLE ||
1416 nFrmType == FRMTYPE_DRAWOBJ)
1417 rSet.DisableItem(nWhich);
1418 else
1420 sal_Bool bFlag = rSh.IsInRightToLeftText();
1421 rSet.Put(SfxBoolItem(nWhich, bFlag));
1424 break;
1426 case SID_RULER_BORDERS_VERTICAL:
1427 case SID_RULER_BORDERS:
1429 bool bFrameHasVerticalColumns(false);
1431 sal_Bool bFrameRTL;
1432 sal_Bool bFrameVertL2R;
1433 bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
1434 bFrmSelection;
1436 bool bHasTable = ( IsTabColFromDoc() ||
1437 ( rSh.GetTableFmt() && !bFrmSelection &&
1438 !(nFrmType & FRMTYPE_COLSECT ) ) );
1440 bool bTableVertical = bHasTable && rSh.IsTableVertical();
1442 if(((SID_RULER_BORDERS_VERTICAL == nWhich) &&
1443 ((bHasTable && !bTableVertical) ||
1444 (!bVerticalWriting && !bFrmSelection && !bHasTable ) ||
1445 ( bFrmSelection && !bFrameHasVerticalColumns))) ||
1446 ((SID_RULER_BORDERS == nWhich) &&
1447 ((bHasTable && bTableVertical) ||
1448 (bVerticalWriting && !bFrmSelection&& !bHasTable) || bFrameHasVerticalColumns)))
1449 rSet.DisableItem(nWhich);
1450 else if ( bHasTable )
1452 SwTabCols aTabCols;
1453 sal_uInt16 nNum;
1454 if ( 0 != ( m_bSetTabColFromDoc = IsTabColFromDoc() ) )
1456 rSh.GetMouseTabCols( aTabCols, m_aTabColFromDocPos );
1457 nNum = rSh.GetCurMouseTabColNum( m_aTabColFromDocPos );
1459 else
1461 rSh.GetTabCols( aTabCols );
1462 nNum = rSh.GetCurTabColNum();
1463 if(rSh.IsTableRightToLeft())
1464 nNum = aTabCols.Count() - nNum;
1467 OSL_ENSURE(nNum <= aTabCols.Count(), "TabCol not found");
1468 const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
1469 const int nRgt = (sal_uInt16)(bTableVertical ? nPageHeight : nPageWidth) -
1470 (aTabCols.GetLeftMin() +
1471 aTabCols.GetRight());
1473 const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
1474 const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
1476 SvxColumnItem aColItem(nNum, nL, nR);
1478 sal_uInt16 nStart = 0,
1479 nEnd;
1481 //columns in right-to-left tables need to be mirrored
1482 sal_Bool bIsTableRTL =
1483 IsTabColFromDoc() ?
1484 rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
1485 : rSh.IsTableRightToLeft();
1486 if(bIsTableRTL)
1488 for ( sal_uInt16 i = aTabCols.Count(); i ; --i )
1490 const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
1491 nEnd = (sal_uInt16)aTabCols.GetRight();
1492 nEnd = nEnd - (sal_uInt16)rEntry.nPos;
1493 SvxColumnDescription aColDesc( nStart, nEnd,
1494 (sal_uInt16(aTabCols.GetRight() - rEntry.nMax)),
1495 (sal_uInt16(aTabCols.GetRight() - rEntry.nMin)),
1496 !aTabCols.IsHidden(i - 1) );
1497 aColItem.Append(aColDesc);
1498 nStart = nEnd;
1500 SvxColumnDescription aColDesc(nStart,
1501 aTabCols.GetRight() - aTabCols.GetLeft(), sal_True);
1502 aColItem.Append(aColDesc);
1504 else
1506 for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
1508 const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
1509 nEnd = static_cast< sal_uInt16 >(rEntry.nPos - aTabCols.GetLeft());
1510 SvxColumnDescription aColDesc( nStart, nEnd,
1511 rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
1512 !aTabCols.IsHidden(i) );
1513 aColItem.Append(aColDesc);
1514 nStart = nEnd;
1516 SvxColumnDescription aColDesc(nStart, aTabCols.GetRight() - aTabCols.GetLeft(),
1517 0, 0,
1518 sal_True);
1519 aColItem.Append(aColDesc);
1521 rSet.Put(aColItem, nWhich);
1523 else if ( bFrmSelection || nFrmType & ( FRMTYPE_COLUMN | FRMTYPE_COLSECT ) )
1525 // Aus Rahmen oder Seite ?
1526 sal_uInt16 nNum = 0;
1527 if(bFrmSelection)
1529 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
1530 if(pFmt)
1531 nNum = pFmt->GetCol().GetNumCols();
1533 else
1534 nNum = rSh.GetCurColNum();
1537 //eigentlich sollte FRMTYPE_COLSECT nicht enthalten sein, wenn der Rahmen selektiert ist!
1538 !bFrmSelection &&
1539 nFrmType & FRMTYPE_COLSECT )
1541 const SwSection *pSect = rSh.GetAnySection(sal_False, pPt);
1542 OSL_ENSURE( pSect, "Which section?");
1543 if( pSect )
1545 SwSectionFmt *pFmt = pSect->GetFmt();
1546 const SwFmtCol& rCol = pFmt->GetCol();
1547 if(rSh.IsInRightToLeftText())
1548 nNum = rCol.GetColumns().size() - nNum;
1549 else
1550 --nNum;
1551 SvxColumnItem aColItem(nNum);
1552 SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
1553 const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
1555 ::lcl_FillSvxColumn(rCol, sal_uInt16(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0);
1557 if(bVerticalWriting)
1559 aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
1560 aRect.Pos().Y() -= rPageRect.Top();
1561 aColItem.SetLeft ((sal_uInt16)(aRect.Top()));
1562 aColItem.SetRight((sal_uInt16)(nPageHeight - aRect.Bottom() ));
1564 else
1566 aRect.Pos() += aTmpRect.Pos();
1568 // make relative to page position:
1569 aColItem.SetLeft ((sal_uInt16)( aRect.Left() - rPageRect.Left() ));
1570 aColItem.SetRight((sal_uInt16)( rPageRect.Right() - aRect.Right()));
1572 aColItem.SetOrtho(aColItem.CalcOrtho());
1574 rSet.Put(aColItem, nWhich);
1577 else if( bFrmSelection || nFrmType & FRMTYPE_FLY_ANY )
1579 // Spalten in Rahmen
1580 if ( nNum )
1582 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
1584 const SwFmtCol& rCol = pFmt->GetCol();
1585 if(rSh.IsInRightToLeftText())
1586 nNum = rCol.GetColumns().size() - nNum;
1587 else
1588 nNum--;
1589 SvxColumnItem aColItem(nNum);
1590 const SwRect &rSizeRect = rSh.GetAnyCurRect(RECT_FLY_PRT_EMBEDDED, pPt);
1592 bool bUseVertical = bFrameHasVerticalColumns || (!bFrmSelection && bVerticalWriting);
1593 const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
1594 const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
1595 long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
1596 ::lcl_FillSvxColumn(rCol, sal_uInt16(lWidth), aColItem, nDist2);
1598 SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
1599 rSh.GetFlyFrmAttr( aFrameSet );
1601 if(bUseVertical)
1603 aColItem.SetLeft ((sal_uInt16)(rRect.Top()- rPageRect.Top()));
1604 aColItem.SetRight((sal_uInt16)(nPageHeight + rPageRect.Top() - rRect.Bottom() ));
1606 else
1608 aColItem.SetLeft ((sal_uInt16)(rRect.Left() - rPageRect.Left() ));
1609 aColItem.SetRight((sal_uInt16)(rPageRect.Right() - rRect.Right() ));
1612 aColItem.SetOrtho(aColItem.CalcOrtho());
1614 rSet.Put(aColItem, nWhich);
1616 else
1617 rSet.DisableItem(nWhich);
1619 else
1620 { // Spalten auf der Seite
1621 const SwFrmFmt& rMaster = rDesc.GetMaster();
1622 SwFmtCol aCol(rMaster.GetCol());
1623 if(rFrameDir.GetValue() == FRMDIR_HORI_RIGHT_TOP)
1624 nNum = aCol.GetColumns().size() - nNum;
1625 else
1626 nNum--;
1628 SvxColumnItem aColItem(nNum);
1629 const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
1630 const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
1631 long nDist = rBox.GetDistance();
1632 ::lcl_FillSvxColumn(aCol,
1633 sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
1634 aColItem, nDist);
1636 if(bBrowse)
1638 aColItem.SetLeft((sal_uInt16)rPagePrtRect.Left());
1639 aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
1641 else
1643 aColItem.SetLeft (aPageLRSpace.GetLeft());
1644 aColItem.SetRight(aPageLRSpace.GetRight());
1646 aColItem.SetOrtho(aColItem.CalcOrtho());
1648 rSet.Put(aColItem, nWhich);
1651 else
1652 rSet.DisableItem(nWhich);
1653 break;
1656 case SID_RULER_ROWS :
1657 case SID_RULER_ROWS_VERTICAL:
1659 bool bFrameHasVerticalColumns(false);
1661 sal_Bool bFrameRTL;
1662 sal_Bool bFrameVertL2R;
1663 bFrameHasVerticalColumns = rSh.IsFrmVertical(sal_False, bFrameRTL, bFrameVertL2R) &&
1664 bFrmSelection;
1667 if(((SID_RULER_ROWS == nWhich) &&
1668 ((!bVerticalWriting && !bFrmSelection) || (bFrmSelection && !bFrameHasVerticalColumns))) ||
1669 ((SID_RULER_ROWS_VERTICAL == nWhich) &&
1670 ((bVerticalWriting && !bFrmSelection) || bFrameHasVerticalColumns)))
1671 rSet.DisableItem(nWhich);
1672 else if ( IsTabRowFromDoc() ||
1673 ( rSh.GetTableFmt() && !bFrmSelection &&
1674 !(nFrmType & FRMTYPE_COLSECT ) ) )
1676 SwTabCols aTabCols;
1677 //no current value necessary
1678 sal_uInt16 nNum = 0;
1679 if ( 0 != ( m_bSetTabRowFromDoc = IsTabRowFromDoc() ) )
1681 rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
1683 else
1685 rSh.GetTabRows( aTabCols );
1688 const int nLft = aTabCols.GetLeftMin();
1689 const int nRgt = (sal_uInt16)(bVerticalWriting ? nPageWidth : nPageHeight) -
1690 (aTabCols.GetLeftMin() +
1691 aTabCols.GetRight());
1693 const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
1694 const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
1696 SvxColumnItem aColItem(nNum, nL, nR);
1698 sal_uInt16 nStart = 0,
1699 nEnd;
1701 for ( sal_uInt16 i = 0; i < aTabCols.Count(); ++i )
1703 const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
1704 if(bVerticalWriting)
1706 nEnd = sal_uInt16(aTabCols.GetRight() - rEntry.nPos);
1707 SvxColumnDescription aColDesc( nStart, nEnd,
1708 aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin,
1709 !aTabCols.IsHidden(i) );
1710 aColItem.Append(aColDesc);
1712 else
1714 nEnd = sal_uInt16(rEntry.nPos - aTabCols.GetLeft());
1715 SvxColumnDescription aColDesc( nStart, nEnd,
1716 sal_uInt16(rEntry.nMin - aTabCols.GetLeft()), sal_uInt16(rEntry.nMax - aTabCols.GetLeft()),
1717 !aTabCols.IsHidden(i) );
1718 aColItem.Append(aColDesc);
1720 nStart = nEnd;
1722 if(bVerticalWriting)
1723 nEnd = static_cast< sal_uInt16 >(aTabCols.GetRight());
1724 else
1725 nEnd = static_cast< sal_uInt16 >(aTabCols.GetLeft());
1726 // put a position protection when the last row cannot be moved
1727 // due to a page break inside of a row
1728 if(!aTabCols.IsLastRowAllowedToChange())
1729 bPutContentProtection = true;
1731 SvxColumnDescription aColDesc( nStart, nEnd,
1732 aTabCols.GetRight(), aTabCols.GetRight(),
1733 sal_False );
1734 aColItem.Append(aColDesc);
1736 rSet.Put(aColItem, nWhich);
1738 else
1739 rSet.DisableItem(nWhich);
1741 break;
1743 case SID_RULER_PAGE_POS:
1745 SvxPagePosSizeItem aPagePosSize(
1746 Point( rPageRect.Left(), rPageRect.Top()) , nPageWidth, nPageHeight);
1748 rSet.Put(aPagePosSize);
1749 break;
1752 case SID_RULER_LR_MIN_MAX:
1754 Rectangle aRectangle;
1755 if( ( nFrmType & FRMTYPE_COLSECT ) && !IsTabColFromDoc() &&
1756 ( nFrmType & ( FRMTYPE_TABLE|FRMTYPE_COLUMN ) ) )
1758 if( nFrmType & FRMTYPE_TABLE )
1760 const sal_uInt16 nNum = rSh.GetCurTabColNum();
1761 SwTabCols aTabCols;
1762 rSh.GetTabCols( aTabCols );
1764 const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
1765 const int nRgt = (sal_uInt16)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
1767 const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
1768 const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
1770 aRectangle.Left() = nL;
1771 if(nNum > 1)
1772 aRectangle.Left() += aTabCols[nNum - 2];
1773 if(nNum)
1774 aRectangle.Left() += MINLAY;
1775 if(aTabCols.Count() <= nNum + 1 )
1776 aRectangle.Right() = nR;
1777 else
1778 aRectangle.Right() = nPageWidth - (nL + aTabCols[nNum + 1]);
1780 if(nNum < aTabCols.Count())
1781 aRectangle.Right() += MINLAY;
1783 else
1785 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
1786 const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
1787 &rDesc.GetMaster().GetCol();
1788 const SwColumns& rCols = pCols->GetColumns();
1789 sal_uInt16 nNum = rSh.GetCurOutColNum();
1790 sal_uInt16 nCount = std::min(sal_uInt16(nNum + 1), sal_uInt16(rCols.size()));
1791 const SwRect aRect( rSh.GetAnyCurRect( pFmt
1792 ? RECT_FLY_PRT_EMBEDDED
1793 : RECT_PAGE_PRT, pPt ));
1794 const SwRect aAbsRect( rSh.GetAnyCurRect( pFmt
1795 ? RECT_FLY_EMBEDDED
1796 : RECT_PAGE, pPt ));
1798 //die Breite im Rahmen bzw. innerhalbe der Seitenraender
1799 const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
1800 //die gesamte Rahmenbreite - die Differenz ist der doppelte Abstand zum Rand
1801 const sal_uInt16 nOuterWidth = (sal_uInt16)aAbsRect.Width();
1802 int nWidth = 0,
1803 nStart = 0,
1804 nEnd = 0;
1805 aRectangle.Left() = 0;
1806 for ( sal_uInt16 i = 0; i < nCount; ++i )
1808 const SwColumn* pCol = &rCols[i];
1809 nStart = pCol->GetLeft() + nWidth;
1810 if(i == nNum - 2)
1811 aRectangle.Left() = nStart;
1812 nWidth += pCols->CalcColWidth( i, nTotalWidth );
1813 nEnd = nWidth - pCol->GetRight();
1815 aRectangle.Right() = rPageRect.Right() - nEnd;
1816 aRectangle.Left() -= rPageRect.Left();
1818 if(nNum > 1)
1820 aRectangle.Left() += MINLAY;
1821 aRectangle.Left() += aRect.Left();
1823 if(pFmt) //Bereich in Rahmen - hier darf man bis zum Rand
1824 aRectangle.Left() = aRectangle.Right() = 0;
1825 else
1827 // das Rechteck an die richtige absolute Position verschieben
1828 aRectangle.Left() += aAbsRect.Left();
1829 aRectangle.Right() -= aAbsRect.Left();
1830 // Abstand zur Umrandung mit einbeziehen
1831 aRectangle.Right() -= (nOuterWidth - nTotalWidth) / 2;
1834 if(nNum < rCols.size())
1836 aRectangle.Right() += MINLAY;
1838 else
1839 // rechts ist jetzt nur noch der Seitenrand
1840 aRectangle.Right() = 0;
1845 else if ( ((nFrmType & FRMTYPE_TABLE) || IsTabColFromDoc()) &&
1846 !bFrmSelection )
1848 bool bColumn;
1849 if ( IsTabColFromDoc() )
1850 bColumn = rSh.GetCurMouseColNum( m_aTabColFromDocPos ) != 0;
1851 else
1852 bColumn = (nFrmType & (FRMTYPE_COLUMN|FRMTYPE_FLY_ANY|FRMTYPE_COLSECTOUTTAB))
1853 ? sal_True
1854 : sal_False;
1856 if ( !bColumn )
1858 if( nFrmType & FRMTYPE_FLY_ANY && IsTabColFromDoc() )
1860 SwRect aRect( rSh.GetAnyCurRect(
1861 RECT_FLY_PRT_EMBEDDED, pPt ) );
1862 aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
1863 pPt ).Pos();
1865 aRectangle.Left() = aRect.Left() - rPageRect.Left();
1866 aRectangle.Right() = rPageRect.Right() - aRect.Right();
1868 else if( bBrowse )
1870 aRectangle.Left() = rPagePrtRect.Left();
1871 aRectangle.Right() = nPageWidth - rPagePrtRect.Right();
1873 else
1875 aRectangle.Left() = aPageLRSpace.GetLeft();
1876 aRectangle.Right() = aPageLRSpace.GetRight();
1879 else
1880 { //hier nur fuer Tabelle in mehrspaltigen Seiten und Rahmen
1881 sal_Bool bSectOutTbl = (nFrmType & FRMTYPE_TABLE) ? sal_True : sal_False;
1882 bool bFrame = (nFrmType & FRMTYPE_FLY_ANY);
1883 bool bColSct = (nFrmType & ( bSectOutTbl
1884 ? FRMTYPE_COLSECTOUTTAB
1885 : FRMTYPE_COLSECT )
1887 //Damit man auch mit der Mouse ziehen kann,
1888 //ohne in der Tabelle zu stehen
1889 CurRectType eRecType = RECT_PAGE_PRT;
1890 sal_uInt16 nNum = IsTabColFromDoc() ?
1891 rSh.GetCurMouseColNum( m_aTabColFromDocPos ):
1892 rSh.GetCurOutColNum();
1893 const SwFrmFmt* pFmt = NULL;
1894 if( bColSct )
1896 eRecType = bSectOutTbl ? RECT_OUTTABSECTION
1897 : RECT_SECTION;
1898 const SwSection *pSect = rSh.GetAnySection( bSectOutTbl, pPt );
1899 OSL_ENSURE( pSect, "Which section?");
1900 pFmt = pSect->GetFmt();
1902 else if( bFrame )
1904 pFmt = rSh.GetFlyFrmFmt();
1905 eRecType = RECT_FLY_PRT_EMBEDDED;
1908 const SwFmtCol* pCols = pFmt ? &pFmt->GetCol():
1909 &rDesc.GetMaster().GetCol();
1910 const SwColumns& rCols = pCols->GetColumns();
1911 const sal_uInt16 nBorder = pFmt ? pFmt->GetBox().GetDistance() :
1912 rDesc.GetMaster().GetBox().GetDistance();
1914 /* RECT_FLY_PRT_EMBEDDED returns the relative position to
1915 RECT_FLY_EMBEDDED
1916 the absolute position must be added here
1918 SwRect aRect( rSh.GetAnyCurRect( eRecType, pPt ) );
1919 if(RECT_FLY_PRT_EMBEDDED == eRecType)
1920 aRect.Pos() += rSh.GetAnyCurRect( RECT_FLY_EMBEDDED,
1921 pPt ).Pos();
1923 const sal_uInt16 nTotalWidth = (sal_uInt16)aRect.Width();
1924 //nStart und nEnd initialisieren fuer nNum == 0
1925 int nWidth = 0,
1926 nStart = 0,
1927 nEnd = nTotalWidth;
1929 if( nNum > rCols.size() )
1931 OSL_ENSURE( !this, "wrong FmtCol is being edited!" );
1932 nNum = rCols.size();
1935 for( sal_uInt16 i = 0; i < nNum; ++i )
1937 const SwColumn* pCol = &rCols[i];
1938 nStart = pCol->GetLeft() + nWidth;
1939 nWidth += pCols->CalcColWidth( i, nTotalWidth );
1940 nEnd = nWidth - pCol->GetRight();
1942 if( bFrame || bColSct )
1944 aRectangle.Left() = aRect.Left() - rPageRect.Left() + nStart;
1945 aRectangle.Right() = nPageWidth - aRectangle.Left() - nEnd + nStart;
1947 else if(!bBrowse)
1949 aRectangle.Left() = aPageLRSpace.GetLeft() + nStart;
1950 aRectangle.Right() = nPageWidth - nEnd - aPageLRSpace.GetLeft();
1952 else
1954 long nLeft = rPagePrtRect.Left();
1955 aRectangle.Left() = nStart + nLeft;
1956 aRectangle.Right() = nPageWidth - nEnd - nLeft;
1958 if(!bFrame)
1960 aRectangle.Left() += nBorder;
1961 aRectangle.Right() -= nBorder;
1965 else if ( nFrmType & ( FRMTYPE_HEADER | FRMTYPE_FOOTER ))
1967 aRectangle.Left() = aPageLRSpace.GetLeft();
1968 aRectangle.Right() = aPageLRSpace.GetRight();
1970 else
1971 aRectangle.Left() = aRectangle.Right() = 0;
1973 SfxRectangleItem aLR( SID_RULER_LR_MIN_MAX , aRectangle);
1974 rSet.Put(aLR);
1976 break;
1978 case SID_RULER_PROTECT:
1980 if(bFrmSelection)
1982 sal_uInt8 nProtect = m_pWrtShell->IsSelObjProtected( FLYPROTECT_SIZE|FLYPROTECT_POS|FLYPROTECT_CONTENT );
1984 SvxProtectItem aProt(SID_RULER_PROTECT);
1985 aProt.SetCntntProtect((nProtect & FLYPROTECT_CONTENT) != 0);
1986 aProt.SetSizeProtect ((nProtect & FLYPROTECT_SIZE) != 0);
1987 aProt.SetPosProtect ((nProtect & FLYPROTECT_POS) != 0);
1988 rSet.Put(aProt);
1990 else
1992 SvxProtectItem aProtect(SID_RULER_PROTECT);
1993 if(bBrowse && !(nFrmType & (FRMTYPE_DRAWOBJ|FRMTYPE_COLUMN)) && !rSh.GetTableFmt())
1995 aProtect.SetSizeProtect(sal_True);
1996 aProtect.SetPosProtect(sal_True);
1998 rSet.Put(aProtect);
2001 break;
2003 nWhich = aIter.NextWhich();
2005 if(bPutContentProtection)
2007 SvxProtectItem aProtect(SID_RULER_PROTECT);
2008 aProtect.SetCntntProtect(sal_True);
2009 rSet.Put(aProtect);
2013 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */