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 #ifdef SW_DLLIMPLEMENTATION 28 #undef SW_DLLIMPLEMENTATION 29 #endif 30 31 32 #include <hintids.hxx> 33 #include <tools/list.hxx> 34 #include <vcl/msgbox.hxx> 35 #include <svl/stritem.hxx> 36 #include <svl/intitem.hxx> 37 #include <svx/htmlmode.hxx> 38 #include <editeng/keepitem.hxx> 39 #include <editeng/brkitem.hxx> 40 #include <editeng/ulspitem.hxx> 41 #include <editeng/frmdiritem.hxx> 42 #include <svl/ctloptions.hxx> 43 #include <swmodule.hxx> 44 #include <fmtornt.hxx> 45 #include <fmtpdsc.hxx> 46 #include <fmtlsplt.hxx> 47 48 #include <svtools/htmlcfg.hxx> 49 #include <fmtrowsplt.hxx> 50 #include <svx/htmlmode.hxx> 51 52 #include "access.hrc" 53 54 #ifndef _DOCSH_HXX 55 #include <docsh.hxx> 56 #endif 57 #include <wrtsh.hxx> 58 #ifndef _VIEW_HXX 59 #include <view.hxx> 60 #endif 61 #include <viewopt.hxx> 62 #include <uitool.hxx> 63 #include <frmatr.hxx> 64 #include <tabledlg.hxx> 65 #ifndef _TABLEPG_HXX 66 #include <tablepg.hxx> 67 #endif 68 #include <tablemgr.hxx> 69 #include <pagedesc.hxx> 70 #include <uiitems.hxx> 71 #include <poolfmt.hxx> 72 #include <SwStyleNameMapper.hxx> 73 74 #ifndef _CMDID_H 75 #include <cmdid.h> 76 #endif 77 #ifndef _TABLEDLG_HRC 78 #include <tabledlg.hrc> 79 #endif 80 #ifndef _TABLE_HRC 81 #include <table.hrc> 82 #endif 83 #include <svx/svxids.hrc> 84 #include <svx/dialogs.hrc> 85 #include <svx/flagsdef.hxx> 86 #include <svx/svxdlg.hxx> 87 88 using namespace ::com::sun::star; 89 90 91 #ifdef DEBUG_TBLDLG 92 void DbgTblRep(SwTableRep* pRep) 93 { 94 DBG_ERROR(String(pRep->GetColCount())) 95 DBG_ERROR(String(pRep->GetAllColCount())) 96 SwTwips nSum = 0; 97 for(sal_uInt16 i = 0; i < pRep->GetAllColCount(); i++) 98 { 99 String sMsg(i); 100 sMsg += pRep->GetColumns()[i].bVisible ? " v " : " h "; 101 sMsg += pRep->GetColumns()[i].nWidth; 102 nSum +=pRep->GetColumns()[i].nWidth; 103 DBG_ERROR(sMsg) 104 } 105 String sMsg("Spaltensumme: "); 106 sMsg += nSum; 107 sMsg += " Tblbreite: "; 108 sMsg += pRep->GetWidth(); 109 DBG_ERROR(sMsg) 110 sMsg = "Gesamt/Links/Rechts: "; 111 sMsg += pRep->GetSpace(); 112 sMsg += '/'; 113 sMsg += pRep->GetLeftSpace(); 114 sMsg += '/'; 115 sMsg += pRep->GetRightSpace(); 116 DBG_ERROR(sMsg) 117 sMsg = "Align: "; 118 sMsg += pRep->GetAlign(); 119 DBG_ERROR(sMsg) 120 121 }; 122 123 #endif 124 125 126 SwFormatTablePage::SwFormatTablePage( Window* pParent, const SfxItemSet& rSet ) : 127 SfxTabPage(pParent, SW_RES( TP_FORMAT_TABLE ), rSet ), 128 aOptionsFL(this, SW_RES( FL_OPTIONS )), 129 aNameFT(this, SW_RES( FT_NAME )), 130 aNameED(this, SW_RES( ED_NAME )), 131 aWidthFT(this, SW_RES( FT_WIDTH )), 132 aWidthMF(this, SW_RES( ED_WIDTH )), 133 aRelWidthCB(this, SW_RES( CB_REL_WIDTH )), 134 135 aPosFL(this, SW_RES( FL_POS )), 136 aFullBtn(this, SW_RES( RB_FULL )), 137 aLeftBtn(this, SW_RES( RB_LEFT )), 138 aFromLeftBtn(this, SW_RES( RB_FROM_LEFT )), 139 aRightBtn(this, SW_RES( RB_RIGHT )), 140 aCenterBtn(this, SW_RES( RB_CENTER )), 141 aFreeBtn(this, SW_RES( RB_FREE )), 142 143 aDistFL(this, SW_RES( FL_DIST )), 144 aLeftFT(this, SW_RES( FT_LEFT_DIST )), 145 aLeftMF(this, SW_RES( ED_LEFT_DIST )), 146 aRightFT(this, SW_RES( FT_RIGHT_DIST )), 147 aRightMF(this, SW_RES( ED_RIGHT_DIST )), 148 aTopFT (this, SW_RES( FT_TOP_DIST )), 149 aTopMF(this, SW_RES( ED_TOP_DIST )), 150 aBottomFT(this, SW_RES( FT_BOTTOM_DIST )), 151 aBottomMF(this, SW_RES( ED_BOTTOM_DIST )), 152 153 aPropertiesFL(this, SW_RES( FL_PROPERTIES )), 154 aTextDirectionFT(this, SW_RES( FT_TEXTDIRECTION )), 155 aTextDirectionLB(this, SW_RES( LB_TEXTDIRECTION )), 156 157 pTblData(0), 158 nSaveWidth(0), 159 nMinTableWidth(MINLAY), 160 bModified(sal_False), 161 bFull(0), 162 bHtmlMode(sal_False) 163 { 164 FreeResource(); 165 SetExchangeSupport(); 166 167 const SfxPoolItem* pItem; 168 if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, sal_False, &pItem)) 169 bHtmlMode = 0 != (((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON); 170 171 sal_Bool bCTL = SW_MOD()->GetCTLOptions().IsCTLFontEnabled(); 172 if( !bHtmlMode && bCTL ) 173 { 174 aPropertiesFL.Show(); 175 aTextDirectionFT.Show(); 176 aTextDirectionLB.Show(); 177 } 178 179 Init(); 180 } 181 182 /*------------------------------------------------------------------------ 183 ------------------------------------------------------------------------*/ 184 void SwFormatTablePage::Init() 185 { 186 aLeftMF.MetricField::SetMin(-999999); 187 aRightMF.MetricField::SetMin(-999999); 188 189 // handler 190 Link aLk = LINK( this, SwFormatTablePage, AutoClickHdl ); 191 aFullBtn.SetClickHdl( aLk ); 192 aFreeBtn.SetClickHdl( aLk ); 193 aLeftBtn.SetClickHdl( aLk ); 194 aFromLeftBtn.SetClickHdl( aLk ); 195 aRightBtn.SetClickHdl( aLk ); 196 aCenterBtn.SetClickHdl( aLk ); 197 198 aLk = LINK( this, SwFormatTablePage, UpDownLoseFocusHdl ); 199 aTopMF.SetUpHdl( aLk ); 200 aBottomMF.SetUpHdl( aLk ); 201 aRightMF.SetUpHdl( aLk ); 202 aLeftMF.SetUpHdl( aLk ); 203 aWidthMF.SetUpHdl( aLk ); 204 205 aTopMF.SetDownHdl( aLk ); 206 aBottomMF.SetDownHdl( aLk ); 207 aRightMF.SetDownHdl( aLk ); 208 aLeftMF.SetDownHdl( aLk ); 209 aWidthMF.SetDownHdl( aLk ); 210 211 aTopMF.SetLoseFocusHdl( aLk ); 212 aBottomMF.SetLoseFocusHdl( aLk ); 213 aRightMF.SetLoseFocusHdl( aLk ); 214 aLeftMF.SetLoseFocusHdl( aLk ); 215 aWidthMF.SetLoseFocusHdl( aLk ); 216 217 aRelWidthCB.SetClickHdl(LINK( this, SwFormatTablePage, RelWidthClickHdl )); 218 } 219 220 /*------------------------------------------------------------------------*/ 221 222 IMPL_LINK( SwFormatTablePage, RelWidthClickHdl, CheckBox *, pBtn ) 223 { 224 DBG_ASSERT(pTblData, "Tabellendaten nicht da?"); 225 sal_Bool bIsChecked = pBtn->IsChecked(); 226 sal_Int64 nLeft = aLeftMF.DenormalizePercent(aLeftMF.GetValue(FUNIT_TWIP )); 227 sal_Int64 nRight = aRightMF.DenormalizePercent(aRightMF.GetValue(FUNIT_TWIP )); 228 aWidthMF.ShowPercent(bIsChecked); 229 aLeftMF.ShowPercent(bIsChecked); 230 aRightMF.ShowPercent(bIsChecked); 231 232 if (bIsChecked) 233 { 234 aWidthMF.SetRefValue(pTblData->GetSpace()); 235 aLeftMF.SetRefValue(pTblData->GetSpace()); 236 aRightMF.SetRefValue(pTblData->GetSpace()); 237 aLeftMF.MetricField::SetMin(0); // wird vom Percentfield ueberschrieben 238 aRightMF.MetricField::SetMin(0);// -""- 239 aLeftMF.MetricField::SetMax(99); // 240 aRightMF.MetricField::SetMax(99);// 241 aLeftMF.SetPrcntValue(aLeftMF.NormalizePercent(nLeft ), FUNIT_TWIP ); 242 aRightMF.SetPrcntValue(aRightMF.NormalizePercent(nRight ), FUNIT_TWIP ); 243 } 244 else 245 ModifyHdl(&aLeftMF); // Werte wieder korrigieren 246 247 if(aFreeBtn.IsChecked()) 248 { 249 sal_Bool bEnable = !pBtn->IsChecked(); 250 aRightMF.Enable(bEnable); 251 aRightFT.Enable(bEnable); 252 } 253 bModified = sal_True; 254 255 return 0; 256 } 257 258 /*------------------------------------------------------------------------ 259 ------------------------------------------------------------------------*/ 260 IMPL_LINK( SwFormatTablePage, AutoClickHdl, CheckBox *, pBox ) 261 { 262 sal_Bool bRestore = sal_True, 263 bLeftEnable = sal_False, 264 bRightEnable= sal_False, 265 bWidthEnable= sal_False, 266 bOthers = sal_True; 267 if( (RadioButton *) pBox == &aFullBtn ) 268 { 269 aLeftMF.SetPrcntValue(0); 270 aRightMF.SetPrcntValue(0); 271 nSaveWidth = static_cast< SwTwips >(aWidthMF.DenormalizePercent(aWidthMF.GetValue(FUNIT_TWIP ))); 272 aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent(pTblData->GetSpace() ), FUNIT_TWIP ); 273 bFull = sal_True; 274 bRestore = sal_False; 275 } 276 else if( (RadioButton *) pBox == &aLeftBtn ) 277 { 278 bRightEnable = bWidthEnable = sal_True; 279 aLeftMF.SetPrcntValue(0); 280 } 281 else if( (RadioButton *) pBox == &aFromLeftBtn ) 282 { 283 bLeftEnable = bWidthEnable = sal_True; 284 aRightMF.SetPrcntValue(0); 285 } 286 else if( (RadioButton *) pBox == &aRightBtn ) 287 { 288 bLeftEnable = bWidthEnable = sal_True; 289 aRightMF.SetPrcntValue(0); 290 } 291 else if( ( RadioButton * ) pBox == &aCenterBtn ) 292 { 293 bLeftEnable = bWidthEnable = sal_True; 294 } 295 else if( ( RadioButton * ) pBox == &aFreeBtn ) 296 { 297 RightModifyHdl(&aRightMF); 298 bLeftEnable = sal_True; 299 bWidthEnable = sal_True; 300 bOthers = sal_False; 301 } 302 aLeftMF.Enable(bLeftEnable); 303 aLeftFT.Enable(bLeftEnable); 304 aWidthMF.Enable(bWidthEnable); 305 aWidthFT.Enable(bWidthEnable); 306 if ( bOthers ) 307 { 308 aRightMF.Enable(bRightEnable); 309 aRightFT.Enable(bRightEnable); 310 aRelWidthCB.Enable(bWidthEnable); 311 } 312 313 if(bFull && bRestore) 314 { 315 // nachdem auf autom. geschaltet wurde, wurde die Breite gemerkt, 316 // um sie beim Zurueckschalten restaurieren zu koennen 317 bFull = sal_False; 318 aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent(nSaveWidth ), FUNIT_TWIP ); 319 } 320 ModifyHdl(&aWidthMF); 321 bModified = sal_True; 322 return 0; 323 } 324 325 /*----------------------------------------------------------------------*/ 326 IMPL_LINK( SwFormatTablePage, RightModifyHdl, MetricField *, EMPTYARG ) 327 { 328 if(aFreeBtn.IsChecked()) 329 { 330 sal_Bool bEnable = aRightMF.GetValue() == 0; 331 // aWidthMF.Enable(bEnable); 332 aRelWidthCB.Enable(bEnable); 333 // aWidthFT.Enable(bEnable); 334 if ( !bEnable ) 335 { 336 aRelWidthCB.Check(sal_False); 337 RelWidthClickHdl(&aRelWidthCB); 338 } 339 bEnable = aRelWidthCB.IsChecked(); 340 aRightMF.Enable(!bEnable); 341 aRightFT.Enable(!bEnable); 342 } 343 return 0; 344 } 345 346 /*------------------------------------------------------------------------ 347 ------------------------------------------------------------------------*/ 348 IMPL_LINK_INLINE_START( SwFormatTablePage, UpDownLoseFocusHdl, MetricField *, pEdit ) 349 { 350 if( &aRightMF == pEdit) 351 RightModifyHdl(pEdit); 352 ModifyHdl( pEdit ); 353 return 0; 354 } 355 IMPL_LINK_INLINE_END( SwFormatTablePage, UpDownLoseFocusHdl, MetricField *, pEdit ) 356 357 void SwFormatTablePage::ModifyHdl( Edit* pEdit ) 358 { 359 360 SwTwips nCurWidth = static_cast< SwTwips >(aWidthMF.DenormalizePercent(aWidthMF.GetValue( FUNIT_TWIP ))); 361 SwTwips nPrevWidth = nCurWidth; 362 SwTwips nRight = static_cast< SwTwips >(aRightMF.DenormalizePercent(aRightMF.GetValue( FUNIT_TWIP ))); 363 SwTwips nLeft = static_cast< SwTwips >(aLeftMF.DenormalizePercent(aLeftMF.GetValue( FUNIT_TWIP ))); 364 SwTwips nDiff; 365 366 if( pEdit == &aWidthMF ) 367 { 368 if( nCurWidth < MINLAY ) 369 nCurWidth = MINLAY; 370 nDiff = nRight + nLeft + nCurWidth - pTblData->GetSpace() ; 371 //rechtsbuendig nur linken Rand veraendern 372 if(aRightBtn.IsChecked()) 373 nLeft -= nDiff; 374 //linksbuendig nur rechten Rand veraendern 375 else if(aLeftBtn.IsChecked()) 376 nRight -= nDiff; 377 //linker Rand und Breite erlaubt - erst rechts - dann links 378 else if(aFromLeftBtn.IsChecked()) 379 { 380 if( nRight >= nDiff ) 381 nRight -= nDiff; 382 else 383 { 384 nDiff -= nRight; 385 nRight = 0; 386 if(nLeft >= nDiff) 387 nLeft -= nDiff; 388 else 389 { 390 nRight += nLeft - nDiff; 391 nLeft = 0; 392 nCurWidth = pTblData->GetSpace(); 393 } 394 395 } 396 } 397 //zentriert beide Seiten gleichmaessig veraendern 398 else if(aCenterBtn.IsChecked()) 399 { 400 if((nLeft != nRight)) 401 { 402 nDiff += nLeft + nRight; 403 nLeft = nDiff/2; 404 nRight = nDiff/2; 405 } 406 else 407 { 408 nLeft -= nDiff/2; 409 nRight -= nDiff/2; 410 } 411 } 412 //freie Ausrichtung: beide Raender verkleinern 413 else if(aFreeBtn.IsChecked()) 414 { 415 nLeft -= nDiff/2; 416 nRight -= nDiff/2; 417 } 418 } 419 if( pEdit == &aRightMF ) 420 { 421 422 if( nRight + nLeft > pTblData->GetSpace() - MINLAY ) 423 nRight = pTblData->GetSpace() -nLeft - MINLAY; 424 425 nCurWidth = pTblData->GetSpace() - nLeft - nRight; 426 } 427 if( pEdit == &aLeftMF ) 428 { 429 if(!aFromLeftBtn.IsChecked()) 430 { 431 sal_Bool bCenter = aCenterBtn.IsChecked(); 432 if( bCenter ) 433 nRight = nLeft; 434 if(nRight + nLeft > pTblData->GetSpace() - MINLAY ) 435 { 436 nLeft = bCenter ? (pTblData->GetSpace() - MINLAY) /2 : 437 (pTblData->GetSpace() - MINLAY) - nRight; 438 nRight = bCenter ? (pTblData->GetSpace() - MINLAY) /2 : nRight; 439 } 440 nCurWidth = pTblData->GetSpace() - nLeft - nRight; 441 } 442 else 443 { 444 //hier wird bei Aenderung an der linken Seite zuerst der 445 //rechte Rand veraendert, dann die Breite 446 nDiff = nRight + nLeft + nCurWidth - pTblData->GetSpace() ; 447 448 nRight -= nDiff; 449 nCurWidth = pTblData->GetSpace() - nLeft - nRight; 450 } 451 } 452 if (nCurWidth != nPrevWidth ) 453 aWidthMF.SetPrcntValue( aWidthMF.NormalizePercent( nCurWidth ), FUNIT_TWIP ); 454 aRightMF.SetPrcntValue( aRightMF.NormalizePercent( nRight ), FUNIT_TWIP ); 455 aLeftMF.SetPrcntValue( aLeftMF.NormalizePercent( nLeft ), FUNIT_TWIP ); 456 bModified = sal_True; 457 } 458 459 /*------------------------------------------------------------------------ 460 ------------------------------------------------------------------------*/ 461 SfxTabPage* SwFormatTablePage::Create( Window* pParent, 462 const SfxItemSet& rAttrSet) 463 { 464 return new SwFormatTablePage( pParent, rAttrSet ); 465 } 466 467 /*------------------------------------------------------------------------ 468 -------------------------------------------------------------------------*/ 469 sal_Bool SwFormatTablePage::FillItemSet( SfxItemSet& rCoreSet ) 470 { 471 // Testen, ob eins der Control noch den Focus hat 472 if(aWidthMF.HasFocus()) 473 ModifyHdl(&aWidthMF); 474 else if(aLeftMF.HasFocus()) 475 ModifyHdl(&aLeftMF); 476 else if(aRightMF.HasFocus()) 477 ModifyHdl(&aRightMF); 478 else if(aTopMF.HasFocus()) 479 ModifyHdl(&aTopMF); 480 else if(aBottomMF.HasFocus()) 481 ModifyHdl(&aBottomMF); 482 483 if(bModified) 484 { 485 if( aBottomMF.GetText() != aBottomMF.GetSavedValue() || 486 aTopMF.GetText() != aTopMF.GetSavedValue() ) 487 { 488 SvxULSpaceItem aULSpace(RES_UL_SPACE); 489 aULSpace.SetUpper( (sal_uInt16) aTopMF.Denormalize( 490 aTopMF.GetValue( FUNIT_TWIP ))); 491 aULSpace.SetLower( (sal_uInt16) aBottomMF.Denormalize( 492 aBottomMF.GetValue( FUNIT_TWIP ))); 493 rCoreSet.Put(aULSpace); 494 } 495 496 } 497 if(aNameED.GetText() != aNameED.GetSavedValue()) 498 { 499 rCoreSet.Put(SfxStringItem( FN_PARAM_TABLE_NAME, aNameED.GetText())); 500 bModified = sal_True; 501 } 502 503 sal_uInt16 nPos; 504 if( aTextDirectionLB.IsVisible() && 505 ( nPos = aTextDirectionLB.GetSelectEntryPos() ) != 506 aTextDirectionLB.GetSavedValue() ) 507 { 508 sal_uInt32 nDirection = (sal_uInt32)(sal_uIntPtr)aTextDirectionLB.GetEntryData( nPos ); 509 rCoreSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR)); 510 bModified = sal_True; 511 } 512 513 return bModified; 514 } 515 516 /*------------------------------------------------------------------------ 517 ------------------------------------------------------------------------*/ 518 void SwFormatTablePage::Reset( const SfxItemSet& ) 519 { 520 const SfxItemSet& rSet = GetItemSet(); 521 const SfxPoolItem* pItem; 522 523 if(bHtmlMode) 524 { 525 aNameED .Disable(); 526 aTopFT .Hide(); 527 aTopMF .Hide(); 528 aBottomFT.Hide(); 529 aBottomMF.Hide(); 530 aFreeBtn.Enable(sal_False); 531 } 532 FieldUnit aMetric = ::GetDfltMetric(bHtmlMode); 533 SetMetric( aWidthMF, aMetric ); 534 SetMetric( aRightMF, aMetric ); 535 SetMetric( aLeftMF, aMetric ); 536 SetMetric( aTopMF, aMetric ); 537 SetMetric( aBottomMF, aMetric ); 538 539 //Name 540 if(SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, sal_False, &pItem )) 541 { 542 aNameED.SetText(((const SfxStringItem*)pItem)->GetValue()); 543 aNameED.SaveValue(); 544 } 545 546 if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem )) 547 { 548 pTblData = (SwTableRep*)((const SwPtrItem*) pItem)->GetValue(); 549 nMinTableWidth = pTblData->GetColCount() * MINLAY; 550 551 if(pTblData->GetWidthPercent()) 552 { 553 aRelWidthCB.Check(sal_True); 554 RelWidthClickHdl(&aRelWidthCB); 555 aWidthMF.SetPrcntValue(pTblData->GetWidthPercent(), FUNIT_CUSTOM); 556 557 aWidthMF.SaveValue(); 558 nSaveWidth = static_cast< SwTwips >(aWidthMF.GetValue(FUNIT_CUSTOM)); 559 } 560 else 561 { 562 aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent( 563 pTblData->GetWidth()), FUNIT_TWIP); 564 aWidthMF.SaveValue(); 565 nSaveWidth = pTblData->GetWidth(); 566 nMinTableWidth = Min( nSaveWidth, nMinTableWidth ); 567 } 568 569 aWidthMF.SetRefValue(pTblData->GetSpace()); 570 aWidthMF.SetLast(aWidthMF.NormalizePercent( pTblData->GetSpace() )); 571 aLeftMF.SetLast(aLeftMF.NormalizePercent( pTblData->GetSpace() )); 572 aRightMF.SetLast(aRightMF.NormalizePercent( pTblData->GetSpace() )); 573 574 aLeftMF.SetPrcntValue(aLeftMF.NormalizePercent( 575 pTblData->GetLeftSpace()), FUNIT_TWIP); 576 aRightMF.SetPrcntValue(aRightMF.NormalizePercent( 577 pTblData->GetRightSpace()), FUNIT_TWIP); 578 aLeftMF.SaveValue(); 579 aRightMF.SaveValue(); 580 581 nOldAlign = pTblData->GetAlign(); 582 583 sal_Bool bSetRight = sal_False, bRightEnable = sal_False, 584 bSetLeft = sal_False, bLeftEnable = sal_False; 585 switch( nOldAlign ) 586 { 587 case text::HoriOrientation::NONE: 588 aFreeBtn.Check(); 589 if(aRelWidthCB.IsChecked()) 590 bSetRight = sal_True; 591 break; 592 case text::HoriOrientation::FULL: 593 { 594 bSetRight = bSetLeft = sal_True; 595 aFullBtn.Check(); 596 aWidthMF.Enable(sal_False); 597 aRelWidthCB.Enable(sal_False); 598 aWidthFT.Enable(sal_False); 599 } 600 break; 601 case text::HoriOrientation::LEFT: 602 { 603 bSetLeft = sal_True; 604 aLeftBtn.Check(); 605 } 606 break; 607 case text::HoriOrientation::LEFT_AND_WIDTH : 608 { 609 bSetRight = sal_True; 610 aFromLeftBtn.Check(); 611 } 612 break; 613 case text::HoriOrientation::RIGHT: 614 { 615 bSetRight = sal_True; 616 aRightBtn.Check(); 617 } 618 break; 619 case text::HoriOrientation::CENTER: 620 { 621 bSetRight = sal_True; 622 aCenterBtn.Check(); 623 } 624 break; 625 } 626 if ( bSetRight ) 627 { 628 aRightMF.Enable(bRightEnable); 629 aRightFT.Enable(bRightEnable); 630 } 631 if ( bSetLeft ) 632 { 633 aLeftMF.Enable(bLeftEnable); 634 aLeftFT.Enable(bLeftEnable); 635 } 636 637 } 638 639 //Raender 640 if(SFX_ITEM_SET == rSet.GetItemState( RES_UL_SPACE, sal_False,&pItem )) 641 { 642 aTopMF.SetValue(aTopMF.Normalize( 643 ((const SvxULSpaceItem*)pItem)->GetUpper()), FUNIT_TWIP); 644 aBottomMF.SetValue(aBottomMF.Normalize( 645 ((const SvxULSpaceItem*)pItem)->GetLower()), FUNIT_TWIP); 646 aTopMF.SaveValue(); 647 aBottomMF.SaveValue(); 648 } 649 650 //text direction 651 if( SFX_ITEM_SET == rSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem ) ) 652 { 653 sal_uInt32 nVal = ((SvxFrameDirectionItem*)pItem)->GetValue(); 654 sal_uInt16 nPos = aTextDirectionLB.GetEntryPos( (void*) nVal ); 655 aTextDirectionLB.SelectEntryPos( nPos ); 656 aTextDirectionLB.SaveValue(); 657 } 658 659 aWidthMF.SetMax( 2*aWidthMF.NormalizePercent( pTblData->GetSpace() ), FUNIT_TWIP ); 660 aRightMF.SetMax( aRightMF.NormalizePercent( pTblData->GetSpace() ), FUNIT_TWIP ); 661 aLeftMF.SetMax( aLeftMF.NormalizePercent( pTblData->GetSpace() ), FUNIT_TWIP ); 662 aWidthMF.SetMin( aWidthMF.NormalizePercent( nMinTableWidth ), FUNIT_TWIP ); 663 664 } 665 666 /*------------------------------------------------------------------------ 667 ------------------------------------------------------------------------*/ 668 void SwFormatTablePage::ActivatePage( const SfxItemSet& rSet ) 669 { 670 DBG_ASSERT(pTblData, "Tabellendaten nicht da?"); 671 if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP )) 672 { 673 SwTwips nCurWidth = text::HoriOrientation::FULL != pTblData->GetAlign() ? 674 pTblData->GetWidth() : 675 pTblData->GetSpace(); 676 if(pTblData->GetWidthPercent() == 0 && 677 nCurWidth != aWidthMF.DenormalizePercent(aWidthMF.GetValue(FUNIT_TWIP ))) 678 { 679 aWidthMF.SetPrcntValue(aWidthMF.NormalizePercent( 680 nCurWidth), FUNIT_TWIP); 681 aWidthMF.SaveValue(); 682 nSaveWidth = nCurWidth; 683 aLeftMF.SetPrcntValue(aLeftMF.NormalizePercent( 684 pTblData->GetLeftSpace()), FUNIT_TWIP); 685 aLeftMF.SaveValue(); 686 aRightMF.SetPrcntValue(aRightMF.NormalizePercent( 687 pTblData->GetRightSpace()), FUNIT_TWIP); 688 aRightMF.SaveValue(); 689 } 690 } 691 692 } 693 /*------------------------------------------------------------------------ 694 ------------------------------------------------------------------------*/ 695 int SwFormatTablePage::DeactivatePage( SfxItemSet* _pSet ) 696 { 697 // os: VCL sorgt nicht dafuer, dass das aktive Control im 698 // dialog bei OK den focus verliert 699 aNameED.GrabFocus(); 700 // Test des Tabellennamens auf Leerzeichen 701 String sTblName = aNameED.GetText(); 702 if(sTblName.Search(' ') != STRING_NOTFOUND) 703 { 704 InfoBox(this, SW_RES(MSG_WRONG_TABLENAME)).Execute(); 705 aNameED.GrabFocus(); 706 return KEEP_PAGE; 707 } 708 if(_pSet) 709 { 710 FillItemSet(*_pSet); 711 if(bModified) 712 { 713 SwTwips lLeft = static_cast< SwTwips >(aLeftMF.DenormalizePercent(aLeftMF.GetValue( FUNIT_TWIP ))); 714 SwTwips lRight = static_cast< SwTwips >(aRightMF.DenormalizePercent(aRightMF.GetValue( FUNIT_TWIP ))); 715 716 717 if( aLeftMF.GetText() != aLeftMF.GetSavedValue() || 718 aRightMF.GetText() != aRightMF.GetSavedValue() ) 719 { 720 pTblData->SetWidthChanged(); 721 pTblData->SetLeftSpace( lLeft); 722 pTblData->SetRightSpace( lRight); 723 } 724 725 SwTwips lWidth; 726 if (aRelWidthCB.IsChecked() && aRelWidthCB.IsEnabled()) 727 { 728 lWidth = pTblData->GetSpace() - lRight - lLeft; 729 sal_uInt16 nPercentWidth = (sal_uInt16)aWidthMF.GetValue(FUNIT_CUSTOM); 730 if(pTblData->GetWidthPercent() != nPercentWidth) 731 { 732 pTblData->SetWidthPercent(nPercentWidth); 733 pTblData->SetWidthChanged(); 734 } 735 } 736 else 737 { 738 pTblData->SetWidthPercent(0); 739 lWidth = static_cast< SwTwips >(aWidthMF.DenormalizePercent(aWidthMF.GetValue( FUNIT_TWIP ))); 740 } 741 pTblData->SetWidth(lWidth); 742 743 SwTwips nColSum = 0; 744 sal_uInt16 i; 745 746 for( i = 0; i < pTblData->GetColCount(); i++) 747 { 748 nColSum += pTblData->GetColumns()[i].nWidth; 749 } 750 if(nColSum != pTblData->GetWidth()) 751 { 752 SwTwips nMinWidth = Min( (long)MINLAY, 753 (long) (pTblData->GetWidth() / 754 pTblData->GetColCount() - 1)); 755 SwTwips nDiff = nColSum - pTblData->GetWidth(); 756 while ( Abs(nDiff) > pTblData->GetColCount() + 1 ) 757 { 758 SwTwips nSub = nDiff / pTblData->GetColCount(); 759 for( i = 0; i < pTblData->GetColCount(); i++) 760 { 761 if(pTblData->GetColumns()[i].nWidth - nMinWidth > nSub) 762 { 763 pTblData->GetColumns()[i].nWidth -= nSub; 764 nDiff -= nSub; 765 } 766 else 767 { 768 nDiff -= pTblData->GetColumns()[i].nWidth - nMinWidth; 769 pTblData->GetColumns()[i].nWidth = nMinWidth; 770 } 771 772 } 773 } 774 } 775 776 sal_Int16 nAlign = 0; 777 if(aRightBtn.IsChecked()) 778 nAlign = text::HoriOrientation::RIGHT; 779 else if(aLeftBtn.IsChecked()) 780 nAlign = text::HoriOrientation::LEFT; 781 else if(aFromLeftBtn.IsChecked()) 782 nAlign = text::HoriOrientation::LEFT_AND_WIDTH; 783 else if(aCenterBtn.IsChecked()) 784 nAlign = text::HoriOrientation::CENTER; 785 else if(aFreeBtn.IsChecked()) 786 nAlign = text::HoriOrientation::NONE; 787 else if(aFullBtn.IsChecked()) 788 { 789 nAlign = text::HoriOrientation::FULL; 790 lWidth = lAutoWidth; 791 } 792 if(nAlign != pTblData->GetAlign()) 793 { 794 pTblData->SetWidthChanged(); 795 pTblData->SetAlign(nAlign); 796 } 797 798 799 // if( text::HoriOrientation::CENTER && lWidth != (SwTwips)aWidthMF.GetSavedValue()) 800 if(pTblData->GetWidth() != lWidth ) 801 { 802 pTblData->SetWidthChanged(); 803 pTblData->SetWidth( 804 nAlign == text::HoriOrientation::FULL ? pTblData->GetSpace() : lWidth ); 805 } 806 if(pTblData->HasWidthChanged()) 807 _pSet->Put(SwPtrItem(FN_TABLE_REP, pTblData)); 808 } 809 #ifdef DEBUG_TBLDLG 810 DbgTblRep(pTblData) 811 #endif 812 } 813 return sal_True; 814 } 815 /*------------------------------------------------------------------------ 816 Beschreibung: Seite Spaltenkonfiguration 817 ------------------------------------------------------------------------*/ 818 SwTableColumnPage::SwTableColumnPage( Window* pParent, 819 const SfxItemSet& rSet ) : 820 SfxTabPage(pParent, SW_RES( TP_TABLE_COLUMN ), rSet ), 821 aModifyTableCB(this, SW_RES(CB_MOD_TBL)), 822 aProportionalCB(this, SW_RES(CB_PROP)), 823 aSpaceFT(this, SW_RES(FT_SPACE)), 824 aSpaceED(this, SW_RES(ED_SPACE)), 825 826 aColFL(this, SW_RES(COL_FL_LAYOUT)), 827 aUpBtn(this, SW_RES(COL_BTN_UP)), 828 aFT1(this, SW_RES(COL_FT_1)), 829 aMF1(this, SW_RES(COL_MF_1)), 830 aFT2(this, SW_RES(COL_FT_2)), 831 aMF2(this, SW_RES(COL_MF_2)), 832 aFT3(this, SW_RES(COL_FT_3)), 833 aMF3(this, SW_RES(COL_MF_3)), 834 aFT4(this, SW_RES(COL_FT_4)), 835 aMF4(this, SW_RES(COL_MF_4)), 836 aFT5(this, SW_RES(COL_FT_5)), 837 aMF5(this, SW_RES(COL_MF_5)), 838 aFT6(this, SW_RES(COL_FT_6)), 839 aMF6(this, SW_RES(COL_MF_6)), 840 aDownBtn(this, SW_RES(COL_BTN_DOWN)), 841 842 nTableWidth(0), 843 nMinWidth( MINLAY ), 844 nNoOfCols( 0 ), 845 nNoOfVisibleCols( 0 ), 846 bModified(sal_False), 847 bModifyTbl(sal_False), 848 bPercentMode(sal_False) 849 { 850 FreeResource(); 851 SetExchangeSupport(); 852 853 aDownBtn.SetAccessibleRelationMemberOf(&aColFL); 854 aUpBtn.SetAccessibleRelationMemberOf(&aColFL); 855 856 pFieldArr[0] = &aMF1; 857 pFieldArr[1] = &aMF2; 858 pFieldArr[2] = &aMF3; 859 pFieldArr[3] = &aMF4; 860 pFieldArr[4] = &aMF5; 861 pFieldArr[5] = &aMF6; 862 863 pTextArr[0] = &aFT1; 864 pTextArr[1] = &aFT2; 865 pTextArr[2] = &aFT3; 866 pTextArr[3] = &aFT4; 867 pTextArr[4] = &aFT5; 868 pTextArr[5] = &aFT6; 869 870 const SfxPoolItem* pItem; 871 Init((SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, sal_False,&pItem ) 872 && ((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON)); 873 874 }; 875 /*------------------------------------------------------------------------ 876 Beschreibung: Seite Spaltenkonfiguration 877 ------------------------------------------------------------------------*/ 878 SwTableColumnPage::~SwTableColumnPage() 879 { 880 }; 881 882 /*------------------------------------------------------------------------ 883 ------------------------------------------------------------------------*/ 884 SfxTabPage* SwTableColumnPage::Create( Window* pParent, 885 const SfxItemSet& rAttrSet) 886 { 887 return new SwTableColumnPage( pParent, rAttrSet ); 888 }; 889 890 /*------------------------------------------------------------------------ 891 ------------------------------------------------------------------------*/ 892 void SwTableColumnPage::Reset( const SfxItemSet& ) 893 { 894 const SfxItemSet& rSet = GetItemSet(); 895 896 const SfxPoolItem* pItem; 897 if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem )) 898 { 899 pTblData = (SwTableRep*)((const SwPtrItem*) pItem)->GetValue(); 900 nNoOfVisibleCols = pTblData->GetColCount(); 901 nNoOfCols = pTblData->GetAllColCount(); 902 nTableWidth = pTblData->GetAlign() != text::HoriOrientation::FULL && 903 pTblData->GetAlign() != text::HoriOrientation::LEFT_AND_WIDTH? 904 pTblData->GetWidth() : pTblData->GetSpace(); 905 906 sal_uInt16 i; 907 for( i = 0; i < nNoOfCols; i++ ) 908 { 909 if( pTblData->GetColumns()[i].nWidth < nMinWidth ) 910 nMinWidth = pTblData->GetColumns()[i].nWidth; 911 } 912 sal_Int64 nMinTwips = pFieldArr[0]->NormalizePercent( nMinWidth ); 913 sal_Int64 nMaxTwips = pFieldArr[0]->NormalizePercent( nTableWidth ); 914 for( i = 0; (i < MET_FIELDS) && (i < nNoOfVisibleCols); i++ ) 915 { 916 pFieldArr[i]->SetPrcntValue( pFieldArr[i]->NormalizePercent( 917 GetVisibleWidth(i) ), FUNIT_TWIP ); 918 pFieldArr[i]->SetMin( nMinTwips , FUNIT_TWIP ); 919 pFieldArr[i]->SetMax( nMaxTwips , FUNIT_TWIP ); 920 pFieldArr[i]->Enable(); 921 pTextArr[i]->Enable(); 922 } 923 924 if( nNoOfVisibleCols > MET_FIELDS ) 925 aUpBtn.Enable(); 926 i = nNoOfVisibleCols; 927 while( i < MET_FIELDS ) 928 { 929 pFieldArr[i]->SetText( aEmptyStr ); 930 pTextArr[i]->Hide(); 931 i++; 932 } 933 } 934 ActivatePage(rSet); 935 936 }; 937 938 /*------------------------------------------------------------------------ 939 ------------------------------------------------------------------------*/ 940 void SwTableColumnPage::Init(sal_Bool bWeb) 941 { 942 FieldUnit aMetric = ::GetDfltMetric(bWeb); 943 Link aLkUp = LINK( this, SwTableColumnPage, UpHdl ); 944 Link aLkDown = LINK( this, SwTableColumnPage, DownHdl ); 945 Link aLkLF = LINK( this, SwTableColumnPage, LoseFocusHdl ); 946 for( sal_uInt16 i = 0; i < MET_FIELDS; i++ ) 947 { 948 aValueTbl[i] = i; 949 SetMetric(*pFieldArr[i], aMetric); 950 pFieldArr[i]->SetUpHdl( aLkUp ); 951 pFieldArr[i]->SetDownHdl( aLkDown ); 952 pFieldArr[i]->SetLoseFocusHdl( aLkLF ); 953 954 } 955 SetMetric(aSpaceED, aMetric); 956 957 Link aLk = LINK( this, SwTableColumnPage, AutoClickHdl ); 958 aUpBtn.SetClickHdl( aLk ); 959 aDownBtn.SetClickHdl( aLk ); 960 961 aLk = LINK( this, SwTableColumnPage, ModeHdl ); 962 aModifyTableCB .SetClickHdl( aLk ); 963 aProportionalCB.SetClickHdl( aLk ); 964 }; 965 966 /*------------------------------------------------------------------------ 967 ------------------------------------------------------------------------*/ 968 IMPL_LINK( SwTableColumnPage, AutoClickHdl, CheckBox *, pBox ) 969 { 970 //Anzeigefenster verschieben 971 if(pBox == (CheckBox *)&aDownBtn) 972 { 973 if(aValueTbl[0] > 0) 974 { 975 for( sal_uInt16 i=0; i < MET_FIELDS; i++ ) 976 aValueTbl[i] -= 1; 977 } 978 } 979 if(pBox == (CheckBox *)&aUpBtn) 980 { 981 if( aValueTbl[ MET_FIELDS -1 ] < nNoOfVisibleCols -1 ) 982 { 983 for(sal_uInt16 i=0;i < MET_FIELDS;i++) 984 aValueTbl[i] += 1; 985 } 986 } 987 for( sal_uInt16 i = 0; (i < nNoOfVisibleCols ) && ( i < MET_FIELDS); i++ ) 988 { 989 String sEntry('~'); 990 String sIndex = String::CreateFromInt32( aValueTbl[i] + 1 ); 991 sEntry += sIndex; 992 pTextArr[i]->SetText( sEntry ); 993 //IAccessibility2 Impplementaton 2009----- 994 //added by menghu for SODC_5143,12/12/2006 995 String sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH); 996 sColumnWidth.SearchAndReplace( DEFINE_CONST_UNICODE("%1"), sIndex ); 997 pFieldArr[i]->SetAccessibleName( sColumnWidth ); 998 //end of SODC_5143 999 //-----IAccessibility2 Impplementaton 2009 1000 } 1001 1002 aDownBtn.Enable(aValueTbl[0] > 0); 1003 aUpBtn.Enable(aValueTbl[ MET_FIELDS -1 ] < nNoOfVisibleCols -1 ); 1004 UpdateCols(0); 1005 return 0; 1006 }; 1007 1008 /*------------------------------------------------------------------------ 1009 ------------------------------------------------------------------------*/ 1010 IMPL_LINK_INLINE_START( SwTableColumnPage, UpHdl, PercentField *, pEdit ) 1011 { 1012 bModified = sal_True; 1013 ModifyHdl( pEdit ); 1014 return 0; 1015 }; 1016 IMPL_LINK_INLINE_END( SwTableColumnPage, UpHdl, PercentField *, pEdit ) 1017 1018 /*------------------------------------------------------------------------ 1019 ------------------------------------------------------------------------*/ 1020 IMPL_LINK_INLINE_START( SwTableColumnPage, DownHdl, PercentField *, pEdit ) 1021 { 1022 bModified = sal_True; 1023 ModifyHdl( pEdit ); 1024 return 0; 1025 }; 1026 IMPL_LINK_INLINE_END( SwTableColumnPage, DownHdl, PercentField *, pEdit ) 1027 1028 /*------------------------------------------------------------------------ 1029 ------------------------------------------------------------------------*/ 1030 IMPL_LINK_INLINE_START( SwTableColumnPage, LoseFocusHdl, PercentField *, pEdit ) 1031 { 1032 if(pEdit->IsModified()) 1033 { 1034 bModified = sal_True; 1035 ModifyHdl( pEdit ); 1036 } 1037 return 0; 1038 }; 1039 IMPL_LINK_INLINE_END( SwTableColumnPage, LoseFocusHdl, PercentField *, pEdit ) 1040 1041 /*------------------------------------------------------------------------ 1042 ------------------------------------------------------------------------*/ 1043 IMPL_LINK( SwTableColumnPage, ModeHdl, CheckBox*, pBox ) 1044 { 1045 sal_Bool bCheck = pBox->IsChecked(); 1046 if(pBox == &aProportionalCB) 1047 { 1048 if(bCheck) 1049 aModifyTableCB.Check(); 1050 aModifyTableCB.Enable(!bCheck && bModifyTbl); 1051 } 1052 return 0; 1053 }; 1054 1055 /*------------------------------------------------------------------------ 1056 ------------------------------------------------------------------------*/ 1057 sal_Bool SwTableColumnPage::FillItemSet( SfxItemSet& ) 1058 { 1059 for( sal_uInt16 i = 0; i < MET_FIELDS; i++ ) 1060 { 1061 if(pFieldArr[i]->HasFocus()) 1062 { 1063 LoseFocusHdl(pFieldArr[i]); 1064 break; 1065 } 1066 } 1067 1068 if(bModified) 1069 { 1070 pTblData->SetColsChanged(); 1071 } 1072 return bModified; 1073 }; 1074 1075 /*------------------------------------------------------------------------ 1076 ------------------------------------------------------------------------*/ 1077 void SwTableColumnPage::ModifyHdl( PercentField* pEdit ) 1078 { 1079 sal_uInt16 nAktPos; 1080 sal_uInt16 i; 1081 1082 for( i = 0; i < MET_FIELDS; i++) 1083 if(pEdit == pFieldArr[i]) 1084 break; 1085 1086 SetVisibleWidth(aValueTbl[i], static_cast< SwTwips >(pEdit->DenormalizePercent(pEdit->GetValue( FUNIT_TWIP ))) ); 1087 nAktPos = aValueTbl[i]; 1088 1089 UpdateCols( nAktPos ); 1090 }; 1091 1092 /*------------------------------------------------------------------------ 1093 ------------------------------------------------------------------------*/ 1094 void SwTableColumnPage::UpdateCols( sal_uInt16 nAktPos ) 1095 { 1096 SwTwips nSum = 0; 1097 sal_uInt16 i; 1098 1099 for( i = 0; i < nNoOfCols; i++ ) 1100 { 1101 nSum += (pTblData->GetColumns())[i].nWidth; 1102 } 1103 SwTwips nDiff = nSum - nTableWidth; 1104 1105 sal_Bool bModifyTable = aModifyTableCB.IsChecked(); 1106 sal_Bool bProp = aProportionalCB.IsChecked(); 1107 1108 if(!bModifyTable && !bProp ) 1109 { 1110 // the table width is constant, the difference is balanced with the other columns 1111 sal_uInt16 nLoopCount = 0; 1112 while( nDiff ) 1113 { 1114 if( ++nAktPos == nNoOfVisibleCols) 1115 { 1116 nAktPos = 0; 1117 ++nLoopCount; 1118 //#i101353# in small tables it might not be possible to balance column width 1119 if( nLoopCount > 1 ) 1120 break; 1121 } 1122 if( nDiff < 0 ) 1123 { 1124 SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) -nDiff); 1125 nDiff = 0; 1126 } 1127 else if( GetVisibleWidth(nAktPos) >= nDiff + nMinWidth ) 1128 { 1129 SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) -nDiff); 1130 nDiff = 0; 1131 } 1132 if( nDiff > 0 && GetVisibleWidth(nAktPos) > nMinWidth ) 1133 { 1134 if( nDiff >= (GetVisibleWidth(nAktPos) - nMinWidth) ) 1135 { 1136 nDiff -= (GetVisibleWidth(nAktPos) - nMinWidth); 1137 SetVisibleWidth(nAktPos, nMinWidth); 1138 } 1139 else 1140 { 1141 nDiff = 0; 1142 SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) -nDiff); 1143 } 1144 DBG_ASSERT(nDiff >= 0, "nDiff < 0 kann hier nicht sein!"); 1145 } 1146 } 1147 } 1148 else if(bModifyTable && !bProp) 1149 { 1150 // Differenz wird ueber die Tabellenbreite ausgeglichen, 1151 // andere Spalten bleiben unveraendert 1152 DBG_ASSERT(nDiff <= pTblData->GetSpace() - nTableWidth, "Maximum falsch eingestellt" ); 1153 SwTwips nActSpace = pTblData->GetSpace() - nTableWidth; 1154 if(nDiff > nActSpace) 1155 { 1156 nTableWidth = pTblData->GetSpace(); 1157 SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) - nDiff + nActSpace ); 1158 } 1159 else 1160 { 1161 nTableWidth += nDiff; 1162 } 1163 } 1164 else if(bModifyTable & bProp) 1165 { 1166 // Alle Spalten werden proportional mitveraendert, die Tabellenbreite wird 1167 // entsprechend angepasst 1168 DBG_ASSERT(nDiff * nNoOfVisibleCols <= pTblData->GetSpace() - nTableWidth, "Maximum falsch eingestellt" ); 1169 long nAdd = nDiff; 1170 if(nDiff * nNoOfVisibleCols > pTblData->GetSpace() - nTableWidth) 1171 { 1172 nAdd = (pTblData->GetSpace() - nTableWidth) / nNoOfVisibleCols; 1173 SetVisibleWidth(nAktPos, GetVisibleWidth(nAktPos) - nDiff + nAdd ); 1174 nDiff = nAdd; 1175 } 1176 if(nAdd) 1177 for(i = 0; i < nNoOfVisibleCols; i++ ) 1178 { 1179 if(i == nAktPos) 1180 continue; 1181 SwTwips nVisWidth; 1182 if((nVisWidth = GetVisibleWidth(i)) + nDiff < MINLAY) 1183 { 1184 nAdd += nVisWidth - MINLAY; 1185 SetVisibleWidth(i, MINLAY); 1186 } 1187 else 1188 { 1189 SetVisibleWidth(i, nVisWidth + nDiff); 1190 nAdd += nDiff; 1191 } 1192 1193 } 1194 nTableWidth += nAdd; 1195 1196 } 1197 else 1198 { 1199 // Die Differenz wird gleichmaessig auf alle anderen Spalten aufgeteilt 1200 // die Tabellenbreite bleibt konstant 1201 /* 1202 SwTwips nDiffn = nDiff/(nNoOfVisibleCols - 1); 1203 if(nDiff < 0 && (nNoOfVisibleCols - 1) * nDiffn != nDiff) 1204 nDiffn-- ; 1205 sal_uInt16 nStart = nAktPos++; 1206 if(nAktPos == nNoOfVisibleCols) 1207 nStart = 0; 1208 for(sal_uInt16 i = 0; i < nNoOfVisibleCols; i++ ) 1209 { 1210 if((nVisWidth = GetVisibleWidth(i)) + nDiff < MINLAY) 1211 { 1212 nAdd += nVisWidth - MINLAY; 1213 SetVisibleWidth(i, MINLAY); 1214 } 1215 } 1216 */ 1217 1218 } 1219 1220 #ifdef DEBUG_TBLDLG 1221 DbgTblRep(pTblData) 1222 #endif 1223 1224 if(!bPercentMode) 1225 aSpaceED.SetValue(aSpaceED.Normalize( pTblData->GetSpace() - nTableWidth) , FUNIT_TWIP); 1226 1227 for( i = 0; ( i < nNoOfVisibleCols ) && ( i < MET_FIELDS ); i++) 1228 { 1229 pFieldArr[i]->SetPrcntValue(pFieldArr[i]->NormalizePercent( 1230 GetVisibleWidth(aValueTbl[i]) ), FUNIT_TWIP); 1231 pFieldArr[i]->ClearModifyFlag(); 1232 } 1233 1234 } 1235 1236 /*------------------------------------------------------------------------ 1237 ------------------------------------------------------------------------*/ 1238 void SwTableColumnPage::ActivatePage( const SfxItemSet& ) 1239 { 1240 bPercentMode = pTblData->GetWidthPercent() != 0; 1241 for( sal_uInt16 i = 0; (i < MET_FIELDS) && (i < nNoOfVisibleCols); i++ ) 1242 { 1243 pFieldArr[i]->SetRefValue(pTblData->GetWidth()); 1244 pFieldArr[i]->ShowPercent( bPercentMode ); 1245 } 1246 1247 sal_uInt16 nTblAlign = pTblData->GetAlign(); 1248 if((text::HoriOrientation::FULL != nTblAlign && nTableWidth != pTblData->GetWidth()) || 1249 (text::HoriOrientation::FULL == nTblAlign && nTableWidth != pTblData->GetSpace())) 1250 { 1251 nTableWidth = text::HoriOrientation::FULL == nTblAlign ? 1252 pTblData->GetSpace() : 1253 pTblData->GetWidth(); 1254 UpdateCols(0); 1255 } 1256 bModifyTbl = sal_True; 1257 if(pTblData->GetWidthPercent() || 1258 text::HoriOrientation::FULL == nTblAlign || 1259 pTblData->IsLineSelected() ) 1260 bModifyTbl = sal_False; 1261 if(bPercentMode) 1262 { 1263 aModifyTableCB .Check(sal_False); 1264 aProportionalCB .Check(sal_False); 1265 } 1266 else if( !bModifyTbl ) 1267 { 1268 aProportionalCB.Check(sal_False); 1269 aModifyTableCB.Check(sal_False); 1270 } 1271 aSpaceFT.Enable(!bPercentMode); 1272 aSpaceED.Enable(!bPercentMode); 1273 aModifyTableCB.Enable( !bPercentMode && bModifyTbl ); 1274 aProportionalCB.Enable(!bPercentMode && bModifyTbl ); 1275 1276 /* if(pTblData->IsLineSelected() && pTblData->IsComplex()) 1277 { 1278 1279 }*/ 1280 aSpaceED.SetValue(aSpaceED.Normalize( 1281 pTblData->GetSpace() - nTableWidth) , FUNIT_TWIP); 1282 1283 } 1284 1285 /*------------------------------------------------------------------------ 1286 ------------------------------------------------------------------------*/ 1287 int SwTableColumnPage::DeactivatePage( SfxItemSet* _pSet ) 1288 { 1289 if(_pSet) 1290 { 1291 FillItemSet(*_pSet); 1292 if(text::HoriOrientation::FULL != pTblData->GetAlign() && pTblData->GetWidth() != nTableWidth) 1293 { 1294 pTblData->SetWidth(nTableWidth); 1295 SwTwips nDiff = pTblData->GetSpace() - pTblData->GetWidth() - 1296 pTblData->GetLeftSpace() - pTblData->GetRightSpace(); 1297 switch( pTblData->GetAlign() ) 1298 { 1299 case text::HoriOrientation::RIGHT: 1300 pTblData->SetLeftSpace(pTblData->GetLeftSpace() + nDiff); 1301 break; 1302 case text::HoriOrientation::LEFT: 1303 pTblData->SetRightSpace(pTblData->GetRightSpace() + nDiff); 1304 break; 1305 case text::HoriOrientation::NONE: 1306 { 1307 SwTwips nDiff2 = nDiff/2; 1308 if( nDiff > 0 || 1309 (-nDiff2 < pTblData->GetRightSpace() && - nDiff2 < pTblData->GetLeftSpace())) 1310 { 1311 pTblData->SetRightSpace(pTblData->GetRightSpace() + nDiff2); 1312 pTblData->SetLeftSpace(pTblData->GetLeftSpace() + nDiff2); 1313 } 1314 else 1315 { 1316 if(pTblData->GetRightSpace() > pTblData->GetLeftSpace()) 1317 { 1318 pTblData->SetLeftSpace(0); 1319 pTblData->SetRightSpace(pTblData->GetSpace() - pTblData->GetWidth()); 1320 } 1321 else 1322 { 1323 pTblData->SetRightSpace(0); 1324 pTblData->SetLeftSpace(pTblData->GetSpace() - pTblData->GetWidth()); 1325 } 1326 } 1327 } 1328 break; 1329 case text::HoriOrientation::CENTER: 1330 pTblData->SetRightSpace(pTblData->GetRightSpace() + nDiff/2); 1331 pTblData->SetLeftSpace(pTblData->GetLeftSpace() + nDiff/2); 1332 break; 1333 case text::HoriOrientation::LEFT_AND_WIDTH : 1334 if(nDiff > pTblData->GetRightSpace()) 1335 { 1336 pTblData->SetLeftSpace(pTblData->GetSpace() - pTblData->GetWidth()); 1337 } 1338 pTblData->SetRightSpace( 1339 pTblData->GetSpace() - pTblData->GetWidth() - pTblData->GetLeftSpace()); 1340 break; 1341 } 1342 pTblData->SetWidthChanged(); 1343 } 1344 #ifdef DEBUG_TBLDLG 1345 DbgTblRep(pTblData) 1346 #endif 1347 _pSet->Put(SwPtrItem( FN_TABLE_REP, pTblData )); 1348 } 1349 return sal_True; 1350 } 1351 1352 /*------------------------------------------------------------------------ 1353 ------------------------------------------------------------------------*/ 1354 SwTwips SwTableColumnPage::GetVisibleWidth(sal_uInt16 nPos) 1355 { 1356 sal_uInt16 i=0; 1357 1358 while( nPos ) 1359 { 1360 if(pTblData->GetColumns()[i].bVisible && nPos) 1361 nPos--; 1362 i++; 1363 } 1364 SwTwips nReturn = pTblData->GetColumns()[i].nWidth; 1365 DBG_ASSERT(i < nNoOfCols, "Array index out of range"); 1366 while(!pTblData->GetColumns()[i].bVisible && (i + 1) < nNoOfCols) 1367 nReturn += pTblData->GetColumns()[++i].nWidth; 1368 1369 // return (*ppTableColumns)[i].nWidth; 1370 return nReturn; 1371 } 1372 1373 /*------------------------------------------------------------------------ 1374 ------------------------------------------------------------------------*/ 1375 void SwTableColumnPage::SetVisibleWidth(sal_uInt16 nPos, SwTwips nNewWidth) 1376 { 1377 sal_uInt16 i=0; 1378 while( nPos ) 1379 { 1380 if(pTblData->GetColumns()[i].bVisible && nPos) 1381 nPos--; 1382 i++; 1383 } 1384 DBG_ASSERT(i < nNoOfCols, "Array index out of range"); 1385 pTblData->GetColumns()[i].nWidth = nNewWidth; 1386 while(!pTblData->GetColumns()[i].bVisible && (i + 1) < nNoOfCols) 1387 pTblData->GetColumns()[++i].nWidth = 0; 1388 1389 } 1390 1391 /*------------------------------------------------------------------------ 1392 ------------------------------------------------------------------------*/ 1393 SwTableTabDlg::SwTableTabDlg(Window* pParent, SfxItemPool& , 1394 const SfxItemSet* pItemSet, SwWrtShell* pSh ) : 1395 SfxTabDialog(pParent, SW_RES(DLG_FORMAT_TABLE), pItemSet,0), 1396 pShell(pSh), 1397 nHtmlMode(::GetHtmlMode(pSh->GetView().GetDocShell())) 1398 { 1399 FreeResource(); 1400 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 1401 DBG_ASSERT(pFact, "Dialogdiet fail!"); 1402 AddTabPage(TP_FORMAT_TABLE, &SwFormatTablePage::Create, 0 ); 1403 AddTabPage(TP_TABLE_TEXTFLOW, &SwTextFlowPage::Create, 0 ); 1404 AddTabPage(TP_TABLE_COLUMN, &SwTableColumnPage::Create, 0 ); 1405 AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 ); 1406 AddTabPage(TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 ); 1407 } 1408 1409 1410 /*------------------------------------------------------------------------ 1411 ------------------------------------------------------------------------*/ 1412 void SwTableTabDlg::PageCreated(sal_uInt16 nId, SfxTabPage& rPage) 1413 { 1414 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); 1415 if( TP_BACKGROUND == nId ) 1416 { 1417 sal_Int32 nFlagType = SVX_SHOW_TBLCTL; 1418 if(!( nHtmlMode & HTMLMODE_ON ) || 1419 nHtmlMode & HTMLMODE_SOME_STYLES) 1420 nFlagType |= SVX_SHOW_SELECTOR; 1421 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType)); 1422 rPage.PageCreated(aSet); 1423 } 1424 else if(TP_BORDER == nId) 1425 { 1426 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_TABLE)); 1427 rPage.PageCreated(aSet); 1428 } 1429 else if(TP_TABLE_TEXTFLOW == nId) 1430 { 1431 ((SwTextFlowPage&)rPage).SetShell(pShell); 1432 const sal_uInt16 eType = pShell->GetFrmType(0,sal_True); 1433 if( !(FRMTYPE_BODY & eType) ) 1434 ((SwTextFlowPage&)rPage).DisablePageBreak(); 1435 } 1436 } 1437 1438 /*-----------------12.12.96 12.22------------------- 1439 --------------------------------------------------*/ 1440 SwTextFlowPage::SwTextFlowPage( Window* pParent, 1441 const SfxItemSet& rSet ) : 1442 SfxTabPage(pParent, SW_RES( TP_TABLE_TEXTFLOW ), rSet ), 1443 aFlowFL (this, SW_RES(FL_FLOW )), 1444 aPgBrkCB (this, SW_RES(CB_PAGEBREAK )), 1445 aPgBrkRB (this, SW_RES(RB_BREAKPAGE )), 1446 aColBrkRB (this, SW_RES(RB_BREAKCOLUMN )), 1447 aPgBrkBeforeRB (this, SW_RES(RB_PAGEBREAKBEFORE)), 1448 aPgBrkAfterRB (this, SW_RES(RB_PAGEBREAKAFTER )), 1449 aPageCollCB (this, SW_RES(CB_PAGECOLL )), 1450 aPageCollLB (this, SW_RES(LB_PAGECOLL )), 1451 aPageNoFT (this, SW_RES(FT_PAGENUM )), 1452 aPageNoNF (this, SW_RES(NF_PAGENUM )), 1453 aSplitCB (this, SW_RES(CB_SPLIT )), 1454 aSplitRowCB (this, SW_RES(CB_SPLIT_ROW )), 1455 aKeepCB (this, SW_RES(CB_KEEP )), 1456 aHeadLineCB (this, SW_RES(CB_HEADLINE )), 1457 aRepeatHeaderFT (this, SW_RES(FT_REPEAT_HEADER )), 1458 aRepeatHeaderBeforeFT (this), 1459 aRepeatHeaderNF (this, SW_RES(NF_REPEAT_HEADER )), 1460 aRepeatHeaderAfterFT (this), 1461 aRepeatHeaderCombo (this, SW_RES(WIN_REPEAT_HEADER), aRepeatHeaderNF, aRepeatHeaderBeforeFT, aRepeatHeaderAfterFT), 1462 aTextDirectionFT(this, SW_RES(FT_TEXTDIRECTION )), 1463 aTextDirectionLB(this, SW_RES(LB_TEXTDIRECTION )), 1464 1465 aVertOrientFL (this, SW_RES(FL_VERT_ORIENT )), 1466 aVertOrientFT(this, SW_RES(FT_VERTORIENT )), 1467 aVertOrientLB(this, SW_RES(LB_VERTORIENT )), 1468 1469 pShell(0), 1470 1471 bPageBreak(sal_True), 1472 bHtmlMode(sal_False) 1473 { 1474 FreeResource(); 1475 1476 aPgBrkRB.SetAccessibleRelationMemberOf(&aPgBrkCB); 1477 aColBrkRB.SetAccessibleRelationMemberOf(&aPgBrkCB); 1478 aPgBrkBeforeRB.SetAccessibleRelationMemberOf(&aPgBrkCB); 1479 aPgBrkAfterRB.SetAccessibleRelationMemberOf(&aPgBrkCB); 1480 aPageCollLB.SetAccessibleRelationLabeledBy(&aPageCollCB); 1481 aPageCollLB.SetAccessibleName(aPageCollCB.GetText()); 1482 1483 aPgBrkCB.SetClickHdl(LINK(this, SwTextFlowPage, PageBreakHdl_Impl)); 1484 aPgBrkBeforeRB.SetClickHdl( 1485 LINK( this, SwTextFlowPage, PageBreakPosHdl_Impl ) ); 1486 aPgBrkAfterRB.SetClickHdl( 1487 LINK( this, SwTextFlowPage, PageBreakPosHdl_Impl ) ); 1488 aPageCollCB.SetClickHdl( 1489 LINK( this, SwTextFlowPage, ApplyCollClickHdl_Impl ) ); 1490 aColBrkRB.SetClickHdl( 1491 LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) ); 1492 aPgBrkRB.SetClickHdl( 1493 LINK( this, SwTextFlowPage, PageBreakTypeHdl_Impl ) ); 1494 aSplitCB.SetClickHdl( 1495 LINK( this, SwTextFlowPage, SplitHdl_Impl)); 1496 aSplitRowCB.SetClickHdl( 1497 LINK( this, SwTextFlowPage, SplitRowHdl_Impl)); 1498 aHeadLineCB.SetClickHdl( LINK( this, SwTextFlowPage, HeadLineCBClickHdl ) ); 1499 1500 #ifndef SW_FILEFORMAT_40 1501 const SfxPoolItem *pItem; 1502 if(SFX_ITEM_SET == rSet.GetItemState( SID_HTML_MODE, sal_False,&pItem ) 1503 && ((const SfxUInt16Item*)pItem)->GetValue() & HTMLMODE_ON) 1504 #endif 1505 { 1506 aKeepCB.Hide(); 1507 aSplitCB.Hide(); 1508 aSplitRowCB.Hide(); 1509 } 1510 1511 aRepeatHeaderCombo.Arrange( aRepeatHeaderFT ); 1512 1513 HeadLineCBClickHdl(); 1514 } 1515 1516 /*-----------------12.12.96 12.22------------------- 1517 --------------------------------------------------*/ 1518 SwTextFlowPage::~SwTextFlowPage() 1519 { 1520 } 1521 1522 /*-----------------12.12.96 12.22------------------- 1523 --------------------------------------------------*/ 1524 SfxTabPage* SwTextFlowPage::Create( Window* pParent, 1525 const SfxItemSet& rAttrSet) 1526 { 1527 return new SwTextFlowPage(pParent, rAttrSet); 1528 } 1529 1530 /*-----------------12.12.96 12.22------------------- 1531 --------------------------------------------------*/ 1532 sal_Bool SwTextFlowPage::FillItemSet( SfxItemSet& rSet ) 1533 { 1534 sal_Bool bModified = sal_False; 1535 1536 //Ueberschrift wiederholen 1537 if(aHeadLineCB.IsChecked() != aHeadLineCB.GetSavedValue() || 1538 String::CreateFromInt32( static_cast< sal_Int32 >(aRepeatHeaderNF.GetValue()) ) != aRepeatHeaderNF.GetSavedValue() ) 1539 { 1540 bModified |= 0 != rSet.Put( 1541 SfxUInt16Item(FN_PARAM_TABLE_HEADLINE, aHeadLineCB.IsChecked()? sal_uInt16(aRepeatHeaderNF.GetValue()) : 0 )); 1542 } 1543 if(aKeepCB.IsChecked() != aKeepCB.GetSavedValue()) 1544 bModified |= 0 != rSet.Put( SvxFmtKeepItem( aKeepCB.IsChecked(), RES_KEEP)); 1545 1546 if(aSplitCB.IsChecked() != aSplitCB.GetSavedValue()) 1547 bModified |= 0 != rSet.Put( SwFmtLayoutSplit( aSplitCB.IsChecked())); 1548 1549 if(aSplitRowCB.IsChecked() != aSplitRowCB.GetSavedValue()) 1550 bModified |= 0 != rSet.Put( SwFmtRowSplit( aSplitRowCB.IsChecked())); 1551 1552 1553 const SvxFmtBreakItem* pBreak = (const SvxFmtBreakItem*)GetOldItem( rSet, RES_BREAK ); 1554 const SwFmtPageDesc* pDesc = (const SwFmtPageDesc*) GetOldItem( rSet, RES_PAGEDESC ); 1555 1556 1557 sal_Bool bState = aPageCollCB.IsChecked(); 1558 1559 //Wenn Seitenvorlage, dann kein Break 1560 sal_Bool bPageItemPut = sal_False; 1561 if ( bState != aPageCollCB.GetSavedValue() || 1562 ( bState && 1563 aPageCollLB.GetSelectEntryPos() != aPageCollLB.GetSavedValue() ) 1564 || (aPageNoNF.IsEnabled() && aPageNoNF.IsValueModified()) ) 1565 { 1566 String sPage; 1567 1568 if ( bState ) 1569 { 1570 sPage = aPageCollLB.GetSelectEntry(); 1571 } 1572 sal_uInt16 nPgNum = static_cast< sal_uInt16 >(aPageNoNF.GetValue()); 1573 if ( !pDesc || !pDesc->GetPageDesc() || 1574 ( pDesc->GetPageDesc() && ((pDesc->GetPageDesc()->GetName() != sPage) || 1575 aPageNoNF.GetSavedValue() != (String)nPgNum))) 1576 { 1577 SwFmtPageDesc aFmt( pShell->FindPageDescByName( sPage, sal_True ) ); 1578 aFmt.SetNumOffset(bState ? nPgNum : 0); 1579 bModified |= 0 != rSet.Put( aFmt ); 1580 bPageItemPut = bState; 1581 } 1582 } 1583 sal_Bool bIsChecked = aPgBrkCB.IsChecked(); 1584 if ( !bPageItemPut && 1585 ( bState != aPageCollCB.GetSavedValue() || 1586 bIsChecked != aPgBrkCB.GetSavedValue() || 1587 aPgBrkBeforeRB.IsChecked() != aPgBrkBeforeRB.GetSavedValue() || 1588 aPgBrkRB.IsChecked() != aPgBrkRB.GetSavedValue() )) 1589 { 1590 SvxFmtBreakItem aBreak( 1591 (const SvxFmtBreakItem&)GetItemSet().Get( RES_BREAK ) ); 1592 1593 if(bIsChecked) 1594 { 1595 sal_Bool bBefore = aPgBrkBeforeRB.IsChecked(); 1596 1597 if ( aPgBrkRB.IsChecked() ) 1598 { 1599 if ( bBefore ) 1600 aBreak.SetValue( SVX_BREAK_PAGE_BEFORE ); 1601 else 1602 aBreak.SetValue( SVX_BREAK_PAGE_AFTER ); 1603 } 1604 else 1605 { 1606 if ( bBefore ) 1607 aBreak.SetValue( SVX_BREAK_COLUMN_BEFORE ); 1608 else 1609 aBreak.SetValue( SVX_BREAK_COLUMN_AFTER ); 1610 } 1611 } 1612 else 1613 { 1614 aBreak.SetValue( SVX_BREAK_NONE ); 1615 } 1616 1617 if ( !pBreak || !( *(const SvxFmtBreakItem*)pBreak == aBreak ) ) 1618 { 1619 bModified |= 0 != rSet.Put( aBreak ); 1620 } 1621 } 1622 1623 if(aTextDirectionLB.GetSelectEntryPos() != aTextDirectionLB.GetSavedValue()) 1624 { 1625 bModified |= 0 != rSet.Put( 1626 SvxFrameDirectionItem( 1627 (SvxFrameDirection)(sal_uLong)aTextDirectionLB.GetEntryData(aTextDirectionLB.GetSelectEntryPos()) 1628 , FN_TABLE_BOX_TEXTDIRECTION)); 1629 } 1630 1631 if(aVertOrientLB.GetSelectEntryPos() != aVertOrientLB.GetSavedValue()) 1632 { 1633 sal_uInt16 nOrient = USHRT_MAX; 1634 switch(aVertOrientLB.GetSelectEntryPos()) 1635 { 1636 case 0 : nOrient = text::VertOrientation::NONE; break; 1637 case 1 : nOrient = text::VertOrientation::CENTER; break; 1638 case 2 : nOrient = text::VertOrientation::BOTTOM; break; 1639 } 1640 if(nOrient != USHRT_MAX) 1641 bModified |= 0 != rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, nOrient)); 1642 } 1643 1644 return bModified; 1645 1646 } 1647 1648 /*-----------------12.12.96 12.22------------------- 1649 --------------------------------------------------*/ 1650 void SwTextFlowPage::Reset( const SfxItemSet& rSet ) 1651 { 1652 const SfxPoolItem* pItem; 1653 SvxHtmlOptions* pHtmlOpt = SvxHtmlOptions::Get(); 1654 sal_Bool bFlowAllowed = !bHtmlMode || pHtmlOpt->IsPrintLayoutExtension(); 1655 if(bFlowAllowed) 1656 { 1657 // Einfuegen der vorhandenen Seitenvorlagen in die Listbox 1658 const sal_uInt16 nCount = pShell->GetPageDescCnt(); 1659 sal_uInt16 i; 1660 1661 for( i = 0; i < nCount; ++i) 1662 { 1663 const SwPageDesc &rPageDesc = pShell->GetPageDesc(i); 1664 aPageCollLB.InsertEntry(rPageDesc.GetName()); 1665 } 1666 1667 String aFmtName; 1668 for(i = RES_POOLPAGE_BEGIN; i < RES_POOLPAGE_END; ++i) 1669 if( LISTBOX_ENTRY_NOTFOUND == aPageCollLB.GetEntryPos( 1670 aFmtName = SwStyleNameMapper::GetUIName( i, aFmtName ) )) 1671 aPageCollLB.InsertEntry( aFmtName ); 1672 1673 if(SFX_ITEM_SET == rSet.GetItemState( RES_KEEP, sal_False, &pItem )) 1674 { 1675 aKeepCB.Check( ((const SvxFmtKeepItem*)pItem)->GetValue() ); 1676 aKeepCB.SaveValue(); 1677 } 1678 if(SFX_ITEM_SET == rSet.GetItemState( RES_LAYOUT_SPLIT, sal_False, &pItem )) 1679 { 1680 aSplitCB.Check( ((const SwFmtLayoutSplit*)pItem)->GetValue() ); 1681 } 1682 else 1683 aSplitCB.Check(); 1684 1685 aSplitCB.SaveValue(); 1686 SplitHdl_Impl(&aSplitCB); 1687 1688 if(SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, sal_False, &pItem )) 1689 { 1690 aSplitRowCB.Check( ((const SwFmtRowSplit*)pItem)->GetValue() ); 1691 } 1692 else 1693 aSplitRowCB.SetState(STATE_DONTKNOW); 1694 aSplitRowCB.SaveValue(); 1695 1696 if(bPageBreak) 1697 { 1698 if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_False, &pItem )) 1699 { 1700 String sPageDesc; 1701 const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc(); 1702 aPageNoNF.SetValue(((const SwFmtPageDesc*)pItem)->GetNumOffset()); 1703 if(pDesc) 1704 sPageDesc = pDesc->GetName(); 1705 if ( sPageDesc.Len() && 1706 aPageCollLB.GetEntryPos( sPageDesc ) != LISTBOX_ENTRY_NOTFOUND ) 1707 { 1708 aPageCollLB.SelectEntry( sPageDesc ); 1709 aPageCollCB.Check(); 1710 1711 aPgBrkCB.Enable(); 1712 aPgBrkRB.Enable(); 1713 aColBrkRB.Enable(); 1714 aPgBrkBeforeRB.Enable(); 1715 aPgBrkAfterRB.Enable(); 1716 aPageCollCB.Enable(); 1717 aPgBrkCB.Check(); 1718 1719 aPgBrkCB.Check( sal_True ); 1720 aColBrkRB.Check( sal_False ); 1721 aPgBrkBeforeRB.Check( sal_True ); 1722 aPgBrkAfterRB.Check( sal_False ); 1723 } 1724 else 1725 { 1726 aPageCollLB.SetNoSelection(); 1727 aPageCollCB.Check(sal_False); 1728 } 1729 } 1730 1731 if(SFX_ITEM_SET == rSet.GetItemState( RES_BREAK, sal_False, &pItem )) 1732 { 1733 const SvxFmtBreakItem* pPageBreak = (const SvxFmtBreakItem*)pItem; 1734 SvxBreak eBreak = (SvxBreak)pPageBreak->GetValue(); 1735 1736 if ( eBreak != SVX_BREAK_NONE ) 1737 { 1738 aPgBrkCB.Check(); 1739 aPageCollCB.Enable(sal_False); 1740 aPageCollLB.Enable(sal_False); 1741 aPageNoFT.Enable(sal_False); 1742 aPageNoNF.Enable(sal_False); 1743 } 1744 switch ( eBreak ) 1745 { 1746 case SVX_BREAK_PAGE_BEFORE: 1747 aPgBrkRB.Check( sal_True ); 1748 aColBrkRB.Check( sal_False ); 1749 aPgBrkBeforeRB.Check( sal_True ); 1750 aPgBrkAfterRB.Check( sal_False ); 1751 break; 1752 case SVX_BREAK_PAGE_AFTER: 1753 aPgBrkRB.Check( sal_True ); 1754 aColBrkRB.Check( sal_False ); 1755 aPgBrkBeforeRB.Check( sal_False ); 1756 aPgBrkAfterRB.Check( sal_True ); 1757 break; 1758 case SVX_BREAK_COLUMN_BEFORE: 1759 aPgBrkRB.Check( sal_False ); 1760 aColBrkRB.Check( sal_True ); 1761 aPgBrkBeforeRB.Check( sal_True ); 1762 aPgBrkAfterRB.Check( sal_False ); 1763 break; 1764 case SVX_BREAK_COLUMN_AFTER: 1765 aPgBrkRB.Check( sal_False ); 1766 aColBrkRB.Check( sal_True ); 1767 aPgBrkBeforeRB.Check( sal_False ); 1768 aPgBrkAfterRB.Check( sal_True ); 1769 break; 1770 default:; //prevent warning 1771 } 1772 1773 } 1774 if ( aPgBrkBeforeRB.IsChecked() ) 1775 PageBreakPosHdl_Impl( &aPgBrkBeforeRB ); 1776 else if ( aPgBrkAfterRB.IsChecked() ) 1777 PageBreakPosHdl_Impl( &aPgBrkAfterRB ); 1778 PageBreakHdl_Impl( &aPgBrkCB ); 1779 } 1780 } 1781 else 1782 { 1783 aPgBrkRB.Enable(sal_False); 1784 aColBrkRB.Enable(sal_False); 1785 aPgBrkBeforeRB.Enable(sal_False); 1786 aPgBrkAfterRB.Enable(sal_False); 1787 aKeepCB .Enable(sal_False); 1788 aSplitCB.Enable(sal_False); 1789 aPgBrkCB.Enable(sal_False); 1790 aPageCollCB.Enable(sal_False); 1791 aPageCollLB.Enable(sal_False); 1792 } 1793 1794 if(SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, sal_False, &pItem )) 1795 { 1796 sal_uInt16 nRep = ((const SfxUInt16Item*)pItem)->GetValue(); 1797 aHeadLineCB.Check( nRep > 0 ); 1798 aHeadLineCB.SaveValue(); 1799 aRepeatHeaderNF.SetValue( nRep ); 1800 aRepeatHeaderNF.SaveValue(); 1801 } 1802 if ( rSet.GetItemState(FN_TABLE_BOX_TEXTDIRECTION) > SFX_ITEM_AVAILABLE ) 1803 { 1804 sal_uLong nDirection = ((const SvxFrameDirectionItem&)rSet.Get(FN_TABLE_BOX_TEXTDIRECTION)).GetValue(); 1805 aTextDirectionLB.SelectEntryPos(aTextDirectionLB.GetEntryPos( (const void*)nDirection )); 1806 } 1807 1808 if ( rSet.GetItemState(FN_TABLE_SET_VERT_ALIGN) > SFX_ITEM_AVAILABLE ) 1809 { 1810 sal_uInt16 nVert = ((const SfxUInt16Item&)rSet.Get(FN_TABLE_SET_VERT_ALIGN)).GetValue(); 1811 sal_uInt16 nPos = 0; 1812 switch(nVert) 1813 { 1814 case text::VertOrientation::NONE: nPos = 0; break; 1815 case text::VertOrientation::CENTER: nPos = 1; break; 1816 case text::VertOrientation::BOTTOM: nPos = 2; break; 1817 } 1818 aVertOrientLB.SelectEntryPos(nPos); 1819 } 1820 1821 aPageCollCB.SaveValue(); 1822 aPageCollLB.SaveValue(); 1823 aPgBrkCB.SaveValue(); 1824 aPgBrkRB.SaveValue(); 1825 aColBrkRB.SaveValue(); 1826 aPgBrkBeforeRB.SaveValue(); 1827 aPgBrkAfterRB.SaveValue(); 1828 aPageNoNF.SaveValue(); 1829 aTextDirectionLB.SaveValue(); 1830 aVertOrientLB.SaveValue(); 1831 1832 HeadLineCBClickHdl(); 1833 } 1834 /*-----------------16.04.98 14:48------------------- 1835 1836 --------------------------------------------------*/ 1837 1838 void SwTextFlowPage::SetShell(SwWrtShell* pSh) 1839 { 1840 pShell = pSh; 1841 bHtmlMode = 0 != (::GetHtmlMode(pShell->GetView().GetDocShell()) & HTMLMODE_ON); 1842 if(bHtmlMode) 1843 { 1844 aPageNoNF.Enable(sal_False); 1845 aPageNoFT.Enable(sal_False); 1846 } 1847 } 1848 1849 /*-----------------12.12.96 16.18------------------- 1850 --------------------------------------------------*/ 1851 IMPL_LINK( SwTextFlowPage, PageBreakHdl_Impl, CheckBox*, EMPTYARG ) 1852 { 1853 if( aPgBrkCB.IsChecked() ) 1854 { 1855 aPgBrkRB. Enable(); 1856 aColBrkRB. Enable(); 1857 aPgBrkBeforeRB. Enable(); 1858 aPgBrkAfterRB. Enable(); 1859 1860 if ( aPgBrkRB.IsChecked() && aPgBrkBeforeRB.IsChecked() ) 1861 { 1862 aPageCollCB.Enable(); 1863 1864 sal_Bool bEnable = aPageCollCB.IsChecked() && 1865 aPageCollLB.GetEntryCount(); 1866 aPageCollLB.Enable(bEnable); 1867 if(!bHtmlMode) 1868 { 1869 aPageNoFT.Enable(bEnable); 1870 aPageNoNF.Enable(bEnable); 1871 } 1872 } 1873 } 1874 else 1875 { 1876 aPageCollCB.Check( sal_False ); 1877 aPageCollCB.Enable(sal_False); 1878 aPageCollLB.Enable(sal_False); 1879 aPageNoFT.Enable(sal_False); 1880 aPageNoNF.Enable(sal_False); 1881 aPgBrkRB. Enable(sal_False); 1882 aColBrkRB. Enable(sal_False); 1883 aPgBrkBeforeRB. Enable(sal_False); 1884 aPgBrkAfterRB. Enable(sal_False); 1885 } 1886 return 0; 1887 } 1888 1889 /*-----------------12.12.96 16.18------------------- 1890 --------------------------------------------------*/ 1891 IMPL_LINK( SwTextFlowPage, ApplyCollClickHdl_Impl, CheckBox*, EMPTYARG ) 1892 { 1893 sal_Bool bEnable = sal_False; 1894 if ( aPageCollCB.IsChecked() && 1895 aPageCollLB.GetEntryCount() ) 1896 { 1897 bEnable = sal_True; 1898 aPageCollLB.SelectEntryPos( 0 ); 1899 } 1900 else 1901 { 1902 aPageCollLB.SetNoSelection(); 1903 } 1904 aPageCollLB.Enable(bEnable); 1905 if(!bHtmlMode) 1906 { 1907 aPageNoFT.Enable(bEnable); 1908 aPageNoNF.Enable(bEnable); 1909 } 1910 return 0; 1911 } 1912 1913 /*-----------------12.12.96 16.18------------------- 1914 --------------------------------------------------*/ 1915 IMPL_LINK( SwTextFlowPage, PageBreakPosHdl_Impl, RadioButton*, pBtn ) 1916 { 1917 if ( aPgBrkCB.IsChecked() ) 1918 { 1919 if ( pBtn == &aPgBrkBeforeRB && aPgBrkRB.IsChecked() ) 1920 { 1921 aPageCollCB.Enable(); 1922 1923 sal_Bool bEnable = aPageCollCB.IsChecked() && 1924 aPageCollLB.GetEntryCount(); 1925 1926 aPageCollLB.Enable(bEnable); 1927 if(!bHtmlMode) 1928 { 1929 aPageNoFT.Enable(bEnable); 1930 aPageNoNF.Enable(bEnable); 1931 } 1932 } 1933 else if ( pBtn == &aPgBrkAfterRB ) 1934 { 1935 aPageCollCB .Check( sal_False ); 1936 aPageCollCB .Enable(sal_False); 1937 aPageCollLB .Enable(sal_False); 1938 aPageNoFT .Enable(sal_False); 1939 aPageNoNF .Enable(sal_False); 1940 } 1941 } 1942 return 0; 1943 } 1944 1945 /*-----------------12.12.96 16.18------------------- 1946 --------------------------------------------------*/ 1947 IMPL_LINK( SwTextFlowPage, PageBreakTypeHdl_Impl, RadioButton*, pBtn ) 1948 { 1949 if ( pBtn == &aColBrkRB || aPgBrkAfterRB.IsChecked() ) 1950 { 1951 aPageCollCB .Check(sal_False); 1952 aPageCollCB .Enable(sal_False); 1953 aPageCollLB .Enable(sal_False); 1954 aPageNoFT .Enable(sal_False); 1955 aPageNoNF .Enable(sal_False); 1956 } 1957 else if ( aPgBrkBeforeRB.IsChecked() ) 1958 PageBreakPosHdl_Impl( &aPgBrkBeforeRB ); 1959 return 0; 1960 } 1961 /*-----------------17.11.2003 11:30----------------- 1962 * 1963 * --------------------------------------------------*/ 1964 IMPL_LINK( SwTextFlowPage, SplitHdl_Impl, CheckBox*, pBox ) 1965 { 1966 aSplitRowCB.Enable(pBox->IsChecked()); 1967 return 0; 1968 } 1969 /*-----------------17.11.2003 11:30----------------- 1970 * 1971 * --------------------------------------------------*/ 1972 IMPL_LINK( SwTextFlowPage, SplitRowHdl_Impl, TriStateBox*, pBox ) 1973 { 1974 pBox->EnableTriState(sal_False); 1975 return 0; 1976 } 1977 1978 IMPL_LINK( SwTextFlowPage, HeadLineCBClickHdl, void*, EMPTYARG ) 1979 { 1980 aRepeatHeaderCombo.Enable(aHeadLineCB.IsChecked()); 1981 1982 return 0; 1983 } 1984 1985 /*-----------------30.05.97 07:37------------------- 1986 1987 --------------------------------------------------*/ 1988 void SwTextFlowPage::DisablePageBreak() 1989 { 1990 bPageBreak = sal_False; 1991 aPgBrkCB .Disable(); 1992 aPgBrkRB .Disable(); 1993 aColBrkRB .Disable(); 1994 aPgBrkBeforeRB .Disable(); 1995 aPgBrkAfterRB .Disable(); 1996 aPageCollCB .Disable(); 1997 aPageCollLB .Disable(); 1998 aPageNoFT .Disable(); 1999 aPageNoNF .Disable(); 2000 } 2001 2002 2003 2004