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 String sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH); 995 sColumnWidth.SearchAndReplace( DEFINE_CONST_UNICODE("%1"), sIndex ); 996 pFieldArr[i]->SetAccessibleName( sColumnWidth ); 997 //-----IAccessibility2 Impplementaton 2009 998 } 999 1000 aDownBtn.Enable(aValueTbl[0] > 0); 1001 aUpBtn.Enable(aValueTbl[ MET_FIELDS -1 ] < nNoOfVisibleCols -1 ); 1002 UpdateCols(0); 1003 return 0; 1004 }; 1005 1006 /*------------------------------------------------------------------------ 1007 ------------------------------------------------------------------------*/ 1008 IMPL_LINK_INLINE_START( SwTableColumnPage, UpHdl, PercentField *, pEdit ) 1009 { 1010 bModified = sal_True; 1011 ModifyHdl( pEdit ); 1012 return 0; 1013 }; 1014 IMPL_LINK_INLINE_END( SwTableColumnPage, UpHdl, PercentField *, pEdit ) 1015 1016 /*------------------------------------------------------------------------ 1017 ------------------------------------------------------------------------*/ 1018 IMPL_LINK_INLINE_START( SwTableColumnPage, DownHdl, PercentField *, pEdit ) 1019 { 1020 bModified = sal_True; 1021 ModifyHdl( pEdit ); 1022 return 0; 1023 }; 1024 IMPL_LINK_INLINE_END( SwTableColumnPage, DownHdl, PercentField *, pEdit ) 1025 1026 /*------------------------------------------------------------------------ 1027 ------------------------------------------------------------------------*/ 1028 IMPL_LINK_INLINE_START( SwTableColumnPage, LoseFocusHdl, PercentField *, pEdit ) 1029 { 1030 if(pEdit->IsModified()) 1031 { 1032 bModified = sal_True; 1033 ModifyHdl( pEdit ); 1034 } 1035 return 0; 1036 }; 1037 IMPL_LINK_INLINE_END( SwTableColumnPage, LoseFocusHdl, PercentField *, pEdit ) 1038 1039 /*------------------------------------------------------------------------ 1040 ------------------------------------------------------------------------*/ 1041 IMPL_LINK( SwTableColumnPage, ModeHdl, CheckBox*, pBox ) 1042 { 1043 sal_Bool bCheck = pBox->IsChecked(); 1044 if(pBox == &aProportionalCB) 1045 { 1046 if(bCheck) 1047 aModifyTableCB.Check(); 1048 aModifyTableCB.Enable(!bCheck && bModifyTbl); 1049 } 1050 return 0; 1051 }; 1052 1053 /*------------------------------------------------------------------------ 1054 ------------------------------------------------------------------------*/ 1055 sal_Bool SwTableColumnPage::FillItemSet( SfxItemSet& ) 1056 { 1057 for( sal_uInt16 i = 0; i < MET_FIELDS; i++ ) 1058 { 1059 if(pFieldArr[i]->HasFocus()) 1060 { 1061 LoseFocusHdl(pFieldArr[i]); 1062 break; 1063 } 1064 } 1065 1066 if(bModified) 1067 { 1068 pTblData->SetColsChanged(); 1069 } 1070 return bModified; 1071 }; 1072 1073 /*------------------------------------------------------------------------ 1074 ------------------------------------------------------------------------*/ 1075 void SwTableColumnPage::ModifyHdl( PercentField* pEdit ) 1076 { 1077 sal_uInt16 nAktPos; 1078 sal_uInt16 i; 1079 1080 for( i = 0; i < MET_FIELDS; i++) 1081 if(pEdit == pFieldArr[i]) 1082 break; 1083 1084 if (MET_FIELDS <= i) 1085 { 1086 OSL_ENSURE(false, "cannot happen."); 1087 return; 1088 } 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