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