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