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