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