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 for( i = 0; i < 5; i++) 521 //Solution:Set accessible name one be one 522 //aDefaultVS.InsertItem( i + 1, i ); 523 { 524 String aItemText; 525 switch( i ) 526 { 527 case 0: 528 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM0 ) ; 529 break; 530 case 1: 531 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM1 ) ; 532 break; 533 case 2: 534 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM2 ) ; 535 break; 536 case 3: 537 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM3 ); 538 break; 539 case 4: 540 aItemText = SW_RESSTR( STR_COLUMN_VALUESET_ITEM4 ); 541 break; 542 default: 543 break; 544 } 545 aDefaultVS.InsertItem( i + 1, aItemText, i ); 546 } 547 548 aDefaultVS.SetSelectHdl(LINK(this, SwColumnPage, SetDefaultsHdl)); 549 550 // Controls fuer Zusaetzebereich beim MoreButton anmelden 551 Link aCLNrLk = LINK(this, SwColumnPage, ColModify); 552 aCLNrEdt.SetLoseFocusHdl(aCLNrLk); 553 aCLNrEdt.SetUpHdl(aCLNrLk); 554 aCLNrEdt.SetDownHdl(aCLNrLk); 555 Link aLk = LINK(this, SwColumnPage, GapModify); 556 aDistEd1.SetUpHdl(aLk); 557 aDistEd1.SetDownHdl(aLk); 558 aDistEd1.SetLoseFocusHdl(aLk); 559 aDistEd2.SetUpHdl(aLk); 560 aDistEd2.SetDownHdl(aLk); 561 aDistEd2.SetLoseFocusHdl(aLk); 562 563 aLk = LINK(this, SwColumnPage, EdModify); 564 565 aEd1.SetUpHdl(aLk); 566 aEd1.SetDownHdl(aLk); 567 aEd1.SetLoseFocusHdl(aLk); 568 569 aEd2.SetUpHdl(aLk); 570 aEd2.SetDownHdl(aLk); 571 aEd2.SetLoseFocusHdl(aLk); 572 573 aEd3.SetUpHdl(aLk); 574 aEd3.SetDownHdl(aLk); 575 aEd3.SetLoseFocusHdl(aLk); 576 577 aBtnUp.SetClickHdl(LINK(this, SwColumnPage, Up)); 578 aBtnDown.SetClickHdl(LINK(this, SwColumnPage, Down)); 579 aAutoWidthBox.SetClickHdl(LINK(this, SwColumnPage, AutoWidthHdl)); 580 581 aLk = LINK( this, SwColumnPage, UpdateColMgr ); 582 aLineTypeDLB.SetSelectHdl( aLk ); 583 aLineHeightEdit.SetModifyHdl( aLk ); 584 aLinePosDLB.SetSelectHdl( aLk ); 585 586 // Trennlinie 587 aLineTypeDLB.SetUnit( FUNIT_POINT ); 588 aLineTypeDLB.SetSourceUnit( FUNIT_TWIP ); 589 for( i = 0; i < nLineCount; ++i ) 590 aLineTypeDLB.InsertEntry( 100 * nLines[ i ] ); 591 } 592 593 594 595 SwColumnPage::~SwColumnPage() 596 { 597 delete pColMgr; 598 } 599 600 /*-------------------------------------------------------------------- 601 Beschreibung: 602 --------------------------------------------------------------------*/ 603 604 605 void SwColumnPage::SetPageWidth(long nPageWidth) 606 { 607 long nNewMaxWidth = static_cast< long >(aEd1.NormalizePercent(nPageWidth)); 608 609 aDistEd1.SetMax(nNewMaxWidth, FUNIT_TWIP); 610 aDistEd2.SetMax(nNewMaxWidth, FUNIT_TWIP); 611 aEd1.SetMax(nNewMaxWidth, FUNIT_TWIP); 612 aEd2.SetMax(nNewMaxWidth, FUNIT_TWIP); 613 aEd3.SetMax(nNewMaxWidth, FUNIT_TWIP); 614 } 615 616 /*-------------------------------------------------------------------- 617 Beschreibung: 618 --------------------------------------------------------------------*/ 619 620 621 622 void SwColumnPage::Reset(const SfxItemSet &rSet) 623 { 624 sal_uInt16 nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current()); 625 if(nHtmlMode & HTMLMODE_ON) 626 { 627 bHtmlMode = sal_True; 628 aAutoWidthBox.Enable(sal_False); 629 } 630 FieldUnit aMetric = ::GetDfltMetric(bHtmlMode); 631 SetMetric(aEd1, aMetric); 632 SetMetric(aEd2, aMetric); 633 SetMetric(aEd3, aMetric); 634 SetMetric(aDistEd1, aMetric); 635 SetMetric(aDistEd2, aMetric); 636 637 delete pColMgr; 638 pColMgr = new SwColMgr(rSet); 639 nCols = pColMgr->GetCount() ; 640 aCLNrEdt.SetMax(Max((sal_uInt16)aCLNrEdt.GetMax(), (sal_uInt16)nCols)); 641 aCLNrEdt.SetLast(Max(nCols,(sal_uInt16)aCLNrEdt.GetMax())); 642 643 if(bFrm) 644 { 645 if(bFormat) // hier gibt es keine Size 646 pColMgr->SetActualWidth(FRAME_FORMAT_WIDTH); 647 else 648 { 649 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE); 650 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX); 651 pColMgr->SetActualWidth((sal_uInt16)rSize.GetSize().Width() - rBox.GetDistance()); 652 } 653 } 654 if(aBalanceColsCB.IsVisible()) 655 { 656 const SfxPoolItem* pItem; 657 if( SFX_ITEM_SET == rSet.GetItemState( RES_COLUMNBALANCE, sal_False, &pItem )) 658 aBalanceColsCB.Check(!((const SwFmtNoBalancedColumns*)pItem)->GetValue()); 659 else 660 aBalanceColsCB.Check( sal_True ); 661 } 662 663 //text direction 664 if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR ) ) 665 { 666 const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR); 667 sal_uInt32 nVal = rItem.GetValue(); 668 sal_uInt16 nPos = aTextDirectionLB.GetEntryPos( (void*) nVal ); 669 aTextDirectionLB.SelectEntryPos( nPos ); 670 aTextDirectionLB.SaveValue(); 671 } 672 673 Init(); 674 ActivatePage( rSet ); 675 } 676 677 /*-------------------------------------------------------------------- 678 Beschreibung: TabPage erzeugen 679 --------------------------------------------------------------------*/ 680 681 682 683 SfxTabPage* SwColumnPage::Create(Window *pParent, const SfxItemSet &rSet) 684 { 685 return new SwColumnPage(pParent, rSet); 686 } 687 688 /*-------------------------------------------------------------------- 689 Beschreibung: Attribute in den Set stopfen bei OK 690 --------------------------------------------------------------------*/ 691 692 693 694 sal_Bool SwColumnPage::FillItemSet(SfxItemSet &rSet) 695 { 696 if(aCLNrEdt.HasChildPathFocus()) 697 aCLNrEdt.GetDownHdl().Call(&aCLNrEdt); 698 // Im ItemSet setzen 699 // Die aktuellen Einstellungen sind 700 // schon vorhanden 701 // 702 const SfxPoolItem* pOldItem; 703 const SwFmtCol& rCol = pColMgr->GetColumns(); 704 if(0 == (pOldItem = GetOldItem( rSet, RES_COL )) || 705 rCol != *pOldItem ) 706 rSet.Put(rCol); 707 708 if(aBalanceColsCB.IsVisible() ) 709 { 710 rSet.Put(SwFmtNoBalancedColumns(!aBalanceColsCB.IsChecked() )); 711 } 712 sal_uInt16 nPos; 713 if( aTextDirectionLB.IsVisible() && 714 ( nPos = aTextDirectionLB.GetSelectEntryPos() ) != 715 aTextDirectionLB.GetSavedValue() ) 716 { 717 sal_uInt32 nDirection = (sal_uInt32)(sal_IntPtr)aTextDirectionLB.GetEntryData( nPos ); 718 rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR)); 719 } 720 return sal_True; 721 } 722 723 /*-------------------------------------------------------------------- 724 Beschreibung: ColumnManager updaten 725 --------------------------------------------------------------------*/ 726 727 728 729 IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ ) 730 { 731 long nGutterWidth = pColMgr->GetGutterWidth(); 732 if(nCols > 1) 733 { 734 // Ermitteln, ob die schmalste Spalte zu schmal ist 735 // fuer den eingestellten Spaltenabstand 736 long nMin = nColWidth[0]; 737 sal_uInt16 i; 738 739 for( i = 1; i < nCols; ++i) 740 nMin = Min(nMin, nColWidth[i]); 741 742 sal_Bool bAutoWidth = aAutoWidthBox.IsChecked(); 743 if(!bAutoWidth) 744 { 745 pColMgr->SetAutoWidth(sal_False); 746 // falls der Benutzer nicht die Gesamtbreite vergeben hat, 747 // den fehlenden Betrag auf die letzte Spalte addieren. 748 long nSum = 0; 749 for(i = 0; i < nCols; ++i) 750 nSum += nColWidth[i]; 751 nGutterWidth = 0; 752 for(i = 0; i < nCols - 1; ++i) 753 nGutterWidth += nColDist[i]; 754 nSum += nGutterWidth; 755 756 long nMaxW = pColMgr->GetActualSize(); 757 758 if( nSum < nMaxW ) 759 nColWidth[nCols - 1] += nMaxW - nSum; 760 761 pColMgr->SetColWidth( 0, static_cast< sal_uInt16 >(nColWidth[0] + (sal_uInt16)nColDist[0]/2) ); 762 for( i = 1; i < nCols-1; ++i ) 763 { 764 long nActDist = (nColDist[i] + nColDist[i - 1]) / 2; 765 pColMgr->SetColWidth( i, (sal_uInt16)nColWidth[i] + (sal_uInt16)nActDist ); 766 } 767 pColMgr->SetColWidth( nCols-1, static_cast< sal_uInt16 >(nColWidth[nCols-1] + nColDist[nCols -2]/2) ); 768 769 } 770 771 // keins ist ausgeschaltet 772 const sal_uInt16 nPos = aLineTypeDLB.GetSelectEntryPos(); 773 sal_Bool bEnable = 0 != nPos; 774 aLineHeightEdit.Enable( bEnable ); 775 aLineHeightLbl.Enable( bEnable ); 776 if( !bEnable ) 777 pColMgr->SetNoLine(); 778 else if( LISTBOX_ENTRY_NOTFOUND != nPos ) 779 { 780 pColMgr->SetLineWidthAndColor(nLines[nPos - 1], Color(COL_BLACK) ); 781 pColMgr->SetAdjust( SwColLineAdj( 782 aLinePosDLB.GetSelectEntryPos() + 1) ); 783 pColMgr->SetLineHeightPercent((short)aLineHeightEdit.GetValue()); 784 bEnable = pColMgr->GetLineHeightPercent() != 100; 785 } 786 aLinePosLbl.Enable( bEnable ); 787 aLinePosDLB.Enable( bEnable ); 788 } 789 else 790 { 791 pColMgr->NoCols(); 792 nCols = 0; 793 } 794 795 //Maximalwerte setzen 796 aCLNrEdt.SetMax(Max(1L, 797 Min(long(nMaxCols), long( pColMgr->GetActualSize() / (nGutterWidth + MINLAY)) ))); 798 aCLNrEdt.SetLast(aCLNrEdt.GetMax()); 799 aCLNrEdt.Reformat(); 800 801 //Beispielfenster anregen 802 if(!bLockUpdate) 803 { 804 if(bFrm) 805 { 806 aFrmExampleWN.SetColumns( pColMgr->GetColumns() ); 807 aFrmExampleWN.Invalidate(); 808 } 809 else 810 aPgeExampleWN.Invalidate(); 811 } 812 813 return 0; 814 } 815 816 /*------------------------------------------------------------------------ 817 Beschreibung: Initialisierung 818 ------------------------------------------------------------------------*/ 819 820 821 822 void SwColumnPage::Init() 823 { 824 aCLNrEdt.SetValue(nCols); 825 826 sal_Bool bAutoWidth = pColMgr->IsAutoWidth() || bHtmlMode; 827 aAutoWidthBox.Check( bAutoWidth ); 828 829 sal_Int32 nColumnWidthSum = 0; 830 // Setzen der Breiten 831 sal_uInt16 i; 832 for(i = 0; i < nCols; ++i) 833 { 834 nColWidth[i] = pColMgr->GetColWidth(i); 835 nColumnWidthSum += nColWidth[i]; 836 if(i < nCols - 1) 837 nColDist[i] = pColMgr->GetGutterWidth(i); 838 } 839 840 if( 1 < nCols ) 841 { 842 // #97495# make sure that the automatic column widht's are always equal 843 if(bAutoWidth) 844 { 845 nColumnWidthSum /= nCols; 846 for(i = 0; i < nCols; ++i) 847 nColWidth[i] = nColumnWidthSum; 848 } 849 SwColLineAdj eAdj = pColMgr->GetAdjust(); 850 if( COLADJ_NONE == eAdj ) // der Dialog kennt kein NONE! 851 { 852 eAdj = COLADJ_TOP; 853 //ohne Adjust auch kein Linientyp 854 aLineTypeDLB.SelectEntryPos( 0 ); 855 aLineHeightEdit.SetValue( 100 ); 856 } 857 else 858 { 859 aLineTypeDLB.SelectEntryPos( lcl_LineWidthToPos(( pColMgr->GetLineWidth() )) + 1); 860 aLineHeightEdit.SetValue( pColMgr->GetLineHeightPercent() ); 861 } 862 aLinePosDLB.SelectEntryPos( static_cast< sal_uInt16 >(eAdj - 1) ); 863 } 864 else 865 { 866 aLinePosDLB.SelectEntryPos( 0 ); 867 aLineTypeDLB.SelectEntryPos( 0 ); 868 aLineHeightEdit.SetValue( 100 ); 869 } 870 871 UpdateCols(); 872 Update(); 873 874 // Maximale Spaltenzahl setzen 875 // Werte kleiner als 1 sind nicht erlaubt 876 aCLNrEdt.SetMax(Max(1L, 877 Min(long(nMaxCols), long( pColMgr->GetActualSize() / nMinWidth) ))); 878 } 879 880 /*------------------------------------------------------------------------ 881 Beschreibung: Die Anzahl der Spalten hat sich veraendert -- hier werden 882 die Controls fuer die Bearbeitung der Spalten entsprechend 883 der Spaltenzahl en- oder disabled. 884 Falls es mehr als nVisCols (= 3) Spalten gibt, werden 885 alle Edit enabled und die Buttons fuer das Scrollen 886 ebenfalls. 887 Andernfalls werden die Edits jeweils fuer die entsprechenden 888 Spaltenzahl enabled; eine Spalte kann nicht bearbeitet werden. 889 ------------------------------------------------------------------------*/ 890 891 892 893 void SwColumnPage::UpdateCols() 894 { 895 sal_Bool bEnableBtns= sal_False; 896 sal_Bool bEnable12 = sal_False; 897 sal_Bool bEnable3 = sal_False; 898 const sal_Bool bEdit = !aAutoWidthBox.IsChecked(); 899 if ( nCols > nVisCols ) 900 { 901 bEnableBtns = sal_True && !bHtmlMode; 902 bEnable12 = bEnable3 = bEdit; 903 } 904 else if( bEdit ) 905 { 906 // hier gibt es absichtlich kaum noch breaks 907 switch(nCols) 908 { 909 case 3: bEnable3 = sal_True; 910 case 2: bEnable12= sal_True; break; 911 default: /* do nothing */; 912 } 913 } 914 aEd1.Enable( bEnable12 ); 915 aDistEd1.Enable(nCols > 1); 916 aEd2.Enable( bEnable12 ); 917 aDistEd2.Enable(bEnable3); 918 aEd3.Enable( bEnable3 ); 919 aLbl1.Enable(bEnable12 ); 920 aLbl2.Enable(bEnable12 ); 921 aLbl3.Enable(bEnable3 ); 922 aBtnUp.Enable( bEnableBtns ); 923 aBtnDown.Enable( bEnableBtns ); 924 925 const sal_Bool bEnable = nCols > 1; 926 if( !bEnable ) 927 { 928 aLinePosDLB.Enable( sal_False ); 929 aLinePosLbl.Enable( sal_False ); 930 } 931 aLineHeightEdit.Enable( bEnable ); 932 aLineHeightLbl.Enable( bEnable ); 933 aLineTypeDLB.Enable( bEnable ); 934 aLineTypeLbl.Enable( bEnable ); 935 aAutoWidthBox.Enable( bEnable && !bHtmlMode ); 936 } 937 938 void SwColumnPage::SetLabels( sal_uInt16 nVis ) 939 { 940 String sLbl( '~' ); 941 942 String sLbl2( String::CreateFromInt32( nVis + 1 )); 943 String tmp1(sLbl2); 944 sLbl2.Insert(sLbl, sLbl2.Len() - 1); 945 aLbl1.SetText(sLbl2); 946 947 sLbl2 = String::CreateFromInt32( nVis + 2 ); 948 String tmp2(sLbl2); 949 sLbl2.Insert(sLbl, sLbl2.Len() - 1); 950 aLbl2.SetText(sLbl2); 951 952 sLbl2 = String::CreateFromInt32( nVis + 3 ); 953 String tmp3(sLbl2); 954 sLbl2.Insert(sLbl, sLbl2.Len() - 1); 955 aLbl3.SetText(sLbl2); 956 String sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ; 957 sColumnWidth.SearchAndReplaceAscii("%1", tmp1); 958 aEd1.SetAccessibleName(sColumnWidth); 959 960 sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ; 961 sColumnWidth.SearchAndReplaceAscii("%1", tmp2); 962 aEd2.SetAccessibleName(sColumnWidth); 963 964 sColumnWidth = SW_RESSTR( STR_ACCESS_COLUMN_WIDTH ) ; 965 sColumnWidth.SearchAndReplaceAscii("%1", tmp3); 966 aEd3.SetAccessibleName(sColumnWidth); 967 968 String sDist = SW_RESSTR( STR_ACCESS_PAGESETUP_SPACING ) ; 969 String sDist1 = sDist; 970 sDist1.SearchAndReplaceAscii("%1", tmp1); 971 sDist1.SearchAndReplaceAscii("%2", tmp2); 972 aDistEd1.SetAccessibleName(sDist1); 973 974 String sDist2 = sDist; 975 sDist2.SearchAndReplaceAscii("%1", tmp2); 976 sDist2.SearchAndReplaceAscii("%2", tmp3); 977 aDistEd2.SetAccessibleName(sDist2); 978 } 979 980 /*------------------------------------------------------------------------ 981 Beschreibung: Handler, der bei einer Veraenderung der Spaltenzahl 982 gerufen wird. 983 Eine Aenderung der Spaltenzahl ueberschreibt eventuelle 984 Breiteneinstellungen des Benutzers; alle Spalten sind 985 gleich breit. 986 ------------------------------------------------------------------------*/ 987 988 IMPL_LINK( SwColumnPage, ColModify, NumericField *, pNF ) 989 { 990 nCols = (sal_uInt16)aCLNrEdt.GetValue(); 991 //#107890# the handler is also called from LoseFocus() 992 //then no change has been made and thus no action should be taken 993 // #i17816# changing the displayed types within the ValueSet 994 //from two columns to two columns with different settings doesn't invalidate the 995 // example windows in ::ColModify() 996 // the pColMgr->GetCount()'s return is some how bugged, 997 // it will return 0 when actual count is 1, so fix it. 998 //if(!pNF ||(pColMgr->GetCount() != nCols)) 999 int nTemp = pColMgr->GetCount(); 1000 if(nTemp == 0) nTemp = 1; 1001 if( nTemp != nCols ) 1002 { 1003 if(pNF) 1004 aDefaultVS.SetNoSelection(); 1005 long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP))); 1006 pColMgr->SetCount(nCols, (sal_uInt16)nDist); 1007 for(sal_uInt16 i = 0; i < nCols; i++) 1008 nColDist[i] = nDist; 1009 nFirstVis = 0; 1010 SetLabels( nFirstVis ); 1011 UpdateCols(); 1012 ResetColWidth(); 1013 Update(); 1014 } 1015 1016 return 0; 1017 } 1018 1019 /*------------------------------------------------------------------------ 1020 Beschreibung: Modify- Handler fuer eine Aenderung der Spaltenbreite 1021 oder des Spaltenabstandes. 1022 Diese Aenderungen wirken sich erst zeitversetzt aus. 1023 Durch eine Aenderung der Spaltenbreite wird die automatische 1024 Berechnung der Spaltenbreite ausser Kraft gesetzt; erst 1025 eine Aenderung der Spaltenzahl kehrt wieder zu diesem 1026 Default zurueck. 1027 ------------------------------------------------------------------------*/ 1028 1029 1030 1031 IMPL_LINK( SwColumnPage, GapModify, PercentField *, pFld ) 1032 { 1033 long nActValue = static_cast< long >(pFld->DenormalizePercent(pFld->GetValue(FUNIT_TWIP))); 1034 if(nCols < 2) 1035 return 0; 1036 if(aAutoWidthBox.IsChecked()) 1037 { 1038 sal_uInt16 nMaxGap = pColMgr->GetActualSize() - nCols * MINLAY; 1039 DBG_ASSERT(nCols, "Abstand kann nicht ohne Spalten eingestellt werden"); 1040 nMaxGap /= nCols - 1; 1041 if(nActValue > nMaxGap) 1042 { 1043 nActValue = nMaxGap; 1044 aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nMaxGap), FUNIT_TWIP); 1045 } 1046 pColMgr->SetGutterWidth((sal_uInt16)nActValue); 1047 for(sal_uInt16 i = 0; i < nCols; i++) 1048 nColDist[i] = nActValue; 1049 1050 ResetColWidth(); 1051 UpdateCols(); 1052 } 1053 else 1054 1055 { 1056 sal_uInt16 nOffset = 0; 1057 if(pFld == &aDistEd2) 1058 { 1059 nOffset = 1; 1060 } 1061 long nDiff = nActValue - nColDist[nFirstVis + nOffset]; 1062 if(nDiff) 1063 { 1064 long nLeft = nColWidth[nFirstVis + nOffset]; 1065 long nRight = nColWidth[nFirstVis + nOffset + 1]; 1066 if(nLeft + nRight + 2 * MINLAY < nDiff) 1067 nDiff = nLeft + nRight - 2 * MINLAY; 1068 if(nDiff < nRight - MINLAY) 1069 { 1070 nRight -= nDiff; 1071 } 1072 else 1073 { 1074 long nTemp = nDiff - nRight + MINLAY; 1075 nRight = MINLAY; 1076 if(nLeft > nTemp - MINLAY) 1077 { 1078 nLeft -= nTemp; 1079 nTemp = 0; 1080 } 1081 else 1082 { 1083 nTemp -= nLeft + MINLAY; 1084 nLeft = MINLAY; 1085 } 1086 nDiff = nTemp; 1087 } 1088 nColWidth[nFirstVis + nOffset] = nLeft; 1089 nColWidth[nFirstVis + nOffset + 1] = nRight; 1090 nColDist[nFirstVis + nOffset] += nDiff; 1091 1092 pColMgr->SetColWidth( nFirstVis + nOffset, sal_uInt16(nLeft) ); 1093 pColMgr->SetColWidth( nFirstVis + nOffset + 1, sal_uInt16(nRight) ); 1094 pColMgr->SetGutterWidth( sal_uInt16(nColDist[nFirstVis + nOffset]), nFirstVis + nOffset ); 1095 } 1096 1097 } 1098 Update(); 1099 return 0; 1100 } 1101 1102 /*------------------------------------------------------------------------ 1103 Beschreibung: 1104 ------------------------------------------------------------------------*/ 1105 1106 1107 1108 IMPL_LINK( SwColumnPage, EdModify, PercentField *, pField ) 1109 { 1110 pModifiedField = pField; 1111 Timeout(0); 1112 return 0; 1113 } 1114 /*------------------------------------------------------------------------ 1115 Beschreibung: Handler hinter der Checkbox fuer automatische Breite. 1116 Ist die Box gecheckt, koennen keine expliziten Werte 1117 fuer die Spaltenbreite eingegeben werden. 1118 ------------------------------------------------------------------------*/ 1119 1120 1121 1122 IMPL_LINK( SwColumnPage, AutoWidthHdl, CheckBox *, pBox ) 1123 { 1124 long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP))); 1125 pColMgr->SetCount(nCols, (sal_uInt16)nDist); 1126 for(sal_uInt16 i = 0; i < nCols; i++) 1127 nColDist[i] = nDist; 1128 if(pBox->IsChecked()) 1129 { 1130 pColMgr->SetGutterWidth(sal_uInt16(nDist)); 1131 ResetColWidth(); 1132 } 1133 pColMgr->SetAutoWidth(pBox->IsChecked(), sal_uInt16(nDist)); 1134 UpdateCols(); 1135 Update(); 1136 return 0; 1137 } 1138 1139 /*------------------------------------------------------------------------ 1140 Beschreibung: Raufscrollen der Inhalte der Edits. 1141 ------------------------------------------------------------------------*/ 1142 1143 IMPL_LINK( SwColumnPage, Up, Button *, EMPTYARG ) 1144 { 1145 if( nFirstVis ) 1146 { 1147 --nFirstVis; 1148 SetLabels( nFirstVis ); 1149 Update(); 1150 } 1151 return 0; 1152 } 1153 /*------------------------------------------------------------------------ 1154 Beschreibung: Runterscrollen der Inhalte der Edits. 1155 ------------------------------------------------------------------------*/ 1156 1157 IMPL_LINK( SwColumnPage, Down, Button *, EMPTYARG ) 1158 { 1159 if( nFirstVis + nVisCols < nCols ) 1160 { 1161 ++nFirstVis; 1162 SetLabels( nFirstVis ); 1163 Update(); 1164 } 1165 return 0; 1166 } 1167 /*------------------------------------------------------------------------ 1168 Beschreibung: Relikt aus alten Zeiten - jetzt direkt ohne time 1169 * Timer- Handler; angetriggert durch eine Aenderung der 1170 Spaltenbreite oder des Spaltenabstandes. 1171 ------------------------------------------------------------------------*/ 1172 1173 IMPL_LINK( SwColumnPage, Timeout, Timer *, EMPTYARG ) 1174 { 1175 DBG_PROFSTART(columnhdl) ; 1176 if(pModifiedField) 1177 { 1178 // Finden der veraenderten Spalte 1179 sal_uInt16 nChanged = nFirstVis; 1180 if(pModifiedField == &aEd2) 1181 ++nChanged; 1182 else if(pModifiedField == &aEd3) 1183 nChanged += 2; 1184 /*else if(pModifiedField == &aEd4) 1185 nChanged += 3;*/ 1186 1187 long nNewWidth = (sal_uInt16) 1188 pModifiedField->DenormalizePercent(pModifiedField->GetValue(FUNIT_TWIP)); 1189 long nDiff = nNewWidth - nColWidth[nChanged]; 1190 1191 // wenn es die letzte Spalte ist 1192 if(nChanged == nCols - 1) 1193 { 1194 nColWidth[0] -= nDiff; 1195 if(nColWidth[0] < (long)nMinWidth) 1196 { 1197 nNewWidth -= nMinWidth - nColWidth[0]; 1198 nColWidth[0] = nMinWidth; 1199 } 1200 1201 } 1202 else if(nDiff) 1203 { 1204 nColWidth[nChanged + 1] -= nDiff; 1205 if(nColWidth[nChanged + 1] < (long) nMinWidth) 1206 { 1207 nNewWidth -= nMinWidth - nColWidth[nChanged + 1]; 1208 nColWidth[nChanged + 1] = nMinWidth; 1209 } 1210 } 1211 nColWidth[nChanged] = nNewWidth; 1212 pModifiedField = 0; 1213 } 1214 Update(); 1215 DBG_PROFSTOP(columnhdl) ; 1216 return 0; 1217 } 1218 /*------------------------------------------------------------------------ 1219 Beschreibung: Aktualisierung der Anzeige 1220 ------------------------------------------------------------------------*/ 1221 1222 1223 1224 void SwColumnPage::Update() 1225 { 1226 aBalanceColsCB.Enable(nCols > 1); 1227 if(nCols >= 2) 1228 { 1229 aEd1.SetPrcntValue(aEd1.NormalizePercent(nColWidth[nFirstVis]), FUNIT_TWIP); 1230 aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nColDist[nFirstVis]), FUNIT_TWIP); 1231 aEd2.SetPrcntValue(aEd2.NormalizePercent(nColWidth[nFirstVis + 1]), FUNIT_TWIP); 1232 if(nCols >= 3) 1233 { 1234 aDistEd2.SetPrcntValue(aDistEd2.NormalizePercent(nColDist[nFirstVis + 1]), FUNIT_TWIP); 1235 aEd3.SetPrcntValue(aEd3.NormalizePercent(nColWidth[nFirstVis + 2]), FUNIT_TWIP); 1236 } 1237 else 1238 { 1239 aEd3.SetText(aEmptyStr); 1240 aDistEd2.SetText(aEmptyStr); 1241 } 1242 } 1243 else 1244 { 1245 aEd1.SetText(aEmptyStr); 1246 aEd2.SetText(aEmptyStr); 1247 aEd3.SetText(aEmptyStr); 1248 aDistEd1.SetText(aEmptyStr); 1249 aDistEd2.SetText(aEmptyStr); 1250 } 1251 UpdateColMgr(0); 1252 } 1253 1254 /*-------------------------------------------------------------------- 1255 Beschreibung: Update Bsp 1256 --------------------------------------------------------------------*/ 1257 1258 1259 1260 void SwColumnPage::ActivatePage(const SfxItemSet& rSet) 1261 { 1262 if(!bFrm) 1263 { 1264 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE )) 1265 { 1266 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get( 1267 SID_ATTR_PAGE_SIZE); 1268 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get( 1269 RES_LR_SPACE ); 1270 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX); 1271 sal_uInt16 nActWidth = static_cast< sal_uInt16 >(rSize.GetSize().Width() 1272 - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance()); 1273 1274 if( pColMgr->GetActualSize() != nActWidth) 1275 { 1276 pColMgr->SetActualWidth(nActWidth); 1277 ColModify( 0 ); 1278 UpdateColMgr( 0 ); 1279 } 1280 } 1281 aFrmExampleWN.Hide(); 1282 aPgeExampleWN.UpdateExample( rSet, pColMgr ); 1283 aPgeExampleWN.Show(); 1284 1285 } 1286 else 1287 { 1288 aPgeExampleWN.Hide(); 1289 aFrmExampleWN.Show(); 1290 1291 // Size 1292 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE); 1293 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX); 1294 1295 long nDistance = rBox.GetDistance(); 1296 const sal_uInt16 nTotalWish = bFormat ? FRAME_FORMAT_WIDTH : sal_uInt16(rSize.GetWidth() - 2 * nDistance); 1297 1298 // Maximalwerte der Spaltenbreiten setzen 1299 SetPageWidth(nTotalWish); 1300 1301 if(pColMgr->GetActualSize() != nTotalWish) 1302 { 1303 pColMgr->SetActualWidth(nTotalWish); 1304 Init(); 1305 } 1306 sal_Bool bPercent; 1307 // im Rahmenformat nur relative Angaben 1308 if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) ) 1309 { 1310 // Wert fuer 100% setzen 1311 aEd1.SetRefValue(nTotalWish); 1312 aEd2.SetRefValue(nTotalWish); 1313 aEd3.SetRefValue(nTotalWish); 1314 aDistEd1.SetRefValue(nTotalWish); 1315 aDistEd2.SetRefValue(nTotalWish); 1316 1317 // Auf %-Darstellung umschalten 1318 bPercent = sal_True; 1319 } 1320 else 1321 bPercent = sal_False; 1322 1323 aEd1.ShowPercent(bPercent); 1324 aEd2.ShowPercent(bPercent); 1325 aEd3.ShowPercent(bPercent); 1326 aDistEd1.ShowPercent(bPercent); 1327 aDistEd2.ShowPercent(bPercent); 1328 aDistEd1.MetricField::SetMin(0); 1329 aDistEd2.MetricField::SetMin(0); 1330 } 1331 Update(); 1332 } 1333 1334 /*-------------------------------------------------------------------- 1335 Beschreibung: 1336 --------------------------------------------------------------------*/ 1337 1338 1339 1340 int SwColumnPage::DeactivatePage(SfxItemSet *_pSet) 1341 { 1342 if(_pSet) 1343 FillItemSet(*_pSet); 1344 1345 return sal_True; 1346 } 1347 1348 1349 1350 sal_uInt16* SwColumnPage::GetRanges() 1351 { 1352 return aPageRg; 1353 } 1354 1355 /*-------------------------------------------------------------------- 1356 Beschreibung: 1357 --------------------------------------------------------------------*/ 1358 1359 1360 1361 IMPL_LINK( SwColumnPage, SetDefaultsHdl, ValueSet *, pVS ) 1362 { 1363 sal_uInt16 nItem = pVS->GetSelectItemId(); 1364 if( nItem < 4 ) 1365 { 1366 aCLNrEdt.SetValue( nItem ); 1367 aAutoWidthBox.Check(); 1368 aDistEd1.SetPrcntValue(0); 1369 ColModify(0); 1370 } 1371 else 1372 { 1373 bLockUpdate = sal_True; 1374 aCLNrEdt.SetValue( 2 ); 1375 aAutoWidthBox.Check(sal_False); 1376 aDistEd1.SetPrcntValue(0); 1377 ColModify(0); 1378 // jetzt noch das Breitenverhaeltnisse auf 2 : 1 bzw. 1 : 2 stellen 1379 sal_uInt16 nSmall = pColMgr->GetActualSize() / 3; 1380 if(nItem == 4) 1381 { 1382 aEd2.SetPrcntValue(aEd2.NormalizePercent(long(nSmall)), FUNIT_TWIP); 1383 pModifiedField = &aEd2; 1384 } 1385 else 1386 { 1387 aEd1.SetPrcntValue(aEd1.NormalizePercent(long(nSmall)), FUNIT_TWIP); 1388 pModifiedField = &aEd1; 1389 } 1390 bLockUpdate = sal_False; 1391 Timeout(0); 1392 1393 } 1394 return 0; 1395 } 1396 1397 /*-----------------25.10.96 11.41------------------- 1398 1399 --------------------------------------------------*/ 1400 1401 1402 void SwColumnPage::SetFrmMode(sal_Bool bMod) 1403 { 1404 bFrm = bMod; 1405 } 1406 /* -----------------------------2002/06/19 13:08------------------------------ 1407 1408 ---------------------------------------------------------------------------*/ 1409 void SwColumnPage::SetInSection(sal_Bool bSet) 1410 { 1411 if(!SW_MOD()->GetCTLOptions().IsCTLFontEnabled()) 1412 return; 1413 1414 aVertFL.Show(bSet); 1415 aPropertiesFL.Show(bSet); 1416 aTextDirectionFT.Show(bSet); 1417 aTextDirectionLB.Show(bSet); 1418 if(bSet) 1419 { 1420 //resize line type FixedLine 1421 Point aLtPos = aFLLineType.GetPosPixel(); 1422 Point aPropPos = aPropertiesFL.GetPosPixel(); 1423 Size aSz = aFLLineType.GetSizePixel(); 1424 aSz.Width() = aPropPos.X() - aLtPos.X() - LogicToPixel(Size(8, 8), MAP_APPFONT).Width(); 1425 aFLLineType.SetSizePixel(aSz); 1426 } 1427 else 1428 { 1429 Size aSz = aFLLineType.GetSizePixel(); 1430 aSz.Width() = LogicToPixel(Size(248, 248), MAP_APPFONT).Width(); 1431 aFLLineType.SetSizePixel(aSz); 1432 } 1433 } 1434 1435 /*-----------------07.03.97 08.33------------------- 1436 1437 --------------------------------------------------*/ 1438 1439 1440 void ColumnValueSet::UserDraw( const UserDrawEvent& rUDEvt ) 1441 { 1442 OutputDevice* pDev = rUDEvt.GetDevice(); 1443 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 1444 1445 Rectangle aRect = rUDEvt.GetRect(); 1446 sal_uInt16 nItemId = rUDEvt.GetItemId(); 1447 long nRectWidth = aRect.GetWidth(); 1448 long nRectHeight = aRect.GetHeight(); 1449 1450 Point aBLPos = aRect.TopLeft(); 1451 Color aFillColor(pDev->GetFillColor()); 1452 Color aLineColor(pDev->GetLineColor()); 1453 pDev->SetFillColor(rStyleSettings.GetFieldColor()); 1454 pDev->SetLineColor(SwViewOption::GetFontColor()); 1455 1456 long nStep = Abs(Abs(nRectHeight * 95 /100) / 11); 1457 long nTop = (nRectHeight - 11 * nStep ) / 2; 1458 sal_uInt16 nCols = 0; 1459 long nStarts[3]; 1460 long nEnds[3]; 1461 nStarts[0] = nRectWidth * 10 / 100; 1462 switch( nItemId ) 1463 { 1464 case 1: 1465 nEnds[0] = nRectWidth * 9 / 10; 1466 nCols = 1; 1467 break; 1468 case 2: nCols = 2; 1469 nEnds[0] = nRectWidth * 45 / 100; 1470 nStarts[1] = nEnds[0] + nStep; 1471 nEnds[1] = nRectWidth * 9 / 10; 1472 break; 1473 case 3: nCols = 3; 1474 nEnds[0] = nRectWidth * 30 / 100; 1475 nStarts[1] = nEnds[0] + nStep; 1476 nEnds[1] = nRectWidth * 63 / 100; 1477 nStarts[2] = nEnds[1] + nStep; 1478 nEnds[2] = nRectWidth * 9 / 10; 1479 break; 1480 case 4: nCols = 2; 1481 nEnds[0] = nRectWidth * 63 / 100; 1482 nStarts[1] = nEnds[0] + nStep; 1483 nEnds[1] = nRectWidth * 9 / 10; 1484 break; 1485 case 5: nCols = 2; 1486 nEnds[0] = nRectWidth * 30 / 100; 1487 nStarts[1] = nEnds[0] + nStep; 1488 nEnds[1] = nRectWidth * 9 / 10; 1489 break; 1490 } 1491 for(sal_uInt16 j = 0; j < nCols; j++ ) 1492 { 1493 Point aStart(aBLPos.X() + nStarts[j], 0); 1494 Point aEnd(aBLPos.X() + nEnds[j], 0); 1495 for( sal_uInt16 i = 0; i < 12; i ++) 1496 { 1497 aStart.Y() = aEnd.Y() = aBLPos.Y() + nTop + i * nStep; 1498 pDev->DrawLine(aStart, aEnd); 1499 } 1500 } 1501 pDev->SetFillColor(aFillColor); 1502 pDev->SetLineColor(aLineColor); 1503 } 1504 1505 /*-----------------07.03.97 08.48------------------- 1506 1507 --------------------------------------------------*/ 1508 1509 ColumnValueSet::~ColumnValueSet() 1510 { 1511 } 1512 /* -----------------------------02.04.2002 16:01------------------------------ 1513 1514 ---------------------------------------------------------------------------*/ 1515 void ColumnValueSet::DataChanged( const DataChangedEvent& rDCEvt ) 1516 { 1517 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 1518 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1519 { 1520 Format(); 1521 } 1522 ValueSet::DataChanged( rDCEvt ); 1523 } 1524 1525