merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / frmdlg / column.cxx
blob46969d633f49d8562cc1fa9afb7025aa9dd425fa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: column.cxx,v $
10 * $Revision: 1.37 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
36 #endif
38 #include "column.hxx"
40 #include "hintids.hxx"
41 #include <svx/htmlmode.hxx>
42 #include <svx/borderline.hxx>
43 #include <svx/boxitem.hxx>
44 #include <svx/lrspitem.hxx>
45 #include <svx/sizeitem.hxx>
46 #include "svx/frmdiritem.hxx"
47 #include <svtools/ctloptions.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <vcl/msgbox.hxx>
50 #include <swmodule.hxx>
52 #include <helpid.h>
53 #include "globals.hrc"
54 #include "swtypes.hxx"
55 #include "wrtsh.hxx"
56 #include "view.hxx"
57 #include "docsh.hxx"
58 #include "uitool.hxx"
59 #include "cmdid.h"
60 #include "viewopt.hxx"
61 #include "format.hxx"
62 #include "frmmgr.hxx"
63 #include "frmdlg.hxx"
64 #include "colmgr.hxx"
65 #include "prcntfld.hxx"
66 #include "paratr.hxx"
67 #include "frmui.hrc"
68 #include "poolfmt.hrc"
69 #include "column.hrc"
70 #include <section.hxx>
71 #include <docary.hxx>
72 #include <pagedesc.hxx>
74 #define FRAME_FORMAT_WIDTH 1000
76 // sw/inc/fmtclds.hxx
77 SV_IMPL_PTRARR( SwColumns, SwColumnPtr )
79 /*--------------------------------------------------------------------
80 Beschreibung: Statische Daten
81 --------------------------------------------------------------------*/
83 static const USHORT __FAR_DATA nLines[] = {
84 DEF_LINE_WIDTH_0,
85 DEF_LINE_WIDTH_1,
86 DEF_LINE_WIDTH_2,
87 DEF_LINE_WIDTH_3,
88 DEF_LINE_WIDTH_4
91 static const USHORT nLineCount = sizeof(nLines) / sizeof(nLines[0]);
92 static const USHORT nVisCols = 3;
94 inline BOOL IsMarkInSameSection( SwWrtShell& rWrtSh, const SwSection* pSect )
96 rWrtSh.SwapPam();
97 BOOL bRet = pSect == rWrtSh.GetCurrSection();
98 rWrtSh.SwapPam();
99 return bRet;
102 /*--------------------------------------------------------------------
103 Beschreibung:
104 --------------------------------------------------------------------*/
106 SwColumnDlg::SwColumnDlg(Window* pParent, SwWrtShell& rSh) :
107 SfxModalDialog(pParent, SW_RES(DLG_COLUMN)),
108 aOK(this, SW_RES(PB_OK)),
109 aCancel(this, SW_RES(PB_CANCEL)),
110 aHelp(this, SW_RES(PB_HELP)),
111 aApplyToFT(this, SW_RES(FT_APPLY_TO)),
112 aApplyToLB(this, SW_RES(LB_APPLY_TO)),
113 rWrtShell(rSh),
114 pPageSet(0),
115 pSectionSet(0),
116 pSelectionSet(0),
117 pFrameSet(0),
118 nOldSelection(0),
119 nSelectionWidth(0),
120 bPageChanged(FALSE),
121 bSectionChanged(FALSE),
122 bSelSectionChanged(FALSE),
123 bFrameChanged(FALSE)
125 FreeResource();
127 SwRect aRect;
128 rWrtShell.CalcBoundRect(aRect, FLY_IN_CNTNT);
130 nSelectionWidth = aRect.Width();
132 SfxItemSet* pColPgSet = 0;
133 static USHORT __READONLY_DATA aSectIds[] = { RES_COL, RES_COL,
134 RES_FRM_SIZE, RES_FRM_SIZE,
135 RES_COLUMNBALANCE, RES_FRAMEDIR,
136 0 };
138 const SwSection* pCurrSection = rWrtShell.GetCurrSection();
139 USHORT nFullSectCnt = rWrtShell.GetFullSelectedSectionCount();
140 if( pCurrSection && ( !rWrtShell.HasSelection() || 0 != nFullSectCnt ))
142 nSelectionWidth = rSh.GetSectionWidth(*pCurrSection->GetFmt());
143 if ( !nSelectionWidth )
144 nSelectionWidth = USHRT_MAX;
145 pSectionSet = new SfxItemSet( rWrtShell.GetAttrPool(), aSectIds );
146 pSectionSet->Put( pCurrSection->GetFmt()->GetAttrSet() );
147 pColPgSet = pSectionSet;
148 aApplyToLB.RemoveEntry( aApplyToLB.GetEntryPos(
149 (void*)( 1 >= nFullSectCnt
150 ? LISTBOX_SECTIONS
151 : LISTBOX_SECTION )));
153 else
155 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_SECTION ));
156 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_SECTIONS ));
159 if( rWrtShell.HasSelection() && rWrtShell.IsInsRegionAvailable() &&
160 ( !pCurrSection || ( 1 != nFullSectCnt &&
161 IsMarkInSameSection( rWrtShell, pCurrSection ) )))
163 pSelectionSet = new SfxItemSet( rWrtShell.GetAttrPool(), aSectIds );
164 pColPgSet = pSelectionSet;
166 else
167 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_SELECTION ));
169 if( rWrtShell.GetFlyFrmFmt() )
171 const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt() ;
172 pFrameSet = new SfxItemSet(rWrtShell.GetAttrPool(), aSectIds );
173 pFrameSet->Put(pFmt->GetFrmSize());
174 pFrameSet->Put(pFmt->GetCol());
175 pColPgSet = pFrameSet;
177 else
178 aApplyToLB.RemoveEntry(aApplyToLB.GetEntryPos( (void*) LISTBOX_FRAME ));
181 USHORT nPagePos = aApplyToLB.GetEntryPos( (void*) LISTBOX_PAGE );
182 const SwPageDesc* pPageDesc = rWrtShell.GetSelectedPageDescs();
183 if( pPageDesc )
185 pPageSet = new SfxItemSet( rWrtShell.GetAttrPool(),
186 RES_COL, RES_COL,
187 RES_FRM_SIZE, RES_FRM_SIZE,
188 RES_LR_SPACE, RES_LR_SPACE,
189 0 );
191 String sPageStr = aApplyToLB.GetEntry(nPagePos);
192 aApplyToLB.RemoveEntry( nPagePos );
193 sPageStr += pPageDesc->GetName();
194 aApplyToLB.InsertEntry( sPageStr, nPagePos );
195 aApplyToLB.SetEntryData( nPagePos, (void*) LISTBOX_PAGE);
197 const SwFrmFmt &rFmt = pPageDesc->GetMaster();
198 nPageWidth = rFmt.GetFrmSize().GetSize().Width();
200 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rFmt.GetLRSpace();
201 const SvxBoxItem& rBox = (const SvxBoxItem&) rFmt.GetBox();
202 nPageWidth -= rLRSpace.GetLeft() + rLRSpace.GetRight() + rBox.GetDistance();
204 pPageSet->Put(rFmt.GetCol());
205 pPageSet->Put(rFmt.GetLRSpace());
206 pColPgSet = pPageSet;
208 else
209 aApplyToLB.RemoveEntry( nPagePos );
212 ASSERT( pColPgSet, "" );
213 // TabPage erzeugen
214 SwColumnPage* pPage = (SwColumnPage*) SwColumnPage::Create( this,
215 *pColPgSet );
216 pTabPage = pPage;
218 //Groesse anpassen
219 Size aPageSize(pTabPage->GetSizePixel());
220 Size aDlgSize(GetOutputSizePixel());
221 aDlgSize.Height() = aPageSize.Height();
222 SetOutputSizePixel(aDlgSize);
223 pTabPage->Show();
225 aApplyToLB.SelectEntryPos(0);
226 ObjectHdl(0);
228 aApplyToLB.SetSelectHdl(LINK(this, SwColumnDlg, ObjectHdl));
229 aOK.SetClickHdl(LINK(this, SwColumnDlg, OkHdl));
230 //#i80458# if no columns can be set then disable OK
231 if( !aApplyToLB.GetEntryCount() )
232 aOK.Enable( sal_False );
233 //#i97810# set focus to the TabPage
234 pTabPage->ActivateColumnControl();
237 /*--------------------------------------------------------------------
238 Beschreibung:
239 --------------------------------------------------------------------*/
241 SwColumnDlg::~SwColumnDlg()
243 delete pTabPage;
244 delete pPageSet;
245 delete pSectionSet;
246 delete pSelectionSet;
249 /* -----------------26.05.99 11:40-------------------
251 * --------------------------------------------------*/
252 IMPL_LINK(SwColumnDlg, ObjectHdl, ListBox*, pBox)
254 SfxItemSet* pSet = 0;
255 switch(nOldSelection)
257 case LISTBOX_SELECTION :
258 pSet = pSelectionSet;
259 break;
260 case LISTBOX_SECTION :
261 pSet = pSectionSet;
262 bSectionChanged = TRUE;
263 break;
264 case LISTBOX_SECTIONS :
265 pSet = pSectionSet;
266 bSelSectionChanged = TRUE;
267 break;
268 case LISTBOX_PAGE :
269 pSet = pPageSet;
270 bPageChanged = TRUE;
271 break;
272 case LISTBOX_FRAME:
273 pSet = pFrameSet;
274 bFrameChanged = TRUE;
275 break;
277 if(pBox)
279 pTabPage->FillItemSet(*pSet);
281 nOldSelection = (long)aApplyToLB.GetEntryData(aApplyToLB.GetSelectEntryPos());
282 long nWidth = nSelectionWidth;
283 switch(nOldSelection)
285 case LISTBOX_SELECTION :
286 pSet = pSelectionSet;
287 if( pSelectionSet )
288 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth));
289 break;
290 case LISTBOX_SECTION :
291 case LISTBOX_SECTIONS :
292 pSet = pSectionSet;
293 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth));
294 break;
295 case LISTBOX_PAGE :
296 nWidth = nPageWidth;
297 pSet = pPageSet;
298 pSet->Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth, nWidth));
299 break;
300 case LISTBOX_FRAME:
301 pSet = pFrameSet;
302 break;
305 BOOL bIsSection = pSet == pSectionSet || pSet == pSelectionSet;
306 pTabPage->ShowBalance(bIsSection);
307 pTabPage->SetInSection(bIsSection);
308 pTabPage->SetFrmMode(TRUE);
309 pTabPage->SetPageWidth(nWidth);
310 if( pSet )
311 pTabPage->Reset(*pSet);
312 return 0;
314 /* -----------------26.05.99 12:32-------------------
316 * --------------------------------------------------*/
317 IMPL_LINK(SwColumnDlg, OkHdl, OKButton*, EMPTYARG)
319 //aktuelle Selektion auswerten
320 SfxItemSet* pSet = 0;
321 switch(nOldSelection)
323 case LISTBOX_SELECTION :
324 pSet = pSelectionSet;
325 break;
326 case LISTBOX_SECTION :
327 pSet = pSectionSet;
328 bSectionChanged = TRUE;
329 break;
330 case LISTBOX_SECTIONS :
331 pSet = pSectionSet;
332 bSelSectionChanged = TRUE;
333 break;
334 case LISTBOX_PAGE :
335 pSet = pPageSet;
336 bPageChanged = TRUE;
337 break;
338 case LISTBOX_FRAME:
339 pSet = pFrameSet;
340 bFrameChanged = TRUE;
341 break;
343 pTabPage->FillItemSet(*pSet);
345 if(pSelectionSet && SFX_ITEM_SET == pSelectionSet->GetItemState(RES_COL))
347 //Bereich mit Spalten einfuegen
348 const SwFmtCol& rColItem = (const SwFmtCol&)pSelectionSet->Get(RES_COL);
349 //nur, wenn es auch Spalten gibt!
350 if(rColItem.GetNumCols() > 1)
351 rWrtShell.GetView().GetViewFrame()->GetDispatcher()->Execute(
352 FN_INSERT_REGION, SFX_CALLMODE_ASYNCHRON, *pSelectionSet );
355 if(pSectionSet && pSectionSet->Count() && bSectionChanged )
357 const SwSection* pCurrSection = rWrtShell.GetCurrSection();
358 const SwSectionFmt* pFmt = pCurrSection->GetFmt();
359 USHORT nNewPos = rWrtShell.GetSectionFmtPos( *pFmt );
360 rWrtShell.ChgSection( nNewPos, *pCurrSection, pSectionSet );
363 if(pSectionSet && pSectionSet->Count() && bSelSectionChanged )
365 rWrtShell.SetSectionAttr( *pSectionSet );
368 if(pPageSet && SFX_ITEM_SET == pPageSet->GetItemState(RES_COL) && bPageChanged)
370 // aktuellen PageDescriptor ermitteln und damit den Set fuellen
371 const USHORT nCurIdx = rWrtShell.GetCurPageDesc();
372 SwPageDesc aPageDesc(rWrtShell.GetPageDesc(nCurIdx));
373 SwFrmFmt &rFmt = aPageDesc.GetMaster();
374 rFmt.SetFmtAttr(pPageSet->Get(RES_COL));
375 rWrtShell.ChgPageDesc(nCurIdx, aPageDesc);
377 if(pFrameSet && SFX_ITEM_SET == pFrameSet->GetItemState(RES_COL) && bFrameChanged)
379 SfxItemSet aTmp(*pFrameSet->GetPool(), RES_COL, RES_COL);
380 aTmp.Put(*pFrameSet);
381 rWrtShell.StartAction();
382 rWrtShell.Push();
383 rWrtShell.SetFlyFrmAttr( aTmp );
384 //die Rahmenselektion wieder aufheben
385 if(rWrtShell.IsFrmSelected())
387 rWrtShell.UnSelectFrm();
388 rWrtShell.LeaveSelFrmMode();
390 rWrtShell.Pop();
391 rWrtShell.EndAction();
393 EndDialog(RET_OK);
394 return 0;
397 /*--------------------------------------------------------------------
398 Beschreibung:
399 --------------------------------------------------------------------*/
401 #if OSL_DEBUG_LEVEL < 2
402 inline
403 #endif
404 USHORT GetMaxWidth( SwColMgr* pColMgr, USHORT nCols )
406 USHORT nMax = pColMgr->GetActualSize();
407 if( --nCols )
408 nMax -= pColMgr->GetGutterWidth() * nCols;
409 return nMax;
412 static USHORT __FAR_DATA aPageRg[] = {
413 RES_COL, RES_COL,
418 DBG_NAME(columnhdl)
422 USHORT lcl_LineWidthToPos(ULONG nWidth)
424 const USHORT nUShortWidth = (USHORT)nWidth;
425 for(USHORT i = 0; i < nLineCount; ++i)
426 if(nUShortWidth == nLines[i])
427 return i;
428 return 0;
433 void SwColumnPage::ResetColWidth()
435 if( nCols )
437 USHORT nWidth = GetMaxWidth( pColMgr, nCols );
438 nWidth = nWidth / nCols;
440 for(USHORT i = 0; i < nCols; ++i)
441 nColWidth[i] = (long) nWidth;
446 /*--------------------------------------------------------------------
447 Beschreibung: Jetzt als TabPage
448 --------------------------------------------------------------------*/
452 SwColumnPage::SwColumnPage(Window *pParent, const SfxItemSet &rSet)
454 : SfxTabPage(pParent, SW_RES(TP_COLUMN), rSet),
456 aClNrLbl(this, SW_RES(FT_NUMBER )),
457 aCLNrEdt(this, SW_RES(ED_NUMBER )),
458 aDefaultVS(this, SW_RES(VS_DEFAULTS)),
459 aBalanceColsCB(this, SW_RES(CB_BALANCECOLS)),
460 aFLGroup(this, SW_RES(FL_COLUMNS )),
462 aBtnUp(this, SW_RES(BTN_DOWN)),
463 aColumnFT(this, SW_RES(FT_COLUMN)),
464 aWidthFT(this, SW_RES(FT_WIDTH)),
465 aDistFT(this, SW_RES(FT_DIST)),
466 aLbl1(this, SW_RES(FT_1)),
467 aEd1(this, SW_RES(ED_1)),
468 aDistEd1(this, SW_RES(ED_DIST1)),
469 aLbl2(this, SW_RES(FT_2)),
470 aEd2(this, SW_RES(ED_2)),
471 aDistEd2(this, SW_RES(ED_DIST2)),
472 aLbl3(this, SW_RES(FT_3)),
473 aEd3(this, SW_RES(ED_3)),
474 aBtnDown(this, SW_RES(BTN_UP)),
475 aAutoWidthBox(this, SW_RES(CB_AUTO_WIDTH)),
477 aFLLayout(this, SW_RES(FL_LAYOUT)),
479 aLineTypeLbl(this, SW_RES(FT_STYLE)),
480 aLineTypeDLB(this, SW_RES(LB_STYLE)),
481 aLineHeightLbl(this, SW_RES(FT_HEIGHT)),
482 aLineHeightEdit(this, SW_RES(ED_HEIGHT)),
483 aLinePosLbl(this, SW_RES(FT_POSITION)),
484 aLinePosDLB(this, SW_RES(LB_POSITION)),
485 aFLLineType(this, SW_RES(FL_LINETYPE)),
487 aVertFL(this, SW_RES(FL_VERT)),
488 aPropertiesFL( this, SW_RES( FL_PROPERTIES )),
489 aTextDirectionFT( this, SW_RES( FT_TEXTDIRECTION )),
490 aTextDirectionLB( this, SW_RES( LB_TEXTDIRECTION )),
492 aPgeExampleWN(this, SW_RES(WN_BSP)),
493 aFrmExampleWN(this, SW_RES(WN_BSP)),
495 pColMgr(0),
497 nFirstVis(0),
498 nMinWidth(MINLAY),
499 pModifiedField(0),
500 bFormat(FALSE),
501 bFrm(FALSE),
502 bHtmlMode(FALSE),
503 bLockUpdate(FALSE)
505 USHORT i;
507 FreeResource();
508 SetExchangeSupport();
510 aDefaultVS.SetHelpId(HID_COLUMN_VALUESET);
511 aDefaultVS.SetColCount( 5 );
512 aDefaultVS.SetStyle( aDefaultVS.GetStyle()
513 | WB_ITEMBORDER
514 | WB_DOUBLEBORDER );
516 for( i = 0; i < 5; i++)
517 aDefaultVS.InsertItem( i + 1, i );
519 aDefaultVS.SetSelectHdl(LINK(this, SwColumnPage, SetDefaultsHdl));
521 // Controls fuer Zusaetzebereich beim MoreButton anmelden
522 Link aCLNrLk = LINK(this, SwColumnPage, ColModify);
523 aCLNrEdt.SetLoseFocusHdl(aCLNrLk);
524 aCLNrEdt.SetUpHdl(aCLNrLk);
525 aCLNrEdt.SetDownHdl(aCLNrLk);
526 Link aLk = LINK(this, SwColumnPage, GapModify);
527 aDistEd1.SetUpHdl(aLk);
528 aDistEd1.SetDownHdl(aLk);
529 aDistEd1.SetLoseFocusHdl(aLk);
530 aDistEd2.SetUpHdl(aLk);
531 aDistEd2.SetDownHdl(aLk);
532 aDistEd2.SetLoseFocusHdl(aLk);
534 aLk = LINK(this, SwColumnPage, EdModify);
536 aEd1.SetUpHdl(aLk);
537 aEd1.SetDownHdl(aLk);
538 aEd1.SetLoseFocusHdl(aLk);
540 aEd2.SetUpHdl(aLk);
541 aEd2.SetDownHdl(aLk);
542 aEd2.SetLoseFocusHdl(aLk);
544 aEd3.SetUpHdl(aLk);
545 aEd3.SetDownHdl(aLk);
546 aEd3.SetLoseFocusHdl(aLk);
548 aBtnUp.SetClickHdl(LINK(this, SwColumnPage, Up));
549 aBtnDown.SetClickHdl(LINK(this, SwColumnPage, Down));
550 aAutoWidthBox.SetClickHdl(LINK(this, SwColumnPage, AutoWidthHdl));
552 aLk = LINK( this, SwColumnPage, UpdateColMgr );
553 aLineTypeDLB.SetSelectHdl( aLk );
554 aLineHeightEdit.SetModifyHdl( aLk );
555 aLinePosDLB.SetSelectHdl( aLk );
557 // Trennlinie
558 aLineTypeDLB.SetUnit( FUNIT_POINT );
559 aLineTypeDLB.SetSourceUnit( FUNIT_TWIP );
560 for( i = 0; i < nLineCount; ++i )
561 aLineTypeDLB.InsertEntry( 100 * nLines[ i ] );
566 SwColumnPage::~SwColumnPage()
568 delete pColMgr;
571 /*--------------------------------------------------------------------
572 Beschreibung:
573 --------------------------------------------------------------------*/
576 void SwColumnPage::SetPageWidth(long nPageWidth)
578 long nNewMaxWidth = static_cast< long >(aEd1.NormalizePercent(nPageWidth));
580 aDistEd1.SetMax(nNewMaxWidth, FUNIT_TWIP);
581 aDistEd2.SetMax(nNewMaxWidth, FUNIT_TWIP);
582 aEd1.SetMax(nNewMaxWidth, FUNIT_TWIP);
583 aEd2.SetMax(nNewMaxWidth, FUNIT_TWIP);
584 aEd3.SetMax(nNewMaxWidth, FUNIT_TWIP);
587 /*--------------------------------------------------------------------
588 Beschreibung:
589 --------------------------------------------------------------------*/
593 void SwColumnPage::Reset(const SfxItemSet &rSet)
595 USHORT nHtmlMode = ::GetHtmlMode((const SwDocShell*)SfxObjectShell::Current());
596 if(nHtmlMode & HTMLMODE_ON)
598 bHtmlMode = TRUE;
599 aAutoWidthBox.Enable(FALSE);
601 FieldUnit aMetric = ::GetDfltMetric(bHtmlMode);
602 SetMetric(aEd1, aMetric);
603 SetMetric(aEd2, aMetric);
604 SetMetric(aEd3, aMetric);
605 SetMetric(aDistEd1, aMetric);
606 SetMetric(aDistEd2, aMetric);
608 delete pColMgr;
609 pColMgr = new SwColMgr(rSet);
610 nCols = pColMgr->GetCount() ;
611 aCLNrEdt.SetMax(Max((USHORT)aCLNrEdt.GetMax(), (USHORT)nCols));
612 aCLNrEdt.SetLast(Max(nCols,(USHORT)aCLNrEdt.GetMax()));
614 if(bFrm)
616 if(bFormat) // hier gibt es keine Size
617 pColMgr->SetActualWidth(FRAME_FORMAT_WIDTH);
618 else
620 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
621 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
622 pColMgr->SetActualWidth((USHORT)rSize.GetSize().Width() - rBox.GetDistance());
625 if(aBalanceColsCB.IsVisible())
627 const SfxPoolItem* pItem;
628 if( SFX_ITEM_SET == rSet.GetItemState( RES_COLUMNBALANCE, FALSE, &pItem ))
629 aBalanceColsCB.Check(!((const SwFmtNoBalancedColumns*)pItem)->GetValue());
630 else
631 aBalanceColsCB.Check( TRUE );
634 //text direction
635 if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( RES_FRAMEDIR ) )
637 const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rSet.Get(RES_FRAMEDIR);
638 sal_uInt32 nVal = rItem.GetValue();
639 USHORT nPos = aTextDirectionLB.GetEntryPos( (void*) nVal );
640 aTextDirectionLB.SelectEntryPos( nPos );
641 aTextDirectionLB.SaveValue();
644 Init();
645 ActivatePage( rSet );
648 /*--------------------------------------------------------------------
649 Beschreibung: TabPage erzeugen
650 --------------------------------------------------------------------*/
654 SfxTabPage* SwColumnPage::Create(Window *pParent, const SfxItemSet &rSet)
656 return new SwColumnPage(pParent, rSet);
659 /*--------------------------------------------------------------------
660 Beschreibung: Attribute in den Set stopfen bei OK
661 --------------------------------------------------------------------*/
665 BOOL SwColumnPage::FillItemSet(SfxItemSet &rSet)
667 if(aCLNrEdt.HasChildPathFocus())
668 aCLNrEdt.GetDownHdl().Call(&aCLNrEdt);
669 // Im ItemSet setzen
670 // Die aktuellen Einstellungen sind
671 // schon vorhanden
673 const SfxPoolItem* pOldItem;
674 const SwFmtCol& rCol = pColMgr->GetColumns();
675 if(0 == (pOldItem = GetOldItem( rSet, RES_COL )) ||
676 rCol != *pOldItem )
677 rSet.Put(rCol);
679 if(aBalanceColsCB.IsVisible() )
681 rSet.Put(SwFmtNoBalancedColumns(!aBalanceColsCB.IsChecked() ));
683 USHORT nPos;
684 if( aTextDirectionLB.IsVisible() &&
685 ( nPos = aTextDirectionLB.GetSelectEntryPos() ) !=
686 aTextDirectionLB.GetSavedValue() )
688 sal_uInt32 nDirection = (sal_uInt32)(sal_IntPtr)aTextDirectionLB.GetEntryData( nPos );
689 rSet.Put( SvxFrameDirectionItem( (SvxFrameDirection)nDirection, RES_FRAMEDIR));
691 return TRUE;
694 /*--------------------------------------------------------------------
695 Beschreibung: ColumnManager updaten
696 --------------------------------------------------------------------*/
700 IMPL_LINK( SwColumnPage, UpdateColMgr, void *, /*pField*/ )
702 long nGutterWidth = pColMgr->GetGutterWidth();
703 if(nCols > 1)
705 // Ermitteln, ob die schmalste Spalte zu schmal ist
706 // fuer den eingestellten Spaltenabstand
707 long nMin = nColWidth[0];
708 USHORT i;
710 for( i = 1; i < nCols; ++i)
711 nMin = Min(nMin, nColWidth[i]);
713 BOOL bAutoWidth = aAutoWidthBox.IsChecked();
714 if(!bAutoWidth)
716 pColMgr->SetAutoWidth(FALSE);
717 // falls der Benutzer nicht die Gesamtbreite vergeben hat,
718 // den fehlenden Betrag auf die letzte Spalte addieren.
719 long nSum = 0;
720 for(i = 0; i < nCols; ++i)
721 nSum += nColWidth[i];
722 nGutterWidth = 0;
723 for(i = 0; i < nCols - 1; ++i)
724 nGutterWidth += nColDist[i];
725 nSum += nGutterWidth;
727 long nMaxW = pColMgr->GetActualSize();
729 if( nSum < nMaxW )
730 nColWidth[nCols - 1] += nMaxW - nSum;
732 pColMgr->SetColWidth( 0, static_cast< USHORT >(nColWidth[0] + (USHORT)nColDist[0]/2) );
733 for( i = 1; i < nCols-1; ++i )
735 long nActDist = (nColDist[i] + nColDist[i - 1]) / 2;
736 pColMgr->SetColWidth( i, (USHORT)nColWidth[i] + (USHORT)nActDist );
738 pColMgr->SetColWidth( nCols-1, static_cast< USHORT >(nColWidth[nCols-1] + nColDist[nCols -2]/2) );
742 // keins ist ausgeschaltet
743 const USHORT nPos = aLineTypeDLB.GetSelectEntryPos();
744 BOOL bEnable = 0 != nPos;
745 aLineHeightEdit.Enable( bEnable );
746 aLineHeightLbl.Enable( bEnable );
747 if( !bEnable )
748 pColMgr->SetNoLine();
749 else if( LISTBOX_ENTRY_NOTFOUND != nPos )
751 pColMgr->SetLineWidthAndColor(nLines[nPos - 1], Color(COL_BLACK) );
752 pColMgr->SetAdjust( SwColLineAdj(
753 aLinePosDLB.GetSelectEntryPos() + 1) );
754 pColMgr->SetLineHeightPercent((short)aLineHeightEdit.GetValue());
755 bEnable = pColMgr->GetLineHeightPercent() != 100;
757 aLinePosLbl.Enable( bEnable );
758 aLinePosDLB.Enable( bEnable );
760 else
762 pColMgr->NoCols();
763 nCols = 0;
766 //Maximalwerte setzen
767 aCLNrEdt.SetMax(Max(1L,
768 Min(long(nMaxCols), long( pColMgr->GetActualSize() / (nGutterWidth + MINLAY)) )));
769 aCLNrEdt.SetLast(aCLNrEdt.GetMax());
770 aCLNrEdt.Reformat();
772 //Beispielfenster anregen
773 if(!bLockUpdate)
775 if(bFrm)
777 aFrmExampleWN.SetColumns( pColMgr->GetColumns() );
778 aFrmExampleWN.Invalidate();
780 else
781 aPgeExampleWN.Invalidate();
784 return 0;
787 /*------------------------------------------------------------------------
788 Beschreibung: Initialisierung
789 ------------------------------------------------------------------------*/
793 void SwColumnPage::Init()
795 aCLNrEdt.SetValue(nCols);
797 BOOL bAutoWidth = pColMgr->IsAutoWidth() || bHtmlMode;
798 aAutoWidthBox.Check( bAutoWidth );
800 sal_Int32 nColumnWidthSum = 0;
801 // Setzen der Breiten
802 USHORT i;
803 for(i = 0; i < nCols; ++i)
805 nColWidth[i] = pColMgr->GetColWidth(i);
806 nColumnWidthSum += nColWidth[i];
807 if(i < nCols - 1)
808 nColDist[i] = pColMgr->GetGutterWidth(i);
811 if( 1 < nCols )
813 // #97495# make sure that the automatic column widht's are always equal
814 if(bAutoWidth)
816 nColumnWidthSum /= nCols;
817 for(i = 0; i < nCols; ++i)
818 nColWidth[i] = nColumnWidthSum;
820 SwColLineAdj eAdj = pColMgr->GetAdjust();
821 if( COLADJ_NONE == eAdj ) // der Dialog kennt kein NONE!
823 eAdj = COLADJ_TOP;
824 //ohne Adjust auch kein Linientyp
825 aLineTypeDLB.SelectEntryPos( 0 );
826 aLineHeightEdit.SetValue( 100 );
828 else
830 aLineTypeDLB.SelectEntryPos( lcl_LineWidthToPos(( pColMgr->GetLineWidth() )) + 1);
831 aLineHeightEdit.SetValue( pColMgr->GetLineHeightPercent() );
833 aLinePosDLB.SelectEntryPos( static_cast< USHORT >(eAdj - 1) );
835 else
837 aLinePosDLB.SelectEntryPos( 0 );
838 aLineTypeDLB.SelectEntryPos( 0 );
839 aLineHeightEdit.SetValue( 100 );
842 UpdateCols();
843 Update();
845 // Maximale Spaltenzahl setzen
846 // Werte kleiner als 1 sind nicht erlaubt
847 aCLNrEdt.SetMax(Max(1L,
848 Min(long(nMaxCols), long( pColMgr->GetActualSize() / nMinWidth) )));
851 /*------------------------------------------------------------------------
852 Beschreibung: Die Anzahl der Spalten hat sich veraendert -- hier werden
853 die Controls fuer die Bearbeitung der Spalten entsprechend
854 der Spaltenzahl en- oder disabled.
855 Falls es mehr als nVisCols (= 3) Spalten gibt, werden
856 alle Edit enabled und die Buttons fuer das Scrollen
857 ebenfalls.
858 Andernfalls werden die Edits jeweils fuer die entsprechenden
859 Spaltenzahl enabled; eine Spalte kann nicht bearbeitet werden.
860 ------------------------------------------------------------------------*/
864 void SwColumnPage::UpdateCols()
866 BOOL bEnableBtns= FALSE;
867 BOOL bEnable12 = FALSE;
868 BOOL bEnable3 = FALSE;
869 const BOOL bEdit = !aAutoWidthBox.IsChecked();
870 if ( nCols > nVisCols )
872 bEnableBtns = TRUE && !bHtmlMode;
873 bEnable12 = bEnable3 = bEdit;
875 else if( bEdit )
877 // hier gibt es absichtlich kaum noch breaks
878 switch(nCols)
880 case 3: bEnable3 = TRUE;
881 case 2: bEnable12= TRUE; break;
882 default: /* do nothing */;
885 aEd1.Enable( bEnable12 );
886 aDistEd1.Enable(nCols > 1);
887 aEd2.Enable( bEnable12 );
888 aDistEd2.Enable(bEnable3);
889 aEd3.Enable( bEnable3 );
890 aLbl1.Enable(bEnable12 );
891 aLbl2.Enable(bEnable12 );
892 aLbl3.Enable(bEnable3 );
893 aBtnUp.Enable( bEnableBtns );
894 aBtnDown.Enable( bEnableBtns );
896 const BOOL bEnable = nCols > 1;
897 if( !bEnable )
899 aLinePosDLB.Enable( FALSE );
900 aLinePosLbl.Enable( FALSE );
902 aLineHeightEdit.Enable( bEnable );
903 aLineHeightLbl.Enable( bEnable );
904 aLineTypeDLB.Enable( bEnable );
905 aLineTypeLbl.Enable( bEnable );
906 aAutoWidthBox.Enable( bEnable && !bHtmlMode );
909 void SwColumnPage::SetLabels( USHORT nVis )
911 String sLbl( '~' );
913 String sLbl2( String::CreateFromInt32( nVis + 1 ));
914 sLbl2.Insert(sLbl, sLbl2.Len() - 1);
915 aLbl1.SetText(sLbl2);
917 sLbl2 = String::CreateFromInt32( nVis + 2 );
918 sLbl2.Insert(sLbl, sLbl2.Len() - 1);
919 aLbl2.SetText(sLbl2);
921 sLbl2 = String::CreateFromInt32( nVis + 3 );
922 sLbl2.Insert(sLbl, sLbl2.Len() - 1);
923 aLbl3.SetText(sLbl2);
926 /*------------------------------------------------------------------------
927 Beschreibung: Handler, der bei einer Veraenderung der Spaltenzahl
928 gerufen wird.
929 Eine Aenderung der Spaltenzahl ueberschreibt eventuelle
930 Breiteneinstellungen des Benutzers; alle Spalten sind
931 gleich breit.
932 ------------------------------------------------------------------------*/
934 IMPL_LINK( SwColumnPage, ColModify, NumericField *, pNF )
936 nCols = (USHORT)aCLNrEdt.GetValue();
937 //#107890# the handler is also called from LoseFocus()
938 //then no change has been made and thus no action should be taken
939 // #i17816# changing the displayed types within the ValueSet
940 //from two columns to two columns with different settings doesn't invalidate the
941 // example windows in ::ColModify()
942 if(!pNF ||(pColMgr->GetCount() != nCols))
944 if(pNF)
945 aDefaultVS.SetNoSelection();
946 long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP)));
947 pColMgr->SetCount(nCols, (USHORT)nDist);
948 for(USHORT i = 0; i < nCols; i++)
949 nColDist[i] = nDist;
950 nFirstVis = 0;
951 SetLabels( nFirstVis );
952 UpdateCols();
953 ResetColWidth();
954 Update();
957 return 0;
960 /*------------------------------------------------------------------------
961 Beschreibung: Modify- Handler fuer eine Aenderung der Spaltenbreite
962 oder des Spaltenabstandes.
963 Diese Aenderungen wirken sich erst zeitversetzt aus.
964 Durch eine Aenderung der Spaltenbreite wird die automatische
965 Berechnung der Spaltenbreite ausser Kraft gesetzt; erst
966 eine Aenderung der Spaltenzahl kehrt wieder zu diesem
967 Default zurueck.
968 ------------------------------------------------------------------------*/
972 IMPL_LINK( SwColumnPage, GapModify, PercentField *, pFld )
974 long nActValue = static_cast< long >(pFld->DenormalizePercent(pFld->GetValue(FUNIT_TWIP)));
975 if(nCols < 2)
976 return 0;
977 if(aAutoWidthBox.IsChecked())
979 USHORT nMaxGap = pColMgr->GetActualSize() - nCols * MINLAY;
980 DBG_ASSERT(nCols, "Abstand kann nicht ohne Spalten eingestellt werden");
981 nMaxGap /= nCols - 1;
982 if(nActValue > nMaxGap)
984 nActValue = nMaxGap;
985 aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nMaxGap), FUNIT_TWIP);
987 pColMgr->SetGutterWidth((USHORT)nActValue);
988 for(USHORT i = 0; i < nCols; i++)
989 nColDist[i] = nActValue;
991 ResetColWidth();
992 UpdateCols();
994 else
997 USHORT nOffset = 0;
998 if(pFld == &aDistEd2)
1000 nOffset = 1;
1002 long nDiff = nActValue - nColDist[nFirstVis + nOffset];
1003 if(nDiff)
1005 long nLeft = nColWidth[nFirstVis + nOffset];
1006 long nRight = nColWidth[nFirstVis + nOffset + 1];
1007 if(nLeft + nRight + 2 * MINLAY < nDiff)
1008 nDiff = nLeft + nRight - 2 * MINLAY;
1009 if(nDiff < nRight - MINLAY)
1011 nRight -= nDiff;
1013 else
1015 long nTemp = nDiff - nRight + MINLAY;
1016 nRight = MINLAY;
1017 if(nLeft > nTemp - MINLAY)
1019 nLeft -= nTemp;
1020 nTemp = 0;
1022 else
1024 nTemp -= nLeft + MINLAY;
1025 nLeft = MINLAY;
1027 nDiff = nTemp;
1029 nColWidth[nFirstVis + nOffset] = nLeft;
1030 nColWidth[nFirstVis + nOffset + 1] = nRight;
1031 nColDist[nFirstVis + nOffset] += nDiff;
1033 pColMgr->SetColWidth( nFirstVis + nOffset, USHORT(nLeft) );
1034 pColMgr->SetColWidth( nFirstVis + nOffset + 1, USHORT(nRight) );
1035 pColMgr->SetGutterWidth( USHORT(nColDist[nFirstVis + nOffset]), nFirstVis + nOffset );
1039 Update();
1040 return 0;
1043 /*------------------------------------------------------------------------
1044 Beschreibung:
1045 ------------------------------------------------------------------------*/
1049 IMPL_LINK( SwColumnPage, EdModify, PercentField *, pField )
1051 pModifiedField = pField;
1052 Timeout(0);
1053 return 0;
1055 /*------------------------------------------------------------------------
1056 Beschreibung: Handler hinter der Checkbox fuer automatische Breite.
1057 Ist die Box gecheckt, koennen keine expliziten Werte
1058 fuer die Spaltenbreite eingegeben werden.
1059 ------------------------------------------------------------------------*/
1063 IMPL_LINK( SwColumnPage, AutoWidthHdl, CheckBox *, pBox )
1065 long nDist = static_cast< long >(aDistEd1.DenormalizePercent(aDistEd1.GetValue(FUNIT_TWIP)));
1066 pColMgr->SetCount(nCols, (USHORT)nDist);
1067 for(USHORT i = 0; i < nCols; i++)
1068 nColDist[i] = nDist;
1069 if(pBox->IsChecked())
1071 pColMgr->SetGutterWidth(USHORT(nDist));
1072 ResetColWidth();
1074 pColMgr->SetAutoWidth(pBox->IsChecked(), USHORT(nDist));
1075 UpdateCols();
1076 Update();
1077 return 0;
1080 /*------------------------------------------------------------------------
1081 Beschreibung: Raufscrollen der Inhalte der Edits.
1082 ------------------------------------------------------------------------*/
1084 IMPL_LINK( SwColumnPage, Up, Button *, EMPTYARG )
1086 if( nFirstVis )
1088 --nFirstVis;
1089 SetLabels( nFirstVis );
1090 Update();
1092 return 0;
1094 /*------------------------------------------------------------------------
1095 Beschreibung: Runterscrollen der Inhalte der Edits.
1096 ------------------------------------------------------------------------*/
1098 IMPL_LINK( SwColumnPage, Down, Button *, EMPTYARG )
1100 if( nFirstVis + nVisCols < nCols )
1102 ++nFirstVis;
1103 SetLabels( nFirstVis );
1104 Update();
1106 return 0;
1108 /*------------------------------------------------------------------------
1109 Beschreibung: Relikt aus alten Zeiten - jetzt direkt ohne time
1110 * Timer- Handler; angetriggert durch eine Aenderung der
1111 Spaltenbreite oder des Spaltenabstandes.
1112 ------------------------------------------------------------------------*/
1114 IMPL_LINK( SwColumnPage, Timeout, Timer *, EMPTYARG )
1116 DBG_PROFSTART(columnhdl) ;
1117 if(pModifiedField)
1119 // Finden der veraenderten Spalte
1120 USHORT nChanged = nFirstVis;
1121 if(pModifiedField == &aEd2)
1122 ++nChanged;
1123 else if(pModifiedField == &aEd3)
1124 nChanged += 2;
1125 /*else if(pModifiedField == &aEd4)
1126 nChanged += 3;*/
1128 long nNewWidth = (USHORT)
1129 pModifiedField->DenormalizePercent(pModifiedField->GetValue(FUNIT_TWIP));
1130 long nDiff = nNewWidth - nColWidth[nChanged];
1132 // wenn es die letzte Spalte ist
1133 if(nChanged == nCols - 1)
1135 nColWidth[0] -= nDiff;
1136 if(nColWidth[0] < (long)nMinWidth)
1138 nNewWidth -= nMinWidth - nColWidth[0];
1139 nColWidth[0] = nMinWidth;
1143 else if(nDiff)
1145 nColWidth[nChanged + 1] -= nDiff;
1146 if(nColWidth[nChanged + 1] < (long) nMinWidth)
1148 nNewWidth -= nMinWidth - nColWidth[nChanged + 1];
1149 nColWidth[nChanged + 1] = nMinWidth;
1152 nColWidth[nChanged] = nNewWidth;
1153 pModifiedField = 0;
1155 Update();
1156 DBG_PROFSTOP(columnhdl) ;
1157 return 0;
1159 /*------------------------------------------------------------------------
1160 Beschreibung: Aktualisierung der Anzeige
1161 ------------------------------------------------------------------------*/
1165 void SwColumnPage::Update()
1167 aBalanceColsCB.Enable(nCols > 1);
1168 if(nCols >= 2)
1170 aEd1.SetPrcntValue(aEd1.NormalizePercent(nColWidth[nFirstVis]), FUNIT_TWIP);
1171 aDistEd1.SetPrcntValue(aDistEd1.NormalizePercent(nColDist[nFirstVis]), FUNIT_TWIP);
1172 aEd2.SetPrcntValue(aEd2.NormalizePercent(nColWidth[nFirstVis + 1]), FUNIT_TWIP);
1173 if(nCols >= 3)
1175 aDistEd2.SetPrcntValue(aDistEd2.NormalizePercent(nColDist[nFirstVis + 1]), FUNIT_TWIP);
1176 aEd3.SetPrcntValue(aEd3.NormalizePercent(nColWidth[nFirstVis + 2]), FUNIT_TWIP);
1178 else
1180 aEd3.SetText(aEmptyStr);
1181 aDistEd2.SetText(aEmptyStr);
1184 else
1186 aEd1.SetText(aEmptyStr);
1187 aEd2.SetText(aEmptyStr);
1188 aEd3.SetText(aEmptyStr);
1189 aDistEd1.SetText(aEmptyStr);
1190 aDistEd2.SetText(aEmptyStr);
1192 UpdateColMgr(0);
1195 /*--------------------------------------------------------------------
1196 Beschreibung: Update Bsp
1197 --------------------------------------------------------------------*/
1201 void SwColumnPage::ActivatePage(const SfxItemSet& rSet)
1203 if(!bFrm)
1205 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_PAGE_SIZE ))
1207 const SvxSizeItem& rSize = (const SvxSizeItem&)rSet.Get(
1208 SID_ATTR_PAGE_SIZE);
1209 const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)rSet.Get(
1210 RES_LR_SPACE );
1211 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
1212 USHORT nActWidth = static_cast< USHORT >(rSize.GetSize().Width()
1213 - rLRSpace.GetLeft() - rLRSpace.GetRight() - rBox.GetDistance());
1215 if( pColMgr->GetActualSize() != nActWidth)
1217 pColMgr->SetActualWidth(nActWidth);
1218 ColModify( 0 );
1219 UpdateColMgr( 0 );
1222 aFrmExampleWN.Hide();
1223 aPgeExampleWN.UpdateExample( rSet, pColMgr );
1224 aPgeExampleWN.Show();
1227 else
1229 aPgeExampleWN.Hide();
1230 aFrmExampleWN.Show();
1232 // Size
1233 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)rSet.Get(RES_FRM_SIZE);
1234 const SvxBoxItem& rBox = (const SvxBoxItem&) rSet.Get(RES_BOX);
1236 long nDistance = rBox.GetDistance();
1237 const USHORT nTotalWish = bFormat ? FRAME_FORMAT_WIDTH : USHORT(rSize.GetWidth() - 2 * nDistance);
1239 // Maximalwerte der Spaltenbreiten setzen
1240 SetPageWidth(nTotalWish);
1242 if(pColMgr->GetActualSize() != nTotalWish)
1244 pColMgr->SetActualWidth(nTotalWish);
1245 Init();
1247 BOOL bPercent;
1248 // im Rahmenformat nur relative Angaben
1249 if ( bFormat || (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) )
1251 // Wert fuer 100% setzen
1252 aEd1.SetRefValue(nTotalWish);
1253 aEd2.SetRefValue(nTotalWish);
1254 aEd3.SetRefValue(nTotalWish);
1255 aDistEd1.SetRefValue(nTotalWish);
1256 aDistEd2.SetRefValue(nTotalWish);
1258 // Auf %-Darstellung umschalten
1259 bPercent = TRUE;
1261 else
1262 bPercent = FALSE;
1264 aEd1.ShowPercent(bPercent);
1265 aEd2.ShowPercent(bPercent);
1266 aEd3.ShowPercent(bPercent);
1267 aDistEd1.ShowPercent(bPercent);
1268 aDistEd2.ShowPercent(bPercent);
1269 aDistEd1.MetricField::SetMin(0);
1270 aDistEd2.MetricField::SetMin(0);
1272 Update();
1275 /*--------------------------------------------------------------------
1276 Beschreibung:
1277 --------------------------------------------------------------------*/
1281 int SwColumnPage::DeactivatePage(SfxItemSet *_pSet)
1283 if(_pSet)
1284 FillItemSet(*_pSet);
1286 return TRUE;
1291 USHORT* SwColumnPage::GetRanges()
1293 return aPageRg;
1296 /*--------------------------------------------------------------------
1297 Beschreibung:
1298 --------------------------------------------------------------------*/
1302 IMPL_LINK( SwColumnPage, SetDefaultsHdl, ValueSet *, pVS )
1304 USHORT nItem = pVS->GetSelectItemId();
1305 if( nItem < 4 )
1307 aCLNrEdt.SetValue( nItem );
1308 aAutoWidthBox.Check();
1309 aDistEd1.SetPrcntValue(0);
1310 ColModify(0);
1312 else
1314 bLockUpdate = TRUE;
1315 aCLNrEdt.SetValue( 2 );
1316 aAutoWidthBox.Check(FALSE);
1317 aDistEd1.SetPrcntValue(0);
1318 ColModify(0);
1319 // jetzt noch das Breitenverhaeltnisse auf 2 : 1 bzw. 1 : 2 stellen
1320 USHORT nSmall = pColMgr->GetActualSize() / 3;
1321 if(nItem == 4)
1323 aEd2.SetPrcntValue(aEd2.NormalizePercent(long(nSmall)), FUNIT_TWIP);
1324 pModifiedField = &aEd2;
1326 else
1328 aEd1.SetPrcntValue(aEd1.NormalizePercent(long(nSmall)), FUNIT_TWIP);
1329 pModifiedField = &aEd1;
1331 bLockUpdate = FALSE;
1332 Timeout(0);
1335 return 0;
1338 /*-----------------25.10.96 11.41-------------------
1340 --------------------------------------------------*/
1343 void SwColumnPage::SetFrmMode(BOOL bMod)
1345 bFrm = bMod;
1347 /* -----------------------------2002/06/19 13:08------------------------------
1349 ---------------------------------------------------------------------------*/
1350 void SwColumnPage::SetInSection(BOOL bSet)
1352 if(!SW_MOD()->GetCTLOptions().IsCTLFontEnabled())
1353 return;
1355 aVertFL.Show(bSet);
1356 aPropertiesFL.Show(bSet);
1357 aTextDirectionFT.Show(bSet);
1358 aTextDirectionLB.Show(bSet);
1359 if(bSet)
1361 //resize line type FixedLine
1362 Point aLtPos = aFLLineType.GetPosPixel();
1363 Point aPropPos = aPropertiesFL.GetPosPixel();
1364 Size aSz = aFLLineType.GetSizePixel();
1365 aSz.Width() = aPropPos.X() - aLtPos.X() - LogicToPixel(Size(8, 8), MAP_APPFONT).Width();
1366 aFLLineType.SetSizePixel(aSz);
1368 else
1370 Size aSz = aFLLineType.GetSizePixel();
1371 aSz.Width() = LogicToPixel(Size(248, 248), MAP_APPFONT).Width();
1372 aFLLineType.SetSizePixel(aSz);
1376 /*-----------------07.03.97 08.33-------------------
1378 --------------------------------------------------*/
1381 void ColumnValueSet::UserDraw( const UserDrawEvent& rUDEvt )
1383 OutputDevice* pDev = rUDEvt.GetDevice();
1384 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1386 Rectangle aRect = rUDEvt.GetRect();
1387 USHORT nItemId = rUDEvt.GetItemId();
1388 long nRectWidth = aRect.GetWidth();
1389 long nRectHeight = aRect.GetHeight();
1391 Point aBLPos = aRect.TopLeft();
1392 Color aFillColor(pDev->GetFillColor());
1393 Color aLineColor(pDev->GetLineColor());
1394 pDev->SetFillColor(rStyleSettings.GetFieldColor());
1395 pDev->SetLineColor(SwViewOption::GetFontColor());
1397 long nStep = Abs(Abs(nRectHeight * 95 /100) / 11);
1398 long nTop = (nRectHeight - 11 * nStep ) / 2;
1399 USHORT nCols = 0;
1400 long nStarts[3];
1401 long nEnds[3];
1402 nStarts[0] = nRectWidth * 10 / 100;
1403 switch( nItemId )
1405 case 1:
1406 nEnds[0] = nRectWidth * 9 / 10;
1407 nCols = 1;
1408 break;
1409 case 2: nCols = 2;
1410 nEnds[0] = nRectWidth * 45 / 100;
1411 nStarts[1] = nEnds[0] + nStep;
1412 nEnds[1] = nRectWidth * 9 / 10;
1413 break;
1414 case 3: nCols = 3;
1415 nEnds[0] = nRectWidth * 30 / 100;
1416 nStarts[1] = nEnds[0] + nStep;
1417 nEnds[1] = nRectWidth * 63 / 100;
1418 nStarts[2] = nEnds[1] + nStep;
1419 nEnds[2] = nRectWidth * 9 / 10;
1420 break;
1421 case 4: nCols = 2;
1422 nEnds[0] = nRectWidth * 63 / 100;
1423 nStarts[1] = nEnds[0] + nStep;
1424 nEnds[1] = nRectWidth * 9 / 10;
1425 break;
1426 case 5: nCols = 2;
1427 nEnds[0] = nRectWidth * 30 / 100;
1428 nStarts[1] = nEnds[0] + nStep;
1429 nEnds[1] = nRectWidth * 9 / 10;
1430 break;
1432 for(USHORT j = 0; j < nCols; j++ )
1434 Point aStart(aBLPos.X() + nStarts[j], 0);
1435 Point aEnd(aBLPos.X() + nEnds[j], 0);
1436 for( USHORT i = 0; i < 12; i ++)
1438 aStart.Y() = aEnd.Y() = aBLPos.Y() + nTop + i * nStep;
1439 pDev->DrawLine(aStart, aEnd);
1442 pDev->SetFillColor(aFillColor);
1443 pDev->SetLineColor(aLineColor);
1446 /*-----------------07.03.97 08.48-------------------
1448 --------------------------------------------------*/
1450 ColumnValueSet::~ColumnValueSet()
1453 /* -----------------------------02.04.2002 16:01------------------------------
1455 ---------------------------------------------------------------------------*/
1456 void ColumnValueSet::DataChanged( const DataChangedEvent& rDCEvt )
1458 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
1459 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1461 Format();
1463 ValueSet::DataChanged( rDCEvt );