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 #include "column.hxx" 32 33 #include "hintids.hxx" 34 #include <svx/htmlmode.hxx> 35 #include <editeng/borderline.hxx> 36 #include <editeng/boxitem.hxx> 37 #include <editeng/lrspitem.hxx> 38 #include <editeng/sizeitem.hxx> 39 #include "editeng/frmdiritem.hxx" 40 #include <svl/ctloptions.hxx> 41 #include <sfx2/dispatch.hxx> 42 #include <vcl/msgbox.hxx> 43 #include <swmodule.hxx> 44 45 #include <helpid.h> 46 #include "globals.hrc" 47 #include "swtypes.hxx" 48 #include "wrtsh.hxx" 49 #include "view.hxx" 50 #include "docsh.hxx" 51 #include "uitool.hxx" 52 #include "cmdid.h" 53 #include "viewopt.hxx" 54 #include "format.hxx" 55 #include "frmmgr.hxx" 56 #include "frmdlg.hxx" 57 #include "colmgr.hxx" 58 #include "prcntfld.hxx" 59 #include "paratr.hxx" 60 #include "frmui.hrc" 61 #include "poolfmt.hrc" 62 #include "column.hrc" 63 #include <section.hxx> 64 #include <docary.hxx> 65 #include <pagedesc.hxx> 66 67 #include "access.hrc" 68 69 #define FRAME_FORMAT_WIDTH 1000 70 71 // sw/inc/fmtclds.hxx 72 SV_IMPL_PTRARR( SwColumns, SwColumnPtr ) 73 74 /*-------------------------------------------------------------------- 75 Beschreibung: Statische Daten 76 --------------------------------------------------------------------*/ 77 78 static const sal_uInt16 __FAR_DATA nLines[] = { 79 DEF_LINE_WIDTH_0, 80 DEF_LINE_WIDTH_1, 81 DEF_LINE_WIDTH_2, 82 DEF_LINE_WIDTH_3, 83 DEF_LINE_WIDTH_4 84 }; 85 86 static const sal_uInt16 nLineCount = sizeof(nLines) / sizeof(nLines[0]); 87 static const sal_uInt16 nVisCols = 3; 88 89 inline sal_Bool IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect ) 90 { 91 rWrtSh.SwapPam(); 92 sal_Bool bRet = pSect == rWrtSh.GetCurrSection(); 93 rWrtSh.SwapPam(); 94 return bRet; 95 } 96 97 /*-------------------------------------------------------------------- 98 Beschreibung: 99 --------------------------------------------------------------------*/ 100 101 SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) : 102 SfxModalDialog(pParent, SW_RES(DLG_COLUMN)), 103 aOK(this, SW_RES(PB_OK)), 104 aCancel(this, SW_RES(PB_CANCEL)), 105 aHelp(this, SW_RES(PB_HELP)), 106 aApplyToFT(this, SW_RES(FT_APPLY_TO)), 107 aApplyToLB(this, SW_RES(LB_APPLY_TO)), 108 rWrtShell(rSh), 109 pPageSet(0), 110 pSectionSet(0), 111 pSelectionSet(0), 112 pFrameSet(0), 113 nOldSelection(0), 114 nSelectionWidth(0), 115 bPageChanged(sal_False), 116 bSectionChanged(sal_False), 117 bSelSectionChanged(sal_False), 118 bFrameChanged(sal_False) 119 { 120 FreeResource(); 121 122 SwRect aRect; 123 rWrtShell.CalcBoundRect(aRect, FLY_AS_CHAR); 124 125 nSelectionWidth = aRect.Width(); 126 127 SfxItemSet* pColPgSet = 0; 128 static sal_uInt16 __READONLY_DATA aSectIds[] = { RES_COL, RES_COL, 129 RES_FRM_SIZE, RES_FRM_SIZE, 130 RES_COLUMNBALANCE, RES_FRAMEDIR, 131 0 }; 132 133 const SwSection* pCurrSection = rWrtShell.GetCurrSection(); 134 sal_uInt16 nFullSectCnt = rWrtShell.GetFullSelectedSectionCount(); 135 if( pCurrSection && ( !rWrtShell.HasSelection() || 0 != nFullSectCnt )) 136 { 137 nSelectionWidth = rSh.GetSectionWidth(*pCurrSection->GetFmt()); 138 if ( !nSelectionWidth ) 139 nSelectionWidth = USHRT_MAX; 140 pSectionSet = new SfxItemSet( rWrtShell.GetAttrPool(), aSectIds ); 141 pSectionSet->Put( pCurrSection->GetFmt()->GetAttrSet() ); 142 pColPgSet = pSectionSet; 143 aApplyToLB.RemoveEntry( aApplyToLB.GetEntryPos( 144 (void*)( 1 >= nFullSectCnt 145 ? LISTBOX_SECTIONS 146 : LISTBOX_SECTION ))); 147 } 148 else 149 { 150 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_SECTION )); 151 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_SECTIONS )); 152 } 153 154 if( rWrtShell.HasSelection() && rWrtShell.IsInsRegionAvailable() && 155 ( !pCurrSection || ( 1 != nFullSectCnt && 156 IsMarkInSameSection( rWrtShell, pCurrSection ) ))) 157 { 158 pSelectionSet = new SfxItemSet( rWrtShell.GetAttrPool(), aSectIds ); 159 pColPgSet = pSelectionSet; 160 } 161 else 162 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_SELECTION )); 163 164 if( rWrtShell.GetFlyFrmFmt() ) 165 { 166 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ; 167 pFrameSet = new SfxItemSet(rWrtShell.GetAttrPool(), aSectIds ); 168 pFrameSet->Put(pFmt->GetFrmSize()); 169 pFrameSet->Put(pFmt->GetCol()); 170 pColPgSet = pFrameSet; 171 } 172 else 173 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_FRAME )); 174 175 176 sal_uInt16 nPagePos = aApplyToLB.GetEntryPos( (void*) LISTBOX_PAGE ); 177 const SwPageDesc* pPageDesc = rWrtShell.GetSelectedPageDescs(); 178 if( pPageDesc ) 179 { 180 pPageSet = new SfxItemSet( rWrtShell.GetAttrPool(), 181 RES_COL, RES_COL, 182 RES_FRM_SIZE, RES_FRM_SIZE, 183 RES_LR_SPACE, RES_LR_SPACE, 184 0 ); 185 186 String sPageStr = aApplyToLB.GetEntry(nPagePos); 187 aApplyToLB.RemoveEntry( nPagePos ); 188 sPageStr += pPageDesc->GetName(); 189 aApplyToLB.InsertEntry( sPageStr, nPagePos ); 190 aApplyToLB.SetEntryData( nPagePos, (void*) LISTBOX_PAGE); 191 192 const SwFrmFmt &rFmt = pPageDesc->GetMaster(); 193 nPageWidth = rFmt.GetFrmSize().GetSize().Width(); 194 195 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rFmt.GetLRSpace(); 196 const SvxBoxItem& rBox = (const SvxBoxItem&) rFmt.GetBox(); 197 nPageWidth -= rLRSpace.GetLeft() + rLRSpace.GetRight() + rBox.GetDistance(); 198 199 pPageSet->Put(rFmt.GetCol()); 200 pPageSet->Put(rFmt.GetLRSpace()); 201 pColPgSet = pPageSet; 202 } 203 else 204 aApplyToLB.RemoveEntry( nPagePos ); 205 206 207 ASSERT( pColPgSet, "" ); 208 // TabPage erzeugen 209 SwColumnPage* pPage = (SwColumnPage*) SwColumnPage::Create( this, 210 *pColPgSet ); 211 pTabPage = pPage; 212 213 //Groesse anpassen 214 Size aPageSize(pTabPage->GetSizePixel()); 215 Size aDlgSize(GetOutputSizePixel()); 216 aDlgSize.Height() = aPageSize.Height(); 217 SetOutputSizePixel(aDlgSize); 218 pTabPage->Show(); 219 220 aApplyToLB.SelectEntryPos(0); 221 ObjectHdl(0); 222 223 aApplyToLB.SetSelectHdl(LINK(this, SwColumnDlg, ObjectHdl)); 224 aOK.SetClickHdl(LINK(this, SwColumnDlg, OkHdl)); 225 //#i80458# if no columns can be set then disable OK 226 if( !aApplyToLB.GetEntryCount() ) 227 aOK.Enable( sal_False ); 228 //#i97810# set focus to the TabPage 229 pTabPage->ActivateColumnControl(); 230 } 231 232 /*-------------------------------------------------------------------- 233 Beschreibung: 234 --------------------------------------------------------------------*/ 235 236 SwColumnDlg::~SwColumnDlg() 237 { 238 delete pTabPage; 239 delete pPageSet; 240 delete pSectionSet; 241 delete pSelectionSet; 242 } 243 244 /* -----------------26.05.99 11:40------------------- 245 * 246 * --------------------------------------------------*/ 247 IMPL_LINK(SwColumnDlg, ObjectHdl, ListBox*, pBox) 248 { 249 SfxItemSet* pSet = 0; 250 switch(nOldSelection) 251 { 252 case LISTBOX_SELECTION : 253 pSet = pSelectionSet; 254 break; 255 case LISTBOX_SECTION : 256 pSet = pSectionSet; 257 bSectionChanged = sal_True; 258 break; 259 case LISTBOX_SECTIONS : 260 pSet = pSectionSet; 261 bSelSectionChanged = sal_True; 262 break; 263 case LISTBOX_PAGE : 264 pSet = pPageSet; 265 bPageChanged = sal_True; 266 break; 267 case LISTBOX_FRAME: 268 pSet = pFrameSet; 269 bFrameChanged = sal_True; 270 break; 271 } 272 if(pBox) 273 { 274 pTabPage->FillItemSet(*pSet); 275 } 276 nOldSelection = (long)aApplyToLB.GetEntryData(aApplyToLB.GetSelectEntryPos()); 277 long nWidth = nSelectionWidth; 278 switch(nOldSelection) 279 { 280 case LISTBOX_SELECTION : 281 pSet = pSelectionSet; 282 if( pSelectionSet ) 283 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth)); 284 break; 285 case LISTBOX_SECTION : 286 case LISTBOX_SECTIONS : 287 pSet = pSectionSet; 288 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth)); 289 break; 290 case LISTBOX_PAGE : 291 nWidth = nPageWidth; 292 pSet = pPageSet; 293 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth)); 294 break; 295 case LISTBOX_FRAME: 296 pSet = pFrameSet; 297 break; 298 } 299 300 sal_Bool bIsSection = pSet == pSectionSet || pSet == pSelectionSet; 301 pTabPage->ShowBalance(bIsSection); 302 pTabPage->SetInSection(bIsSection); 303 pTabPage->SetFrmMode(sal_True); 304 pTabPage->SetPageWidth(nWidth); 305 if( pSet ) 306 pTabPage->Reset(*pSet); 307 return 0; 308 } 309 /* -----------------26.05.99 12:32------------------- 310 * 311 * --------------------------------------------------*/ 312 IMPL_LINK(SwColumnDlg, OkHdl, OKButton*, EMPTYARG) 313 { 314 //aktuelle Selektion auswerten 315 SfxItemSet* pSet = 0; 316 switch(nOldSelection) 317 { 318 case LISTBOX_SELECTION : 319 pSet = pSelectionSet; 320 break; 321 case LISTBOX_SECTION : 322 pSet = pSectionSet; 323 bSectionChanged = sal_True; 324 break; 325 case LISTBOX_SECTIONS : 326 pSet = pSectionSet; 327 bSelSectionChanged = sal_True; 328 break; 329 case LISTBOX_PAGE : 330 pSet = pPageSet; 331 bPageChanged = sal_True; 332 break; 333 case LISTBOX_FRAME: 334 pSet = pFrameSet; 335 bFrameChanged = sal_True; 336 break; 337 } 338 pTabPage->FillItemSet(*pSet); 339 340 if(pSelectionSet && SFX_ITEM_SET == pSelectionSet->GetItemState(RES_COL)) 341 { 342 //Bereich mit Spalten einfuegen 343 const SwFmtCol& rColItem = (const SwFmtCol&)pSelectionSet->Get(RES_COL); 344 //nur, wenn es auch Spalten gibt! 345 if(rColItem.GetNumCols() > 1) 346 rWrtShell.GetView().GetViewFrame()->GetDispatcher()->Execute( 347 FN_INSERT_REGION, SFX_CALLMODE_ASYNCHRON, *pSelectionSet ); 348 } 349 350 if(pSectionSet && pSectionSet->Count() && bSectionChanged ) 351 { 352 const SwSection* pCurrSection = rWrtShell.GetCurrSection(); 353 const SwSectionFmt* pFmt = pCurrSection->GetFmt(); 354 sal_uInt16 nNewPos = rWrtShell.GetSectionFmtPos( *pFmt ); 355 SwSectionData aData(*pCurrSection); 356 rWrtShell.UpdateSection( nNewPos, aData, pSectionSet ); 357 } 358 359 if(pSectionSet && pSectionSet->Count() && bSelSectionChanged ) 360 { 361 rWrtShell.SetSectionAttr( *pSectionSet ); 362 } 363 364 if(pPageSet && SFX_ITEM_SET == pPageSet->GetItemState(RES_COL) && bPageChanged) 365 { 366 // aktuellen PageDescriptor ermitteln und damit den Set fuellen 367 const sal_uInt16 nCurIdx = rWrtShell.GetCurPageDesc(); 368 SwPageDesc aPageDesc(rWrtShell.GetPageDesc(nCurIdx)); 369 SwFrmFmt &rFmt = aPageDesc.GetMaster(); 370 rFmt.SetFmtAttr(pPageSet->Get(RES_COL)); 371 rWrtShell.ChgPageDesc(nCurIdx, aPageDesc); 372 } 373 if(pFrameSet && SFX_ITEM_SET == pFrameSet->GetItemState(RES_COL) && bFrameChanged) 374 { 375 SfxItemSet aTmp(*pFrameSet->GetPool(), RES_COL, RES_COL); 376 aTmp.Put(*pFrameSet); 377 rWrtShell.StartAction(); 378 rWrtShell.Push(); 379 rWrtShell.SetFlyFrmAttr( aTmp ); 380 //die Rahmenselektion wieder aufheben 381 if(rWrtShell.IsFrmSelected()) 382 { 383 rWrtShell.UnSelectFrm(); 384 rWrtShell.LeaveSelFrmMode(); 385 } 386 rWrtShell.Pop(); 387 rWrtShell.EndAction(); 388 } 389 EndDialog(RET_OK); 390 return 0; 391 } 392 393 /*-------------------------------------------------------------------- 394 Beschreibung: 395 --------------------------------------------------------------------*/ 396 397 #if OSL_DEBUG_LEVEL < 2 398 inline 399 #endif 400 sal_uInt16 GetMaxWidth( SwColMgr* pColMgr, sal_uInt16 nCols ) 401 { 402 sal_uInt16 nMax = pColMgr->GetActualSize(); 403 if( --nCols ) 404 nMax -= pColMgr->GetGutterWidth() * nCols; 405 return nMax; 406 } 407 408 static sal_uInt16 __FAR_DATA aPageRg[] = { 409 RES_COL, RES_COL, 410 0 411 }; 412 413 414 DBG_NAME(columnhdl) 415 416 417 418 sal_uInt16 lcl_LineWidthToPos(sal_uLong nWidth) 419 { 420 const sal_uInt16 nUShortWidth = (sal_uInt16)nWidth; 421 for(sal_uInt16 i = 0; i < nLineCount; ++i) 422 if(nUShortWidth == nLines[i]) 423 return i; 424 return 0; 425 } 426 427 428 429 void SwColumnPage::ResetColWidth() 430 { 431 if( nCols ) 432 { 433 sal_uInt16 nWidth = GetMaxWidth( pColMgr, nCols ); 434 nWidth = nWidth / nCols; 435 436 for(sal_uInt16 i = 0; i < nCols; ++i) 437 nColWidth[i] = (long) nWidth; 438 } 439 440 } 441 442 /*-------------------------------------------------------------------- 443 Beschreibung: Jetzt als TabPage 444 --------------------------------------------------------------------*/ 445 446 447 448 SwColumnPage::SwColumnPage(Window *pParent, const SfxItemSet &rSet) 449 450 : SfxTabPage(pParent, SW_RES(TP_COLUMN), rSet), 451 452 aFLGroup(this, SW_RES(FL_COLUMNS )), 453 aClNrLbl(this, SW_RES(FT_NUMBER )), 454 aCLNrEdt(this, SW_RES(ED_NUMBER )), 455 aDefaultVS(this, SW_RES(VS_DEFAULTS)), 456 aBalanceColsCB(this, SW_RES(CB_BALANCECOLS)), 457 458 aFLLayout(this, SW_RES(FL_LAYOUT)), 459 aBtnUp(this, SW_RES(BTN_DOWN)), 460 aColumnFT(this, SW_RES(FT_COLUMN)), 461 aWidthFT(this, SW_RES(FT_WIDTH)), 462 aDistFT(this, SW_RES(FT_DIST)), 463 aLbl1(this, SW_RES(FT_1)), 464 aEd1(this, SW_RES(ED_1)), 465 aDistEd1(this, SW_RES(ED_DIST1)), 466 aLbl2(this, SW_RES(FT_2)), 467 aEd2(this, SW_RES(ED_2)), 468 aDistEd2(this, SW_RES(ED_DIST2)), 469 aLbl3(this, SW_RES(FT_3)), 470 aEd3(this, SW_RES(ED_3)), 471 aBtnDown(this, SW_RES(BTN_UP)), 472 aAutoWidthBox(this, SW_RES(CB_AUTO_WIDTH)), 473 474 aFLLineType(this, SW_RES(FL_LINETYPE)), 475 aLineTypeLbl(this, SW_RES(FT_STYLE)), 476 aLineTypeDLB(this, SW_RES(LB_STYLE)), 477 aLineHeightLbl(this, SW_RES(FT_HEIGHT)), 478 aLineHeightEdit(this, SW_RES(ED_HEIGHT)), 479 aLinePosLbl(this, SW_RES(FT_POSITION)), 480 aLinePosDLB(this, SW_RES(LB_POSITION)), 481 482 aVertFL(this, SW_RES(FL_VERT)), 483 aPropertiesFL( this, SW_RES( FL_PROPERTIES )), 484 aTextDirectionFT( this, SW_RES( FT_TEXTDIRECTION )), 485 aTextDirectionLB( this, SW_RES( LB_TEXTDIRECTION )), 486 487 aPgeExampleWN(this, SW_RES(WN_BSP)), 488 aFrmExampleWN(this, SW_RES(WN_BSP)), 489 490 pColMgr(0), 491 492 nFirstVis(0), 493 nMinWidth(MINLAY), 494 pModifiedField(0), 495 bFormat(sal_False), 496 bFrm(sal_False), 497 bHtmlMode(sal_False), 498 bLockUpdate(sal_False) 499 { 500 sal_uInt16 i; 501 502 FreeResource(); 503 SetExchangeSupport(); 504 505 aBtnDown.SetAccessibleRelationMemberOf(&aFLLayout); 506 aEd1.SetAccessibleRelationLabeledBy(&aWidthFT); 507 aEd2.SetAccessibleRelationLabeledBy(&aWidthFT); 508 aEd3.SetAccessibleRelationLabeledBy(&aWidthFT); 509 aDistEd1.SetAccessibleRelationLabeledBy(&aDistFT); 510 aDistEd2.SetAccessibleRelationLabeledBy(&aDistFT); 511 aBtnUp.SetAccessibleRelationLabeledBy(&aColumnFT); 512 aBtnDown.SetAccessibleRelationLabeledBy(&aColumnFT); 513 514 aDefaultVS.SetHelpId(HID_COLUMN_VALUESET); 515 aDefaultVS.SetColCount( 5 ); 516 aDefaultVS.SetStyle( aDefaultVS.GetStyle() 517 | WB_ITEMBORDER 518 | WB_DOUBLEBORDER ); 519 520 //IAccessibility2 Impplementaton 2009----- 521 for( i = 0; i < 5; i++) 522 //Solution:Set accessible name one be one 523 //aDefaultVS.InsertItem( i + 1, i ); 524 { 525 String aItemText; 526 switch( i ) 527 { 528 case 0: 529 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM0 ) ; 530 break; 531 case 1: 532 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM1 ) ; 533 break; 534 case 2: 535 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM2 ) ; 536 break; 537 case 3: 538 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM3 ); 539 break; 540 case 4: 541 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM4 ); 542 break; 543 default: 544 break; 545 } 546 aDefaultVS.InsertItem( i + 1, aItemText, i ); 547 } 548 //-----IAccessibility2 Impplementaton 2009 549 550 aDefaultVS.SetSelectHdl(LINK(this, SwColumnPage, SetDefaultsHdl)); 551 552 // Controls fuer Zusaetzebereich beim MoreButton anmelden 553 Link aCLNrLk = LINK(this, SwColumnPage, ColModify); 554 aCLNrEdt.SetLoseFocusHdl(aCLNrLk); 555 aCLNrEdt.SetUpHdl(aCLNrLk); 556 aCLNrEdt.SetDownHdl(aCLNrLk); 557 Link aLk = LINK(this, SwColumnPage, GapModify); 558 aDistEd1.SetUpHdl(aLk); 559 aDistEd1.SetDownHdl(aLk); 560 aDistEd1.SetLoseFocusHdl(aLk); 561 aDistEd2.SetUpHdl(aLk); 562 aDistEd2.SetDownHdl(aLk); 563 aDistEd2.SetLoseFocusHdl(aLk); 564 565 aLk = LINK(this, SwColumnPage, EdModify); 566 567 aEd1.SetUpHdl(aLk); 568 aEd1.SetDownHdl(aLk); 569 aEd1.SetLoseFocusHdl(aLk); 570 571 aEd2.SetUpHdl(aLk); 572 aEd2.SetDownHdl(aLk); 573 aEd2.SetLoseFocusHdl(aLk); 574 575 aEd3.SetUpHdl(aLk); 576 aEd3.SetDownHdl(aLk); 577 aEd3.SetLoseFocusHdl(aLk); 578 579 aBtnUp.SetClickHdl(LINK(this, SwColumnPage, Up)); 580 aBtnDown.SetClickHdl(LINK(this, SwColumnPage, Down)); 581 aAutoWidthBox.SetClickHdl(LINK(this, SwColumnPage, AutoWidthHdl)); 582 583 aLk = LINK( this, SwColumnPage, UpdateColMgr ); 584 aLineTypeDLB.SetSelectHdl( aLk ); 585 aLineHeightEdit.SetModifyHdl( aLk ); 586 aLinePosDLB.SetSelectHdl( aLk ); 587 588 // Trennlinie 589 aLineTypeDLB.SetUnit( FUNIT_POINT ); 590 aLineTypeDLB.SetSourceUnit( FUNIT_TWIP ); 591 for( i = 0; i < nLineCount; ++i ) 592 aLineTypeDLB.InsertEntry( 100 * nLines[ i ] ); 593 } 594 595 596 597 SwColumnPage::~SwColumnPage() 598 { 599 delete pColMgr; 600 } 601 602 /*-------------------------------------------------------------------- 603 Beschreibung: 604 --------------------------------------------------------------------*/ 605 606 607 void SwColumnPage::SetPageWidth(long nPageWidth) 608 { 609 long nNewMaxWidth = static_cast< long >(aEd1.NormalizePercent(nPageWidth)); 610 611 aDistEd1.SetMax(nNewMaxWidth, FUNIT_TWIP); 612 aDistEd2.SetMax(nNewMaxWidth, FUNIT_TWIP); 613 aEd1.SetMax(nNewMaxWidth, FUNIT_TWIP); 614 aEd2.SetMax(nNewMaxWidth, FUNIT_TWIP); 615 aEd3.SetMax(nNewMaxWidth, FUNIT_TWIP); 616 } 617 618 /*-------------------------------------------------------------------- 619 Beschreibung: 620 --------------------------------------------------------------------*/ 621 622 623 624 void SwColumnPage::Reset(const SfxItemSet &rSet) 625 { 626 sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current()); 627 if(nHtmlMode & HTMLMODE_ON) 628 { 629 bHtmlMode = sal_True; 630 aAutoWidthBox.Enable(sal_False); 631 } 632 FieldUnit aMetric = ::GetDfltMetric(bHtmlMode); 633 SetMetric(aEd1, aMetric); 634 SetMetric(aEd2, aMetric); 635 SetMetric(aEd3, aMetric); 636 SetMetric(aDistEd1, aMetric); 637 SetMetric(aDistEd2, aMetric); 638 639 delete pColMgr; 640 pColMgr = new SwColMgr(rSet); 641 nCols = pColMgr->GetCount() ; 642 aCLNrEdt.SetMax(Max((sal_uInt16)aCLNrEdt.GetMax(), (sal_uInt16)nCols)); 643 aCLNrEdt.SetLast(Max(nCols,(sal_uInt16)aCLNrEdt.GetMax())); 644 645 if(bFrm) 646 { 647 if(bFormat) // hier gibt es keine Size 648 pColMgr->SetActualWidth(FRAME_FORMAT_WIDTH); 649 else 650 { 651 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE); 652 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX); 653 pColMgr->SetActualWidth((sal_uInt16)rSize.GetSize().Width() - rBox.GetDistance()); 654 } 655 } 656 if(aBalanceColsCB.IsVisible()) 657 { 658 const SfxPoolItem* pItem; 659 if( SFX_ITEM_SET == rSet.GetItemState( RES_COLUMNBALANCE, sal_False, &pItem )) 660 aBalanceColsCB.Check(!((const SwFmtNoBalancedColumns*)pItem)->GetValue()); 661 else 662 aBalanceColsCB.Check( sal_True ); 663 } 664 665 //text direction 666 if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR ) ) 667 { 668 const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR); 669 sal_uInt32 nVal = rItem.GetValue(); 670 sal_uInt16 nPos = aTextDirectionLB.GetEntryPos( (void*) nVal ); 671 aTextDirectionLB.SelectEntryPos( nPos ); 672 aTextDirectionLB.SaveValue(); 673 } 674 675 Init(); 676 ActivatePage( rSet ); 677 } 678 679 /*-------------------------------------------------------------------- 680 Beschreibung: TabPage erzeugen 681 --------------------------------------------------------------------*/ 682 683 684 685 SfxTabPage* SwColumnPage::Create(Window *pParent, const SfxItemSet &rSet) 686 { 687 return new SwColumnPage(pParent, rSet); 688 } 689 690 /*-------------------------------------------------------------------- 691 Beschreibung: Attribute in den Set stopfen bei OK 692 --------------------------------------------------------------------*/ 693 694 695 696 sal_Bool SwColumnPage::FillItemSet(SfxItemSet &rSet) 697 { 698 if(aCLNrEdt.HasChildPathFocus()) 699 aCLNrEdt.GetDownHdl().Call(&aCLNrEdt); 700 // Im ItemSet setzen 701 // Die aktuellen Einstellungen sind 702 // schon vorhanden 703 // 704 const SfxPoolItem* pOldItem; 705 const SwFmtCol& rCol = pColMgr->GetColumns(); 706 if(0 == (pOldItem = GetOldItem( rSet, RES_COL )) || 707 rCol != *pOldItem ) 708 rSet.Put(rCol); 709 710 if(aBalanceColsCB.IsVisible() ) 711 { 712 rSet.Put(SwFmtNoBalancedColumns(!aBalanceColsCB.IsChecked() )); 713 } 714 sal_uInt16 nPos; 715 if( aTextDirectionLB.IsVisible() && 716 ( nPos = aTextDirectionLB.GetSelectEntryPos() ) != 717 aTextDirectionLB.GetSavedValue() ) 718 { 719 sal_uInt32 nDirection = (sal_uInt32)(sal_IntPtr)aTextDirectionLB.GetEntryData( nPos ); 720 rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR)); 721 } 722 return sal_True; 723 } 724 725 /*-------------------------------------------------------------------- 726 Beschreibung: ColumnManager updaten 727 --------------------------------------------------------------------*/ 728 729 730 731 IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ ) 732 { 733 long nGutterWidth = pColMgr->GetGutterWidth(); 734 if(nCols > 1) 735 { 736 // Ermitteln, ob die schmalste Spalte zu schmal ist 737 // fuer den eingestellten Spaltenabstand 738 long nMin = nColWidth[0]; 739 sal_uInt16 i; 740 741 for( i = 1; i < nCols; ++i) 742 nMin = Min(nMin, nColWidth[i]); 743 744 sal_Bool bAutoWidth = aAutoWidthBox.IsChecked(); 745 if(!bAutoWidth) 746 { 747 pColMgr->SetAutoWidth(sal_False); 748 // falls der Benutzer nicht die Gesamtbreite vergeben hat, 749 // den fehlenden Betrag auf die letzte Spalte addieren. 750 long nSum = 0; 751 for(i = 0; i < nCols; ++i) 752 nSum += nColWidth[i]; 753 nGutterWidth = 0; 754 for(i = 0; i < nCols - 1; ++i) 755 nGutterWidth += nColDist[i]; 756 nSum += nGutterWidth; 757 758 long nMaxW = pColMgr->GetActualSize(); 759 760 if( nSum < nMaxW ) 761 nColWidth[nCols - 1] += nMaxW - nSum; 762 763 pColMgr->SetColWidth( 0, static_cast< sal_uInt16 >(nColWidth[0] + (sal_uInt16)nColDist[0]/2) ); 764 for( i = 1; i < nCols-1; ++i ) 765 { 766 long nActDist = (nColDist[i] + nColDist[i - 1]) / 2; 767 pColMgr->SetColWidth( i, (sal_uInt16)nColWidth[i] + (sal_uInt16)nActDist ); 768 } 769 pColMgr->SetColWidth( nCols-1, static_cast< sal_uInt16 >(nColWidth[nCols-1] + nColDist[nCols -2]/2) ); 770 771 } 772 773 // keins ist ausgeschaltet 774 const sal_uInt16 nPos = aLineTypeDLB.GetSelectEntryPos(); 775 sal_Bool bEnable = 0 != nPos; 776 aLineHeightEdit.Enable( bEnable ); 777 aLineHeightLbl.Enable( bEnable ); 778 if( !bEnable ) 779 pColMgr->SetNoLine(); 780 else if( LISTBOX_ENTRY_NOTFOUND != nPos ) 781 { 782 pColMgr->SetLineWidthAndColor(nLines[nPos - 1], Color(COL_BLACK) ); 783 pColMgr->SetAdjust( SwColLineAdj( 784 aLinePosDLB.GetSelectEntryPos() + 1) ); 785 pColMgr->SetLineHeightPercent((short)aLineHeightEdit.GetValue()); 786 bEnable = pColMgr->GetLineHeightPercent() != 100; 787 } 788 aLinePosLbl.Enable( bEnable ); 789 aLinePosDLB.Enable( bEnable ); 790 } 791 else 792 { 793 pColMgr->NoCols(); 794 nCols = 0; 795 } 796 797 //Maximalwerte setzen 798 aCLNrEdt.SetMax(Max(1L, 799 Min(long(nMaxCols), long( pColMgr->GetActualSize() / (nGutterWidth + MINLAY)) ))); 800 aCLNrEdt.SetLast(aCLNrEdt.GetMax()); 801 aCLNrEdt.Reformat(); 802 803 //Beispielfenster anregen 804 if(!bLockUpdate) 805 { 806 if(bFrm) 807 { 808 aFrmExampleWN.SetColumns( pColMgr->GetColumns() ); 809 aFrmExampleWN.Invalidate(); 810 } 811 else 812 aPgeExampleWN.Invalidate(); 813 } 814 815 return 0; 816 } 817 818 /*------------------------------------------------------------------------ 819 Beschreibung: Initialisierung 820 ------------------------------------------------------------------------*/ 821 822 823 824 void SwColumnPage::Init() 825 { 826 aCLNrEdt.SetValue(nCols); 827 828 sal_Bool bAutoWidth = pColMgr->IsAutoWidth() || bHtmlMode; 829 aAutoWidthBox.Check( bAutoWidth ); 830 831 sal_Int32 nColumnWidthSum = 0; 832 // Setzen der Breiten 833 sal_uInt16 i; 834 for(i = 0; i < nCols; ++i) 835 { 836 nColWidth[i] = pColMgr->GetColWidth(i); 837 nColumnWidthSum += nColWidth[i]; 838 if(i < nCols - 1) 839 nColDist[i] = pColMgr->GetGutterWidth(i); 840 } 841 842 if( 1 < nCols ) 843 { 844 // #97495# make sure that the automatic column widht's are always equal 845 if(bAutoWidth) 846 { 847 nColumnWidthSum /= nCols; 848 for(i = 0; i < nCols; ++i) 849 nColWidth[i] = nColumnWidthSum; 850 } 851 SwColLineAdj eAdj = pColMgr->GetAdjust(); 852 if( COLADJ_NONE == eAdj ) // der Dialog kennt kein NONE! 853 { 854 eAdj = COLADJ_TOP; 855 //ohne Adjust auch kein Linientyp 856 aLineTypeDLB.SelectEntryPos( 0 ); 857 aLineHeightEdit.SetValue( 100 ); 858 } 859 else 860 { 861 aLineTypeDLB.SelectEntryPos( lcl_LineWidthToPos(( pColMgr->GetLineWidth() )) + 1); 862 aLineHeightEdit.SetValue( pColMgr->GetLineHeightPercent() ); 863 } 864 aLinePosDLB.SelectEntryPos( static_cast< sal_uInt16 >(eAdj - 1) ); 865 } 866 else 867 { 868 aLinePosDLB.SelectEntryPos( 0 ); 869 aLineTypeDLB.SelectEntryPos( 0 ); 870 aLineHeightEdit.SetValue( 100 ); 871 } 872 873 UpdateCols(); 874 Update(); 875 876 // Maximale Spaltenzahl setzen 877 // Werte kleiner als 1 sind nicht erlaubt 878 aCLNrEdt.SetMax(Max(1L, 879 Min(long(nMaxCols), long( pColMgr->GetActualSize() / nMinWidth) ))); 880 } 881 882 /*------------------------------------------------------------------------ 883 Beschreibung: Die Anzahl der Spalten hat sich veraendert -- hier werden 884 die Controls fuer die Bearbeitung der Spalten entsprechend 885 der Spaltenzahl en- oder disabled. 886 Falls es mehr als nVisCols (= 3) Spalten gibt, werden 887 alle Edit enabled und die Buttons fuer das Scrollen 888 ebenfalls. 889 Andernfalls werden die Edits jeweils fuer die entsprechenden 890 Spaltenzahl enabled; eine Spalte kann nicht bearbeitet werden. 891 ------------------------------------------------------------------------*/ 892 893 894 895 void SwColumnPage::UpdateCols() 896 { 897 sal_Bool bEnableBtns= sal_False; 898 sal_Bool bEnable12 = sal_False; 899 sal_Bool bEnable3 = sal_False; 900 const sal_Bool bEdit = !aAutoWidthBox.IsChecked(); 901 if ( nCols > nVisCols ) 902 { 903 bEnableBtns = sal_True && !bHtmlMode; 904 bEnable12 = bEnable3 = bEdit; 905 } 906 else if( bEdit ) 907 { 908 // hier gibt es absichtlich kaum noch breaks 909 switch(nCols) 910 { 911 case 3: bEnable3 = sal_True; 912 case 2: bEnable12= sal_True; break; 913 default: /* do nothing */; 914 } 915 } 916 aEd1.Enable( bEnable12 ); 917 aDistEd1.Enable(nCols > 1); 918 aEd2.Enable( bEnable12 ); 919 aDistEd2.Enable(bEnable3); 920 aEd3.Enable( bEnable3 ); 921 aLbl1.Enable(bEnable12 ); 922 aLbl2.Enable(bEnable12 ); 923 aLbl3.Enable(bEnable3 ); 924 aBtnUp.Enable( bEnableBtns ); 925 aBtnDown.Enable( bEnableBtns ); 926 927 const sal_Bool bEnable = nCols > 1; 928 if( !bEnable ) 929 { 930 aLinePosDLB.Enable( sal_False ); 931 aLinePosLbl.Enable( sal_False ); 932 } 933 aLineHeightEdit.Enable( bEnable ); 934 aLineHeightLbl.Enable( bEnable ); 935 aLineTypeDLB.Enable( bEnable ); 936 aLineTypeLbl.Enable( bEnable ); 937 aAutoWidthBox.Enable( bEnable && !bHtmlMode ); 938 } 939 940 void SwColumnPage::SetLabels( sal_uInt16 nVis ) 941 { 942 String sLbl( '~' ); 943 944 String sLbl2( String::CreateFromInt32( nVis + 1 )); 945 String tmp1(sLbl2); 946 sLbl2.Insert(sLbl, sLbl2.Len() - 1); 947 aLbl1.SetText(sLbl2); 948 949 sLbl2 = String::CreateFromInt32( nVis + 2 ); 950 String tmp2(sLbl2); 951 sLbl2.Insert(sLbl, sLbl2.Len() - 1); 952 aLbl2.SetText(sLbl2); 953 954 sLbl2 = String::CreateFromInt32( nVis + 3 ); 955 String tmp3(sLbl2); 956 sLbl2.Insert(sLbl, sLbl2.Len() - 1); 957 aLbl3.SetText(sLbl2); 958 String sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ; 959 sColumnWidth.SearchAndReplaceAscii("%1", tmp1); 960 aEd1.SetAccessibleName(sColumnWidth); 961 962 sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ; 963 sColumnWidth.SearchAndReplaceAscii("%1", tmp2); 964 aEd2.SetAccessibleName(sColumnWidth); 965 966 sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ; 967 sColumnWidth.SearchAndReplaceAscii("%1", tmp3); 968 aEd3.SetAccessibleName(sColumnWidth); 969 970 String sDist = SW_RESSTR( STR_ACCESS_PAGESETUP_SPACING ) ; 971 String sDist1 = sDist; 972 sDist1.SearchAndReplaceAscii("%1", tmp1); 973 sDist1.SearchAndReplaceAscii("%2", tmp2); 974 aDistEd1.SetAccessibleName(sDist1); 975 976 String sDist2 = sDist; 977 sDist2.SearchAndReplaceAscii("%1", tmp2); 978 sDist2.SearchAndReplaceAscii("%2", tmp3); 979 aDistEd2.SetAccessibleName(sDist2); 980 } 981 982 /*------------------------------------------------------------------------ 983 Beschreibung: Handler, der bei einer Veraenderung der Spaltenzahl 984 gerufen wird. 985 Eine Aenderung der Spaltenzahl ueberschreibt eventuelle 986 Breiteneinstellungen des Benutzers; alle Spalten sind 987 gleich breit. 988 ------------------------------------------------------------------------*/ 989 990 IMPL_LINK( SwColumnPage, ColModify, NumericField *, pNF ) 991 { 992 nCols = (sal_uInt16)aCLNrEdt.GetValue(); 993 //#107890# the handler is also called from LoseFocus() 994 //then no change has been made and thus no action should be taken 995 // #i17816# changing the displayed types within the ValueSet 996 //from two columns to two columns with different settings doesn't invalidate the 997 // example windows in ::ColModify() 998 //IAccessibility2 Impplementaton 2009----- 999 // the pColMgr->GetCount()'s return is some how bugged, 1000 // it will return 0 when actual count is 1, so fix it. 1001 //if(!pNF ||(pColMgr->GetCount() != nCols)) 1002 int nTemp = pColMgr->GetCount(); 1003 if(nTemp == 0) nTemp = 1; 1004 if( nTemp != nCols ) 1005 //-----IAccessibility2 Impplementaton 2009 1006 { 1007 if(pNF) 1008 aDefaultVS.SetNoSelection(); 1009 long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP))); 1010 pColMgr->SetCount(nCols, (sal_uInt16)nDist); 1011 for(sal_uInt16 i = 0; i < nCols; i++) 1012 nColDist[i] = nDist; 1013 nFirstVis = 0; 1014 SetLabels( nFirstVis ); 1015 UpdateCols(); 1016 ResetColWidth(); 1017 Update(); 1018 } 1019 1020 return 0; 1021 } 1022 1023 /*------------------------------------------------------------------------ 1024 Beschreibung: Modify- Handler fuer eine Aenderung der Spaltenbreite 1025 oder des Spaltenabstandes. 1026 Diese Aenderungen wirken sich erst zeitversetzt aus. 1027 Durch eine Aenderung der Spaltenbreite wird die automatische 1028 Berechnung der Spaltenbreite ausser Kraft gesetzt; erst 1029 eine Aenderung der Spaltenzahl kehrt wieder zu diesem 1030 Default zurueck. 1031 ------------------------------------------------------------------------*/ 1032 1033 1034 1035 IMPL_LINK( SwColumnPage, GapModify, PercentField *, pFld ) 1036 { 1037 long nActValue = static_cast< long >(pFld->DenormalizePercent(pFld->GetValue(FUNIT_TWIP))); 1038 if(nCols < 2) 1039 return 0; 1040 if(aAutoWidthBox.IsChecked()) 1041 { 1042 sal_uInt16 nMaxGap = pColMgr->GetActualSize() - nCols * MINLAY; 1043 DBG_ASSERT(nCols, "Abstand kann nicht ohne Spalten eingestellt werden"); 1044 nMaxGap /= nCols - 1; 1045 if(nActValue > nMaxGap) 1046 { 1047 nActValue = nMaxGap; 1048 aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nMaxGap), FUNIT_TWIP); 1049 } 1050 pColMgr->SetGutterWidth((sal_uInt16)nActValue); 1051 for(sal_uInt16 i = 0; i < nCols; i++) 1052 nColDist[i] = nActValue; 1053 1054 ResetColWidth(); 1055 UpdateCols(); 1056 } 1057 else 1058 1059 { 1060 sal_uInt16 nOffset = 0; 1061 if(pFld == &aDistEd2) 1062 { 1063 nOffset = 1; 1064 } 1065 long nDiff = nActValue - nColDist[nFirstVis + nOffset]; 1066 if(nDiff) 1067 { 1068 long nLeft = nColWidth[nFirstVis + nOffset]; 1069 long nRight = nColWidth[nFirstVis + nOffset + 1]; 1070 if(nLeft + nRight + 2 * MINLAY < nDiff) 1071 nDiff = nLeft + nRight - 2 * MINLAY; 1072 if(nDiff < nRight - MINLAY) 1073 { 1074 nRight -= nDiff; 1075 } 1076 else 1077 { 1078 long nTemp = nDiff - nRight + MINLAY; 1079 nRight = MINLAY; 1080 if(nLeft > nTemp - MINLAY) 1081 { 1082 nLeft -= nTemp; 1083 nTemp = 0; 1084 } 1085 else 1086 { 1087 nTemp -= nLeft + MINLAY; 1088 nLeft = MINLAY; 1089 } 1090 nDiff = nTemp; 1091 } 1092 nColWidth[nFirstVis + nOffset] = nLeft; 1093 nColWidth[nFirstVis + nOffset + 1] = nRight; 1094 nColDist[nFirstVis + nOffset] += nDiff; 1095 1096 pColMgr->SetColWidth( nFirstVis + nOffset, sal_uInt16(nLeft) ); 1097 pColMgr->SetColWidth( nFirstVis + nOffset + 1, sal_uInt16(nRight) ); 1098 pColMgr->SetGutterWidth( sal_uInt16(nColDist[nFirstVis + nOffset]), nFirstVis + nOffset ); 1099 } 1100 1101 } 1102 Update(); 1103 return 0; 1104 } 1105 1106 /*------------------------------------------------------------------------ 1107 Beschreibung: 1108 ------------------------------------------------------------------------*/ 1109 1110 1111 1112 IMPL_LINK( SwColumnPage, EdModify, PercentField *, pField ) 1113 { 1114 pModifiedField = pField; 1115 Timeout(0); 1116 return 0; 1117 } 1118 /*------------------------------------------------------------------------ 1119 Beschreibung: Handler hinter der Checkbox fuer automatische Breite. 1120 Ist die Box gecheckt, koennen keine expliziten Werte 1121 fuer die Spaltenbreite eingegeben werden. 1122 ------------------------------------------------------------------------*/ 1123 1124 1125 1126 IMPL_LINK( SwColumnPage, AutoWidthHdl, CheckBox *, pBox ) 1127 { 1128 long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP))); 1129 pColMgr->SetCount(nCols, (sal_uInt16)nDist); 1130 for(sal_uInt16 i = 0; i < nCols; i++) 1131 nColDist[i] = nDist; 1132 if(pBox->IsChecked()) 1133 { 1134 pColMgr->SetGutterWidth(sal_uInt16(nDist)); 1135 ResetColWidth(); 1136 } 1137 pColMgr->SetAutoWidth(pBox->IsChecked(), sal_uInt16(nDist)); 1138 UpdateCols(); 1139 Update(); 1140 return 0; 1141 } 1142 1143 /*------------------------------------------------------------------------ 1144 Beschreibung: Raufscrollen der Inhalte der Edits. 1145 ------------------------------------------------------------------------*/ 1146 1147 IMPL_LINK( SwColumnPage, Up, Button *, EMPTYARG ) 1148 { 1149 if( nFirstVis ) 1150 { 1151 --nFirstVis; 1152 SetLabels( nFirstVis ); 1153 Update(); 1154 } 1155 return 0; 1156 } 1157 /*------------------------------------------------------------------------ 1158 Beschreibung: Runterscrollen der Inhalte der Edits. 1159 ------------------------------------------------------------------------*/ 1160 1161 IMPL_LINK( SwColumnPage, Down, Button *, EMPTYARG ) 1162 { 1163 if( nFirstVis + nVisCols < nCols ) 1164 { 1165 ++nFirstVis; 1166 SetLabels( nFirstVis ); 1167 Update(); 1168 } 1169 return 0; 1170 } 1171 /*------------------------------------------------------------------------ 1172 Beschreibung: Relikt aus alten Zeiten - jetzt direkt ohne time 1173 * Timer- Handler; angetriggert durch eine Aenderung der 1174 Spaltenbreite oder des Spaltenabstandes. 1175 ------------------------------------------------------------------------*/ 1176 1177 IMPL_LINK( SwColumnPage, Timeout, Timer *, EMPTYARG ) 1178 { 1179 DBG_PROFSTART(columnhdl) ; 1180 if(pModifiedField) 1181 { 1182 // Finden der veraenderten Spalte 1183 sal_uInt16 nChanged = nFirstVis; 1184 if(pModifiedField == &aEd2) 1185 ++nChanged; 1186 else if(pModifiedField == &aEd3) 1187 nChanged += 2; 1188 /*else if(pModifiedField == &aEd4) 1189 nChanged += 3;*/ 1190 1191 long nNewWidth = (sal_uInt16) 1192 pModifiedField->DenormalizePercent(pModifiedField->GetValue(FUNIT_TWIP)); 1193 long nDiff = nNewWidth - nColWidth[nChanged]; 1194 1195 // wenn es die letzte Spalte ist 1196 if(nChanged == nCols - 1) 1197 { 1198 nColWidth[0] -= nDiff; 1199 if(nColWidth[0] < (long)nMinWidth) 1200 { 1201 nNewWidth -= nMinWidth - nColWidth[0]; 1202 nColWidth[0] = nMinWidth; 1203 } 1204 1205 } 1206 else if(nDiff) 1207 { 1208 nColWidth[nChanged + 1] -= nDiff; 1209 if(nColWidth[nChanged + 1] < (long) nMinWidth) 1210 { 1211 nNewWidth -= nMinWidth - nColWidth[nChanged + 1]; 1212 nColWidth[nChanged + 1] = nMinWidth; 1213 } 1214 } 1215 nColWidth[nChanged] = nNewWidth; 1216 pModifiedField = 0; 1217 } 1218 Update(); 1219 DBG_PROFSTOP(columnhdl) ; 1220 return 0; 1221 } 1222 /*------------------------------------------------------------------------ 1223 Beschreibung: Aktualisierung der Anzeige 1224 ------------------------------------------------------------------------*/ 1225 1226 1227 1228 void SwColumnPage::Update() 1229 { 1230 aBalanceColsCB.Enable(nCols > 1); 1231 if(nCols >= 2) 1232 { 1233 aEd1.SetPrcntValue(aEd1.NormalizePercent(nColWidth[nFirstVis]), FUNIT_TWIP); 1234 aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nColDist[nFirstVis]), FUNIT_TWIP); 1235 aEd2.SetPrcntValue(aEd2.NormalizePercent(nColWidth[nFirstVis + 1]), FUNIT_TWIP); 1236 if(nCols >= 3) 1237 { 1238 aDistEd2.SetPrcntValue(aDistEd2.NormalizePercent(nColDist[nFirstVis + 1]), FUNIT_TWIP); 1239 aEd3.SetPrcntValue(aEd3.NormalizePercent(nColWidth[nFirstVis + 2]), FUNIT_TWIP); 1240 } 1241 else 1242 { 1243 aEd3.SetText(aEmptyStr); 1244 aDistEd2.SetText(aEmptyStr); 1245 } 1246 } 1247 else 1248 { 1249 aEd1.SetText(aEmptyStr); 1250 aEd2.SetText(aEmptyStr); 1251 aEd3.SetText(aEmptyStr); 1252 aDistEd1.SetText(aEmptyStr); 1253 aDistEd2.SetText(aEmptyStr); 1254 } 1255 UpdateColMgr(0); 1256 } 1257 1258 /*-------------------------------------------------------------------- 1259 Beschreibung: Update Bsp 1260 --------------------------------------------------------------------*/ 1261 1262 1263 1264 void SwColumnPage::ActivatePage(const SfxItemSet& rSet) 1265 { 1266 if(!bFrm) 1267 { 1268 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE )) 1269 { 1270 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( 1271 SID_ATTR_PAGE_SIZE); 1272 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get( 1273 RES_LR_SPACE ); 1274 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX); 1275 sal_uInt16 nActWidth = static_cast< sal_uInt16 >(rSize.GetSize().Width() 1276 - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance()); 1277 1278 if( pColMgr->GetActualSize() != nActWidth) 1279 { 1280 pColMgr->SetActualWidth(nActWidth); 1281 ColModify( 0 ); 1282 UpdateColMgr( 0 ); 1283 } 1284 } 1285 aFrmExampleWN.Hide(); 1286 aPgeExampleWN.UpdateExample( rSet, pColMgr ); 1287 aPgeExampleWN.Show(); 1288 1289 } 1290 else 1291 { 1292 aPgeExampleWN.Hide(); 1293 aFrmExampleWN.Show(); 1294 1295 // Size 1296 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE); 1297 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX); 1298 1299 long nDistance = rBox.GetDistance(); 1300 const sal_uInt16 nTotalWish = bFormat ? FRAME_FORMAT_WIDTH : sal_uInt16(rSize.GetWidth() - 2 * nDistance); 1301 1302 // Maximalwerte der Spaltenbreiten setzen 1303 SetPageWidth(nTotalWish); 1304 1305 if(pColMgr->GetActualSize() != nTotalWish) 1306 { 1307 pColMgr->SetActualWidth(nTotalWish); 1308 Init(); 1309 } 1310 sal_Bool bPercent; 1311 // im Rahmenformat nur relative Angaben 1312 if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) ) 1313 { 1314 // Wert fuer 100% setzen 1315 aEd1.SetRefValue(nTotalWish); 1316 aEd2.SetRefValue(nTotalWish); 1317 aEd3.SetRefValue(nTotalWish); 1318 aDistEd1.SetRefValue(nTotalWish); 1319 aDistEd2.SetRefValue(nTotalWish); 1320 1321 // Auf %-Darstellung umschalten 1322 bPercent = sal_True; 1323 } 1324 else 1325 bPercent = sal_False; 1326 1327 aEd1.ShowPercent(bPercent); 1328 aEd2.ShowPercent(bPercent); 1329 aEd3.ShowPercent(bPercent); 1330 aDistEd1.ShowPercent(bPercent); 1331 aDistEd2.ShowPercent(bPercent); 1332 aDistEd1.MetricField::SetMin(0); 1333 aDistEd2.MetricField::SetMin(0); 1334 } 1335 Update(); 1336 } 1337 1338 /*-------------------------------------------------------------------- 1339 Beschreibung: 1340 --------------------------------------------------------------------*/ 1341 1342 1343 1344 int SwColumnPage::DeactivatePage(SfxItemSet *_pSet) 1345 { 1346 if(_pSet) 1347 FillItemSet(*_pSet); 1348 1349 return sal_True; 1350 } 1351 1352 1353 1354 sal_uInt16* SwColumnPage::GetRanges() 1355 { 1356 return aPageRg; 1357 } 1358 1359 /*-------------------------------------------------------------------- 1360 Beschreibung: 1361 --------------------------------------------------------------------*/ 1362 1363 1364 1365 IMPL_LINK( SwColumnPage, SetDefaultsHdl, ValueSet *, pVS ) 1366 { 1367 sal_uInt16 nItem = pVS->GetSelectItemId(); 1368 if( nItem < 4 ) 1369 { 1370 aCLNrEdt.SetValue( nItem ); 1371 aAutoWidthBox.Check(); 1372 aDistEd1.SetPrcntValue(0); 1373 ColModify(0); 1374 } 1375 else 1376 { 1377 bLockUpdate = sal_True; 1378 aCLNrEdt.SetValue( 2 ); 1379 aAutoWidthBox.Check(sal_False); 1380 aDistEd1.SetPrcntValue(0); 1381 ColModify(0); 1382 // jetzt noch das Breitenverhaeltnisse auf 2 : 1 bzw. 1 : 2 stellen 1383 sal_uInt16 nSmall = pColMgr->GetActualSize() / 3; 1384 if(nItem == 4) 1385 { 1386 aEd2.SetPrcntValue(aEd2.NormalizePercent(long(nSmall)), FUNIT_TWIP); 1387 pModifiedField = &aEd2; 1388 } 1389 else 1390 { 1391 aEd1.SetPrcntValue(aEd1.NormalizePercent(long(nSmall)), FUNIT_TWIP); 1392 pModifiedField = &aEd1; 1393 } 1394 bLockUpdate = sal_False; 1395 Timeout(0); 1396 1397 } 1398 return 0; 1399 } 1400 1401 /*-----------------25.10.96 11.41------------------- 1402 1403 --------------------------------------------------*/ 1404 1405 1406 void SwColumnPage::SetFrmMode(sal_Bool bMod) 1407 { 1408 bFrm = bMod; 1409 } 1410 /* -----------------------------2002/06/19 13:08------------------------------ 1411 1412 ---------------------------------------------------------------------------*/ 1413 void SwColumnPage::SetInSection(sal_Bool bSet) 1414 { 1415 if(!SW_MOD()->GetCTLOptions().IsCTLFontEnabled()) 1416 return; 1417 1418 aVertFL.Show(bSet); 1419 aPropertiesFL.Show(bSet); 1420 aTextDirectionFT.Show(bSet); 1421 aTextDirectionLB.Show(bSet); 1422 if(bSet) 1423 { 1424 //resize line type FixedLine 1425 Point aLtPos = aFLLineType.GetPosPixel(); 1426 Point aPropPos = aPropertiesFL.GetPosPixel(); 1427 Size aSz = aFLLineType.GetSizePixel(); 1428 aSz.Width() = aPropPos.X() - aLtPos.X() - LogicToPixel(Size(8, 8), MAP_APPFONT).Width(); 1429 aFLLineType.SetSizePixel(aSz); 1430 } 1431 else 1432 { 1433 Size aSz = aFLLineType.GetSizePixel(); 1434 aSz.Width() = LogicToPixel(Size(248, 248), MAP_APPFONT).Width(); 1435 aFLLineType.SetSizePixel(aSz); 1436 } 1437 } 1438 1439 /*-----------------07.03.97 08.33------------------- 1440 1441 --------------------------------------------------*/ 1442 1443 1444 void ColumnValueSet::UserDraw( const UserDrawEvent& rUDEvt ) 1445 { 1446 OutputDevice* pDev = rUDEvt.GetDevice(); 1447 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 1448 1449 Rectangle aRect = rUDEvt.GetRect(); 1450 sal_uInt16 nItemId = rUDEvt.GetItemId(); 1451 long nRectWidth = aRect.GetWidth(); 1452 long nRectHeight = aRect.GetHeight(); 1453 1454 Point aBLPos = aRect.TopLeft(); 1455 Color aFillColor(pDev->GetFillColor()); 1456 Color aLineColor(pDev->GetLineColor()); 1457 pDev->SetFillColor(rStyleSettings.GetFieldColor()); 1458 pDev->SetLineColor(SwViewOption::GetFontColor()); 1459 1460 long nStep = Abs(Abs(nRectHeight * 95 /100) / 11); 1461 long nTop = (nRectHeight - 11 * nStep ) / 2; 1462 sal_uInt16 nCols = 0; 1463 long nStarts[3]; 1464 long nEnds[3]; 1465 nStarts[0] = nRectWidth * 10 / 100; 1466 switch( nItemId ) 1467 { 1468 case 1: 1469 nEnds[0] = nRectWidth * 9 / 10; 1470 nCols = 1; 1471 break; 1472 case 2: nCols = 2; 1473 nEnds[0] = nRectWidth * 45 / 100; 1474 nStarts[1] = nEnds[0] + nStep; 1475 nEnds[1] = nRectWidth * 9 / 10; 1476 break; 1477 case 3: nCols = 3; 1478 nEnds[0] = nRectWidth * 30 / 100; 1479 nStarts[1] = nEnds[0] + nStep; 1480 nEnds[1] = nRectWidth * 63 / 100; 1481 nStarts[2] = nEnds[1] + nStep; 1482 nEnds[2] = nRectWidth * 9 / 10; 1483 break; 1484 case 4: nCols = 2; 1485 nEnds[0] = nRectWidth * 63 / 100; 1486 nStarts[1] = nEnds[0] + nStep; 1487 nEnds[1] = nRectWidth * 9 / 10; 1488 break; 1489 case 5: nCols = 2; 1490 nEnds[0] = nRectWidth * 30 / 100; 1491 nStarts[1] = nEnds[0] + nStep; 1492 nEnds[1] = nRectWidth * 9 / 10; 1493 break; 1494 } 1495 for(sal_uInt16 j = 0; j < nCols; j++ ) 1496 { 1497 Point aStart(aBLPos.X() + nStarts[j], 0); 1498 Point aEnd(aBLPos.X() + nEnds[j], 0); 1499 for( sal_uInt16 i = 0; i < 12; i ++) 1500 { 1501 aStart.Y() = aEnd.Y() = aBLPos.Y() + nTop + i * nStep; 1502 pDev->DrawLine(aStart, aEnd); 1503 } 1504 } 1505 pDev->SetFillColor(aFillColor); 1506 pDev->SetLineColor(aLineColor); 1507 } 1508 1509 /*-----------------07.03.97 08.48------------------- 1510 1511 --------------------------------------------------*/ 1512 1513 ColumnValueSet::~ColumnValueSet() 1514 { 1515 } 1516 /* -----------------------------02.04.2002 16:01------------------------------ 1517 1518 ---------------------------------------------------------------------------*/ 1519 void ColumnValueSet::DataChanged( const DataChangedEvent& rDCEvt ) 1520 { 1521 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 1522 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1523 { 1524 Format(); 1525 } 1526 ValueSet::DataChanged( rDCEvt ); 1527 } 1528 1529