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